When you divide two histograms, ratio is calculated and error is also calculated as the ratio of errors of data and reference. Which is wrong as you also know because the calculation is not considering error propagation.

I realized that if the histograms are declared, filled or bin contents and error are set in the script, division works fine. If the bin content is given only but not bin error, then it works only if you call Sumw2 function before you divide the histogram.

Here comes the problem. When you retrieve histograms from a root file, clone data histogram into another histogram and divide, you realize that division is not working even if you call Sumw2 function before the division.
I was wondering if this is a known issue and/or has any fixes.

Here you can find four different methods to produce ratio and errors.

Plot at the top is the data and reference that I used to find the ratio.
At the bottom, there 4 ratio plots:

Ratio plot: After getting histogram from root file, I have cloned it into another histogram by using Clone function and divided by reference.
As you can see, errors of ratio histogram are being calculated automatically as the ratio of errors of data and reference which is wrong.

Ratio plot: This time I have called Sumw2 function for the data, reference and cloned histogram before I divide.
But it seems Sumw2 is not working as expected. Errors are being calculated in a wrong again.
And I see this warning because of the Sumw2 function called by the clone histogram.
“Warning in TProfile::Divide: Cannot preserve during the division of profiles the sum of bin weight square”

Ratio Plot: Here, Instead of using Clone function, I have cloned the data with a loop. I have assigned bin contents and bin errors of data histogram to another histogram and divided by the reference.
Resulting errors of the ratio histogram are as expected. This methods works fine.

Ratio Plot: This plot was just to see the correct results of error propagation. I have set bin contents of this histogram by calculating the ratio of data and reference. Bin errors are calculated by using the error propagation formula.

Thanks a lot in advance.

ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided

Note that, with the TRatioPlot, you can use different “error options”, e.g. “pois” (the default), “divsym”, “diffsig” (with “errasym” or “errfunc”), “diff”, “cp”.

TRatioPlot did not solve this problem, errors on default option are nonsense. Also tried other options and calling Sumw2 on histograms but none of them showed the results same as the error propagation.

This is a bit odd. I have an example where I retrieve two histograms from root files, then do Sumw2() for each of them, clone the first one, and then Divide() this clone by the second one. The uncertainties of the ratio histogram are fine. At least in ROOT 5.30.06.

Errors on division histogram are correct? I mean error propagation is considered? In my case errors on the ratio histogram are just calculated as the ratio of errors of data and reference.

Thanks for the answers guys. After your guidance, I have tested some more samples and saw that its working for TH1 files from the root file. Even if you do not call Sumw2. And it made me realize that the object I was retrieving at first was not TH1, it was TProfile. Hence it was needed to run ProjectionX() function before division. So thats why when I get it as TH1 it draws but errors were miscalculated. Thanks a lot for your helps to clear this out for me.