Belle II Software development
trgcdct2dDQM.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12from ROOT import Belle2
13
14# skip the event in the output if it doesn't contain trg data
15skim_dummy_trg = True
16# whether to save the output dst file
17save_output = False
18# use an input file that is already unpacked
19from_unpacked = False
20
21input_files = Belle2.Environment.Instance().getInputFilesOverride()
22if not input_files.empty() and input_files.front().endswith(".sroot"):
23 root_input = b2.register_module('SeqRootInput')
24else:
25 root_input = b2.register_module('RootInput')
26
27main = b2.create_path()
28main.add_module(root_input)
29
30histo = b2.register_module('HistoManager')
31histoutput_name = input_files.front().split('/')[-1]
32histoutput_name = './monitor_plots/' + histoutput_name[:histoutput_name.rfind('.')] + '.unpacked.root'
33histo.param("histoFileName", histoutput_name)
34main.add_module(histo)
35
36
37if not from_unpacked:
38 main.add_module('Progress')
39 unpacker = b2.register_module('CDCTriggerUnpacker')
40 unpacker.logging.log_level = b2.LogLevel.DEBUG
41 # increase this value to get debug mesages in more detail
42 unpacker.logging.debug_level = 10
43 unpacker.logging.set_info(b2.LogLevel.DEBUG, b2.LogInfo.LEVEL | b2.LogInfo.MESSAGE)
44 # size (number of words) of the Belle2Link header
45 unpacker.param('headerSize', 3)
46 # unpack the data from the 2D tracker and save its Bitstream
47 unpacker.param('unpackTracker2D', True)
48 # make CDCTriggerSegmentHit objects from the 2D input
49 unpacker.param('decode2DFinderInput', True)
50 unpacker.param('decode2DFinderTrack', True)
51 # it seems the B2L for 2D0 and 2D1 are swapped
52 unpacker.param('2DNodeId', [
53 [0x11000001, 0],
54 [0x11000001, 1],
55 [0x11000002, 0],
56 [0x11000002, 1]])
57 unpacker.param('2DNodeId_pcie40', [
58 [0x10000001, 0],
59 [0x10000001, 1],
60 [0x10000001, 2],
61 [0x10000001, 3]])
62
63 main.add_module(unpacker)
64
65 if skim_dummy_trg:
66 # skip if there are no trigger data in the event
67 empty_path = b2.create_path()
68 unpacker.if_false(empty_path)
69
70 main.add_module('TRGCDCT2DDQM')
71
72
73if save_output:
74 # save the output root file with specified file name
75 output_name = input_files.front().split('/')[-1]
76 output_name = output_name[:output_name.rfind('.')] + '.unpacked.root'
77 main.add_module('RootOutput',
78 outputFileName=output_name,
79 excludeBranchNames=['RawCDCs',
80 'RawECLs',
81 'RawKLMs',
82 'RawSVDs',
83 'RawPXDs',
84 'RawTOPs'])
85
86b2.process(main)
87print(b2.statistics)
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28