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