-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetSkimEfficiency.py
executable file
·77 lines (63 loc) · 2.19 KB
/
getSkimEfficiency.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python
#
import sys,string,math,os,commands
from optparse import OptionParser
GREP="grep"
searchString="skimL1Algos"
logfiles="*.stdout"
def usage():
"""
Get the skim Efficiency from the logfiles created during a crab job.
Program parses the *.stdout files in <logDirectory> to extract the totals
Type -h to get full options
"""
pass
def getCount(input,iele):
xx=string.rstrip(input)
inputLine=xx.split()
return int(inputLine[iele])
if __name__ == '__main__':
narg=len(sys.argv)
if narg < 2 :
print usage.__doc__
sys.exit(1)
usage = "usage: %prog [options] <logDirectory>" + "\n" + usage.__doc__
verbose=False
parser = OptionParser(usage=usage)
parser.add_option("-v","--verbose",
action="store_true",dest="verbose",default=False,
help="be verbose, default=false")
(options, args) = parser.parse_args()
# searchDirectory=sys.argv[1]
searchDirectory=args[0]
verbose=options.verbose
logfiles=os.path.join(searchDirectory,logfiles)
grepArgs=string.join([searchString,logfiles])
grepArgs=string.join([grepArgs," | grep -v TimeReport"])
grepArgs=string.join([grepArgs," | grep -v Modules"])
myargs=string.join([GREP,grepArgs])
print "\n",myargs
xx=commands.getoutput(myargs)
# print xx
TotalSkimEvents=0
TotalEvents=0
skimCounts=xx.split("\n")
if skimCounts[0].find("No such file or directory")>-1:
print "\nTrouble with grep command. Check input directory"
sys.exit(1)
# print "xxx ",len(skimCounts),skimCounts
for Counts in skimCounts:
if (verbose): print Counts
# iele=4 # Number of skimmed events
# iele=3 # Total Number of events
skimmedEvents=getCount(Counts,4)
Events=getCount(Counts,3)
if (verbose):
print skimmedEvents, Events
TotalSkimEvents=TotalSkimEvents+skimmedEvents
TotalEvents=TotalEvents+Events
print "\n"
print "Total number of Skimmed Events: ", TotalSkimEvents
print "Total number of Events Processed: ", TotalEvents
print "\n"
print "Skim Efficiency: ", float(TotalSkimEvents)/TotalEvents