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