2 from array
import array
6 import ProviderHistoHelpers
10 from ParseInsituInput_MJB
import ReadInSituHistograms
12 InSituCompDictionary =
ReadInSituHistograms(
"/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Moriond2018/forMJBInputs_GammaZJet")
13 SingleParticleFile = TFile(
"/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Moriond2018/HighPt2012/AggressiveHighPt_Final2014.root")
15 jetDefList = [
'AntiKt4Topo_EMJES',
19 outputFile = TFile(
"2012HighPtTerm_2017Moriond2018adjusted.root",
"RECREATE")
21 for jetDef
in jetDefList :
23 inSituHist = InSituCompDictionary[jetDef][
'Zjet_dPhi'].Clone(
"InSitu_Quad")
25 inSituHist.SetDirectory(0)
28 for histkey
in InSituCompDictionary[jetDef] :
30 hist = InSituCompDictionary[jetDef][histkey]
32 for bin
in range(1, hist.GetNbinsX()+1) :
34 assert(inSituHist.GetBinLowEdge(bin) == hist.GetBinLowEdge(bin)
and inSituHist.GetBinWidth(bin) == hist.GetBinWidth(bin))
36 inSituHist.SetBinContent(bin,inSituHist.GetBinContent(bin)+math.pow(hist.GetBinContent(bin),2))
42 spHist = SingleParticleFile.Get(
"SingleParticle_HighPt_AntiKt4Topo_EMJES")
43 print "Setting all to",spHist.GetBinContent(spHist.GetNbinsX())
44 for bin
in range(1,spHist.GetNbinsX()+1) :
45 spHist.SetBinContent(bin,spHist.GetBinContent(spHist.GetNbinsX()))
47 outputHist = spHist.Clone(
"adjustedInterpolatedSingleParticleUncertainty")
48 outputHist.SetDirectory(0)
53 for bin
in range(0,spHist.GetNbinsX()+2) :
55 pT = spHist.GetXaxis().GetBinCenter(bin)
56 inSituBin = inSituHist.FindBin(pT)
57 if inSituBin > inSituHist.GetNbinsX() : inSituBin = inSituHist.GetNbinsX()
58 inSituVal2 = inSituHist.GetBinContent(inSituBin)
59 spVal = spHist.Interpolate(pT)
61 diff = spVal*spVal - inSituVal2
66 keepSPVal = math.sqrt(spVal*spVal - inSituVal2)
71 smoothedSPVal = keepSPVal * ((pT - 800)/200)
73 smoothedSPVal = keepSPVal
75 outputHist.SetBinContent(bin,smoothedSPVal)
78 outputHist.Write(
"SingleParticle_HighPt_{0}".
format(jetDef))