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