Belle II Software development
unpackToTOPDigitsWithTBC.py
1#!/usr/bin/env python
2
3
10
11# ---------------------------------------------------------------------------------------
12# Unpack raw data to TOPDigits using time base calibration
13#
14# Usage: basf2 unpackToTOPDigitsWithTBC.py -i <input_file.root> -o <output_file.root>
15# ---------------------------------------------------------------------------------------
16
17import basf2 as b2
18
19# Database
20b2.conditions.override_globaltags()
21b2.conditions.append_globaltag('online')
22# b2.conditions.append_testing_payloads('localDB-FEMaps/localDB.txt') # SCROD mapping from local database
23# b2.conditions.append_testing_payloads('localDB-timebase/localDB.txt') # timebase calibration from local database
24
25# Create path
26main = b2.create_path()
27
28# input
29# roinput = b2.register_module('SeqRootInput') # sroot files
30roinput = b2.register_module('RootInput') # root files
31main.add_module(roinput)
32
33# conversion from RawCOPPER or RawDataBlock to RawDetector objects (uncomment for pocketDAQ)
34# main.add_module('Convert2RawDet')
35
36# Initialize TOP geometry parameters (creation of Geant geometry is not needed)
37main.add_module('TOPGeometryParInitializer')
38
39# Unpacking (format auto detection works now)
40unpack = b2.register_module('TOPUnpacker')
41main.add_module(unpack)
42
43# Convert to TOPDigits
44converter = b2.register_module('TOPRawDigitConverter')
45converter.param('useSampleTimeCalibration', True) # enable using calibration
46converter.param('useChannelT0Calibration', False)
47converter.param('useModuleT0Calibration', False)
48converter.param('useCommonT0Calibration', False)
49converter.param('calibrationChannel', 0) # if set, cal pulses will be flagged
50converter.param('calpulseHeightMin', 450) # in [ADC counts]
51converter.param('calpulseHeightMax', 900) # in [ADC counts]
52converter.param('calpulseWidthMin', 2.0) # in [ns]
53converter.param('calpulseWidthMax', 6.0) # in [ns]
54main.add_module(converter)
55
56# output
57output = b2.register_module('RootOutput')
58output.param('branchNames', ['TOPDigits', 'TOPRawDigits', 'TOPProductionEventDebugs',
59 'TOPProductionHitDebugs', 'TOPRawDigitsToTOPProductionHitDebugs',
60 # 'TOPRawWaveforms', 'TOPRawDigitsToTOPRawWaveforms',
61 ])
62main.add_module(output)
63
64# Print progress
65progress = b2.register_module('Progress')
66main.add_module(progress)
67
68# Process events
69b2.process(main)
70
71# Print statistics
72print(b2.statistics)