ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MuJetAnalysis/AnalysisTools/scripts/countSuccessfulEvents.py
Revision: 1.3
Committed: Wed Oct 13 01:09:39 2010 UTC (14 years, 6 months ago) by pivarski
Content type: text/x-python
Branch: MAIN
CVS Tags: JP-2010-10-12-a
Changes since 1.2: +2 -1 lines
Log Message:
analyzing new data

File Contents

# Content
1 import sys, re, glob
2
3 fileList, crabResDir = sys.argv[1:]
4 execfile(fileList)
5
6 fileNameRE = re.compile("output_([0-9]+).*root")
7 fileNameRE2 = re.compile("patified_([0-9]+).root")
8 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 m = fileNameRE2.search(fileName)
16 if m is None:
17 raise Exception, "File \"%s\" is not of the right form." % fileName
18
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 # indexes[index] = True
23
24 try:
25 f = open("%s/CMSSW_%d.stdout" % (crabResDir, index))
26 except IOError:
27 try:
28 f = open("%s/Submission_1/CMSSW_%d.stdout" % (crabResDir, index))
29 except IOError:
30 fname = glob.glob("%s/output_*_%d.stdout" % (crabResDir, index))
31 f = open(fname[0])
32
33 eventnumber = None
34 for line in f.xreadlines():
35 m2 = lineRE.search(line)
36 if m2 is not None:
37 e = int(m2.group(1))
38 if eventnumber is not None and e <= eventnumber:
39 raise Exception, "%s/CMSSW_%d.stdout has an out-of-order event (number %d)." % (crabResDir, index, e)
40 eventnumber = e
41
42 total_number_of_events += eventnumber
43 print fileName, eventnumber
44
45 print "======================================================"
46 print "Total:", total_number_of_events