1 |
pivarski |
1.2 |
import sys, re, glob
|
2 |
pivarski |
1.1 |
|
3 |
|
|
fileList, crabResDir = sys.argv[1:]
|
4 |
|
|
execfile(fileList)
|
5 |
|
|
|
6 |
|
|
fileNameRE = re.compile("output_([0-9]+)_.*")
|
7 |
pivarski |
1.2 |
fileNameRE2 = re.compile("patified_([0-9]+).root")
|
8 |
pivarski |
1.1 |
lineRE = re.compile("\[E\( ([0-9]+) \)E\]")
|
9 |
|
|
|
10 |
|
|
indexes = {}
|
11 |
|
|
total_number_of_events = 0
|
12 |
|
|
for fileName in source.fileNames:
|
13 |
|
|
m = fileNameRE.search(fileName)
|
14 |
|
|
if m is None:
|
15 |
pivarski |
1.2 |
m = fileNameRE2.search(fileName)
|
16 |
|
|
if m is None:
|
17 |
|
|
raise Exception, "File \"%s\" is not of the right form." % fileName
|
18 |
pivarski |
1.1 |
|
19 |
|
|
index = int(m.group(1))
|
20 |
|
|
if index in indexes:
|
21 |
|
|
raise Exception, "Index %s appears for the second time in \"%s\"." % (m.group(0), fileName)
|
22 |
|
|
|
23 |
|
|
try:
|
24 |
|
|
f = open("%s/CMSSW_%d.stdout" % (crabResDir, index))
|
25 |
|
|
except IOError:
|
26 |
pivarski |
1.2 |
try:
|
27 |
|
|
f = open("%s/Submission_1/CMSSW_%d.stdout" % (crabResDir, index))
|
28 |
|
|
except IOError:
|
29 |
|
|
fname = glob.glob("%s/output_*_%d.stdout" % (crabResDir, index))
|
30 |
|
|
f = open(fname[0])
|
31 |
pivarski |
1.1 |
|
32 |
|
|
eventnumber = None
|
33 |
|
|
for line in f.xreadlines():
|
34 |
|
|
m2 = lineRE.search(line)
|
35 |
|
|
if m2 is not None:
|
36 |
|
|
e = int(m2.group(1))
|
37 |
|
|
if eventnumber is not None and e <= eventnumber:
|
38 |
|
|
raise Exception, "%s/CMSSW_%d.stdout has an out-of-order event (number %d)." % (crabResDir, index, e)
|
39 |
|
|
eventnumber = e
|
40 |
|
|
|
41 |
|
|
total_number_of_events += eventnumber
|
42 |
|
|
print fileName, eventnumber
|
43 |
|
|
|
44 |
|
|
print "======================================================"
|
45 |
|
|
print "Total:", total_number_of_events
|