14 from ROOT.Belle2
import SVDCoGTimeCalibrationAlgorithm
16 from caf.framework
import Calibration
17 from prompt
import CalibrationSettings
18 from caf
import strategies
19 from caf.utils
import IoV
23 b2.set_log_level(b2.LogLevel.INFO)
24 now = datetime.datetime.now()
26 settings = CalibrationSettings(name=
"SVDCoGTimeCalibrationPrompt",
27 expert_username=
"gdujany",
29 input_data_formats=[
"cdst"],
30 input_data_names=[
"hlt_hadron"],
36 def get_calibrations(input_data, **kwargs):
39 path = b2.create_path()
41 path.add_module(
"Gearbox")
42 path.add_module(
"Geometry", useDB=
True)
50 for moda
in path.modules():
51 if moda.name() ==
'SVDCoGTimeEstimator':
52 moda.param(
"ShaperDigits",
'SVDShaperDigitsFromTracks')
53 moda.param(
"RecoDigits",
'SVDRecoDigitsFromTracks')
54 moda.param(
"CalibrationWithEventT0",
False)
55 if moda.name() ==
'SVDSimpleClusterizer':
56 moda.param(
"Clusters",
'SVDClustersFromTracks')
57 moda.param(
"RecoDigits",
'SVDRecoDigitsFromTracks')
58 if moda.name() ==
'SVDSpacePointCreator':
59 moda.param(
"SVDClusters",
'SVDClustersFromTracks')
61 path = b2.remove_module(path,
'SVDMissingAPVsClusterCreator')
63 file_to_iov_physics = input_data[
"hlt_hadron"]
70 reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run, min_events_per_file=1)
72 good_input_files = list(reduced_file_to_iov_physics.keys())
73 b2.B2INFO(f
"Total number of files actually used as input = {len(good_input_files)}")
75 exps = [i.exp_low
for i
in reduced_file_to_iov_physics.values()]
76 runs = sorted([i.run_low
for i
in reduced_file_to_iov_physics.values()])
82 if not len(good_input_files):
83 print(
"No good input files found! Check that the input files have entries != 0!")
86 uniqueID =
"SVDCoGTimeCalibrations_Prompt_" + str(now.isoformat()) +
"_INFO:_3rdOrderPol_TBindep_Exp" + \
87 str(expNum) +
"_runsFrom" + str(firstRun) +
"to" + str(lastRun)
94 requested_iov = kwargs.get(
"requested_iov",
None)
95 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
98 collector = b2.register_module(
'SVDTimeCalibrationCollector')
99 collector.param(
"SVDClustersFromTracksName",
"SVDClustersFromTracks")
100 collector.param(
"SVDEventInfoName",
"SVDEventInfo")
101 collector.param(
"EventT0Name",
"EventT0")
102 collector.param(
"granularity",
"run")
105 algorithm = SVDCoGTimeCalibrationAlgorithm(uniqueID)
106 algorithm.setMinEntries(10000)
111 algorithms=algorithm,
112 input_files=good_input_files,
113 pre_collector_path=path,
119 calibration.strategies = strategies.SequentialBoundaries
121 for algorithm
in calibration.algorithms:
122 algorithm.params = {
"iov_coverage": output_iov}
def add_svd_unpacker(path)
def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False)