8 from functools
import cache
11 Dump content of the HLT result and HLT related details from the event header.
15 parser = argparse.ArgumentParser(description = __doc__)
17 parser.add_argument(
"files", metavar=
"FILE", nargs=
'+',
18 help=
"RAW file to inspect")
20 parser.add_argument(
"-n",
"--events", metavar=
"N", action=
"store", type=int,
21 help=
"Process N events")
23 parser.add_argument(
"-s",
"--skip", metavar=
"N", action=
"store", type=int,
26 parser.add_argument(
"--l1", action=
"store_true", default=
False,
27 help=
"L1 trigger bits (from event header)")
29 parser.add_argument(
"--decodeItems", action=
"store_true", default=
False,
30 help=
"Decode trigger item names")
32 parser.add_argument(
"--smk", action=
"store", type=int, default=0,
33 help=
"Specify SMK for trigger item decoding if not available in HLT result")
35 parser.add_argument(
"--l2", action=
"store_true", default=
False,
36 help=
"L2 trigger bits (from event header)")
38 parser.add_argument(
"--ef",
"--hlt", action=
"store_true", default=
False,
39 help=
"EF/HLT trigger bits (from event header)")
41 parser.add_argument(
"--ctp", nargs=
"?", metavar=
"MID", default=
False, const=1,
42 help=
"CTP ROB details of ROB with module_id MID [default=%(const)s]")
44 parser.add_argument(
"--stag", action=
"store_true", default=
False,
47 parser.add_argument(
"--l2res", action=
"store_true", default=
False,
48 help=
"details of L2 ROB payload")
50 parser.add_argument(
"--efres",
"--hltres", action=
"store_true", default=
False,
51 help=
"details of EF/HLT ROB payload")
53 parser.add_argument(
"--chains", action=
"store_true", default=
False,
54 help=
"details about chains")
56 parser.add_argument(
"--features", action=
"store_true", default=
False,
57 help=
"details about features")
59 parser.add_argument(
"--tes", action=
"store_true", default=
False,
60 help=
"details about TriggerElements")
62 parser.add_argument(
"--conf", action=
"store_true", default=
False,
63 help=
"configuration keys")
65 parser.add_argument(
"--sizes", action=
"store_true", default=
False,
66 help=
"dump info about sizes")
68 parser.add_argument(
"--stats", action=
"store_true", default=
False,
69 help=
"dump counts at the end only")
71 parser.add_argument(
"--sizeSummary", action=
"store_true", default=
False,
72 help=
"dump info about sizes at the end")
74 parser.add_argument(
"--interactive", action=
"store_true", default=
False,
75 help=
"after opening the file enter interactive prompt")
79 args = parser.parse_args()
81 from TrigByteStreamTools.hltResult
import hltResult, print_HLTResult, collect_feature_sizes
82 from TrigByteStreamTools
import CTPfragment
95 info = event.lvl1_trigger_info()
97 return [CTPfragment.decodeTriggerBits(info[i*nwords:(i+1)*nwords])
for i
in range(3)]
101 ctp_robs = [rob
for rob
in event.children() \
102 if rob.source_id().subdetector_id() == eformat.helper.SubDetector.TDAQ_CTP \
103 and rob.source_id().module_id()==module_id]
106 print(
"No CTP ROB found")
109 x = CTPfragment.getExtraPayloadObject(rob)
111 upd =
''.
join([
'[%d,%d]' % (f.second.folderIndex,f.second.lumiBlock)
for f
in folderUpdates])
112 print(
"ROB 0x%0x, L1ID %10d, LB %4d, Version %d, Bunch %d, HLT counter: %3d, Payload #%d %s L1PSK %d BGK %d COOLUPD %s" % (
113 rob.source_id().
code(),
116 CTPfragment.ctpFormatVersion(rob),
117 CTPfragment.lvl1AcceptBunch(rob),
118 CTPfragment.hltCounter(rob),
119 CTPfragment.numberHltExtraPayloadWords(rob),
120 CTPfragment.hltExtraPayloadWords(rob),
125 for w
in [
'TBP',
'TAP',
'TAV']:
126 items = CTPfragment.decodeTriggerBits(CTPfragment.getTriggerWords(rob,w))
132 from CoolRunQuery.utils.AtlRunQueryTriggerUtils
import getL1Menu
136 if not args.decodeItems:
140 names = [l1menu[i].name
for i
in items]
145 """Runs the dumping routines"""
151 print(
"Opening", bsfile)
153 input = eformat.istream(bsfile)
157 code.interact(local=locals())
162 offset = args.skip
if args.skip
else 0
170 if args.events
is not None and event_count>args.events:
173 print(
"======================= RunNumber : %d , Event: %d, LB: %d, LVL1_ID: %d, Global_ID: %d bunch-x: %d TT: x%x =========================="
174 % ( event.run_no(), event_count, event.lumi_block(), event.lvl1_id(), event.global_id(), event.bc_id(), event.lvl1_trigger_type()))
177 if args.decodeItems
and args.smk==0:
178 hltrob = [f
for f
in event.children()
if f.source_id().subdetector_id()
in [eformat.helper.SubDetector.TDAQ_LVL2,eformat.helper.SubDetector.TDAQ_EVENT_FILTER] ]
180 print(
"ERROR: Cannot find HLT result. Will not decode trigger item names.")
181 args.decodeItems =
False
184 smk = res.getConfigSuperMasterKey()
186 print(
"ERROR: No SMK stored in HLT result. Will not decode trigger item names.")
187 args.decodeItems =
False
200 print(
"L2 TriggerInfo: ", [
"0x%x"%i
for i
in event.lvl2_trigger_info() ])
203 if args.l2res
or args.sizeSummary:
205 for f
in event.children():
206 if f.source_id().subdetector_id() == eformat.helper.SubDetector.TDAQ_LVL2:
207 print(
'.. %s %s %s bytes' % (f.__class__.__name__, f.source_id(), f.fragment_size_word()*4))
216 print(
".. EOF HLTResult for L2")
218 print(
".. No HLTResult for L2")
222 print(
"EF TriggerInfo: ", [
"0x%x"%i
for i
in event.event_filter_info()])
226 if args.efres
or args.sizeSummary:
228 for f
in event.children():
229 if f.source_id().subdetector_id() == eformat.helper.SubDetector.TDAQ_EVENT_FILTER:
230 print(
'.. %s %s %s bytes' % (f.__class__.__name__, f.source_id(), f.fragment_size_word()*4))
240 except Exception
as ex:
241 print(
'... **** problems in analyzing payload', ex)
242 print(
'... **** raw data[:10]',
list(f.rod_data())[:10])
243 print(
".. EOF HLTResult for EF")
245 print(
".. No HLTResult for EF")
248 print(
"StreamTag: ", [(s.name, s.type)
for s
in event.stream_tag()])
250 event_count =
max(l2_event_count, ef_event_count)
252 print(
'... '+20*
'-'+
'sizes by type')
253 for f,s
in sorted(featureSizes.items(),key=operator.itemgetter(1),reverse=
True):
255 print(
".... %-70s %6d B %6d B/ev" %(f, s, (1.*s)/event_count))
256 print(
'... '+20*
'-'+
'sizes by type#key')
257 for f,s
in sorted(featureSizes.items(),key=operator.itemgetter(1),reverse=
True):
259 print(
".... %-70s %6d B %6d B/ev" %(f, s, (1.*s)/event_count))
262 if __name__ ==
"__main__":