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