Skip to content

Commit

Permalink
smearing matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcellocosti committed Aug 5, 2024
1 parent a4995ad commit 2143d0b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fempy/utils/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ def WeightedAverage(hQuantity, hWeight):

return avgQuantity, avgQuantityErr

def SmearHisto(hist, smearmatr):
'''
Assuming kgen on x-axis, kreco on y-axis
'''

smearedHisto = hist.Clone(f'{hist.GetTitle()}_smeared')
smearedHisto.Reset('ICESM')
print(smearedHisto.Integral())
for iBin in range(hist.GetNbinsX()):
hProjYSmearMatr = smearmatr.ProjectionY(f'iBin_{iBin+1}', iBin+1, iBin+1)
if hProjYSmearMatr.Integral()>0:
hProjYSmearMatr.Scale(hist.GetBinContent(iBin+1) / hProjYSmearMatr.Integral())
smearedHisto.Add(hProjYSmearMatr)

for iBin in range(smearedHisto.GetNbinsX()):
smearedHisto.SetBinError(iBin+1, math.sqrt(smearedHisto.GetBinContent(iBin+1)))

return smearedHisto

def ChangeUnits(hist, multiplier):
'''
Only for histogram with constant binwidth!
Expand Down

0 comments on commit 2143d0b

Please sign in to comment.