9 """A simple example calibration that takes one input data list from raw data and performs
10 a single calibration."""
12 from prompt
import CalibrationSettings, INPUT_DATA_FILTERS
23 settings = CalibrationSettings(name=
"Example Simple",
24 expert_username=
"ddossett",
26 input_data_formats=[
"raw"],
27 input_data_names=[
"physics"],
28 input_data_filters={
"physics": [f
"NOT {INPUT_DATA_FILTERS['Magnet']['On']}",
29 INPUT_DATA_FILTERS[
"Data Tag"][
"hadron_calib"],
30 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good"],
31 INPUT_DATA_FILTERS[
"Beam Energy"][
"4S"],
32 INPUT_DATA_FILTERS[
"Run Type"][
"physics"]]},
48 def get_calibrations(input_data, **kwargs):
51 input_data (dict): Should contain every name from the 'input_data_names' variable as a key.
52 Each value is a dictionary with {"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful for
53 assigning to calibration.files_to_iov
55 **kwargs: Configuration options to be sent in. Since this may change we use kwargs as a way to help prevent
56 backwards compatibility problems. But you could use the correct arguments in b2caf-prompt-run for this
57 release explicitly if you want to.
59 Currently only kwargs["requested_iov"] and kwargs["expert_config"] are used.
61 "requested_iov" is the IoV range of the bucket and your payloads should correspond to this range.
62 However your highest payload IoV should be open ended e.g. IoV(3,4,-1,-1)
64 "expert_config" is the input configuration. It takes default values from your `CalibrationSettings` but these are
65 overwritten by values from the 'expert_config' key in your input `caf_config.json` file when running ``b2caf-prompt-run``.
68 list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
75 file_to_iov_physics = input_data[
"physics"]
85 min_events_per_file = 1
91 reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run, min_events_per_file)
92 input_files_physics = list(reduced_file_to_iov_physics.keys())
93 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_physics)}")
97 requested_iov = kwargs.get(
"requested_iov",
None)
102 from caf.utils
import IoV
104 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
109 from ROOT.Belle2
import TestCalibrationAlgorithm
111 alg_test = TestCalibrationAlgorithm()
116 from caf.framework
import Calibration
120 algorithms=[alg_test],
121 input_files=input_files_physics
125 for algorithm
in cal_test.algorithms:
126 algorithm.params = {
"apply_iov": output_iov}