forked from UCATLAS/xAODAnaHelpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getEventCounts.py
46 lines (35 loc) · 1.03 KB
/
getEventCounts.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
import optparse
parser = optparse.OptionParser()
parser.add_option('-i', '--input', dest="inFileName", default="", help="Input file name")
o, a = parser.parse_args()
try:
import pyAMI.client
except:
print "Failed to load pyAMI.client, you need to set up local PyAMI"
print "do"
print " > localSetupPyAMI"
import sys
sys.exit(-1)
import pyAMI.atlas.api as AtlasAPI
client = pyAMI.client.Client('atlas')
AtlasAPI.init()
inputDS = []
eventCounts = {}
inputFile = open(o.inFileName,"r")
for line in inputFile:
if line.startswith("#"): continue
words = line.split()
if not len(words): continue
dsName = words[0].rstrip("/")
dsID = dsName.split(".")[1]
print dsName
try:
dsInfo = AtlasAPI.list_datasets(client, patterns = dsName, fields = ['events'])
nEvents = dsInfo[0]['events']
except:
print "Skipping",dsName
continue
inputDS.append(dsName)
eventCounts[dsName] = nEvents
for ds in inputDS:
print ds,"\t",eventCounts[ds]