Belle II Software development
run_eclBhabhaTimeCalibrationValidation_algorithm.py
1#!/usr/bin/env python3
2
3
10
11
17
18# Usage: basf2 run_eclBhabhaTimeCalibrationValidation_algorithm.py [input_file]
19# Glob expression can be passed as an input file.
20# Example: basf2 run_eclBhabhaTimeCalibrationValidation_algorithm.py "exp_0003_run_*.root"
21
22import sys
23import ROOT
24import basf2 as b2
25from ROOT import Belle2
26from glob import glob
27
28from basf2 import conditions as b2conditions
29
31
32# Setting just with steering file
33
34# For whether to execute the algorithm over each run invidually or to combine them together in a single plot
35# often it is easier just to only pass a single file to the algorithm code instead of to use this feature
36combineRuns = True
37
38
39# Set up and execute calibration
40algo = Belle2.ECL.eclTValidationAlgorithm("eclBhabhaTimeCalibrationValidationCollector")
41
42
43print("Python arguments:")
44counting = 0
45for arg in sys.argv:
46 print(counting, arg)
47 counting = counting + 1
48
49fileNames = ['eclBhabhaTimeCalibrationValidationCollector.root']
50narg = len(sys.argv)
51if(narg >= 2):
52 fileNames = glob(sys.argv[1])
53algo.setInputFileNames(fileNames)
54
55basePath = ""
56if(narg >= 3):
57 basePath = sys.argv[2] + "/"
58 print("basePath = ", basePath)
59
60
61# algo.cellIDLo = 3
62# algo.cellIDHi = 2
63algo.meanCleanRebinFactor = 3 # Rebin factor
64# 0 means no cut. # 1 means keep only bins from max rebinned bin.
65algo.meanCleanCutMinFactor = 0.4
66
67b2.set_debug_level(35)
68b2.set_log_level(b2.LogLevel.INFO) # b2.LogLevel.INFO or b2.LogLevel.DEBUG
69
70
71exprun_vector = algo.getRunListFromAllData()
72
73baseName = "eclBhabhaTValidationAlgorithm"
74basePathAndName = basePath + baseName
75algo.debugFilenameBase = basePathAndName
76
77
78# == Configure database
79b2conditions.reset()
80b2conditions.override_globaltags()
81
82b2.B2INFO("Adding Local Database {} to head of chain of local databases.")
83b2conditions.prepend_testing_payloads("localdb/database.txt")
84b2.B2INFO("Using Global Tag {}")
85b2conditions.prepend_globaltag("dp_recon_release6_patch")
86b2conditions.prepend_globaltag("Reco_master_patch_rel5")
87b2conditions.prepend_globaltag("AIRFLOW_online_snapshot_20210719-124441")
88b2conditions.prepend_globaltag("data_reprocessing_prompt")
89
90
91if (combineRuns):
92 print("Combining all runs' histograms for a single calibration")
93 print("path = ", basePathAndName)
94 alg_result = algo.execute()
95 print("Calibration completion status", alg_result)
96 if (alg_result == 0):
97 algo.commit()
98else:
99 print("Calibrating each run individually")
100 runsWithoutEnoughData = []
101 for exprun in exprun_vector:
102 iov_to_execute = ROOT.vector("std::pair<int,int>")()
103 iov_to_execute.push_back(exprun)
104 print("path = ", basePathAndName)
105 alg_result = algo.execute(iov_to_execute, 0)
106 print("Calibration success-result was", alg_result, " (0=ok, 2=needs more data)")
107 if (alg_result == 0):
108 algo.commit()
109
110
111print("Summary of possible calibration completion status values:")
112print(" c_OK = Finished successfuly = 0 in Python")
113print(" c_Iterate, = Needs iteration = 1 in Python")
114print(" c_NotEnoughData, = Needs more data = 2 in Python")
115print(" c_Failure, = Failed = 3 in Python")
116print(" c_Undefined = Not yet known (before execution) = 4 in Python")
Validate the ecl timing calibrations using a hadronic event selection.
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28