Belle II Software development
trggdlDQM.py
1#!/usr/bin/env python3
2
3
10
11# -----------------------------------------------------------------------------------
12#
13# Example of GDL trigger DQM Module
14#
15# usage : %> basf2 trggdlDQM.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
26
27b2.set_log_level(b2.LogLevel.DEBUG)
28
29b2.use_central_database("TRGGDL_201811")
30
31main = b2.create_path()
32
33if argc == 2 and argvs[1][-6:] == ".sroot":
34 f_in_root = argvs[1]
35 input = b2.register_module('SeqRootInput')
36 matchobj = re.search("([^\\/]+)\\.sroot", f_in_root)
37 basename = re.sub('\\.sroot$', '', matchobj.group())
38 input.param('inputFileName', f_in_root)
39elif argc == 2 and argvs[1][-5:] == ".root":
40 f_in_root = argvs[1]
41 input = b2.register_module('RootInput')
42 matchobj = re.search("([^\\/]+)\\.root", f_in_root)
43 basename = re.sub('\\.root$', '', matchobj.group())
44 input.param('inputFileName', f_in_root)
45elif argc == 1:
46 input = b2.register_module('RootInput')
47 input.param('inputFileName', '/home/belle/nkzw/e3.4S/r034*/all/raw/sub00/raw.physics.hlt_hadron.0003.*.root')
48 basename = "e3.4S.r034"
49else:
50 sys.exit("trggdlDQM.py> # of arg is strange. Exit.")
51
52main.add_module(input)
53histo = b2.register_module('HistoManager')
54histo.param("histoFileName", f"dqm.{basename}.root")
55
56# Unpacker
57trggdlUnpacker = b2.register_module("TRGGDLUnpacker")
58main.add_module(trggdlUnpacker)
59main.add_module(histo)
60
61# DQM
62# trggdldqm = register_module('TRGGDLDQM', logLevel=LogLevel.DEBUG, debugLevel=20)
63trggdldqm = b2.register_module('TRGGDLDQM')
64# event by event bit-vs-clock TH2I hist for itd, ftdl, psnm in ROOT file.
65trggdldqm.param('eventByEventTimingHistRecord', False)
66# bit name on BinLabel for hGDL_itd,ftd,psn.
67trggdldqm.param('bitNameOnBinLabel', True)
68# generate postscript file that includes rising and falling edge distribution
69trggdldqm.param('generatePostscript', False)
70# postscript file name
71psname = f"dqm.{basename}.ps"
72trggdldqm.param('postScriptName', psname)
73
74# dump vcd file
75dumpVcdFileTrue = False
76trggdldqm.param('dumpVcdFile', dumpVcdFileTrue)
77if dumpVcdFileTrue:
78 if not os.path.isdir('vcd'):
79 os.mkdir('vcd')
80 trggdldqm.param('bitConditionToDumpVcd', 'HIE ECL_BHA')
81 # '+' means logical OR. '!' is logical NOT.
82 # Bit names is delimited by space. No space after '!'.
83 # Parenthesis, A (B+!C) not allowed. Must be expanded to 'A B+A !C'.
84 # If one of characters is capital, the bit is regarded as psnm bit,
85 # otherwise ftdl bit: 'hie' is ftdl hie bit. 'hIE' is psnm hie bit.
86 trggdldqm.param('vcdEventStart', 0)
87 trggdldqm.param('vcdNumberOfEvents', 10)
88
89main.add_module(trggdldqm)
90
91progress = b2.register_module('Progress')
92main.add_module(progress)
93
94b2.process(main)
95
96print(b2.statistics)