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