5 import os,sys,subprocess,datetime,copy,math,array,shutil,ROOT,re,string
7 from subprocess
import call
8 from array
import array
10 __author__ =
"John Anders"
11 __doc__ =
"""Script to add Sherpa Systematic Weight branches to existing file."""
15 print "Adding gamma+jets to the dictionary"
17 for i
in range(361039, 361042):
22 for i
in range(361042, 361045):
27 for i
in range(361045, 361048):
33 for i
in range(361048, 361051):
37 print "Range 500-1000"
38 for i
in range(361051, 361054):
42 print "Range 1000-2000"
43 for i
in range(361054, 361057):
47 print "Range 2000-ECMS"
48 for i
in range(361057, 361061):
60 print "Creating MCID, GammapT mapping"
61 GammapTMapping = dict()
64 print "Loading histograms with weights"
68 fileWithWeights =
"/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/dev/SUSYTools/GammaJets_SysParameterization/AllVariationsGamma.root"
70 g = ROOT.TFile(fileWithWeights)
71 systList = [
"ckkw15",
"ckkw30",
"fact025",
"fact4",
"renorm025",
"renorm4",
"qsf025",
"qsf4"]
75 h = ROOT.TH2F(g.Get(syst))
79 f = ROOT.TFile(infile,
"update")
86 treeName =
"GAMMA_CRY"
94 ckkw15 =
array(
'f', [0.])
95 ckkw30 =
array(
'f', [0.])
96 fact025 =
array(
'f', [0.])
97 fact4 =
array(
'f', [0.])
98 renorm025 =
array(
'f', [0.])
99 renorm4 =
array(
'f', [0.])
100 qsf025 =
array(
'f', [0.])
101 qsf4 =
array(
'f', [0.])
105 ckkw15branch = T.Branch(
"ckkw15_Weight", ckkw15,
"ckkw15_Weight/F")
106 ckkw30branch = T.Branch(
"ckkw30_Weight", ckkw30,
"ckkw30_Weight/F")
107 fact025branch = T.Branch(
"fact025_Weight", fact025,
"fact025_Weight/F")
108 fact4branch = T.Branch(
"fact4_Weight", fact4,
"fact4_Weight/F")
109 renorm025branch = T.Branch(
"renorm025_Weight", renorm025,
"renorm025_Weight/F")
110 renorm4branch = T.Branch(
"renorm4_Weight", renorm4,
"renorm4_Weight/F")
111 qsf025branch = T.Branch(
"qsf025_Weight", qsf025,
"qsf025_Weight/F")
112 qsf4branch = T.Branch(
"qsf4_Weight", qsf4,
"qsf4_Weight/F")
114 print "Adding Weights"
115 nEvts = T.GetEntries()
116 for iEvt
in range(nEvts):
119 print "Current Event being Processed is: ", iEvt
128 GammapTBin = GammapTMapping.get(MCID)
129 TruthJetBin = nTruthJets+1
132 if GammapTBin ==
None:
144 ckkw15[0] = Histograms[0].GetBinContent(GammapTBin,TruthJetBin)
145 ckkw30[0] = Histograms[1].GetBinContent(GammapTBin,TruthJetBin)
146 fact025[0] = Histograms[2].GetBinContent(GammapTBin,TruthJetBin)
147 fact4[0] = Histograms[3].GetBinContent(GammapTBin,TruthJetBin)
148 renorm025[0] = Histograms[4].GetBinContent(GammapTBin,TruthJetBin)
149 renorm4[0] = Histograms[5].GetBinContent(GammapTBin,TruthJetBin)
150 qsf025[0] = Histograms[6].GetBinContent(GammapTBin,TruthJetBin)
151 qsf4[0] = Histograms[7].GetBinContent(GammapTBin,TruthJetBin)
157 renorm025branch.Fill()
168 if __name__ ==
'__main__':