Go to the documentation of this file.00001
00002 import json
00003 class pileupParser(object):
00004 def __init__(self,selectStr):
00005 self.__result={}
00006 self.__strresult={}
00007 strresult=json.loads(selectStr)
00008 for k,v in strresult.items():
00009
00010
00011 ldict={}
00012 for elems in v:
00013 llist = [ elems[1],elems[2],elems[3] ]
00014 ldict[int(elems[0])] = llist
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 self.__result[int(k)]=ldict
00032
00033 def runs(self):
00034 return self.__result.keys()
00035 def runsandls(self):
00036 '''return expanded {run:lslist}
00037 '''
00038 return self.__result
00039 def runsandlsStr(self):
00040 '''return expanded {'run':lslist}
00041 '''
00042 return self.__strresult
00043 def numruns(self):
00044 return len(self.__result.keys())
00045 def numls(self,run):
00046 return len(self.__result[run])
00047 if __name__ == "__main__":
00048
00049 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]]}')
00050
00051 print 'runs : ',s.runs()
00052 print 'full result : ',s.runsandls()
00053
00054
00055