Hi all,
With ROOT 5.10/00, I construct two TH1Ds, apply ::Sumw2() on them, fill them with entries of various weights, try to divide one of the TH1Ds by the other (ResultingTH1D.Divide(…,…,1.,1.,“b”)), get ResultingTH1D which is empty.
When I save the 2 inital filled TH1Ds in a .root, retrieve them from the .root file and make the division operation, ResultingTH1D is filled but the weights applied on the events seem to be not considered when building the error bars.
histosDIV.C computes the division of a TH1D by another one.
I observe that the vertical error bars of the ResultingTH1D when using ROOT 5.10 and 5.14 are slightly different. With the first version, the error bars are equal to the error bars when weights are not considered.
May I rely on the error bars by ROOT 5.14?
Each inital TH1D was filled with various weights.
With both versions, when I construct the two initial TH1Ds, apply ::Sumw2() on them, fill them with entries of various weights, try to divide one of the TH1Ds by the other (ResultingTH1D.Divide(…,…,1.,1.,“b”)) in a same .C (without retrieving the TH1Ds from a .root file), ResultingTH1D is empty.
Cheers,
Ludovic histosDIV.C (3.18 KB) histos.root (6.65 KB)
You must call TH1::Sumw2 on at least on your histograms before making the division.
see modified file in the attachment
see doc of TH1::Divide at: root.cern.ch/root/html/TH1.html#TH1:Divide
I called TH1::Sumw2 on the inital histograms before filling them.
When I call TH1::Sumw2 on the histogram which will contain the result of the division of an initial histogram by another one, then error bars are the same as before (when TH1::Sumw2 not called).
Ludovic
division of weighted histograms with binomial statistics (option “b”) has been implemented only since ROOT version 5.14. In older vrsions errors are the same as when weights are not considered (as you noticed).
Isn’t
fSumw2.fArray[bin] = TMath::Abs( ( (1-2w)e1e1 + wwe2e2 )/(b2*b2) ); (with e1 and e2 the bin errors for histogram 1 and 2)
correct in case of entries in an initial histogram with a constant weight, uncorrect in case (my case) the weights of the entries in the histogram vary?
Why the following behaviour? ->
With ROOT 5.10 and ROOT 5.14, when I construct the two initial TH1Ds, apply ::Sumw2() on them, fill them with entries of various weights, try to divide one of the TH1Ds by the other (ResultingTH1D.Divide(…,…,1.,1.,“b”)) in a same .C (without retrieving the TH1Ds from a .root file), ResultingTH1D is empty.