11 from caf.framework
import Calibration, Collection
12 from caf.strategies
import SequentialRunByRun, SingleIOV, SimpleRunByRun, SequentialBoundaries
13 from ROOT
import Belle2
14 from ROOT.Belle2
import TOP
18 def BS13d_calibration_local(inputFiles, look_back=28, globalTags=None, localDBs=None):
20 Returns calibration object for carrier shift calibration of BS13d with local runs
21 (laser, single-pulse or double-pulse).
22 :param inputFiles: A list of input files in sroot format
23 :param look_back: look-back window setting (set it to 0 to use the one from DB)
24 :param globalTags: a list of global tags, highest priority first
25 :param localDBs: a list of local databases, highest priority first
29 main = basf2.create_path()
32 main.add_module(
'SeqRootInput')
33 main.add_module(
'TOPGeometryParInitializer')
34 main.add_module(
'TOPUnpacker')
35 main.add_module(
'TOPRawDigitConverter', lookBackWindows=look_back,
36 useAsicShiftCalibration=
False, useChannelT0Calibration=
False)
39 collector = basf2.register_module(
'TOPAsicShiftsBS13dCollector')
42 algorithm = TOP.TOPAsicShiftsBS13dAlgorithm()
43 algorithm.setWindowSize(0)
46 cal =
Calibration(name=
'TOP_BS13dCalibration', collector=collector,
47 algorithms=algorithm, input_files=inputFiles)
49 for globalTag
in reversed(globalTags):
50 cal.use_central_database(globalTag)
52 for localDB
in reversed(localDBs):
53 cal.use_local_database(localDB)
54 cal.pre_collector_path = main
55 cal.strategies = SequentialRunByRun
60 def BS13d_calibration_rawdata(inputFiles, globalTags=None, localDBs=None):
62 Returns calibration object for carrier shift calibration of BS13d with raw data.
63 :param inputFiles: A list of input files in raw data format
64 :param globalTags: a list of global tags, highest priority first
65 :param localDBs: a list of local databases, highest priority first
69 main = basf2.create_path()
72 main.add_module(
'RootInput')
73 main.add_module(
'TOPGeometryParInitializer')
74 main.add_module(
'TOPUnpacker')
75 main.add_module(
'TOPRawDigitConverter',
76 useAsicShiftCalibration=
False, useChannelT0Calibration=
False)
79 collector = basf2.register_module(
'TOPAsicShiftsBS13dCollector')
82 algorithm = TOP.TOPAsicShiftsBS13dAlgorithm()
85 cal =
Calibration(name=
'TOP_BS13dCalibration', collector=collector,
86 algorithms=algorithm, input_files=inputFiles)
88 for globalTag
in reversed(globalTags):
89 cal.use_central_database(globalTag)
91 for localDB
in reversed(localDBs):
92 cal.use_local_database(localDB)
93 cal.pre_collector_path = main
94 cal.strategies = SequentialRunByRun
99 def BS13d_calibration_cdst(inputFiles, time_offset=0, globalTags=None, localDBs=None,
100 new_cdst_format=True):
102 Returns calibration object for carrier shift calibration of BS13d with processed data.
103 :param inputFiles: A list of input files in cdst data format
104 :param time_offset: time offset [ns]
105 :param globalTags: a list of global tags, highest priority first
106 :param localDBs: a list of local databases, highest priority first
107 :param new_cdst_format: True or False for new or old cdst format, respectively
111 main = basf2.create_path()
114 main.add_module(
'RootInput')
116 main.add_module(
'Gearbox')
117 main.add_module(
'Geometry')
118 main.add_module(
'Ext')
119 main.add_module(
'TOPUnpacker')
120 main.add_module(
'TOPRawDigitConverter')
121 main.add_module(
'TOPChannelMasker')
122 main.add_module(
'TOPBunchFinder', subtractRunningOffset=
False)
123 main.add_module(
'TOPTimeRecalibrator',
124 useAsicShiftCalibration=
False, useChannelT0Calibration=
True)
126 main.add_module(
'TOPGeometryParInitializer')
127 main.add_module(
'TOPTimeRecalibrator',
128 useAsicShiftCalibration=
False, useChannelT0Calibration=
True)
131 collector = basf2.register_module(
'TOPAsicShiftsBS13dCollector',
132 timeOffset=time_offset, requireRecBunch=
True)
135 algorithm = TOP.TOPAsicShiftsBS13dAlgorithm()
138 cal =
Calibration(name=
'TOP_BS13dCalibration', collector=collector,
139 algorithms=algorithm, input_files=inputFiles)
141 for globalTag
in reversed(globalTags):
142 cal.use_central_database(globalTag)
144 for localDB
in reversed(localDBs):
145 cal.use_local_database(localDB)
146 cal.pre_collector_path = main
147 cal.strategies = SequentialRunByRun
152 def moduleT0_calibration_DeltaT(inputFiles, globalTags=None, localDBs=None,
153 new_cdst_format=True):
155 Returns calibration object for rough module T0 calibration with method DeltaT
156 :param inputFiles: A list of input files in cdst data format
157 :param globalTags: a list of global tags, highest priority first
158 :param localDBs: a list of local databases, highest priority first
159 :param new_cdst_format: True or False for new or old cdst format, respectively
163 main = basf2.create_path()
166 main.add_module(
'RootInput')
168 main.add_module(
'Gearbox')
169 main.add_module(
'Geometry')
170 main.add_module(
'Ext')
171 main.add_module(
'TOPUnpacker')
172 main.add_module(
'TOPRawDigitConverter')
173 main.add_module(
'TOPChannelMasker')
174 main.add_module(
'TOPBunchFinder', subtractRunningOffset=
False)
176 main.add_module(
'TOPGeometryParInitializer')
177 main.add_module(
'TOPTimeRecalibrator', subtractBunchTime=
False)
178 main.add_module(
'TOPChannelMasker')
179 main.add_module(
'TOPBunchFinder', usePIDLikelihoods=
True,
180 subtractRunningOffset=
False)
183 collector = basf2.register_module(
'TOPModuleT0DeltaTCollector')
184 collector.param(
'granularity',
'run')
187 algorithm = TOP.TOPModuleT0DeltaTAlgorithm()
190 cal =
Calibration(name=
'TOP_moduleT0_rough', collector=collector,
191 algorithms=algorithm, input_files=inputFiles)
193 for globalTag
in reversed(globalTags):
194 cal.use_central_database(globalTag)
196 for localDB
in reversed(localDBs):
197 cal.use_local_database(localDB)
198 cal.pre_collector_path = main
199 cal.strategies = SequentialBoundaries
204 def moduleT0_calibration_LL(inputFiles, sample='dimuon', globalTags=None, localDBs=None,
205 new_cdst_format=True):
207 Returns calibration object for final module T0 calibration with method LL
208 :param inputFiles: A list of input files in cdst data format
209 :param sample: data sample ('dimuon' or 'bhabha')
210 :param globalTags: a list of global tags, highest priority first
211 :param localDBs: a list of local databases, highest priority first
212 :param new_cdst_format: True or False for new or old cdst format, respectively
216 main = basf2.create_path()
219 main.add_module(
'RootInput')
221 main.add_module(
'Gearbox')
222 main.add_module(
'Geometry')
223 main.add_module(
'Ext')
224 main.add_module(
'TOPUnpacker')
225 main.add_module(
'TOPRawDigitConverter')
226 main.add_module(
'TOPChannelMasker')
227 main.add_module(
'TOPBunchFinder', subtractRunningOffset=
False)
229 main.add_module(
'TOPGeometryParInitializer')
230 main.add_module(
'TOPTimeRecalibrator', subtractBunchTime=
False)
231 main.add_module(
'TOPChannelMasker')
232 main.add_module(
'TOPBunchFinder', usePIDLikelihoods=
True,
233 subtractRunningOffset=
False)
236 collector = basf2.register_module(
'TOPModuleT0LLCollector')
237 collector.param(
'sample', sample)
238 collector.param(
'granularity',
'run')
241 algorithm = TOP.TOPModuleT0LLAlgorithm()
244 cal =
Calibration(name=
'TOP_moduleT0_final', collector=collector,
245 algorithms=algorithm, input_files=inputFiles)
247 for globalTag
in reversed(globalTags):
248 cal.use_central_database(globalTag)
250 for localDB
in reversed(localDBs):
251 cal.use_local_database(localDB)
252 cal.pre_collector_path = main
253 cal.strategies = SequentialBoundaries
258 def commonT0_calibration_BF(inputFiles, globalTags=None, localDBs=None,
259 new_cdst_format=True):
261 Returns calibration object for common T0 calibration with method BF
262 :param inputFiles: A list of input files in cdst data format
263 :param globalTags: a list of global tags, highest priority first
264 :param localDBs: a list of local databases, highest priority first
265 :param new_cdst_format: True or False for new or old cdst format, respectively
269 main = basf2.create_path()
272 main.add_module(
'RootInput')
274 main.add_module(
'Gearbox')
275 main.add_module(
'Geometry')
276 main.add_module(
'Ext')
277 main.add_module(
'TOPUnpacker')
278 main.add_module(
'TOPRawDigitConverter')
279 main.add_module(
'TOPChannelMasker')
280 main.add_module(
'TOPBunchFinder', subtractRunningOffset=
False)
282 main.add_module(
'TOPGeometryParInitializer')
283 main.add_module(
'TOPTimeRecalibrator', subtractBunchTime=
False)
284 main.add_module(
'TOPChannelMasker')
285 main.add_module(
'TOPBunchFinder', usePIDLikelihoods=
True,
286 subtractRunningOffset=
False)
289 collector = basf2.register_module(
'TOPCommonT0BFCollector')
292 algorithm = TOP.TOPCommonT0BFAlgorithm()
295 cal =
Calibration(name=
'TOP_commonT0Calibration', collector=collector,
296 algorithms=algorithm, input_files=inputFiles)
298 for globalTag
in reversed(globalTags):
299 cal.use_central_database(globalTag)
301 for localDB
in reversed(localDBs):
302 cal.use_local_database(localDB)
303 cal.pre_collector_path = main
304 cal.strategies = SequentialRunByRun
309 def commonT0_calibration_LL(inputFiles, sample='dimuon', globalTags=None, localDBs=None,
310 new_cdst_format=True):
312 Returns calibration object for common T0 calibration with method LL
313 :param inputFiles: A list of input files in cdst data format
314 :param sample: data sample ('dimuon' or 'bhabha')
315 :param globalTags: a list of global tags, highest priority first
316 :param localDBs: a list of local databases, highest priority first
317 :param new_cdst_format: True or False for new or old cdst format, respectively
321 main = basf2.create_path()
324 main.add_module(
'RootInput')
326 main.add_module(
'Gearbox')
327 main.add_module(
'Geometry')
328 main.add_module(
'Ext')
329 main.add_module(
'TOPUnpacker')
330 main.add_module(
'TOPRawDigitConverter')
331 main.add_module(
'TOPChannelMasker')
332 main.add_module(
'TOPBunchFinder', subtractRunningOffset=
False)
334 main.add_module(
'TOPGeometryParInitializer')
335 main.add_module(
'TOPTimeRecalibrator', subtractBunchTime=
False)
336 main.add_module(
'TOPChannelMasker')
337 main.add_module(
'TOPBunchFinder', usePIDLikelihoods=
True,
338 subtractRunningOffset=
False)
341 collector = basf2.register_module(
'TOPCommonT0LLCollector')
342 collector.param(
'sample', sample)
345 algorithm = TOP.TOPCommonT0LLAlgorithm()
348 cal =
Calibration(name=
'TOP_commonT0Calibration', collector=collector,
349 algorithms=algorithm, input_files=inputFiles)
351 for globalTag
in reversed(globalTags):
352 cal.use_central_database(globalTag)
354 for localDB
in reversed(localDBs):
355 cal.use_local_database(localDB)
356 cal.pre_collector_path = main
357 cal.strategies = SequentialRunByRun
362 def pulseHeight_calibration_laser(inputFiles, t_min=-50.0, t_max=0.0, look_back=28,
363 globalTags=None, localDBs=None):
365 Returns calibration object for calibration of pulse-height distributions and
366 threshold efficiencies with local laser runs.
367 :param inputFiles: A list of input files in sroot format
368 :param t_min: lower edge of time window to select laser signal [ns]
369 :param t_max: upper edge of time window to select laser signal [ns]
370 :param look_back: look-back window setting (set it to 0 to use the one from DB)
371 :param globalTags: a list of global tags, highest priority first
372 :param localDBs: a list of local databases, highest priority first
376 main = basf2.create_path()
379 main.add_module(
'SeqRootInput')
380 main.add_module(
'TOPGeometryParInitializer')
381 main.add_module(
'TOPUnpacker')
382 main.add_module(
'TOPRawDigitConverter', lookBackWindows=look_back)
385 collector = basf2.register_module(
'TOPPulseHeightCollector')
386 collector.param(
'timeWindow', [t_min, t_max])
387 collector.param(
'granularity',
'all')
390 algorithm = TOP.TOPPulseHeightAlgorithm()
393 cal =
Calibration(name=
'TOP_pulseHeightCalibration', collector=collector,
394 algorithms=algorithm, input_files=inputFiles)
396 for globalTag
in reversed(globalTags):
397 cal.use_central_database(globalTag)
399 for localDB
in reversed(localDBs):
400 cal.use_local_database(localDB)
401 cal.pre_collector_path = main
402 cal.strategies = SingleIOV
407 def pulseHeight_calibration_rawdata(inputFiles, globalTags=None, localDBs=None):
409 Returns calibration object for calibration of pulse-height distributions and
410 threshold efficiencies with raw data
411 :param inputFiles: A list of input files in raw data format
412 :param globalTags: a list of global tags, highest priority first
413 :param localDBs: a list of local databases, highest priority first
417 main = basf2.create_path()
420 main.add_module(
'RootInput')
421 main.add_module(
'TOPGeometryParInitializer')
422 main.add_module(
'TOPUnpacker')
423 main.add_module(
'TOPRawDigitConverter')
426 collector = basf2.register_module(
'TOPPulseHeightCollector')
427 collector.param(
'granularity',
'all')
430 algorithm = TOP.TOPPulseHeightAlgorithm()
433 cal =
Calibration(name=
'TOP_pulseHeightCalibration', collector=collector,
434 algorithms=algorithm, input_files=inputFiles)
436 for globalTag
in reversed(globalTags):
437 cal.use_central_database(globalTag)
439 for localDB
in reversed(localDBs):
440 cal.use_local_database(localDB)
441 cal.pre_collector_path = main
442 cal.strategies = SingleIOV
447 def module_alignment(inputFiles, sample='dimuon', fixedParameters=['dn/n'],
448 globalTags=None, localDBs=None, new_cdst_format=True,
451 Returns calibration object for alignment of TOP modules.
452 :param inputFiles: A list of input files in cdst data format
453 :param sample: data sample ('dimuon' or 'bhabha')
454 :fixedParameters: a list of parameters to be fixed (parameter names: basf2 -m TOPAlignmentCollector)
455 :param globalTags: a list of global tags, highest priority first
456 :param localDBs: a list of local databases, highest priority first
457 :param new_cdst_format: True or False for new or old cdst format, respectively
458 :param backend_args: Dictionary of backend args for the Collection object to use
464 for globalTag
in reversed(globalTags):
465 cal.use_central_database(globalTag)
467 for localDB
in reversed(localDBs):
468 cal.use_local_database(localDB)
469 cal.strategies = SingleIOV
475 jobs_per_collection = ceil(total_jobs / number_of_slots)
478 for slot
in range(1, 17):
480 main = basf2.create_path()
483 main.add_module(
'RootInput')
485 main.add_module(
'Gearbox')
486 main.add_module(
'Geometry')
487 main.add_module(
'Ext')
488 main.add_module(
'TOPUnpacker')
489 main.add_module(
'TOPRawDigitConverter')
490 main.add_module(
'TOPChannelMasker')
491 main.add_module(
'TOPBunchFinder', subtractRunningOffset=
False)
493 main.add_module(
'TOPGeometryParInitializer')
494 main.add_module(
'TOPTimeRecalibrator', subtractBunchTime=
False)
495 main.add_module(
'TOPChannelMasker')
496 main.add_module(
'TOPBunchFinder',
497 usePIDLikelihoods=
True, subtractRunningOffset=
False)
500 collector = basf2.register_module(
'TOPAlignmentCollector')
501 collector.param(
'sample', sample)
502 collector.param(
'parFixed', fixedParameters)
503 collector.param(
'targetModule', slot)
504 collector.param(
'granularity',
'all')
507 collection =
Collection(collector=collector, input_files=inputFiles,
508 pre_collector_path=main, max_collector_jobs=jobs_per_collection)
510 for globalTag
in reversed(globalTags):
511 collection.use_central_database(globalTag)
513 for localDB
in reversed(localDBs):
514 collection.use_local_database(localDB)
516 collection.backend_args = backend_args
519 cal.add_collection(name=
'slot_' +
'{:0=2d}'.format(slot), collection=collection)
522 algorithm = TOP.TOPAlignmentAlgorithm()
523 cal.algorithms = algorithm