13from prompt
import ValidationSettings
22settings = ValidationSettings(name=
'ECL_Energy',
24 download_files=[
'stdout'],
33 from ROOT
import TH1F, TCanvas, TFile, TGraph, TLine, kRed, gStyle
36 from array
import array
38 if not os.path.exists(
'plots'):
42 gStyle.SetOptStat(1111111)
43 gStyle.SetOptFit(1111)
47 ggRatio = TH1F(
"ggRatio",
"Ratio of output to input calib, gamma gammaRatio", 200, 0.9, 1.1)
49 eeRatio = TH1F(
"eeRatio",
"Ratio of output to input calib, Bhabha5x5Ratio", 400, 0.9, 1.1)
50 eeggRatio = TH1F(
"eeggRatio",
"Ratio of ee/gg calibrations, thetaID [14,57]Ratio", 200, 0.95, 1.05)
52 mumuggRatio = TH1F(
"mumuggRatio",
"Ratio of muon pair/gg calibrations, thetaID [14,57]Ratio", 200, 0.93, 1.03)
54 checkMerge = TH1F(
"checkMerge",
"Ratio between final and gg calib valuesRatio", 200, 0., 2.)
55 finalRatio = TH1F(
"finalRatio",
"Ratio of new/existing energy calibrationsratio", 200, 0.95, 1.05)
61 print(
"\n---------------------------------------- \nGamma gamma comparison: \n\n")
62 gg = TFile(f
"{job_path}/ecl_gamma_gamma/0/algorithm_output/eclGammaGammaE_algorithm.root")
65 EnVsCrysID = gg.Get(
"EnVsCrysID")
66 ggEntries = EnVsCrysID.GetEntries()
67 crossSection = 3990000.
68 lumi = ggEntries / crossSection
70 estUnc = 0.5 * np.sqrt(nomLum / lumi)
72 print(f
"{ggEntries:f} entries in gg EnVsCrysID lumi = {lumi:.2f} fb-1 est uncerta = {estUnc:.2f} \n")
75 hStatusgg = gg.Get(
"hStatus")
76 success = 100. * (hStatusgg.GetBinContent(22) + hStatusgg.GetBinContent(14)) / 8736.
77 print(f
"\nSummary of Gamma Gamma fit status. {success:.1f} good fits:\n")
78 print(f
"16 good fit: {hStatusgg.GetBinContent(22):.4f} \n")
79 print(f
" 8 iterations: {hStatusgg.GetBinContent(14):.4f} \n")
80 print(f
" 4 at limit: {hStatusgg.GetBinContent(10):.4f} \n")
81 print(f
" 3 poor fit: {hStatusgg.GetBinContent(9):.4f} \n")
82 print(f
"-1 low stats: {hStatusgg.GetBinContent(5):.4f} \n")
85 StatusVsCrysIDgg = gg.Get(
"StatusVsCrysID")
86 AverageInitCalibgg = gg.Get(
"AverageInitCalib")
87 CalibVsCrysIDgg = gg.Get(
"CalibVsCrysID")
89 print(
"\nCompare gamma gamma output calibration to input for large changes:\n")
95 for cellID
in range(1, 8736 + 1):
96 status = StatusVsCrysIDgg.GetBinContent(cellID)
98 inputCalib = AverageInitCalibgg.GetBinContent(cellID)
99 outputCalib = CalibVsCrysIDgg.GetBinContent(cellID)
100 ratio = outputCalib / inputCalib
102 if(ratio < 0.95
or ratio > 1.05):
104 print(f
"{bigChange:.2f} cellID {cellID:.4f} {ratio:.3f} {status}\n")
107 if(cellID >= 1297
and cellID <= 7632):
108 if(ratio < minBarrelRatio):
109 minBarrelRatio = ratio
111 if(ratio > maxBarrelRatio):
112 maxBarrelRatio = ratio
116 myC.Print(
"plots/ggRatio.pdf")
118 print(
"\nLargest changes in thetaID [14,57]\n")
119 print(f
"ratio = {minBarrelRatio:.3f} in cellID {minCellID:f} \n")
120 print(f
"ratio = {maxBarrelRatio:.3f} in cellID {maxCellID:f} \n")
122 histMean = ggRatio.GetMean()
123 ggfit = ggRatio.GetFunction(
"gaus")
124 fitMean = ggfit.GetParameter(1)
125 fitSigma = ggfit.GetParameter(2)
127 "\n\nRatio of New/old Gamma gamma calib consts: mean = %.4f mean of Gaussian fit = %.4f, sigma = %.4f\n" %
128 (histMean, fitMean, fitSigma))
132 print(
"\n---------------------------------------- \nBhabha comparison: \n\n")
133 ee = TFile(f
"{job_path}/ecl_ee5x5/0/algorithm_output/eclee5x5Algorithm.root")
136 AverageInitCalibee = ee.Get(
"AverageInitCalib")
137 CalibVsCrysIDee = ee.Get(
"CalibVsCrysID")
139 print(
"\nCompare Bhabha output calibration to input:\n")
142 for cellID
in range(1, 8736 + 1):
143 inputCalib = AverageInitCalibee.GetBinContent(cellID)
144 outputCalib = CalibVsCrysIDee.GetBinContent(cellID)
147 ratio = outputCalib / inputCalib
149 if(ratio < 0.95
or ratio > 1.05):
151 print(f
" {int(bigChange):2} cellID {cellID:.4f} {ratio:5.3f}\n")
153 print(f
"Total calibrated crystals = {eeCalibrated:.4f} = {100.0 * eeCalibrated / 8736.0:.1f} \n\n")
155 myC.Print(
"plots/eeRatio.pdf")
157 histMean = eeRatio.GetMean()
158 eefit = eeRatio.GetFunction(
"gaus")
159 fitMean = eefit.GetParameter(1)
160 fitSigma = eefit.GetParameter(2)
161 print(f
"\nBhabha mean ratio = {histMean:.4f} mean of Gaussian fit = {fitMean:.4f}, sigma = {fitSigma:.4f}\n")
165 print(
"\n---------------------------------------- \nBhabha to gamma comparison: \n\n")
166 xcellID = array(
'd', [0] * 8736)
167 yratio = array(
'd', [0] * 8736)
169 for cellID
in range(1, 8736 + 1):
170 ggstatus = StatusVsCrysIDgg.GetBinContent(cellID)
171 ggCalib = CalibVsCrysIDgg.GetBinContent(cellID)
172 eeCalib = CalibVsCrysIDee.GetBinContent(cellID)
173 if(ggstatus > 0.
and eeCalib > 0.):
174 if(cellID >= 1297
and cellID <= 7632):
175 eeggRatio.Fill(eeCalib / ggCalib)
176 xcellID[nPo] = cellID
177 yratio[nPo] = eeCalib / ggCalib
181 eeggRatio.Fit(
"gaus")
182 myC.Print(
"plots/eeggRatio.pdf")
184 histMean = eeggRatio.GetMean()
185 eeggfit = eeggRatio.GetFunction(
"gaus")
186 fitMean = eeggfit.GetParameter(1)
187 fitSigma = eeggfit.GetParameter(2)
188 print(f
"\nBhabha to gg ratio mean = {histMean:.4f} mean of Gaussian fit = {fitMean:.4f}, sigma = {fitSigma:.4f}\n")
191 eeggRatiovsCellID = TGraph(nPo, xcellID, yratio)
192 eeggRatiovsCellID.SetName(
"eeggRatiovsCellID")
193 eeggRatiovsCellID.SetMarkerStyle(20)
194 eeggRatiovsCellID.SetMarkerSize(0.3)
195 eeggRatiovsCellID.SetTitle(
"Bhabha/gg calibration ratiocellIDratio")
196 eeggRatiovsCellID.Draw(
"AP")
197 eeggRatiovsCellID.GetXaxis().SetRangeUser(1, 8737)
198 eeggRatiovsCellID.GetYaxis().SetRangeUser(0.95, 1.05)
199 one = TLine(1, 1, 8737, 1)
200 one.SetLineColor(kRed)
203 myC.Print(
"plots/eeggRatiovsCellID.pdf")
207 print(
"\n---------------------------------------- \nMuon pair comparison: \n\n")
208 mumu = TFile(f
"{job_path}/ecl_mu_mu/0/algorithm_output/eclMuMuEAlgorithm.root")
211 hStatusmumu = mumu.Get(
"hStatus")
212 success = 100. * (hStatusmumu.GetBinContent(22) + hStatusmumu.GetBinContent(14)) / 8736.
213 print(
r"\nSummary of muon pair fit status. \%.1f good fits:\n", success)
214 print(f
"16 good fit: {hStatusmumu.GetBinContent(22):.4f} \n")
215 print(f
" 8 iterations: {hStatusmumu.GetBinContent(14):.4f} \n")
216 print(f
" 4 at limit: {hStatusmumu.GetBinContent(10):.4f} \n")
217 print(f
" 3 poor fit: {hStatusmumu.GetBinContent(9):.4f} \n")
218 print(f
" 2 no peak: {hStatusmumu.GetBinContent(8):.4f} \n")
219 print(f
"-1 low stats: {hStatusmumu.GetBinContent(5):.4f} \n")
223 print(
"\n---------------------------------------- \nMuon pair to gamma comparison: \n\n")
224 StatusVsCrysIDmumu = mumu.Get(
"StatusVsCrysID")
226 CalibVsCrysIDmumu = mumu.Get(
"CalibVsCrysID")
229 for cellID
in range(1, 8736 + 1):
230 ggstatus = StatusVsCrysIDgg.GetBinContent(cellID)
231 ggCalib = CalibVsCrysIDgg.GetBinContent(cellID)
232 mumustatus = StatusVsCrysIDmumu.GetBinContent(cellID)
233 mumuCalib = CalibVsCrysIDmumu.GetBinContent(cellID)
234 if(ggstatus > 7.5
and mumustatus > 7.5):
235 if(cellID >= 1297
and cellID <= 7632):
236 mumuggRatio.Fill(mumuCalib / ggCalib)
237 xcellID[nPo] = cellID
238 yratio[nPo] = mumuCalib / ggCalib
241 mumuggRatio.Fit(
"gaus")
242 myC.Print(
"plots/mumuggRatio.pdf")
244 histMean = mumuggRatio.GetMean()
245 mumuggfit = mumuggRatio.GetFunction(
"gaus")
246 fitMean = mumuggfit.GetParameter(1)
247 fitSigma = mumuggfit.GetParameter(2)
249 f
"\nMuon pair to gg ratio mean = {histMean:.4f} mean of Gaussian fit = {fitMean:.4f}, sigma = {fitSigma:.4f}\n")
252 mumuggRatiovsCellID = TGraph(nPo, xcellID, yratio)
253 mumuggRatiovsCellID.SetName(
"mumuggRatiovsCellID")
254 mumuggRatiovsCellID.SetMarkerStyle(20)
255 mumuggRatiovsCellID.SetMarkerSize(0.3)
256 mumuggRatiovsCellID.SetTitle(
"Muon pair/gg calibration ratiocellIDratio")
257 mumuggRatiovsCellID.Draw(
"AP")
258 mumuggRatiovsCellID.GetXaxis().SetRangeUser(1, 8737)
259 mumuggRatiovsCellID.GetYaxis().SetRangeUser(0.93, 1.03)
261 myC.Print(
"plots/mumuggRatiovsCellID.pdf")
265 print(
"\n---------------------------------------- \nFinal merge comparison: \n\n")
266 merge = TFile(f
"{job_path}/ecl_merge/0/algorithm_output/ECLCrystalEnergy.root")
267 newPayload = merge.Get(
"newPayload")
268 existingPayload = merge.Get(
"existingPayload")
272 for cellID
in range(1, 8736 + 1):
273 ggstatus = StatusVsCrysIDgg.GetBinContent(cellID)
274 newOldRatio = newPayload.GetBinContent(cellID) / existingPayload.GetBinContent(cellID)
275 newggRatio = newPayload.GetBinContent(cellID) / CalibVsCrysIDgg.GetBinContent(cellID)
277 checkMerge.Fill(newggRatio)
278 finalRatio.Fill(newOldRatio)
279 xcellID[nPo] = cellID
280 yratio[nPo] = newOldRatio
283 checkMerge.Fill(newOldRatio)
286 myC.Print(
"plots/checkMerge.pdf")
288 finalRatio.Fit(
"gaus")
289 myC.Print(
"plots/finalRatio.pdf")
291 histMean = finalRatio.GetMean()
292 finalRatiofit = finalRatio.GetFunction(
"gaus")
293 fitMean = finalRatiofit.GetParameter(1)
294 fitSigma = finalRatiofit.GetParameter(2)
295 print(f
"\nNew to exist ratio mean = {histMean:.4f} mean of Gaussian fit = {fitMean:.4f}, sigma = {fitSigma:.4f}\n")
298 newOldRatiovsCellID = TGraph(nPo, xcellID, yratio)
299 newOldRatiovsCellID.SetName(
"newOldRatiovsCellID")
300 newOldRatiovsCellID.SetMarkerStyle(20)
301 newOldRatiovsCellID.SetMarkerSize(0.3)
302 newOldRatiovsCellID.SetTitle(
"New/existing calibration ratiocellIDratio")
303 newOldRatiovsCellID.Draw(
"AP")
304 newOldRatiovsCellID.GetXaxis().SetRangeUser(1, 8737)
305 newOldRatiovsCellID.GetYaxis().SetRangeUser(0.95, 1.05)
307 myC.Print(
"plots/newOldRatiovsCellID.pdf")
311 fout = TFile(
"validateAirflow.root",
"recreate")
319 eeggRatiovsCellID.Write()
320 mumuggRatiovsCellID.Write()
321 newOldRatiovsCellID.Write()
327if __name__ ==
"__main__":