Attempt to divide histograms with different bin limits


Given two histograms (TH1F) that have the same number of bins, same bin widths and same lower edges for all bins and the underflow and overflow, calling Divide causes:

Warning in TH1F::Divide: Attempt to divide histograms with different bin limits

The divide appears to work as expected. Other than reading the ROOT TH C++ code, does someone have a suggestion as to what else could be checked? One histogram was created with an array of bins and the other was created with the number of bins constructor. Could this cause the warning?

Thanks and best regards,



I have found the answer, by reading the TH1 C++ code. The TH1 Divide function calls TH1::CheckBinLabels(const TAxis* a1, const TAxis * a2) which reports the problem

When the histogram is created using an array of lower bin edges, then

const TArrayD * h2Array = hist->GetXaxis()->GetXbins();

returns the number of lower bin edges. When the histogram is created with a number of bins, then the fN value is zero. In both cases, the bin dimensions themselves are exactly the same, but the code produces a warning.

Best regards,



It makes no sense whatsoever that making a histogram by using the number of bins and the upper + lower limits gives a histogram that is incompatible with using the same binning, but through an array of boundaries.

This makes ROOT refuse to divide two histograms that are perfectly compatible and is a bug. Why hasn’t anyone done anything about this since 2014?


Hi @rooter_03,
sorry for the late reply. Typically we encourage opening new threads rather than replying to very old ones.

In any case, note that the Divide works fine, with the undesired side-effect that a warning (safe to ignore if you know what you are doing) is printed (the warning can also be suppressed by setting gErrorIgnoreLevel appropriately).

I am not sure there is a bug report about the spurious warning, feel free to open one at .