Belle II Software prerelease-11-00-00a
caf_cdc_deadboard.py
1
8"""CDC deadboard calibration."""
9import basf2
10from prompt import CalibrationSettings, INPUT_DATA_FILTERS
11from ROOT import Belle2
12
13settings = CalibrationSettings(name="CDC deadboard",
14 expert_username="liumh",
15 subsystem="cdc",
16 description=__doc__,
17 input_data_formats=["raw"],
18 input_data_names=["mumu_tight_or_highm_calib"],
19 input_data_filters={"mumu_tight_or_highm_calib":
20 [INPUT_DATA_FILTERS["Data Tag"]["mumu_tight_or_highm_calib"],
21 INPUT_DATA_FILTERS["Data Quality Tag"]["Good"],
22 INPUT_DATA_FILTERS["Magnet"]["On"]]},
23 depends_on=[],
24 expert_config={
25 "min_events_per_file": 100,
26 "components": ["CDC"],
27 "payload_boundaries": [],
28 "backend_args": {"request_memory": "2 GB"},
29 "dead_board_threshold": 0.0
30 },
31 produced_payloads=["CDCBadBoards"])
32
33
34# Main function to get calibrations
35def get_calibrations(input_data, **kwargs):
36 expert_config = kwargs.get("expert_config")
37 min_events_per_file = expert_config["min_events_per_file"]
38 components = expert_config["components"]
39 dead_board_threshold = expert_config["dead_board_threshold"]
40
41 # In this script we want to use one sources of input data.
42 # Get the input files from the input_data variable
43 file_to_iov_mumu = input_data["mumu_tight_or_highm_calib"]
44 from prompt.utils import filter_by_max_files_per_run
45 reduced_file_to_iov_mumu = filter_by_max_files_per_run(file_to_iov_mumu, 1, min_events_per_file)
46 input_files_mumu = list(reduced_file_to_iov_mumu.keys())
47 basf2.B2INFO("Complete input data selection.")
48 basf2.B2INFO(f"Total number of files actually used as input = {len(input_files_mumu)}")
49
50 from prompt.utils import ExpRun
51 from caf.utils import IoV
52 from caf import strategies
53 payload_boundaries = []
54 payload_boundaries.extend([ExpRun(*boundary) for boundary in expert_config["payload_boundaries"]])
55 basf2.B2INFO(f"Payload boundaries from expert_config: {payload_boundaries}")
56
57 # The actual value our output IoV payload should have. Notice that we've set it open ended.
58 requested_iov = kwargs.get("requested_iov", None)
59 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
60
61 # for SingleIOV stratrgy, it's better to set the granularity to 'all' so that the collector jobs will run faster
62 if payload_boundaries:
63 basf2.B2INFO('Found payload_boundaries: set collector granularity to run')
64 # call collector module
65 col = basf2.register_module("CDCDeadBoardDetector")
66
67 # call algorighm
69 algo.setHistName("CDCboardIDs")
70 algo.setThreshold(dead_board_threshold)
71 # Calibration setup
72 from caf.framework import Calibration
73 deadboard_calib = Calibration("CDC_DeadBoard",
74 collector=col,
75 algorithms=algo,
76 input_files=input_files_mumu,
77 pre_collector_path=pre_collector(components=components))
78 # Do this for the default AlgorithmStrategy to force the output payload IoV
79 # It may be different if you are using another strategy like SequentialRunByRun
80 if payload_boundaries:
81 basf2.B2INFO("Found payload_boundaries: calibration strategies set to SequentialBoundaries.")
82 deadboard_calib.strategies = strategies.SequentialBoundaries
83 for alg in deadboard_calib.algorithms:
84 alg.params = {"iov_coverage": output_iov, "payload_boundaries": payload_boundaries}
85 else:
86 deadboard_calib.strategies = strategies.SequentialRunByRun
87 for alg in deadboard_calib.algorithms:
88 alg.params = {"iov_coverage": output_iov}
89
90 return [deadboard_calib]
91
92
93def pre_collector(components=["CDC"]):
94 # Create an execution path
95 path = basf2.create_path()
96 branches = ['EventMetaData', 'RawCDCs', 'RawFTSWs']
97
98 # Only rootInput is required with RawCDCs included:
99 path.add_module("RootInput", branchNames=branches)
100 # Print some progress messages
101 path.add_module("Progress")
102
103 basf2.print_path(path)
104 return path
Class for dead board detection.