3 """A simple example calibration that takes one input data list from raw data and performs
4 a single calibration."""
6 from prompt
import CalibrationSettings, input_data_filters
17 settings = CalibrationSettings(name=
"Example Simple",
18 expert_username=
"ddossett",
20 input_data_formats=[
"raw"],
21 input_data_names=[
"physics"],
22 input_data_filters={
"physics": [f
"NOT {input_data_filters['Magnet']['On']}",
23 input_data_filters[
"Data Tag"][
"hadron_calib"],
24 input_data_filters[
"Data Quality Tag"][
"Good"],
25 input_data_filters[
"Beam Energy"][
"4S"],
26 input_data_filters[
"Run Type"][
"physics"]]},
42 def get_calibrations(input_data, **kwargs):
45 input_data (dict): Should contain every name from the 'input_data_names' variable as a key.
46 Each value is a dictionary with {"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful for
47 assigning to calibration.files_to_iov
49 **kwargs: Configuration options to be sent in. Since this may change we use kwargs as a way to help prevent
50 backwards compatibility problems. But you could use the correct arguments in b2caf-prompt-run for this
51 release explicitly if you want to.
53 Currently only kwargs["requested_iov"] and kwargs["expert_config"] are used.
55 "requested_iov" is the IoV range of the bucket and your payloads should correspond to this range.
56 However your highest payload IoV should be open ended e.g. IoV(3,4,-1,-1)
58 "expert_config" is the input configuration. It takes default values from your `CalibrationSettings` but these are
59 overwritten by values from the 'expert_config' key in your input `caf_config.json` file when running ``b2caf-prompt-run``.
62 list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
69 file_to_iov_physics = input_data[
"physics"]
79 min_events_per_file = 1
85 reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run, min_events_per_file)
86 input_files_physics = list(reduced_file_to_iov_physics.keys())
87 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_physics)}")
91 requested_iov = kwargs.get(
"requested_iov",
None)
96 from caf.utils
import IoV
98 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
103 from ROOT.Belle2
import TestCalibrationAlgorithm
105 alg_test = TestCalibrationAlgorithm()
110 from caf.framework
import Calibration
114 algorithms=[alg_test],
115 input_files=input_files_physics
119 for algorithm
in cal_test.algorithms:
120 algorithm.params = {
"apply_iov": output_iov}