Belle II Software development
trgcdctsf2DQM.py
1#!/usr/bin/env python3
2
3
10
11# -----------------------------------------------------------------------------------
12#
13# Example of GDL trigger DQM Module
14#
15# usage : %> basf2 trgcdctsfDQM.py [input sroot file name]
16#
17# -----------------------------------------------------------------------------------
18
19import basf2 as b2
20
21import sys # get argv
22import re
23argvs = sys.argv # get arg
24argc = len(argvs) # of arg
25
26b2.set_log_level(b2.LogLevel.DEBUG)
27
28main = b2.create_path()
29
30if argc == 2 and argvs[1][-6:] == ".sroot":
31 f_in_root = argvs[1]
32 input = b2.register_module('SeqRootInput')
33 matchobj = re.search(r"([^\/]+)\.sroot", f_in_root)
34 basename = re.sub(r'\.sroot$', '', matchobj.group())
35 input.param('inputFileName', f_in_root)
36elif argc == 2 and argvs[1][-5:] == ".root":
37 f_in_root = argvs[1]
38 input = b2.register_module('RootInput')
39 matchobj = re.search(r"([^\/]+)\.root", f_in_root)
40 basename = re.sub(r'\.root$', '', matchobj.group())
41 input.param('inputFileName', f_in_root)
42elif argc == 1:
43 input = b2.register_module('RootInput')
44 input.param('inputFileName', '/home/belle/nkzw/e3.4S/r034*/all/raw/sub00/raw.physics.hlt_hadron.0003.*.root')
45 basename = "e3.4S.r034"
46else:
47 sys.exit("trgcdctsfDQM.py> # of arg is strange. Exit.")
48
49main.add_module(input)
50histo = b2.register_module('HistoManager')
51histo.param("histoFileName", f"dqm.{basename}.superlayer2.root")
52
53# Unpacker
54trgcdctsfUnpacker = b2.register_module("TRGCDCTSFUnpacker")
55trgcdctsfUnpacker.param('TSFMOD', 2)
56main.add_module(trgcdctsfUnpacker)
57main.add_module(histo)
58
59# DQM
60trgcdctsfdqm = b2.register_module('TRGCDCTSFDQM')
61trgcdctsfdqm.param('generatePostscript', True)
62trgcdctsfdqm.param('TSFMOD', 2)
63# postscript file name
64psname = f"dqm.{basename}.ps"
65trgcdctsfdqm.param('postScriptName', psname)
66
67main.add_module(trgcdctsfdqm)
68
69progress = b2.register_module('Progress')
70main.add_module(progress)
71
72b2.process(main)
73
74print(b2.statistics)