Belle II Software  release-08-01-10
trgcdctsfDQM.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.root" % basename)
53 
54 
55 nmod = [0, 1, 2, 3, 4, 5, 6]
56 for mod in nmod:
57  # Unpacker
58  main.add_module('TRGCDCTSFUnpacker', TSFMOD=mod)
59 
60  # DQM
61  main.add_module('TRGCDCTSFDQM', TSFMOD=mod)
62 
63 main.add_module(histo)
64 
65 progress = b2.register_module('Progress')
66 main.add_module(progress)
67 
68 b2.process(main)
69 
70 print(b2.statistics)