Division of THnSparse histograms - wrong value

Dear ROOT Experts,

I am trying to divide two THnSparseF histograms in the following method:

  TFile *f1 = new TFile("histos.root");
  
  THnSparseF *fTHGeneratedEff = ccontainer0->FindObject("fTHnGeneratedEff");
  THnSparseF *fTHnReconstructedEff = ccontainer0->FindObject("fTHnReconstructedEff");

  const Int_t nDims = 4;
  Int_t fBins[nDims] = {15, 10, 16, 100 };
  Double_t fMin[nDims] = { 0.0, -10.0, -0.8, 0.0};
  Double_t fMax[nDims] = { 100.0, 10.0, 0.8, 30};
 
  const Int_t nVarBins0 = 15;
  Double_t varBins0[nVarBins0+1] = {0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100};
  
  THnSparseF *fTHnEff = new THnSparseF("fTHnEff","Cent-zVtx-Eta-pT", nDims, fBins, fMin, fMax);
  fTHnEff->GetAxis(0)->Set(nVarBins0, varBins0); 
  
  fTHnEff->Divide(fTHnReconstructedEff, fTHGeneratedEff, 1., 1.,"b");

  TFile *file = new TFile("THnEfficiency.root", "RECREATE");
  fTHnEff->Write();

But, the resulting thnsparse I get has wrong entries. I have attached the root files containing the thnsparse I divide, as well as the thnsparse after division.
Histos.root (1.21 MB)
THnEfficiency.root (759 KB)

Thanks for any help :slight_smile:

Dear greeshma, did you found the solution for your problem? If so, please let me know, I am having same problem.

Hey,

this post is 7 years old, so ROOT might have changed quite a bit in the mean time. If you think that there’s a bug, could you open a new thread, and describe the problem in more detail?
Please include the ROOT version you are using, and decribe why you think exactly that it’s wrong (this is unfortunately missing in the initial post).
In the best case, include also the code that demonstrates the problem, so people can test it straight away.