ATLAS Offline Software
Functions | Variables
trigbs_dumpHLTNav Namespace Reference

Functions

def get_parser ()
 
def dump_nav (collections)
 
def dump_info (bsfile, args)
 
def load_streamerinfos ()
 

Variables

 log
 
 args
 

Function Documentation

◆ dump_info()

def trigbs_dumpHLTNav.dump_info (   bsfile,
  args 
)

Definition at line 107 of file trigbs_dumpHLTNav.py.

107 def dump_info(bsfile, args):
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)
112  event_count = 0
113 
114  # Loop over events
115  for event in input:
116  event_count += 1
117  if event_count <= offset:
118  continue
119  if event_count > offset+max_events:
120  break
121 
122  # Print event header info
123  print('{sep:s} Event: {:d}, Run: {:d}, LB: {:d}, Global_ID: {:d} {sep:s}'.format(
124  event_count,
125  event.run_no(),
126  event.lumi_block(),
127  event.global_id(),
128  sep='='*20))
129 
130  for rob in event.children():
131  if rob.source_id().subdetector_id() != eformat.helper.SubDetector.TDAQ_HLT:
132  continue
133  if args.module>=0 and rob.source_id().module_id() != args.module:
134  continue
135 
136  # Print ROB header info
137  print('- ROB SourceID: {:s}'.format(rob.source_id().human()))
138 
139  # Parse the raw data
140  collections = hltResultMT.get_collections(rob)
141  dump_nav(collections)
142 
143 

◆ dump_nav()

def trigbs_dumpHLTNav.dump_nav (   collections)

Definition at line 36 of file trigbs_dumpHLTNav.py.

36 def dump_nav(collections):
37 
38  xaod_map = {}
39 
40  # First step: loop over all collections to match interface + aux + decorations
41  for col in collections:
42  if 'HLTNav_' not in col.name():
43  continue
44 
45  if col.is_xAOD_interface_container():
46  xaod_map[col.name_key] = {
47  'interface': col,
48  'aux_cont': None,
49  'decorations': []
50  }
51  elif col.is_xAOD_aux_container():
52  strip_name = col.name_key[0:-4] # Remove 'Aux.'
53  if strip_name not in xaod_map:
54  log.warning('%s not in xaod_map', strip_name)
55  continue
56  xaod_map[strip_name]['aux_cont'] = col
57  elif col.is_xAOD_decoration():
58  if not col.parent:
59  log.warning('{:s} has no parent', col.name())
60  strip_name = col.parent.name_key[0:-4] # Remove 'Aux.'
61  if strip_name not in xaod_map:
62  log.warning('%s not in xaod_map', strip_name)
63  continue
64  xaod_map[strip_name]['decorations'].append(col)
65 
66  # Second step: loop over the matched collections and decode and print
67  for key, col_dict in xaod_map.items():
68  if not col_dict['interface']:
69  log.warning('%s interface collection missing', key)
70  continue
71  if not col_dict['aux_cont']:
72  log.warning('%s aux_cont collection missing', key)
73  continue
74  cont_if = col_dict['interface'].deserialise()
75  cont_aux = col_dict['aux_cont'].deserialise()
76  cont_deco = [c.deserialise() for c in col_dict['decorations']]
77 
78  if not cont_if:
79  # Don't know why this happens, silence the warning for now
80  # log.warning('%s interface deserialisation failed', key)
81  continue
82  if not cont_aux:
83  log.warning('%s aux_cont deserialisation failed', key)
84  continue
85 
86  cont_if.setStore(cont_aux)
87 
88  print(' - %s' % key, flush=True)
89  for i in range(cont_if.size()):
90  obj = cont_if.at(i)
91  print(' - Element #%d' % i)
92  print(' - name: %s' % obj.name())
93  print(' - decisions: %s' % obj.decisions())
94  if cont_deco:
95  print(' - decorations:')
96  for i_deco, deco_vec in enumerate(cont_deco):
97  try:
98  print(' - %s = %s' % (col_dict['decorations'][i_deco].name_key, deco_vec.at(i)))
99  except Exception as ex:
100  log.warning(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']))
105 
106 

◆ get_parser()

def trigbs_dumpHLTNav.get_parser ( )

Definition at line 18 of file trigbs_dumpHLTNav.py.

18 def get_parser():
19  parser = argparse.ArgumentParser(usage='%(prog)s [options] FILE [FILE]',
20  description=__doc__)
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,
29  help='Skip N events')
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')
33  return parser
34 
35 

◆ load_streamerinfos()

def trigbs_dumpHLTNav.load_streamerinfos ( )

Definition at line 144 of file trigbs_dumpHLTNav.py.

144 def load_streamerinfos():
145  import ROOT
146  import os
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)
151  break
152  else:
153  log.warning('Cannot find bs-streamerinfos.root file in DATAPATH')
154  return
155 
156 

Variable Documentation

◆ args

trigbs_dumpHLTNav.args

Definition at line 158 of file trigbs_dumpHLTNav.py.

◆ log

trigbs_dumpHLTNav.log

Definition at line 15 of file trigbs_dumpHLTNav.py.

vtune_athena.format
format
Definition: vtune_athena.py:14
trigbs_dumpHLTNav.load_streamerinfos
def load_streamerinfos()
Definition: trigbs_dumpHLTNav.py:144
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
trigbs_dumpHLTNav.dump_info
def dump_info(bsfile, args)
Definition: trigbs_dumpHLTNav.py:107
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
RoiUtil::deserialise
void deserialise(const roiserial_type &s, std::vector< const IRoiDescriptor * > &rois)
deserialise uint32_t vector into a full vector of IRoiDescriptors
Definition: RoiSerialise.cxx:62
trigbs_dumpHLTNav.dump_nav
def dump_nav(collections)
Definition: trigbs_dumpHLTNav.py:36
min
#define min(a, b)
Definition: cfImp.cxx:40
trigbs_dumpHLTNav.get_parser
def get_parser()
Definition: trigbs_dumpHLTNav.py:18
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28