10Airflow script for TOP post-tracking calibration:
11 BS13d carrier shifts, module T0 and common T0.
12 Histograms
for validation are also prepared here.
15from prompt import CalibrationSettings, INPUT_DATA_FILTERS
16from caf.utils import IoV
17from caf.strategies import SequentialBoundaries
18from top_calibration import BS13d_calibration_cdst
19from top_calibration import moduleT0_calibration_DeltaT, moduleT0_calibration_LL
20from top_calibration import commonT0_calibration_BF
21from top_calibration import offset_calibration
22from top_calibration import photonYields_calibration
23from top_calibration import calibration_validation
24from prompt.calibrations.caf_top_pre import settings as top_pretracking
25from prompt.utils import filter_by_max_files_per_run
27## Required variable - tells the automated system some details of this script
28settings = CalibrationSettings(
29 name="TOP post-tracking calibration",
30 expert_username=
"skohani",
32 input_data_formats=[
"cdst"],
33 input_data_names=[
"mumu_tight_or_highm_calib"],
35 "mumu_tight_or_highm_calib": [
36 INPUT_DATA_FILTERS[
"Data Tag"][
"mumu_tight_or_highm_calib"],
37 INPUT_DATA_FILTERS[
"Run Type"][
"physics"],
38 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good Or Recoverable"]]},
39 depends_on=[top_pretracking],
41 "max_files_per_run": 20,
42 "payload_boundaries":
None,
43 "request_memory":
"8 GB"
48def get_calibrations(input_data, **kwargs):
50 Returns a list of calibration objects.
51 :input_data (dict): Contains every file name from the
'input_data_names' as a key.
52 :**kwargs: Configuration options to be sent
in.
55 file_to_iov = input_data["mumu_tight_or_highm_calib"]
57 expert_config = kwargs.get(
"expert_config")
58 max_files_per_run = expert_config[
"max_files_per_run"]
59 min_events_per_file = 1
61 reduced_file_to_iov = filter_by_max_files_per_run(file_to_iov, max_files_per_run, min_events_per_file, random_select=
True)
62 inputFiles = list(reduced_file_to_iov.keys())
63 basf2.B2INFO(f
"Total number of files actually used as input = {len(inputFiles)}")
64 requested_iov = kwargs.get(
"requested_iov",
None)
65 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
68 if requested_iov.exp_low > 26
or requested_iov.exp_low <= 0:
69 basf2.B2INFO(
"Running Run 2 calibration chain for TOP")
70 cal = [moduleT0_calibration_DeltaT(inputFiles),
71 moduleT0_calibration_LL(inputFiles, sample),
72 commonT0_calibration_BF(inputFiles),
73 offset_calibration(inputFiles),
74 photonYields_calibration(inputFiles, sample),
75 calibration_validation(inputFiles, sample)]
76 cal[0].save_payloads =
False
77 cal[5].save_payloads =
False
79 basf2.B2INFO(
"Running Run 1 calibration chain for TOP")
80 cal = [BS13d_calibration_cdst(inputFiles),
81 moduleT0_calibration_DeltaT(inputFiles),
82 moduleT0_calibration_LL(inputFiles, sample),
83 commonT0_calibration_BF(inputFiles),
84 offset_calibration(inputFiles),
85 calibration_validation(inputFiles, sample)]
86 cal[1].save_payloads =
False
87 cal[5].save_payloads =
False
91 if c.strategies[0] == SequentialBoundaries:
94 payload_boundaries = [[output_iov.exp_low, output_iov.run_low]]
97 if expert_config[
"payload_boundaries"]
is not None:
98 payload_boundaries = expert_config[
"payload_boundaries"]
101 for alg
in c.algorithms:
102 alg.params = {
"iov_coverage": output_iov,
"payload_boundaries": payload_boundaries}
106 for alg
in c.algorithms:
107 alg.params = {
"iov_coverage": output_iov}
109 for i
in range(1, len(cal)):
110 cal[i].depends_on(cal[i - 1])