Main Page
Namespaces
Classes
Package Documentation
RecoLuminosity
LumiDB
python
selectionParser.py
Go to the documentation of this file.
1
import
json
2
class
selectionParser
(
object
):
3
def
__init__
(self,selectStr):
4
self.
__result
={}
5
self.
__strresult
={}
6
strresult=json.loads(selectStr)
7
for
k,v
in
strresult.items():
8
expandedvalues=[]
9
for
w
in
v:
10
if
len(w)==0:
11
self.
__result
[
int
(k)]=expandedvalues
12
self.
__strresult
[k]=[]
13
continue
14
###weed out [10]-like stuff just in case they exist
15
elif
len(w)==1:
16
expandedvalues.append(w[0])
17
##weed out [10,10]-like stuff
18
elif
len(w)==2
and
w[0]==w[1]:
19
expandedvalues.append(w[0])
20
else
:
21
for
i
in
range(w[0],w[1]+1):
22
expandedvalues.append(i)
23
self.
__result
[
int
(k)]=expandedvalues
24
self.
__strresult
[k]=[
str
(x)
for
x
in
expandedvalues]
25
def
runs
(self):
26
return
self.__result.keys()
27
def
runsandls
(self):
28
'''return expanded {run:lslist}
29
'''
30
return
self.
__result
31
def
runsandlsStr
(self):
32
'''return expanded {'run':lslist}
33
'''
34
return
self.
__strresult
35
def
numruns
(self):
36
return
len(self.__result.keys())
37
def
numls
(self,run):
38
return
len(self.
__result
[run])
39
if
__name__ ==
"__main__"
:
40
s=
selectionParser
(
'{"1":[[3,45]],"2":[[4,8],[10,10]],"3":[[]]}'
)
41
print
'runs : '
,s.runs()
42
print
'full result : '
,s.runsandls()
43
print
'str result : '
,s.runsandlsStr()
44
print
'num runs : '
,s.numruns()
45
print
'numls in run : '
,s.numls(1)
selectionParser.selectionParser.__strresult
__strresult
Definition:
selectionParser.py:5
selectionParser.selectionParser.runsandls
def runsandls(self)
Definition:
selectionParser.py:27
selectionParser.selectionParser.__result
__result
Definition:
selectionParser.py:4
createfilelist.int
int
Definition:
createfilelist.py:10
selectionParser.selectionParser.runs
def runs(self)
Definition:
selectionParser.py:25
selectionParser.selectionParser.runsandlsStr
def runsandlsStr(self)
Definition:
selectionParser.py:31
selectionParser.selectionParser.numruns
def numruns(self)
Definition:
selectionParser.py:35
selectionParser.selectionParser.numls
def numls(self, run)
Definition:
selectionParser.py:37
harvestTrackValidationPlots.str
str
Definition:
harvestTrackValidationPlots.py:10
resolutioncreator_cfi.object
object
Definition:
resolutioncreator_cfi.py:4
selectionParser.selectionParser.__init__
def __init__(self, selectStr)
Definition:
selectionParser.py:3
selectionParser.selectionParser
Definition:
selectionParser.py:2
Generated for CMSSW Reference Manual by
1.8.11