def lumiReport::dumptocsv | ( | fieldnames, | |
result, | |||
filename | |||
) |
utility method to dump result to csv file
Definition at line 11 of file lumiReport.py.
00012 : 00013 ''' 00014 utility method to dump result to csv file 00015 ''' 00016 assert(filename) 00017 if filename.upper()=='STDOUT': 00018 r=sys.stdout 00019 r.write(','.join(fieldnames)+'\n') 00020 for l in result: 00021 r.write(str(l)+'\n') 00022 else: 00023 r=csvReporter.csvReporter(filename) 00024 r.writeRow(fieldnames) 00025 r.writeRows(result) 00026 r.close()
def lumiReport::toCSVLumiByLSXing | ( | lumidata, | |
scalefactor, | |||
filename, | |||
irunlsdict = None , |
|||
noWarning = True |
|||
) |
input:{run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),bxdata(8),beamdata(9),fillnum(10)]} output: fieldnames=['Run:Fill','LS','UTCTime','Delivered(/ub)','Recorded(/ub)','BX']
Definition at line 875 of file lumiReport.py.
00876 : 00877 ''' 00878 input:{run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),bxdata(8),beamdata(9),fillnum(10)]} 00879 output: 00880 fieldnames=['Run:Fill','LS','UTCTime','Delivered(/ub)','Recorded(/ub)','BX'] 00881 ''' 00882 result=[] 00883 assert(filename) 00884 fieldnames=['run:fill','ls','UTCTime','delivered(/ub)','recorded(/ub)','[bx,Hz/ub]'] 00885 datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with 00886 for run in sorted(lumidata): 00887 rundata=lumidata[run] 00888 if rundata is None: 00889 result.append([str(run)+':0','n/a','n/a','n/a','n/a','n/a']) 00890 if irunlsdict and irunlsdict[run]: 00891 print '[WARNING] selected but no lumi data for run '+str(run) 00892 continue 00893 fillnum=0 00894 if rundata and rundata[0][10]: 00895 fillnum=rundata[0][10] 00896 if irunlsdict and not noWarning: 00897 existdata=[x[1] for x in rundata if x[1] ] 00898 datarunlsdict[run]=existdata 00899 for lsdata in rundata: 00900 lumilsnum=lsdata[0] 00901 cmslsnum=0 00902 if lsdata and lsdata[1]: 00903 cmslsnum=lsdata[1] 00904 tsStr='n/a' 00905 if lsdata and lsdata[2]: 00906 ts=lsdata[2] 00907 tsStr=ts.strftime('%m/%d/%y %H:%M:%S') 00908 deliveredlumi=0. 00909 if lsdata[5]: 00910 deliveredlumi=lsdata[5] 00911 recordedlumi=0. 00912 if lsdata[6]: 00913 recordedlumi=lsdata[6] 00914 (bxidxlist,bxvaluelist,bxerrorlist)=lsdata[8] 00915 if irunlsdict and irunlsdict[run]: 00916 if run in irunlsdict and cmslsnum in irunlsdict[run]: 00917 if bxidxlist and bxvaluelist: 00918 bxresult=[] 00919 bxinfo=CommonUtil.transposed([bxidxlist,bxvaluelist]) 00920 bxresult=CommonUtil.flatten([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo]) 00921 result.append(bxresult) 00922 else: 00923 result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor]) 00924 else: 00925 if bxidxlist and bxvaluelist: 00926 bxresult=[] 00927 bxinfo=CommonUtil.transposed([bxidxlist,bxvaluelist]) 00928 bxresult=CommonUtil.flatten([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo]) 00929 result.append(bxresult) 00930 else: 00931 result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor]) 00932 r=None 00933 if filename.upper()=='STDOUT': 00934 r=sys.stdout 00935 r.write(','.join(fieldnames)+'\n') 00936 for l in result: 00937 r.write(str(l)+'\n') 00938 else: 00939 r=csvReporter.csvReporter(filename) 00940 r.writeRow(fieldnames) 00941 r.writeRows(result)
def lumiReport::toScreenConfHlt | ( | hltconfdata, | |
iresults = [] , |
|||
toFile = None |
|||
) |
input : {runnumber,[(hltpath,l1seedexpr,l1bitname),...]}
Definition at line 1060 of file lumiReport.py.
01061 : 01062 ''' 01063 input : {runnumber,[(hltpath,l1seedexpr,l1bitname),...]} 01064 ''' 01065 result=[] 01066 for r in iresults: 01067 pp=r[1] 01068 pp=' '.join([pp[i:i+25] for i in range(0,len(pp),25)]) 01069 sdepr=r[2] 01070 sdepr=' '.join([sdepr[i:i+25] for i in range(0,len(sdepr),25)]) 01071 lb=r[3] 01072 lb=' '.join([lb[i:i+25] for i in range(0,len(lb),25)]) 01073 result.append([r[0],pp,sdepr,lb]) 01074 for run in sorted(hltconfdata): 01075 pathdata=hltconfdata[run] 01076 if pathdata is None: 01077 result.append([str(run),'n/a','n/a','n/a']) 01078 continue 01079 for thispathinfo in pathdata: 01080 thispath=thispathinfo[0] 01081 thispath=' '.join([thispath[i:i+25] for i in range(0,len(thispath),25)]) 01082 thisseed=thispathinfo[1] 01083 thisseed=' '.join([thisseed[i:i+25] for i in range(0,len(thisseed),25)]).replace('"','') 01084 thisbit=thispathinfo[2] 01085 if not thisbit: 01086 thisbit='n/a' 01087 else: 01088 thisbit=' '.join([thisbit[i:i+25] for i in range(0,len(thisbit),25)]).replace('"','') 01089 result.append([str(run),thispath,thisseed,thisbit]) 01090 if not toFile: 01091 labels=[('Run','hltpath','l1seedexpr','l1bit')] 01092 print ' == = ' 01093 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False, 01094 prefix = '| ', postfix = ' |', justify = 'left', 01095 delim = ' | ', wrapfunc = lambda x: wrap_onspace(x,25) ) 01096 else: 01097 filename=toFile 01098 fieldnames=['Run','hltpath','l1seedexpr','l1bit'] 01099 dumptocsv(fieldnames,sortedresult,filename)
def lumiReport::toScreenHeader | ( | commandname, | |
datatagname, | |||
normtag, | |||
worktag, | |||
updatetag, | |||
lumitype, | |||
toFile = None |
|||
) |
input: commandname: commandname datataginfo: tagname normtag: normtag worktag: working version updatetag: updated version if amy
Definition at line 27 of file lumiReport.py.
00028 : 00029 ''' 00030 input: 00031 commandname: commandname 00032 datataginfo: tagname 00033 normtag: normtag 00034 worktag: working version 00035 updatetag: updated version if amy 00036 ''' 00037 gmtnowStr=time.asctime(time.gmtime())+' UTC' 00038 updatetagStr='None' 00039 if updatetag: 00040 updatetagStr=updatetag 00041 header=''.join(['*']*80)+'\n' 00042 header+='* '+gmtnowStr+'\n' 00043 header+='* lumitype: '+lumitype+' , datatag: '+datatagname+' , normtag: '+normtag+' , worktag: '+worktag+'\n' 00044 header+='* \n' 00045 header+='* by:\n' 00046 header+='* '+commandname+'\n' 00047 header+='* \n' 00048 header+='* update: '+updatetag+'\n' 00049 header+=''.join(['*']*80)+'\n' 00050 if not toFile: 00051 sys.stdout.write(header) 00052 else: 00053 assert(toFile) 00054 if toFile.upper()=='STDOUT': 00055 r=sys.stdout 00056 else: 00057 r=open(toFile,'wb') 00058 r.write(header)
def lumiReport::toScreenLSBeam | ( | beamdata, | |
iresults = [] , |
|||
dumpIntensity = False , |
|||
toFile = None |
|||
) |
input: {run:[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(4)),..]} beaminfolist:[(bxidx,b1,b2)]
Definition at line 1100 of file lumiReport.py.
01101 : 01102 ''' 01103 input: {run:[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(4)),..]} 01104 beaminfolist:[(bxidx,b1,b2)] 01105 ''' 01106 result=[] 01107 for rline in iresults: 01108 result.append(rline) 01109 for run in sorted(beamdata): 01110 perrundata=beamdata[run] 01111 if perrundata is None: 01112 ll=[str(run),'n/a','n/a'] 01113 if dumpIntensity: 01114 ll.extend('n/a') 01115 continue 01116 for lsdata in perrundata: 01117 lumilsnum=lsdata[0] 01118 cmslsnum=lsdata[1] 01119 beamstatus=lsdata[2] 01120 beamenergy=lsdata[3] 01121 ncollidingbx=lsdata[4] 01122 if not dumpIntensity: 01123 result.append([str(run),str(lumilsnum)+':'+str(cmslsnum),beamstatus,'%.2f'%beamenergy,str(ncollidingbx)]) 01124 continue 01125 allbxinfo=lsdata[5] 01126 allbxresult=[] 01127 for thisbxinfo in allbxinfo: 01128 thisbxresultStr='(n/a,n/a,n/a,n/a)' 01129 bxidx=thisbxinfo[0] 01130 b1=thisbxinfo[1] 01131 b2=thisbxinfo[2] 01132 thisbxresultStr=','.join(['%d'%bxidx,'%.3e'%b1,'%.3e'%b2]) 01133 allbxresult.append(thisbxresultStr) 01134 allbxresultStr=' '.join(allbxresult) 01135 result.append([str(run),str(lumilsnum)+':'+str(cmslsnum),beamstatus,'%.2f'%beamenergy,str(ncollidingbx),allbxresultStr]) 01136 01137 if not toFile: 01138 labels=[('Run','LS','beamstatus','egev','ncollidingbx')] 01139 if dumpIntensity: 01140 labels=[('Run','LS','beamstatus','egev','ncollidingbx','(bxidx,b1,b2)')] 01141 print ' == = ' 01142 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False, 01143 prefix = '| ', postfix = ' |', justify = 'left', 01144 delim = ' | ', wrapfunc = lambda x: wrap_onspace(x,25) ) 01145 else: 01146 fieldnames=['Run','LS','beamstatus','egev','ncollidingbx'] 01147 if dumpIntensity: 01148 fieldnames.append('(bxidx,b1,b2)') 01149 filename=toFile 01150 dumptocsv(fieldnames,result,filename)
def lumiReport::toScreenLSEffective | ( | lumidata, | |
resultlines, | |||
scalefactor, | |||
irunlsdict = None , |
|||
noWarning = True , |
|||
toFile = None |
|||
) |
input: {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)]}
Definition at line 538 of file lumiReport.py.
00539 : 00540 ''' 00541 input: {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)]} 00542 ''' 00543 result=[]#[run,ls,hltpath,l1bitname,hltpresc,l1presc,efflumi] 00544 totalrow=[] 00545 totSelectedLSDict={} 00546 totRecordedDict={} 00547 totEffectiveDict={} 00548 00549 totOldSelectedLSDict={} 00550 totOldRecordedDict={} 00551 totOldEffectiveDict={} 00552 00553 maxlslumi = 0.0 00554 datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with 00555 for rline in resultlines: 00556 runfillstr=rline[0] 00557 [runnumstr,fillnumstr]=runfillstr.split(':') 00558 if irunlsdict and not noWarning: 00559 if rline[1] is not 'n/a': 00560 datarunlsdict[int(runnumstr)]=[] 00561 myls=rline[1] 00562 mypath=rline[2] 00563 00564 if myls and myls!='n/a' and mpath and mpath!='n/a': 00565 totOldSelectedLSDict[mypath]=0 00566 totOldRecordedDict[mypath]=0. 00567 totOldEffectiveDict[mypath]=0. 00568 if myls!='n/a': 00569 [luls,cmls]=myls.split(':') 00570 if cmls!='0': 00571 if totOldSelectedLSDict.has_key(mypath): 00572 totOldSelectedLSDict[mypath]+=1 00573 if irunlsdict and not noWarning: 00574 datarunlsdict[int(runnumstr)].append(int(myls)) 00575 myrecorded=0. 00576 if rline[6]!='n/a': 00577 myrecorded=float(rline[6]) 00578 if myrecorded>maxlslumi:maxlslumi=myrecorded 00579 if totOldRecordedDict.has_key(mypath): 00580 totOldRecordedDict[mypath]+=myrecorded 00581 rline[6]=myrecorded 00582 myeff={} 00583 if rline[7]!='n/a': 00584 myeff=float(rline[7]) 00585 if totOldEffectiveDict.has_key(mypath): 00586 totOldEffectiveDict[mypath]+=myeff 00587 rline[7]=myeff 00588 result.append(rline) 00589 00590 for run in lumidata.keys():#loop over runs 00591 lsdata=lumidata[run] 00592 if not lsdata: 00593 result.append([str(run),'n/a','n/a','n/a','n/a','n/a','n/a','n/a']) 00594 if irunlsdict and irunlsdict[run] and not noWarning: 00595 datarunlsdict[run]=None 00596 continue 00597 fillnum=0 00598 if lsdata[0] and lsdata[0][11]: 00599 fillnum=lsdata[0][11] 00600 datarunlsdict[run]=[] 00601 for thisls in lsdata: 00602 lumilsnum=thisls[0] 00603 cmslsnum=thisls[1]#triggered ls 00604 if not cmslsnum: continue 00605 efflumiDict=thisls[8]# this ls has no such path? 00606 recordedlumi=0. 00607 if thisls[6]: 00608 recordedlumi=thisls[6] 00609 if recordedlumi>maxlslumi:maxlslumi=recordedlumi 00610 if not efflumiDict: 00611 result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),'n/a','n/a','n/a','n/a',recordedlumi,'n/a']) 00612 continue 00613 00614 for hltpathname in sorted(efflumiDict): 00615 if hltpathname and hltpathname !='n/a' : 00616 if not totRecordedDict.has_key(hltpathname): 00617 totRecordedDict[hltpathname]=0. 00618 if not totSelectedLSDict.has_key(hltpathname): 00619 totSelectedLSDict[hltpathname]=0 00620 if not totEffectiveDict.has_key(hltpathname): 00621 totEffectiveDict[hltpathname]=0. 00622 totSelectedLSDict[hltpathname]+=1 00623 totRecordedDict[hltpathname]+=recordedlumi 00624 pathdata=efflumiDict[hltpathname] 00625 l1name=pathdata[0] 00626 cleanl1name='n/a' 00627 if l1name: 00628 cleanl1name=l1name.replace('"','') 00629 l1presc='0' 00630 if pathdata[1]: 00631 l1presc=str(pathdata[1]) 00632 hltpresc='0' 00633 if pathdata[2]: 00634 hltpresc=str(pathdata[2]) 00635 lumival=0. 00636 if pathdata[3]: 00637 lumival=pathdata[3] 00638 result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),hltpathname,cleanl1name,hltpresc,l1presc,recordedlumi,lumival]) 00639 if hltpathname and hltpathname !='n/a' : 00640 totEffectiveDict[hltpathname]+=lumival 00641 if irunlsdict and not noWarning: 00642 datarunlsdict[run].append(int(cmslsnum)) 00643 sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0])) 00644 if irunlsdict and not noWarning: 00645 for run,cmslslist in irunlsdict.items(): 00646 if run not in datarunlsdict.keys() or datarunlsdict[run] is None: 00647 sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no HLT data\n') 00648 continue 00649 if cmslslist: 00650 for ss in cmslslist: 00651 if ss not in datarunlsdict[run]: 00652 sys.stdout.write('[WARNING] selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB or has no qualified data\n') 00653 00654 if not toFile: 00655 (lsunitstring,unitdenomitor)=CommonUtil.lumiUnitForPrint(maxlslumi*scalefactor) 00656 labels = [('Run:Fill','LS','HLTpath','L1bit','HLTpresc','L1presc','Recorded('+lsunitstring+')','Effective('+lsunitstring+')')] 00657 perlsresult=[] 00658 for entry in sortedresult: 00659 reclumi=entry[6] 00660 if reclumi!='n/a': 00661 reclumi='%.3f'%float(float(reclumi*scalefactor)/float(unitdenomitor)) 00662 efflumi=entry[7] 00663 if efflumi!='n/a': 00664 efflumi='%.3f'%float(float(efflumi*scalefactor)/float(unitdenomitor)) 00665 perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],entry[5],reclumi,efflumi]) 00666 print ' == = ' 00667 print tablePrinter.indent (labels+perlsresult, hasHeader = True, separateRows = False, 00668 prefix = '| ', postfix = ' |', justify = 'right', 00669 delim = ' | ', wrapfunc = lambda x: wrap_onspace_strict(x,25) ) 00670 for mpath in sorted(totRecordedDict): 00671 totSelectedLS=totSelectedLSDict[mpath] 00672 if totOldSelectedLSDict.has_key(mpath): 00673 totSelectedLS+=totOldSelectedLS[mpath] 00674 totRecorded=totRecordedDict[mpath] 00675 if totOldRecordedDict.has_key(mpath): 00676 totRecorded+=totOldRecorded[mpath] 00677 totRecorded=float(totRecorded*scalefactor)/float(unitdenomitor) 00678 totEffective=totEffectiveDict[mpath] 00679 if totOldEffectiveDict.has_key(mpath): 00680 totEffective+=totOldEffective[mpath] 00681 totEffective=float(totEffective*scalefactor)/float(unitdenomitor) 00682 totalrow.append([str(totSelectedLS),mpath,'%.3f'%(totRecorded),'%.3f'%(totEffective)]) 00683 lastrowlabels = [ ('Selected LS','HLTPath','Recorded('+lsunitstring+')','Effective('+lsunitstring+')')] 00684 print ' == = Total : ' 00685 print tablePrinter.indent (lastrowlabels+totalrow, hasHeader = True, separateRows = False, prefix = '| ', 00686 postfix = ' |', justify = 'right', delim = ' | ', 00687 wrapfunc = lambda x: wrap_onspace (x, 20)) 00688 else: 00689 fieldnames = ['Run:Fill','LS','HLTpath','L1bit','HLTpresc','L1presc','Recorded(/ub)','Effective(/ub)'] 00690 filename=toFile 00691 dumptocsv(fieldnames,sortedresult,filename)
def lumiReport::toScreenLSHlt | ( | hltdata, | |
iresults = [] , |
|||
toFile = None |
|||
) |
input:{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})}
Definition at line 1007 of file lumiReport.py.
01008 : 01009 ''' 01010 input:{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})} 01011 ''' 01012 result=[] 01013 for r in iresults: 01014 result.append(r) 01015 for run in hltdata.keys(): 01016 if hltdata[run] is None: 01017 ll=[str(run),'n/a','n/a','n/a','n/a','n/a'] 01018 continue 01019 perrundata=hltdata[run] 01020 for lsdata in perrundata: 01021 cmslsnum=lsdata[0] 01022 allpathinfo=lsdata[1] 01023 allpathresult=[] 01024 for thispathinfo in allpathinfo: 01025 thispathname=thispathinfo[0] 01026 thispathpresc=thispathinfo[1] 01027 thisl1pass=None 01028 thishltaccept=None 01029 thispathresult=[] 01030 thispathresult.append(thispathname) 01031 if thispathpresc is None: 01032 thispathpresc='n/a' 01033 else: 01034 thispathresult.append('%d'%thispathpresc) 01035 thisl1pass=thispathinfo[2] 01036 if thispathinfo[2] is None: 01037 thispathresult.append('n/a') 01038 else: 01039 thispathresult.append('%d'%thisl1pass) 01040 thishltaccept=thispathinfo[3] 01041 if thispathinfo[3] is None: 01042 thispathresult.append('n/a') 01043 else: 01044 thispathresult.append('%d'%thishltaccept) 01045 01046 thispathresultStr='('+','.join(thispathresult)+')' 01047 allpathresult.append(thispathresultStr) 01048 result.append([str(run),str(cmslsnum),', '.join(allpathresult)]) 01049 01050 if not toFile: 01051 print ' == = ' 01052 labels = [('Run', 'LS', '(hltpath,presc,l1pass,hltaccept)')] 01053 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False, 01054 prefix = '| ', postfix = ' |', justify = 'left', 01055 delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,70) ) 01056 else: 01057 fieldnames=['Run','LS','(hltpath,presc,l1pass,hltaccept)'] 01058 filename=toFile 01059 dumptocsv(fieldnames,result,filename)
def lumiReport::toScreenLSTrg | ( | trgdata, | |
iresults = [] , |
|||
irunlsdict = None , |
|||
noWarning = True , |
|||
toFile = None , |
|||
withoutmask = False |
|||
) |
input:{run:[[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(name,count,presc,mask),]],..]
Definition at line 942 of file lumiReport.py.
00943 : 00944 ''' 00945 input:{run:[[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(name,count,presc,mask),]],..] 00946 ''' 00947 result=[] 00948 datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with 00949 for rline in iresults: 00950 runnumStr=rline[0] 00951 cmslsnumStr=rline[1] 00952 if irunlsdict and not noWarning: 00953 if runnumStr is not 'n/a' and not datarunlsdict.has_key(int(runnumStr)): 00954 datarunlsdict[int(runnumstr)]=[] 00955 if cmslsnumStr!='n/a': 00956 datarunlsdict[int(runnumStr)].append(int(cmslsnumStr)) 00957 result.append(rline) 00958 for run in trgdata.keys(): 00959 rundata=trgdata[run] 00960 if not rundata: 00961 ll=[str(run),'n/a','n/a','n/a'] 00962 result.append(ll) 00963 if irunlsdict and not noWarning: 00964 print '[WARNING] selected but no trg data for run '+str(run) 00965 continue 00966 if irunlsdict and not noWarning: 00967 existdata=[x[0] for x in rundata if x[0] ] 00968 datarunlsdict[run]=existdata 00969 deadfrac=0.0 00970 bitdataStr='n/a' 00971 for lsdata in rundata: 00972 cmslsnum=lsdata[0] 00973 deadfrac=lsdata[1] 00974 deadcount=lsdata[2] 00975 bitdata=lsdata[5]# already sorted by name 00976 if bitdata: 00977 if withoutmask: 00978 flatbitdata=["("+x[0]+',%d'%x[1]+',%d'%x[2]+")" for x in bitdata if x[0]!='False'] 00979 bitdataStr=' '.join(flatbitdata) 00980 else: 00981 #consider trg mask by default 00982 flatbitdata=["("+x[0]+',%d'%x[1]+',%d'%x[2]+")" for x in bitdata if x[0]!='False' and x[3]] 00983 bitdataStr=' '.join(flatbitdata) 00984 if irunlsdict and irunlsdict[run]: 00985 if run in irunlsdict and cmslsnum in irunlsdict[run]: 00986 result.append([str(run),str(cmslsnum),'%.4f'%(deadfrac),bitdataStr]) 00987 else: 00988 result.append([str(run),str(cmslsnum),'%.4f'%(deadfrac),bitdataStr]) 00989 if irunlsdict and not noWarning: 00990 for run,cmslslist in irunlsdict.items(): 00991 if run not in datarunlsdict.keys() or datarunlsdict[run] is None: 00992 sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no qualified data\n') 00993 continue 00994 if cmslslist: 00995 for ss in cmslslist: 00996 if ss not in datarunlsdict[run]: 00997 sys.stdout.write('[WARNING] selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB\n') 00998 00999 if not toFile: 01000 print ' == = ' 01001 labels = [('Run', 'LS', 'dfrac','(bitname,count,presc)')] 01002 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,70) ) 01003 else: 01004 filename=toFile 01005 fieldnames=['Run','LS','dfrac','(bitname,count,presc)'] 01006 dumptocsv(fieldnames,result,filename)
def lumiReport::toScreenLumiByLS | ( | lumidata, | |
resultlines, | |||
scalefactor, | |||
irunlsdict = None , |
|||
noWarning = True , |
|||
toFile = None |
|||
) |
input: lumidata {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),pu(11)]} {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 resultlines [[resultrow1],[resultrow2],...,] existing result row
Definition at line 392 of file lumiReport.py.
00393 : 00394 ''' 00395 input: 00396 lumidata {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),pu(11)]} 00397 {run:None} None means no run in lumiDB, 00398 {run:[]} [] means no lumi for this run in lumiDB 00399 {run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB 00400 {run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0 00401 resultlines [[resultrow1],[resultrow2],...,] existing result row 00402 ''' 00403 result=[] 00404 totalrow = [] 00405 00406 totalDeliveredLS = 0 00407 totalSelectedLS = 0 00408 totalDelivered = 0.0 00409 totalRecorded = 0.0 00410 00411 totOldDeliveredLS = 0 00412 totOldSelectedLS = 0 00413 totOldDelivered = 0.0 00414 totOldRecorded = 0.0 00415 00416 maxlslumi = 0.0 00417 datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with 00418 for rline in resultlines: 00419 runfillstr=rline[0] 00420 [runnumstr,fillnumstr]=runfillstr.split(':') 00421 if irunlsdict and not noWarning: 00422 if rline[1] is not 'n/a': 00423 datarunlsdict[int(runnumstr)]=[] 00424 myls=rline[1] 00425 if myls!='n/a': 00426 [luls,cmls]=myls.split(':') 00427 totOldDeliveredLS+=1 00428 if cmls!='0': 00429 totOldSelectedLS+=1 00430 if irunlsdict and not noWarning: 00431 datarunlsdict[int(runnumstr)].append(int(myls)) 00432 dl=rline[5] 00433 if rline[5]!='n/a': 00434 dl=float(rline[5])#delivered in /ub 00435 if dl>maxlslumi: maxlslumi=dl 00436 rline[5]=dl 00437 totOldDelivered+=dl 00438 rl=rline[6] 00439 if rline[6]!='n/a': 00440 rl=float(rline[6])#recorded in /ub 00441 rline[6]=rl 00442 totOldRecorded+=rl 00443 result.append(rline) 00444 00445 for run in lumidata.keys(): 00446 lsdata=lumidata[run] 00447 if not lsdata: 00448 #result.append([str(run),'n/a','n/a','n/a','n/a','n/a','n/a','n/a']) 00449 if irunlsdict and irunlsdict[run] and not noWarning: 00450 datarunlsdict[run]=None 00451 #print '[WARNING] selected but no lumi data for run '+str(run) 00452 continue 00453 fillnum=0 00454 if lsdata[0] and lsdata[0][10]: 00455 fillnum=lsdata[0][10] 00456 existdata=[] 00457 #if irunlsdict and not noWarning: 00458 # existdata=[x[1] for x in rundata if x[1] ] 00459 # datarunlsdict[run]=existdata 00460 for perlsdata in lsdata: 00461 lumilsnum=perlsdata[0] 00462 cmslsnum=perlsdata[1]#triggered ls 00463 if not noWarning: 00464 if cmslsnum: 00465 existdata.append(cmslsnum) 00466 ts=perlsdata[2] 00467 bs=perlsdata[3] 00468 begev=perlsdata[4] 00469 deliveredlumi=perlsdata[5] 00470 npu=perlsdata[11] 00471 if deliveredlumi>maxlslumi: maxlslumi=deliveredlumi 00472 recordedlumi=0. 00473 if perlsdata[6]: 00474 recordedlumi=perlsdata[6] 00475 if irunlsdict and irunlsdict[run]: 00476 if run in irunlsdict and lumilsnum in irunlsdict[run]: 00477 result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),ts.strftime('%m/%d/%y %H:%M:%S'),bs,'%.1f'%begev,deliveredlumi,recordedlumi,npu]) 00478 totalDelivered+=deliveredlumi 00479 totalRecorded+=recordedlumi 00480 totalDeliveredLS+=1 00481 totalSelectedLS+=1 00482 else: 00483 result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),ts.strftime('%m/%d/%y %H:%M:%S'),bs,'%.1f'%begev,deliveredlumi,recordedlumi,npu]) 00484 totalDelivered+=deliveredlumi 00485 totalRecorded+=recordedlumi 00486 totalDeliveredLS+=1 00487 if cmslsnum : 00488 totalSelectedLS+=1 00489 datarunlsdict[run]=existdata 00490 sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0])) 00491 if irunlsdict and not noWarning: 00492 for run,cmslslist in irunlsdict.items(): 00493 if run not in datarunlsdict.keys() or datarunlsdict[run] is None: 00494 sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no qualified data\n') 00495 continue 00496 if cmslslist: 00497 for ss in cmslslist: 00498 if ss not in datarunlsdict[run]: 00499 sys.stdout.write('[WARNING] lumi or trg for selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB\n') 00500 if not toFile: 00501 (lsunitstring,unitdenomitor)=CommonUtil.lumiUnitForPrint(maxlslumi*scalefactor) 00502 labels = [ ('Run:Fill','LS','UTCTime','Beam Status','E(GeV)','Del('+lsunitstring+')','Rec('+lsunitstring+')','avgPU') ] 00503 perlsresult=[] 00504 for entry in sortedresult: 00505 delumi=entry[5] 00506 if delumi!='n/a': 00507 delumi='%.3f'%float(float(delumi*scalefactor)/float(unitdenomitor)) 00508 reclumi=entry[6] 00509 if reclumi!='n/a': 00510 reclumi='%.3f'%float(float(reclumi*scalefactor)/float(unitdenomitor)) 00511 avgPU=entry[7] 00512 if avgPU!='n/a': 00513 if avgPU>0: 00514 avgPU='%.3f'%avgPU 00515 else: 00516 avgPU='0' 00517 perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],delumi,reclumi,avgPU]) 00518 totdeliveredlumi=0.0 00519 deliveredlumiunit='/ub' 00520 (totdeliveredlumi,deliveredlumiunit)=CommonUtil.guessUnit((totalDelivered+totOldDelivered)*scalefactor) 00521 totrecordedlumi=0.0 00522 recordedlumiunit='/ub' 00523 (totrecordedlumi,recordedlumiunit)=CommonUtil.guessUnit((totalRecorded+totOldRecorded)*scalefactor) 00524 lastrowlabels = [ ('Delivered LS','Selected LS', 'Delivered('+deliveredlumiunit+')', 'Recorded('+recordedlumiunit+')')] 00525 totalrow.append ([str(totalDeliveredLS+totOldDeliveredLS),str(totalSelectedLS+totOldSelectedLS),'%.3f'%(totdeliveredlumi),'%.3f'%(totrecordedlumi)]) 00526 print ' == = ' 00527 print tablePrinter.indent (labels+perlsresult, hasHeader = True, separateRows = False, prefix = '| ', 00528 postfix = ' |', justify = 'right', delim = ' | ', 00529 wrapfunc = lambda x: wrap_onspace_strict (x, 22)) 00530 print ' == = Total : ' 00531 print tablePrinter.indent (lastrowlabels+totalrow, hasHeader = True, separateRows = False, prefix = '| ', 00532 postfix = ' |', justify = 'right', delim = ' | ', 00533 wrapfunc = lambda x: wrap_onspace (x, 20)) 00534 else: 00535 fieldnames=['Run:Fill','LS','UTCTime','Beam Status','E(GeV)','Delivered(/ub)','Recorded(/ub)','avgPU'] 00536 filename=toFile 00537 dumptocsv(fieldnames,sortedresult,filename)
def lumiReport::toScreenNormDetail | ( | normname, | |
norminfo, | |||
normvalues | |||
) |
list norm detail input: normname norminfo=[data_id[0],lumitype(1)istypedefault[2],comment[3],creationtime[4]] normvalues={since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
Definition at line 76 of file lumiReport.py.
00077 : 00078 ''' 00079 list norm detail 00080 input: 00081 normname 00082 norminfo=[data_id[0],lumitype(1)istypedefault[2],comment[3],creationtime[4]] 00083 normvalues={since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} 00084 ''' 00085 lumitype=norminfo[1] 00086 istypedefault=norminfo[2] 00087 print '==========================================================' 00088 print '* Norm: '+normname 00089 print '* Type: '+lumitype 00090 print '* isDefault: '+str(istypedefault) 00091 print '==========================================================' 00092 labels=[('Since','Func','Parameters','amodetag','egev','comment')] 00093 00094 result=[] 00095 print ' == = ' 00096 for since in sorted(normvalues): 00097 normdata=normvalues[since] 00098 correctorStr=normdata[0] 00099 paramDict=normdata[1] 00100 paramDictStr='' 00101 count=0 00102 for pname in sorted(paramDict): 00103 pval=paramDict[pname] 00104 if count!=0: 00105 paramDictStr+=' ' 00106 try: 00107 fpval=float(pval) 00108 if fpval<1.: 00109 paramDictStr+=pname+':'+'%.4f'%fpval 00110 else: 00111 paramDictStr+=pname+':'+'%.2f'%fpval 00112 except ValueError: 00113 paramDictStr+=pname+':'+pval 00114 count+=1 00115 amodetag=normdata[2] 00116 egev=str(normdata[3]) 00117 comment=normdata[4] 00118 result.append([str(since),correctorStr,paramDictStr,amodetag,egev,comment]) 00119 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,40) )
def lumiReport::toScreenNormSummary | ( | allnorms | ) |
list all known norms summary input: {normname:[data_id(0),lumitype(1),istypedefault(2),comment(3),creationtime(4)]}
Definition at line 59 of file lumiReport.py.
00060 : 00061 ''' 00062 list all known norms summary 00063 input: {normname:[data_id(0),lumitype(1),istypedefault(2),comment(3),creationtime(4)]} 00064 ''' 00065 result=[] 00066 labels=[('Name','Type','IsTypeDefault','Comment','CreationTime')] 00067 print ' == = ' 00068 sorted_allnorms=sorted(allnorms.iteritems(),key=lambda x:x[0],reverse=True) 00069 for (normname,normvalues) in sorted_allnorms: 00070 lumitype=normvalues[1] 00071 istypedefault=str(normvalues[2]) 00072 commentStr=normvalues[3] 00073 creationtime=normvalues[4] 00074 result.append([normname,lumitype,istypedefault,commentStr,creationtime]) 00075 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) )
def lumiReport::toScreenOverview | ( | lumidata, | |
resultlines, | |||
scalefactor, | |||
irunlsdict = None , |
|||
noWarning = True , |
|||
toFile = None |
|||
) |
input: lumidata {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)]} resultlines [[resultrow1],[resultrow2],...,] existing result row
Definition at line 260 of file lumiReport.py.
00261 : 00262 ''' 00263 input: 00264 lumidata {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)]} 00265 resultlines [[resultrow1],[resultrow2],...,] existing result row 00266 ''' 00267 result=[] 00268 00269 totOldDeliveredLS=0 00270 totOldSelectedLS=0 00271 totOldDelivered=0.0 00272 totOldRecorded=0.0 00273 00274 totaltable=[] 00275 totalDeliveredLS = 0 00276 totalSelectedLS = 0 00277 totalDelivered = 0.0 00278 totalRecorded = 0.0 00279 datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with 00280 for r in resultlines: 00281 runfillstr=r[0] 00282 [runnumstr,fillnumstr]=runfillstr.split(':') 00283 if irunlsdict and not noWarning: 00284 if r[1] is not 'n/a': 00285 datarunlsdict[int(runnumstr)]=[] 00286 dl=0.0 00287 if(r[2]!='n/a'): 00288 dl=float(r[2])#delivered in /ub because it comes from file! 00289 (rr,lumiu)=CommonUtil.guessUnit(dl) 00290 r[2]='%.3f'%(rr)+' ('+lumiu+')' 00291 dls=0 00292 if(r[1]!='n/a'): 00293 dls=int(r[1]) 00294 totOldDeliveredLS+=dls 00295 totOldDelivered+=dl 00296 rls=0 00297 if(r[3]!='n/a'): 00298 rlsstr=r[3] 00299 listcomp=rlsstr.split(', ') 00300 for lstr in listcomp: 00301 enddigs=lstr[1:-1].split('-') 00302 lsmin=int(enddigs[0]) 00303 lsmax=int(enddigs[1]) 00304 rls=lsmax-lsmin+1 00305 totOldSelectedLS+=rls 00306 if(r[4]!='n/a'): 00307 rcd=float(r[4])#recorded in /ub because it comes from file! 00308 (rrcd,rlumiu)=CommonUtil.guessUnit(rcd) 00309 r[4]='%.3f'%(rrcd)+' ('+rlumiu+')' 00310 totOldRecorded+=rcd 00311 result.append(r) 00312 for run in lumidata.keys(): 00313 lsdata=lumidata[run] 00314 if not lsdata: 00315 result.append([str(run)+':0','n/a','n/a','n/a','n/a']) 00316 if irunlsdict and irunlsdict[run] and not noWarning: 00317 datarunlsdict[run]=None 00318 continue 00319 fillnum=0 00320 if lsdata[0] and lsdata[0][10]: 00321 fillnum=lsdata[0][10] 00322 deliveredData=[] 00323 recordedData=[] 00324 nls=0 00325 existdata=[] 00326 selectedcmsls=[] 00327 for perlsdata in lsdata: 00328 lumilsnum=perlsdata[0] 00329 cmslsnum=perlsdata[1] 00330 if not noWarning: 00331 if cmslsnum: 00332 existdata.append(cmslsnum) 00333 if irunlsdict and irunlsdict[run]: 00334 if lumilsnum and lumilsnum in irunlsdict[run]: 00335 if perlsdata[5] is not None: 00336 deliveredData.append(perlsdata[5]) 00337 if perlsdata[6]: 00338 recordedData.append(perlsdata[6]) 00339 selectedcmsls.append(lumilsnum) 00340 else: 00341 deliveredData.append(perlsdata[5]) 00342 if perlsdata[6]: 00343 recordedData.append(perlsdata[6]) 00344 if cmslsnum: 00345 selectedcmsls.append(cmslsnum) 00346 datarunlsdict[run]=existdata 00347 nls=len(deliveredData) 00348 totdelivered=sum(deliveredData) 00349 totalDelivered+=totdelivered 00350 totalDeliveredLS+=len(deliveredData) 00351 (totdeliveredlumi,deliveredlumiunit)=CommonUtil.guessUnit(totdelivered) 00352 totrecorded=sum(recordedData) 00353 totalRecorded+=totrecorded 00354 (totrecordedlumi,recordedlumiunit)=CommonUtil.guessUnit(totrecorded) 00355 totalSelectedLS+=len(selectedcmsls) 00356 if len(selectedcmsls)==0: 00357 selectedlsStr='n/a' 00358 else: 00359 selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls) 00360 if not toFile: 00361 result.append([str(run)+':'+str(fillnum),str(nls),'%.3f'%(totdeliveredlumi*scalefactor)+' ('+deliveredlumiunit+')',selectedlsStr,'%.3f'%(totrecordedlumi*scalefactor)+' ('+recordedlumiunit+')']) 00362 else: 00363 result.append([str(run)+':'+str(fillnum),nls,totdelivered*scalefactor,selectedlsStr,totrecorded*scalefactor]) 00364 sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0])) 00365 if irunlsdict and not noWarning: 00366 for run,cmslslist in irunlsdict.items(): 00367 if run not in datarunlsdict.keys() or datarunlsdict[run] is None: 00368 sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no qualified data\n') 00369 continue 00370 if cmslslist: 00371 for ss in cmslslist: 00372 if ss not in datarunlsdict[run]: 00373 sys.stdout.write('[WARNING] lumi or trg for selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB\n') 00374 if not toFile: 00375 labels = [('Run:Fill', 'Delivered LS', 'Delivered','Selected LS','Recorded')] 00376 print ' == = ' 00377 print tablePrinter.indent (labels+sortedresult, hasHeader = True, separateRows = False, 00378 prefix = '| ', postfix = ' |', justify = 'right', 00379 delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) ) 00380 print ' == = Total : ' 00381 (totalDeliveredVal,totalDeliveredUni)=CommonUtil.guessUnit(totalDelivered+totOldDelivered) 00382 (totalRecordedVal,totalRecordedUni)=CommonUtil.guessUnit(totalRecorded+totOldRecorded) 00383 totrowlabels = [('Delivered LS','Delivered('+totalDeliveredUni+')','Selected LS','Recorded('+totalRecordedUni+')')] 00384 totaltable.append([str(totalDeliveredLS+totOldDeliveredLS),'%.3f'%(totalDeliveredVal*scalefactor),str(totalSelectedLS+totOldSelectedLS),'%.3f'%(totalRecordedVal*scalefactor)]) 00385 print tablePrinter.indent (totrowlabels+totaltable, hasHeader = True, separateRows = False, prefix = '| ', 00386 postfix = ' |', justify = 'right', delim = ' | ', 00387 wrapfunc = lambda x: wrap_onspace (x, 20)) 00388 else: 00389 fieldnames = ['Run:Fill', 'DeliveredLS', 'Delivered(/ub)','SelectedLS','Recorded(/ub)'] 00390 filename=toFile 00391 dumptocsv(fieldnames,sortedresult,filename)
def lumiReport::toScreenSingleTag | ( | taginfo | ) |
input: {run:(lumidataid,trgdataid,hltdataid,comment)}
Definition at line 135 of file lumiReport.py.
00136 : 00137 ''' 00138 input: {run:(lumidataid,trgdataid,hltdataid,comment)} 00139 ''' 00140 result=[] 00141 labels=[('Run','Data Id','Insertion Time','Patch Comment')] 00142 print ' == = ' 00143 for run in sorted(taginfo): 00144 (lumidataid,trgdataid,hltdataid,(ctimestr,comment))=taginfo[run] 00145 payloadid='-'.join([str(lumidataid),str(trgdataid),str(hltdataid)]) 00146 result.append([str(run),payloadid,ctimestr,comment]) 00147 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,25) )
def lumiReport::toScreenTags | ( | tagdata | ) |
Definition at line 120 of file lumiReport.py.
00121 : 00122 result=[] 00123 labels=[('Name','Min Run','Max Run','Creation Time')] 00124 print ' == = ' 00125 for tagid in sorted(tagdata): 00126 taginfo=tagdata[tagid] 00127 name=taginfo[0] 00128 minRun=str(taginfo[1]) 00129 maxRun='Open' 00130 if taginfo[2]!=0: 00131 maxRun=str(taginfo[2]) 00132 creationtime=taginfo[3] 00133 result.append([name,minRun,maxRun,creationtime]) 00134 print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) )
def lumiReport::toScreenTotDelivered | ( | lumidata, | |
resultlines, | |||
scalefactor, | |||
irunlsdict = None , |
|||
noWarning = True , |
|||
toFile = None |
|||
) |
inputs: lumidata {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierror(6),(bxidx,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum)(9)]} resultlines [[resultrow1],[resultrow2],...,] existing result row ('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)') irunlsdict: run/ls selection list. irunlsdict=None means no filter
Definition at line 148 of file lumiReport.py.
00149 : 00150 ''' 00151 inputs: 00152 lumidata {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierror(6),(bxidx,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum)(9)]} 00153 resultlines [[resultrow1],[resultrow2],...,] existing result row 00154 ('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)') 00155 irunlsdict: run/ls selection list. irunlsdict=None means no filter 00156 ''' 00157 result=[] 00158 totOldDeliveredLS=0 00159 totOldCMSLS=0 00160 totOldDelivered=0.0 00161 datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with 00162 for r in resultlines: 00163 runfillstr=r[0] 00164 [runnumstr,fillnumstr]=runfillstr.split(':') 00165 if irunlsdict and not noWarning: 00166 if r[1] is not 'n/a': 00167 datarunlsdict[int(runnumstr)]=[] 00168 dl=0.0 00169 if(r[3]!='n/a'): #delivered 00170 dl=float(r[3])#in /ub because it comes from file! 00171 (rr,lumiu)=CommonUtil.guessUnit(dl) 00172 r[3]='%.3f'%(rr)+' ('+lumiu+')' 00173 sls=0 00174 if(r[1]!='n/a'): #n_ls 00175 sls=int(r[1]) 00176 totcmsls=0 00177 if(r[2]!='n/a'):#n_cmsls 00178 totcmsls=int(r[2]) 00179 totOldDeliveredLS+=sls 00180 totOldCMSLS+=totcmsls 00181 totOldDelivered+=dl 00182 if(r[5]!='n/a'): #egev 00183 egv=float(r[5]) 00184 r[5]='%.1f'%egv 00185 result.append(r) 00186 totls=0 00187 totcmsls=0 00188 totdelivered=0.0 00189 totaltable=[] 00190 for run in lumidata.keys(): 00191 lsdata=lumidata[run] 00192 if not lsdata: 00193 result.append([str(run)+':0','n/a','n/a','n/a','n/a','n/a']) 00194 if irunlsdict and not noWarning: 00195 datarunlsdict[run]=None 00196 continue 00197 fillnum=0 00198 if lsdata[0] and lsdata[0][9]: 00199 fillnum=lsdata[0][9] 00200 deliveredData=[] 00201 nls=0 00202 existdata=[] 00203 selectedcmsls=[] 00204 for perlsdata in lsdata: 00205 lumilsnum=perlsdata[0] 00206 cmslsnum=perlsdata[1] 00207 if not noWarning: 00208 if cmslsnum: 00209 existdata.append(cmslsnum) 00210 if irunlsdict and irunlsdict[run]: 00211 if lumilsnum and lumilsnum in irunlsdict[run]: 00212 deliveredData.append(perlsdata[5]) 00213 if cmslsnum: 00214 selectedcmsls.append(cmslsnum) 00215 else: 00216 deliveredData.append(perlsdata[5]) 00217 if cmslsnum: 00218 selectedcmsls.append(cmslsnum) 00219 datarunlsdict[run]=existdata 00220 nls=len(deliveredData) 00221 ncmsls=0 00222 if selectedcmsls: 00223 ncmsls=len(selectedcmsls) 00224 totcmsls+=ncmsls 00225 totls+=nls 00226 totlumi=sum(deliveredData) 00227 totdelivered+=totlumi 00228 (totlumival,lumiunit)=CommonUtil.guessUnit(totlumi) 00229 beamenergyPerLS=[float(x[4]) for x in lsdata if x[3]=='STABLE BEAMS'] 00230 avgbeamenergy=0.0 00231 if len(beamenergyPerLS): 00232 avgbeamenergy=sum(beamenergyPerLS)/len(beamenergyPerLS) 00233 runstarttime='n/a' 00234 if lsdata[0] and lsdata[0][2]: 00235 runstarttime=lsdata[0][2] 00236 runstarttime=runstarttime.strftime("%m/%d/%y %H:%M:%S") 00237 if not toFile: 00238 result.append([str(run)+':'+str(fillnum),str(nls),str(ncmsls),'%.3f'%(totlumival*scalefactor)+' ('+lumiunit+')',runstarttime,'%.1f'%(avgbeamenergy)]) 00239 else: 00240 result.append([str(run)+':'+str(fillnum),str(nls),str(ncmsls),(totlumi*scalefactor),runstarttime,'%.1f'%(avgbeamenergy)]) 00241 sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0])) 00242 #print 'sortedresult ',sortedresult 00243 if not toFile: 00244 labels = [('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)')] 00245 print ' == = ' 00246 print tablePrinter.indent (labels+sortedresult, hasHeader = True, separateRows = False, 00247 prefix = '| ', postfix = ' |', justify = 'right', 00248 delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,40) ) 00249 print ' == = Total : ' 00250 (totalDeliveredVal,totalDeliveredUni)=CommonUtil.guessUnit(totdelivered+totOldDelivered) 00251 totrowlabels = [('Delivered LS','Total CMS LS','Delivered('+totalDeliveredUni+')')] 00252 totaltable.append([str(totls+totOldDeliveredLS),str(totcmsls+totOldCMSLS),'%.3f'%(totalDeliveredVal*scalefactor)]) 00253 print tablePrinter.indent (totrowlabels+totaltable, hasHeader = True, separateRows = False, prefix = '| ', 00254 postfix = ' |', justify = 'right', delim = ' | ', 00255 wrapfunc = lambda x: wrap_onspace (x, 20)) 00256 else: 00257 fieldnames = ['Run:Fill', 'N_LS','N_CMSLS','Delivered(/ub)','UTCTime','E(GeV)'] 00258 filename=toFile 00259 dumptocsv(fieldnames,sortedresult,filename)
def lumiReport::toScreenTotEffective | ( | lumidata, | |
resultlines, | |||
scalefactor, | |||
irunlsdict = None , |
|||
noWarning = True , |
|||
toFile = None |
|||
) |
input: {run:[lumilsnum(0),triggeredls(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)} screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective
Definition at line 692 of file lumiReport.py.
00693 : 00694 00695 ''' 00696 input: {run:[lumilsnum(0),triggeredls(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)} 00697 screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective 00698 ''' 00699 result=[]#[run,selectedlsStr,recordedofthisrun,hltpath,l1bit,efflumi] 00700 00701 totdict={}#{hltpath:[nls,toteff]} 00702 selectedcmsls=[] 00703 alltotrecorded=0.0 00704 alleffective=0.0 00705 recordedPerpathPerrun={}#{path:{run:recorded}} 00706 selectedPerpathPerrun={}#{path:{run:totselected}} 00707 datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with 00708 for rline in resultlines: 00709 runfillstr=rline[0] 00710 [runnumstr,fillnumstr]=runfillstr.split(':') 00711 myls=rline[1] 00712 if irunlsdict and not noWarning: 00713 if myls is not 'n/a': 00714 datarunlsdict[int(runnumstr)]=[] 00715 mypath=rline[3] 00716 if mypath!='n/a': 00717 mypath=mypath.split('(')[0] 00718 if not totdict.has_key(mypath): 00719 totdict[mypath]=[0,0.0] 00720 recordedPerpathPerrun[mypath]={} 00721 selectedPerpathPerrun[mypath]={} 00722 if myls!='n/a': 00723 listcomp=myls.split(', ') 00724 for lstr in listcomp: 00725 enddigs=lstr[1:-1].split('-') 00726 lsmin=int(enddigs[0]) 00727 lsmax=int(enddigs[1]) 00728 rls=lsmax-lsmin+1 00729 totdict[mypath][0]+=rls 00730 selectedPerrun[mypath].setdefault(int(myrun),totdict[mypath][0]) 00731 myrecorded=rline[2] 00732 if myrecorded!='n/a': 00733 recordedPerpathPerrun[mypath].setdefault(int(myrun),float(myrecorded)) 00734 (rr,lumiu)=CommonUtil.guessUnit(float(myrecorded)) 00735 rline[2]='%.3f'%(rr)+' ('+lumiu+')' 00736 myeff=rline[5] 00737 if myeff!='n/a': 00738 reff=float(myeff) 00739 (rr,lumiu)=CommonUtil.guessUnit(float(reff)) 00740 rline[5]='%.3f'%(rr)+' ('+lumiu+')' 00741 totdict[mypath][1]+=reff 00742 result.append(rline) 00743 for run in lumidata.keys():#loop over runs 00744 lsdata=lumidata[run] 00745 hprescdict={} 00746 lprescdict={} 00747 if not lsdata: 00748 result.append([str(run),'n/a','n/a','n/a','n/a','n/a']) 00749 if irunlsdict and irunlsdict[run] and not noWarning: 00750 datarunlsdict[run]=None 00751 continue 00752 fillnum=0 00753 if lsdata[0] and lsdata[0][11]: 00754 fillnum=lsdata[0][11] 00755 selectedcmsls=[x[1] for x in lsdata if x[1]] 00756 totefflumiDict={} 00757 totrecorded=0.0 00758 toteffective=0.0 00759 pathmap={}#{hltpathname:1lname} 00760 existdata=[] 00761 for thisls in lsdata: 00762 cmslsnum=thisls[1] 00763 if not noWarning: 00764 if cmslsnum: 00765 existdata.append(cmslsnum) 00766 efflumiDict=thisls[8]# this ls has no such path? 00767 recordedlumi=0.0 00768 if thisls[6]: 00769 recordedlumi=thisls[6] 00770 totrecorded+=recordedlumi 00771 if not efflumiDict:#no hltdata for this LS 00772 lumival=0. 00773 if cmslsnum in selectedcmsls: 00774 selectedcmsls.remove(cmslsnum) 00775 continue 00776 for hltpathname in sorted(efflumiDict): 00777 pathdata=efflumiDict[hltpathname] 00778 if not totefflumiDict.has_key(hltpathname): 00779 totefflumiDict[hltpathname]=0.0 00780 pathmap[hltpathname]='n/a' 00781 l1name=pathdata[0] 00782 l1presc=pathdata[1] 00783 hltpresc=pathdata[2] 00784 lumival=pathdata[3] 00785 recordedPerpathPerrun.setdefault(hltpathname,{}) 00786 selectedPerpathPerrun.setdefault(hltpathname,{}) 00787 if not totdict.has_key(hltpathname): 00788 totdict[hltpathname]=[0,0.0] 00789 if l1presc is None or hltpresc is None:#if found all null prescales and if it is in the selectedcmsls, remove it because incomplete 00790 if cmslsnum in selectedcmsls: 00791 selectedcmsls.remove(cmslsnum) 00792 else: 00793 if not hprescdict.has_key(hltpathname): 00794 hprescdict[hltpathname]=[] 00795 hprescdict[hltpathname].append(hltpresc) 00796 if not lprescdict.has_key(l1name): 00797 lprescdict[l1name]=[] 00798 lprescdict[l1name].append(l1presc) 00799 if cmslsnum!=0: 00800 totdict[hltpathname][0]+=1 00801 if lumival: 00802 totdict[hltpathname][1]+=lumival 00803 totefflumiDict[hltpathname]+=lumival 00804 pathmap[hltpathname]=l1name 00805 recordedPerpathPerrun[hltpathname][run]=totrecorded 00806 selectedPerpathPerrun[hltpathname][run]=len(selectedcmsls) 00807 if len(selectedcmsls)==0: 00808 selectedlsStr='n/a' 00809 else: 00810 selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls) 00811 if irunlsdict and not noWarning: 00812 datarunlsdict[run]=selectedcmsls 00813 00814 for name in sorted(totefflumiDict): 00815 lname=pathmap[name] 00816 totrecordedinrun=recordedPerpathPerrun[name][run] 00817 hprescs=list(set(hprescdict[name])) 00818 hprescStr='('+','.join(['%d'%(x) for x in hprescs])+')' 00819 (totrecval,totrecunit)=CommonUtil.guessUnit(totrecordedinrun*scalefactor) 00820 effval='n/a' 00821 00822 effvalStr='n/a' 00823 lprescStr='n/a' 00824 cleanlname='' 00825 if lname!='n/a': 00826 effval=totefflumiDict[name]*scalefactor 00827 lprescs=list(set(lprescdict[lname])) 00828 lprescStr='('+','.join(['%d'%(x) for x in lprescs])+')' 00829 cleanlname=lname.replace('"','') 00830 (efflumival,efflumiunit)=CommonUtil.guessUnit(effval) 00831 effvalStr='%.3f'%(efflumival)+'('+efflumiunit+')' 00832 if not toFile: 00833 result.append([str(run)+':'+str(fillnum),selectedlsStr,'%.3f'%(totrecval)+'('+totrecunit+')',name+hprescStr,cleanlname+lprescStr,effvalStr]) 00834 else: 00835 result.append([str(run)+':'+str(fillnum),selectedlsStr,totrecordedinrun*scalefactor,name+hprescStr,cleanlname+lprescStr,effval]) 00836 00837 if irunlsdict and not noWarning: 00838 for run,cmslslist in irunlsdict.items(): 00839 if run not in datarunlsdict.keys() or datarunlsdict[run] is None: 00840 sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no HLT data\n') 00841 continue 00842 if cmslslist: 00843 for ss in cmslslist: 00844 if ss not in datarunlsdict[run]: 00845 sys.stdout.write('[WARNING] selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB or has no HLT data\n') 00846 00847 sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0])) 00848 00849 if not toFile: 00850 labels = [('Run:Fill','SelectedLS','Recorded','HLTpath(Presc)','L1bit(Presc)','Effective')] 00851 print ' == = ' 00852 print tablePrinter.indent (labels+sortedresult, hasHeader = True, separateRows = False, 00853 prefix = '| ', postfix = ' |', justify = 'right', 00854 delim = ' | ', wrapfunc = lambda x: wrap_onspace_strict(x,22) ) 00855 print ' == = Total : ' 00856 lastrowlabels=[('HLTPath','SelectedLS','Recorded','Effective')] 00857 totresult=[] 00858 for hname in sorted(totdict): 00859 hdata=totdict[hname] 00860 totnls=hdata[0] 00861 (toteffval,toteffunit)=CommonUtil.guessUnit(hdata[1]*scalefactor) 00862 alltotrecorded=0.0 00863 selectedThispath=selectedPerpathPerrun[hname] 00864 for runnumber,nselected in selectedThispath.items(): 00865 if nselected==0: continue 00866 alltotrecorded+=recordedPerpathPerrun[hname][runnumber] 00867 (alltotrecordedVal,alltotrecordedunit)=CommonUtil.guessUnit(alltotrecorded*scalefactor) 00868 totresult.append([hname,str(totnls),'%.3f'%(alltotrecordedVal)+'('+alltotrecordedunit+')','%.3f'%(toteffval)+'('+toteffunit+')']) 00869 print tablePrinter.indent (lastrowlabels+totresult, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'right', 00870 delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) ) 00871 else: 00872 fieldnames=['Run:Fill','SelectedLS','Recorded','HLTpath(Presc)','L1bit(Presc)','Effective(/ub)'] 00873 filename=toFile 00874 dumptocsv(fieldnames,sortedresult,filename)