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