Belle II Software development
trggdlSummary.py
1#!/usr/bin/env python3
2
3
10
11# -----------------------------------------------------------------------------------
12#
13# Example of GDL trigger Summary Module
14#
15# usage : %> basf2 trggdlSummary.py [input sroot file name]
16#
17# -----------------------------------------------------------------------------------
18
19import basf2 as b2
20
21import sys # get argv
22import re
23import os.path
24argvs = sys.argv # get arg
25argc = len(argvs) # of arg
26if argc != 2:
27 sys.exit("trggdlSummary.py> # of arg is strange. Exit.")
28if argc == 2:
29 f_in_root = argvs[1]
30
31
32b2.set_log_level(b2.LogLevel.INFO)
33
34main = b2.create_path()
35
36# input
37if f_in_root[-6:] == ".sroot":
38 rootfiletype = "sroot"
39 input = b2.register_module('SeqRootInput')
40 matchobj = re.search("([^\\/]+)\\.sroot", f_in_root)
41 basename = re.sub('\\.sroot$', '', matchobj.group())
42if f_in_root[-5:] == ".root":
43 rootfiletype = "root"
44 input = b2.register_module('RootInput')
45 matchobj = re.search("([^\\/]+)\\.root", f_in_root)
46 basename = re.sub('\\.root$', '', matchobj.group())
47
48input.param('inputFileName', f_in_root)
49main.add_module(input)
50
51
52# output
53output = b2.register_module('RootOutput')
54output.param("outputFileName", f"trgsum/trgsum.{basename}.root")
55if not os.path.isdir('trgsum'):
56 os.mkdir('trgsum')
57
58# Unpacker
59trggdlUnpacker = b2.register_module("TRGGDLUnpacker")
60main.add_module(trggdlUnpacker)
61
62#
63trggdlsummary = b2.register_module('TRGGDLSummary')
64main.add_module(trggdlsummary)
65
66progress = b2.register_module('Progress')
67main.add_module(progress)
68
69main.add_module(output, branchNames=["TRGSummary"])
70
71b2.process(main)
72
73print(b2.statistics)