56
57
58 script, infile = argv
59
60 print "Creating MCID, GammapT mapping"
61 GammapTMapping = dict()
62 generateGammapTMapping(GammapTMapping)
63
64 print "Loading histograms with weights"
65 Histograms = []
66
67
68 fileWithWeights = "/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/dev/SUSYTools/GammaJets_SysParameterization/AllVariationsGamma.root"
69
70 g = ROOT.TFile(fileWithWeights)
71 systList = ["ckkw15", "ckkw30", "fact025", "fact4", "renorm025", "renorm4", "qsf025", "qsf4"]
72
73 for syst in systList:
74 print 'syst',syst
75 h = ROOT.TH2F(g.Get(syst))
76 Histograms.append(h)
77
78 print "Loading File"
79 f = ROOT.TFile(infile,"update")
80
81
82
83
84
85
86 treeName = "GAMMA_CRY"
87
88
89
90
91 print "Loading Tree"
92
93
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.])
102
103
104 T = f.Get(treeName)
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")
113
114 print "Adding Weights"
115 nEvts = T.GetEntries()
116 for iEvt in range(nEvts):
117
118 if iEvt%1000 == 0:
119 print "Current Event being Processed is: ", iEvt
120
121 T.GetEntry(iEvt)
122
123
124 MCID = T.RunNumber
125 nTruthJets = T.nJet
126
127
128 GammapTBin = GammapTMapping.get(MCID)
129 TruthJetBin = nTruthJets+1
130 if nTruthJets >= 11:
131 TruthJetBin = 12
132 if GammapTBin == None:
133
134 ckkw15[0] = 1
135 ckkw30[0] = 1
136 fact025[0] = 1
137 fact4[0] = 1
138 renorm025[0] = 1
139 renorm4[0] = 1
140 qsf025[0] = 1
141 qsf4[0] = 1
142
143 else:
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)
152
153 ckkw15branch.Fill()
154 ckkw30branch.Fill()
155 fact025branch.Fill()
156 fact4branch.Fill()
157 renorm025branch.Fill()
158 renorm4branch.Fill()
159 qsf025branch.Fill()
160 qsf4branch.Fill()
161
162
163
164 T.Write()
165
166 print "Done."
167