Belle II Software  release-08-01-10
caf_ecl_leakage.py
1 
8 
9 """ECL calibration to calculate photon energy leakage corrections."""
10 
11 from prompt import CalibrationSettings, INPUT_DATA_FILTERS
12 
13 
14 # --------------------------------------------------------------
15 # ..Tell the automated script some required details
16 settings = CalibrationSettings(name="ecl_leakage",
17  expert_username="hearty",
18  description=__doc__,
19  input_data_formats=["mdst"],
20  input_data_names=["single_gamma_mc"],
21  input_data_filters={
22  "single_gamma_mc": [
23  INPUT_DATA_FILTERS["Data Tag"]["single_gamma_mc"]
24  ]
25  },
26  depends_on=[],
27  expert_config={"number_energies": 8,
28  "forward_energies": [0.030, 0.050, 0.100, 0.200, 0.483, 1.166, 2.816, 6.800],
29  "barrel_energies": [0.030, 0.050, 0.100, 0.200, 0.458, 1.049, 2.402, 5.500],
30  "backward_energies": [0.030, 0.050, 0.100, 0.200, 0.428, 0.917, 1.962, 4.200],
31  "lowEnergyThreshold": 0.,
32  "showerArrayName": "ECLTrimmedShowers"
33  }
34  )
35 
36 
37 # --------------------------------------------------------------
38 # ..The calibration functions
39 
40 
41 def get_calibrations(input_data, **kwargs):
42  import basf2
43  from ROOT import Belle2
44  from caf.utils import IoV
45  from caf.framework import Calibration
46 
47  # --------------------------------------------------------------
48  # ..Input data
49  file_to_iov_leakage = input_data["single_gamma_mc"]
50  input_files_leakage = list(file_to_iov_leakage.keys())
51 
52  # ..Collector
53  ecl_leakage_collector = basf2.register_module("eclLeakageCollector")
54  ecl_leakage_collector.param("granularity", "all")
55  ecl_leakage_collector.param("position_bins", 29)
56 
57  # ..Number of energy points and their values can be set via expert_config
58  expert_config = kwargs.get("expert_config")
59  number_energies = expert_config["number_energies"]
60  ecl_leakage_collector.param("number_energies", number_energies)
61 
62  forward_energies = expert_config["forward_energies"]
63  ecl_leakage_collector.param("energies_forward", forward_energies)
64 
65  barrel_energies = expert_config["barrel_energies"]
66  ecl_leakage_collector.param("energies_barrel", barrel_energies)
67 
68  backward_energies = expert_config["backward_energies"]
69  ecl_leakage_collector.param("energies_backward", backward_energies)
70 
71  showerArrayName = expert_config["showerArrayName"]
72  ecl_leakage_collector.param("showerArrayName", showerArrayName)
73 
74  # ..Algorithm
75  algo_leakage = Belle2.ECL.eclLeakageAlgorithm()
76  lowEnergyThreshold = expert_config["lowEnergyThreshold"]
77  algo_leakage.setLowEnergyThreshold(lowEnergyThreshold)
78 
79  # ..The calibration
80  cal_ecl_leakage = Calibration(
81  name="ecl_leakage",
82  collector=ecl_leakage_collector,
83  algorithms=algo_leakage,
84  input_files=input_files_leakage)
85 
86  # ..pre_path is empty
87  ecl_leakage_pre_path = basf2.create_path()
88  cal_ecl_leakage.pre_collector_path = ecl_leakage_pre_path
89 
90  # --------------------------------------------------------------
91  # ..Force the output iovs to be open
92  requested_iov = kwargs.get("requested_iov", None)
93  output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
94  for algorithm in cal_ecl_leakage.algorithms:
95  algorithm.params = {"apply_iov": output_iov}
96 
97  # --------------------------------------------------------------
98  # ..Return the calibrations
99  return [cal_ecl_leakage]
Calculate ECL energy leakage corrections.