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