Belle II Software development
run_eclBhabhaT_algorithm.py
1#!/usr/bin/env python3
2
3
10
11
27
28
29import sys
30import ROOT
31import basf2 as b2
32from ROOT import Belle2
33from glob import glob
34
35from basf2 import conditions as b2conditions
36
38
39# Setting just with steering file
40
41# For whether to execute the algorithm over each run invidually or to combine them together in a single plot
42# often it is easier just to only pass a single file to the algorithm code instead of to use this feature
43combineRuns = True
44
45
46# Set up and execute calibration
48
49
50print("Python arguments:")
51counting = 0
52for arg in sys.argv:
53 print(counting, arg)
54 counting = counting + 1
55
56fileNames = ['eclBhabhaTCollector.root']
57narg = len(sys.argv)
58if(narg >= 2):
59 fileNames = glob(sys.argv[1])
60algo.setInputFileNames(fileNames)
61
62basePath = ""
63if(narg >= 3):
64 basePath = sys.argv[2] + "/"
65 print("basePath = ", basePath)
66
67
68algo.cellIDLo = 3
69algo.cellIDHi = 2
70algo.debugOutput = True
71algo.meanCleanRebinFactor = 3 # Rebin factor
72# 0 means no cut. # 1 means keep only bins from max rebinned bin. # Note that with low stats, 0.2 is still too large.
73algo.meanCleanCutMinFactor = 0.3
74# algo.crateIDLo = 10
75# algo.crateIDHi = 9
76algo.debugFilenameBase = "eclBhabhaTAlgorithm"
77
78# Don't need to use this unless I want to change the reference crystals
79# algo.refCrysPerCrate = arr.array('i', [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
80# -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
81# -1,-1,-1]) # 'i' is a signed integer
82
83# Below is equivalent to the first payload version
84# algo.refCrysPerCrate = arr.array('i', [2306, 2309, 2313, 2317, 2321,
85# 2326, 2329, 2334, 2337, 2343, 2348, 2349, 2356, 2357, 2361, 2365, 2372,
86# 2373, 2377, 2381, 2388, 2391, 2393, 2399, 2401, 2407, 2409, 2413, 2417,
87# 2421, 2426, 2429, 2433, 2440, 2585, 2446, 671, 583, 595, 607, 619, 631,
88# 643, 655, 8252, 8177, 8185, 8192, 8206, 8224, 8228, 8244])
89# 'i' is a signed integer
90
91b2.set_debug_level(35)
92b2.set_log_level(b2.LogLevel.INFO) # b2.LogLevel.INFO or b2.LogLevel.DEBUG
93
94
95exprun_vector = algo.getRunListFromAllData()
96
97baseName = "eclBhabhaTAlgorithm"
98basePathAndName = basePath + baseName
99algo.debugFilenameBase = basePathAndName
100
101
102# == Configure database
103b2conditions.reset()
104b2conditions.override_globaltags()
105
106b2.B2INFO("Adding Local Database {} to head of chain of local databases.")
107b2conditions.prepend_testing_payloads("localdb/database.txt")
108b2.B2INFO("Using Global Tag {}")
109b2conditions.prepend_globaltag("dp_recon_release6_patch")
110b2conditions.prepend_globaltag("Reco_master_patch_rel5")
111b2conditions.prepend_globaltag("AIRFLOW_online_snapshot_20210719-124441")
112b2conditions.prepend_globaltag("data_reprocessing_prompt")
113
114
115if (combineRuns):
116 print("Combining all runs' histograms for a single calibration")
117 print("path = ", basePathAndName)
118 alg_result = algo.execute()
119 print("Calibration completion status", alg_result)
120 if (alg_result == 0):
121 algo.commit()
122else:
123 print("Calibrating each run individually")
124 runsWithoutEnoughData = []
125 for exprun in exprun_vector:
126 iov_to_execute = ROOT.vector("std::pair<int,int>")()
127 iov_to_execute.push_back(exprun)
128 print("path = ", basePathAndName)
129 alg_result = algo.execute(iov_to_execute, 0)
130 print("Calibration success-result was", alg_result, " (0=ok, 2=needs more data)")
131 if (alg_result == 0):
132 algo.commit()
133
134
135print("Summary of possible calibration completion status values:")
136print(" c_OK = Finished successfuly = 0 in Python")
137print(" c_Iterate, = Needs iteration = 1 in Python")
138print(" c_NotEnoughData, = Needs more data = 2 in Python")
139print(" c_Failure, = Failed = 3 in Python")
140print(" c_Undefined = Not yet known (before execution) = 4 in Python")
Calibrate ecl crystals using bhabha events.
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28