1 from __future__
import print_function
9 from RecoLuminosity.LumiDB
import tablePrinter, csvReporter,CommonUtil
10 from RecoLuminosity.LumiDB.wordWrappers
import wrap_always, wrap_onspace, wrap_onspace_strict
15 utility method to dump result to csv file 18 if filename.upper()==
'STDOUT':
20 r.write(
','.
join(fieldnames)+
'\n')
25 r.writeRow(fieldnames)
29 def toScreenHeader(commandname,datatagname,normtag,worktag,updatetag,lumitype,toFile=None):
32 commandname: commandname 35 worktag: working version 36 updatetag: updated version if amy 38 gmtnowStr=time.asctime(time.gmtime())+
' UTC' 41 updatetagStr=updatetag
42 header=
''.
join([
'*']*80)+
'\n' 43 header+=
'* '+gmtnowStr+
'\n' 44 header+=
'* lumitype: '+lumitype+
' , datatag: '+datatagname+
' , normtag: '+normtag+
' , worktag: '+worktag+
'\n' 47 header+=
'* '+commandname+
'\n' 49 header+=
'* update: '+updatetag+
'\n' 50 header+=
''.
join([
'*']*80)+
'\n' 52 sys.stdout.write(header)
55 if toFile.upper()==
'STDOUT':
63 list all known norms summary 64 input: {normname:[data_id(0),lumitype(1),istypedefault(2),comment(3),creationtime(4)]} 67 labels=[(
'Name',
'Type',
'IsTypeDefault',
'Comment',
'CreationTime')]
69 sorted_allnorms=sorted(six.iteritems(allnorms),key=
lambda x:x[0],reverse=
True)
70 for (normname,normvalues)
in sorted_allnorms:
71 lumitype=normvalues[1]
72 istypedefault=
str(normvalues[2])
73 commentStr=normvalues[3]
74 creationtime=normvalues[4]
75 result.append([normname,lumitype,istypedefault,commentStr,creationtime])
76 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
83 norminfo=[data_id[0],lumitype(1)istypedefault[2],comment[3],creationtime[4]] 84 normvalues={since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} 87 istypedefault=norminfo[2]
88 print(
'==========================================================')
89 print(
'* Norm: '+normname)
90 print(
'* Type: '+lumitype)
91 print(
'* isDefault: '+
str(istypedefault))
92 print(
'==========================================================')
93 labels=[(
'Since',
'Func',
'Parameters',
'amodetag',
'egev',
'comment')]
97 for since
in sorted(normvalues):
98 normdata=normvalues[since]
99 correctorStr=normdata[0]
100 paramDict=normdata[1]
103 for pname
in sorted(paramDict):
104 pval=paramDict[pname]
110 paramDictStr+=pname+
':'+
'%.4f'%fpval
112 paramDictStr+=pname+
':'+
'%.2f'%fpval
114 paramDictStr+=pname+
':'+pval
117 egev=
str(normdata[3])
119 result.append([
str(since),correctorStr,paramDictStr,amodetag,egev,comment])
120 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,40) ))
124 labels=[(
'Name',
'Min Run',
'Max Run',
'Creation Time')]
126 for tagid
in sorted(tagdata):
127 taginfo=tagdata[tagid]
129 minRun=
str(taginfo[1])
132 maxRun=
str(taginfo[2])
133 creationtime=taginfo[3]
134 result.append([name,minRun,maxRun,creationtime])
135 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
139 input: {run:(lumidataid,trgdataid,hltdataid,comment)} 142 labels=[(
'Run',
'Data Id',
'Insertion Time',
'Patch Comment')]
144 for run
in sorted(taginfo):
145 (lumidataid,trgdataid,hltdataid,(ctimestr,comment))=taginfo[run]
146 payloadid=
'-'.
join([
str(lumidataid),
str(trgdataid),
str(hltdataid)])
147 result.append([
str(run),payloadid,ctimestr,comment])
148 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,25) ))
153 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)]} 154 resultlines [[resultrow1],[resultrow2],...,] existing result row 155 ('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)') 156 irunlsdict: run/ls selection list. irunlsdict=None means no filter 163 for r
in resultlines:
165 [runnumstr,fillnumstr]=runfillstr.split(
':')
166 if irunlsdict
and not noWarning:
167 if r[1]
is not 'n/a':
168 datarunlsdict[
int(runnumstr)]=[]
173 r[3]=
'%.3f'%(rr)+
' ('+lumiu+
')' 180 totOldDeliveredLS+=sls
181 totOldCMSLS+=totcmsls
191 for run
in lumidata.keys():
194 result.append([
str(run)+
':0',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
195 if irunlsdict
and not noWarning:
196 datarunlsdict[run]=
None 199 if lsdata[0]
and lsdata[0][9]:
205 for perlsdata
in lsdata:
206 lumilsnum=perlsdata[0]
207 cmslsnum=perlsdata[1]
210 existdata.append(cmslsnum)
211 if irunlsdict
and irunlsdict[run]:
212 if lumilsnum
and lumilsnum
in irunlsdict[run]:
213 deliveredData.append(perlsdata[5])
215 selectedcmsls.append(cmslsnum)
217 deliveredData.append(perlsdata[5])
219 selectedcmsls.append(cmslsnum)
220 datarunlsdict[run]=existdata
221 nls=len(deliveredData)
224 ncmsls=len(selectedcmsls)
227 totlumi=sum(deliveredData)
228 totdelivered+=totlumi
230 beamenergyPerLS=[
float(x[4])
for x
in lsdata
if x[3]==
'STABLE BEAMS']
232 if len(beamenergyPerLS):
233 avgbeamenergy=sum(beamenergyPerLS)/len(beamenergyPerLS)
235 if lsdata[0]
and lsdata[0][2]:
236 runstarttime=lsdata[0][2]
237 runstarttime=runstarttime.strftime(
"%m/%d/%y %H:%M:%S")
239 result.append([
str(run)+
':'+
str(fillnum),
str(nls),
str(ncmsls),
'%.3f'%(totlumival*scalefactor)+
' ('+lumiunit+
')',runstarttime,
'%.1f'%(avgbeamenergy)])
241 result.append([
str(run)+
':'+
str(fillnum),
str(nls),
str(ncmsls),(totlumi*scalefactor),runstarttime,
'%.1f'%(avgbeamenergy)])
242 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
245 labels = [(
'Run:Fill',
'N_LS',
'N_CMSLS',
'Delivered',
'UTCTime',
'E(GeV)')]
247 print(tablePrinter.indent (labels+sortedresult, hasHeader =
True, separateRows =
False,
248 prefix =
'| ', postfix =
' |', justify =
'right',
249 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,40) ))
250 print(
' == = Total : ')
252 totrowlabels = [(
'Delivered LS',
'Total CMS LS',
'Delivered('+totalDeliveredUni+
')')]
253 totaltable.append([
str(totls+totOldDeliveredLS),
str(totcmsls+totOldCMSLS),
'%.3f'%(totalDeliveredVal*scalefactor)])
254 print(tablePrinter.indent (totrowlabels+totaltable, hasHeader =
True, separateRows =
False, prefix =
'| ',
255 postfix =
' |', justify =
'right', delim =
' | ',
256 wrapfunc =
lambda x: wrap_onspace (x, 20)))
258 fieldnames = [
'Run:Fill',
'N_LS',
'N_CMSLS',
'Delivered(/ub)',
'UTCTime',
'E(GeV)']
260 dumptocsv(fieldnames,sortedresult,filename)
262 def toScreenOverview(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
265 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)]} 266 resultlines [[resultrow1],[resultrow2],...,] existing result row 281 for r
in resultlines:
283 [runnumstr,fillnumstr]=runfillstr.split(
':')
284 if irunlsdict
and not noWarning:
285 if r[1]
is not 'n/a':
286 datarunlsdict[
int(runnumstr)]=[]
291 r[2]=
'%.3f'%(rr)+
' ('+lumiu+
')' 295 totOldDeliveredLS+=dls
300 listcomp=rlsstr.split(
', ')
301 for lstr
in listcomp:
302 enddigs=lstr[1:-1].
split(
'-')
303 lsmin=
int(enddigs[0])
304 lsmax=
int(enddigs[1])
306 totOldSelectedLS+=rls
310 r[4]=
'%.3f'%(rrcd)+
' ('+rlumiu+
')' 313 for run
in lumidata.keys():
316 result.append([
str(run)+
':0',
'n/a',
'n/a',
'n/a',
'n/a'])
317 if irunlsdict
and irunlsdict[run]
and not noWarning:
318 datarunlsdict[run]=
None 321 if lsdata[0]
and lsdata[0][10]:
322 fillnum=lsdata[0][10]
328 for perlsdata
in lsdata:
329 lumilsnum=perlsdata[0]
330 cmslsnum=perlsdata[1]
333 existdata.append(cmslsnum)
334 if irunlsdict
and irunlsdict[run]:
335 if lumilsnum
and lumilsnum
in irunlsdict[run]:
336 if perlsdata[5]
is not None:
337 deliveredData.append(perlsdata[5])
339 recordedData.append(perlsdata[6])
340 selectedcmsls.append(lumilsnum)
342 deliveredData.append(perlsdata[5])
344 recordedData.append(perlsdata[6])
346 selectedcmsls.append(cmslsnum)
347 datarunlsdict[run]=existdata
348 nls=len(deliveredData)
349 totdelivered=sum(deliveredData)
350 totalDelivered+=totdelivered
351 totalDeliveredLS+=len(deliveredData)
353 totrecorded=sum(recordedData)
354 totalRecorded+=totrecorded
356 totalSelectedLS+=len(selectedcmsls)
357 if len(selectedcmsls)==0:
362 result.append([
str(run)+
':'+
str(fillnum),
str(nls),
'%.3f'%(totdeliveredlumi*scalefactor)+
' ('+deliveredlumiunit+
')',selectedlsStr,
'%.3f'%(totrecordedlumi*scalefactor)+
' ('+recordedlumiunit+
')'])
364 result.append([
str(run)+
':'+
str(fillnum),nls,totdelivered*scalefactor,selectedlsStr,totrecorded*scalefactor])
365 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
366 if irunlsdict
and not noWarning:
367 for run,cmslslist
in irunlsdict.items():
368 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
369 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no qualified data\n')
373 if ss
not in datarunlsdict[run]:
374 sys.stdout.write(
'[WARNING] lumi or trg for selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB\n')
376 labels = [(
'Run:Fill',
'Delivered LS',
'Delivered',
'Selected LS',
'Recorded')]
378 print(tablePrinter.indent (labels+sortedresult, hasHeader =
True, separateRows =
False,
379 prefix =
'| ', postfix =
' |', justify =
'right',
380 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
381 print(
' == = Total : ')
384 totrowlabels = [(
'Delivered LS',
'Delivered('+totalDeliveredUni+
')',
'Selected LS',
'Recorded('+totalRecordedUni+
')')]
385 totaltable.append([
str(totalDeliveredLS+totOldDeliveredLS),
'%.3f'%(totalDeliveredVal*scalefactor),
str(totalSelectedLS+totOldSelectedLS),
'%.3f'%(totalRecordedVal*scalefactor)])
386 print(tablePrinter.indent (totrowlabels+totaltable, hasHeader =
True, separateRows =
False, prefix =
'| ',
387 postfix =
' |', justify =
'right', delim =
' | ',
388 wrapfunc =
lambda x: wrap_onspace (x, 20)))
390 fieldnames = [
'Run:Fill',
'DeliveredLS',
'Delivered(/ub)',
'SelectedLS',
'Recorded(/ub)']
392 dumptocsv(fieldnames,sortedresult,filename)
394 def toScreenLumiByLS(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
397 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)]} 398 {run:None} None means no run in lumiDB, 399 {run:[]} [] means no lumi for this run in lumiDB 400 {run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB 401 {run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0 402 resultlines [[resultrow1],[resultrow2],...,] existing result row 412 totOldDeliveredLS = 0
414 totOldDelivered = 0.0
419 for rline
in resultlines:
421 [runnumstr,fillnumstr]=runfillstr.split(
':')
422 if irunlsdict
and not noWarning:
423 if rline[1]
is not 'n/a':
424 datarunlsdict[
int(runnumstr)]=[]
427 [luls,cmls]=myls.split(
':')
431 if irunlsdict
and not noWarning:
436 if dl>maxlslumi: maxlslumi=dl
446 for run
in lumidata.keys():
450 if irunlsdict
and irunlsdict[run]
and not noWarning:
451 datarunlsdict[run]=
None 455 if lsdata[0]
and lsdata[0][10]:
456 fillnum=lsdata[0][10]
461 for perlsdata
in lsdata:
462 lumilsnum=perlsdata[0]
463 cmslsnum=perlsdata[1]
466 existdata.append(cmslsnum)
470 deliveredlumi=perlsdata[5]
472 if deliveredlumi>maxlslumi: maxlslumi=deliveredlumi
475 recordedlumi=perlsdata[6]
476 if irunlsdict
and irunlsdict[run]:
477 if run
in irunlsdict
and lumilsnum
in irunlsdict[run]:
478 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),ts.strftime(
'%m/%d/%y %H:%M:%S'),bs,
'%.1f'%begev,deliveredlumi,recordedlumi,npu])
479 totalDelivered+=deliveredlumi
480 totalRecorded+=recordedlumi
484 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),ts.strftime(
'%m/%d/%y %H:%M:%S'),bs,
'%.1f'%begev,deliveredlumi,recordedlumi,npu])
485 totalDelivered+=deliveredlumi
486 totalRecorded+=recordedlumi
490 datarunlsdict[run]=existdata
491 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
492 if irunlsdict
and not noWarning:
493 for run,cmslslist
in irunlsdict.items():
494 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
495 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no qualified data\n')
499 if ss
not in datarunlsdict[run]:
500 sys.stdout.write(
'[WARNING] lumi or trg for selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB\n')
503 labels = [ (
'Run:Fill',
'LS',
'UTCTime',
'Beam Status',
'E(GeV)',
'Del('+lsunitstring+
')',
'Rec('+lsunitstring+
')',
'avgPU') ]
505 for entry
in sortedresult:
518 perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],delumi,reclumi,avgPU])
520 deliveredlumiunit=
'/ub' 521 (totdeliveredlumi,deliveredlumiunit)=
CommonUtil.guessUnit((totalDelivered+totOldDelivered)*scalefactor)
523 recordedlumiunit=
'/ub' 524 (totrecordedlumi,recordedlumiunit)=
CommonUtil.guessUnit((totalRecorded+totOldRecorded)*scalefactor)
525 lastrowlabels = [ (
'Delivered LS',
'Selected LS',
'Delivered('+deliveredlumiunit+
')',
'Recorded('+recordedlumiunit+
')')]
526 totalrow.append ([
str(totalDeliveredLS+totOldDeliveredLS),
str(totalSelectedLS+totOldSelectedLS),
'%.3f'%(totdeliveredlumi),
'%.3f'%(totrecordedlumi)])
528 print(tablePrinter.indent (labels+perlsresult, hasHeader =
True, separateRows =
False, prefix =
'| ',
529 postfix =
' |', justify =
'right', delim =
' | ',
530 wrapfunc =
lambda x: wrap_onspace_strict (x, 22)))
531 print(
' == = Total : ')
532 print(tablePrinter.indent (lastrowlabels+totalrow, hasHeader =
True, separateRows =
False, prefix =
'| ',
533 postfix =
' |', justify =
'right', delim =
' | ',
534 wrapfunc =
lambda x: wrap_onspace (x, 20)))
536 fieldnames=[
'Run:Fill',
'LS',
'UTCTime',
'Beam Status',
'E(GeV)',
'Delivered(/ub)',
'Recorded(/ub)',
'avgPU']
538 dumptocsv(fieldnames,sortedresult,filename)
542 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)]} 550 totOldSelectedLSDict={}
551 totOldRecordedDict={}
552 totOldEffectiveDict={}
556 for rline
in resultlines:
558 [runnumstr,fillnumstr]=runfillstr.split(
':')
559 if irunlsdict
and not noWarning:
560 if rline[1]
is not 'n/a':
561 datarunlsdict[
int(runnumstr)]=[]
565 if myls
and myls!=
'n/a' and mpath
and mpath!=
'n/a':
566 totOldSelectedLSDict[mypath]=0
567 totOldRecordedDict[mypath]=0.
568 totOldEffectiveDict[mypath]=0.
570 [luls,cmls]=myls.split(
':')
572 if mypath
in totOldSelectedLSDict:
573 totOldSelectedLSDict[mypath]+=1
574 if irunlsdict
and not noWarning:
578 myrecorded=
float(rline[6])
579 if myrecorded>maxlslumi:maxlslumi=myrecorded
580 if mypath
in totOldRecordedDict:
581 totOldRecordedDict[mypath]+=myrecorded
585 myeff=
float(rline[7])
586 if mypath
in totOldEffectiveDict:
587 totOldEffectiveDict[mypath]+=myeff
591 for run
in lumidata.keys():
594 result.append([
str(run),
'n/a',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
595 if irunlsdict
and irunlsdict[run]
and not noWarning:
596 datarunlsdict[run]=
None 599 if lsdata[0]
and lsdata[0][11]:
600 fillnum=lsdata[0][11]
601 datarunlsdict[run]=[]
602 for thisls
in lsdata:
605 if not cmslsnum:
continue 606 efflumiDict=thisls[8]
609 recordedlumi=thisls[6]
610 if recordedlumi>maxlslumi:maxlslumi=recordedlumi
612 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),
'n/a',
'n/a',
'n/a',
'n/a',recordedlumi,
'n/a'])
615 for hltpathname
in sorted(efflumiDict):
616 if hltpathname
and hltpathname !=
'n/a' :
617 if hltpathname
not in totRecordedDict:
618 totRecordedDict[hltpathname]=0.
619 if hltpathname
not in totSelectedLSDict:
620 totSelectedLSDict[hltpathname]=0
621 if hltpathname
not in totEffectiveDict:
622 totEffectiveDict[hltpathname]=0.
623 totSelectedLSDict[hltpathname]+=1
624 totRecordedDict[hltpathname]+=recordedlumi
625 pathdata=efflumiDict[hltpathname]
629 cleanl1name=l1name.replace(
'"',
'')
632 l1presc=
str(pathdata[1])
635 hltpresc=
str(pathdata[2])
639 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),hltpathname,cleanl1name,hltpresc,l1presc,recordedlumi,lumival])
640 if hltpathname
and hltpathname !=
'n/a' :
641 totEffectiveDict[hltpathname]+=lumival
642 if irunlsdict
and not noWarning:
644 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
645 if irunlsdict
and not noWarning:
646 for run,cmslslist
in irunlsdict.items():
647 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
648 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no HLT data\n')
652 if ss
not in datarunlsdict[run]:
653 sys.stdout.write(
'[WARNING] selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB or has no qualified data\n')
657 labels = [(
'Run:Fill',
'LS',
'HLTpath',
'L1bit',
'HLTpresc',
'L1presc',
'Recorded('+lsunitstring+
')',
'Effective('+lsunitstring+
')')]
659 for entry
in sortedresult:
666 perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],entry[5],reclumi,efflumi])
668 print(tablePrinter.indent (labels+perlsresult, hasHeader =
True, separateRows =
False,
669 prefix =
'| ', postfix =
' |', justify =
'right',
671 for mpath
in sorted(totRecordedDict):
672 totSelectedLS=totSelectedLSDict[mpath]
673 if mpath
in totOldSelectedLSDict:
674 totSelectedLS+=totOldSelectedLS[mpath]
675 totRecorded=totRecordedDict[mpath]
676 if mpath
in totOldRecordedDict:
677 totRecorded+=totOldRecorded[mpath]
678 totRecorded=
float(totRecorded*scalefactor)/
float(unitdenomitor)
679 totEffective=totEffectiveDict[mpath]
680 if mpath
in totOldEffectiveDict:
681 totEffective+=totOldEffective[mpath]
682 totEffective=
float(totEffective*scalefactor)/
float(unitdenomitor)
683 totalrow.append([
str(totSelectedLS),mpath,
'%.3f'%(totRecorded),
'%.3f'%(totEffective)])
684 lastrowlabels = [ (
'Selected LS',
'HLTPath',
'Recorded('+lsunitstring+
')',
'Effective('+lsunitstring+
')')]
685 print(
' == = Total : ')
686 print(tablePrinter.indent (lastrowlabels+totalrow, hasHeader =
True, separateRows =
False, prefix =
'| ',
687 postfix =
' |', justify =
'right', delim =
' | ',
688 wrapfunc =
lambda x: wrap_onspace (x, 20)))
690 fieldnames = [
'Run:Fill',
'LS',
'HLTpath',
'L1bit',
'HLTpresc',
'L1presc',
'Recorded(/ub)',
'Effective(/ub)']
692 dumptocsv(fieldnames,sortedresult,filename)
697 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)} 698 screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective 706 recordedPerpathPerrun={}
707 selectedPerpathPerrun={}
709 for rline
in resultlines:
711 [runnumstr,fillnumstr]=runfillstr.split(
':')
713 if irunlsdict
and not noWarning:
714 if myls
is not 'n/a':
715 datarunlsdict[
int(runnumstr)]=[]
718 mypath=mypath.split(
'(')[0]
719 if mypath
not in totdict:
720 totdict[mypath]=[0,0.0]
721 recordedPerpathPerrun[mypath]={}
722 selectedPerpathPerrun[mypath]={}
724 listcomp=myls.split(
', ')
725 for lstr
in listcomp:
726 enddigs=lstr[1:-1].
split(
'-')
727 lsmin=
int(enddigs[0])
728 lsmax=
int(enddigs[1])
730 totdict[mypath][0]+=rls
731 selectedPerrun[mypath].setdefault(
int(myrun),totdict[mypath][0])
733 if myrecorded!=
'n/a':
734 recordedPerpathPerrun[mypath].setdefault(
int(myrun),
float(myrecorded))
736 rline[2]=
'%.3f'%(rr)+
' ('+lumiu+
')' 741 rline[5]=
'%.3f'%(rr)+
' ('+lumiu+
')' 742 totdict[mypath][1]+=reff
744 for run
in lumidata.keys():
749 result.append([
str(run),
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
750 if irunlsdict
and irunlsdict[run]
and not noWarning:
751 datarunlsdict[run]=
None 754 if lsdata[0]
and lsdata[0][11]:
755 fillnum=lsdata[0][11]
756 selectedcmsls=[x[1]
for x
in lsdata
if x[1]]
762 for thisls
in lsdata:
766 existdata.append(cmslsnum)
767 efflumiDict=thisls[8]
770 recordedlumi=thisls[6]
771 totrecorded+=recordedlumi
774 if cmslsnum
in selectedcmsls:
775 selectedcmsls.remove(cmslsnum)
777 for hltpathname
in sorted(efflumiDict):
778 pathdata=efflumiDict[hltpathname]
779 if hltpathname
not in totefflumiDict:
780 totefflumiDict[hltpathname]=0.0
781 pathmap[hltpathname]=
'n/a' 786 recordedPerpathPerrun.setdefault(hltpathname,{})
787 selectedPerpathPerrun.setdefault(hltpathname,{})
788 if hltpathname
not in totdict:
789 totdict[hltpathname]=[0,0.0]
790 if l1presc
is None or hltpresc
is None:
791 if cmslsnum
in selectedcmsls:
792 selectedcmsls.remove(cmslsnum)
794 if hltpathname
not in hprescdict:
795 hprescdict[hltpathname]=[]
796 hprescdict[hltpathname].
append(hltpresc)
797 if l1name
not in lprescdict:
798 lprescdict[l1name]=[]
799 lprescdict[l1name].
append(l1presc)
801 totdict[hltpathname][0]+=1
803 totdict[hltpathname][1]+=lumival
804 totefflumiDict[hltpathname]+=lumival
805 pathmap[hltpathname]=l1name
806 recordedPerpathPerrun[hltpathname][run]=totrecorded
807 selectedPerpathPerrun[hltpathname][run]=len(selectedcmsls)
808 if len(selectedcmsls)==0:
812 if irunlsdict
and not noWarning:
813 datarunlsdict[run]=selectedcmsls
815 for name
in sorted(totefflumiDict):
817 totrecordedinrun=recordedPerpathPerrun[name][run]
818 hprescs=
list(set(hprescdict[name]))
819 hprescStr=
'('+
','.
join([
'%d'%(x)
for x
in hprescs])+
')' 827 effval=totefflumiDict[name]*scalefactor
828 lprescs=
list(set(lprescdict[lname]))
829 lprescStr=
'('+
','.
join([
'%d'%(x)
for x
in lprescs])+
')' 830 cleanlname=lname.replace(
'"',
'')
832 effvalStr=
'%.3f'%(efflumival)+
'('+efflumiunit+
')' 834 result.append([
str(run)+
':'+
str(fillnum),selectedlsStr,
'%.3f'%(totrecval)+
'('+totrecunit+
')',name+hprescStr,cleanlname+lprescStr,effvalStr])
836 result.append([
str(run)+
':'+
str(fillnum),selectedlsStr,totrecordedinrun*scalefactor,name+hprescStr,cleanlname+lprescStr,effval])
838 if irunlsdict
and not noWarning:
839 for run,cmslslist
in irunlsdict.items():
840 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
841 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no HLT data\n')
845 if ss
not in datarunlsdict[run]:
846 sys.stdout.write(
'[WARNING] selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB or has no HLT data\n')
848 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
851 labels = [(
'Run:Fill',
'SelectedLS',
'Recorded',
'HLTpath(Presc)',
'L1bit(Presc)',
'Effective')]
853 print(tablePrinter.indent (labels+sortedresult, hasHeader =
True, separateRows =
False,
854 prefix =
'| ', postfix =
' |', justify =
'right',
856 print(
' == = Total : ')
857 lastrowlabels=[(
'HLTPath',
'SelectedLS',
'Recorded',
'Effective')]
859 for hname
in sorted(totdict):
864 selectedThispath=selectedPerpathPerrun[hname]
865 for runnumber,nselected
in selectedThispath.items():
866 if nselected==0:
continue 867 alltotrecorded+=recordedPerpathPerrun[hname][runnumber]
869 totresult.append([hname,
str(totnls),
'%.3f'%(alltotrecordedVal)+
'('+alltotrecordedunit+
')',
'%.3f'%(toteffval)+
'('+toteffunit+
')'])
870 print(tablePrinter.indent (lastrowlabels+totresult, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'right',
871 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
873 fieldnames=[
'Run:Fill',
'SelectedLS',
'Recorded',
'HLTpath(Presc)',
'L1bit(Presc)',
'Effective(/ub)']
875 dumptocsv(fieldnames,sortedresult,filename)
879 input:{run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),bxdata(8),beamdata(9),fillnum(10)]} 881 fieldnames=['Run:Fill','LS','UTCTime','Delivered(/ub)','Recorded(/ub)','BX'] 885 fieldnames=[
'run:fill',
'ls',
'UTCTime',
'delivered(/ub)',
'recorded(/ub)',
'[bx,Hz/ub]']
887 for run
in sorted(lumidata):
888 rundata=lumidata[run]
890 result.append([
str(run)+
':0',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
891 if irunlsdict
and irunlsdict[run]:
892 print(
'[WARNING] selected but no lumi data for run '+
str(run))
895 if rundata
and rundata[0][10]:
896 fillnum=rundata[0][10]
897 if irunlsdict
and not noWarning:
898 existdata=[x[1]
for x
in rundata
if x[1] ]
899 datarunlsdict[run]=existdata
900 for lsdata
in rundata:
903 if lsdata
and lsdata[1]:
906 if lsdata
and lsdata[2]:
908 tsStr=ts.strftime(
'%m/%d/%y %H:%M:%S')
911 deliveredlumi=lsdata[5]
914 recordedlumi=lsdata[6]
915 (bxidxlist,bxvaluelist,bxerrorlist)=lsdata[8]
916 if irunlsdict
and irunlsdict[run]:
917 if run
in irunlsdict
and cmslsnum
in irunlsdict[run]:
918 if bxidxlist
and bxvaluelist:
921 bxresult=
CommonUtil.flatten([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo])
922 result.append(bxresult)
924 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor])
926 if bxidxlist
and bxvaluelist:
929 bxresult=
CommonUtil.flatten([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo])
930 result.append(bxresult)
932 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor])
934 if filename.upper()==
'STDOUT':
936 r.write(
','.
join(fieldnames)+
'\n')
941 r.writeRow(fieldnames)
944 def toScreenLSTrg(trgdata,iresults=[],irunlsdict=None,noWarning=True,toFile=None,withoutmask=False):
946 input:{run:[[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(name,count,presc,mask),]],..] 950 for rline
in iresults:
953 if irunlsdict
and not noWarning:
954 if runnumStr
is not 'n/a' and int(runnumStr)
not in datarunlsdict:
955 datarunlsdict[
int(runnumstr)]=[]
956 if cmslsnumStr!=
'n/a':
959 for run
in trgdata.keys():
962 ll=[
str(run),
'n/a',
'n/a',
'n/a']
964 if irunlsdict
and not noWarning:
965 print(
'[WARNING] selected but no trg data for run '+
str(run))
967 if irunlsdict
and not noWarning:
968 existdata=[x[0]
for x
in rundata
if x[0] ]
969 datarunlsdict[run]=existdata
972 for lsdata
in rundata:
979 flatbitdata=[
"("+x[0]+
',%d'%x[1]+
',%d'%x[2]+
")" for x
in bitdata
if x[0]!=
'False']
980 bitdataStr=
' '.
join(flatbitdata)
983 flatbitdata=[
"("+x[0]+
',%d'%x[1]+
',%d'%x[2]+
")" for x
in bitdata
if x[0]!=
'False' and x[3]]
984 bitdataStr=
' '.
join(flatbitdata)
985 if irunlsdict
and irunlsdict[run]:
986 if run
in irunlsdict
and cmslsnum
in irunlsdict[run]:
987 result.append([
str(run),
str(cmslsnum),
'%.4f'%(deadfrac),bitdataStr])
989 result.append([
str(run),
str(cmslsnum),
'%.4f'%(deadfrac),bitdataStr])
990 if irunlsdict
and not noWarning:
991 for run,cmslslist
in irunlsdict.items():
992 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
993 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no qualified data\n')
997 if ss
not in datarunlsdict[run]:
998 sys.stdout.write(
'[WARNING] selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB\n')
1002 labels = [(
'Run',
'LS',
'dfrac',
'(bitname,count,presc)')]
1003 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,70) ))
1006 fieldnames=[
'Run',
'LS',
'dfrac',
'(bitname,count,presc)']
1011 input:{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})} 1016 for run
in hltdata.keys():
1017 if hltdata[run]
is None:
1018 ll=[
str(run),
'n/a',
'n/a',
'n/a',
'n/a',
'n/a']
1020 perrundata=hltdata[run]
1021 for lsdata
in perrundata:
1023 allpathinfo=lsdata[1]
1025 for thispathinfo
in allpathinfo:
1026 thispathname=thispathinfo[0]
1027 thispathpresc=thispathinfo[1]
1031 thispathresult.append(thispathname)
1032 if thispathpresc
is None:
1035 thispathresult.append(
'%d'%thispathpresc)
1036 thisl1pass=thispathinfo[2]
1037 if thispathinfo[2]
is None:
1038 thispathresult.append(
'n/a')
1040 thispathresult.append(
'%d'%thisl1pass)
1041 thishltaccept=thispathinfo[3]
1042 if thispathinfo[3]
is None:
1043 thispathresult.append(
'n/a')
1045 thispathresult.append(
'%d'%thishltaccept)
1047 thispathresultStr=
'('+
','.
join(thispathresult)+
')' 1048 allpathresult.append(thispathresultStr)
1049 result.append([
str(run),
str(cmslsnum),
', '.
join(allpathresult)])
1053 labels = [(
'Run',
'LS',
'(hltpath,presc,l1pass,hltaccept)')]
1054 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,
1055 prefix =
'| ', postfix =
' |', justify =
'left',
1056 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,70) ))
1058 fieldnames=[
'Run',
'LS',
'(hltpath,presc,l1pass,hltaccept)']
1064 input : {runnumber,[(hltpath,l1seedexpr,l1bitname),...]} 1069 pp=
' '.
join([pp[i:i+25]
for i
in range(0,len(pp),25)])
1071 sdepr=
' '.
join([sdepr[i:i+25]
for i
in range(0,len(sdepr),25)])
1073 lb=
' '.
join([lb[i:i+25]
for i
in range(0,len(lb),25)])
1074 result.append([r[0],pp,sdepr,lb])
1075 for run
in sorted(hltconfdata):
1076 pathdata=hltconfdata[run]
1077 if pathdata
is None:
1078 result.append([
str(run),
'n/a',
'n/a',
'n/a'])
1080 for thispathinfo
in pathdata:
1081 thispath=thispathinfo[0]
1082 thispath=
' '.
join([thispath[i:i+25]
for i
in range(0,len(thispath),25)])
1083 thisseed=thispathinfo[1]
1084 thisseed=
' '.
join([thisseed[i:i+25]
for i
in range(0,len(thisseed),25)]).
replace(
'"',
'')
1085 thisbit=thispathinfo[2]
1089 thisbit=
' '.
join([thisbit[i:i+25]
for i
in range(0,len(thisbit),25)]).
replace(
'"',
'')
1090 result.append([
str(run),thispath,thisseed,thisbit])
1092 labels=[(
'Run',
'hltpath',
'l1seedexpr',
'l1bit')]
1094 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,
1095 prefix =
'| ', postfix =
' |', justify =
'left',
1096 delim =
' | ', wrapfunc =
lambda x:
wrap_onspace(x,25) ))
1099 fieldnames=[
'Run',
'hltpath',
'l1seedexpr',
'l1bit']
1100 dumptocsv(fieldnames,sortedresult,filename)
1104 input: {run:[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(4)),..]} 1105 beaminfolist:[(bxidx,b1,b2)] 1108 for rline
in iresults:
1109 result.append(rline)
1110 for run
in sorted(beamdata):
1111 perrundata=beamdata[run]
1112 if perrundata
is None:
1113 ll=[
str(run),
'n/a',
'n/a']
1117 for lsdata
in perrundata:
1120 beamstatus=lsdata[2]
1121 beamenergy=lsdata[3]
1122 ncollidingbx=lsdata[4]
1123 if not dumpIntensity:
1124 result.append([
str(run),
str(lumilsnum)+
':'+
str(cmslsnum),beamstatus,
'%.2f'%beamenergy,
str(ncollidingbx)])
1128 for thisbxinfo
in allbxinfo:
1129 thisbxresultStr=
'(n/a,n/a,n/a,n/a)' 1133 thisbxresultStr=
','.
join([
'%d'%bxidx,
'%.3e'%b1,
'%.3e'%b2])
1134 allbxresult.append(thisbxresultStr)
1135 allbxresultStr=
' '.
join(allbxresult)
1136 result.append([
str(run),
str(lumilsnum)+
':'+
str(cmslsnum),beamstatus,
'%.2f'%beamenergy,
str(ncollidingbx),allbxresultStr])
1139 labels=[(
'Run',
'LS',
'beamstatus',
'egev',
'ncollidingbx')]
1141 labels=[(
'Run',
'LS',
'beamstatus',
'egev',
'ncollidingbx',
'(bxidx,b1,b2)')]
1143 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,
1144 prefix =
'| ', postfix =
' |', justify =
'left',
1145 delim =
' | ', wrapfunc =
lambda x:
wrap_onspace(x,25) ))
1147 fieldnames=[
'Run',
'LS',
'beamstatus',
'egev',
'ncollidingbx']
1149 fieldnames.append(
'(bxidx,b1,b2)')
1153 if __name__ ==
"__main__":
def toScreenOverview(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def toScreenLSHlt(hltdata, iresults=[], toFile=None)
def replace(string, replacements)
def toScreenLumiByLS(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def guessUnit(inverseubval)
S & print(S &os, JobReport::InputFile const &f)
def toScreenConfHlt(hltconfdata, iresults=[], toFile=None)
def toScreenTotDelivered(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def toScreenLSTrg(trgdata, iresults=[], irunlsdict=None, noWarning=True, toFile=None, withoutmask=False)
def toCSVLumiByLSXing(lumidata, scalefactor, filename, irunlsdict=None, noWarning=True)
def splitlistToRangeString(inPut)
def transposed(lists, defaultval=None)
def toScreenNormDetail(normname, norminfo, normvalues)
def toScreenTags(tagdata)
def dumptocsv(fieldnames, result, filename)
def toScreenHeader(commandname, datatagname, normtag, worktag, updatetag, lumitype, toFile=None)
static std::string join(char **cmd)
def toScreenTotEffective(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def toScreenLSEffective(lumidata, resultlines, scalefactor, irunlsdict=None, noWarning=True, toFile=None)
def toScreenLSBeam(beamdata, iresults=[], dumpIntensity=False, toFile=None)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def toScreenNormSummary(allnorms)
def toScreenSingleTag(taginfo)