EDIT: NEVERMIND, as usual, 5 minutes after posting this question, I kept looking and found TAxis::IsVariableBinSize(). Mods can delete this post if they want.
Hi, I’m wondering how to determine programmatically if a given TH1 has variable bins or fixed bins. In the TH1 member functions (e.g. FindFixBin), the code accesses private members to determine this, and I was unable to find a workaround using public members and methods. I know the TH1 class is supposed to mostly hide the difference from the user when filling & drawing, but it should still be possible to find out somehow…
Try to call:
histo->GetXaxis()->GetXbins()->GetSize()
histo->GetYaxis()->GetXbins()->GetSize()
histo->GetZaxis()->GetXbins()->GetSize()
and if such a call returns non-zero value then this axis has “variable bins”.
There is a logic bug in TAxis::IsVariableBinSize. The histogram might have been created with an array of bin edges where the edges are equidistant. Therefore it is not sufficient to check for the existence of the bin array to decide whether the bin size is constant or not.