16from ROOT
import Belle2, TFile
17from ROOT.Belle2
import SVD3SampleCoGTimeCalibrationAlgorithm
19from caf.framework
import CAF, Calibration, CentralDatabase
20from caf
import backends
21from caf
import strategies
23import reconstruction
as reco
26b2.set_log_level(b2.LogLevel.INFO)
28 'SVDShaperDigitsFromTracks',
35now = 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 if moda.name() ==
'SVDSimpleClusterizer':
61 moda.param(
"Clusters",
'SVDClustersFromTracks')
62 moda.param(
"RecoDigits",
'SVDRecoDigitsFromTracks')
63 moda.param(
"ShaperDigits",
'SVDShaperDigitsFromTracks')
64 moda.param(
"timeAlgorithm", 1)
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)
75def 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")
88 collector.param(
"RawCoGBinWidth", 0.5)
91 algorithm = SVD3SampleCoGTimeCalibrationAlgorithm(uniqueID)
92 algorithm.setMinEntries(100)
93 algorithm.setAllowedTimeShift(2.)
100 pre_collector_path=pre_collector(),
101 database_chain=[CentralDatabase(tag)
for tag
in tags],
102 output_patterns=
None,
103 max_files_per_collector_job=1,
107 calibration.strategies = strategies.SequentialBoundaries
112if __name__ ==
"__main__":
122 good_input_files = []
125 for i
in input_files:
126 file_list = glob.glob(i)
129 tree = tf.Get(
"tree")
130 if tree.GetEntries() != 0:
131 good_input_files.append(f)
133 inputStringSplit = f.split(
"/")
134 for string
in inputStringSplit:
135 if string.startswith(
'r0'):
137 runNum = runs.append(int(s_run[1:6]))
138 if string.startswith(
'e0'):
140 expNum = int(s_exp[1:5])
147 if not len(good_input_files):
148 print(
"You have to specify some input file(s)\n"
149 "using the standard basf2 command line option - i")
150 print(
"See: basf2 -h")
155 uniqueID =
"SVD3SampleCoGTimeCalibrations_" + str(now.isoformat()) +
"_INFO:_3rdOrderPol_TBindep_Exp" + \
156 str(expNum) +
"_runsFrom" + str(firstRun) +
"to" + str(lastRun)
162 b2.conditions.override_globaltags()
163 svdCoGCAF = SVDCoGTimeCalibration(good_input_files,
165 "online",
"Reco_master_patch_rel5"],
173 cal_fw.add_calibration(svdCoGCAF)
174 cal_fw.backend = backends.LSF()
static Environment & Instance()
Static method to get a reference to the Environment instance.
def add_svd_unpacker(path)