16 from ROOT
import Belle2, TFile
17 from ROOT.Belle2
import SVDCoGTimeCalibrationAlgorithm
19 from caf.framework
import CAF, Calibration, CentralDatabase
20 from caf
import backends
21 from caf
import strategies
23 import reconstruction
as reco
26 b2.set_log_level(b2.LogLevel.INFO)
28 'SVDShaperDigitsFromTracks',
35 now = datetime.datetime.now()
43 b2.B2INFO(
"Pre-collector")
44 pre_path = b2.create_path()
45 pre_path.add_module(
'RootInput', branchNames=input_branches)
47 pre_path.add_module(
"Gearbox")
48 pre_path.add_module(
"Geometry", useDB=
True)
54 reco.add_svd_reconstruction(pre_path)
56 for moda
in pre_path.modules():
57 if moda.name() ==
'SVDCoGTimeEstimator':
58 moda.param(
"ShaperDigits",
'SVDShaperDigitsFromTracks')
59 moda.param(
"RecoDigits",
'SVDRecoDigitsFromTracks')
60 moda.param(
"CalibrationWithEventT0",
False)
61 if moda.name() ==
'SVDSimpleClusterizer':
62 moda.param(
"Clusters",
'SVDClustersFromTracks')
63 moda.param(
"RecoDigits",
'SVDRecoDigitsFromTracks')
64 moda.param(
"timeAlgorithm", 0)
65 if moda.name() ==
'SVDSpacePointCreator':
66 moda.param(
"SVDClusters",
'SVDClustersFromTracks')
68 pre_path = b2.remove_module(pre_path,
'SVDMissingAPVsClusterCreator')
70 b2.print_path(pre_path)
75 def SVDCoGTimeCalibration(files, tags, uniqueID):
78 path = b2.create_path()
80 path.add_module(
'Progress')
83 collector = b2.register_module(
'SVDTimeCalibrationCollector')
84 collector.param(
"SVDClustersFromTracksName",
"SVDClustersFromTracks")
85 collector.param(
"SVDEventInfoName",
"SVDEventInfo")
86 collector.param(
"EventT0Name",
"EventT0")
87 collector.param(
"granularity",
"run")
90 algorithm = SVDCoGTimeCalibrationAlgorithm(uniqueID)
91 algorithm.setMinEntries(100)
92 algorithm.setAllowedTimeShift(2.)
99 pre_collector_path=pre_collector(),
100 database_chain=[CentralDatabase(tag)
for tag
in tags],
101 output_patterns=
None,
102 max_files_per_collector_job=1,
106 calibration.strategies = strategies.SequentialBoundaries
111 if __name__ ==
"__main__":
121 good_input_files = []
124 for i
in input_files:
125 file_list = glob.glob(i)
128 tree = tf.Get(
"tree")
129 if tree.GetEntries() != 0:
130 good_input_files.append(f)
132 inputStringSplit = f.split(
"/")
133 for string
in inputStringSplit:
134 if string.startswith(
'r0'):
136 runNum = runs.append(int(s_run[1:6]))
137 if string.startswith(
'e0'):
139 expNum = int(s_exp[1:5])
146 if not len(good_input_files):
147 print(
"You have to specify some input file(s)\n"
148 "using the standard basf2 command line option - i")
149 print(
"See: basf2 -h")
154 uniqueID =
"SVDCoGTimeCalibrations_" + str(now.isoformat()) +
"_INFO:_3rdOrderPol_TBindep_Exp" + \
155 str(expNum) +
"_runsFrom" + str(firstRun) +
"to" + str(lastRun)
161 b2.conditions.override_globaltags()
162 svdCoGCAF = SVDCoGTimeCalibration(good_input_files,
164 "data_reprocessing_proc11_baseline",
165 "staging_data_reprocessing_proc11",
166 "svd_NOCoGCorrections"],
170 cal_fw.add_calibration(svdCoGCAF)
171 cal_fw.backend = backends.LSF()
static Environment & Instance()
Static method to get a reference to the Environment instance.
def add_svd_unpacker(path)