ATLAS Offline Software
Functions | Variables
python.scripts.check_sg Namespace Reference

Functions

def main (args)
 

Variables

 __doc__
 
 __author__
 
 name
 
 nargs
 
 help
 
 default
 

Function Documentation

◆ main()

def python.scripts.check_sg.main (   args)
read a POOL file and dump the DataHeader's content

ex:
 $ check-sg aod.pool.root
 $ check-sg /castor/foo.pool
 $ check-sg root://castoratlas//castor/foo.pool
 $ check-sg LFN:ttbar.pool

Definition at line 26 of file check_sg.py.

26 def main(args):
27  """read a POOL file and dump the DataHeader's content
28 
29  ex:
30  $ check-sg aod.pool.root
31  $ check-sg /castor/foo.pool
32  $ check-sg root://castoratlas//castor/foo.pool
33  $ check-sg LFN:ttbar.pool
34  """
35  files = args.files
36  if isinstance(files, str):
37  files = [files]
38 
39  from collections import defaultdict
40  from PyUtils.PoolFile import extract_items
41  import os
42  import sys
43 
44  for i,f in enumerate(files):
45  files[i] = os.path.expandvars(os.path.expanduser(f))
46 
47  exitcode = 0
48  for fname in files:
49  try:
50  print ("## checking [%s]..." % (fname,))
51 
52  item_list = defaultdict(list)
53  for name, key in extract_items(fname, verbose=False, items_type='eventdata'):
54  item_list[name].append(key)
55 
56  print ("="*80)
57  print ("%40s%s%-40s" % ("Container type", " | ","StoreGate keys"))
58  print ("%40s%s%-40s" % ("-"*40, "-+-", "-"*(40-3)))
59  for name, sgkeys in sorted(item_list.items()):
60  # decode b-strings to strings
61  sgkeys = [(k.decode("utf-8") if not isinstance(k, str) else k) for k in sgkeys]
62  print ("%40s%s%-40s" % (name, " | ", ', '.join(sorted(sgkeys))))
63  print ("="*80)
64  if args.output:
65  outFileName = args.output
66  outFileName = os.path.expanduser(outFileName)
67  outFileName = os.path.expandvars(outFileName)
68  print ("## saving report into [%s]..." % (outFileName,))
69  if os.path.splitext(outFileName)[1] in ('.pkl', '.dat'):
70  import shelve
71  if os.path.exists(outFileName):
72  os.remove(outFileName)
73  with shelve.open(outFileName) as db:
74  db['eventdata_items'] = item_list
75  else:
76  from pprint import pprint
77  with open( outFileName, 'w' ) as txt:
78  pprint( dict(item_list), txt )
79 
80  except Exception as e:
81  print ("## Caught exception [%s] !!" % str(e.__class__))
82  print ("## What:",e)
83  print (sys.exc_info()[0])
84  print (sys.exc_info()[1])
85  import traceback
86  traceback.print_exc()
87  exitcode = 1
88  pass
89 
90  if len(files) > 1:
91  print ()
92  pass # loop over fileNames
93 
94  print ("## Bye.")
95  return exitcode
96 

Variable Documentation

◆ __author__

python.scripts.check_sg.__author__
private

Definition at line 9 of file check_sg.py.

◆ __doc__

python.scripts.check_sg.__doc__
private

Definition at line 8 of file check_sg.py.

◆ default

python.scripts.check_sg.default

Definition at line 19 of file check_sg.py.

◆ help

python.scripts.check_sg.help

Definition at line 17 of file check_sg.py.

◆ name

python.scripts.check_sg.name

Definition at line 15 of file check_sg.py.

◆ nargs

python.scripts.check_sg.nargs

Definition at line 16 of file check_sg.py.

dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.scripts.check_sg.main
def main(args)
Definition: check_sg.py:26
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
Trk::open
@ open
Definition: BinningType.h:40
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolFile.extract_items
def extract_items(pool_file, verbose=True, items_type='eventdata')
Definition: PoolFile.py:446