Determine if TH1 has variable bins or not

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…

Thanks,
Jean-François

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.

“Variable bin size” means that the user provided his/her own bin edges. It does NOT matter at all if the provided edges are equidistant or not.

Ah so the logic bug is in the assumption that variable bin size means non-equidistant bin edges. Ive seen people use it like that.