def lumiCalcAPI::deliveredLumiForRange | ( | schema, | |
inputRange, | |||
amodetag = 'PROTPHYS' , |
|||
nominalegev = 3500 , |
|||
beamstatus = None , |
|||
withBXInfo = False , |
|||
bxAlgo = 'OCC1' , |
|||
xingMinLum = 1.0e-4 , |
|||
withBeamIntensity = False , |
|||
normname = None , |
|||
datatag = None |
|||
) |
input: inputRange {run:[lsnum]} (required) [lsnum]==None means all ; [lsnum]==[] means selected ls amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] beamstatus: LS filter on beamstatus (optional) beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamInfo: get beam intensity info (optional) normname: norm factor name to use (optional) datatag: data version output: result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,deliveredlumi,calibratedlumierr,(bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} avg lumi unit: 1/ub
Definition at line 126 of file lumiCalcAPI.py.
00127 : 00128 ''' 00129 input: 00130 inputRange {run:[lsnum]} (required) [lsnum]==None means all ; [lsnum]==[] means selected ls 00131 amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] 00132 beamstatus: LS filter on beamstatus (optional) 00133 beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc 00134 withBXInfo: get per bunch info (optional) 00135 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00136 xingMinLum: cut on bx lumi value (optional) 00137 withBeamInfo: get beam intensity info (optional) 00138 normname: norm factor name to use (optional) 00139 datatag: data version 00140 output: 00141 result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,deliveredlumi,calibratedlumierr,(bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} 00142 avg lumi unit: 1/ub 00143 ''' 00144 result = {} 00145 normid=None 00146 if not normname: 00147 normid=dataDML.guessnormIdByContext(schema,amodetag,nominalegev) 00148 if not normid: 00149 raise ValueError('cannot find a normalization factor for the combined condition '+amodetag+' '+nominalegev) 00150 normval=dataDML.luminormById(schema,normid)[2] 00151 perbunchnormval=float(normval)/float(1000) 00152 instresult=instLumiForRange(schema,inputRange,beamstatus,withBXInfo,bxAlgo,withBeamIntensity,datatag) 00153 for run,lslist in inputRange.items(): 00154 result[run]={} 00155 for (lumilsnum,cmslsnum),perlsdata in lsdict.items(): 00156 timestamp=perlsdata[0] 00157 beamstatus=perlsdata[1] 00158 beamenergy=perlsdata[2] 00159 calibratedlumi=perlsdata[3]*normval 00160 calibratedlumierr=perlsdata[4]*normval 00161 numorbit=perlsdata[6] 00162 numbx=3564 00163 lslen=lslengthsec(numorbit,numbx) 00164 deliveredlumi=calibratedlumi*lslen 00165 bxdata=perlsdata[7] 00166 calibratedbxdata=None 00167 if bxdata: 00168 calibratedbxdata=([x*perbunchnormval for x in bxdata[0]],[x*perbunchnormval for x in bxdata[1]]) 00169 intensitydata=perlsdata[8] 00170 result[run][(lumilsnum,cmslsnum)]=[timestamp,beamstatus,beamenergy,deliveredlumi,calibratedlumierr,calibratedbxdata,intensitydata] 00171 return result
def lumiCalcAPI::effectiveLumiForRange | ( | schema, | |
inputRange, | |||
hltpathname = None , |
|||
hltpathpattern = None , |
|||
amodetag = 'PROTPHYS' , |
|||
beamstatus = None , |
|||
beamenergy = None , |
|||
beamenergyFluc = 0.2 , |
|||
withBXInfo = False , |
|||
xingMinLum = 1.0e-4 , |
|||
bxAlgo = 'OCC1' , |
|||
withBeamInfo = False , |
|||
normname = None , |
|||
datatag = None |
|||
) |
input: inputRange {run:[cmsls]} (required) hltpathname: selected hltpathname hltpathpattern: regex select hltpaths amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] beamstatus: LS filter on beamstatus (optional) beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamInfo: get beam intensity info (optional) normname: norm factor name to use (optional) datatag: data version output: result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,{hltpath:[l1name,l1prescale,hltprescale,efflumi]},bxdata,beamdata]}} lumi unit: 1/ub
Definition at line 271 of file lumiCalcAPI.py.
00272 : 00273 ''' 00274 input: 00275 inputRange {run:[cmsls]} (required) 00276 hltpathname: selected hltpathname 00277 hltpathpattern: regex select hltpaths 00278 amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] 00279 beamstatus: LS filter on beamstatus (optional) 00280 beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc 00281 withBXInfo: get per bunch info (optional) 00282 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00283 xingMinLum: cut on bx lumi value (optional) 00284 withBeamInfo: get beam intensity info (optional) 00285 normname: norm factor name to use (optional) 00286 datatag: data version 00287 output: 00288 result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,{hltpath:[l1name,l1prescale,hltprescale,efflumi]},bxdata,beamdata]}} 00289 lumi unit: 1/ub 00290 ''' 00291 result = {} 00292 normid=None 00293 if not normname: 00294 normid=dataDML.guessnormIdByContext(schema,amodetag,nominalegev) 00295 if not normid: 00296 raise ValueError('cannot find a normalization factor for the combined condition '+amodetag+' '+nominalegev) 00297 normval=dataDML.luminormById(schema,normid)[2] 00298 perbunchnormval=float(normval)/float(1000) 00299 c=lumiTime.lumiTime() 00300 for run,lslist in inputRange.items(): 00301 if lslist is not None and len(lslist)==0:#no selected ls, do nothing for this run 00302 result[run]={} 00303 continue 00304 cmsrunsummary=dataDML.runsummary(schema,run) 00305 startTimeStr=cmsrunsummary[6] 00306 lumidataid=None 00307 trgdataid=None 00308 hltdataid=None 00309 (lumidataid,trgdataid,hltdataid)=dataDML.guessDataIdByRun(schema,run) 00310 (lumirunnum,lumidata)=dataDML.lumiLSById(schema,lumidataid,beamstatus,beamenergy,beamenergyFluc,withBXInfo,bxAlgo,withBeamInfo) 00311 (trgrunnum,trgdata)=dataDML.trgLSById(schema,trgdataid,withblobdata=True) 00312 (hltrunnum,hltdata)=dataDML.hltLSById(schema,hltdataid) 00313 trgrundata=dataDML.trgRunById(schema,trgdataid) 00314 hltrundata=dataDML.hltRunById(schema,hltdataid) 00315 bitnames=trgrundata[3].split(',') 00316 hlttrgmap=dataDML.hlttrgMappingByrun(schema,run) 00317 pathnames=hltrundata[3].split(',') 00318 perrunresult={} 00319 for lumilsnum,perlsdata in lumidata.items(): 00320 cmslsnum=perlsdata[0] 00321 if lslist is not None and cmslsnum not in lslist: 00322 continue 00323 instlumi=perlsdata[1] 00324 instlumierror=perlsdata[2] 00325 calibratedlumi=instlumi*normval 00326 calibratedlumierror=instlumierror*normval 00327 beamstatus=perlsdata[4] 00328 beamenergy=perlsdata[5] 00329 numorbit=perlsdata[6] 00330 startorbit=perlsdata[7] 00331 timestamp=c.OrbitToUTCTimestamp(startTimeStr,numorbit) 00332 numbx=3564 00333 lslen=lslengthsec(numorbit,numbx) 00334 deliveredlumi=calibratedlumi*lslen 00335 recordedlumi=0.0 00336 00337 if cmslsnum==0: continue # skip lumils 00338 00339 deadcount=trgdata[cmslsnum][0] ##subject to change !! 00340 bitzerocount=trgdata[cmslsnum][1] 00341 bitzeroprescale=trgdata[cmslsnum][2] 00342 deadfrac=float(deadcount)/(float(bitzerocount)*float(bitzeroprescale)) 00343 if deadfrac>1.0: 00344 deadfrac=0.0 #artificial correction in case of trigger wrong prescale 00345 recordedlumi=deliveredlumi*(1.0-deadfrac) 00346 efflumidict={} 00347 l1prescaleblob=trgdata[cmslsnum][4] 00348 l1prescalearray=CommonUtil.unpackBlobtoArray(l1prescaleblob,'h') 00349 hltprescaleblob=hltdata[cmslsnum][0] 00350 hltprescalearray=CommonUtil.unpackBlobtoArray(hltprescaleblob,'h') 00351 trgprescalemap={} #build trg prescale map {bitname:l1prescale} 00352 for bitnum,bitprescale in enumerate(l1prescalearray): 00353 thisbitname=bitnames[bitnum] 00354 trgprescalemap[thisbitname]=bitprescale 00355 00356 if hltpathname is None and hltpathpattern is None: #get all paths 00357 for hpath,l1seedexpr in hlttrgmap.items(): 00358 hltprescale=None 00359 l1prescale=None 00360 efflumi=None 00361 for pathidx,nm in enumerate(hltpathnames): 00362 if nm==hpath: 00363 hltprescale=hltprescalearray[pathidx] 00364 break 00365 try: 00366 l1bitname=hltTrgSeedMapper.findUniqueSeed(hpath,l1seedexpr) 00367 if l1bitname: 00368 l1prescale=trgprescalemap[l1bitname] 00369 except KeyError: 00370 l1prescale=None 00371 if l1prescale and hltprescale: 00372 efflumi=recordedlumi*l1prescale*hltprescale 00373 efflumidict[hpath]=[l1bitname,l1prescale,hltprescale,efflumi] 00374 elif hltpathname is not None: #get one path 00375 hltprescale=None 00376 l1prescale=None 00377 efflumi=None 00378 for pathidx,nm in enumerate(hltpathnames): 00379 if nm==hltpathname: 00380 hltprescale=hltprescalearray[pathidx] 00381 break 00382 try: 00383 l1bitname=hltTrgSeedMapper.findUniqueSeed(hltpathname,l1seedexpr) 00384 if l1bitname: 00385 l1prescale=trgprescalemap[l1bitname] 00386 except KeyError: 00387 l1prescale=None 00388 if l1prescale and hltprescale: 00389 efflumi=recordedlumi*l1prescale*hltprescale 00390 efflumidict[hpath]=[l1bitname,l1prescale,hltprescale,efflumi] 00391 elif hltpathpattern is not None: #get paths matching pattern 00392 for hpath,l1seexexpr in hlttrgmap.items(): 00393 hltprescale=None 00394 l1prescale=None 00395 efflumi=None 00396 if fnmatch.fnmatch(hpath,hltpathpattern):#use fnmatch rules 00397 for pathidx,nm in enumerate(hltpathnames): 00398 if nm==hpath: 00399 hltprescale=hltprescalearray[pathidx] 00400 break 00401 try: 00402 l1bitname=hltTrgSeedMapper.findUniqueSeed(hpath,l1seedexpr) 00403 if l1bitname: 00404 l1prescale=trgprescalemap[l1bitname] 00405 except KeyError: 00406 l1prescale=None 00407 if l1prescale and hltprescale: 00408 efflumi=recordedlumi*l1prescale*hltprescale 00409 efflumidict[hpath]=[l1bitname,l1prescale,hltprescale,efflumi] 00410 bxdata=None 00411 if withBXInfo: 00412 bxvalueblob=lumidata[8] 00413 bxerrblob=lumidata[9] 00414 bxidxlist=[] 00415 bxvaluelist=[] 00416 bxerrorlist=[] 00417 if bxvalueblob is not None and bxerrblob is not None: 00418 bxvaluearray=CommonUtil.unpackBlobtoArray(bxvalueblob,'f') 00419 bxerrorarray=CommonUtil.unpackBlobtoArray(bxerrblob,'f') 00420 for idx,bxval in enumerate(bxvaluearray): 00421 if bxval*perbunchnormval>xingMinLum: 00422 bxidxlist.append(idx) 00423 bxvaluelist.append(bxval*perbunchnormval) 00424 bxerrorlist.append(bxerrorarray[idx]*perbunchnormval) 00425 bxdata=(bxidxlist,bxvaluelist,bxerrorlist) 00426 beamdata=None 00427 if withBeamInfo: 00428 bxindexblob=lumidata[10] 00429 beam1intensityblob=lumidata[11] 00430 beam2intensityblob=lumidata[12] 00431 bxindexlist=[] 00432 b1intensitylist=[] 00433 b2intensitylist=[] 00434 if bxindexblob is not None and beam1intensity is not None and beam2intensity is not None: 00435 bxindexlist=CommonUtil.unpackBlobtoArray(bxindexblob,'h').tolist() 00436 beam1intensitylist=CommonUtil.unpackBlobtoArray(beam1intensityblob,'f').tolist() 00437 beam2intensitylist=CommonUtil.unpackBlobtoArray(beam2intensityblob,'f').tolist() 00438 beamdata=(bxindexlist,b1intensitylist,b2intensitylist) 00439 perrunresult[(lumilsnum,cmslsnum)]=[timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,efflumidict,bxdata,beamdata] 00440 lumidata.clear() #clean lumi memory 00441 trgdata.clear() 00442 hltdata.clear() 00443 result[run]=perrunresult return result
def lumiCalcAPI::hltForRange | ( | schema, | |
inputRange, | |||
hltpathname = None , |
|||
hltpathpattern = None , |
|||
datatag = None |
|||
) |
input: inputRange: {run:[cmsls]} (required) hltpathname: exact match hltpathname (optional) hltpathpattern: regex match hltpathpattern (optional) datatag : data version output: {runnumber:{hltpath:[[cmslsnum,l1pass,hltaccept,hltprescale]]})}
Definition at line 41 of file lumiCalcAPI.py.
00042 : 00043 ''' 00044 input: 00045 inputRange: {run:[cmsls]} (required) 00046 hltpathname: exact match hltpathname (optional) 00047 hltpathpattern: regex match hltpathpattern (optional) 00048 datatag : data version 00049 output: {runnumber:{hltpath:[[cmslsnum,l1pass,hltaccept,hltprescale]]})} 00050 ''' 00051 pass
def lumiCalcAPI::hltpathsForRange | ( | schema, | |
runlist | |||
) |
input: runlist [run], (required) datatag: data version (optional) output : {runnumber,{hltpath:(l1bitname,l1seedexpr)}}
Definition at line 17 of file lumiCalcAPI.py.
00018 : 00019 ''' 00020 input: runlist [run], (required) 00021 datatag: data version (optional) 00022 output : {runnumber,{hltpath:(l1bitname,l1seedexpr)}} 00023 ''' 00024 result={} 00025 if isinstance(inputRange,list): 00026 for run in runlist: 00027 extendedmap={} 00028 hlttrgmap=dataDML.hlttrgMappingByrun(run) 00029 for hltpath,l1seedexpr in hlttrgmap.items(): 00030 l1bitname=hltTrgSeedMapper(hltpath,l1seedexpr) 00031 extendedmap[hltpath]=(l1bitname,l1seedexpr) 00032 result[run]=extendedmap return result
def lumiCalcAPI::instCalibratedLumiForRange | ( | schema, | |
inputRange, | |||
amodetag = 'PROTPHYS' , |
|||
nominalegev = 3500 , |
|||
beamstatus = None , |
|||
withBXInfo = False , |
|||
bxAlgo = 'OCC1' , |
|||
xingMinLum = 1.0e-4 , |
|||
withBeamInfo = False , |
|||
normname = None , |
|||
datatag = None |
|||
) |
Inst luminosity after calibration input: inputRange {run:[cmsls]} (required) amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] beamstatus: LS filter on beamstatus (optional) beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamInfo: get beam intensity info (optional) normname: norm factor name to use (optional) datatag: data version output: result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,calibratedlumi,calibratedlumierr,startorbit,numorbit,(bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} lumi unit: HZ/ub
Definition at line 81 of file lumiCalcAPI.py.
00082 : 00083 ''' 00084 Inst luminosity after calibration 00085 input: 00086 inputRange {run:[cmsls]} (required) 00087 amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] 00088 beamstatus: LS filter on beamstatus (optional) 00089 beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc 00090 withBXInfo: get per bunch info (optional) 00091 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00092 xingMinLum: cut on bx lumi value (optional) 00093 withBeamInfo: get beam intensity info (optional) 00094 normname: norm factor name to use (optional) 00095 datatag: data version 00096 output: 00097 result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,calibratedlumi,calibratedlumierr,startorbit,numorbit,(bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} 00098 lumi unit: HZ/ub 00099 ''' 00100 result = {} 00101 normid=None 00102 if not normname: 00103 normid=dataDML.guessnormIdByContext(schema,amodetag,nominalegev) 00104 if not normid: 00105 raise ValueError('cannot find a normalization factor for the combined condition '+amodetag+' '+nominalegev) 00106 normval=dataDML.luminormById(schema,normid)[2] 00107 perbunchnormval=float(normval)/float(1000) 00108 instresult=instLumiForRange(schema,inputRange,beamstatus,withBXInfo,bxAlgo,withBeamIntensity,datatag) 00109 for run,lsdict in instresult.items(): 00110 result[run]={} 00111 for (lumilsnum,cmslsnum),perlsdata in lsdict.items(): 00112 timestamp=perlsdata[0] 00113 beamstatus=perlsdata[1] 00114 beamenergy=perlsdata[2] 00115 calibratedlumi=perlsdata[3]*normval 00116 calibratedlumierr=perlsdata[4]*normval 00117 startorbit=perlsdata[5] 00118 numorbit=perlsdata[6] 00119 bxdata=perlsdata[7] 00120 calibfatedbxdata=None 00121 if bxdata: 00122 calibratedbxdata=([x*perbunchnormval for x in bxdata[0]],[x*perbunchnormval for x in bxdata[1]]) 00123 intensitydata=perlsdata[8] 00124 result[run][(lumilsnum,cmslsnum)]=[timestamp,beamstatus,beamenergy,calibratedlumi,calibratedlumierr,startorbit,numorbit,calibfatedbxdata,intensitydata] 00125 return result
def lumiCalcAPI::instLumiForRange | ( | schema, | |
inputRange, | |||
beamstatus = None , |
|||
withBXInfo = False , |
|||
bxAlgo = 'OCC1' , |
|||
xingMinLum = 1.0e-4 , |
|||
withBeamIntensity = False , |
|||
datatag = None |
|||
) |
input: inputRange {run:[cmsls]} (required) beamstatus: LS filter on beamstatus (optional) beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamInfo: get beam intensity info (optional) datatag: data version output: result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,instlumi,instlumierr,startorbit,numorbit,(bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} lumi unit: HZ/ub
Definition at line 64 of file lumiCalcAPI.py.
00065 : 00066 ''' 00067 input: 00068 inputRange {run:[cmsls]} (required) 00069 beamstatus: LS filter on beamstatus (optional) 00070 beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc 00071 withBXInfo: get per bunch info (optional) 00072 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00073 xingMinLum: cut on bx lumi value (optional) 00074 withBeamInfo: get beam intensity info (optional) 00075 datatag: data version 00076 output: 00077 result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,instlumi,instlumierr,startorbit,numorbit,(bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} 00078 lumi unit: HZ/ub 00079 ''' 00080 pass
def lumiCalcAPI::lslengthsec | ( | numorbit, | |
numbx | |||
) |
input: numorbit : number of orbit in the lumi section numbx : number of orbits output: lumi section length in sec
Definition at line 7 of file lumiCalcAPI.py.
def lumiCalcAPI::lumiForRange | ( | schema, | |
inputRange, | |||
amodetag = 'PROTPHYS' , |
|||
beamstatus = None , |
|||
beamenergy = None , |
|||
beamenergyFluc = 0.2 , |
|||
withBXInfo = False , |
|||
bxAlgo = 'OCC1' , |
|||
xingMinLum = 1.0e-4 , |
|||
withBeamInfo = False , |
|||
normname = None , |
|||
datatag = None |
|||
) |
input: inputRange {run:[cmsls]} (required) amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] beamstatus: LS filter on beamstatus (optional) beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamInfo: get beam intensity info (optional) normname: norm factor name to use (optional) datatag: data version output: result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,((bxidx,bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} lumi unit: 1/ub
Definition at line 172 of file lumiCalcAPI.py.
00173 : 00174 ''' 00175 input: 00176 inputRange {run:[cmsls]} (required) 00177 amodetag : accelerator mode for all the runs (optional) ['PROTPHYS','HIPHYS'] 00178 beamstatus: LS filter on beamstatus (optional) 00179 beamenergy: LS filter on beamenergy (optional) beamenergy+-beamenergyFluc 00180 withBXInfo: get per bunch info (optional) 00181 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00182 xingMinLum: cut on bx lumi value (optional) 00183 withBeamInfo: get beam intensity info (optional) 00184 normname: norm factor name to use (optional) 00185 datatag: data version 00186 output: 00187 result {run:{(lumilsnum,cmslsnum):[timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,((bxidx,bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}} 00188 lumi unit: 1/ub 00189 ''' 00190 result = {} 00191 normid=None 00192 if not normname: 00193 normid=dataDML.guessnormIdByContext(schema,amodetag,nominalegev) 00194 if not normid: 00195 raise ValueError('cannot find a normalization factor for the combined condition '+amodetag+' '+nominalegev) 00196 normval=dataDML.luminormById(schema,normid)[2] 00197 perbunchnormval=float(normval)/float(1000) 00198 c=lumiTime.lumiTime() 00199 for run,lslist in inputRange.items(): 00200 if lslist is not None and len(lslist)==0:#no selected ls, do nothing for this run 00201 result[run]={} 00202 continue 00203 cmsrunsummary=dataDML.runsummary(schema,run) 00204 startTimeStr=cmsrunsummary[6] 00205 lumidataid=None 00206 trgdataid=None 00207 hltdataid=None 00208 (lumidataid,trgdataid,hltdataid)=dataDML.guessDataIdByRun(schema,run) 00209 (lumirunnum,lumidata)=dataDML.lumiLSById(schema,lumidataid,beamstatus,beamenergy,beamenergyFluc,withBXInfo,bxAlgo,withBeamInfo) 00210 (trgrunnum,trgdata)=dataDML.trgLSById(schema,trgdataid,withblobdata=False) 00211 perrunresult={} 00212 for lumilsnum,perlsdata in lumidata.items(): 00213 cmslsnum=perlsdata[0] 00214 if lslist is not None and cmslsnum not in lslist: 00215 continue 00216 instlumi=perlsdata[1] 00217 instlumierror=perlsdata[2] 00218 calibratedlumi=instlumi*normval 00219 calibratedlumierror=instlumierror*normval 00220 beamstatus=perlsdata[4] 00221 beamenergy=perlsdata[5] 00222 numorbit=perlsdata[6] 00223 startorbit=perlsdata[7] 00224 timestamp=c.OrbitToUTCTimestamp(startTimeStr,numorbit,startorbit+numorbit,0) 00225 numbx=3564 00226 lslen=lslengthsec(numorbit,numbx) 00227 deliveredlumi=calibratedlumi*lslen 00228 recordedlumi=0.0 00229 if cmslsnum!=0: 00230 deadcount=trgdata[cmslsnum][0] ##subject to change !! 00231 bitzerocount=trgdata[cmslsnum][1] 00232 bitzeroprescale=trgdata[cmslsnum][2] 00233 deadfrac=float(deadcount)/(float(bitzerocount)*float(bitzeroprescale)) 00234 if deadfrac>1.0: 00235 deadfrac=0.0 #artificial correction in case of trigger wrong prescale 00236 recordedlumi=deliveredlumi*(1.0-deadfrac) 00237 bxdata=None 00238 if withBXInfo: 00239 bxvalueblob=lumidata[8] 00240 bxerrblob=lumidata[9] 00241 bxidxlist=[] 00242 bxvaluelist=[] 00243 bxerrorlist=[] 00244 if bxvalueblob is not None and bxerrblob is not None: 00245 bxvaluearray=CommonUtil.unpackBlobtoArray(bxvalueblob,'f') 00246 bxerrorarray=CommonUtil.unpackBlobtoArray(bxerrblob,'f') 00247 for idx,bxval in enumerate(bxvaluearray): 00248 if bxval*perbunchnormval>xingMinLum: 00249 bxidxlist.append(idx) 00250 bxvaluelist.append(bxval*perbunchnormval) 00251 bxerrorlist.append(bxerrorarray[idx]*perbunchnormval) 00252 bxdata=(bxidxlist,bxvaluelist,bxerrorlist) 00253 beamdata=None 00254 if withBeamInfo: 00255 bxindexblob=lumidata[10] 00256 beam1intensityblob=lumidata[11] 00257 beam2intensityblob=lumidata[12] 00258 bxindexlist=[] 00259 b1intensitylist=[] 00260 b2intensitylist=[] 00261 if bxindexblob is not None and beam1intensity is not None and beam2intensity is not None: 00262 bxindexlist=CommonUtil.unpackBlobtoArray(bxindexblob,'h').tolist() 00263 beam1intensitylist=CommonUtil.unpackBlobtoArray(beam1intensityblob,'f').tolist() 00264 beam2intensitylist=CommonUtil.unpackBlobtoArray(beam2intensityblob,'f').tolist() 00265 beamdata=(bxindexlist,b1intensitylist,b2intensitylist) 00266 perrunresult[(lumilsnum,cmslsnum)]=[timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,bxdata,beamdata] 00267 lumidata.clear() #clean lumi memory 00268 trgdata.clear() 00269 result[run]=perrunresult 00270 return result
def lumiCalcAPI::runList | ( | schema, | |
fillnum = None , |
|||
runmin = None , |
|||
runmax = None , |
|||
startT = None , |
|||
stopT = None , |
|||
l1keyPattern = None , |
|||
hltkeyPattern = None , |
|||
amodetag = None , |
|||
nominalEnergy = None , |
|||
energyFlut = 0.2 , |
|||
requiretrg = True , |
|||
requirehlt = True |
|||
) |
Definition at line 4 of file lumiCalcAPI.py.
def lumiCalcAPI::trgbitsForRange | ( | schema, | |
runlist, | |||
datatag = None |
|||
) |
input: runlist [run],(required) datatag: data version (optional) output: {runnumber:bitzeroname,[bitnames]}
Definition at line 33 of file lumiCalcAPI.py.
def lumiCalcAPI::trgForRange | ( | schema, | |
inputRange, | |||
trgbitname = None , |
|||
trgbitnamepattern = None , |
|||
datatag = None |
|||
) |
input : inputRange {run:[cmsls]} (required) trgbitname exact match trgbitname (optional) trgbitnamepattern regex match trgbitname (optional) datatag : data version output result {run,{cmslsnum:[deadtimecount,bitzero_count,bitzero_prescale,deadfraction,{bitname:[prescale,counts]}]}}
Definition at line 52 of file lumiCalcAPI.py.
00053 : 00054 ''' 00055 input : 00056 inputRange {run:[cmsls]} (required) 00057 trgbitname exact match trgbitname (optional) 00058 trgbitnamepattern regex match trgbitname (optional) 00059 datatag : data version 00060 output 00061 result {run,{cmslsnum:[deadtimecount,bitzero_count,bitzero_prescale,deadfraction,{bitname:[prescale,counts]}]}} 00062 ''' 00063 pass