9"""ECL single crystal energy calibration using three control samples."""
11from prompt
import CalibrationSettings, INPUT_DATA_FILTERS
15settings = CalibrationSettings(
17 expert_username=
"hearty",
19 input_data_formats=[
"cdst"],
23 "mumu_tight_or_highm_calib"],
26 INPUT_DATA_FILTERS[
"Data Tag"][
"bhabha_all_calib"],
27 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good Or Recoverable"],
28 INPUT_DATA_FILTERS[
"Beam Energy"][
"4S"],
29 INPUT_DATA_FILTERS[
"Run Type"][
"physics"],
30 INPUT_DATA_FILTERS[
"Magnet"][
"On"]],
31 "gamma_gamma_calib": [
32 INPUT_DATA_FILTERS[
"Data Tag"][
"gamma_gamma_calib"],
33 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good Or Recoverable"],
34 INPUT_DATA_FILTERS[
"Beam Energy"][
"4S"],
35 INPUT_DATA_FILTERS[
"Run Type"][
"physics"],
36 INPUT_DATA_FILTERS[
"Magnet"][
"On"]],
37 "mumu_tight_or_highm_calib": [
38 INPUT_DATA_FILTERS[
"Data Tag"][
"mumu_tight_or_highm_calib"],
39 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good Or Recoverable"],
40 INPUT_DATA_FILTERS[
"Beam Energy"][
"4S"],
41 INPUT_DATA_FILTERS[
"Run Type"][
"physics"],
42 INPUT_DATA_FILTERS[
"Magnet"][
"On"]]},
44 expert_config={
"eCmsScale": 1.0,
45 "ee5x5_min_entries": 100})
51def touch_CRFinder(path, new_seed):
54 Speed up ECL clustering by increasing seed threshold
56 new_path = basf2.create_path()
58 for m
in path.modules():
59 if str(m) !=
"ECLCRFinder":
60 new_path.add_module(m)
62 crfinder = basf2.register_module(
'ECLCRFinder')
63 crfinder.param(
'energyCut0', new_seed)
64 basf2.print_params(crfinder)
65 new_path.add_module(crfinder)
68 raise KeyError(
"Could not find ECLCRFinder in path")
75def touch_WaveformFit(path, energy_threshold):
78 Speed up ECL reconstruction by increasing energy threshold
80 new_path = basf2.create_path()
82 for m
in path.modules():
83 if str(m) !=
"ECLWaveformFit":
84 new_path.add_module(m)
86 waveformfit = basf2.register_module(
'ECLWaveformFit')
87 waveformfit.param(
'EnergyThreshold', energy_threshold)
88 basf2.print_params(waveformfit)
89 new_path.add_module(waveformfit)
92 raise KeyError(
"Could not find ECLWaveformFit in path")
99def get_calibrations(input_data, **kwargs):
101 from ROOT
import Belle2
102 from caf.utils
import IoV
103 from caf.framework
import Calibration
104 from reconstruction
import prepare_cdst_analysis
110 file_to_iov_bhabha = input_data[
"bhabha_all_calib"]
111 input_files_bhabha = list(file_to_iov_bhabha.keys())
115 expert_config = kwargs.get(
"expert_config")
116 ee5x5minEntries = expert_config[
"ee5x5_min_entries"]
117 algo_ee5x5.setMinEntries(ee5x5minEntries)
118 algo_ee5x5.setPayloadName(
"ECLCrystalEnergy5x5")
119 algo_ee5x5.setStoreConst(
True)
122 eclee5x5_collector = basf2.register_module(
"eclee5x5Collector")
123 eclee5x5_collector.param(
"thetaLabMinDeg", 17.)
124 eclee5x5_collector.param(
"thetaLabMaxDeg", 150.)
125 eclee5x5_collector.param(
"minE0", 0.45)
126 eclee5x5_collector.param(
"minE1", 0.40)
127 eclee5x5_collector.param(
"maxdThetaSum", 2.)
128 eclee5x5_collector.param(
"dPhiScale", 1.)
129 eclee5x5_collector.param(
"maxTime", 10.)
130 eclee5x5_collector.param(
"useCalDigits",
False)
131 eclee5x5_collector.param(
"requireL1",
False)
132 eclee5x5_collector.param(
"granularity",
"all")
135 eCmsScale = expert_config[
"eCmsScale"]
136 eclee5x5_collector.param(
"expectedEnergyScale", eCmsScale)
139 collector=eclee5x5_collector,
140 algorithms=[algo_ee5x5],
141 input_files=input_files_bhabha
143 cal_ecl_ee5x5.backend_args = {
"request_memory":
"4 GB"}
146 ee5x5_pre_path = basf2.create_path()
147 prepare_cdst_analysis(ee5x5_pre_path, components=[
'ECL'])
149 ee5x5_pre_path = touch_CRFinder(ee5x5_pre_path, new_threshold)
150 waveform_threshold = 99.
151 ee5x5_pre_path = touch_WaveformFit(ee5x5_pre_path, waveform_threshold)
152 cal_ecl_ee5x5.pre_collector_path = ee5x5_pre_path
158 file_to_iov_gamma_gamma = input_data[
"gamma_gamma_calib"]
159 input_files_gamma_gamma = list(file_to_iov_gamma_gamma.keys())
163 algo_gamma_gamma.setOutputName(
"eclGammaGammaE_algorithm.root")
164 algo_gamma_gamma.setCellIDLo(1)
165 algo_gamma_gamma.setCellIDHi(8736)
166 algo_gamma_gamma.setMinEntries(150)
167 algo_gamma_gamma.setMaxIterations(10)
168 algo_gamma_gamma.setTRatioMin(0.45)
169 algo_gamma_gamma.setTRatioMax(0.70)
170 algo_gamma_gamma.setTRatioMinHiStat(0.70)
171 algo_gamma_gamma.setTRatioMaxHiStat(0.95)
172 algo_gamma_gamma.setUpperEdgeThresh(0.02)
173 algo_gamma_gamma.setPerformFits(
True)
174 algo_gamma_gamma.setFindExpValues(
False)
175 algo_gamma_gamma.setStoreConst(0)
178 eclGammaGamma_collector = basf2.register_module(
"eclGammaGammaECollector")
179 eclGammaGamma_collector.param(
"granularity",
"all")
180 eclGammaGamma_collector.param(
"thetaLabMinDeg", 0.)
181 eclGammaGamma_collector.param(
"thetaLabMaxDeg", 180.)
182 eclGammaGamma_collector.param(
"minPairMass", 9.)
183 eclGammaGamma_collector.param(
"mindPhi", 179.)
184 eclGammaGamma_collector.param(
"maxTime", 999.)
185 eclGammaGamma_collector.param(
"measureTrueEnergy",
False)
186 eclGammaGamma_collector.param(
"requireL1",
False)
189 eclGammaGamma_collector.param(
"expectedEnergyScale", eCmsScale)
191 cal_ecl_gamma_gamma =
Calibration(
"ecl_gamma_gamma",
192 collector=eclGammaGamma_collector,
193 algorithms=[algo_gamma_gamma],
194 input_files=input_files_gamma_gamma
198 gamma_gamma_pre_path = basf2.create_path()
199 prepare_cdst_analysis(gamma_gamma_pre_path, components=[
'ECL'])
201 gamma_gamma_pre_path = touch_CRFinder(gamma_gamma_pre_path, new_threshold)
202 waveform_threshold = 99.
203 gamma_gamma_pre_path = touch_WaveformFit(gamma_gamma_pre_path, waveform_threshold)
204 cal_ecl_gamma_gamma.pre_collector_path = gamma_gamma_pre_path
210 file_to_iov_mu_mu = input_data[
"mumu_tight_or_highm_calib"]
211 input_files_mu_mu = list(file_to_iov_mu_mu.keys())
215 algo_mu_mu.cellIDLo = 1
216 algo_mu_mu.cellIDHi = 8736
217 algo_mu_mu.minEntries = 150
218 algo_mu_mu.nToRebin = 1000
219 algo_mu_mu.tRatioMin = 0.05
220 algo_mu_mu.tRatioMax = 0.40
221 algo_mu_mu.lowerEdgeThresh = 0.10
222 algo_mu_mu.performFits =
True
223 algo_mu_mu.findExpValues =
False
224 algo_mu_mu.storeConst = 0
227 eclmumu_collector = basf2.register_module(
"eclMuMuECollector")
228 eclmumu_collector.param(
"granularity",
"all")
229 eclmumu_collector.param(
"minPairMass", 9.0)
230 eclmumu_collector.param(
"minTrackLength", 30.)
231 eclmumu_collector.param(
"MaxNeighbourE", 0.010)
232 eclmumu_collector.param(
"thetaLabMinDeg", 17.)
233 eclmumu_collector.param(
"thetaLabMaxDeg", 150.)
234 eclmumu_collector.param(
"measureTrueEnergy",
False)
235 eclmumu_collector.param(
"requireL1",
False)
236 cal_ecl_mu_mu =
Calibration(name=
"ecl_mu_mu", collector=eclmumu_collector, algorithms=algo_mu_mu, input_files=input_files_mu_mu)
239 ext_path = basf2.create_path()
240 prepare_cdst_analysis(ext_path, components=[
'ECL'])
241 ext_path.add_module(
"Ext", pdgCodes=[13])
243 ext_path = touch_CRFinder(ext_path, new_threshold)
244 waveform_threshold = 99.
245 ext_path = touch_WaveformFit(ext_path, waveform_threshold)
246 cal_ecl_mu_mu.pre_collector_path = ext_path
257 cal_ecl_merge =
Calibration(name=
"ecl_merge", collector=
"DummyCollector", algorithms=[merging_alg],
258 input_files=input_files_mu_mu[:1])
261 cal_ecl_merge.depends_on(cal_ecl_ee5x5)
262 cal_ecl_merge.depends_on(cal_ecl_gamma_gamma)
263 cal_ecl_merge.depends_on(cal_ecl_mu_mu)
266 ecl_merge_pre_path = basf2.create_path()
267 prepare_cdst_analysis(ecl_merge_pre_path, components=[
'ECL'])
269 ecl_merge_pre_path = touch_CRFinder(ecl_merge_pre_path, new_threshold)
270 waveform_threshold = 99.
271 ecl_merge_pre_path = touch_WaveformFit(ecl_merge_pre_path, waveform_threshold)
272 ecl_merge_pre_path.pre_collector_path = ecl_merge_pre_path
276 requested_iov = kwargs.get(
"requested_iov",
None)
277 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
278 for algorithm
in cal_ecl_ee5x5.algorithms:
279 algorithm.params = {
"apply_iov": output_iov}
280 for algorithm
in cal_ecl_gamma_gamma.algorithms:
281 algorithm.params = {
"apply_iov": output_iov}
282 for algorithm
in cal_ecl_mu_mu.algorithms:
283 algorithm.params = {
"apply_iov": output_iov}
284 for algorithm
in cal_ecl_merge.algorithms:
285 algorithm.params = {
"apply_iov": output_iov}
289 return [cal_ecl_ee5x5, cal_ecl_gamma_gamma, cal_ecl_mu_mu, cal_ecl_merge]
Calibrate ecl crystals using gamma pair events.
Calibrate ecl crystals using previously created payloads.
Calibrate ecl crystals using muon pair events.
Calibrate ecl crystals using Bhabha events.