Belle II Software development
trggdlUnpacker.py
1#!/usr/bin/env python
2#
3
4
11
12# -----------------------------------------------------------------------------------
13#
14# GDL trigger Unpacker module
15#
16# usage : %> basf2 TrgGdlUnpacker.py [input sroot file name]
17#
18# -----------------------------------------------------------------------------------
19
20import basf2 as b2
21
22import sys
23
24argvs = sys.argv # get arg
25argc = len(argvs) # of arg
26
27if argc != 2:
28 sys.exit("trggdlUnpacker.py> # of arg is strange.\n 1.rootname\n Exit.")
29
30if argc == 2:
31 f_in_root = argvs[1]
32
33# set_log_level(LogLevel.ERROR)
34b2.set_log_level(b2.LogLevel.INFO)
35
36b2.use_central_database("TRGGDL_201811")
37
38# input
39if f_in_root[-6:] == ".sroot":
40 rootfiletype = "sroot"
41 input = b2.register_module('SeqRootInput')
42if f_in_root[-5:] == ".root":
43 rootfiletype = "root"
44 input = b2.register_module('RootInput')
45
46input.param('inputFileName', f_in_root)
47
48# unpacker
49unpacker = b2.register_module('TRGGDLUnpacker')
50# No unpacking. Just print info of trigger readout board
51# included in the data.
52trgReadoutBoardSearch = False
53unpacker.param('trgReadoutBoardSearch', trgReadoutBoardSearch)
54
55# output
56output = b2.register_module('RootOutput')
57
58# Create main path
59main = b2.create_path()
60
61# Add modules to main path
62main.add_module(input)
63main.add_module(unpacker)
64
65input.param("inputFileName", f_in_root)
66output.param("outputFileName", "gdltrg_test.root")
67
68main.add_module(output, branchNames=["TRGGDLUnpackerStores"])
69
70if trgReadoutBoardSearch:
71 b2.process(main, max_event=100)
72else:
73 b2.process(main)