20 import multiprocessing
24 from ROOT
import Belle2, TFile
25 from ROOT.Belle2
import SVDOccupancyCalibrationsAlgorithm
26 from ROOT.Belle2
import SVDHotStripsCalibrationsAlgorithm
28 from caf.framework
import CAF, Calibration, CentralDatabase
29 from caf
import backends
30 from caf
import strategies
35 b2.set_log_level(b2.LogLevel.INFO)
37 now = datetime.datetime.now()
39 uniqueID_hotStrips =
''
45 b2.set_log_level(b2.LogLevel.INFO)
48 def SVDOccupancyAndHotStripsCalibrations(files, tags):
51 path = b2.create_path()
55 path.add_module(
'Progress')
57 path.add_module(
'RootInput', branchNames=input_branches)
59 path.add_module(
"Gearbox")
60 path.add_module(
"Geometry", useDB=
True)
61 raw.add_unpackers(path, components=[
'SVD'])
63 'SVDZeroSuppressionEmulator',
65 ShaperDigits=
'SVDShaperDigits',
66 ShaperDigitsIN=
'SVDShaperDigitsZS5',
69 collector = b2.register_module(
'SVDOccupancyCalibrationsCollector')
70 collector.param(
"SVDShaperDigitsName",
"SVDShaperDigitsZS5")
71 algorithm1 = SVDOccupancyCalibrationsAlgorithm(uniqueID_occup)
72 algorithm2 = SVDHotStripsCalibrationsAlgorithm(uniqueID_hotStrips)
76 calibration =
Calibration(
'SVDOccupancyAndHotStrips',
78 algorithms=[algorithm1, algorithm2],
80 pre_collector_path=path,
81 database_chain=[CentralDatabase(tag)
for tag
in tags],
83 max_files_per_collector_job=1,
87 calibration.strategies = strategies.SequentialRunByRun
92 if __name__ ==
"__main__":
98 .getInputFilesOverride()]
105 good_input_files = []
108 for i
in input_files:
109 file_list = glob.glob(i)
112 tree = tf.Get(
"tree")
113 if tree.GetEntries() != 0:
114 good_input_files.append(f)
116 inputStringSplit = f.split(
"/")
117 s_run = str(inputStringSplit[7])
118 s_exp = str(inputStringSplit[6])
119 print(str(s_run) +
" " + str(s_exp))
120 runNum = runs.append(int(s_run[1:6]))
121 runNum = int(s_run[1:6])
122 expNum = int(s_exp[1:5])
128 if not len(input_files):
129 print(
"You have to specify some input file(s)\n"
130 "using the standard basf2 command line option - i")
131 print(
"See: basf2 -h")
134 uniqueID_occup =
"SVDOccupancyCalibrations_" + \
135 str(now.isoformat()) +
"_INFO:_ZS5_Exp" + str(expNum) +
"_runsFrom" + \
136 str(firstRun) +
"to" + str(lastRun)
138 print(
"UniqueID for SVDccupancyCalibrations")
140 print(str(uniqueID_occup))
143 uniqueID_hotStrips =
"SVDHotStripsCalibrations_" + \
144 str(now.isoformat()) +
"_INFO:_ZS5_base=-1_relOccPrec=5_absOccThr=0.2_Exp"\
145 + str(expNum) +
"_runsFrom" + str(firstRun) +
"to" + str(lastRun)
146 print(
"UniqueID for SVDHotStripsCalibrations")
148 print(str(uniqueID_hotStrips))
151 svdOccupAndHotStripsCAF = SVDOccupancyAndHotStripsCalibrations(input_files,
152 [
'data_reprocessing_prompt',
'svd_basic',
'online'])
155 cal_fw.add_calibration(svdOccupAndHotStripsCAF)
157 cal_fw.backend = backends.LSF()
160 if multiprocessing.cpu_count() < 10:
161 cal_fw.backend = backends.Local(8)
static Environment & Instance()
Static method to get a reference to the Environment instance.