Belle II Software development
calibrateTimeBase.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12
13# ----------------------------------------------------------------------------
14# Example of running time base calibration using simulated double pulses
15# ----------------------------------------------------------------------------
16
17# slot number to calibrate
18moduleID = 5
19
20# use realistic cal pulses (waveforms) or not
21realistic = True
22
23# Suppress messages and warnings during processing:
24b2.set_log_level(b2.LogLevel.ERROR)
25
26# Create path
27main = b2.create_path()
28
29# Set number of events to generate
30eventinfosetter = b2.register_module('EventInfoSetter')
31eventinfosetter.param('evtNumList', [10000])
32main.add_module(eventinfosetter)
33
34# Gearbox: access to database (xml files)
35gearbox = b2.register_module('Gearbox')
36main.add_module(gearbox)
37
38# Geometry
39geometry = b2.register_module('Geometry')
40geometry.param('useDB', False)
41geometry.param('components', ['TOP'])
42main.add_module(geometry)
43
44# pulse generator
45if realistic:
46 # generator
47 calpulse = b2.register_module('TOPCalPulseGenerator')
48 calpulse.param('asicChannels', [0])
49 calpulse.param('moduleIDs', [moduleID])
50 calpulse.param('amplitude', 750.0)
51 main.add_module(calpulse)
52
53 # digitization
54 topdigi = b2.register_module('TOPDigitizer')
55 topdigi.param('useSampleTimeCalibration', True)
56 main.add_module(topdigi)
57else:
58 # generator
59 calpulse = b2.register_module('TOPDoublePulseGenerator')
60 calpulse.param('asicChannels', [0])
61 calpulse.param('moduleIDs', [moduleID])
62 calpulse.param('useDatabase', True)
63 calpulse.param('outputFileName', 'usedSampleTimes.root')
64 main.add_module(calpulse)
65
66
67# TB calibrator
68calib = b2.register_module('TOPTimeBaseCalibrator')
69calib.param('moduleID', moduleID)
70calib.param('minTimeDiff', 40)
71calib.param('maxTimeDiff', 80)
72calib.param('directoryName', 'tbc')
73calib.param('method', 1)
74calib.param('useFallingEdge', False)
75calib.logging.log_level = b2.LogLevel.INFO
76main.add_module(calib)
77
78# Show progress of processing
79progress = b2.register_module('Progress')
80main.add_module(progress)
81
82# Process events
83b2.process(main)
84
85# Print call statistics
86print(b2.statistics)
87print(b2.statistics(b2.statistics.TERM))