Belle II Software  release-05-01-25
unpackToTOPDigitsWithTBC.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # ---------------------------------------------------------------------------------------
5 # Unpack raw data in Interim FE format v2.1 to TOPDigits using time base calibration
6 # Usage: basf2 unpackToTOPDigitsWithTBC.py -i <input_file.sroot> -o <output_file.root>
7 #
8 # Name and location of local DB can be changed if needed
9 # ---------------------------------------------------------------------------------------
10 
11 from basf2 import *
12 
13 # Create path
14 main = create_path()
15 
16 # input
17 roinput = register_module('SeqRootInput')
18 # roinput = register_module('RootInput')
19 main.add_module(roinput)
20 
21 # conversion from RawCOPPER or RawDataBlock to RawDetector objects
22 converter = register_module('Convert2RawDet')
23 main.add_module(converter)
24 
25 # geometry parameters
26 gearbox = register_module('Gearbox')
27 main.add_module(gearbox)
28 
29 # Geometry (only TOP needed)
30 geometry = register_module('Geometry')
31 geometry.param('useDB', False)
32 geometry.param('components', ['TOP'])
33 main.add_module(geometry)
34 
35 # Unpacking (format auto detection works now)
36 unpack = register_module('TOPUnpacker')
37 main.add_module(unpack)
38 
39 # Add multiple hits by running feature extraction offline
40 featureExtractor = register_module('TOPWaveformFeatureExtractor')
41 main.add_module(featureExtractor)
42 
43 # Convert to TOPDigits
44 converter = register_module('TOPRawDigitConverter')
45 converter.param('useSampleTimeCalibration', True) # enable calibration
46 converter.param('useChannelT0Calibration', False)
47 converter.param('useModuleT0Calibration', False)
48 converter.param('useCommonT0Calibration', False)
49 converter.param('calibrationChannel', 0) # if set, cal pulses will be flagged
50 converter.param('calpulseHeightMin', 450) # in [ADC counts]
51 converter.param('calpulseHeightMax', 900) # in [ADC counts]
52 converter.param('calpulseWidthMin', 2.0) # in [ns]
53 converter.param('calpulseWidthMax', 6.0) # in [ns]
54 main.add_module(converter)
55 
56 # output
57 output = register_module('RootOutput')
58 output.param('branchNames', ['TOPDigits', 'TOPRawDigits', 'TOPInterimFEInfos',
59  'TOPRawDigitsToTOPInterimFEInfos',
60  # 'TOPRawWaveforms', 'TOPRawWaveformsToTOPInterimFEInfos',
61  # 'TOPRawDigitsToTOPRawWaveforms',
62  ])
63 main.add_module(output)
64 
65 # Print progress
66 progress = register_module('Progress')
67 main.add_module(progress)
68 
69 # Process events
70 process(main)
71 
72 # Print statistics
73 print(statistics)