11"""ECL waveform template calibration"""
13from prompt
import CalibrationSettings, INPUT_DATA_FILTERS
17settings = CalibrationSettings(
18 name=
"ecl_WaveformTemplateShapeCalibration",
19 expert_username=
"longos",
21 input_data_formats=[
"cdst"],
22 input_data_names=[
"gamma_gamma_calib"],
24 "gamma_gamma_calib": [
25 INPUT_DATA_FILTERS[
"Data Tag"][
"gamma_gamma_calib"],
26 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good Or Recoverable"],
27 INPUT_DATA_FILTERS[
"Run Type"][
"physics"],
28 INPUT_DATA_FILTERS[
"Magnet"][
"On"]]},
31 "C2_MinEnergyThreshold": 2.0,
39def get_calibrations(input_data, **kwargs):
41 from ROOT
import Belle2
42 from caf.utils
import IoV
43 from caf.framework
import Calibration
49 file_to_iov_gamma_gamma = input_data[
"gamma_gamma_calib"]
50 input_files = list(file_to_iov_gamma_gamma.keys())
55 expert_config = kwargs.get(
"expert_config")
56 C2_MinEnergyThreshold = expert_config[
"C2_MinEnergyThreshold"]
57 nFilesCollector = expert_config[
"nFilesCollector"]
60 collector_C1 = basf2.register_module(
"eclWaveformTemplateCalibrationC1Collector")
61 collector_C1.param(
'MinEnergyThreshold', C2_MinEnergyThreshold)
65 collector=collector_C1,
67 input_files=input_files,
68 max_files_per_collector_job=nFilesCollector)
71 gamma_gamma_pre_path = basf2.create_path()
72 gamma_gamma_pre_path.add_module(
"RootInput", inputFileNames=
"", branchNames=[
"EventMetaData",
"RawECLs"])
73 eclunpacker = basf2.register_module(
'ECLUnpacker')
74 gamma_gamma_pre_path.add_module(eclunpacker)
76 cal_ecl_Wave_C1.pre_collector_path = gamma_gamma_pre_path
87 for i
in range(0, nbatches):
89 lowLimit = (batchsize*i)+1
91 highLimit = (batchsize*(i+1))
93 if (highLimit > 8736):
96 print(
"lowLimit,highLimit", lowLimit, highLimit)
100 algos_C2[-1].setFirstCellID(lowLimit)
101 algos_C2[-1].setLastCellID(highLimit)
104 algos_C3[-1].setFirstCellID(lowLimit)
105 algos_C3[-1].setLastCellID(highLimit)
107 collectors_C2.append(basf2.register_module(
"eclWaveformTemplateCalibrationC2Collector"))
108 collectors_C2[-1].pre_collector_path = gamma_gamma_pre_path
109 collectors_C2[-1].param(
'MinCellID', lowLimit)
110 collectors_C2[-1].param(
'MaxCellID', highLimit)
111 collectors_C2[-1].param(
'MinEnergyThreshold', C2_MinEnergyThreshold)
114 calibrations_C2.append(
Calibration(
"ecl_Wave_C2_"+str(lowLimit)+
"_"+str(highLimit),
115 collector=collectors_C2[-1],
116 algorithms=[algos_C2[-1],
118 input_files=input_files,
119 max_files_per_collector_job=nFilesCollector))
120 calibrations_C2[-1].pre_collector_path = gamma_gamma_pre_path
121 calibrations_C2[-1].depends_on(cal_ecl_Wave_C1)
125 algo_C4.setFirstCellID(1)
126 algo_C4.setLastCellID(8736)
130 collector=
"DummyCollector",
131 algorithms=[algo_C4],
132 input_files=input_files[:1],
135 cal_ecl_Wave_C4.depends_on(cal_ecl_Wave_C1)
136 for cal
in calibrations_C2:
137 cal_ecl_Wave_C4.depends_on(cal)
141 requested_iov = kwargs.get(
"requested_iov",
None)
142 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
143 for algorithm
in cal_ecl_Wave_C1.algorithms:
144 algorithm.params = {
"apply_iov": output_iov}
145 for C2
in calibrations_C2:
146 for algorithm
in C2.algorithms:
147 algorithm.params = {
"apply_iov": output_iov}
148 for algorithm
in cal_ecl_Wave_C4.algorithms:
149 algorithm.params = {
"apply_iov": output_iov}
153 calList = [cal_ecl_Wave_C1] + calibrations_C2 + [cal_ecl_Wave_C4]