# TH1F Integral to obtaine normalisation

**URL:** <https://root-forum.cern.ch/t/th1f-integral-to-obtaine-normalisation/31549>\
**Category:** Newbie\
**Created:** [November 12, 2018, 11:08am UTC](https://root-forum.cern.ch/t/th1f-integral-to-obtaine-normalisation/31549 "2018-11-12T11:08:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Veronika](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/839c29/32.png) [@Veronika](https://root-forum.cern.ch/u/Veronika)\
**Post date:** [November 12, 2018, 11:08am UTC](https://root-forum.cern.ch/t/th1f-integral-to-obtaine-normalisation/31549/1 "2018-11-12T11:08:13Z")

</div>

Dear ROOT-experts,

I’m trying to estimate a normalisation factor by taking the ration of the integral of data and data driven BG in the dedicated selection. This factor is then applied as weights to BG. Naively I would expect that taking the ration again for the same selection after rescaling the BG gives 1 but instead I find differences of the order of a view percent.  
Here’s what I did (eventWeight is always =1 here):

```auto
weightList=['eventWeight']
cutsCRQ='(veto==0 || veto==410500) && dPhi < 0.200000 && abs(jetEta[1]) <= 2.800000 && abs(jetEta[0]) <= 2.800000 && met >= 250.000000 && nJet >= 2 && jetPt[0] >= 200.000000 && jetPt[1] >= 50.000000 && meffInc >= 800 && (abs(jetEta[0])>2.4 || jet1Chf/jetFracSamplingMax[0]>0.1) && (abs(jetEta[1])>2.4 || jet2Chf/jetFracSamplingMax[1]>0.1) && (dPhiBadTile>0.3 || RunNumber>284484) && ((cleaning & 0x30F)==0) && (abs(timing)<4 || timing==-99999)'
smearTree=smear.Get('Data_SRAll')
dataTree=data.Get('Data_SRAll')

smearSRhistoROOT=ROOT.TH1F('smearSRhistoROOT', '', 20,0.,4.) 
dataSRhistoROOT=ROOT.TH1F('dataSRhistoROOT', '', 20,0.,4.) 

smearTree.Draw('dPhi>>smearCRQhistoROOT', cutsCRQ)
smearCRQhistoROOT=ROOT.gPad.GetPrimitive('smearCRQhistoROOT')

dataTree.Draw('dPhi>>dataCRQhistoROOT', cutsCRQ)
dataCRQhistoROOT=ROOT.gPad.GetPrimitive('dataCRQhistoROOT')

print "\n integral smear histo from Tree.Draw(): ", smearCRQhistoROOT.Integral()
print " integral data histo from Tree.Draw(): ", dataCRQhistoROOT.Integral()
normFactorROOT=dataCRQhistoROOT.Integral()/smearCRQhistoROOT.Integral()

print "\n =>normfactor from ROOT only: ", normFactorROOT

smearCRQhistoROOTNorm=ROOT.TH1F('smearCRQhistoROOTNorm', '', 20,0.,4.) 
dataCRQhistoROOTNorm=ROOT.TH1F('dataCRQhistoROOTNorm', '', 20,0.,4.) 
 
dataTree.Draw('dPhi>>dataCRQhistoROOTNorm', '(%s)*(%s)' %(cutsCRQ, '*'.join(weightList)))
dataCRQhistoROOTNorm=ROOT.gPad.GetPrimitive('dataCRQhistoROOTNorm')

smearTree.Draw('dPhi>>smearCRQhistoROOTNorm', '(%s)*(%s*%s)' %(cutsCRQ, '*'.join(weightList), normFactorROOT))
smearCRQhistoROOTNorm=ROOT.gPad.GetPrimitive('smearCRQhistoROOTNorm')

print "\nnorm integral smear histo from Tree.Draw(): ", smearCRQhistoROOTNorm.Integral()
print "norm integral data histo from Tree.Draw(): ", dataCRQhistoROOTNorm.Integral()
print "\n => normalised norm factor (should be 1): ", dataCRQhistoROOTNorm.Integral()/smearCRQhistoROOTNorm.Integral()

```

What am I missing?

Many thanks,  
Veronika

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [November 12, 2018, 10:18pm UTC](https://root-forum.cern.ch/t/th1f-integral-to-obtaine-normalisation/31549/2 "2018-11-12T22:18:06Z")

</div>

Hi,

I would use TH1D. It is possible that the difference is caused by the limited precision of the TH1F.  
Normally the are no reasons (only in case of a huge number of bins, e.g in case of 3d histograms) to use TH1F instead of TH1D

Lorenzo

---

<div class="post-metadata">

**Author:** ![Veronika](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/839c29/32.png) [@Veronika](https://root-forum.cern.ch/u/Veronika)\
**Post date:** [November 22, 2018, 9:56am UTC](https://root-forum.cern.ch/t/th1f-integral-to-obtaine-normalisation/31549/3 "2018-11-22T09:56:28Z")

</div>

Hi Lorenzo,

just realised I never replied here. So even if it’s way too late… this was indeed the issue. Thanks a lot for your help 🙂
