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