Sumw2 method for weighted histogram


ROOT Version: 6.06/01
Platform: Ubuntu 16.04
Compiler: gcc530


Hello, root experts.

I have a question for usage of Sumw2 function in my situation.

At the moment, I am filling my histogram in given way

sample ='ZH_HToSSTobbbb_ZToLL_MH-125_MS-15_ctauS-10 & 5'
h16 = TH1F("Decaydist",'%s Decaydist' % sample,100, 0, 100)
h16w = TH1F("Decaydistw",'%s Decaydistw' % sample,100, 0, 100)
h16w.Sumw2()
h16s = TH1F("ctauEventWeight",'%s ctauEventWeight' % sample,80, 0, 4)
DY16dir=glob.glob('path/0000/*')
for i in range (7):
        filename = DY16dir[i]
        _file0 = TFile.Open(filename,'read')
        mytree16 = _file0.Get("lldjNtuple/EventTree")
        for entry in mytree16:
                ctau = mytree16.ctauEventWeight
                h16s.Fill(ctau[0],1)
                #print(ctau[0]) 
                Decaydist=mytree16.AODnVtx
                h16.Fill(Decaydist,1)
                h16w.Fill(Decaydist,ctau[0])



As you can see, h16w hist is weighted with ctau[0] with predefined condition of h16w.Sumw2()

At the end, the plot looks like

Technically, the integral of the red(h16) and the blue(h16w) should be equal to each other, but differ a little bit in my case.

I want to prove that the discrepancy in integral is OK because the difference is within the error range of the integral of the Weighted (blue, h16w) histogram".

How can I get the error range in the integral of the blue histogram, using the Sumw2?
Do you have any good idea?

Thank you.

Trentacoollime

In general, both integrals would be exactly equal only if for all entries “ctau[0]=1”.

Try:

h16w.Fill(Decaydist, ctau[0] / 10.)

I have a reason why it should be equal to 1…

When I do h16w.Fill(Decaydist, ctau[0] / 10.),

So, as you can see, everything seems to be fine (if weights are 10 times smaller, so is the integral).
You could also try:

print(h16w.Integral() - h16.Integral())

And if, for test purposes, you want them exactly equal, try:

h16w.Fill(Decaydist, 1)

Filling the histogram indeed seems all fine.

Yet, I want to know the statistical error of my h16w histogram’s integral using the Sumw2().

I do set h16w.Sumw2() before filling the hist, but how do I retrieve the information of statistical error with Sumw2()?

Thanks!

TH1::IntegralAndError

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.