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