3 """CDC Wire Efficiency and BadWire creator. Creates layer-by-layer and wire-by-wire efficiencies and returns bad wire list"""
5 from prompt
import CalibrationSettings
6 from caf.framework
import Calibration
10 settings = CalibrationSettings(name=
"CDC bad wires",
11 expert_username=
"uchida",
13 input_data_formats=[
"raw"],
14 input_data_names=[
"hlt_mumu"],
25 def get_calibrations(input_data, **kwargs):
29 file_to_iov_mumu = input_data[
"hlt_mumu"]
31 max_files_per_run = 10
32 min_events_per_file = 1000
34 max_events_per_calibration = 10000000
35 max_events_per_file = 10000
37 reduced_file_to_iov_mumu = filter_by_max_files_per_run(file_to_iov_mumu, max_files_per_run, min_events_per_file)
38 input_files_mumu = list(reduced_file_to_iov_mumu.keys())
39 basf2.B2INFO(f
"Total number of hlt_mumu files actually used as input = {len(input_files_mumu)}")
41 input_file_dict = {
"hlt_mumu": reduced_file_to_iov_mumu}
44 requested_iov = kwargs.get(
"requested_iov",
None)
46 from caf.utils
import IoV
48 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
51 cal = CDCCalibration(name=
'wire_eff',
52 algorithms=[wire_algo()],
53 input_file_dict=input_file_dict,
59 for algorithm
in cal.algorithms:
60 algorithm.params = {
"apply_iov": output_iov}
67 def pre_collector(max_events=None):
69 Define pre collection (reconstruction).
70 Needs to perform reconstruction with all wire (including bad) enabled.
72 max_events [int] : number of events to be processed.
73 All events by Default.
75 path : path for pre collection
77 from basf2
import create_path, register_module
78 reco_path = create_path()
79 if max_events
is None:
80 root_input = register_module(
'RootInput')
82 root_input = register_module(
'RootInput',
83 entrySequences=[
'0:{}'.format(max_events)]
85 reco_path.add_module(root_input)
87 gearbox = register_module(
'Gearbox')
88 reco_path.add_module(gearbox)
89 reco_path.add_module(
'Geometry', useDB=
True)
91 from rawdata
import add_unpackers
93 add_unpackers(reco_path)
95 from reconstruction
import add_reconstruction
96 add_reconstruction(reco_path,
97 add_trigger_calculation=
False,
98 trackFitHypotheses=[13],
101 for module
in reco_path.modules():
102 if module.name() ==
"TFCDC_WireHitPreparer":
103 print(
"Enabling bad wires during reconstruction.")
104 module.param({
"useBadWires":
True})
109 def collector(bField=True, is_cosmic=False):
111 Create a cdc calibration collector
113 bField [bool] : True if B field is on, else False
114 isCosmic [bool] : True if cosmic events,
115 else (collision) False.
117 collector : collector module
119 from basf2
import register_module
120 col = register_module(
'CDCCalibrationCollector',
122 calExpectedDriftTime=
True,
123 eventT0Extraction=
True,
133 Create wire efficiency plots.
135 algo : Wire efficiency algorithm
137 from ROOT
import Belle2
142 from caf.framework
import Calibration
147 CDCCalibration is a specialized calibration class for cdc.
148 Since collector is same in all elements, no need to specify it.
157 max_events=10000000):
158 for algo
in algorithms:
159 algo.setHistFileName(name)
161 super().__init__(name=name,
162 algorithms=algorithms
165 from caf.framework
import Collection
167 for skim_type, file_list
in input_file_dict.items():
169 input_files=file_list,
170 pre_collector_path=pre_collector(max_events=max_events),
172 self.add_collection(name=skim_type, collection=collection)
176 if dependencies
is not None:
177 for dep
in dependencies: