7 Dump content of the HLT navigation collections found in HLT ByteStream data
12 from TrigByteStreamTools
import hltResultMT
14 from AthenaCommon.Logging
import logging
15 log = logging.getLogger(
'dumpHLTNav')
19 parser = argparse.ArgumentParser(usage=
'%(prog)s [options] FILE [FILE]',
21 parser.add_argument(
'files',
22 metavar=
'FILE [FILE]', nargs=
'+',
23 help=
'RAW files to inspect')
24 parser.add_argument(
'-n',
'--events',
25 metavar=
'N', action=
'store', type=int,
26 help=
'Process N events')
27 parser.add_argument(
'-s',
'--skip',
28 metavar=
'N', action=
'store', type=int,
30 parser.add_argument(
'-m',
'--module',
31 metavar=
'N', action=
'store', type=int, default=0,
32 help=
'HLT ROB module ID to print; negative number means all modules, default is %(default)s')
41 for col
in collections:
42 if 'HLTNav_' not in col.name():
45 if col.is_xAOD_interface_container():
46 xaod_map[col.name_key] = {
51 elif col.is_xAOD_aux_container():
52 strip_name = col.name_key[0:-4]
53 if strip_name
not in xaod_map:
54 log.warning(
'%s not in xaod_map', strip_name)
56 xaod_map[strip_name][
'aux_cont'] = col
57 elif col.is_xAOD_decoration():
59 log.warning(
'{:s} has no parent', col.name())
60 strip_name = col.parent.name_key[0:-4]
61 if strip_name
not in xaod_map:
62 log.warning(
'%s not in xaod_map', strip_name)
64 xaod_map[strip_name][
'decorations'].
append(col)
67 for key, col_dict
in xaod_map.items():
68 if not col_dict[
'interface']:
69 log.warning(
'%s interface collection missing', key)
71 if not col_dict[
'aux_cont']:
72 log.warning(
'%s aux_cont collection missing', key)
76 cont_deco = [c.deserialise()
for c
in col_dict[
'decorations']]
83 log.warning(
'%s aux_cont deserialisation failed', key)
86 cont_if.setStore(cont_aux)
88 print(
' - %s' % key, flush=
True)
89 for i
in range(cont_if.size()):
91 print(
' - Element #%d' % i)
92 print(
' - name: %s' % obj.name())
93 print(
' - decisions: %s' % obj.decisions())
95 print(
' - decorations:')
96 for i_deco, deco_vec
in enumerate(cont_deco):
98 print(
' - %s = %s' % (col_dict[
'decorations'][i_deco].name_key, deco_vec.at(i)))
99 except Exception
as ex:
101 log.warning(
'i: %d', i)
102 log.warning(
'len(deco_vec): %d', len(deco_vec))
103 log.warning(
'i_deco: %d', i_deco)
104 log.warning(
'len(col_dict["decorations"]): %d', len(col_dict[
'decorations']))
108 log.info(
'Opening %s', bsfile)
109 input = eformat.istream(bsfile)
110 offset = args.skip
if args.skip
else 0
111 max_events =
min(args.events, len(input))
if args.events
else len(input)
117 if event_count <= offset:
119 if event_count > offset+max_events:
123 print(
'{sep:s} Event: {:d}, Run: {:d}, LB: {:d}, Global_ID: {:d} {sep:s}'.
format(
130 for rob
in event.children():
131 if rob.source_id().subdetector_id() != eformat.helper.SubDetector.TDAQ_HLT:
133 if args.module>=0
and rob.source_id().module_id() != args.module:
137 print(
'- ROB SourceID: {:s}'.
format(rob.source_id().human()))
140 collections = hltResultMT.get_collections(rob)
147 for p
in os.environ[
'DATAPATH'].split (
':'):
148 fname = os.path.join (p,
'bs-streamerinfos.root')
149 if os.path.exists (fname):
150 ROOT.TFile.Open (fname)
153 log.warning(
'Cannot find bs-streamerinfos.root file in DATAPATH')
157 if '__main__' in __name__: