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