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