Belle II Software development
SVDCoGTimeCalibrationPromptCAF.py
1
8
9import basf2 as b2
10
11import sys
12import datetime
13
14from caf.framework import Calibration
15from prompt import CalibrationSettings
16from caf import strategies
17from caf.utils import IoV
18
19import svd as svd
20
21b2.set_log_level(b2.LogLevel.INFO)
22now = datetime.datetime.now()
23
24settings = CalibrationSettings(name="SVDCoGTimeCalibrationPrompt",
25 expert_username="gdujany",
26 description=__doc__,
27 input_data_formats=["cdst"],
28 input_data_names=["hlt_hadron"],
29 depends_on=[])
30
31# Definition of the class
32
33
34def get_calibrations(input_data, **kwargs):
35 # avoid top level ROOT imports
36 from ROOT import Belle2 # noqa: make Belle2 namespace available
37 from ROOT.Belle2 import SVDCoGTimeCalibrationAlgorithm
38
39 # Set-up re-processing path
40 path = b2.create_path()
41
42 path.add_module("Gearbox")
43 path.add_module("Geometry", useDB=True)
44
45 # unpack raw svd data and produce: SVDEventInfo and SVDShaperDigits
47
48 # run SVD reconstruction, changing names of StoreArray
50
51 for moda in path.modules():
52 if moda.name() == 'SVDCoGTimeEstimator':
53 moda.param("ShaperDigits", 'SVDShaperDigitsFromTracks')
54 moda.param("RecoDigits", 'SVDRecoDigitsFromTracks')
55 moda.param("CalibrationWithEventT0", False)
56 if moda.name() == 'SVDSimpleClusterizer':
57 moda.param("Clusters", 'SVDClustersFromTracks')
58 moda.param("RecoDigits", 'SVDRecoDigitsFromTracks')
59 if moda.name() == 'SVDSpacePointCreator':
60 moda.param("SVDClusters", 'SVDClustersFromTracks')
61
62 path = b2.remove_module(path, 'SVDMissingAPVsClusterCreator')
63
64 file_to_iov_physics = input_data["hlt_hadron"]
65
66 max_files_per_run = 1
67
68 from prompt.utils import filter_by_max_files_per_run
69
70 # reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run)
71 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 # input_files_physics = list(reduced_file_to_iov_physics.keys())
73 good_input_files = list(reduced_file_to_iov_physics.keys())
74 b2.B2INFO(f"Total number of files actually used as input = {len(good_input_files)}")
75
76 exps = [i.exp_low for i in reduced_file_to_iov_physics.values()]
77 runs = sorted([i.run_low for i in reduced_file_to_iov_physics.values()])
78
79 firstRun = runs[0]
80 lastRun = runs[-1]
81 expNum = exps[0]
82
83 if not len(good_input_files):
84 print("No good input files found! Check that the input files have entries != 0!")
85 sys.exit(1)
86
87 uniqueID = "SVDCoGTimeCalibrations_Prompt_" + str(now.isoformat()) + "_INFO:_3rdOrderPol_TBindep_Exp" + \
88 str(expNum) + "_runsFrom" + str(firstRun) + "to" + str(lastRun)
89 print("")
90 print("UniqueID")
91 print("")
92 print(str(uniqueID))
93 print("")
94
95 requested_iov = kwargs.get("requested_iov", None)
96 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
97
98 # collector setup
99 collector = b2.register_module('SVDTimeCalibrationCollector')
100 collector.param("SVDClustersFromTracksName", "SVDClustersFromTracks")
101 collector.param("SVDEventInfoName", "SVDEventInfo")
102 collector.param("EventT0Name", "EventT0")
103 collector.param("granularity", "run")
104
105 # algorithm setup
106 algorithm = SVDCoGTimeCalibrationAlgorithm(uniqueID)
107 algorithm.setMinEntries(10000)
108
109 # calibration setup
110 calibration = Calibration('SVDCoGTime',
111 collector=collector,
112 algorithms=algorithm,
113 input_files=good_input_files,
114 pre_collector_path=path,
115 )
116
117 # calibration.pre_algorithms = pre_alg
118 # calibration.strategies = strategies.SequentialRunByRun
119 # calibration.strategies = strategies.SingleIOV
120 calibration.strategies = strategies.SequentialBoundaries
121
122 for algorithm in calibration.algorithms:
123 algorithm.params = {"iov_coverage": output_iov}
124
125 return [calibration]
def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False)
Definition: __init__.py:14
def add_svd_unpacker(path)
Definition: __init__.py:275