Belle II Software development
caf_ecl_cluster_energy.py
1
8
9"""ECL cluster crystal energy calibration using single photon MCrd."""
10
11from prompt import CalibrationSettings, INPUT_DATA_FILTERS
12
13# --------------------------------------------------------------
14# ..Tell the automated script some required details
15settings = CalibrationSettings(
16 name="ecl_cluster_energy",
17 expert_username="hearty",
18 description=__doc__,
19 input_data_formats=["mdst"],
20 input_data_names=["single_gamma_mc"],
21 input_data_filters={"single_gamma_mc": [INPUT_DATA_FILTERS["Data Tag"]["single_gamma_mc"]]},
22 depends_on=[],
23
24 # ..The expert_config settings should agree with the parameters of the jobs used
25 # to create the single_gamma_mc samples.
26 # Number of energy points, and the values of these for each of the three ECL regions.
27 # The mc samples include a reduced set of showers and CalDigits, with these names.
28 expert_config={"number_energies": 8,
29 "forward_energies": [0.030, 0.050, 0.100, 0.200, 0.483, 1.166, 2.816, 6.800],
30 "barrel_energies": [0.030, 0.050, 0.100, 0.200, 0.458, 1.049, 2.402, 5.500],
31 "backward_energies": [0.030, 0.050, 0.100, 0.200, 0.428, 0.917, 1.962, 4.200],
32 "digitArrayName": "ECLTrimmedDigits",
33 "showerArrayName": "ECLTrimmedShowers",
34 "nGroupPerThetaID": 8,
35 "lowEnergyThreshold": 0.}
36 )
37
38# --------------------------------------------------------------
39# ..The calibration functions
40
41
42def get_calibrations(input_data, **kwargs):
43 import basf2
44 from ROOT import Belle2
45 from caf.utils import IoV
46 from caf.framework import Calibration
47
48 # --------------------------------------------------------------
49 # ..Input data, same for both calibrations
50 file_to_iov = input_data["single_gamma_mc"]
51 input_files_single_gamma = list(file_to_iov.keys())
52
53 # --------------------------------------------------------------
54 # ..nOptimal calibration first
55
56 # ..eclNOptimal collector
57 ecl_nOptimal_collector = basf2.register_module("eclNOptimalCollector")
58 ecl_nOptimal_collector.param("granularity", "all")
59
60 # ..Number of energy points and their values can be set via expert_config
61 expert_config = kwargs.get("expert_config")
62 number_energies = expert_config["number_energies"]
63 ecl_nOptimal_collector.param("numberEnergies", number_energies)
64
65 forward_energies = expert_config["forward_energies"]
66 ecl_nOptimal_collector.param("energiesForward", forward_energies)
67
68 barrel_energies = expert_config["barrel_energies"]
69 ecl_nOptimal_collector.param("energiesBarrel", barrel_energies)
70
71 backward_energies = expert_config["backward_energies"]
72 ecl_nOptimal_collector.param("energiesBackward", backward_energies)
73
74 digitArrayName = expert_config["digitArrayName"]
75 ecl_nOptimal_collector.param("digitArrayName", digitArrayName)
76
77 showerArrayName = expert_config["showerArrayName"]
78 ecl_nOptimal_collector.param("showerArrayName", showerArrayName)
79
80 nGroupPerThetaID = expert_config["nGroupPerThetaID"]
81 ecl_nOptimal_collector.param("nGroupPerThetaID", nGroupPerThetaID)
82
83 # ..eclNOptimal algorithm
84 algo_nOptimal = Belle2.ECL.eclNOptimalAlgorithm()
85
86 # ..The calibration
87 cal_ecl_nOptimal = Calibration(
88 name="ecl_nOptimal",
89 collector=ecl_nOptimal_collector,
90 algorithms=algo_nOptimal,
91 input_files=input_files_single_gamma)
92
93 # ..pre_path is empty
94 ecl_nOptimal_pre_path = basf2.create_path()
95 cal_ecl_nOptimal.pre_collector_path = ecl_nOptimal_pre_path
96
97 # --------------------------------------------------------------
98 # ..Leakage correction, which depends on nOptimal
99
100 # ..eclLeakage collector
101 ecl_leakage_collector = basf2.register_module("eclLeakageCollector")
102 ecl_leakage_collector.param("granularity", "all")
103 ecl_leakage_collector.param("position_bins", 29)
104
105 # ..Number of energy points and their values can be set via expert_config
106 ecl_leakage_collector.param("number_energies", number_energies)
107 ecl_leakage_collector.param("energies_forward", forward_energies)
108 ecl_leakage_collector.param("energies_barrel", barrel_energies)
109 ecl_leakage_collector.param("energies_backward", backward_energies)
110 ecl_leakage_collector.param("showerArrayName", showerArrayName)
111
112 # ..eclLeakage algorithm
113 algo_leakage = Belle2.ECL.eclLeakageAlgorithm()
114 lowEnergyThreshold = expert_config["lowEnergyThreshold"]
115 algo_leakage.setLowEnergyThreshold(lowEnergyThreshold)
116
117 # ..The calibration
118 cal_ecl_leakage = Calibration(
119 name="ecl_leakage",
120 collector=ecl_leakage_collector,
121 algorithms=algo_leakage,
122 input_files=input_files_single_gamma)
123
124 # ..Depends on nOptimal
125 cal_ecl_leakage.depends_on(cal_ecl_nOptimal)
126
127 # ..pre_path is empty
128 ecl_leakage_pre_path = basf2.create_path()
129 cal_ecl_leakage.pre_collector_path = ecl_leakage_pre_path
130
131 # --------------------------------------------------------------
132 # ..Force the output iovs to be open
133 requested_iov = kwargs.get("requested_iov", None)
134 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
135 for algorithm in cal_ecl_nOptimal.algorithms:
136 algorithm.params = {"apply_iov": output_iov}
137 for algorithm in cal_ecl_leakage.algorithms:
138 algorithm.params = {"apply_iov": output_iov}
139
140 # --------------------------------------------------------------
141 # ..Return the calibrations
142 return [cal_ecl_nOptimal, cal_ecl_leakage]
Calculate ECL energy leakage corrections.
Algorithm that works with eclNOptimalCollector to find the number of crystals to be summed to get the...