Divide using tprofile

How does one divide two profile histograms and get proper errors (in errors in quadrature)?

thanks,
Donna

Donna,

If you have TProfile *p1, *p2, you can divide p1 by p2 (with results in p1)
with
p1->Divide(p2);

Note that there is a second function
TProfile::Divide(p1,p2,c1,c2,option)
If you use this general function, you will a message indicating
that the algorithm is certainly wrong. I hope to find a volunteer to
investigate this problem.

Rene

Thanks Rene,

I have done as you suggested and it works for the ratios however the
errors on the plot are not correct. They are very large and not meaningful.
How does one get the errors to be the bin by bin errors in quadrature?

I have found this problem in general with profile plot- for example, I am trying
to perform a linear fit to the plot. The fit reports the chisquare =0, as if the
errors are being ignored. Any suggestions on this problem.
Thanks for your help!
-Donna

Hi,

I am having the same problem mentioned in this post.
I get the following warning:
Warning in TProfile::Divide: Cannot preserve during the division of profiles the sum of bin weight square

Thanks in advance for any help.
Hermes

Hi,

this message means, that, if you have profile classes filled with weights (i.e. when TProfile::Sumw2() has been set), the error resulting from the devision will not be corrected, since we do not support a correct treatment of the weights during the division of TProfile classes.
Best Regards

Lorenzo

Hi,

Thanks for the answer. Actually what I do is to create a TProfile
starting from a TH2F that was filled with weights.

Is there any way I can obtain a ratio of TProfiles with error bars,
creating the TProfiles from projections TH2’s that had been set with Sumw2 ?

Many thanks in advance,
Hermes

Yes, you should be able to divide the TH2 histograms and then later project into a TProfile

Lorenzo

Hi,

Thanks for your answer. However I think that what you suggest
does not work, because I am trying to calculate the ratio of mean
values, and not the mean value of the ratio.

Hermes

Hi,

In this case, you must divide the 1D histograms and not the profiles, thus do, if p1 and p2 are your profiles :

TProfile * p1 = .....
TProfile * p2 = .....
TH1D *h1 = p1->ProjectionX();
TH1D *h1 = p1->ProjectionX();
h1->Divide(h2);

Lorenzo

Thanks a lot! This is exactly what I wanted.

Hermes

Hi Everyone,

I have a problem similar to this one, and I couldn’t solve it using the way that described here. In my case, I have a TH2D, and I get a profile like the following:

h1 = p1TH2D.ProfileX()
h2 = p2TH2D.ProfileX()

I plot those two histograms on a canvas, there’s no problem with that.
So I got what I want on the y-axis (RMS). However, the problem comes when dividing
these two histograms like:

h1.Divide(h2)

The problem is the error on the ratio plot is huge when I compare it to the individual error of the main histograms. Please can someone help?

Thanks

Cheers,
Abdualazem.

Hi,
As explained in the post above, you should not divide the two profiles if you want the ratio of the mean values, but the corresponding 1D histograms. Do:

h1 = p1TH2D.ProfileX();
h2 = p2TH2D.ProfileX();
histX1 = h1->ProjectionX(); 
histX2 = h2->ProjectionX();;
histX1.Divide(histX2); 

Lorenzo