ATLAS Offline Software
checkFileSG.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # @file: checkFileSG.py
4 # @purpose: answers queries on a SGAudSvc produced file
5 # @author: Ilija Vukotic <ivukotic@cern.ch>
6 # @date: October 2007
7 #
8 # @example:
9 #
10 # checkFileSG SGAudSvc.out
11 
12 __version__ = "$Revision: 1.1 $"
13 __author__ = "Ilija Vukotic <ivukotic@cern.ch>"
14 
15 import sys
16 import os
17 import shutil
18 import glob
19 
20 lRemove = ['_Data','_Link','noKey','HLTAuto','CBNT_']
21 
22 def toSkip(inpName):
23  for comp in lRemove:
24  if inpName.count(comp)>0:
25  return True
26  return False
27 
28 def toRemove(inpVal):
29  result=False
30  if isNumb(inpVal)==True:
31  print "remove ", inpVal, "is a number"
32  result=True
33  for thing in lRemove:
34  if inpVal.count(thing)>0:
35  print "remove ", inpVal ,"since it contains", thing
36  result=True
37  return result
38 
39 def findMatches(iAlg, iObj, F, Fa, Fo):
40  n=0
41  print "---- algos -----"
42  for alg in iAlg: #----------------> find matching algos
43  if alg.count(F)>0 and not toSkip(alg):
44  Fa.append(alg)
45  print alg
46  n+=1
47  print '---- objects ----'
48  for obj in iObj: #---------------> find matching objects
49  if obj.count(F)>0 and not toSkip(obj):
50  Fobj.append(obj)
51  print obj
52  n+=1
53  print '-----------------'
54  return n
55 
56 nArgs= len (sys.argv)
57 inFN=''
58 if nArgs==1:
59  print "Usage: checkFileSG.py input_filename "
60  sys.exit()
61 if nArgs>1:
62  print "Input file: ",sys.argv[1]
63  inFN=sys.argv[1]
64 try:
65  fi = open (inFN)
66 except:
67  print "No such file!"
68  sys.exit()
69 
70 
71 lines = fi.readlines()
72 fi.close()
73 
74 #===================================================================
75 line=lines.pop(0)
76 words=line.split(' ')
77 nAlgs=int(words[1])
78 print '%(a)d algorithms found'%{'a':nAlgs}
79 
80 algs=[]
81 for i in range(nAlgs): # -------------------> reading alg names
82  line=lines.pop(0).strip('\n')
83  line=line.replace('/','_')
84  algs.append(line)
85 
86 #print algs
87 
88 line=lines.pop(0)
89 words=line.split(' ')
90 nObjs=int(words[1])
91 print '%(a)d objects found'%{'a':nObjs}
92 
93 objs=[]
94 for i in range(nObjs): # ----------------> reading object names
95  line=lines.pop(0).strip('\n')
96  line=line.replace('/','_')
97  line=line.replace('<','LT')
98  line=line.replace('>','GT')
99  objs.append(line)
100 #==================================================================
101 
102 
103 Falg=[]; Fobj=[]
104 LF=raw_input('Please enter algorithm or SG object name: ')
105 
106 
107 while (findMatches(algs, objs, LF, Falg, Fobj)!=1): #----------> getting single input
108  LF=raw_input('Please enter algorithm or SG object name. To exit type \'x\' : ')
109  if LF=='x':
110  sys.exit(0)
111  Falg=[];Fobj=[]
112 
113 
114 
115 print 'Calculating calls for:',LF,' '
116 if len(Falg)>0:
117  #print 'algorithms', Falg
118  ind=algs.index(Falg[0])+1
119  for i in range(ind):
120  line=lines.pop(0)
121  #print line
122  words=line.strip('\n').split('\t')
123  for obj in objs:
124  rw=words.pop(0).split(':')
125  #print rw
126  reads=int(rw[0])
127  writes=int(rw[1])
128  if (reads+writes)>0:
129  print 'Object:',obj, "has been accessed",reads,"times and written",writes,"times."
130 
131 else:
132  #print 'objects',Fobj
133  ind=objs.index(Fobj[0])
134  for i in range(len(algs)):
135  line=lines.pop(0)
136  words=line.strip('\n').split('\t')
137  rw=words[ind].split(':')
138  reads=int(rw[0])
139  writes=int(rw[1])
140  if (reads+writes)>0:
141  print 'Algorithm',algs[i],'accessed object',reads,'times and wrote it',writes,'times'
142 
143 sys.exit(0)
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
checkFileSG.toSkip
def toSkip(inpName)
Definition: checkFileSG.py:22
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
SGout2dot.isNumb
def isNumb(inpVal)
Definition: SGout2dot.py:48
checkFileSG.toRemove
def toRemove(inpVal)
Definition: checkFileSG.py:28
checkFileSG.findMatches
def findMatches(iAlg, iObj, F, Fa, Fo)
Definition: checkFileSG.py:39
Trk::split
@ split
Definition: LayerMaterialProperties.h:38