Belle II Software development
monitor.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12from ROOT import Belle2
13from monitor_module import Monitor
14
15# skip the event in the output if it doesn't contain trg data
16skim_dummy_trg = True
17# whether to save the output dst file
18save_output = False
19# use an input file that is already unpacked
20from_unpacked = False
21
22input_files = Belle2.Environment.Instance().getInputFilesOverride()
23if not input_files.empty() and input_files.front().endswith(".sroot"):
24 root_input = b2.register_module('SeqRootInput')
25else:
26 root_input = b2.register_module('RootInput')
27
28main = b2.create_path()
29main.add_module(root_input)
30
31if not from_unpacked:
32 main.add_module('Progress')
33 # unpack CDC data
34 # Set Database
35 b2.use_database_chain()
36 b2.use_local_database(Belle2.FileSystem.findFile("data/framework/database.txt"))
37 cdc_unpacker = b2.register_module('CDCUnpacker')
38 cdc_unpacker.param('enableStoreCDCRawHit', True)
39 main.add_module(cdc_unpacker)
40
41 unpacker = b2.register_module('CDCTriggerUnpacker')
42 unpacker.logging.log_level = b2.LogLevel.DEBUG
43 # increase this value to get debug mesages in more detail
44 unpacker.logging.debug_level = 10
45 unpacker.logging.set_info(b2.LogLevel.DEBUG, b2.LogInfo.LEVEL | b2.LogInfo.MESSAGE)
46 # size (number of words) of the Belle2Link header
47 unpacker.param('headerSize', 3)
48 # unpack the data from the 2D tracker and save its Bitstream
49 unpacker.param('unpackTracker2D', True)
50 # make CDCTriggerSegmentHit objects from the 2D input
51 unpacker.param('decode2DFinderInput', True)
52 # it seems the B2L for 2D0 and 2D1 are swapped
53 unpacker.param('2DNodeId', [
54 [0x11000001, 1],
55 [0x11000001, 0],
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('Gearbox')
72 main.add_module('Geometry', components=['BeamPipe',
73 'PXD', 'SVD', 'CDC',
74 'MagneticFieldConstant4LimitedRCDC'])
75 cdcdigitizer = b2.register_module('CDCDigitizer')
76 # ...CDCDigitizer...
77 # set digitizer to no smearing
78 param_cdcdigi = {'Fraction': 1,
79 'Resolution1': 0.,
80 'Resolution2': 0.,
81 'Threshold': -10.0}
82 cdcdigitizer.param(param_cdcdigi)
83 cdcdigitizer.param('AddInWirePropagationDelay', True)
84 cdcdigitizer.param('AddTimeOfFlight', True)
85 cdcdigitizer.param('UseSimpleDigitization', True)
86 main.add_module(cdcdigitizer)
87 main.add_module('CDCTriggerTSF',
88 InnerTSLUTFile=Belle2.FileSystem.findFile("data/trg/cdc/innerLUT_Bkg_p0.70_b0.80.coe"),
89 OuterTSLUTFile=Belle2.FileSystem.findFile("data/trg/cdc/outerLUT_Bkg_p0.70_b0.80.coe"),
90 TSHitCollectionName='TSimSegmentHits')
91else:
92 save_output = False
93
94main.add_module(Monitor())
95
96if save_output:
97 # save the output root file with specified file name
98 output_name = input_files.front().split('/')[-1]
99 output_name = output_name[:output_name.rfind('.')] + '.unpacked.root'
100 main.add_module('RootOutput',
101 outputFileName=output_name,
102 excludeBranchNames=['RawCDCs',
103 'RawECLs',
104 'RawKLMs',
105 'RawSVDs',
106 'RawPXDs',
107 'RawTOPs'])
108
109b2.process(main)
110print(b2.statistics)
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:151