Belle II Software development
runTBC.py
1#!/usr/bin/env python3
2
3
10
11#
12# Steering file to produce the Time Base calibration out of a pulser run
13# Called by the wrapper scripts runTBCpocket.sh and runTBClocal.sh, which
14# sets the proper directories for the output.
15#
16
17import basf2 as b2
18import sys
19
20# read parameters
21
22argvs = sys.argv
23if len(argvs) != 5:
24 print('usage: basf2', argvs[0],
25 '-i <file_root> (pocket|local) <slot> <channel> <output_dir>')
26 sys.exit()
27
28datatype = argvs[1] # data type (pocket, local)
29slot = int(argvs[2]) # slot number (1-16)
30channel = int(argvs[3]) # calibration channel (0-7)
31outdir = argvs[4] # output directory path
32
33print('data type:', datatype, ' slot:', slot, ' calibration channel:', channel,
34 ' output to:', outdir)
35
36# Suppress messages and warnings during processing
37b2.set_log_level(b2.LogLevel.ERROR)
38
39# Create path
40main = b2.create_path()
41
42# input
43roinput = b2.register_module('RootInput') # root files
44main.add_module(roinput)
45
46# conversion from RawCOPPER or RawDataBlock to RawDetector objects
47if datatype == 'pocket':
48 print('pocket DAQ data assumed')
49 converter = b2.register_module('Convert2RawDet')
50 main.add_module(converter)
51
52# Initialize TOP geometry parameters (creation of Geant geometry is not needed)
53main.add_module('TOPGeometryParInitializer')
54
55# Unpacking
56unpack = b2.register_module('TOPUnpacker')
57main.add_module(unpack)
58
59# Convert to TOPDigits
60converter = b2.register_module('TOPRawDigitConverter')
61converter.param('useSampleTimeCalibration', False)
62converter.param('useChannelT0Calibration', False)
63converter.param('useModuleT0Calibration', False)
64converter.param('useCommonT0Calibration', False)
65converter.param('calibrationChannel', channel) # if set, cal pulses will be flagged
66converter.param('calpulseHeightMin', 200) # in [ADC counts]
67converter.param('calpulseHeightMax', 900) # in [ADC counts]
68converter.param('calpulseWidthMin', 0.5) # in [ns]
69converter.param('calpulseWidthMax', 4.0) # in [ns]
70converter.param('minPulseWidth', 0.5) # in [ns]
71converter.param('lookBackWindows', 30) # in number of windows
72main.add_module(converter)
73
74# TB calibrator
75calib = b2.register_module('TOPTimeBaseCalibrator')
76calib.param('moduleID', slot)
77calib.param('method', 1) # Matrix inversion or iterative
78calib.param('directoryName', outdir)
79calib.logging.log_level = b2.LogLevel.INFO
80main.add_module(calib)
81
82# Show progress of processing
83progress = b2.register_module('Progress')
84main.add_module(progress)
85
86# Process events
87b2.process(main)
88
89# Print call statistics
90print(b2.statistics)
91print(b2.statistics(b2.statistics.TERM))