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