ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MuJetAnalysis/AnalysisTools/scripts/countSuccessfulEvents.py
Revision: 1.1
Committed: Wed Sep 22 22:45:42 2010 UTC (14 years, 7 months ago) by pivarski
Content type: text/x-python
Branch: MAIN
CVS Tags: JP-2010-10-04-a, JP-2010-09-30-a
Log Message:
AnalysisTools/scripts

File Contents

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