15 from prompt
import ValidationSettings
18 from pathlib
import Path
27 settings = ValidationSettings(name=
'ECL crystal and crate time calibrations and validations',
29 download_files=[
'stdout'],
33 def run_validation(job_path, input_data_path, requested_iov, expert_config, **kwargs):
38 from ROOT
import TH1F, TCanvas, TFile, TGraph, TLine, kRed, gStyle
41 from array
import array
44 r.gStyle.SetPadTickX(1)
45 r.gStyle.SetPadTickY(1)
48 print(
"job_path = ", job_path)
49 print(
"input_data_path = ", input_data_path)
50 print(
"requested_iov = ", requested_iov)
51 print(
"expert_config = ", expert_config)
53 if not os.path.exists(
'plots'):
57 gStyle.SetOptStat(1111111)
58 gStyle.SetOptFit(1111)
64 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal = TH1F(
65 "clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal",
66 "Bhabha: Cluster t means;Block of runs with one crystal calibration;Mean elec ECL cluster time / run block. Err = RMS",
68 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal = TH1F(
69 "peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal",
70 "Bhabha: Mean(cluster t fit means);Runs of const crys calib;Mean(elec time fit mean / crys)/run block. Err=fit sigma",
73 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal = TH1F(
74 "clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal",
75 "Hadron: Cluster t means;Block of runs with one crystal calibration;Mean photon ECL cluster time / run block. Err = RMS",
77 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal = TH1F(
78 "peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal",
79 "Hadron: Mean(cluster t fit means);Runs of const crys calib;Mean(photon time fit mean / crys)/run block. Err=fit sigma",
88 print(
"\n---------------------------------------- \nBhabha crate calibrations: \n\n")
89 crate_calib_output_dir = Path(job_path)
90 crate_calib_files = sorted(crate_calib_output_dir.glob(
'**/eclBhabhaTAlgorithm_cratesAllRuns.root'))
92 print(
"List of crate calibration files:\n")
93 print(crate_calib_files)
95 num_files = len(crate_calib_files)
96 print(f
'Looping over {num_files} files')
97 for count, in_file_name
in enumerate(crate_calib_files, start=1):
98 in_file = r.TFile(str(in_file_name))
99 print(
"--------------------\nReading file ", in_file,
"\n Crate calib iteration = ", count,
"\n")
101 inFileBaseName = str(in_file_name)
102 inFileBaseName = os.path.basename(inFileBaseName)
103 inFileBaseName = inFileBaseName[:-5]
104 print(
"inFileBaseName = ", inFileBaseName)
107 crate_calib_directory_iter = os.path.split(os.path.split(os.path.split(os.path.dirname(in_file_name))[0])[0])[1]
110 tcrateNew_MINUS_tcrateOld_allRuns = in_file.Get(
"tcrateNew_MINUS_tcrateOld_allRuns")
111 tcrateNew_MINUS_tcrateOld_allRuns_allCrates = in_file.Get(
"tcrateNew_MINUS_tcrateOld_allRuns_allCrates")
114 tcrateNew_MINUS_tcrateOld_allRuns.Draw(
"")
115 tcrateNew_MINUS_tcrateOld_allRuns__Filename = str(
117 crate_calib_directory_iter +
119 "tcrateNew_MINUS_tcrateOld_allRuns__" +
124 print(
"tcrateNew_MINUS_tcrateOld_allRuns__Filename = ", tcrateNew_MINUS_tcrateOld_allRuns__Filename)
125 myC.Print(tcrateNew_MINUS_tcrateOld_allRuns__Filename)
128 tcrateNew_MINUS_tcrateOld_allRuns.Draw(
"")
129 tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename = str(
"plots/" + crate_calib_directory_iter +
"__" +
130 "tcrateNew_MINUS_tcrateOld_allRuns__logY__" +
131 inFileBaseName +
"__counter" + str(count) +
".pdf")
132 print(
"tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename = ", tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename)
133 myC.Print(tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename)
137 tcrateNew_MINUS_tcrateOld_allRuns_allCrates.Draw(
"")
138 tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename = str(
"plots/" + crate_calib_directory_iter +
"__" +
139 "tcrateNew_MINUS_tcrateOld_allRuns_allCrates__" +
140 inFileBaseName +
"__counter" + str(count) +
".pdf")
141 print(
"tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename = ", tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename)
142 myC.Print(tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename)
145 tcrateNew_MINUS_tcrateOld_allRuns_allCrates.Draw(
"")
146 tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename = str(
148 crate_calib_directory_iter +
150 "tcrateNew_MINUS_tcrateOld_allRuns_allCrates__logY__" +
155 print(
"tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename = ",
156 tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename)
157 myC.Print(tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename)
164 print(
"\n---------------------------------------- \nBhabha crystal calibrations: \n\n")
165 crystal_calib_output_dir = Path(job_path)
166 crystal_calib_files = sorted(crystal_calib_output_dir.glob(
167 '**/ECLcrystalTimeCalibration_physics_*/*/*/eclBhabhaTAlgorithm_*.root'))
169 print(
"List of crystal calibration files:\n")
170 print(crystal_calib_files)
172 num_files = len(crystal_calib_files)
173 print(f
'Looping over {num_files} files')
174 for count, in_file_name
in enumerate(crystal_calib_files, start=1):
175 in_file = r.TFile(str(in_file_name))
176 print(
"--------------------\nReading file ", in_file,
"\n crystal calib iteration = ", count,
"\n")
178 inFileBaseName = str(in_file_name)
179 inFileBaseName = os.path.basename(inFileBaseName)
180 inFileBaseName = inFileBaseName[:-5]
181 print(
"inFileBaseName = ", inFileBaseName)
184 crystal_calib_directory_iter = os.path.split(os.path.split(os.path.split(os.path.dirname(in_file_name))[0])[0])[1]
187 tsNew_MINUS_tsOld__cid = in_file.Get(
"tsNew_MINUS_tsOld__cid")
188 tsNew_MINUS_tsOld = in_file.Get(
"tsNew_MINUS_tsOld")
189 tsNew_MINUS_tsCustomPrev__cid = in_file.Get(
"tsNew_MINUS_tsCustomPrev__cid")
190 tsNew_MINUS_tsCustomPrev = in_file.Get(
"tsNew_MINUS_tsCustomPrev")
191 tsNew_MINUS_tsOldBhabha__cid = in_file.Get(
"tsNew_MINUS_tsOldBhabha__cid")
192 tsNew_MINUS_tsOldBhabha = in_file.Get(
"tsNew_MINUS_tsOldBhabha")
193 cutflow = in_file.Get(
"cutflow")
194 h_crysHits = in_file.Get(
"h_crysHits")
197 tsNew_MINUS_tsOld__cid.Draw(
"")
198 tsNew_MINUS_tsOld__cid.SetStats(0)
199 tsNew_MINUS_tsOld__cid.Draw(
"")
200 tsNew_MINUS_tsOld__cid__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOld__cid__" +
201 inFileBaseName +
"__counter" + str(count) +
".pdf")
202 print(
"tsNew_MINUS_tsOld__cid__Filename = ", tsNew_MINUS_tsOld__cid__Filename)
203 myC.Print(tsNew_MINUS_tsOld__cid__Filename)
206 tsNew_MINUS_tsOld.Draw(
"")
207 tsNew_MINUS_tsOld__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOld__" +
208 inFileBaseName +
"__counter" + str(count) +
".pdf")
209 print(
"tsNew_MINUS_tsOld__Filename = ", tsNew_MINUS_tsOld__Filename)
210 myC.Print(tsNew_MINUS_tsOld__Filename)
213 tsNew_MINUS_tsOld.Draw(
"")
214 tsNew_MINUS_tsOldLogY__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOld__logY__" +
215 inFileBaseName +
"__counter" + str(count) +
".pdf")
216 print(
"tsNew_MINUS_tsOldLogY__Filename = ", tsNew_MINUS_tsOldLogY__Filename)
217 myC.Print(tsNew_MINUS_tsOldLogY__Filename)
221 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
222 tsNew_MINUS_tsCustomPrev__cid.SetStats(0)
223 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
224 tsNew_MINUS_tsCustomPrev__cid__Filename = str(
226 crystal_calib_directory_iter +
228 "tsNew_MINUS_tsCustomPrev__cid__" +
233 print(
"tsNew_MINUS_tsCustomPrev__cid__Filename = ", tsNew_MINUS_tsCustomPrev__cid__Filename)
234 myC.Print(tsNew_MINUS_tsCustomPrev__cid__Filename)
237 tsNew_MINUS_tsCustomPrev.Draw(
"")
238 tsNew_MINUS_tsCustomPrev__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsCustomPrev__" +
239 inFileBaseName +
"__counter" + str(count) +
".pdf")
240 print(
"tsNew_MINUS_tsCustomPrev__Filename = ", tsNew_MINUS_tsCustomPrev__Filename)
241 myC.Print(tsNew_MINUS_tsCustomPrev__Filename)
244 tsNew_MINUS_tsCustomPrev.Draw(
"")
245 tsNew_MINUS_tsCustomPrevLogY__Filename = str(
247 crystal_calib_directory_iter +
249 "tsNew_MINUS_tsCustomPrev__logY__" +
254 print(
"tsNew_MINUS_tsCustomPrevLogY__Filename = ", tsNew_MINUS_tsCustomPrevLogY__Filename)
255 myC.Print(tsNew_MINUS_tsCustomPrevLogY__Filename)
259 tsNew_MINUS_tsOldBhabha__cid.Draw(
"")
260 tsNew_MINUS_tsOldBhabha__cid.SetStats(0)
261 tsNew_MINUS_tsOldBhabha__cid.Draw(
"")
262 tsNew_MINUS_tsOldBhabha__cid__Filename = str(
264 crystal_calib_directory_iter +
266 "tsNew_MINUS_tsOldBhabha__cid__" +
271 print(
"tsNew_MINUS_tsOldBhabha__cid__Filename = ", tsNew_MINUS_tsOldBhabha__cid__Filename)
272 myC.Print(tsNew_MINUS_tsOldBhabha__cid__Filename)
275 tsNew_MINUS_tsOldBhabha.Draw(
"")
276 tsNew_MINUS_tsOldBhabha__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOldBhabha__" +
277 inFileBaseName +
"__counter" + str(count) +
".pdf")
278 print(
"tsNew_MINUS_tsOldBhabha__Filename = ", tsNew_MINUS_tsOldBhabha__Filename)
279 myC.Print(tsNew_MINUS_tsOldBhabha__Filename)
282 tsNew_MINUS_tsOldBhabha.Draw(
"")
283 tsNew_MINUS_tsOldBhabhaLogY__Filename = str(
285 crystal_calib_directory_iter +
287 "tsNew_MINUS_tsOldBhabha__logY__" +
292 print(
"tsNew_MINUS_tsOldBhabhaLogY__Filename = ", tsNew_MINUS_tsOldBhabhaLogY__Filename)
293 myC.Print(tsNew_MINUS_tsOldBhabhaLogY__Filename)
298 cutflow__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"cutflow__" +
299 inFileBaseName +
"__counter" + str(count) +
".pdf")
300 print(
"cutflow__Filename = ", cutflow__Filename)
301 myC.Print(cutflow__Filename)
306 h_crysHits.SetStats(0)
308 h_crysHits__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"h_crysHits__" +
309 inFileBaseName +
"__counter" + str(count) +
".pdf")
310 print(
"h_crysHits__Filename = ", h_crysHits__Filename)
311 myC.Print(h_crysHits__Filename)
318 print(
"\n---------------------------------------- \nBhabha calibration crystal mergers: \n\n")
319 merger_alg_output_dir = Path(job_path)
320 merger_files = sorted(merger_alg_output_dir.glob(
'**/ECLCrystalTimeOffsetMerged_*.root'))
322 print(
"List of bhabha validation files:\n")
325 num_files = len(merger_files)
326 print(f
'Looping over {num_files} files')
327 for count, in_file_name
in enumerate(merger_files, start=1):
328 in_file = r.TFile(str(in_file_name))
329 print(
"--------------------\nReading file ", in_file,
"\n Crystal calib iteration or blocks = ", count,
"\n")
331 inFileBaseName = str(in_file_name)
332 inFileBaseName = os.path.basename(inFileBaseName)
333 inFileBaseName = inFileBaseName[:-5]
334 print(
"inFileBaseName = ", inFileBaseName)
337 merge_directory_iter = os.path.split(os.path.split(os.path.split(os.path.dirname(in_file_name))[0])[0])[1]
340 newBhabhaMinusCustomPrev__cid = in_file.Get(
"newBhabhaMinusCustomPrev__cid")
341 newBhabhaMinusCustomPrevBhabha__cid = in_file.Get(
"newBhabhaMinusCustomPrevBhabha__cid")
342 TsNewBhabha_MINUS_TsCustomPrev = in_file.Get(
"TsNewBhabha_MINUS_TsCustomPrev")
343 TsNewBhabha_MINUS_TsCustomPrevBhabha = in_file.Get(
"TsNewBhabha_MINUS_TsCustomPrevBhabha")
346 newBhabhaMinusCustomPrev__cid.Draw(
"")
347 newBhabhaMinusCustomPrev__cid.SetStats(0)
348 newBhabhaMinusCustomPrev__cid.Draw(
"")
349 newBhabhaMinusCustomPrev__cid__Filename = str(
"plots/" + merge_directory_iter +
"__" +
"newBhabhaMinusCustomPrev__cid__" +
350 inFileBaseName +
"__counter" + str(count) +
".pdf")
351 print(
"newBhabhaMinusCustomPrev__cid__Filename = ", newBhabhaMinusCustomPrev__cid__Filename)
352 myC.Print(newBhabhaMinusCustomPrev__cid__Filename)
355 newBhabhaMinusCustomPrevBhabha__cid.Draw(
"")
356 newBhabhaMinusCustomPrevBhabha__cid.SetStats(0)
357 newBhabhaMinusCustomPrevBhabha__cid.Draw(
"")
358 newBhabhaMinusCustomPrevBhabha__cid__Filename = str(
360 merge_directory_iter +
362 "newBhabhaMinusCustomPrevBhabha__cid__" +
367 print(
"newBhabhaMinusCustomPrevBhabha__cid__Filename = ", newBhabhaMinusCustomPrevBhabha__cid__Filename)
368 myC.Print(newBhabhaMinusCustomPrevBhabha__cid__Filename)
371 TsNewBhabha_MINUS_TsCustomPrev.Draw(
"")
372 TsNewBhabha_MINUS_TsCustomPrev__Filename = str(
"plots/" + merge_directory_iter +
"__" +
"TsNewBhabha_MINUS_TsCustomPrev__" +
373 inFileBaseName +
"__counter" + str(count) +
".pdf")
374 print(
"TsNewBhabha_MINUS_TsCustomPrev__Filename = ", TsNewBhabha_MINUS_TsCustomPrev__Filename)
375 myC.Print(TsNewBhabha_MINUS_TsCustomPrev__Filename)
378 TsNewBhabha_MINUS_TsCustomPrev.Draw(
"")
379 TsNewBhabha_MINUS_TsCustomPrevLogY__Filename = str(
381 merge_directory_iter +
383 "TsNewBhabha_MINUS_TsCustomPrev__logY__" +
388 print(
"TsNewBhabha_MINUS_TsCustomPrevLogY__Filename = ", TsNewBhabha_MINUS_TsCustomPrevLogY__Filename)
389 myC.Print(TsNewBhabha_MINUS_TsCustomPrevLogY__Filename)
393 TsNewBhabha_MINUS_TsCustomPrevBhabha.Draw(
"")
394 TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename = str(
396 merge_directory_iter +
398 "TsNewBhabha_MINUS_TsCustomPrevBhabha__" +
403 print(
"TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename = ", TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename)
404 myC.Print(TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename)
407 TsNewBhabha_MINUS_TsCustomPrevBhabha.Draw(
"")
408 TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename = str(
"plots/" + merge_directory_iter +
409 "__" +
"TsNewBhabha_MINUS_TsCustomPrevBhabha__logY__" +
410 inFileBaseName +
"__counter" + str(count) +
".pdf")
411 print(
"TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename = ", TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename)
412 myC.Print(TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename)
419 print(
"\n---------------------------------------- \nBhabha self-consistency check: \n\n")
420 bhabhaVal_alg_output_dir = Path(job_path) /
'ECLcrystalTimeCalValidation_bhabhaPhysics/0/algorithm_output/'
421 bhabhaVal_files = sorted(bhabhaVal_alg_output_dir.glob(
'**/eclBhabhaTValidationAlgorithm_*.root'))
423 print(
"List of bhabha validation files:\n")
424 print(bhabhaVal_files)
426 num_files = len(bhabhaVal_files)
427 print(f
'Looping over {num_files} files')
428 for count, in_file_name
in enumerate(bhabhaVal_files, start=1):
429 in_file = r.TFile(str(in_file_name))
430 print(
"--------------------\nReading file ", in_file,
", crystal calib block # = ", count,
"\n")
432 inFileBaseName = str(in_file_name)
433 inFileBaseName = os.path.basename(inFileBaseName)
434 inFileBaseName = inFileBaseName[:-5]
435 print(
"inFileBaseName = ", inFileBaseName)
437 bhabhaVal_directory =
"ECLcrystalTimeCalValidation_bhabhaPhysics"
440 peakClusterTimesGoodFit = in_file.Get(
"peakClusterTimesGoodFit")
441 clusterTime = in_file.Get(
"clusterTime")
444 title =
"From: " + inFileBaseName
445 title = title +
" : cluster time" +
", block " + str(count)
446 clusterTime.SetTitle(title)
448 clusterTime.Fit(
"gaus")
450 clusterTimeFilename = str(
"plots/" + inFileBaseName +
"__clusterTime__block" + str(count) +
".pdf")
451 print(
"clusterTimeFilename = ", clusterTimeFilename)
452 myC.Print(clusterTimeFilename)
454 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinContent(count, clusterTime.GetMean())
455 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinError(count, clusterTime.GetStdDev())
458 title =
"From: " + inFileBaseName
459 title = title +
" : cluster time fits" +
", block " + str(count)
460 peakClusterTimesGoodFit.SetTitle(title)
461 peakClusterTimesGoodFit.Draw(
"")
462 peakClusterTimesGoodFit.Fit(
"gaus")
464 peakClusterTimesGoodFitFilename = str(
"plots/" + inFileBaseName +
"__peakClusterTimesGoodFit__block" + str(count) +
".pdf")
465 print(
"peakClusterTimesGoodFitFilename = ", peakClusterTimesGoodFitFilename)
466 myC.Print(peakClusterTimesGoodFitFilename)
468 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinContent(count, peakClusterTimesGoodFit.GetMean())
469 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinError(count, peakClusterTimesGoodFit.GetStdDev())
472 tsNew_MINUS_tsCustomPrev__cid = in_file.Get(
"tsNew_MINUS_tsCustomPrev__cid")
473 tsNew_MINUS_tsCustomPrev = in_file.Get(
"tsNew_MINUS_tsCustomPrev")
474 clusterTimePeak_ClusterEnergy_varBin = in_file.Get(
"clusterTimePeak_ClusterEnergy_varBin")
475 peakClusterTime_cid = in_file.Get(
"peakClusterTime_cid")
476 peakClusterTimes = in_file.Get(
"peakClusterTimes")
477 g_clusterTimeFractionInWindowInGoodECLRings__cid = in_file.Get(
"g_clusterTimeFractionInWindowInGoodECLRings__cid")
478 clusterTimeFractionInWindow = in_file.Get(
"clusterTimeFractionInWindow")
481 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
482 tsNew_MINUS_tsCustomPrev__cid.SetStats(0)
483 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
484 tsNew_MINUS_tsCustomPrev__cid__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__cid__" +
485 inFileBaseName +
"__block" + str(count) +
".pdf")
486 print(
"tsNew_MINUS_tsCustomPrev__cid__Filename = ", tsNew_MINUS_tsCustomPrev__cid__Filename)
487 myC.Print(tsNew_MINUS_tsCustomPrev__cid__Filename)
490 tsNew_MINUS_tsCustomPrev.Draw(
"")
491 tsNew_MINUS_tsCustomPrev__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__" +
492 inFileBaseName +
"__block" + str(count) +
".pdf")
493 print(
"tsNew_MINUS_tsCustomPrev__Filename = ", tsNew_MINUS_tsCustomPrev__Filename)
494 myC.Print(tsNew_MINUS_tsCustomPrev__Filename)
497 tsNew_MINUS_tsCustomPrev.Draw(
"")
498 tsNew_MINUS_tsCustomPrevLogY__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__logY__" +
499 inFileBaseName +
"__block" + str(count) +
".pdf")
500 print(
"tsNew_MINUS_tsCustomPrevLogY__Filename = ", tsNew_MINUS_tsCustomPrevLogY__Filename)
501 myC.Print(tsNew_MINUS_tsCustomPrevLogY__Filename)
505 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
506 clusterTimePeak_ClusterEnergy_varBin.SetStats(0)
507 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
508 clusterTimePeak_ClusterEnergy_varBin.SetMinimum(-3)
509 clusterTimePeak_ClusterEnergy_varBin.SetMaximum(3)
510 clusterTimePeak_ClusterEnergy_varBinLogX__Filename = str(
"plots/" + bhabhaVal_directory +
511 "__" +
"clusterTimePeak_ClusterEnergy_varBin__logX__" +
512 inFileBaseName +
"__block" + str(count) +
".pdf")
513 print(
"clusterTimePeak_ClusterEnergy_varBinLogX__Filename = ", clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
514 myC.Print(clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
517 peakClusterTime_cid.Draw(
"")
518 peakClusterTime_cid.SetStats(0)
519 peakClusterTime_cid.Draw(
"")
520 peakClusterTime_cid__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"peakClusterTime_cid__" +
521 inFileBaseName +
"__block" + str(count) +
".pdf")
522 print(
"peakClusterTime_cid__Filename = ", peakClusterTime_cid__Filename)
523 myC.Print(peakClusterTime_cid__Filename)
526 peakClusterTimes.Draw(
"")
527 peakClusterTimes__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"peakClusterTimes__" +
528 inFileBaseName +
"__block" + str(count) +
".pdf")
529 print(
"peakClusterTimes__Filename = ", peakClusterTimes__Filename)
530 myC.Print(peakClusterTimes__Filename)
533 g_clusterTimeFractionInWindowInGoodECLRings__cid.Draw(
"")
534 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = str(
536 bhabhaVal_directory +
538 "g_clusterTimeFractionInWindowInGoodECLRings__cid__" +
543 print(
"g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = ",
544 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
545 myC.Print(g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
548 clusterTimeFractionInWindow.Draw(
"")
549 clusterTimeFractionInWindow__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"clusterTimeFractionInWindow__" +
550 inFileBaseName +
"__block" + str(count) +
".pdf")
551 print(
"clusterTimeFractionInWindow__Filename = ", clusterTimeFractionInWindow__Filename)
552 myC.Print(clusterTimeFractionInWindow__Filename)
554 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Draw(
"")
555 myC.Print(
"plots/crystalCalibBlocksBhabhaVal__clusterTime_histMeanStdDev.pdf")
557 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Draw(
"")
558 myC.Print(
"plots/crystalCalibBlocksBhabhaVal__peakClusterTimesGoodFit_histMeanStdDev.pdf")
564 print(
"\n---------------------------------------- \nHadron self-consistency check: \n\n")
565 hadronVal_alg_output_dir = Path(job_path) /
'ECLcrystalTimeCalValidation_hadronPhysics/0/algorithm_output/'
566 hadronVal_files = sorted(hadronVal_alg_output_dir.glob(
'**/eclHadronTValidationAlgorithm_*.root'))
568 print(
"List of hadron validation files:\n")
569 print(hadronVal_files)
571 num_files = len(hadronVal_files)
572 print(f
'Looping over {num_files} files')
573 for count, in_file_name
in enumerate(hadronVal_files, start=1):
574 in_file = r.TFile(str(in_file_name))
575 print(
"--------------------\nReading file ", in_file,
", crystal calib block # = ", count,
"\n")
577 inFileBaseName = str(in_file_name)
578 inFileBaseName = os.path.basename(inFileBaseName)
579 inFileBaseName = inFileBaseName[:-5]
580 print(
"inFileBaseName = ", inFileBaseName)
582 hadVal_directory =
"ECLcrystalTimeCalValidation_hadronPhysics"
585 peakClusterTimesGoodFit = in_file.Get(
"peakClusterTimesGoodFit")
586 clusterTime = in_file.Get(
"clusterTime")
589 title =
"From: " + inFileBaseName
590 title = title +
" : cluster time" +
", block " + str(count)
591 clusterTime.SetTitle(title)
593 clusterTime.Fit(
"gaus")
595 clusterTimeFilename = str(
"plots/" + inFileBaseName +
"__clusterTime__block" + str(count) +
".pdf")
596 print(
"clusterTimeFilename = ", clusterTimeFilename)
597 myC.Print(clusterTimeFilename)
599 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinContent(count, clusterTime.GetMean())
600 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinError(count, clusterTime.GetStdDev())
603 title =
"From: " + inFileBaseName
604 title = title +
" : cluster time fits" +
", block " + str(count)
605 peakClusterTimesGoodFit.SetTitle(title)
606 peakClusterTimesGoodFit.Draw(
"")
607 peakClusterTimesGoodFit.Fit(
"gaus")
609 peakClusterTimesGoodFitFilename = str(
"plots/" + inFileBaseName +
"__peakClusterTimesGoodFit __block" + str(count) +
".pdf")
610 print(
"peakClusterTimesGoodFitFilename = ", peakClusterTimesGoodFitFilename)
611 myC.Print(peakClusterTimesGoodFitFilename)
613 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinContent(count, peakClusterTimesGoodFit.GetMean())
614 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinError(count, peakClusterTimesGoodFit.GetStdDev())
617 tsNew_MINUS_tsCustomPrev__cid = in_file.Get(
"tsNew_MINUS_tsCustomPrev__cid")
618 tsNew_MINUS_tsCustomPrev = in_file.Get(
"tsNew_MINUS_tsCustomPrev")
619 clusterTimePeak_ClusterEnergy_varBin = in_file.Get(
"clusterTimePeak_ClusterEnergy_varBin")
620 peakClusterTime_cid = in_file.Get(
"peakClusterTime_cid")
621 peakClusterTimes = in_file.Get(
"peakClusterTimes")
622 g_clusterTimeFractionInWindowInGoodECLRings__cid = in_file.Get(
"g_clusterTimeFractionInWindowInGoodECLRings__cid")
623 clusterTimeFractionInWindow = in_file.Get(
"clusterTimeFractionInWindow")
626 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
627 tsNew_MINUS_tsCustomPrev__cid.SetStats(0)
628 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
629 tsNew_MINUS_tsCustomPrev__cid__Filename = str(
"plots/" + hadVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__cid__" +
630 inFileBaseName +
"__block" + str(count) +
".pdf")
631 print(
"tsNew_MINUS_tsCustomPrev__cid__Filename = ", tsNew_MINUS_tsCustomPrev__cid__Filename)
632 myC.Print(tsNew_MINUS_tsCustomPrev__cid__Filename)
635 tsNew_MINUS_tsCustomPrev.Draw(
"")
636 tsNew_MINUS_tsCustomPrev__Filename = str(
"plots/" + hadVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__" +
637 inFileBaseName +
"__block" + str(count) +
".pdf")
638 print(
"tsNew_MINUS_tsCustomPrev__Filename = ", tsNew_MINUS_tsCustomPrev__Filename)
639 myC.Print(tsNew_MINUS_tsCustomPrev__Filename)
642 tsNew_MINUS_tsCustomPrev.Draw(
"")
643 tsNew_MINUS_tsCustomPrevLogY__Filename = str(
"plots/" + hadVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__logY__" +
644 inFileBaseName +
"__block" + str(count) +
".pdf")
645 print(
"tsNew_MINUS_tsCustomPrevLogY__Filename = ", tsNew_MINUS_tsCustomPrevLogY__Filename)
646 myC.Print(tsNew_MINUS_tsCustomPrevLogY__Filename)
651 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
652 clusterTimePeak_ClusterEnergy_varBin.SetStats(0)
653 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
654 clusterTimePeak_ClusterEnergy_varBin.SetMinimum(-10)
655 clusterTimePeak_ClusterEnergy_varBin.SetMaximum(5)
656 clusterTimePeak_ClusterEnergy_varBinLogX__Filename = str(
"plots/" + hadVal_directory +
657 "__" +
"clusterTimePeak_ClusterEnergy_varBin__logX__" +
658 inFileBaseName +
"__block" + str(count) +
".pdf")
659 print(
"clusterTimePeak_ClusterEnergy_varBinLogX__Filename = ", clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
660 myC.Print(clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
664 peakClusterTime_cid.Draw(
"")
665 peakClusterTime_cid.SetStats(0)
666 peakClusterTime_cid.Draw(
"")
667 peakClusterTime_cid__Filename = str(
"plots/" + hadVal_directory +
"__" +
"peakClusterTime_cid__" +
668 inFileBaseName +
"__block" + str(count) +
".pdf")
669 print(
"peakClusterTime_cid__Filename = ", peakClusterTime_cid__Filename)
670 myC.Print(peakClusterTime_cid__Filename)
673 peakClusterTimes.Draw(
"")
674 peakClusterTimes__Filename = str(
"plots/" + hadVal_directory +
"__" +
"peakClusterTimes__" +
675 inFileBaseName +
"__block" + str(count) +
".pdf")
676 print(
"peakClusterTimes__Filename = ", peakClusterTimes__Filename)
677 myC.Print(peakClusterTimes__Filename)
680 g_clusterTimeFractionInWindowInGoodECLRings__cid.Draw(
"")
681 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = str(
685 "g_clusterTimeFractionInWindowInGoodECLRings__cid__" +
690 print(
"g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = ",
691 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
692 myC.Print(g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
695 clusterTimeFractionInWindow.Draw(
"")
696 clusterTimeFractionInWindow__Filename = str(
"plots/" + hadVal_directory +
"__" +
"clusterTimeFractionInWindow__" +
697 inFileBaseName +
"__block" + str(count) +
".pdf")
698 print(
"clusterTimeFractionInWindow__Filename = ", clusterTimeFractionInWindow__Filename)
699 myC.Print(clusterTimeFractionInWindow__Filename)
701 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.Draw(
"")
702 myC.Print(
"plots/crystalCalibBlocksHadronVal__clusterTime_histMeanStdDev.pdf")
704 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.Draw(
"")
705 myC.Print(
"plots/crystalCalibBlocksHadronVal__peakClusterTimesGoodFit_histMeanStdDev.pdf")
709 fout = TFile(
"ecl_timing_validateAirflow.root",
"recreate")
711 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Write()
712 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Write()
713 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.Write()
714 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.Write()
719 if __name__ ==
"__main__":
720 run_validation(*sys.argv[1:])