13from prompt
import ValidationSettings
15from pathlib
import Path
23settings = ValidationSettings(name=
'ECL crystal and crate time calibrations and validations',
25 download_files=[
'stdout'],
29def run_validation(job_path, input_data_path, requested_iov, expert_config, **kwargs):
34 from ROOT
import TH1F, TCanvas, TFile, gStyle
42 print(
"job_path = ", job_path)
43 print(
"input_data_path = ", input_data_path)
44 print(
"requested_iov = ", requested_iov)
45 print(
"expert_config = ", expert_config)
47 if not os.path.exists(
'plots'):
51 gStyle.SetOptStat(1111111)
52 gStyle.SetOptFit(1111)
58 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal = TH1F(
59 "clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal",
60 "Bhabha: Cluster t means;Block of runs with one crystal calibration;Mean elec ECL cluster time / run block. Err = RMS",
62 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal = TH1F(
63 "peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal",
64 "Bhabha: Mean(cluster t fit means);Runs of const crys calib;Mean(elec time fit mean / crys)/run block. Err=fit sigma",
67 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal = TH1F(
68 "clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal",
69 "Hadron: Cluster t means;Block of runs with one crystal calibration;Mean photon ECL cluster time / run block. Err = RMS",
71 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal = TH1F(
72 "peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal",
73 "Hadron: Mean(cluster t fit means);Runs of const crys calib;Mean(photon time fit mean / crys)/run block. Err=fit sigma",
82 print(
"\n---------------------------------------- \nBhabha crate calibrations: \n\n")
83 crate_calib_output_dir = Path(job_path)
84 crate_calib_files = sorted(crate_calib_output_dir.glob(
'**/eclBhabhaTAlgorithm_cratesAllRuns.root'))
86 print(
"List of crate calibration files:\n")
87 print(crate_calib_files)
89 num_files = len(crate_calib_files)
90 print(f
'Looping over {num_files} files')
91 for count, in_file_name
in enumerate(crate_calib_files, start=1):
92 in_file = TFile(str(in_file_name))
93 print(
"--------------------\nReading file ", in_file,
"\n Crate calib iteration = ", count,
"\n")
95 inFileBaseName = str(in_file_name)
96 inFileBaseName = os.path.basename(inFileBaseName)
97 inFileBaseName = inFileBaseName[:-5]
98 print(
"inFileBaseName = ", inFileBaseName)
101 crate_calib_directory_iter = os.path.split(os.path.split(os.path.split(os.path.dirname(in_file_name))[0])[0])[1]
104 tcrateNew_MINUS_tcrateOld_allRuns = in_file.Get(
"tcrateNew_MINUS_tcrateOld_allRuns")
105 tcrateNew_MINUS_tcrateOld_allRuns_allCrates = in_file.Get(
"tcrateNew_MINUS_tcrateOld_allRuns_allCrates")
108 tcrateNew_MINUS_tcrateOld_allRuns.Draw(
"")
109 tcrateNew_MINUS_tcrateOld_allRuns__Filename = str(
111 crate_calib_directory_iter +
113 "tcrateNew_MINUS_tcrateOld_allRuns__" +
118 print(
"tcrateNew_MINUS_tcrateOld_allRuns__Filename = ", tcrateNew_MINUS_tcrateOld_allRuns__Filename)
119 myC.Print(tcrateNew_MINUS_tcrateOld_allRuns__Filename)
122 tcrateNew_MINUS_tcrateOld_allRuns.Draw(
"")
123 tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename = str(
"plots/" + crate_calib_directory_iter +
"__" +
124 "tcrateNew_MINUS_tcrateOld_allRuns__logY__" +
125 inFileBaseName +
"__counter" + str(count) +
".pdf")
126 print(
"tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename = ", tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename)
127 myC.Print(tcrateNew_MINUS_tcrateOld_allRunsLogY__Filename)
131 tcrateNew_MINUS_tcrateOld_allRuns_allCrates.Draw(
"")
132 tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename = str(
"plots/" + crate_calib_directory_iter +
"__" +
133 "tcrateNew_MINUS_tcrateOld_allRuns_allCrates__" +
134 inFileBaseName +
"__counter" + str(count) +
".pdf")
135 print(
"tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename = ", tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename)
136 myC.Print(tcrateNew_MINUS_tcrateOld_allRuns_allCrates__Filename)
139 tcrateNew_MINUS_tcrateOld_allRuns_allCrates.Draw(
"")
140 tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename = str(
142 crate_calib_directory_iter +
144 "tcrateNew_MINUS_tcrateOld_allRuns_allCrates__logY__" +
149 print(
"tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename = ",
150 tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename)
151 myC.Print(tcrateNew_MINUS_tcrateOld_allRuns_allCratesLogY__Filename)
158 print(
"\n---------------------------------------- \nBhabha crystal calibrations: \n\n")
159 crystal_calib_output_dir = Path(job_path)
160 crystal_calib_files = sorted(crystal_calib_output_dir.glob(
161 '**/ECLcrystalTimeCalibration_physics_*/*/*/eclBhabhaTAlgorithm_*.root'))
163 print(
"List of crystal calibration files:\n")
164 print(crystal_calib_files)
166 num_files = len(crystal_calib_files)
167 print(f
'Looping over {num_files} files')
168 for count, in_file_name
in enumerate(crystal_calib_files, start=1):
169 in_file = TFile(str(in_file_name))
170 print(
"--------------------\nReading file ", in_file,
"\n crystal calib iteration = ", count,
"\n")
172 inFileBaseName = str(in_file_name)
173 inFileBaseName = os.path.basename(inFileBaseName)
174 inFileBaseName = inFileBaseName[:-5]
175 print(
"inFileBaseName = ", inFileBaseName)
178 crystal_calib_directory_iter = os.path.split(os.path.split(os.path.split(os.path.dirname(in_file_name))[0])[0])[1]
181 tsNew_MINUS_tsOld__cid = in_file.Get(
"tsNew_MINUS_tsOld__cid")
182 tsNew_MINUS_tsOld = in_file.Get(
"tsNew_MINUS_tsOld")
183 tsNew_MINUS_tsCustomPrev__cid = in_file.Get(
"tsNew_MINUS_tsCustomPrev__cid")
184 tsNew_MINUS_tsCustomPrev = in_file.Get(
"tsNew_MINUS_tsCustomPrev")
185 tsNew_MINUS_tsOldBhabha__cid = in_file.Get(
"tsNew_MINUS_tsOldBhabha__cid")
186 tsNew_MINUS_tsOldBhabha = in_file.Get(
"tsNew_MINUS_tsOldBhabha")
187 cutflow = in_file.Get(
"cutflow")
188 h_crysHits = in_file.Get(
"h_crysHits")
191 tsNew_MINUS_tsOld__cid.Draw(
"")
192 tsNew_MINUS_tsOld__cid.SetStats(0)
193 tsNew_MINUS_tsOld__cid.Draw(
"")
194 tsNew_MINUS_tsOld__cid__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOld__cid__" +
195 inFileBaseName +
"__counter" + str(count) +
".pdf")
196 print(
"tsNew_MINUS_tsOld__cid__Filename = ", tsNew_MINUS_tsOld__cid__Filename)
197 myC.Print(tsNew_MINUS_tsOld__cid__Filename)
200 tsNew_MINUS_tsOld.Draw(
"")
201 tsNew_MINUS_tsOld__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOld__" +
202 inFileBaseName +
"__counter" + str(count) +
".pdf")
203 print(
"tsNew_MINUS_tsOld__Filename = ", tsNew_MINUS_tsOld__Filename)
204 myC.Print(tsNew_MINUS_tsOld__Filename)
207 tsNew_MINUS_tsOld.Draw(
"")
208 tsNew_MINUS_tsOldLogY__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOld__logY__" +
209 inFileBaseName +
"__counter" + str(count) +
".pdf")
210 print(
"tsNew_MINUS_tsOldLogY__Filename = ", tsNew_MINUS_tsOldLogY__Filename)
211 myC.Print(tsNew_MINUS_tsOldLogY__Filename)
215 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
216 tsNew_MINUS_tsCustomPrev__cid.SetStats(0)
217 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
218 tsNew_MINUS_tsCustomPrev__cid__Filename = str(
220 crystal_calib_directory_iter +
222 "tsNew_MINUS_tsCustomPrev__cid__" +
227 print(
"tsNew_MINUS_tsCustomPrev__cid__Filename = ", tsNew_MINUS_tsCustomPrev__cid__Filename)
228 myC.Print(tsNew_MINUS_tsCustomPrev__cid__Filename)
231 tsNew_MINUS_tsCustomPrev.Draw(
"")
232 tsNew_MINUS_tsCustomPrev__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsCustomPrev__" +
233 inFileBaseName +
"__counter" + str(count) +
".pdf")
234 print(
"tsNew_MINUS_tsCustomPrev__Filename = ", tsNew_MINUS_tsCustomPrev__Filename)
235 myC.Print(tsNew_MINUS_tsCustomPrev__Filename)
238 tsNew_MINUS_tsCustomPrev.Draw(
"")
239 tsNew_MINUS_tsCustomPrevLogY__Filename = str(
241 crystal_calib_directory_iter +
243 "tsNew_MINUS_tsCustomPrev__logY__" +
248 print(
"tsNew_MINUS_tsCustomPrevLogY__Filename = ", tsNew_MINUS_tsCustomPrevLogY__Filename)
249 myC.Print(tsNew_MINUS_tsCustomPrevLogY__Filename)
253 tsNew_MINUS_tsOldBhabha__cid.Draw(
"")
254 tsNew_MINUS_tsOldBhabha__cid.SetStats(0)
255 tsNew_MINUS_tsOldBhabha__cid.Draw(
"")
256 tsNew_MINUS_tsOldBhabha__cid__Filename = str(
258 crystal_calib_directory_iter +
260 "tsNew_MINUS_tsOldBhabha__cid__" +
265 print(
"tsNew_MINUS_tsOldBhabha__cid__Filename = ", tsNew_MINUS_tsOldBhabha__cid__Filename)
266 myC.Print(tsNew_MINUS_tsOldBhabha__cid__Filename)
269 tsNew_MINUS_tsOldBhabha.Draw(
"")
270 tsNew_MINUS_tsOldBhabha__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"tsNew_MINUS_tsOldBhabha__" +
271 inFileBaseName +
"__counter" + str(count) +
".pdf")
272 print(
"tsNew_MINUS_tsOldBhabha__Filename = ", tsNew_MINUS_tsOldBhabha__Filename)
273 myC.Print(tsNew_MINUS_tsOldBhabha__Filename)
276 tsNew_MINUS_tsOldBhabha.Draw(
"")
277 tsNew_MINUS_tsOldBhabhaLogY__Filename = str(
279 crystal_calib_directory_iter +
281 "tsNew_MINUS_tsOldBhabha__logY__" +
286 print(
"tsNew_MINUS_tsOldBhabhaLogY__Filename = ", tsNew_MINUS_tsOldBhabhaLogY__Filename)
287 myC.Print(tsNew_MINUS_tsOldBhabhaLogY__Filename)
292 cutflow__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"cutflow__" +
293 inFileBaseName +
"__counter" + str(count) +
".pdf")
294 print(
"cutflow__Filename = ", cutflow__Filename)
295 myC.Print(cutflow__Filename)
300 h_crysHits.SetStats(0)
302 h_crysHits__Filename = str(
"plots/" + crystal_calib_directory_iter +
"__" +
"h_crysHits__" +
303 inFileBaseName +
"__counter" + str(count) +
".pdf")
304 print(
"h_crysHits__Filename = ", h_crysHits__Filename)
305 myC.Print(h_crysHits__Filename)
312 print(
"\n---------------------------------------- \nBhabha calibration crystal mergers: \n\n")
313 merger_alg_output_dir = Path(job_path)
314 merger_files = sorted(merger_alg_output_dir.glob(
'**/ECLCrystalTimeOffsetMerged_*.root'))
316 print(
"List of bhabha validation files:\n")
319 num_files = len(merger_files)
320 print(f
'Looping over {num_files} files')
321 for count, in_file_name
in enumerate(merger_files, start=1):
322 in_file = TFile(str(in_file_name))
323 print(
"--------------------\nReading file ", in_file,
"\n Crystal calib iteration or blocks = ", count,
"\n")
325 inFileBaseName = str(in_file_name)
326 inFileBaseName = os.path.basename(inFileBaseName)
327 inFileBaseName = inFileBaseName[:-5]
328 print(
"inFileBaseName = ", inFileBaseName)
331 merge_directory_iter = os.path.split(os.path.split(os.path.split(os.path.dirname(in_file_name))[0])[0])[1]
334 newBhabhaMinusCustomPrev__cid = in_file.Get(
"newBhabhaMinusCustomPrev__cid")
335 newBhabhaMinusCustomPrevBhabha__cid = in_file.Get(
"newBhabhaMinusCustomPrevBhabha__cid")
336 TsNewBhabha_MINUS_TsCustomPrev = in_file.Get(
"TsNewBhabha_MINUS_TsCustomPrev")
337 TsNewBhabha_MINUS_TsCustomPrevBhabha = in_file.Get(
"TsNewBhabha_MINUS_TsCustomPrevBhabha")
340 newBhabhaMinusCustomPrev__cid.Draw(
"")
341 newBhabhaMinusCustomPrev__cid.SetStats(0)
342 newBhabhaMinusCustomPrev__cid.Draw(
"")
343 newBhabhaMinusCustomPrev__cid__Filename = str(
"plots/" + merge_directory_iter +
"__" +
"newBhabhaMinusCustomPrev__cid__" +
344 inFileBaseName +
"__counter" + str(count) +
".pdf")
345 print(
"newBhabhaMinusCustomPrev__cid__Filename = ", newBhabhaMinusCustomPrev__cid__Filename)
346 myC.Print(newBhabhaMinusCustomPrev__cid__Filename)
349 newBhabhaMinusCustomPrevBhabha__cid.Draw(
"")
350 newBhabhaMinusCustomPrevBhabha__cid.SetStats(0)
351 newBhabhaMinusCustomPrevBhabha__cid.Draw(
"")
352 newBhabhaMinusCustomPrevBhabha__cid__Filename = str(
354 merge_directory_iter +
356 "newBhabhaMinusCustomPrevBhabha__cid__" +
361 print(
"newBhabhaMinusCustomPrevBhabha__cid__Filename = ", newBhabhaMinusCustomPrevBhabha__cid__Filename)
362 myC.Print(newBhabhaMinusCustomPrevBhabha__cid__Filename)
365 TsNewBhabha_MINUS_TsCustomPrev.Draw(
"")
366 TsNewBhabha_MINUS_TsCustomPrev__Filename = str(
"plots/" + merge_directory_iter +
"__" +
"TsNewBhabha_MINUS_TsCustomPrev__" +
367 inFileBaseName +
"__counter" + str(count) +
".pdf")
368 print(
"TsNewBhabha_MINUS_TsCustomPrev__Filename = ", TsNewBhabha_MINUS_TsCustomPrev__Filename)
369 myC.Print(TsNewBhabha_MINUS_TsCustomPrev__Filename)
372 TsNewBhabha_MINUS_TsCustomPrev.Draw(
"")
373 TsNewBhabha_MINUS_TsCustomPrevLogY__Filename = str(
375 merge_directory_iter +
377 "TsNewBhabha_MINUS_TsCustomPrev__logY__" +
382 print(
"TsNewBhabha_MINUS_TsCustomPrevLogY__Filename = ", TsNewBhabha_MINUS_TsCustomPrevLogY__Filename)
383 myC.Print(TsNewBhabha_MINUS_TsCustomPrevLogY__Filename)
387 TsNewBhabha_MINUS_TsCustomPrevBhabha.Draw(
"")
388 TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename = str(
390 merge_directory_iter +
392 "TsNewBhabha_MINUS_TsCustomPrevBhabha__" +
397 print(
"TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename = ", TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename)
398 myC.Print(TsNewBhabha_MINUS_TsCustomPrevBhabha__Filename)
401 TsNewBhabha_MINUS_TsCustomPrevBhabha.Draw(
"")
402 TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename = str(
"plots/" + merge_directory_iter +
403 "__" +
"TsNewBhabha_MINUS_TsCustomPrevBhabha__logY__" +
404 inFileBaseName +
"__counter" + str(count) +
".pdf")
405 print(
"TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename = ", TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename)
406 myC.Print(TsNewBhabha_MINUS_TsCustomPrevBhabhaLogY__Filename)
413 print(
"\n---------------------------------------- \nBhabha self-consistency check: \n\n")
414 bhabhaVal_alg_output_dir = Path(job_path) /
'ECLcrystalTimeCalValidation_bhabhaPhysics/0/algorithm_output/'
415 bhabhaVal_files = sorted(bhabhaVal_alg_output_dir.glob(
'**/eclBhabhaTValidationAlgorithm_*.root'))
417 print(
"List of bhabha validation files:\n")
418 print(bhabhaVal_files)
420 num_files = len(bhabhaVal_files)
421 print(f
'Looping over {num_files} files')
422 for count, in_file_name
in enumerate(bhabhaVal_files, start=1):
423 in_file = TFile(str(in_file_name))
424 print(
"--------------------\nReading file ", in_file,
", crystal calib block # = ", count,
"\n")
426 inFileBaseName = str(in_file_name)
427 inFileBaseName = os.path.basename(inFileBaseName)
428 inFileBaseName = inFileBaseName[:-5]
429 print(
"inFileBaseName = ", inFileBaseName)
431 bhabhaVal_directory =
"ECLcrystalTimeCalValidation_bhabhaPhysics"
434 peakClusterTimesGoodFit = in_file.Get(
"peakClusterTimesGoodFit")
435 clusterTime = in_file.Get(
"clusterTime")
438 title =
"From: " + inFileBaseName
439 title = title +
" : cluster time" +
", block " + str(count)
440 clusterTime.SetTitle(title)
442 clusterTime.Fit(
"gaus")
444 clusterTimeFilename = str(
"plots/" + inFileBaseName +
"__clusterTime__block" + str(count) +
".pdf")
445 print(
"clusterTimeFilename = ", clusterTimeFilename)
446 myC.Print(clusterTimeFilename)
448 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinContent(count, clusterTime.GetMean())
449 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinError(count, clusterTime.GetStdDev())
452 title =
"From: " + inFileBaseName
453 title = title +
" : cluster time fits" +
", block " + str(count)
454 peakClusterTimesGoodFit.SetTitle(title)
455 peakClusterTimesGoodFit.Draw(
"")
456 peakClusterTimesGoodFit.Fit(
"gaus")
458 peakClusterTimesGoodFitFilename = str(
"plots/" + inFileBaseName +
"__peakClusterTimesGoodFit__block" + str(count) +
".pdf")
459 print(
"peakClusterTimesGoodFitFilename = ", peakClusterTimesGoodFitFilename)
460 myC.Print(peakClusterTimesGoodFitFilename)
462 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinContent(count, peakClusterTimesGoodFit.GetMean())
463 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.SetBinError(count, peakClusterTimesGoodFit.GetStdDev())
466 tsNew_MINUS_tsCustomPrev__cid = in_file.Get(
"tsNew_MINUS_tsCustomPrev__cid")
467 tsNew_MINUS_tsCustomPrev = in_file.Get(
"tsNew_MINUS_tsCustomPrev")
468 clusterTimePeak_ClusterEnergy_varBin = in_file.Get(
"clusterTimePeak_ClusterEnergy_varBin")
469 peakClusterTime_cid = in_file.Get(
"peakClusterTime_cid")
470 peakClusterTimes = in_file.Get(
"peakClusterTimes")
471 g_clusterTimeFractionInWindowInGoodECLRings__cid = in_file.Get(
"g_clusterTimeFractionInWindowInGoodECLRings__cid")
472 clusterTimeFractionInWindow = in_file.Get(
"clusterTimeFractionInWindow")
475 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
476 tsNew_MINUS_tsCustomPrev__cid.SetStats(0)
477 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
478 tsNew_MINUS_tsCustomPrev__cid__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__cid__" +
479 inFileBaseName +
"__block" + str(count) +
".pdf")
480 print(
"tsNew_MINUS_tsCustomPrev__cid__Filename = ", tsNew_MINUS_tsCustomPrev__cid__Filename)
481 myC.Print(tsNew_MINUS_tsCustomPrev__cid__Filename)
484 tsNew_MINUS_tsCustomPrev.Draw(
"")
485 tsNew_MINUS_tsCustomPrev__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__" +
486 inFileBaseName +
"__block" + str(count) +
".pdf")
487 print(
"tsNew_MINUS_tsCustomPrev__Filename = ", tsNew_MINUS_tsCustomPrev__Filename)
488 myC.Print(tsNew_MINUS_tsCustomPrev__Filename)
491 tsNew_MINUS_tsCustomPrev.Draw(
"")
492 tsNew_MINUS_tsCustomPrevLogY__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__logY__" +
493 inFileBaseName +
"__block" + str(count) +
".pdf")
494 print(
"tsNew_MINUS_tsCustomPrevLogY__Filename = ", tsNew_MINUS_tsCustomPrevLogY__Filename)
495 myC.Print(tsNew_MINUS_tsCustomPrevLogY__Filename)
499 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
500 clusterTimePeak_ClusterEnergy_varBin.SetStats(0)
501 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
502 clusterTimePeak_ClusterEnergy_varBin.SetMinimum(-3)
503 clusterTimePeak_ClusterEnergy_varBin.SetMaximum(3)
504 clusterTimePeak_ClusterEnergy_varBinLogX__Filename = str(
"plots/" + bhabhaVal_directory +
505 "__" +
"clusterTimePeak_ClusterEnergy_varBin__logX__" +
506 inFileBaseName +
"__block" + str(count) +
".pdf")
507 print(
"clusterTimePeak_ClusterEnergy_varBinLogX__Filename = ", clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
508 myC.Print(clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
511 peakClusterTime_cid.Draw(
"")
512 peakClusterTime_cid.SetStats(0)
513 peakClusterTime_cid.Draw(
"")
514 peakClusterTime_cid__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"peakClusterTime_cid__" +
515 inFileBaseName +
"__block" + str(count) +
".pdf")
516 print(
"peakClusterTime_cid__Filename = ", peakClusterTime_cid__Filename)
517 myC.Print(peakClusterTime_cid__Filename)
520 peakClusterTimes.Draw(
"")
521 peakClusterTimes__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"peakClusterTimes__" +
522 inFileBaseName +
"__block" + str(count) +
".pdf")
523 print(
"peakClusterTimes__Filename = ", peakClusterTimes__Filename)
524 myC.Print(peakClusterTimes__Filename)
527 g_clusterTimeFractionInWindowInGoodECLRings__cid.Draw(
"")
528 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = str(
530 bhabhaVal_directory +
532 "g_clusterTimeFractionInWindowInGoodECLRings__cid__" +
537 print(
"g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = ",
538 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
539 myC.Print(g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
542 clusterTimeFractionInWindow.Draw(
"")
543 clusterTimeFractionInWindow__Filename = str(
"plots/" + bhabhaVal_directory +
"__" +
"clusterTimeFractionInWindow__" +
544 inFileBaseName +
"__block" + str(count) +
".pdf")
545 print(
"clusterTimeFractionInWindow__Filename = ", clusterTimeFractionInWindow__Filename)
546 myC.Print(clusterTimeFractionInWindow__Filename)
548 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Draw(
"")
549 myC.Print(
"plots/crystalCalibBlocksBhabhaVal__clusterTime_histMeanStdDev.pdf")
551 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Draw(
"")
552 myC.Print(
"plots/crystalCalibBlocksBhabhaVal__peakClusterTimesGoodFit_histMeanStdDev.pdf")
558 print(
"\n---------------------------------------- \nHadron self-consistency check: \n\n")
559 hadronVal_alg_output_dir = Path(job_path) /
'ECLcrystalTimeCalValidation_hadronPhysics/0/algorithm_output/'
560 hadronVal_files = sorted(hadronVal_alg_output_dir.glob(
'**/eclHadronTValidationAlgorithm_*.root'))
562 print(
"List of hadron validation files:\n")
563 print(hadronVal_files)
565 num_files = len(hadronVal_files)
566 print(f
'Looping over {num_files} files')
567 for count, in_file_name
in enumerate(hadronVal_files, start=1):
568 in_file = TFile(str(in_file_name))
569 print(
"--------------------\nReading file ", in_file,
", crystal calib block # = ", count,
"\n")
571 inFileBaseName = str(in_file_name)
572 inFileBaseName = os.path.basename(inFileBaseName)
573 inFileBaseName = inFileBaseName[:-5]
574 print(
"inFileBaseName = ", inFileBaseName)
576 hadVal_directory =
"ECLcrystalTimeCalValidation_hadronPhysics"
579 peakClusterTimesGoodFit = in_file.Get(
"peakClusterTimesGoodFit")
580 clusterTime = in_file.Get(
"clusterTime")
583 title =
"From: " + inFileBaseName
584 title = title +
" : cluster time" +
", block " + str(count)
585 clusterTime.SetTitle(title)
587 clusterTime.Fit(
"gaus")
589 clusterTimeFilename = str(
"plots/" + inFileBaseName +
"__clusterTime__block" + str(count) +
".pdf")
590 print(
"clusterTimeFilename = ", clusterTimeFilename)
591 myC.Print(clusterTimeFilename)
593 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinContent(count, clusterTime.GetMean())
594 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinError(count, clusterTime.GetStdDev())
597 title =
"From: " + inFileBaseName
598 title = title +
" : cluster time fits" +
", block " + str(count)
599 peakClusterTimesGoodFit.SetTitle(title)
600 peakClusterTimesGoodFit.Draw(
"")
601 peakClusterTimesGoodFit.Fit(
"gaus")
603 peakClusterTimesGoodFitFilename = str(
"plots/" + inFileBaseName +
"__peakClusterTimesGoodFit __block" + str(count) +
".pdf")
604 print(
"peakClusterTimesGoodFitFilename = ", peakClusterTimesGoodFitFilename)
605 myC.Print(peakClusterTimesGoodFitFilename)
607 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinContent(count, peakClusterTimesGoodFit.GetMean())
608 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.SetBinError(count, peakClusterTimesGoodFit.GetStdDev())
611 tsNew_MINUS_tsCustomPrev__cid = in_file.Get(
"tsNew_MINUS_tsCustomPrev__cid")
612 tsNew_MINUS_tsCustomPrev = in_file.Get(
"tsNew_MINUS_tsCustomPrev")
613 clusterTimePeak_ClusterEnergy_varBin = in_file.Get(
"clusterTimePeak_ClusterEnergy_varBin")
614 peakClusterTime_cid = in_file.Get(
"peakClusterTime_cid")
615 peakClusterTimes = in_file.Get(
"peakClusterTimes")
616 g_clusterTimeFractionInWindowInGoodECLRings__cid = in_file.Get(
"g_clusterTimeFractionInWindowInGoodECLRings__cid")
617 clusterTimeFractionInWindow = in_file.Get(
"clusterTimeFractionInWindow")
620 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
621 tsNew_MINUS_tsCustomPrev__cid.SetStats(0)
622 tsNew_MINUS_tsCustomPrev__cid.Draw(
"")
623 tsNew_MINUS_tsCustomPrev__cid__Filename = str(
"plots/" + hadVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__cid__" +
624 inFileBaseName +
"__block" + str(count) +
".pdf")
625 print(
"tsNew_MINUS_tsCustomPrev__cid__Filename = ", tsNew_MINUS_tsCustomPrev__cid__Filename)
626 myC.Print(tsNew_MINUS_tsCustomPrev__cid__Filename)
629 tsNew_MINUS_tsCustomPrev.Draw(
"")
630 tsNew_MINUS_tsCustomPrev__Filename = str(
"plots/" + hadVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__" +
631 inFileBaseName +
"__block" + str(count) +
".pdf")
632 print(
"tsNew_MINUS_tsCustomPrev__Filename = ", tsNew_MINUS_tsCustomPrev__Filename)
633 myC.Print(tsNew_MINUS_tsCustomPrev__Filename)
636 tsNew_MINUS_tsCustomPrev.Draw(
"")
637 tsNew_MINUS_tsCustomPrevLogY__Filename = str(
"plots/" + hadVal_directory +
"__" +
"tsNew_MINUS_tsCustomPrev__logY__" +
638 inFileBaseName +
"__block" + str(count) +
".pdf")
639 print(
"tsNew_MINUS_tsCustomPrevLogY__Filename = ", tsNew_MINUS_tsCustomPrevLogY__Filename)
640 myC.Print(tsNew_MINUS_tsCustomPrevLogY__Filename)
645 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
646 clusterTimePeak_ClusterEnergy_varBin.SetStats(0)
647 clusterTimePeak_ClusterEnergy_varBin.Draw(
"")
648 clusterTimePeak_ClusterEnergy_varBin.SetMinimum(-10)
649 clusterTimePeak_ClusterEnergy_varBin.SetMaximum(5)
650 clusterTimePeak_ClusterEnergy_varBinLogX__Filename = str(
"plots/" + hadVal_directory +
651 "__" +
"clusterTimePeak_ClusterEnergy_varBin__logX__" +
652 inFileBaseName +
"__block" + str(count) +
".pdf")
653 print(
"clusterTimePeak_ClusterEnergy_varBinLogX__Filename = ", clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
654 myC.Print(clusterTimePeak_ClusterEnergy_varBinLogX__Filename)
658 peakClusterTime_cid.Draw(
"")
659 peakClusterTime_cid.SetStats(0)
660 peakClusterTime_cid.Draw(
"")
661 peakClusterTime_cid__Filename = str(
"plots/" + hadVal_directory +
"__" +
"peakClusterTime_cid__" +
662 inFileBaseName +
"__block" + str(count) +
".pdf")
663 print(
"peakClusterTime_cid__Filename = ", peakClusterTime_cid__Filename)
664 myC.Print(peakClusterTime_cid__Filename)
667 peakClusterTimes.Draw(
"")
668 peakClusterTimes__Filename = str(
"plots/" + hadVal_directory +
"__" +
"peakClusterTimes__" +
669 inFileBaseName +
"__block" + str(count) +
".pdf")
670 print(
"peakClusterTimes__Filename = ", peakClusterTimes__Filename)
671 myC.Print(peakClusterTimes__Filename)
674 g_clusterTimeFractionInWindowInGoodECLRings__cid.Draw(
"")
675 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = str(
679 "g_clusterTimeFractionInWindowInGoodECLRings__cid__" +
684 print(
"g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename = ",
685 g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
686 myC.Print(g_clusterTimeFractionInWindowInGoodECLRings__cid__Filename)
689 clusterTimeFractionInWindow.Draw(
"")
690 clusterTimeFractionInWindow__Filename = str(
"plots/" + hadVal_directory +
"__" +
"clusterTimeFractionInWindow__" +
691 inFileBaseName +
"__block" + str(count) +
".pdf")
692 print(
"clusterTimeFractionInWindow__Filename = ", clusterTimeFractionInWindow__Filename)
693 myC.Print(clusterTimeFractionInWindow__Filename)
695 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.Draw(
"")
696 myC.Print(
"plots/crystalCalibBlocksHadronVal__clusterTime_histMeanStdDev.pdf")
698 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.Draw(
"")
699 myC.Print(
"plots/crystalCalibBlocksHadronVal__peakClusterTimesGoodFit_histMeanStdDev.pdf")
703 fout = TFile(
"ecl_timing_validateAirflow.root",
"recreate")
705 clusterTime_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Write()
706 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksBhabhaVal.Write()
707 clusterTime_histMeanStdDev_CrystalCalibBlocksHadronVal.Write()
708 peakClusterTimesGoodFit_histMeanStdDev_CrystalCalibBlocksHadronVal.Write()
713if __name__ ==
"__main__":