-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathefficiency.py
More file actions
35 lines (30 loc) · 1.15 KB
/
efficiency.py
File metadata and controls
35 lines (30 loc) · 1.15 KB
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
### assumes QCD_Pt-.../res/ folders are in current directory ###
import glob, os, string
folderList = glob.glob('QCD*')
print '------------------------------------------------------------'
print 'directory'
print ' total,', 'passed,', 'efficiency'
print '------------------------------------------------------------'
for folder in folderList:
eventsTotalList = []
eventsPassedList = []
fileList = glob.glob(folder + '/res/*.stdout')
#if fileList != []:
for f in fileList:
fileObj = open(f,'r')
for line in fileObj:
if line.count('TrigReport') != 0 and line.count('out') != 0:
# events total line.split()[4]
# events passed line.split()[7]
# events failed line.split()[10]
eventsTotalList.append(int(line.split()[3]))
eventsPassedList.append(int(line.split()[4]))
sumTotal = sum(eventsTotalList)
sumPassed = sum(eventsPassedList)
if (type(sumTotal) is int) & (sumTotal > 0):
print os.path.basename(folder)
print ' {0}, {1}, {2}'.format(sumTotal, sumPassed, sumPassed/float(sumTotal))
else:
print os.path.basename(folder)
print ' no logs found'
print '------------------------------------------------------------'