test
Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
RecoLuminosity
LumiDB
python
pileupParser.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
import
json
3
class
pileupParser
(object):
4
def
__init__
(self,selectStr):
5
self.
__result
={}
6
self.
__strresult
={}
7
strresult=json.loads(selectStr)
8
for
k,v
in
strresult.items():
9
# expandedvalues=[]
10
# print v
11
ldict={}
12
for
elems
in
v:
13
llist = [ elems[1],elems[2],elems[3] ]
14
ldict[int(elems[0])] = llist
15
16
17
# for w in v:
18
# if len(w)==0:
19
# self.__result[int(k)]=expandedvalues
20
# self.__strresult[k]=[]
21
# continue
22
###weed out [10]-like stuff just in case they exist
23
# elif len(w)==1:
24
# expandedvalues.append(w[0])
25
##weed out [10,10]-like stuff
26
# elif len(w)==2 and w[0]==w[1]:
27
# expandedvalues.append(w[0])
28
# else:
29
# for i in range(w[0],w[1]+1):
30
# expandedvalues.append(i)
31
self.
__result
[int(k)]=ldict
32
# self.__strresult[k]=[str(x) for x in expandedvalues]
33
def
runs
(self):
34
return
self.__result.keys()
35
def
runsandls
(self):
36
'''return expanded {run:lslist}
37
'''
38
return
self.
__result
39
def
runsandlsStr
(self):
40
'''return expanded {'run':lslist}
41
'''
42
return
self.
__strresult
43
def
numruns
(self):
44
return
len(self.__result.keys())
45
def
numls
(self,run):
46
return
len(self.
__result
[run])
47
if
__name__ ==
"__main__"
:
48
# s=pileupParser('{"1":[[3,45]],"2":[[4,8],[10,10]],"3":[[]]}')
49
s=
pileupParser
(
'{"179434": [[21,38.140,7.2,2.220e-04],[22,49.032,7.2,2.218e-04]],"179435": [[21,38.140,7.2,2.220e-04],[22,49.032,7.2,2.218e-04]]}'
)
50
51
print
'runs : '
,s.runs()
52
print
'full result : '
,s.runsandls()
53
# print 'str result : ',s.runsandlsStr()
54
# print 'num runs : ',s.numruns()
55
# print 'numls in run : ',s.numls(1)
pileupParser.pileupParser.__strresult
__strresult
Definition:
pileupParser.py:6
pileupParser.pileupParser.runsandls
def runsandls
Definition:
pileupParser.py:35
pileupParser.pileupParser.numruns
def numruns
Definition:
pileupParser.py:43
pileupParser.pileupParser.numls
def numls
Definition:
pileupParser.py:45
pileupParser.pileupParser.__init__
def __init__
Definition:
pileupParser.py:4
pileupParser.pileupParser
Definition:
pileupParser.py:3
pileupParser.pileupParser.runs
def runs
Definition:
pileupParser.py:33
pileupParser.pileupParser.__result
__result
Definition:
pileupParser.py:5
pileupParser.pileupParser.runsandlsStr
def runsandlsStr
Definition:
pileupParser.py:39
Generated for CMSSW Reference Manual by
1.8.5