Functions | |
def | beamForIds |
def | beamForRange |
def | deliveredLumiForIds |
def | effectiveLumiForIds |
def | fillInRange |
def | fillrunMap |
def | hltForIds |
def | hltpathsForRange |
def | instLumiForIds |
def | lumiForIds |
def | runList |
def | runsummary |
Lumi data management and calculation API # # Author: Zhen Xie #. | |
def | runsummaryMap |
def | trgForIds |
def lumiCalcAPI::beamForIds | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
withBeamIntensity = False , |
|||
minIntensity = 0.1 |
|||
) |
input: inputRange: {run:[cmsls]} (required) dataidmap: {run:(lumiid,trgid,hltid)} output : {runnumber:[(lumicmslnum(0),cmslsnum(1),beamenergy(2),beamstatus(3),ncollidingbx(4),[(ibx,b1,b2)])...](5)}
Definition at line 115 of file lumiCalcAPI.py.
00116 : 00117 ''' 00118 input: 00119 inputRange: {run:[cmsls]} (required) 00120 dataidmap: {run:(lumiid,trgid,hltid)} 00121 output : {runnumber:[(lumicmslnum(0),cmslsnum(1),beamenergy(2),beamstatus(3),ncollidingbx(4),[(ibx,b1,b2)])...](5)} 00122 ''' 00123 result={} 00124 for run in irunlsdict.keys(): 00125 result[run]=[] 00126 lslist=irunlsdict[run] 00127 if lslist is not None and len(lslist)==0: 00128 continue 00129 if not dataidmap.has_key(run): 00130 continue #run non exist 00131 lumidataid=dataidmap[run][0] 00132 if lumidataid is None: 00133 result[run]=None 00134 continue 00135 lumidata=dataDML.beamInfoById(schema,lumidataid,withBeamIntensity=withBeamIntensity,minIntensity=minIntensity) 00136 #(runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..]) 00137 if lumidata and lumidata[1]: 00138 perrundata=lumidata[1] 00139 for perlsdata in perrundata: 00140 lumilsnum=perlsdata[0] 00141 cmslsnum=perlsdata[1] 00142 if lslist is not None and cmslsnum not in lslist: 00143 continue 00144 beamstatus=perlsdata[2] 00145 beamenergy=perlsdata[3] 00146 ncollidingbunches=perlsdata[4] 00147 beamintInfolist=[] 00148 if withBeamIntensity: 00149 beamintInfolist=perlsdata[5] 00150 result[run].append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beamintInfolist)) 00151 return result
def lumiCalcAPI::beamForRange | ( | schema, | |
inputRange, | |||
withBeamIntensity = False , |
|||
minIntensity = 0.1 , |
|||
tableName = None , |
|||
branchName = None |
|||
) |
input: inputRange: {run:[cmsls]} (required) output : {runnumber:[(lumicmslnum,cmslsnum,beamenergy,beamstatus,[(ibx,b1,b2)])...](4)}
Definition at line 75 of file lumiCalcAPI.py.
00076 : 00077 ''' 00078 input: 00079 inputRange: {run:[cmsls]} (required) 00080 output : {runnumber:[(lumicmslnum,cmslsnum,beamenergy,beamstatus,[(ibx,b1,b2)])...](4)} 00081 ''' 00082 if tableName is None: 00083 tableName=nameDealer.lumidataTableName() 00084 if branchName is None: 00085 branchName='DATA' 00086 result={} 00087 for run in inputRange.keys(): 00088 lslist=inputRange[run] 00089 if lslist is not None and len(lslist)==0: 00090 result[run]=[]#if no LS is selected for a run 00091 continue 00092 lumidataid=dataDML.guessLumiDataIdByRun(schema,run,tableName) 00093 if lumidataid is None: 00094 result[run]=None 00095 continue #run non exist 00096 lumidata=dataDML.beamInfoById(schema,lumidataid,withBeamIntensity=withBeamIntensity,minIntensity=minIntensity) 00097 #(runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),beaminfolist(4)),..]) 00098 result[run]=[] 00099 perrundata=lumidata[1] 00100 if not perrundata: 00101 result[run]=[] 00102 continue 00103 for perlsdata in perrundata: 00104 lumilsnum=perlsdata[0] 00105 cmslsnum=perlsdata[1] 00106 if lslist is not None and cmslsnum not in lslist: 00107 continue 00108 beamstatus=perlsdata[2] 00109 beamenergy=perlsdata[3] 00110 beamintInfolist=[] 00111 if withBeamIntensity: 00112 beamintInfolist=perlsdata[4] 00113 result[run].append((lumilsnum,cmslsnum,beamstatus,beamenergy,beamintInfolist)) 00114 return result
def lumiCalcAPI::deliveredLumiForIds | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
runsummaryMap, | |||
beamstatusfilter = None , |
|||
timeFilter = None , |
|||
normmap = None , |
|||
withBXInfo = False , |
|||
bxAlgo = None , |
|||
xingMinLum = None , |
|||
withBeamIntensity = False , |
|||
lumitype = 'HF' , |
|||
minbiasXsec = None |
|||
) |
delivered lumi (including calibration,time integral) input: irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls dataidmap : {run:(lumiid,trgid,hltid)} runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} beamstatus: LS filter on beamstatus normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamIntensity: get beam intensity info (optional) lumitype: luminosity source output: result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierr(6),(bxidxlist,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum(9),pu(10)]} special meanings: {run:None} None means no run in lumiDB, {run:[]} [] means no lumi for this run in lumiDB {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected lumi unit: /ub
Definition at line 369 of file lumiCalcAPI.py.
00370 : 00371 ''' 00372 delivered lumi (including calibration,time integral) 00373 input: 00374 irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls 00375 dataidmap : {run:(lumiid,trgid,hltid)} 00376 runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} 00377 beamstatus: LS filter on beamstatus 00378 normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction 00379 withBXInfo: get per bunch info (optional) 00380 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00381 xingMinLum: cut on bx lumi value (optional) 00382 withBeamIntensity: get beam intensity info (optional) 00383 lumitype: luminosity source 00384 output: 00385 result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierr(6),(bxidxlist,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum(9),pu(10)]} 00386 00387 special meanings: 00388 {run:None} None means no run in lumiDB, 00389 {run:[]} [] means no lumi for this run in lumiDB 00390 {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected 00391 lumi unit: /ub 00392 ''' 00393 result = {} 00394 lumip=lumiParameters.ParametersObject() 00395 lumirundata=dataDML.lumiRunByIds(schema,dataidmap,lumitype=lumitype) 00396 instresult=instLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=beamstatusfilter,timeFilter=timeFilter,withBXInfo=withBXInfo,bxAlgo=bxAlgo,withBeamIntensity=withBeamIntensity,lumitype=lumitype) 00397 00398 intglumimap={} 00399 if lumitype=='HF': 00400 intglumimap=dataDML.intglumiForRange(schema,irunlsdict.keys())#some runs need drift correction 00401 allsince=[] 00402 if normmap: 00403 allsince=normmap.keys() 00404 allsince.sort() 00405 correctorname='fPoly' #HF default 00406 correctionparams={'a0':1.0} 00407 runfillschemeMap={} 00408 fillschemePatternMap={} 00409 if lumitype=='PIXEL': 00410 correctorname='fPolyScheme' #PIXEL default 00411 fillschemePatternMap=dataDML.fillschemePatternMap(schema,'PIXEL') 00412 for run,perrundata in instresult.items(): 00413 if perrundata is None: 00414 result[run]=None 00415 continue 00416 intglumi=0. 00417 if normmap and intglumimap and intglumimap.has_key(run) and intglumimap[run]: 00418 intglumi=intglumimap[run] 00419 nBXs=0 00420 if normmap and lumirundata and lumirundata.has_key(run) and lumirundata[run][2]: 00421 nBXs=lumirundata[run][2] 00422 fillschemeStr='' 00423 if normmap and runsummaryMap and runsummaryMap.has_key(run) and runsummaryMap[run][5]: 00424 fillschemeStr=runsummaryMap[run][5] 00425 if allsince: 00426 lastsince=allsince[0] 00427 for since in allsince: 00428 if run>=since: 00429 lastsince=since 00430 correctorname=normmap[lastsince][0] 00431 correctionparams=normmap[lastsince][1] 00432 00433 correctioninput=[0.,intglumi,nBXs,fillschemeStr,fillschemePatternMap] 00434 result[run]=[] 00435 for perlsdata in perrundata:#loop over ls 00436 lumilsnum=perlsdata[0] 00437 cmslsnum=perlsdata[1] 00438 timestamp=perlsdata[2] 00439 bs=perlsdata[3] 00440 beamenergy=perlsdata[4] 00441 instluminonorm=perlsdata[5] 00442 correctioninput[0]=instluminonorm 00443 totcorrectionFac=normFunctors.normFunctionCaller(correctorname,*correctioninput,**correctionparams) 00444 fillnum=perlsdata[11] 00445 instcorrectedlumi=totcorrectionFac*instluminonorm 00446 numorbit=perlsdata[8] 00447 numbx=lumip.NBX 00448 lslen=lumip.lslengthsec() 00449 deliveredlumi=instcorrectedlumi*lslen 00450 calibratedbxdata=None 00451 beamdata=None 00452 pu=0.#avgPU 00453 if nBXs and minbiasXsec: 00454 pu=(instcorrectedlumi/nBXs)*minbiasXsec/lumip.rotationRate 00455 if withBXInfo: 00456 (bxidxData,bxvaluesData,bxerrsData)=perlsdata[9] 00457 if lumitype=='HF': 00458 if xingMinLum: 00459 bxidxList=[] 00460 bxvalueList=[] 00461 bxerrList=[] 00462 for idx,bxval in enumerate(bxvaluesData): 00463 correctedbxintlumi=totcorrectionFac*bxval 00464 correctedbxintlumierr=totcorrectionFac*bxerrsData[idx] 00465 if correctedbxintlumi>xingMinLum: 00466 bxidxList.append(bxidxData[idx]) 00467 bxvalueList.append(correctedbxintlumi) 00468 bxerrList.append(correctedbxintlumierr) 00469 calibratedbxdata=(bxidxList,bxvalueList,bxerrList) 00470 else: 00471 calibratedbxvalue=[totcorrectionFac*x for x in bxvaluesData] 00472 calibratedlumierr=[totcorrectionFac*x for x in bxerrsData] 00473 calibratedbxdata=(bxidxData,calibratedbxvalue,calibratedlumierr) 00474 if withBeamIntensity: 00475 beamdata=perlsdata[10] 00476 calibratedlumierr=0.0 00477 result[run].append([lumilsnum,cmslsnum,timestamp,bs,beamenergy,deliveredlumi,calibratedlumierr,calibratedbxdata,beamdata,fillnum,pu]) 00478 del perlsdata[:] 00479 return result
def lumiCalcAPI::effectiveLumiForIds | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
runsummaryMap = None , |
|||
beamstatusfilter = None , |
|||
timeFilter = None , |
|||
normmap = None , |
|||
hltpathname = None , |
|||
hltpathpattern = None , |
|||
withBXInfo = False , |
|||
bxAlgo = None , |
|||
xingMinLum = None , |
|||
withBeamIntensity = False , |
|||
lumitype = 'HF' , |
|||
minbiasXsec = None |
|||
) |
delivered/recorded/eff lumi in selected hlt path (including calibration,time integral) input: irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls dataidmap : {run:(lumiid,trgid,hltid)} runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} beamstatusfilter: LS filter on beamstatus normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction hltpathname: selected hltpathname hltpathpattern: regex select hltpaths withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamIntensity: get beam intensity info (optional) lumitype: luminosity source output: result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),{hltpath:[l1name,l1prescale,hltprescale,efflumi]}(8),bxdata(9),beamdata(10),fillnum(11),ncollidingbunches(12)]} {run:None} None means no run in lumiDB, {run:[]} [] means no lumi for this run in lumiDB {run:[....deliveredlumi(5),recorded(6)==None,]} means no trigger in lumiDB {run:[....deliveredlumi(5),recorded(6),calibratedlumierror(7)==None]} means no hlt in lumiDB lumi unit: 1/ub
Definition at line 532 of file lumiCalcAPI.py.
00533 : 00534 ''' 00535 delivered/recorded/eff lumi in selected hlt path (including calibration,time integral) 00536 input: 00537 irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls 00538 dataidmap : {run:(lumiid,trgid,hltid)} 00539 runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} 00540 beamstatusfilter: LS filter on beamstatus 00541 normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction 00542 hltpathname: selected hltpathname 00543 hltpathpattern: regex select hltpaths 00544 withBXInfo: get per bunch info (optional) 00545 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00546 xingMinLum: cut on bx lumi value (optional) 00547 withBeamIntensity: get beam intensity info (optional) 00548 lumitype: luminosity source 00549 output: 00550 result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),{hltpath:[l1name,l1prescale,hltprescale,efflumi]}(8),bxdata(9),beamdata(10),fillnum(11),ncollidingbunches(12)]} 00551 {run:None} None means no run in lumiDB, 00552 {run:[]} [] means no lumi for this run in lumiDB 00553 {run:[....deliveredlumi(5),recorded(6)==None,]} means no trigger in lumiDB 00554 {run:[....deliveredlumi(5),recorded(6),calibratedlumierror(7)==None]} means no hlt in lumiDB 00555 00556 lumi unit: 1/ub 00557 ''' 00558 deliveredresult=deliveredLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=beamstatusfilter,timeFilter=timeFilter,normmap=normmap,withBXInfo=withBXInfo,bxAlgo=bxAlgo,xingMinLum=xingMinLum,withBeamIntensity=withBeamIntensity,lumitype=lumitype,minbiasXsec=minbiasXsec) 00559 trgresult=trgForIds(schema,irunlsdict,dataidmap,withPrescale=True) #{run:[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(bitname,prescale,counts,mask)]]} 00560 hltresult=hltForIds(schema,irunlsdict,dataidmap,hltpathname=hltpathname,hltpathpattern=hltpathpattern,withL1Pass=False,withHLTAccept=False) #{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})} 00561 for run in deliveredresult.keys(): #loop over delivered 00562 perrundata=deliveredresult[run] 00563 if perrundata is None or len(perrundata)==0:#pass through 00564 continue 00565 alltrgls=[] 00566 if trgresult.has_key(run) and trgresult[run]: 00567 alltrgls=[x[0] for x in trgresult[run]] 00568 allhltls=[] 00569 if hltresult.has_key(run) and hltresult[run]: 00570 allhltls=[x[0] for x in hltresult[run]] 00571 l1bitinfo=[] 00572 hltpathinfo=[] 00573 hlttrgmap=dataDML.hlttrgMappingByrun(schema,run,hltpathname=hltpathname,hltpathpattern=hltpathpattern) 00574 00575 for perlsdata in perrundata: #loop over ls 00576 if not perlsdata: continue #no lumi for this ls 00577 perlsdata.insert(6,None) 00578 perlsdata.insert(8,None) 00579 if not alltrgls: continue #no trg for this run 00580 cmslsnum=perlsdata[1] 00581 recordedlumi=0.0 00582 if cmslsnum==0:#if not a cmsls or not selected by cms list, set recordedlumi,efflumi to 0 00583 continue 00584 else: 00585 try: 00586 trglsidx=alltrgls.index(cmslsnum) 00587 deadfrac=trgresult[run][trglsidx][1] 00588 l1bitinfo=trgresult[run][trglsidx][5] 00589 if deadfrac<0 or deadfrac>1.0:deadfrac=1.0 00590 deliveredlumi=perlsdata[5] 00591 recordedlumi=(1.0-deadfrac)*deliveredlumi 00592 except ValueError: 00593 #print '[WARNING] no trigger for LS=',cmslsnum 00594 continue #do not go further 00595 perlsdata[6]=recordedlumi 00596 if not allhltls: continue #no hlt for this run 00597 try: 00598 hltlsidx=allhltls.index(cmslsnum) 00599 except ValueError: 00600 #print '[WARNING] no hlt for LS=',cmslsnum 00601 continue #do not go further 00602 trgprescalemap={} #{bitname:l1prescale} for this lumi section 00603 if l1bitinfo: 00604 for thisbitinfo in l1bitinfo: 00605 thisbitname=thisbitinfo[0] 00606 thisbitprescale=thisbitinfo[2] 00607 trgprescalemap['"'+thisbitname+'"']=thisbitprescale 00608 else: 00609 continue 00610 hltpathdata=hltresult[run][hltlsidx][1] 00611 efflumidict={}#{pathname:[[l1bitname,l1prescale,hltprescale,efflumi]]} 00612 for pathidx,thispathinfo in enumerate(hltpathdata): 00613 thispathname=thispathinfo[0] 00614 thisprescale=thispathinfo[1] 00615 thisl1seed=None 00616 l1bitname=None 00617 l1prescale=None 00618 try: 00619 thisl1seed=hlttrgmap[thispathname] 00620 except KeyError: 00621 thisl1seed=None 00622 if thisl1seed: 00623 try: 00624 (exptype,l1bits)=hltTrgSeedMapper.findUniqueSeed(thispathname,thisl1seed) 00625 if l1bits: 00626 if not exptype: 00627 l1bitname=l1bits[0] 00628 l1prescale=trgprescalemap[l1bits[0]]#need to match double quoted string! 00629 else: 00630 pmin=99999999 00631 pmax=0 00632 for bit in l1bits: 00633 l1p=trgprescalemap[bit] 00634 if exptype=='OR': 00635 if l1p!=0 and l1p<pmin: 00636 pmin=l1p 00637 l1prescale=l1p 00638 l1bitname=bit 00639 if exptype=='AND': 00640 if l1p!=0 and l1p>pmax: 00641 pmax=l1p 00642 l1prescale=l1p 00643 l1bitname=bit 00644 else: 00645 l1prescale=None 00646 except KeyError: 00647 l1prescale=None 00648 00649 efflumi=0.0 00650 if l1prescale and thisprescale:#normal both prescaled 00651 efflumi=recordedlumi/(float(l1prescale)*float(thisprescale)) 00652 efflumidict[thispathname]=[l1bitname,l1prescale,thisprescale,efflumi] 00653 elif l1prescale and thisprescale==0: #hltpath in menu but masked 00654 efflumidict[thispathname]=[l1bitname,l1prescale,thisprescale,efflumi] 00655 else: 00656 efflumidict[thispathname]=[None,0,thisprescale,efflumi] 00657 perlsdata[8]=efflumidict 00658 return deliveredresult 00659
def lumiCalcAPI::fillInRange | ( | schema, | |
fillmin = 1000 , |
|||
fillmax = 9999 , |
|||
amodetag = 'PROTPHYS' , |
|||
startT = None , |
|||
stopT = None |
|||
) |
output [fill]
Definition at line 35 of file lumiCalcAPI.py.
def lumiCalcAPI::fillrunMap | ( | schema, | |
fillnum = None , |
|||
runmin = None , |
|||
runmax = None , |
|||
startT = None , |
|||
stopT = None , |
|||
l1keyPattern = None , |
|||
hltkeyPattern = None , |
|||
amodetag = None |
|||
) |
output: {fill:[runnum,...]}
Definition at line 41 of file lumiCalcAPI.py.
def lumiCalcAPI::hltForIds | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
hltpathname = None , |
|||
hltpathpattern = None , |
|||
withL1Pass = False , |
|||
withHLTAccept = False |
|||
) |
input: irunlsdict: {run:[cmsls]} (required) dataidmap: {run:(lumiid,trgid,hltid)} hltpathname: exact match hltpathname (optional) hltpathpattern: regex match hltpathpattern (optional) withL1Pass: with L1 pass count withHLTAccept: with HLT accept output: {runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})}
Definition at line 152 of file lumiCalcAPI.py.
00153 : 00154 ''' 00155 input: 00156 irunlsdict: {run:[cmsls]} (required) 00157 dataidmap: {run:(lumiid,trgid,hltid)} 00158 hltpathname: exact match hltpathname (optional) 00159 hltpathpattern: regex match hltpathpattern (optional) 00160 withL1Pass: with L1 pass count 00161 withHLTAccept: with HLT accept 00162 output: {runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})} 00163 ''' 00164 result={} 00165 for run in irunlsdict.keys(): 00166 lslist=irunlsdict[run] 00167 if lslist is not None and len(lslist)==0: 00168 result[run]=[]#if no LS is selected for a run 00169 continue 00170 if not dataidmap.has_key(run): 00171 continue 00172 hltdataid=dataidmap[run][2] 00173 if hltdataid is None: 00174 result[run]=None 00175 continue #run non exist 00176 hltdata=dataDML.hltLSById(schema,hltdataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern,withL1Pass=withL1Pass,withHLTAccept=withHLTAccept) 00177 #(runnum,{cmslsnum:[(pathname,prescale,l1pass,hltaccept),...]}) 00178 result[run]=[] 00179 if hltdata and hltdata[1]: 00180 lsdict={} 00181 for cmslsnum in sorted(hltdata[1]): 00182 if lslist is not None and cmslsnum not in lslist: 00183 continue 00184 lsdata=[] 00185 for perpathdata in hltdata[1][cmslsnum]: 00186 pathname=perpathdata[0] 00187 prescale=perpathdata[1] 00188 l1pass=None 00189 hltaccept=None 00190 if withL1Pass: 00191 l1pass=perpathdata[2] 00192 if withHLTAccept: 00193 hltaccept=perpathdata[3] 00194 lsdata.append((pathname,prescale,l1pass,hltaccept)) 00195 result[run].append((cmslsnum,lsdata)) 00196 return result
def lumiCalcAPI::hltpathsForRange | ( | schema, | |
runlist, | |||
hltpathname = None , |
|||
hltpathpattern = None |
|||
) |
input: runlist [run], (required) datatag: data version (optional) output : {runnumber,[(hltpath,l1seedexpr,l1bitname)...]}
Definition at line 53 of file lumiCalcAPI.py.
00054 : 00055 ''' 00056 input: runlist [run], (required) 00057 datatag: data version (optional) 00058 output : {runnumber,[(hltpath,l1seedexpr,l1bitname)...]} 00059 ''' 00060 result={} 00061 for run in runlist: 00062 hlttrgmap=dataDML.hlttrgMappingByrun(schema,run,hltpathname=hltpathname,hltpathpattern=hltpathpattern) 00063 result[run]=[] 00064 for hltpath in sorted(hlttrgmap): 00065 l1seedexpr=hlttrgmap[hltpath] 00066 (exptype,l1bits)=hltTrgSeedMapper.findUniqueSeed(hltpath,l1seedexpr) 00067 l1bitname='n/a' 00068 if l1bits: 00069 if exptype: 00070 l1bitname=l1seedexpr 00071 else: 00072 l1bitname=l1bits[0] 00073 result[run].append((hltpath,l1seedexpr,l1bitname)) 00074 return result
def lumiCalcAPI::instLumiForIds | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
runsummaryMap, | |||
beamstatusfilter = None , |
|||
timeFilter = None , |
|||
withBXInfo = False , |
|||
bxAlgo = None , |
|||
xingMinLum = None , |
|||
withBeamIntensity = False , |
|||
lumitype = 'HF' |
|||
) |
FROM ROOT FILE NO CORRECTION AT ALL input: irunlsdict: {run:[cmsls]} dataidmap: {run:(lumiid,trgid,hltid)} runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} beamstatus: LS filter on beamstatus (optional) timeFilter: (minLSBegTime,maxLSBegTime) withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: None means apply no cut withBeamIntensity: get beam intensity info (optional) lumitype: luminosity measurement source output: result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),instlumi(5),instlumierr(6),startorbit(7),numorbit(8),(bxidx,bxvalues,bxerrs)(9),(bxidx,b1intensities,b2intensities)(10),fillnum(11)]}} special meanings: {run:None} None means selected run not in lumiDB, {run:[]} [] means no lumi data for this run in lumiDB {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected instlumi unit in Hz/ub
Definition at line 250 of file lumiCalcAPI.py.
00251 : 00252 ''' 00253 FROM ROOT FILE NO CORRECTION AT ALL 00254 input: 00255 irunlsdict: {run:[cmsls]} 00256 dataidmap: {run:(lumiid,trgid,hltid)} 00257 runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} 00258 beamstatus: LS filter on beamstatus (optional) 00259 timeFilter: (minLSBegTime,maxLSBegTime) 00260 withBXInfo: get per bunch info (optional) 00261 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00262 xingMinLum: None means apply no cut 00263 withBeamIntensity: get beam intensity info (optional) 00264 lumitype: luminosity measurement source 00265 output: 00266 result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),instlumi(5),instlumierr(6),startorbit(7),numorbit(8),(bxidx,bxvalues,bxerrs)(9),(bxidx,b1intensities,b2intensities)(10),fillnum(11)]}} 00267 00268 special meanings: 00269 {run:None} None means selected run not in lumiDB, 00270 {run:[]} [] means no lumi data for this run in lumiDB 00271 {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected 00272 instlumi unit in Hz/ub 00273 ''' 00274 if lumitype not in ['HF','PIXEL']: 00275 raise ValueError('unknown lumitype '+lumitype) 00276 lumitableName='' 00277 lumilstableName='' 00278 if lumitype=='HF': 00279 lumitableName=nameDealer.lumidataTableName() 00280 lumilstableName=nameDealer.lumisummaryv2TableName() 00281 else: 00282 lumitableName=nameDealer.pixellumidataTableName() 00283 lumilstableName=nameDealer.pixellumisummaryv2TableName() 00284 result={} 00285 for run in irunlsdict.keys(): 00286 #for run,(lumidataid,trgid,hltid ) in dataidmap.items(): 00287 lslist=irunlsdict[run] 00288 if lslist is not None and len(lslist)==0: 00289 result[run]=[]#no lumi data for this run in lumiDB 00290 continue 00291 fillnum=runsummaryMap[run][4] 00292 runstarttimeStr=runsummaryMap[run][6] 00293 if not dataidmap.has_key(run): 00294 result[run]=[]#no lumi data for this run in lumiDB 00295 continue 00296 (lumidataid,trgid,hltid )=dataidmap[run] 00297 if lumidataid is None: #selected run not in lumiDB 00298 result[run]=None 00299 continue 00300 (lumirunnum,perlsresult)=dataDML.lumiLSById(schema,lumidataid,beamstatus=beamstatusfilter,withBXInfo=withBXInfo,bxAlgo=bxAlgo,withBeamIntensity=withBeamIntensity,tableName=lumilstableName) 00301 lsresult=[] 00302 c=lumiTime.lumiTime() 00303 for lumilsnum in perlsresult.keys(): 00304 perlsdata=perlsresult[lumilsnum] 00305 cmslsnum=perlsdata[0] 00306 if lslist is not None and cmslsnum not in lslist: #ls exists but not selected 00307 cmslsnum=0 00308 numorbit=perlsdata[6] 00309 startorbit=perlsdata[7] 00310 orbittime=c.OrbitToTime(runstarttimeStr,startorbit,begorbit=0,customfm='%m/%d/%y %H:%M:%S') 00311 if timeFilter: 00312 if timeFilter[0]: 00313 if orbittime<timeFilter[0]: continue 00314 if timeFilter[1]: 00315 if orbittime>timeFilter[1]: continue 00316 if lumitype=='HF': 00317 instlumi=perlsdata[1]*1000.0 #HF db avg values are in Hz/mb,change it to Hz/ub 00318 instlumierr=perlsdata[2]*1000.0 00319 else: 00320 instlumi=perlsdata[1] #PIXEL avg values are in Hz/ub, need no conversion 00321 instlumierr=perlsdata[2] 00322 beamstatus=perlsdata[4] 00323 beamenergy=perlsdata[5] 00324 bxidxlist=[] 00325 bxvaluelist=[] 00326 bxerrorlist=[] 00327 bxdata=None 00328 beamdata=None 00329 if withBXInfo: 00330 bxinfo=perlsdata[8] 00331 bxvalueArray=None 00332 bxerrArray=None 00333 if bxinfo: 00334 bxvalueArray=bxinfo[0] 00335 bxerrArray=bxinfo[1] 00336 if xingMinLum : 00337 for idx,bxval in enumerate(bxvalueArray): 00338 if bxval>xingMinLum: 00339 bxidxlist.append(idx) 00340 bxvaluelist.append(bxval) 00341 bxerrorlist.append(bxerrArray[idx]) 00342 else: 00343 bxidxlist=range(0,len(bxvalueArray)) 00344 bxvaluelist=bxvalueArray.tolist() 00345 bxerrorlist=bxerrArray.tolist() 00346 del bxvalueArray[:] 00347 del bxerrArray[:] 00348 bxdata=(bxidxlist,bxvaluelist,bxerrorlist) 00349 if withBeamIntensity: 00350 beaminfo=perlsdata[9] 00351 bxindexlist=[] 00352 b1intensitylist=[] 00353 b2intensitylist=[] 00354 if beaminfo[0] and beaminfo[1] and beaminfo[2]: 00355 bxindexarray=beaminfo[0] 00356 beam1intensityarray=beaminfo[1] 00357 beam2intensityarray=beaminfo[2] 00358 bxindexlist=bxindexarray.tolist() 00359 b1intensitylist=beam1intensityarray.tolist() 00360 b2intensitylist=beam2intensityarray.tolist() 00361 del bxindexarray[:] 00362 del beam1intensityarray[:] 00363 del beam2intensityarray[:] 00364 beamdata=(bxindexlist,b1intensitylist,b2intensitylist) 00365 lsresult.append([lumilsnum,cmslsnum,orbittime,beamstatus,beamenergy,instlumi,instlumierr,startorbit,numorbit,bxdata,beamdata,fillnum]) 00366 del perlsdata[:] 00367 result[run]=lsresult 00368 return result
def lumiCalcAPI::lumiForIds | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
runsummaryMap, | |||
beamstatusfilter = None , |
|||
timeFilter = None , |
|||
normmap = None , |
|||
withBXInfo = False , |
|||
bxAlgo = None , |
|||
xingMinLum = None , |
|||
withBeamIntensity = False , |
|||
lumitype = 'HF' , |
|||
minbiasXsec = None |
|||
) |
delivered/recorded lumi (including calibration,time integral) input: irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means no selected ls dataidmap : {run:(lumiid,trgid,hltid)} runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} beamstatus: LS filter on beamstatus normmap: withBXInfo: get per bunch info (optional) bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] xingMinLum: cut on bx lumi value (optional) withBeamIntensity: get beam intensity info (optional) lumitype: luminosity source output: result {run:[[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),(bxidx,bxvalues,bxerrs)(8),(bxidx,b1intensities,b2intensities)(9),fillnum(10),ncollidingbunches(11)]...]} special meanings: {run:None} None means no run in lumiDB, {run:[]} [] means no lumi for this run in lumiDB {run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB {run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0 lumi unit: 1/ub
Definition at line 480 of file lumiCalcAPI.py.
00481 : 00482 ''' 00483 delivered/recorded lumi (including calibration,time integral) 00484 input: 00485 irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means no selected ls 00486 dataidmap : {run:(lumiid,trgid,hltid)} 00487 runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} 00488 beamstatus: LS filter on beamstatus 00489 normmap: 00490 withBXInfo: get per bunch info (optional) 00491 bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET'] 00492 xingMinLum: cut on bx lumi value (optional) 00493 withBeamIntensity: get beam intensity info (optional) 00494 lumitype: luminosity source 00495 output: 00496 result {run:[[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),(bxidx,bxvalues,bxerrs)(8),(bxidx,b1intensities,b2intensities)(9),fillnum(10),ncollidingbunches(11)]...]} 00497 special meanings: 00498 {run:None} None means no run in lumiDB, 00499 {run:[]} [] means no lumi for this run in lumiDB 00500 {run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB 00501 {run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0 00502 lumi unit: 1/ub 00503 ''' 00504 deliveredresult=deliveredLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=beamstatusfilter,timeFilter=timeFilter,normmap=normmap,withBXInfo=withBXInfo,bxAlgo=bxAlgo,xingMinLum=xingMinLum,withBeamIntensity=withBeamIntensity,lumitype=lumitype,minbiasXsec=minbiasXsec) 00505 trgresult=trgForIds(schema,irunlsdict,dataidmap) 00506 for run in deliveredresult.keys():#loop over delivered,already selected 00507 perrundata=deliveredresult[run] 00508 if perrundata is None or len(perrundata)==0: #pass through 00509 continue 00510 alltrgls=[] 00511 if trgresult.has_key(run) and trgresult[run]: 00512 alltrgls=[x[0] for x in trgresult[run]] 00513 for perlsdata in perrundata:#loop over ls 00514 if not perlsdata: continue #no lumi data for this ls 00515 perlsdata.insert(6,None) 00516 if not alltrgls: continue #no trg for this run,recorded=None 00517 cmslsnum=perlsdata[1] 00518 if cmslsnum==0:#if not a cmsls or not selected by cms list, set recordedlumi to 0 00519 recordedlumi=0.0 00520 else: 00521 try: 00522 trglsidx=alltrgls.index(cmslsnum) 00523 deadfrac=trgresult[run][trglsidx][1] 00524 if deadfrac<0 or deadfrac>1.0: deadfrac=1.0 00525 deliveredlumi=perlsdata[5] 00526 recordedlumi=(1.0-deadfrac)*deliveredlumi 00527 except ValueError: 00528 #print '[WARNING] no trigger for LS=',cmslsnum 00529 recordedlumi=None 00530 perlsdata[6]=recordedlumi 00531 return deliveredresult
def lumiCalcAPI::runList | ( | schema, | |
datatagid, | |||
runmin = None , |
|||
runmax = None , |
|||
fillmin = None , |
|||
fillmax = None , |
|||
startT = None , |
|||
stopT = None , |
|||
l1keyPattern = None , |
|||
hltkeyPattern = None , |
|||
amodetag = None , |
|||
nominalEnergy = None , |
|||
energyFlut = 0.2 , |
|||
requiretrg = True , |
|||
requirehlt = True , |
|||
preselectedruns = None , |
|||
lumitype = 'HF' |
|||
) |
output: [runnumber,...]
Definition at line 47 of file lumiCalcAPI.py.
00048 : 00049 ''' 00050 output: [runnumber,...] 00051 ''' 00052 return dataDML.runList(schema,datatagid,runmin=runmin,runmax=runmax,fillmin=fillmin,fillmax=fillmax,startT=startT,stopT=stopT,l1keyPattern=l1keyPattern,hltkeyPattern=hltkeyPattern,amodetag=amodetag,nominalEnergy=nominalEnergy,energyFlut=energyFlut,requiretrg=requiretrg,requirehlt=requirehlt,lumitype=lumitype)
def lumiCalcAPI::runsummary | ( | schema, | |
irunlsdict | |||
) |
Lumi data management and calculation API # # Author: Zhen Xie #.
output [[run(0),l1key(1),amodetag(2),egev(3),hltkey(4),fillnum(5),fillscheme(6),starttime(7),stoptime(8)]]
Definition at line 10 of file lumiCalcAPI.py.
00011 : 00012 ''' 00013 output [[run(0),l1key(1),amodetag(2),egev(3),hltkey(4),fillnum(5),fillscheme(6),starttime(7),stoptime(8)]] 00014 ''' 00015 result=[] 00016 for run in sorted(irunlsdict): 00017 runinfo=dataDML.runsummary(schema,run) 00018 runinfo.insert(0,run) 00019 result.append(runinfo) 00020 return result
def lumiCalcAPI::runsummaryMap | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
lumitype = 'HF' |
|||
) |
output: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
Definition at line 21 of file lumiCalcAPI.py.
00022 : 00023 ''' 00024 output: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]} 00025 ''' 00026 result={} 00027 seqresult=runsummary(schema,irunlsdict) 00028 idresult=dataDML.lumiRunByIds(schema,dataidmap,lumitype) 00029 for [run,l1key,amodetag,hltkey,fillnum,fillscheme] in seqresult: 00030 egev=idresult[run][2] 00031 startT=idresult[run][3] 00032 stopT=idresult[run][4] 00033 result[run]=[l1key,amodetag,egev,hltkey,fillnum,fillscheme,startT,stopT] 00034 return result
def lumiCalcAPI::trgForIds | ( | schema, | |
irunlsdict, | |||
dataidmap, | |||
trgbitname = None , |
|||
trgbitnamepattern = None , |
|||
withL1Count = False , |
|||
withPrescale = False |
|||
) |
input : irunlsdict {run:[cmsls]} (required) dataidmap: {run:(lumiid,trgid,hltid)} trgbitname exact match trgbitname (optional) trgbitnamepattern match trgbitname (optional) output result {run:[[cmslsnum(0),deadfrac(1),deadtimecount(2),bitzero_count(3),bitzero_prescale(4),[(bitname,prescale,counts,mask)](5)]]}
Definition at line 197 of file lumiCalcAPI.py.
00198 : 00199 ''' 00200 input : 00201 irunlsdict {run:[cmsls]} (required) 00202 dataidmap: {run:(lumiid,trgid,hltid)} 00203 trgbitname exact match trgbitname (optional) 00204 trgbitnamepattern match trgbitname (optional) 00205 output 00206 result {run:[[cmslsnum(0),deadfrac(1),deadtimecount(2),bitzero_count(3),bitzero_prescale(4),[(bitname,prescale,counts,mask)](5)]]} 00207 ''' 00208 result={} 00209 for run in irunlsdict.keys(): 00210 result[run]=[] 00211 lslist=irunlsdict[run] 00212 if lslist is not None and len(lslist)==0: 00213 #if no LS is selected for a run 00214 continue 00215 if not dataidmap.has_key(run): 00216 continue 00217 trgdataid=dataidmap[run][1] 00218 if trgdataid is None: 00219 result[run]=None 00220 continue #if run non exist 00221 if trgdataid==0: 00222 continue 00223 trgdata=dataDML.trgLSById(schema,trgdataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern,withL1Count=withL1Count,withPrescale=withPrescale) 00224 00225 #(runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale)](4)]}) 00226 if trgdata and trgdata[1]: 00227 lsdict={} 00228 for cmslsnum in sorted(trgdata[1]): 00229 if lslist is not None and cmslsnum not in lslist: 00230 continue 00231 lsdata=[] 00232 #print trgdata[1][cmslsnum] 00233 deadtimecount=trgdata[1][cmslsnum][0] 00234 #bitzerocount=trgdata[1][cmslsnum][1] 00235 #bitzeroprescale=trgdata[1][cmslsnum][2] 00236 bitzerocount=0 00237 bitzeroprescale=0 00238 deadfrac=trgdata[1][cmslsnum][3] 00239 if deadfrac<0 or deadfrac>1.0: 00240 deadfrac=1.0 00241 allbitsinfo=trgdata[1][cmslsnum][4] 00242 lsdata.append(cmslsnum) 00243 lsdata.append(deadfrac) 00244 lsdata.append(deadtimecount) 00245 lsdata.append(bitzerocount) 00246 lsdata.append(bitzeroprescale) 00247 lsdata.append(allbitsinfo) 00248 result[run].append(lsdata) 00249 return result