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