1 from __future__
import print_function
8 from builtins
import range
10 from RecoLuminosity.LumiDB
import tablePrinter, csvReporter,CommonUtil
11 from RecoLuminosity.LumiDB.wordWrappers
import wrap_always, wrap_onspace, wrap_onspace_strict
16 utility method to dump result to csv file 19 if filename.upper()==
'STDOUT':
21 r.write(
','.
join(fieldnames)+
'\n')
26 r.writeRow(fieldnames)
30 def toScreenHeader(commandname,datatagname,normtag,worktag,updatetag,lumitype,toFile=None):
33 commandname: commandname 36 worktag: working version 37 updatetag: updated version if amy 39 gmtnowStr=time.asctime(time.gmtime())+
' UTC' 42 updatetagStr=updatetag
43 header=
''.
join([
'*']*80)+
'\n' 44 header+=
'* '+gmtnowStr+
'\n' 45 header+=
'* lumitype: '+lumitype+
' , datatag: '+datatagname+
' , normtag: '+normtag+
' , worktag: '+worktag+
'\n' 48 header+=
'* '+commandname+
'\n' 50 header+=
'* update: '+updatetag+
'\n' 51 header+=
''.
join([
'*']*80)+
'\n' 53 sys.stdout.write(header)
56 if toFile.upper()==
'STDOUT':
64 list all known norms summary 65 input: {normname:[data_id(0),lumitype(1),istypedefault(2),comment(3),creationtime(4)]} 68 labels=[(
'Name',
'Type',
'IsTypeDefault',
'Comment',
'CreationTime')]
70 sorted_allnorms=sorted(six.iteritems(allnorms),key=
lambda x:x[0],reverse=
True)
71 for (normname,normvalues)
in sorted_allnorms:
72 lumitype=normvalues[1]
73 istypedefault=
str(normvalues[2])
74 commentStr=normvalues[3]
75 creationtime=normvalues[4]
76 result.append([normname,lumitype,istypedefault,commentStr,creationtime])
77 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
84 norminfo=[data_id[0],lumitype(1)istypedefault[2],comment[3],creationtime[4]] 85 normvalues={since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} 88 istypedefault=norminfo[2]
89 print(
'==========================================================')
90 print(
'* Norm: '+normname)
91 print(
'* Type: '+lumitype)
92 print(
'* isDefault: '+
str(istypedefault))
93 print(
'==========================================================')
94 labels=[(
'Since',
'Func',
'Parameters',
'amodetag',
'egev',
'comment')]
98 for since
in sorted(normvalues):
99 normdata=normvalues[since]
100 correctorStr=normdata[0]
101 paramDict=normdata[1]
104 for pname
in sorted(paramDict):
105 pval=paramDict[pname]
111 paramDictStr+=pname+
':'+
'%.4f'%fpval
113 paramDictStr+=pname+
':'+
'%.2f'%fpval
115 paramDictStr+=pname+
':'+pval
118 egev=
str(normdata[3])
120 result.append([
str(since),correctorStr,paramDictStr,amodetag,egev,comment])
121 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,40) ))
125 labels=[(
'Name',
'Min Run',
'Max Run',
'Creation Time')]
127 for tagid
in sorted(tagdata):
128 taginfo=tagdata[tagid]
130 minRun=
str(taginfo[1])
133 maxRun=
str(taginfo[2])
134 creationtime=taginfo[3]
135 result.append([name,minRun,maxRun,creationtime])
136 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
140 input: {run:(lumidataid,trgdataid,hltdataid,comment)} 143 labels=[(
'Run',
'Data Id',
'Insertion Time',
'Patch Comment')]
145 for run
in sorted(taginfo):
146 (lumidataid,trgdataid,hltdataid,(ctimestr,comment))=taginfo[run]
147 payloadid=
'-'.
join([
str(lumidataid),
str(trgdataid),
str(hltdataid)])
148 result.append([
str(run),payloadid,ctimestr,comment])
149 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,25) ))
154 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)]} 155 resultlines [[resultrow1],[resultrow2],...,] existing result row 156 ('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)') 157 irunlsdict: run/ls selection list. irunlsdict=None means no filter 164 for r
in resultlines:
166 [runnumstr,fillnumstr]=runfillstr.split(
':')
167 if irunlsdict
and not noWarning:
168 if r[1]
is not 'n/a':
169 datarunlsdict[
int(runnumstr)]=[]
174 r[3]=
'%.3f'%(rr)+
' ('+lumiu+
')' 181 totOldDeliveredLS+=sls
182 totOldCMSLS+=totcmsls
192 for run
in lumidata.keys():
195 result.append([
str(run)+
':0',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
196 if irunlsdict
and not noWarning:
197 datarunlsdict[run]=
None 200 if lsdata[0]
and lsdata[0][9]:
206 for perlsdata
in lsdata:
207 lumilsnum=perlsdata[0]
208 cmslsnum=perlsdata[1]
211 existdata.append(cmslsnum)
212 if irunlsdict
and irunlsdict[run]:
213 if lumilsnum
and lumilsnum
in irunlsdict[run]:
214 deliveredData.append(perlsdata[5])
216 selectedcmsls.append(cmslsnum)
218 deliveredData.append(perlsdata[5])
220 selectedcmsls.append(cmslsnum)
221 datarunlsdict[run]=existdata
222 nls=len(deliveredData)
225 ncmsls=len(selectedcmsls)
228 totlumi=sum(deliveredData)
229 totdelivered+=totlumi
231 beamenergyPerLS=[
float(x[4])
for x
in lsdata
if x[3]==
'STABLE BEAMS']
233 if len(beamenergyPerLS):
234 avgbeamenergy=sum(beamenergyPerLS)/len(beamenergyPerLS)
236 if lsdata[0]
and lsdata[0][2]:
237 runstarttime=lsdata[0][2]
238 runstarttime=runstarttime.strftime(
"%m/%d/%y %H:%M:%S")
240 result.append([
str(run)+
':'+
str(fillnum),
str(nls),
str(ncmsls),
'%.3f'%(totlumival*scalefactor)+
' ('+lumiunit+
')',runstarttime,
'%.1f'%(avgbeamenergy)])
242 result.append([
str(run)+
':'+
str(fillnum),
str(nls),
str(ncmsls),(totlumi*scalefactor),runstarttime,
'%.1f'%(avgbeamenergy)])
243 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
246 labels = [(
'Run:Fill',
'N_LS',
'N_CMSLS',
'Delivered',
'UTCTime',
'E(GeV)')]
248 print(tablePrinter.indent (labels+sortedresult, hasHeader =
True, separateRows =
False,
249 prefix =
'| ', postfix =
' |', justify =
'right',
250 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,40) ))
251 print(
' == = Total : ')
253 totrowlabels = [(
'Delivered LS',
'Total CMS LS',
'Delivered('+totalDeliveredUni+
')')]
254 totaltable.append([
str(totls+totOldDeliveredLS),
str(totcmsls+totOldCMSLS),
'%.3f'%(totalDeliveredVal*scalefactor)])
255 print(tablePrinter.indent (totrowlabels+totaltable, hasHeader =
True, separateRows =
False, prefix =
'| ',
256 postfix =
' |', justify =
'right', delim =
' | ',
257 wrapfunc =
lambda x: wrap_onspace (x, 20)))
259 fieldnames = [
'Run:Fill',
'N_LS',
'N_CMSLS',
'Delivered(/ub)',
'UTCTime',
'E(GeV)']
261 dumptocsv(fieldnames,sortedresult,filename)
263 def toScreenOverview(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
266 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)]} 267 resultlines [[resultrow1],[resultrow2],...,] existing result row 282 for r
in resultlines:
284 [runnumstr,fillnumstr]=runfillstr.split(
':')
285 if irunlsdict
and not noWarning:
286 if r[1]
is not 'n/a':
287 datarunlsdict[
int(runnumstr)]=[]
292 r[2]=
'%.3f'%(rr)+
' ('+lumiu+
')' 296 totOldDeliveredLS+=dls
301 listcomp=rlsstr.split(
', ')
302 for lstr
in listcomp:
303 enddigs=lstr[1:-1].
split(
'-')
304 lsmin=
int(enddigs[0])
305 lsmax=
int(enddigs[1])
307 totOldSelectedLS+=rls
311 r[4]=
'%.3f'%(rrcd)+
' ('+rlumiu+
')' 314 for run
in lumidata.keys():
317 result.append([
str(run)+
':0',
'n/a',
'n/a',
'n/a',
'n/a'])
318 if irunlsdict
and irunlsdict[run]
and not noWarning:
319 datarunlsdict[run]=
None 322 if lsdata[0]
and lsdata[0][10]:
323 fillnum=lsdata[0][10]
329 for perlsdata
in lsdata:
330 lumilsnum=perlsdata[0]
331 cmslsnum=perlsdata[1]
334 existdata.append(cmslsnum)
335 if irunlsdict
and irunlsdict[run]:
336 if lumilsnum
and lumilsnum
in irunlsdict[run]:
337 if perlsdata[5]
is not None:
338 deliveredData.append(perlsdata[5])
340 recordedData.append(perlsdata[6])
341 selectedcmsls.append(lumilsnum)
343 deliveredData.append(perlsdata[5])
345 recordedData.append(perlsdata[6])
347 selectedcmsls.append(cmslsnum)
348 datarunlsdict[run]=existdata
349 nls=len(deliveredData)
350 totdelivered=sum(deliveredData)
351 totalDelivered+=totdelivered
352 totalDeliveredLS+=len(deliveredData)
354 totrecorded=sum(recordedData)
355 totalRecorded+=totrecorded
357 totalSelectedLS+=len(selectedcmsls)
358 if len(selectedcmsls)==0:
363 result.append([
str(run)+
':'+
str(fillnum),
str(nls),
'%.3f'%(totdeliveredlumi*scalefactor)+
' ('+deliveredlumiunit+
')',selectedlsStr,
'%.3f'%(totrecordedlumi*scalefactor)+
' ('+recordedlumiunit+
')'])
365 result.append([
str(run)+
':'+
str(fillnum),nls,totdelivered*scalefactor,selectedlsStr,totrecorded*scalefactor])
366 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
367 if irunlsdict
and not noWarning:
368 for run,cmslslist
in irunlsdict.items():
369 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
370 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no qualified data\n')
374 if ss
not in datarunlsdict[run]:
375 sys.stdout.write(
'[WARNING] lumi or trg for selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB\n')
377 labels = [(
'Run:Fill',
'Delivered LS',
'Delivered',
'Selected LS',
'Recorded')]
379 print(tablePrinter.indent (labels+sortedresult, hasHeader =
True, separateRows =
False,
380 prefix =
'| ', postfix =
' |', justify =
'right',
381 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
382 print(
' == = Total : ')
385 totrowlabels = [(
'Delivered LS',
'Delivered('+totalDeliveredUni+
')',
'Selected LS',
'Recorded('+totalRecordedUni+
')')]
386 totaltable.append([
str(totalDeliveredLS+totOldDeliveredLS),
'%.3f'%(totalDeliveredVal*scalefactor),
str(totalSelectedLS+totOldSelectedLS),
'%.3f'%(totalRecordedVal*scalefactor)])
387 print(tablePrinter.indent (totrowlabels+totaltable, hasHeader =
True, separateRows =
False, prefix =
'| ',
388 postfix =
' |', justify =
'right', delim =
' | ',
389 wrapfunc =
lambda x: wrap_onspace (x, 20)))
391 fieldnames = [
'Run:Fill',
'DeliveredLS',
'Delivered(/ub)',
'SelectedLS',
'Recorded(/ub)']
393 dumptocsv(fieldnames,sortedresult,filename)
395 def toScreenLumiByLS(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
398 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)]} 399 {run:None} None means no run in lumiDB, 400 {run:[]} [] means no lumi for this run in lumiDB 401 {run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB 402 {run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0 403 resultlines [[resultrow1],[resultrow2],...,] existing result row 413 totOldDeliveredLS = 0
415 totOldDelivered = 0.0
420 for rline
in resultlines:
422 [runnumstr,fillnumstr]=runfillstr.split(
':')
423 if irunlsdict
and not noWarning:
424 if rline[1]
is not 'n/a':
425 datarunlsdict[
int(runnumstr)]=[]
428 [luls,cmls]=myls.split(
':')
432 if irunlsdict
and not noWarning:
437 if dl>maxlslumi: maxlslumi=dl
447 for run
in lumidata.keys():
451 if irunlsdict
and irunlsdict[run]
and not noWarning:
452 datarunlsdict[run]=
None 456 if lsdata[0]
and lsdata[0][10]:
457 fillnum=lsdata[0][10]
462 for perlsdata
in lsdata:
463 lumilsnum=perlsdata[0]
464 cmslsnum=perlsdata[1]
467 existdata.append(cmslsnum)
471 deliveredlumi=perlsdata[5]
473 if deliveredlumi>maxlslumi: maxlslumi=deliveredlumi
476 recordedlumi=perlsdata[6]
477 if irunlsdict
and irunlsdict[run]:
478 if run
in irunlsdict
and lumilsnum
in irunlsdict[run]:
479 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),ts.strftime(
'%m/%d/%y %H:%M:%S'),bs,
'%.1f'%begev,deliveredlumi,recordedlumi,npu])
480 totalDelivered+=deliveredlumi
481 totalRecorded+=recordedlumi
485 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),ts.strftime(
'%m/%d/%y %H:%M:%S'),bs,
'%.1f'%begev,deliveredlumi,recordedlumi,npu])
486 totalDelivered+=deliveredlumi
487 totalRecorded+=recordedlumi
491 datarunlsdict[run]=existdata
492 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
493 if irunlsdict
and not noWarning:
494 for run,cmslslist
in irunlsdict.items():
495 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
496 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no qualified data\n')
500 if ss
not in datarunlsdict[run]:
501 sys.stdout.write(
'[WARNING] lumi or trg for selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB\n')
504 labels = [ (
'Run:Fill',
'LS',
'UTCTime',
'Beam Status',
'E(GeV)',
'Del('+lsunitstring+
')',
'Rec('+lsunitstring+
')',
'avgPU') ]
506 for entry
in sortedresult:
519 perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],delumi,reclumi,avgPU])
521 deliveredlumiunit=
'/ub' 522 (totdeliveredlumi,deliveredlumiunit)=
CommonUtil.guessUnit((totalDelivered+totOldDelivered)*scalefactor)
524 recordedlumiunit=
'/ub' 525 (totrecordedlumi,recordedlumiunit)=
CommonUtil.guessUnit((totalRecorded+totOldRecorded)*scalefactor)
526 lastrowlabels = [ (
'Delivered LS',
'Selected LS',
'Delivered('+deliveredlumiunit+
')',
'Recorded('+recordedlumiunit+
')')]
527 totalrow.append ([
str(totalDeliveredLS+totOldDeliveredLS),
str(totalSelectedLS+totOldSelectedLS),
'%.3f'%(totdeliveredlumi),
'%.3f'%(totrecordedlumi)])
529 print(tablePrinter.indent (labels+perlsresult, hasHeader =
True, separateRows =
False, prefix =
'| ',
530 postfix =
' |', justify =
'right', delim =
' | ',
531 wrapfunc =
lambda x: wrap_onspace_strict (x, 22)))
532 print(
' == = Total : ')
533 print(tablePrinter.indent (lastrowlabels+totalrow, hasHeader =
True, separateRows =
False, prefix =
'| ',
534 postfix =
' |', justify =
'right', delim =
' | ',
535 wrapfunc =
lambda x: wrap_onspace (x, 20)))
537 fieldnames=[
'Run:Fill',
'LS',
'UTCTime',
'Beam Status',
'E(GeV)',
'Delivered(/ub)',
'Recorded(/ub)',
'avgPU']
539 dumptocsv(fieldnames,sortedresult,filename)
543 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)]} 551 totOldSelectedLSDict={}
552 totOldRecordedDict={}
553 totOldEffectiveDict={}
557 for rline
in resultlines:
559 [runnumstr,fillnumstr]=runfillstr.split(
':')
560 if irunlsdict
and not noWarning:
561 if rline[1]
is not 'n/a':
562 datarunlsdict[
int(runnumstr)]=[]
566 if myls
and myls!=
'n/a' and mpath
and mpath!=
'n/a':
567 totOldSelectedLSDict[mypath]=0
568 totOldRecordedDict[mypath]=0.
569 totOldEffectiveDict[mypath]=0.
571 [luls,cmls]=myls.split(
':')
573 if mypath
in totOldSelectedLSDict:
574 totOldSelectedLSDict[mypath]+=1
575 if irunlsdict
and not noWarning:
579 myrecorded=
float(rline[6])
580 if myrecorded>maxlslumi:maxlslumi=myrecorded
581 if mypath
in totOldRecordedDict:
582 totOldRecordedDict[mypath]+=myrecorded
586 myeff=
float(rline[7])
587 if mypath
in totOldEffectiveDict:
588 totOldEffectiveDict[mypath]+=myeff
592 for run
in lumidata.keys():
595 result.append([
str(run),
'n/a',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
596 if irunlsdict
and irunlsdict[run]
and not noWarning:
597 datarunlsdict[run]=
None 600 if lsdata[0]
and lsdata[0][11]:
601 fillnum=lsdata[0][11]
602 datarunlsdict[run]=[]
603 for thisls
in lsdata:
606 if not cmslsnum:
continue 607 efflumiDict=thisls[8]
610 recordedlumi=thisls[6]
611 if recordedlumi>maxlslumi:maxlslumi=recordedlumi
613 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),
'n/a',
'n/a',
'n/a',
'n/a',recordedlumi,
'n/a'])
616 for hltpathname
in sorted(efflumiDict):
617 if hltpathname
and hltpathname !=
'n/a' :
618 if hltpathname
not in totRecordedDict:
619 totRecordedDict[hltpathname]=0.
620 if hltpathname
not in totSelectedLSDict:
621 totSelectedLSDict[hltpathname]=0
622 if hltpathname
not in totEffectiveDict:
623 totEffectiveDict[hltpathname]=0.
624 totSelectedLSDict[hltpathname]+=1
625 totRecordedDict[hltpathname]+=recordedlumi
626 pathdata=efflumiDict[hltpathname]
630 cleanl1name=l1name.replace(
'"',
'')
633 l1presc=
str(pathdata[1])
636 hltpresc=
str(pathdata[2])
640 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),hltpathname,cleanl1name,hltpresc,l1presc,recordedlumi,lumival])
641 if hltpathname
and hltpathname !=
'n/a' :
642 totEffectiveDict[hltpathname]+=lumival
643 if irunlsdict
and not noWarning:
645 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
646 if irunlsdict
and not noWarning:
647 for run,cmslslist
in irunlsdict.items():
648 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
649 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no HLT data\n')
653 if ss
not in datarunlsdict[run]:
654 sys.stdout.write(
'[WARNING] selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB or has no qualified data\n')
658 labels = [(
'Run:Fill',
'LS',
'HLTpath',
'L1bit',
'HLTpresc',
'L1presc',
'Recorded('+lsunitstring+
')',
'Effective('+lsunitstring+
')')]
660 for entry
in sortedresult:
667 perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],entry[5],reclumi,efflumi])
669 print(tablePrinter.indent (labels+perlsresult, hasHeader =
True, separateRows =
False,
670 prefix =
'| ', postfix =
' |', justify =
'right',
672 for mpath
in sorted(totRecordedDict):
673 totSelectedLS=totSelectedLSDict[mpath]
674 if mpath
in totOldSelectedLSDict:
675 totSelectedLS+=totOldSelectedLS[mpath]
676 totRecorded=totRecordedDict[mpath]
677 if mpath
in totOldRecordedDict:
678 totRecorded+=totOldRecorded[mpath]
679 totRecorded=
float(totRecorded*scalefactor)/
float(unitdenomitor)
680 totEffective=totEffectiveDict[mpath]
681 if mpath
in totOldEffectiveDict:
682 totEffective+=totOldEffective[mpath]
683 totEffective=
float(totEffective*scalefactor)/
float(unitdenomitor)
684 totalrow.append([
str(totSelectedLS),mpath,
'%.3f'%(totRecorded),
'%.3f'%(totEffective)])
685 lastrowlabels = [ (
'Selected LS',
'HLTPath',
'Recorded('+lsunitstring+
')',
'Effective('+lsunitstring+
')')]
686 print(
' == = Total : ')
687 print(tablePrinter.indent (lastrowlabels+totalrow, hasHeader =
True, separateRows =
False, prefix =
'| ',
688 postfix =
' |', justify =
'right', delim =
' | ',
689 wrapfunc =
lambda x: wrap_onspace (x, 20)))
691 fieldnames = [
'Run:Fill',
'LS',
'HLTpath',
'L1bit',
'HLTpresc',
'L1presc',
'Recorded(/ub)',
'Effective(/ub)']
693 dumptocsv(fieldnames,sortedresult,filename)
698 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)} 699 screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective 707 recordedPerpathPerrun={}
708 selectedPerpathPerrun={}
710 for rline
in resultlines:
712 [runnumstr,fillnumstr]=runfillstr.split(
':')
714 if irunlsdict
and not noWarning:
715 if myls
is not 'n/a':
716 datarunlsdict[
int(runnumstr)]=[]
719 mypath=mypath.split(
'(')[0]
720 if mypath
not in totdict:
721 totdict[mypath]=[0,0.0]
722 recordedPerpathPerrun[mypath]={}
723 selectedPerpathPerrun[mypath]={}
725 listcomp=myls.split(
', ')
726 for lstr
in listcomp:
727 enddigs=lstr[1:-1].
split(
'-')
728 lsmin=
int(enddigs[0])
729 lsmax=
int(enddigs[1])
731 totdict[mypath][0]+=rls
732 selectedPerrun[mypath].setdefault(
int(myrun),totdict[mypath][0])
734 if myrecorded!=
'n/a':
735 recordedPerpathPerrun[mypath].setdefault(
int(myrun),
float(myrecorded))
737 rline[2]=
'%.3f'%(rr)+
' ('+lumiu+
')' 742 rline[5]=
'%.3f'%(rr)+
' ('+lumiu+
')' 743 totdict[mypath][1]+=reff
745 for run
in lumidata.keys():
750 result.append([
str(run),
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
751 if irunlsdict
and irunlsdict[run]
and not noWarning:
752 datarunlsdict[run]=
None 755 if lsdata[0]
and lsdata[0][11]:
756 fillnum=lsdata[0][11]
757 selectedcmsls=[x[1]
for x
in lsdata
if x[1]]
763 for thisls
in lsdata:
767 existdata.append(cmslsnum)
768 efflumiDict=thisls[8]
771 recordedlumi=thisls[6]
772 totrecorded+=recordedlumi
775 if cmslsnum
in selectedcmsls:
776 selectedcmsls.remove(cmslsnum)
778 for hltpathname
in sorted(efflumiDict):
779 pathdata=efflumiDict[hltpathname]
780 if hltpathname
not in totefflumiDict:
781 totefflumiDict[hltpathname]=0.0
782 pathmap[hltpathname]=
'n/a' 787 recordedPerpathPerrun.setdefault(hltpathname,{})
788 selectedPerpathPerrun.setdefault(hltpathname,{})
789 if hltpathname
not in totdict:
790 totdict[hltpathname]=[0,0.0]
791 if l1presc
is None or hltpresc
is None:
792 if cmslsnum
in selectedcmsls:
793 selectedcmsls.remove(cmslsnum)
795 if hltpathname
not in hprescdict:
796 hprescdict[hltpathname]=[]
797 hprescdict[hltpathname].
append(hltpresc)
798 if l1name
not in lprescdict:
799 lprescdict[l1name]=[]
800 lprescdict[l1name].
append(l1presc)
802 totdict[hltpathname][0]+=1
804 totdict[hltpathname][1]+=lumival
805 totefflumiDict[hltpathname]+=lumival
806 pathmap[hltpathname]=l1name
807 recordedPerpathPerrun[hltpathname][run]=totrecorded
808 selectedPerpathPerrun[hltpathname][run]=len(selectedcmsls)
809 if len(selectedcmsls)==0:
813 if irunlsdict
and not noWarning:
814 datarunlsdict[run]=selectedcmsls
816 for name
in sorted(totefflumiDict):
818 totrecordedinrun=recordedPerpathPerrun[name][run]
819 hprescs=
list(set(hprescdict[name]))
820 hprescStr=
'('+
','.
join([
'%d'%(x)
for x
in hprescs])+
')' 828 effval=totefflumiDict[name]*scalefactor
829 lprescs=
list(set(lprescdict[lname]))
830 lprescStr=
'('+
','.
join([
'%d'%(x)
for x
in lprescs])+
')' 831 cleanlname=lname.replace(
'"',
'')
833 effvalStr=
'%.3f'%(efflumival)+
'('+efflumiunit+
')' 835 result.append([
str(run)+
':'+
str(fillnum),selectedlsStr,
'%.3f'%(totrecval)+
'('+totrecunit+
')',name+hprescStr,cleanlname+lprescStr,effvalStr])
837 result.append([
str(run)+
':'+
str(fillnum),selectedlsStr,totrecordedinrun*scalefactor,name+hprescStr,cleanlname+lprescStr,effval])
839 if irunlsdict
and not noWarning:
840 for run,cmslslist
in irunlsdict.items():
841 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
842 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no HLT data\n')
846 if ss
not in datarunlsdict[run]:
847 sys.stdout.write(
'[WARNING] selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB or has no HLT data\n')
849 sortedresult=sorted(result,key=
lambda x :
int(
str(x[0]).
split(
':')[0]))
852 labels = [(
'Run:Fill',
'SelectedLS',
'Recorded',
'HLTpath(Presc)',
'L1bit(Presc)',
'Effective')]
854 print(tablePrinter.indent (labels+sortedresult, hasHeader =
True, separateRows =
False,
855 prefix =
'| ', postfix =
' |', justify =
'right',
857 print(
' == = Total : ')
858 lastrowlabels=[(
'HLTPath',
'SelectedLS',
'Recorded',
'Effective')]
860 for hname
in sorted(totdict):
865 selectedThispath=selectedPerpathPerrun[hname]
866 for runnumber,nselected
in selectedThispath.items():
867 if nselected==0:
continue 868 alltotrecorded+=recordedPerpathPerrun[hname][runnumber]
870 totresult.append([hname,
str(totnls),
'%.3f'%(alltotrecordedVal)+
'('+alltotrecordedunit+
')',
'%.3f'%(toteffval)+
'('+toteffunit+
')'])
871 print(tablePrinter.indent (lastrowlabels+totresult, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'right',
872 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,20) ))
874 fieldnames=[
'Run:Fill',
'SelectedLS',
'Recorded',
'HLTpath(Presc)',
'L1bit(Presc)',
'Effective(/ub)']
876 dumptocsv(fieldnames,sortedresult,filename)
880 input:{run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),bxdata(8),beamdata(9),fillnum(10)]} 882 fieldnames=['Run:Fill','LS','UTCTime','Delivered(/ub)','Recorded(/ub)','BX'] 886 fieldnames=[
'run:fill',
'ls',
'UTCTime',
'delivered(/ub)',
'recorded(/ub)',
'[bx,Hz/ub]']
888 for run
in sorted(lumidata):
889 rundata=lumidata[run]
891 result.append([
str(run)+
':0',
'n/a',
'n/a',
'n/a',
'n/a',
'n/a'])
892 if irunlsdict
and irunlsdict[run]:
893 print(
'[WARNING] selected but no lumi data for run '+
str(run))
896 if rundata
and rundata[0][10]:
897 fillnum=rundata[0][10]
898 if irunlsdict
and not noWarning:
899 existdata=[x[1]
for x
in rundata
if x[1] ]
900 datarunlsdict[run]=existdata
901 for lsdata
in rundata:
904 if lsdata
and lsdata[1]:
907 if lsdata
and lsdata[2]:
909 tsStr=ts.strftime(
'%m/%d/%y %H:%M:%S')
912 deliveredlumi=lsdata[5]
915 recordedlumi=lsdata[6]
916 (bxidxlist,bxvaluelist,bxerrorlist)=lsdata[8]
917 if irunlsdict
and irunlsdict[run]:
918 if run
in irunlsdict
and cmslsnum
in irunlsdict[run]:
919 if bxidxlist
and bxvaluelist:
922 bxresult=
CommonUtil.flatten([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo])
923 result.append(bxresult)
925 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor])
927 if bxidxlist
and bxvaluelist:
930 bxresult=
CommonUtil.flatten([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo])
931 result.append(bxresult)
933 result.append([
str(run)+
':'+
str(fillnum),
str(lumilsnum)+
':'+
str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor])
935 if filename.upper()==
'STDOUT':
937 r.write(
','.
join(fieldnames)+
'\n')
942 r.writeRow(fieldnames)
945 def toScreenLSTrg(trgdata,iresults=[],irunlsdict=None,noWarning=True,toFile=None,withoutmask=False):
947 input:{run:[[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(name,count,presc,mask),]],..] 951 for rline
in iresults:
954 if irunlsdict
and not noWarning:
955 if runnumStr
is not 'n/a' and int(runnumStr)
not in datarunlsdict:
956 datarunlsdict[
int(runnumstr)]=[]
957 if cmslsnumStr!=
'n/a':
960 for run
in trgdata.keys():
963 ll=[
str(run),
'n/a',
'n/a',
'n/a']
965 if irunlsdict
and not noWarning:
966 print(
'[WARNING] selected but no trg data for run '+
str(run))
968 if irunlsdict
and not noWarning:
969 existdata=[x[0]
for x
in rundata
if x[0] ]
970 datarunlsdict[run]=existdata
973 for lsdata
in rundata:
980 flatbitdata=[
"("+x[0]+
',%d'%x[1]+
',%d'%x[2]+
")" for x
in bitdata
if x[0]!=
'False']
981 bitdataStr=
' '.
join(flatbitdata)
984 flatbitdata=[
"("+x[0]+
',%d'%x[1]+
',%d'%x[2]+
")" for x
in bitdata
if x[0]!=
'False' and x[3]]
985 bitdataStr=
' '.
join(flatbitdata)
986 if irunlsdict
and irunlsdict[run]:
987 if run
in irunlsdict
and cmslsnum
in irunlsdict[run]:
988 result.append([
str(run),
str(cmslsnum),
'%.4f'%(deadfrac),bitdataStr])
990 result.append([
str(run),
str(cmslsnum),
'%.4f'%(deadfrac),bitdataStr])
991 if irunlsdict
and not noWarning:
992 for run,cmslslist
in irunlsdict.items():
993 if run
not in datarunlsdict.keys()
or datarunlsdict[run]
is None:
994 sys.stdout.write(
'[WARNING] selected run '+
str(run)+
' not in lumiDB or has no qualified data\n')
998 if ss
not in datarunlsdict[run]:
999 sys.stdout.write(
'[WARNING] selected run/ls '+
str(run)+
' '+
str(ss)+
' not in lumiDB\n')
1003 labels = [(
'Run',
'LS',
'dfrac',
'(bitname,count,presc)')]
1004 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,prefix =
'| ', postfix =
' |', justify =
'left',delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,70) ))
1007 fieldnames=[
'Run',
'LS',
'dfrac',
'(bitname,count,presc)']
1012 input:{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})} 1017 for run
in hltdata.keys():
1018 if hltdata[run]
is None:
1019 ll=[
str(run),
'n/a',
'n/a',
'n/a',
'n/a',
'n/a']
1021 perrundata=hltdata[run]
1022 for lsdata
in perrundata:
1024 allpathinfo=lsdata[1]
1026 for thispathinfo
in allpathinfo:
1027 thispathname=thispathinfo[0]
1028 thispathpresc=thispathinfo[1]
1032 thispathresult.append(thispathname)
1033 if thispathpresc
is None:
1036 thispathresult.append(
'%d'%thispathpresc)
1037 thisl1pass=thispathinfo[2]
1038 if thispathinfo[2]
is None:
1039 thispathresult.append(
'n/a')
1041 thispathresult.append(
'%d'%thisl1pass)
1042 thishltaccept=thispathinfo[3]
1043 if thispathinfo[3]
is None:
1044 thispathresult.append(
'n/a')
1046 thispathresult.append(
'%d'%thishltaccept)
1048 thispathresultStr=
'('+
','.
join(thispathresult)+
')' 1049 allpathresult.append(thispathresultStr)
1050 result.append([
str(run),
str(cmslsnum),
', '.
join(allpathresult)])
1054 labels = [(
'Run',
'LS',
'(hltpath,presc,l1pass,hltaccept)')]
1055 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,
1056 prefix =
'| ', postfix =
' |', justify =
'left',
1057 delim =
' | ', wrapfunc =
lambda x: wrap_onspace (x,70) ))
1059 fieldnames=[
'Run',
'LS',
'(hltpath,presc,l1pass,hltaccept)']
1065 input : {runnumber,[(hltpath,l1seedexpr,l1bitname),...]} 1070 pp=
' '.
join([pp[i:i+25]
for i
in range(0,len(pp),25)])
1072 sdepr=
' '.
join([sdepr[i:i+25]
for i
in range(0,len(sdepr),25)])
1074 lb=
' '.
join([lb[i:i+25]
for i
in range(0,len(lb),25)])
1075 result.append([r[0],pp,sdepr,lb])
1076 for run
in sorted(hltconfdata):
1077 pathdata=hltconfdata[run]
1078 if pathdata
is None:
1079 result.append([
str(run),
'n/a',
'n/a',
'n/a'])
1081 for thispathinfo
in pathdata:
1082 thispath=thispathinfo[0]
1083 thispath=
' '.
join([thispath[i:i+25]
for i
in range(0,len(thispath),25)])
1084 thisseed=thispathinfo[1]
1085 thisseed=
' '.
join([thisseed[i:i+25]
for i
in range(0,len(thisseed),25)]).
replace(
'"',
'')
1086 thisbit=thispathinfo[2]
1090 thisbit=
' '.
join([thisbit[i:i+25]
for i
in range(0,len(thisbit),25)]).
replace(
'"',
'')
1091 result.append([
str(run),thispath,thisseed,thisbit])
1093 labels=[(
'Run',
'hltpath',
'l1seedexpr',
'l1bit')]
1095 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,
1096 prefix =
'| ', postfix =
' |', justify =
'left',
1097 delim =
' | ', wrapfunc =
lambda x:
wrap_onspace(x,25) ))
1100 fieldnames=[
'Run',
'hltpath',
'l1seedexpr',
'l1bit']
1101 dumptocsv(fieldnames,sortedresult,filename)
1105 input: {run:[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(4)),..]} 1106 beaminfolist:[(bxidx,b1,b2)] 1109 for rline
in iresults:
1110 result.append(rline)
1111 for run
in sorted(beamdata):
1112 perrundata=beamdata[run]
1113 if perrundata
is None:
1114 ll=[
str(run),
'n/a',
'n/a']
1118 for lsdata
in perrundata:
1121 beamstatus=lsdata[2]
1122 beamenergy=lsdata[3]
1123 ncollidingbx=lsdata[4]
1124 if not dumpIntensity:
1125 result.append([
str(run),
str(lumilsnum)+
':'+
str(cmslsnum),beamstatus,
'%.2f'%beamenergy,
str(ncollidingbx)])
1129 for thisbxinfo
in allbxinfo:
1130 thisbxresultStr=
'(n/a,n/a,n/a,n/a)' 1134 thisbxresultStr=
','.
join([
'%d'%bxidx,
'%.3e'%b1,
'%.3e'%b2])
1135 allbxresult.append(thisbxresultStr)
1136 allbxresultStr=
' '.
join(allbxresult)
1137 result.append([
str(run),
str(lumilsnum)+
':'+
str(cmslsnum),beamstatus,
'%.2f'%beamenergy,
str(ncollidingbx),allbxresultStr])
1140 labels=[(
'Run',
'LS',
'beamstatus',
'egev',
'ncollidingbx')]
1142 labels=[(
'Run',
'LS',
'beamstatus',
'egev',
'ncollidingbx',
'(bxidx,b1,b2)')]
1144 print(tablePrinter.indent (labels+result, hasHeader =
True, separateRows =
False,
1145 prefix =
'| ', postfix =
' |', justify =
'left',
1146 delim =
' | ', wrapfunc =
lambda x:
wrap_onspace(x,25) ))
1148 fieldnames=[
'Run',
'LS',
'beamstatus',
'egev',
'ncollidingbx']
1150 fieldnames.append(
'(bxidx,b1,b2)')
1154 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)