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