Hi All,
I am trying to generate a 2D histogram from an ntuple using the ttree->Draw() function, including the “e” option which is supposed to turn on Sumw2() for the histogram and correctly tabulate the weights. This works fine when I use it on 1D histograms but when I inspect the errors on the bin contents of a 2D histogram created with this same method, it seems like Sumw2() is never called. I include attached here an example dummy code that creates a simple ttree, and then draws a 1D and 2D histogram with the “e” option, and finally inspects the bin contents and their errors. The output that should be produced from this code is pasted below. From this you can see that in the second case, the bin error is just being taken as the square root of the bin contents, not as it should be.
Is there some additional option that must be supplied for 2D histograms to obtain this functionality, or is this a failure of root?
I should also note, I have read in the documentation that one can generate a TProfile2D from ttree draw that does save bin errors, but I dont think that generating a TProfile2D will give me the same desired result as a TH2D for my use.
Thanks,
Sam
====================
SamMeehanMacBook-150:Phase_2_Tagging_MassCut2VarMVA meehan$ root TestCode.C
root [0]
Processing TestCode.C…
Filling Entry: val=2 weight=0.1
Filling Entry: val=2 weight=0.1
Filling Entry: val=2 weight=0.2
CorrectBinError:
0.244949
1D HIST
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1
h1: BinNumber=0 BinContent=0 BinError=0
h1: BinNumber=1 BinContent=0 BinError=0
h1: BinNumber=2 BinContent=0 BinError=0
h1: BinNumber=3 BinContent=0.4 BinError=0.244949
h1: BinNumber=4 BinContent=0 BinError=0
2D HIST
h1: BinNumber(X)=0 BinNumber(Y)=0 BinContent=0 BinError=0
h1: BinNumber(X)=0 BinNumber(Y)=1 BinContent=0 BinError=0
h1: BinNumber(X)=0 BinNumber(Y)=2 BinContent=0 BinError=0
h1: BinNumber(X)=0 BinNumber(Y)=3 BinContent=0 BinError=0
h1: BinNumber(X)=0 BinNumber(Y)=4 BinContent=0 BinError=0
h1: BinNumber(X)=1 BinNumber(Y)=0 BinContent=0 BinError=0
h1: BinNumber(X)=1 BinNumber(Y)=1 BinContent=0 BinError=0
h1: BinNumber(X)=1 BinNumber(Y)=2 BinContent=0 BinError=0
h1: BinNumber(X)=1 BinNumber(Y)=3 BinContent=0 BinError=0
h1: BinNumber(X)=1 BinNumber(Y)=4 BinContent=0 BinError=0
h1: BinNumber(X)=2 BinNumber(Y)=0 BinContent=0 BinError=0
h1: BinNumber(X)=2 BinNumber(Y)=1 BinContent=0 BinError=0
h1: BinNumber(X)=2 BinNumber(Y)=2 BinContent=0 BinError=0
h1: BinNumber(X)=2 BinNumber(Y)=3 BinContent=0 BinError=0
h1: BinNumber(X)=2 BinNumber(Y)=4 BinContent=0 BinError=0
h1: BinNumber(X)=3 BinNumber(Y)=0 BinContent=0 BinError=0
h1: BinNumber(X)=3 BinNumber(Y)=1 BinContent=0 BinError=0
h1: BinNumber(X)=3 BinNumber(Y)=2 BinContent=0 BinError=0
h1: BinNumber(X)=3 BinNumber(Y)=3 BinContent=0.4 BinError=0.632456
h1: BinNumber(X)=3 BinNumber(Y)=4 BinContent=0 BinError=0
h1: BinNumber(X)=4 BinNumber(Y)=0 BinContent=0 BinError=0
h1: BinNumber(X)=4 BinNumber(Y)=1 BinContent=0 BinError=0
h1: BinNumber(X)=4 BinNumber(Y)=2 BinContent=0 BinError=0
h1: BinNumber(X)=4 BinNumber(Y)=3 BinContent=0 BinError=0
h1: BinNumber(X)=4 BinNumber(Y)=4 BinContent=0 BinError=0
root [1]
TestCode.C (2.11 KB)