Belle II Software development
unpack_cdctrigger.py
1#!/usr/bin/env python3
2
3
10
11
14
15# usage: basf2 SOME_PATH/unpack_cdctrigger.py -i inputFile.[s]root [-o outputFile.root]
16# (items in the square brackets [] are optional)
17
18import basf2 as b2
19from ROOT import Belle2
20
21# whether we will also unpack CDC data
22unpack_CDCHit = True
23# don't save the event in the output if it doesn't contain trg data
24skim_dummy_trg = True
25
26input_files = Belle2.Environment.Instance().getInputFilesOverride()
27if not input_files.empty() and input_files.front().endswith(".sroot"):
28 root_input = b2.register_module('SeqRootInput')
29else:
30 root_input = b2.register_module('RootInput')
31
32main = b2.create_path()
33main.add_module(root_input)
34
35if unpack_CDCHit:
36 # Set Database
37 b2.use_database_chain()
38 b2.use_local_database(Belle2.FileSystem.findFile("data/framework/database.txt"))
39 cdc_unpacker = b2.register_module('CDCUnpacker')
40 cdc_unpacker.param('enableStoreCDCRawHit', True)
41 main.add_module(cdc_unpacker)
42
43unpacker = b2.register_module('CDCTriggerUnpacker')
44unpacker.logging.log_level = b2.LogLevel.DEBUG
45# increase this value to get debug mesages in more detail
46unpacker.logging.debug_level = 10
47unpacker.logging.set_info(b2.LogLevel.DEBUG, b2.LogInfo.LEVEL | b2.LogInfo.MESSAGE)
48# size (number of words) of the Belle2Link header
49unpacker.param('headerSize', 3)
50# unpack the data from the 2D tracker and save its Bitstream
51unpacker.param('unpackTracker2D', True)
52# make CDCTriggerTrack and CDCTriggerSegmentHit objects from the 2D output
53unpacker.param('decode2DFinderTrack', True)
54# make CDCTriggerSegmentHit objects from the 2D input
55unpacker.param('decode2DFinderInput', True)
56# it seems the B2L for 2D0 and 2D1 are swapped
57unpacker.param('2DNodeId', [
58 [0x11000001, 1],
59 [0x11000001, 0],
60 [0x11000002, 0],
61 [0x11000002, 1]])
62unpacker.param('2DNodeId_pcie40', [
63 [0x10000001, 0],
64 [0x10000001, 1],
65 [0x10000001, 2],
66 [0x10000001, 3]])
67
68main.add_module(unpacker)
69
70if skim_dummy_trg:
71 # don't save the output if there are no trigger data in the event
72 empty_path = b2.create_path()
73 unpacker.if_false(empty_path)
74
75# save the output root file with specified file name
76main.add_module('RootOutput',
77 outputFileName='unpackedCDCTrigger.root',
78 excludeBranchNames=['RawCDCs',
79 'RawECLs',
80 'RawKLMs',
81 'RawSVDs',
82 'RawPXDs',
83 'RawTOPs'])
84b2.process(main)
85print(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