Belle II Software  release-05-02-19
monitor.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 if not from_unpacked:
26  main.add_module('Progress')
27  # unpack CDC data
28  # Set Database
29  use_database_chain()
30  use_local_database(Belle2.FileSystem.findFile("data/framework/database.txt"))
31  cdc_unpacker = register_module('CDCUnpacker')
32  cdc_unpacker.param('enableStoreCDCRawHit', True)
33  main.add_module(cdc_unpacker)
34 
35  unpacker = register_module('CDCTriggerUnpacker')
36  unpacker.logging.log_level = LogLevel.DEBUG
37  # increase this value to get debug mesages in more detail
38  unpacker.logging.debug_level = 10
39  unpacker.logging.set_info(LogLevel.DEBUG, LogInfo.LEVEL | LogInfo.MESSAGE)
40  # size (number of words) of the Belle2Link header
41  unpacker.param('headerSize', 3)
42  # unpack the data from the 2D tracker and save its Bitstream
43  unpacker.param('unpackTracker2D', True)
44  # make CDCTriggerSegmentHit objects from the 2D input
45  unpacker.param('decode2DFinderInput', True)
46  # it seems the B2L for 2D0 and 2D1 are swapped
47  unpacker.param('2DNodeId', [
48  [0x11000001, 1],
49  [0x11000001, 0],
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('Gearbox')
61  main.add_module('Geometry', components=['BeamPipe',
62  'PXD', 'SVD', 'CDC',
63  'MagneticFieldConstant4LimitedRCDC'])
64  cdcdigitizer = register_module('CDCDigitizer')
65  # ...CDCDigitizer...
66  # set digitizer to no smearing
67  param_cdcdigi = {'Fraction': 1,
68  'Resolution1': 0.,
69  'Resolution2': 0.,
70  'Threshold': -10.0}
71  cdcdigitizer.param(param_cdcdigi)
72  cdcdigitizer.param('AddInWirePropagationDelay', True)
73  cdcdigitizer.param('AddTimeOfFlight', True)
74  cdcdigitizer.param('UseSimpleDigitization', True)
75  main.add_module(cdcdigitizer)
76  main.add_module('CDCTriggerTSF',
77  InnerTSLUTFile=Belle2.FileSystem.findFile("data/trg/cdc/innerLUT_Bkg_p0.70_b0.80.coe"),
78  OuterTSLUTFile=Belle2.FileSystem.findFile("data/trg/cdc/outerLUT_Bkg_p0.70_b0.80.coe"),
79  TSHitCollectionName='TSimSegmentHits')
80 else:
81  save_output = False
82 
83 main.add_module(Monitor())
84 
85 if save_output:
86  # save the output root file with specified file name
87  output_name = input_files.front().split('/')[-1]
88  output_name = output_name[:output_name.rfind('.')] + '.unpacked.root'
89  main.add_module('RootOutput',
90  outputFileName=output_name,
91  excludeBranchNames=['RawCDCs',
92  'RawECLs',
93  'RawKLMs',
94  'RawSVDs',
95  'RawPXDs',
96  'RawTOPs'])
97 
98 process(main)
99 print(statistics)
Belle2::Environment::Instance
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:31
Belle2::FileSystem::findFile
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:147
Monitor
Definition: Monitor.py:1