ROOT file bin thresh changed w/ IsVariabeBinSize(), but FindBin() still returning old thresh

ROOT Version: 6.06.01
Platform: Ubuntu 16.04
Compiler: gcc530

Hi, I recently changed the my root file’s hist’s Y axis() threshold from 20.0->12.0 with help of the two links below.

Following the answers above with the code,

(bool) true
(*(TArrayD*)NUM_LooseID_DEN_genTracks_eta_pt->GetYaxis()->GetXbins())[0] = 12.; 

for ROOT fileRunGH_SF_ID.root (16.2 KB), which changed into Run_SF_ID.root (15.7 KB).

When I look at the Second bin’s lower Edge with GetBinLowEdge(), It shows expected behavior with RunGH_SF_ID.root showing 20, Run_SF_ID.root showing 12.

root [3] NUM_LooseID_DEN_genTracks_eta_pt->GetYaxis()->GetBinLowEdge(1)
(Double_t) 12.0000

However, my code tries to get content of bin using this mechanism.

 Int_t tmpbinx       = your_histogram->GetXaxis()->FindBin( mueta );
   Int_t tmpbiny       = your_histogram->GetYaxis()->FindBin( mupt  );
   Int_t tmpbin        = your_histogram->GetBin( tmpbinx, tmpbiny );
   tmpweight = your_histogram-->GetBinContent(tmpbin);}

However, when I use the FindBin() function at 12.0 for Run_SF_ID.root, it gives me the value of 0 instead of 1, which is the supposed value for my hist w/ the new threshold.

root [2] NUM_LooseID_DEN_genTracks_eta_pt->GetYaxis()->FindBin(12)
(Int_t) 0

It returns the value of 1, only when it is above 20, which was the original threshold.
What is happening and how can I fix the bug?

Thank you!

Maybe I’m mistaken, or @couet can give more details, but when drawing your histogram in 3D, it looks like the first bin (0) starts at 12 and ends at 20. Or did I miss something?

You need to apply an additional fix:

// one must set the new proper "xmin" and "xmax" for this axis
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.