CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
lumiReport Namespace Reference

Functions

def dumptocsv
 
def toCSVLumiByLSXing
 
def toScreenConfHlt
 
def toScreenHeader
 
def toScreenLSBeam
 
def toScreenLSEffective
 
def toScreenLSHlt
 
def toScreenLSTrg
 
def toScreenLumiByLS
 
def toScreenNormDetail
 
def toScreenNormSummary
 
def toScreenOverview
 
def toScreenSingleTag
 
def toScreenTags
 
def toScreenTotDelivered
 
def toScreenTotEffective
 

Function Documentation

def lumiReport.dumptocsv (   fieldnames,
  result,
  filename 
)
utility method to dump result to csv file

Definition at line 11 of file lumiReport.py.

References join().

Referenced by toScreenConfHlt(), toScreenLSBeam(), toScreenLSEffective(), toScreenLSHlt(), toScreenLSTrg(), toScreenLumiByLS(), toScreenOverview(), toScreenTotDelivered(), and toScreenTotEffective().

11 
12 def dumptocsv(fieldnames,result,filename):
13  '''
14  utility method to dump result to csv file
15  '''
16  assert(filename)
17  if filename.upper()=='STDOUT':
18  r=sys.stdout
19  r.write(','.join(fieldnames)+'\n')
20  for l in result:
21  r.write(str(l)+'\n')
22  else:
23  r=csvReporter.csvReporter(filename)
24  r.writeRow(fieldnames)
25  r.writeRows(result)
26  r.close()
def dumptocsv
Definition: lumiReport.py:11
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def lumiReport.toCSVLumiByLSXing (   lumidata,
  scalefactor,
  filename,
  irunlsdict = None,
  noWarning = True 
)
input:{run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),bxdata(8),beamdata(9),fillnum(10)]}
output:
fieldnames=['Run:Fill','LS','UTCTime','Delivered(/ub)','Recorded(/ub)','BX']

Definition at line 875 of file lumiReport.py.

References CommonUtil.flatten(), join(), and CommonUtil.transposed().

876 def toCSVLumiByLSXing(lumidata,scalefactor,filename,irunlsdict=None,noWarning=True):
877  '''
878  input:{run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),bxdata(8),beamdata(9),fillnum(10)]}
879  output:
880  fieldnames=['Run:Fill','LS','UTCTime','Delivered(/ub)','Recorded(/ub)','BX']
881  '''
882  result=[]
883  assert(filename)
884  fieldnames=['run:fill','ls','UTCTime','delivered(/ub)','recorded(/ub)','[bx,Hz/ub]']
885  datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with
886  for run in sorted(lumidata):
887  rundata=lumidata[run]
888  if rundata is None:
889  result.append([str(run)+':0','n/a','n/a','n/a','n/a','n/a'])
890  if irunlsdict and irunlsdict[run]:
891  print '[WARNING] selected but no lumi data for run '+str(run)
892  continue
893  fillnum=0
894  if rundata and rundata[0][10]:
895  fillnum=rundata[0][10]
896  if irunlsdict and not noWarning:
897  existdata=[x[1] for x in rundata if x[1] ]
898  datarunlsdict[run]=existdata
899  for lsdata in rundata:
900  lumilsnum=lsdata[0]
901  cmslsnum=0
902  if lsdata and lsdata[1]:
903  cmslsnum=lsdata[1]
904  tsStr='n/a'
905  if lsdata and lsdata[2]:
906  ts=lsdata[2]
907  tsStr=ts.strftime('%m/%d/%y %H:%M:%S')
908  deliveredlumi=0.
909  if lsdata[5]:
910  deliveredlumi=lsdata[5]
911  recordedlumi=0.
912  if lsdata[6]:
913  recordedlumi=lsdata[6]
914  (bxidxlist,bxvaluelist,bxerrorlist)=lsdata[8]
915  if irunlsdict and irunlsdict[run]:
916  if run in irunlsdict and cmslsnum in irunlsdict[run]:
917  if bxidxlist and bxvaluelist:
918  bxresult=[]
919  bxinfo=CommonUtil.transposed([bxidxlist,bxvaluelist])
920  bxresult=CommonUtil.flatten([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo])
921  result.append(bxresult)
922  else:
923  result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor])
924  else:
925  if bxidxlist and bxvaluelist:
926  bxresult=[]
927  bxinfo=CommonUtil.transposed([bxidxlist,bxvaluelist])
928  bxresult=CommonUtil.flatten([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor,bxinfo])
929  result.append(bxresult)
930  else:
931  result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),tsStr,deliveredlumi*scalefactor,recordedlumi*scalefactor])
932  r=None
933  if filename.upper()=='STDOUT':
934  r=sys.stdout
935  r.write(','.join(fieldnames)+'\n')
936  for l in result:
937  r.write(str(l)+'\n')
938  else:
939  r=csvReporter.csvReporter(filename)
940  r.writeRow(fieldnames)
941  r.writeRows(result)
def transposed
Definition: CommonUtil.py:146
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def flatten
Definition: CommonUtil.py:4
def toCSVLumiByLSXing
Definition: lumiReport.py:875
def lumiReport.toScreenConfHlt (   hltconfdata,
  iresults = [],
  toFile = None 
)
input : {runnumber,[(hltpath,l1seedexpr,l1bitname),...]}

Definition at line 1060 of file lumiReport.py.

References dumptocsv(), join(), linker.replace(), and dataformats.wrap_onspace().

1061 def toScreenConfHlt(hltconfdata,iresults=[],toFile=None):
1062  '''
1063  input : {runnumber,[(hltpath,l1seedexpr,l1bitname),...]}
1064  '''
1065  result=[]
1066  for r in iresults:
1067  pp=r[1]
1068  pp=' '.join([pp[i:i+25] for i in range(0,len(pp),25)])
1069  sdepr=r[2]
1070  sdepr=' '.join([sdepr[i:i+25] for i in range(0,len(sdepr),25)])
1071  lb=r[3]
1072  lb=' '.join([lb[i:i+25] for i in range(0,len(lb),25)])
1073  result.append([r[0],pp,sdepr,lb])
1074  for run in sorted(hltconfdata):
1075  pathdata=hltconfdata[run]
1076  if pathdata is None:
1077  result.append([str(run),'n/a','n/a','n/a'])
1078  continue
1079  for thispathinfo in pathdata:
1080  thispath=thispathinfo[0]
1081  thispath=' '.join([thispath[i:i+25] for i in range(0,len(thispath),25)])
1082  thisseed=thispathinfo[1]
1083  thisseed=' '.join([thisseed[i:i+25] for i in range(0,len(thisseed),25)]).replace('"','')
1084  thisbit=thispathinfo[2]
1085  if not thisbit:
1086  thisbit='n/a'
1087  else:
1088  thisbit=' '.join([thisbit[i:i+25] for i in range(0,len(thisbit),25)]).replace('"','')
1089  result.append([str(run),thispath,thisseed,thisbit])
1090  if not toFile:
1091  labels=[('Run','hltpath','l1seedexpr','l1bit')]
1092  print ' == = '
1093  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,
1094  prefix = '| ', postfix = ' |', justify = 'left',
1095  delim = ' | ', wrapfunc = lambda x: wrap_onspace(x,25) )
1096  else:
1097  filename=toFile
1098  fieldnames=['Run','hltpath','l1seedexpr','l1bit']
1099  dumptocsv(fieldnames,sortedresult,filename)
def toScreenConfHlt
Definition: lumiReport.py:1060
def wrap_onspace
Definition: dataformats.py:47
def replace
Definition: linker.py:10
def dumptocsv
Definition: lumiReport.py:11
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def lumiReport.toScreenHeader (   commandname,
  datatagname,
  normtag,
  worktag,
  updatetag,
  lumitype,
  toFile = None 
)
input:
   commandname: commandname
   datataginfo: tagname
   normtag: normtag
   worktag: working version
   updatetag: updated version if amy

Definition at line 27 of file lumiReport.py.

References join().

Referenced by toScreenLSBeam().

27 
28 def toScreenHeader(commandname,datatagname,normtag,worktag,updatetag,lumitype,toFile=None):
29  '''
30  input:
31  commandname: commandname
32  datataginfo: tagname
33  normtag: normtag
34  worktag: working version
35  updatetag: updated version if amy
36  '''
37  gmtnowStr=time.asctime(time.gmtime())+' UTC'
38  updatetagStr='None'
39  if updatetag:
40  updatetagStr=updatetag
41  header=''.join(['*']*80)+'\n'
42  header+='* '+gmtnowStr+'\n'
43  header+='* lumitype: '+lumitype+' , datatag: '+datatagname+' , normtag: '+normtag+' , worktag: '+worktag+'\n'
44  header+='* \n'
45  header+='* by:\n'
46  header+='* '+commandname+'\n'
47  header+='* \n'
48  header+='* update: '+updatetag+'\n'
49  header+=''.join(['*']*80)+'\n'
50  if not toFile:
51  sys.stdout.write(header)
52  else:
53  assert(toFile)
54  if toFile.upper()=='STDOUT':
55  r=sys.stdout
56  else:
57  r=open(toFile,'wb')
58  r.write(header)
def toScreenHeader
Definition: lumiReport.py:27
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def lumiReport.toScreenLSBeam (   beamdata,
  iresults = [],
  dumpIntensity = False,
  toFile = None 
)
input: {run:[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(4)),..]}
beaminfolist:[(bxidx,b1,b2)]

Definition at line 1100 of file lumiReport.py.

References dumptocsv(), join(), toScreenHeader(), and dataformats.wrap_onspace().

1101 def toScreenLSBeam(beamdata,iresults=[],dumpIntensity=False,toFile=None):
1102  '''
1103  input: {run:[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(4)),..]}
1104  beaminfolist:[(bxidx,b1,b2)]
1105  '''
1106  result=[]
1107  for rline in iresults:
1108  result.append(rline)
1109  for run in sorted(beamdata):
1110  perrundata=beamdata[run]
1111  if perrundata is None:
1112  ll=[str(run),'n/a','n/a']
1113  if dumpIntensity:
1114  ll.extend('n/a')
1115  continue
1116  for lsdata in perrundata:
1117  lumilsnum=lsdata[0]
1118  cmslsnum=lsdata[1]
1119  beamstatus=lsdata[2]
1120  beamenergy=lsdata[3]
1121  ncollidingbx=lsdata[4]
1122  if not dumpIntensity:
1123  result.append([str(run),str(lumilsnum)+':'+str(cmslsnum),beamstatus,'%.2f'%beamenergy,str(ncollidingbx)])
1124  continue
1125  allbxinfo=lsdata[5]
1126  allbxresult=[]
1127  for thisbxinfo in allbxinfo:
1128  thisbxresultStr='(n/a,n/a,n/a,n/a)'
1129  bxidx=thisbxinfo[0]
1130  b1=thisbxinfo[1]
1131  b2=thisbxinfo[2]
1132  thisbxresultStr=','.join(['%d'%bxidx,'%.3e'%b1,'%.3e'%b2])
1133  allbxresult.append(thisbxresultStr)
1134  allbxresultStr=' '.join(allbxresult)
1135  result.append([str(run),str(lumilsnum)+':'+str(cmslsnum),beamstatus,'%.2f'%beamenergy,str(ncollidingbx),allbxresultStr])
1136 
1137  if not toFile:
1138  labels=[('Run','LS','beamstatus','egev','ncollidingbx')]
1139  if dumpIntensity:
1140  labels=[('Run','LS','beamstatus','egev','ncollidingbx','(bxidx,b1,b2)')]
1141  print ' == = '
1142  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,
1143  prefix = '| ', postfix = ' |', justify = 'left',
1144  delim = ' | ', wrapfunc = lambda x: wrap_onspace(x,25) )
1145  else:
1146  fieldnames=['Run','LS','beamstatus','egev','ncollidingbx']
1147  if dumpIntensity:
1148  fieldnames.append('(bxidx,b1,b2)')
1149  filename=toFile
1150  dumptocsv(fieldnames,result,filename)
def wrap_onspace
Definition: dataformats.py:47
def toScreenLSBeam
Definition: lumiReport.py:1100
def dumptocsv
Definition: lumiReport.py:11
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def lumiReport.toScreenLSEffective (   lumidata,
  resultlines,
  scalefactor,
  irunlsdict = None,
  noWarning = True,
  toFile = None 
)
input:  {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),{hltpath:[l1name,l1prescale,hltprescale,efflumi]}(8),bxdata(9),beamdata(10),fillnum(11)]}

Definition at line 538 of file lumiReport.py.

References python.multivaluedict.append(), dumptocsv(), CommonUtil.lumiUnitForPrint(), split, and dataformats.wrap_onspace_strict().

539 def toScreenLSEffective(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
540  '''
541  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)]}
542  '''
543  result=[]#[run,ls,hltpath,l1bitname,hltpresc,l1presc,efflumi]
544  totalrow=[]
545  totSelectedLSDict={}
546  totRecordedDict={}
547  totEffectiveDict={}
548 
549  totOldSelectedLSDict={}
550  totOldRecordedDict={}
551  totOldEffectiveDict={}
552 
553  maxlslumi = 0.0
554  datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with
555  for rline in resultlines:
556  runfillstr=rline[0]
557  [runnumstr,fillnumstr]=runfillstr.split(':')
558  if irunlsdict and not noWarning:
559  if rline[1] is not 'n/a':
560  datarunlsdict[int(runnumstr)]=[]
561  myls=rline[1]
562  mypath=rline[2]
563 
564  if myls and myls!='n/a' and mpath and mpath!='n/a':
565  totOldSelectedLSDict[mypath]=0
566  totOldRecordedDict[mypath]=0.
567  totOldEffectiveDict[mypath]=0.
568  if myls!='n/a':
569  [luls,cmls]=myls.split(':')
570  if cmls!='0':
571  if totOldSelectedLSDict.has_key(mypath):
572  totOldSelectedLSDict[mypath]+=1
573  if irunlsdict and not noWarning:
574  datarunlsdict[int(runnumstr)].append(int(myls))
575  myrecorded=0.
576  if rline[6]!='n/a':
577  myrecorded=float(rline[6])
578  if myrecorded>maxlslumi:maxlslumi=myrecorded
579  if totOldRecordedDict.has_key(mypath):
580  totOldRecordedDict[mypath]+=myrecorded
581  rline[6]=myrecorded
582  myeff={}
583  if rline[7]!='n/a':
584  myeff=float(rline[7])
585  if totOldEffectiveDict.has_key(mypath):
586  totOldEffectiveDict[mypath]+=myeff
587  rline[7]=myeff
588  result.append(rline)
589 
590  for run in lumidata.keys():#loop over runs
591  lsdata=lumidata[run]
592  if not lsdata:
593  result.append([str(run),'n/a','n/a','n/a','n/a','n/a','n/a','n/a'])
594  if irunlsdict and irunlsdict[run] and not noWarning:
595  datarunlsdict[run]=None
596  continue
597  fillnum=0
598  if lsdata[0] and lsdata[0][11]:
599  fillnum=lsdata[0][11]
600  datarunlsdict[run]=[]
601  for thisls in lsdata:
602  lumilsnum=thisls[0]
603  cmslsnum=thisls[1]#triggered ls
604  if not cmslsnum: continue
605  efflumiDict=thisls[8]# this ls has no such path?
606  recordedlumi=0.
607  if thisls[6]:
608  recordedlumi=thisls[6]
609  if recordedlumi>maxlslumi:maxlslumi=recordedlumi
610  if not efflumiDict:
611  result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),'n/a','n/a','n/a','n/a',recordedlumi,'n/a'])
612  continue
613 
614  for hltpathname in sorted(efflumiDict):
615  if hltpathname and hltpathname !='n/a' :
616  if not totRecordedDict.has_key(hltpathname):
617  totRecordedDict[hltpathname]=0.
618  if not totSelectedLSDict.has_key(hltpathname):
619  totSelectedLSDict[hltpathname]=0
620  if not totEffectiveDict.has_key(hltpathname):
621  totEffectiveDict[hltpathname]=0.
622  totSelectedLSDict[hltpathname]+=1
623  totRecordedDict[hltpathname]+=recordedlumi
624  pathdata=efflumiDict[hltpathname]
625  l1name=pathdata[0]
626  cleanl1name='n/a'
627  if l1name:
628  cleanl1name=l1name.replace('"','')
629  l1presc='0'
630  if pathdata[1]:
631  l1presc=str(pathdata[1])
632  hltpresc='0'
633  if pathdata[2]:
634  hltpresc=str(pathdata[2])
635  lumival=0.
636  if pathdata[3]:
637  lumival=pathdata[3]
638  result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),hltpathname,cleanl1name,hltpresc,l1presc,recordedlumi,lumival])
639  if hltpathname and hltpathname !='n/a' :
640  totEffectiveDict[hltpathname]+=lumival
641  if irunlsdict and not noWarning:
642  datarunlsdict[run].append(int(cmslsnum))
643  sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0]))
644  if irunlsdict and not noWarning:
645  for run,cmslslist in irunlsdict.items():
646  if run not in datarunlsdict.keys() or datarunlsdict[run] is None:
647  sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no HLT data\n')
648  continue
649  if cmslslist:
650  for ss in cmslslist:
651  if ss not in datarunlsdict[run]:
652  sys.stdout.write('[WARNING] selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB or has no qualified data\n')
653 
654  if not toFile:
655  (lsunitstring,unitdenomitor)=CommonUtil.lumiUnitForPrint(maxlslumi*scalefactor)
656  labels = [('Run:Fill','LS','HLTpath','L1bit','HLTpresc','L1presc','Recorded('+lsunitstring+')','Effective('+lsunitstring+')')]
657  perlsresult=[]
658  for entry in sortedresult:
659  reclumi=entry[6]
660  if reclumi!='n/a':
661  reclumi='%.3f'%float(float(reclumi*scalefactor)/float(unitdenomitor))
662  efflumi=entry[7]
663  if efflumi!='n/a':
664  efflumi='%.3f'%float(float(efflumi*scalefactor)/float(unitdenomitor))
665  perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],entry[5],reclumi,efflumi])
666  print ' == = '
667  print tablePrinter.indent (labels+perlsresult, hasHeader = True, separateRows = False,
668  prefix = '| ', postfix = ' |', justify = 'right',
669  delim = ' | ', wrapfunc = lambda x: wrap_onspace_strict(x,25) )
670  for mpath in sorted(totRecordedDict):
671  totSelectedLS=totSelectedLSDict[mpath]
672  if totOldSelectedLSDict.has_key(mpath):
673  totSelectedLS+=totOldSelectedLS[mpath]
674  totRecorded=totRecordedDict[mpath]
675  if totOldRecordedDict.has_key(mpath):
676  totRecorded+=totOldRecorded[mpath]
677  totRecorded=float(totRecorded*scalefactor)/float(unitdenomitor)
678  totEffective=totEffectiveDict[mpath]
679  if totOldEffectiveDict.has_key(mpath):
680  totEffective+=totOldEffective[mpath]
681  totEffective=float(totEffective*scalefactor)/float(unitdenomitor)
682  totalrow.append([str(totSelectedLS),mpath,'%.3f'%(totRecorded),'%.3f'%(totEffective)])
683  lastrowlabels = [ ('Selected LS','HLTPath','Recorded('+lsunitstring+')','Effective('+lsunitstring+')')]
684  print ' == = Total : '
685  print tablePrinter.indent (lastrowlabels+totalrow, hasHeader = True, separateRows = False, prefix = '| ',
686  postfix = ' |', justify = 'right', delim = ' | ',
687  wrapfunc = lambda x: wrap_onspace (x, 20))
688  else:
689  fieldnames = ['Run:Fill','LS','HLTpath','L1bit','HLTpresc','L1presc','Recorded(/ub)','Effective(/ub)']
690  filename=toFile
691  dumptocsv(fieldnames,sortedresult,filename)
def toScreenLSEffective
Definition: lumiReport.py:538
def dumptocsv
Definition: lumiReport.py:11
def lumiUnitForPrint
Definition: CommonUtil.py:30
def wrap_onspace_strict
Definition: dataformats.py:63
double split
Definition: MVATrainer.cc:139
def lumiReport.toScreenLSHlt (   hltdata,
  iresults = [],
  toFile = None 
)
input:{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})}

Definition at line 1007 of file lumiReport.py.

References dumptocsv(), and join().

1008 def toScreenLSHlt(hltdata,iresults=[],toFile=None):
1009  '''
1010  input:{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})}
1011  '''
1012  result=[]
1013  for r in iresults:
1014  result.append(r)
1015  for run in hltdata.keys():
1016  if hltdata[run] is None:
1017  ll=[str(run),'n/a','n/a','n/a','n/a','n/a']
1018  continue
1019  perrundata=hltdata[run]
1020  for lsdata in perrundata:
1021  cmslsnum=lsdata[0]
1022  allpathinfo=lsdata[1]
1023  allpathresult=[]
1024  for thispathinfo in allpathinfo:
1025  thispathname=thispathinfo[0]
1026  thispathpresc=thispathinfo[1]
1027  thisl1pass=None
1028  thishltaccept=None
1029  thispathresult=[]
1030  thispathresult.append(thispathname)
1031  if thispathpresc is None:
1032  thispathpresc='n/a'
1033  else:
1034  thispathresult.append('%d'%thispathpresc)
1035  thisl1pass=thispathinfo[2]
1036  if thispathinfo[2] is None:
1037  thispathresult.append('n/a')
1038  else:
1039  thispathresult.append('%d'%thisl1pass)
1040  thishltaccept=thispathinfo[3]
1041  if thispathinfo[3] is None:
1042  thispathresult.append('n/a')
1043  else:
1044  thispathresult.append('%d'%thishltaccept)
1045 
1046  thispathresultStr='('+','.join(thispathresult)+')'
1047  allpathresult.append(thispathresultStr)
1048  result.append([str(run),str(cmslsnum),', '.join(allpathresult)])
1049 
1050  if not toFile:
1051  print ' == = '
1052  labels = [('Run', 'LS', '(hltpath,presc,l1pass,hltaccept)')]
1053  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,
1054  prefix = '| ', postfix = ' |', justify = 'left',
1055  delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,70) )
1056  else:
1057  fieldnames=['Run','LS','(hltpath,presc,l1pass,hltaccept)']
1058  filename=toFile
1059  dumptocsv(fieldnames,result,filename)
def toScreenLSHlt
Definition: lumiReport.py:1007
def dumptocsv
Definition: lumiReport.py:11
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def lumiReport.toScreenLSTrg (   trgdata,
  iresults = [],
  irunlsdict = None,
  noWarning = True,
  toFile = None,
  withoutmask = False 
)
input:{run:[[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(name,count,presc,mask),]],..]

Definition at line 942 of file lumiReport.py.

References python.multivaluedict.append(), dumptocsv(), and join().

943 def toScreenLSTrg(trgdata,iresults=[],irunlsdict=None,noWarning=True,toFile=None,withoutmask=False):
944  '''
945  input:{run:[[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(name,count,presc,mask),]],..]
946  '''
947  result=[]
948  datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with
949  for rline in iresults:
950  runnumStr=rline[0]
951  cmslsnumStr=rline[1]
952  if irunlsdict and not noWarning:
953  if runnumStr is not 'n/a' and not datarunlsdict.has_key(int(runnumStr)):
954  datarunlsdict[int(runnumstr)]=[]
955  if cmslsnumStr!='n/a':
956  datarunlsdict[int(runnumStr)].append(int(cmslsnumStr))
957  result.append(rline)
958  for run in trgdata.keys():
959  rundata=trgdata[run]
960  if not rundata:
961  ll=[str(run),'n/a','n/a','n/a']
962  result.append(ll)
963  if irunlsdict and not noWarning:
964  print '[WARNING] selected but no trg data for run '+str(run)
965  continue
966  if irunlsdict and not noWarning:
967  existdata=[x[0] for x in rundata if x[0] ]
968  datarunlsdict[run]=existdata
969  deadfrac=0.0
970  bitdataStr='n/a'
971  for lsdata in rundata:
972  cmslsnum=lsdata[0]
973  deadfrac=lsdata[1]
974  deadcount=lsdata[2]
975  bitdata=lsdata[5]# already sorted by name
976  if bitdata:
977  if withoutmask:
978  flatbitdata=["("+x[0]+',%d'%x[1]+',%d'%x[2]+")" for x in bitdata if x[0]!='False']
979  bitdataStr=' '.join(flatbitdata)
980  else:
981  #consider trg mask by default
982  flatbitdata=["("+x[0]+',%d'%x[1]+',%d'%x[2]+")" for x in bitdata if x[0]!='False' and x[3]]
983  bitdataStr=' '.join(flatbitdata)
984  if irunlsdict and irunlsdict[run]:
985  if run in irunlsdict and cmslsnum in irunlsdict[run]:
986  result.append([str(run),str(cmslsnum),'%.4f'%(deadfrac),bitdataStr])
987  else:
988  result.append([str(run),str(cmslsnum),'%.4f'%(deadfrac),bitdataStr])
989  if irunlsdict and not noWarning:
990  for run,cmslslist in irunlsdict.items():
991  if run not in datarunlsdict.keys() or datarunlsdict[run] is None:
992  sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no qualified data\n')
993  continue
994  if cmslslist:
995  for ss in cmslslist:
996  if ss not in datarunlsdict[run]:
997  sys.stdout.write('[WARNING] selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB\n')
998 
999  if not toFile:
1000  print ' == = '
1001  labels = [('Run', 'LS', 'dfrac','(bitname,count,presc)')]
1002  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,70) )
1003  else:
1004  filename=toFile
1005  fieldnames=['Run','LS','dfrac','(bitname,count,presc)']
1006  dumptocsv(fieldnames,result,filename)
def toScreenLSTrg
Definition: lumiReport.py:942
def dumptocsv
Definition: lumiReport.py:11
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def lumiReport.toScreenLumiByLS (   lumidata,
  resultlines,
  scalefactor,
  irunlsdict = None,
  noWarning = True,
  toFile = None 
)
input:
lumidata {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),(bxidx,bxvalues,bxerrs)(8),(bxidx,b1intensities,b2intensities)(9),fillnum(10),pu(11)]}
{run:None}  None means no run in lumiDB, 
{run:[]} [] means no lumi for this run in lumiDB
{run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB
{run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0
resultlines [[resultrow1],[resultrow2],...,] existing result row

Definition at line 392 of file lumiReport.py.

References python.multivaluedict.append(), dumptocsv(), CommonUtil.guessUnit(), CommonUtil.lumiUnitForPrint(), and split.

393 def toScreenLumiByLS(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
394  '''
395  input:
396  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)]}
397  {run:None} None means no run in lumiDB,
398  {run:[]} [] means no lumi for this run in lumiDB
399  {run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB
400  {run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0
401  resultlines [[resultrow1],[resultrow2],...,] existing result row
402  '''
403  result=[]
404  totalrow = []
405 
406  totalDeliveredLS = 0
407  totalSelectedLS = 0
408  totalDelivered = 0.0
409  totalRecorded = 0.0
410 
411  totOldDeliveredLS = 0
412  totOldSelectedLS = 0
413  totOldDelivered = 0.0
414  totOldRecorded = 0.0
415 
416  maxlslumi = 0.0
417  datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with
418  for rline in resultlines:
419  runfillstr=rline[0]
420  [runnumstr,fillnumstr]=runfillstr.split(':')
421  if irunlsdict and not noWarning:
422  if rline[1] is not 'n/a':
423  datarunlsdict[int(runnumstr)]=[]
424  myls=rline[1]
425  if myls!='n/a':
426  [luls,cmls]=myls.split(':')
427  totOldDeliveredLS+=1
428  if cmls!='0':
429  totOldSelectedLS+=1
430  if irunlsdict and not noWarning:
431  datarunlsdict[int(runnumstr)].append(int(myls))
432  dl=rline[5]
433  if rline[5]!='n/a':
434  dl=float(rline[5])#delivered in /ub
435  if dl>maxlslumi: maxlslumi=dl
436  rline[5]=dl
437  totOldDelivered+=dl
438  rl=rline[6]
439  if rline[6]!='n/a':
440  rl=float(rline[6])#recorded in /ub
441  rline[6]=rl
442  totOldRecorded+=rl
443  result.append(rline)
444 
445  for run in lumidata.keys():
446  lsdata=lumidata[run]
447  if not lsdata:
448  #result.append([str(run),'n/a','n/a','n/a','n/a','n/a','n/a','n/a'])
449  if irunlsdict and irunlsdict[run] and not noWarning:
450  datarunlsdict[run]=None
451  #print '[WARNING] selected but no lumi data for run '+str(run)
452  continue
453  fillnum=0
454  if lsdata[0] and lsdata[0][10]:
455  fillnum=lsdata[0][10]
456  existdata=[]
457  #if irunlsdict and not noWarning:
458  # existdata=[x[1] for x in rundata if x[1] ]
459  # datarunlsdict[run]=existdata
460  for perlsdata in lsdata:
461  lumilsnum=perlsdata[0]
462  cmslsnum=perlsdata[1]#triggered ls
463  if not noWarning:
464  if cmslsnum:
465  existdata.append(cmslsnum)
466  ts=perlsdata[2]
467  bs=perlsdata[3]
468  begev=perlsdata[4]
469  deliveredlumi=perlsdata[5]
470  npu=perlsdata[11]
471  if deliveredlumi>maxlslumi: maxlslumi=deliveredlumi
472  recordedlumi=0.
473  if perlsdata[6]:
474  recordedlumi=perlsdata[6]
475  if irunlsdict and irunlsdict[run]:
476  if run in irunlsdict and lumilsnum in irunlsdict[run]:
477  result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),ts.strftime('%m/%d/%y %H:%M:%S'),bs,'%.1f'%begev,deliveredlumi,recordedlumi,npu])
478  totalDelivered+=deliveredlumi
479  totalRecorded+=recordedlumi
480  totalDeliveredLS+=1
481  totalSelectedLS+=1
482  else:
483  result.append([str(run)+':'+str(fillnum),str(lumilsnum)+':'+str(cmslsnum),ts.strftime('%m/%d/%y %H:%M:%S'),bs,'%.1f'%begev,deliveredlumi,recordedlumi,npu])
484  totalDelivered+=deliveredlumi
485  totalRecorded+=recordedlumi
486  totalDeliveredLS+=1
487  if cmslsnum :
488  totalSelectedLS+=1
489  datarunlsdict[run]=existdata
490  sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0]))
491  if irunlsdict and not noWarning:
492  for run,cmslslist in irunlsdict.items():
493  if run not in datarunlsdict.keys() or datarunlsdict[run] is None:
494  sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no qualified data\n')
495  continue
496  if cmslslist:
497  for ss in cmslslist:
498  if ss not in datarunlsdict[run]:
499  sys.stdout.write('[WARNING] lumi or trg for selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB\n')
500  if not toFile:
501  (lsunitstring,unitdenomitor)=CommonUtil.lumiUnitForPrint(maxlslumi*scalefactor)
502  labels = [ ('Run:Fill','LS','UTCTime','Beam Status','E(GeV)','Del('+lsunitstring+')','Rec('+lsunitstring+')','avgPU') ]
503  perlsresult=[]
504  for entry in sortedresult:
505  delumi=entry[5]
506  if delumi!='n/a':
507  delumi='%.3f'%float(float(delumi*scalefactor)/float(unitdenomitor))
508  reclumi=entry[6]
509  if reclumi!='n/a':
510  reclumi='%.3f'%float(float(reclumi*scalefactor)/float(unitdenomitor))
511  avgPU=entry[7]
512  if avgPU!='n/a':
513  if avgPU>0:
514  avgPU='%.3f'%avgPU
515  else:
516  avgPU='0'
517  perlsresult.append([entry[0],entry[1],entry[2],entry[3],entry[4],delumi,reclumi,avgPU])
518  totdeliveredlumi=0.0
519  deliveredlumiunit='/ub'
520  (totdeliveredlumi,deliveredlumiunit)=CommonUtil.guessUnit((totalDelivered+totOldDelivered)*scalefactor)
521  totrecordedlumi=0.0
522  recordedlumiunit='/ub'
523  (totrecordedlumi,recordedlumiunit)=CommonUtil.guessUnit((totalRecorded+totOldRecorded)*scalefactor)
524  lastrowlabels = [ ('Delivered LS','Selected LS', 'Delivered('+deliveredlumiunit+')', 'Recorded('+recordedlumiunit+')')]
525  totalrow.append ([str(totalDeliveredLS+totOldDeliveredLS),str(totalSelectedLS+totOldSelectedLS),'%.3f'%(totdeliveredlumi),'%.3f'%(totrecordedlumi)])
526  print ' == = '
527  print tablePrinter.indent (labels+perlsresult, hasHeader = True, separateRows = False, prefix = '| ',
528  postfix = ' |', justify = 'right', delim = ' | ',
529  wrapfunc = lambda x: wrap_onspace_strict (x, 22))
530  print ' == = Total : '
531  print tablePrinter.indent (lastrowlabels+totalrow, hasHeader = True, separateRows = False, prefix = '| ',
532  postfix = ' |', justify = 'right', delim = ' | ',
533  wrapfunc = lambda x: wrap_onspace (x, 20))
534  else:
535  fieldnames=['Run:Fill','LS','UTCTime','Beam Status','E(GeV)','Delivered(/ub)','Recorded(/ub)','avgPU']
536  filename=toFile
537  dumptocsv(fieldnames,sortedresult,filename)
def toScreenLumiByLS
Definition: lumiReport.py:392
def dumptocsv
Definition: lumiReport.py:11
def lumiUnitForPrint
Definition: CommonUtil.py:30
def guessUnit
Definition: CommonUtil.py:59
double split
Definition: MVATrainer.cc:139
def lumiReport.toScreenNormDetail (   normname,
  norminfo,
  normvalues 
)
list norm detail
input:
    normname
    norminfo=[data_id[0],lumitype(1)istypedefault[2],comment[3],creationtime[4]]
    normvalues={since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}

Definition at line 76 of file lumiReport.py.

76 
77 def toScreenNormDetail(normname,norminfo,normvalues):
78  '''
79  list norm detail
80  input:
81  normname
82  norminfo=[data_id[0],lumitype(1)istypedefault[2],comment[3],creationtime[4]]
83  normvalues={since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]}
84  '''
85  lumitype=norminfo[1]
86  istypedefault=norminfo[2]
87  print '=========================================================='
88  print '* Norm: '+normname
89  print '* Type: '+lumitype
90  print '* isDefault: '+str(istypedefault)
91  print '=========================================================='
92  labels=[('Since','Func','Parameters','amodetag','egev','comment')]
93 
94  result=[]
95  print ' == = '
96  for since in sorted(normvalues):
97  normdata=normvalues[since]
98  correctorStr=normdata[0]
99  paramDict=normdata[1]
100  paramDictStr=''
101  count=0
102  for pname in sorted(paramDict):
103  pval=paramDict[pname]
104  if count!=0:
105  paramDictStr+=' '
106  try:
107  fpval=float(pval)
108  if fpval<1.:
109  paramDictStr+=pname+':'+'%.4f'%fpval
110  else:
111  paramDictStr+=pname+':'+'%.2f'%fpval
112  except ValueError:
113  paramDictStr+=pname+':'+pval
114  count+=1
115  amodetag=normdata[2]
116  egev=str(normdata[3])
117  comment=normdata[4]
118  result.append([str(since),correctorStr,paramDictStr,amodetag,egev,comment])
119  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,40) )
def toScreenNormDetail
Definition: lumiReport.py:76
def lumiReport.toScreenNormSummary (   allnorms)
list all known norms summary
input: {normname:[data_id(0),lumitype(1),istypedefault(2),comment(3),creationtime(4)]}

Definition at line 59 of file lumiReport.py.

59 
60 def toScreenNormSummary(allnorms):
61  '''
62  list all known norms summary
63  input: {normname:[data_id(0),lumitype(1),istypedefault(2),comment(3),creationtime(4)]}
64  '''
65  result=[]
66  labels=[('Name','Type','IsTypeDefault','Comment','CreationTime')]
67  print ' == = '
68  sorted_allnorms=sorted(allnorms.iteritems(),key=lambda x:x[0],reverse=True)
69  for (normname,normvalues) in sorted_allnorms:
70  lumitype=normvalues[1]
71  istypedefault=str(normvalues[2])
72  commentStr=normvalues[3]
73  creationtime=normvalues[4]
74  result.append([normname,lumitype,istypedefault,commentStr,creationtime])
75  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) )
def toScreenNormSummary
Definition: lumiReport.py:59
def lumiReport.toScreenOverview (   lumidata,
  resultlines,
  scalefactor,
  irunlsdict = None,
  noWarning = True,
  toFile = None 
)
input:
lumidata {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),(bxidx,bxvalues,bxerrs)(8),(bxidx,b1intensities,b2intensities)(9),fillnum(10)]}
resultlines [[resultrow1],[resultrow2],...,] existing result row

Definition at line 260 of file lumiReport.py.

References dumptocsv(), CommonUtil.guessUnit(), if(), split, and CommonUtil.splitlistToRangeString().

261 def toScreenOverview(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
262  '''
263  input:
264  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)]}
265  resultlines [[resultrow1],[resultrow2],...,] existing result row
266  '''
267  result=[]
268 
269  totOldDeliveredLS=0
270  totOldSelectedLS=0
271  totOldDelivered=0.0
272  totOldRecorded=0.0
273 
274  totaltable=[]
275  totalDeliveredLS = 0
276  totalSelectedLS = 0
277  totalDelivered = 0.0
278  totalRecorded = 0.0
279  datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with
280  for r in resultlines:
281  runfillstr=r[0]
282  [runnumstr,fillnumstr]=runfillstr.split(':')
283  if irunlsdict and not noWarning:
284  if r[1] is not 'n/a':
285  datarunlsdict[int(runnumstr)]=[]
286  dl=0.0
287  if(r[2]!='n/a'):
288  dl=float(r[2])#delivered in /ub because it comes from file!
289  (rr,lumiu)=CommonUtil.guessUnit(dl)
290  r[2]='%.3f'%(rr)+' ('+lumiu+')'
291  dls=0
292  if(r[1]!='n/a'):
293  dls=int(r[1])
294  totOldDeliveredLS+=dls
295  totOldDelivered+=dl
296  rls=0
297  if(r[3]!='n/a'):
298  rlsstr=r[3]
299  listcomp=rlsstr.split(', ')
300  for lstr in listcomp:
301  enddigs=lstr[1:-1].split('-')
302  lsmin=int(enddigs[0])
303  lsmax=int(enddigs[1])
304  rls=lsmax-lsmin+1
305  totOldSelectedLS+=rls
306  if(r[4]!='n/a'):
307  rcd=float(r[4])#recorded in /ub because it comes from file!
308  (rrcd,rlumiu)=CommonUtil.guessUnit(rcd)
309  r[4]='%.3f'%(rrcd)+' ('+rlumiu+')'
310  totOldRecorded+=rcd
311  result.append(r)
312  for run in lumidata.keys():
313  lsdata=lumidata[run]
314  if not lsdata:
315  result.append([str(run)+':0','n/a','n/a','n/a','n/a'])
316  if irunlsdict and irunlsdict[run] and not noWarning:
317  datarunlsdict[run]=None
318  continue
319  fillnum=0
320  if lsdata[0] and lsdata[0][10]:
321  fillnum=lsdata[0][10]
322  deliveredData=[]
323  recordedData=[]
324  nls=0
325  existdata=[]
326  selectedcmsls=[]
327  for perlsdata in lsdata:
328  lumilsnum=perlsdata[0]
329  cmslsnum=perlsdata[1]
330  if not noWarning:
331  if cmslsnum:
332  existdata.append(cmslsnum)
333  if irunlsdict and irunlsdict[run]:
334  if lumilsnum and lumilsnum in irunlsdict[run]:
335  if perlsdata[5] is not None:
336  deliveredData.append(perlsdata[5])
337  if perlsdata[6]:
338  recordedData.append(perlsdata[6])
339  selectedcmsls.append(lumilsnum)
340  else:
341  deliveredData.append(perlsdata[5])
342  if perlsdata[6]:
343  recordedData.append(perlsdata[6])
344  if cmslsnum:
345  selectedcmsls.append(cmslsnum)
346  datarunlsdict[run]=existdata
347  nls=len(deliveredData)
348  totdelivered=sum(deliveredData)
349  totalDelivered+=totdelivered
350  totalDeliveredLS+=len(deliveredData)
351  (totdeliveredlumi,deliveredlumiunit)=CommonUtil.guessUnit(totdelivered)
352  totrecorded=sum(recordedData)
353  totalRecorded+=totrecorded
354  (totrecordedlumi,recordedlumiunit)=CommonUtil.guessUnit(totrecorded)
355  totalSelectedLS+=len(selectedcmsls)
356  if len(selectedcmsls)==0:
357  selectedlsStr='n/a'
358  else:
359  selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls)
360  if not toFile:
361  result.append([str(run)+':'+str(fillnum),str(nls),'%.3f'%(totdeliveredlumi*scalefactor)+' ('+deliveredlumiunit+')',selectedlsStr,'%.3f'%(totrecordedlumi*scalefactor)+' ('+recordedlumiunit+')'])
362  else:
363  result.append([str(run)+':'+str(fillnum),nls,totdelivered*scalefactor,selectedlsStr,totrecorded*scalefactor])
364  sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0]))
365  if irunlsdict and not noWarning:
366  for run,cmslslist in irunlsdict.items():
367  if run not in datarunlsdict.keys() or datarunlsdict[run] is None:
368  sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no qualified data\n')
369  continue
370  if cmslslist:
371  for ss in cmslslist:
372  if ss not in datarunlsdict[run]:
373  sys.stdout.write('[WARNING] lumi or trg for selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB\n')
374  if not toFile:
375  labels = [('Run:Fill', 'Delivered LS', 'Delivered','Selected LS','Recorded')]
376  print ' == = '
377  print tablePrinter.indent (labels+sortedresult, hasHeader = True, separateRows = False,
378  prefix = '| ', postfix = ' |', justify = 'right',
379  delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) )
380  print ' == = Total : '
381  (totalDeliveredVal,totalDeliveredUni)=CommonUtil.guessUnit(totalDelivered+totOldDelivered)
382  (totalRecordedVal,totalRecordedUni)=CommonUtil.guessUnit(totalRecorded+totOldRecorded)
383  totrowlabels = [('Delivered LS','Delivered('+totalDeliveredUni+')','Selected LS','Recorded('+totalRecordedUni+')')]
384  totaltable.append([str(totalDeliveredLS+totOldDeliveredLS),'%.3f'%(totalDeliveredVal*scalefactor),str(totalSelectedLS+totOldSelectedLS),'%.3f'%(totalRecordedVal*scalefactor)])
385  print tablePrinter.indent (totrowlabels+totaltable, hasHeader = True, separateRows = False, prefix = '| ',
386  postfix = ' |', justify = 'right', delim = ' | ',
387  wrapfunc = lambda x: wrap_onspace (x, 20))
388  else:
389  fieldnames = ['Run:Fill', 'DeliveredLS', 'Delivered(/ub)','SelectedLS','Recorded(/ub)']
390  filename=toFile
391  dumptocsv(fieldnames,sortedresult,filename)
def toScreenOverview
Definition: lumiReport.py:260
def splitlistToRangeString
Definition: CommonUtil.py:256
def dumptocsv
Definition: lumiReport.py:11
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def guessUnit
Definition: CommonUtil.py:59
double split
Definition: MVATrainer.cc:139
def lumiReport.toScreenSingleTag (   taginfo)
input: {run:(lumidataid,trgdataid,hltdataid,comment)}

Definition at line 135 of file lumiReport.py.

References join().

136 def toScreenSingleTag(taginfo):
137  '''
138  input: {run:(lumidataid,trgdataid,hltdataid,comment)}
139  '''
140  result=[]
141  labels=[('Run','Data Id','Insertion Time','Patch Comment')]
142  print ' == = '
143  for run in sorted(taginfo):
144  (lumidataid,trgdataid,hltdataid,(ctimestr,comment))=taginfo[run]
145  payloadid='-'.join([str(lumidataid),str(trgdataid),str(hltdataid)])
146  result.append([str(run),payloadid,ctimestr,comment])
147  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,25) )
def toScreenSingleTag
Definition: lumiReport.py:135
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def lumiReport.toScreenTags (   tagdata)

Definition at line 120 of file lumiReport.py.

121 def toScreenTags(tagdata):
122  result=[]
123  labels=[('Name','Min Run','Max Run','Creation Time')]
124  print ' == = '
125  for tagid in sorted(tagdata):
126  taginfo=tagdata[tagid]
127  name=taginfo[0]
128  minRun=str(taginfo[1])
129  maxRun='Open'
130  if taginfo[2]!=0:
131  maxRun=str(taginfo[2])
132  creationtime=taginfo[3]
133  result.append([name,minRun,maxRun,creationtime])
134  print tablePrinter.indent (labels+result, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'left',delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) )
def toScreenTags
Definition: lumiReport.py:120
def lumiReport.toScreenTotDelivered (   lumidata,
  resultlines,
  scalefactor,
  irunlsdict = None,
  noWarning = True,
  toFile = None 
)
inputs:
lumidata {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierror(6),(bxidx,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum)(9)]}  
resultlines [[resultrow1],[resultrow2],...,] existing result row
            ('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)')
irunlsdict: run/ls selection list. irunlsdict=None means no filter

Definition at line 148 of file lumiReport.py.

References dumptocsv(), CommonUtil.guessUnit(), if(), and split.

149 def toScreenTotDelivered(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
150  '''
151  inputs:
152  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)]}
153  resultlines [[resultrow1],[resultrow2],...,] existing result row
154  ('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)')
155  irunlsdict: run/ls selection list. irunlsdict=None means no filter
156  '''
157  result=[]
158  totOldDeliveredLS=0
159  totOldCMSLS=0
160  totOldDelivered=0.0
161  datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with
162  for r in resultlines:
163  runfillstr=r[0]
164  [runnumstr,fillnumstr]=runfillstr.split(':')
165  if irunlsdict and not noWarning:
166  if r[1] is not 'n/a':
167  datarunlsdict[int(runnumstr)]=[]
168  dl=0.0
169  if(r[3]!='n/a'): #delivered
170  dl=float(r[3])#in /ub because it comes from file!
171  (rr,lumiu)=CommonUtil.guessUnit(dl)
172  r[3]='%.3f'%(rr)+' ('+lumiu+')'
173  sls=0
174  if(r[1]!='n/a'): #n_ls
175  sls=int(r[1])
176  totcmsls=0
177  if(r[2]!='n/a'):#n_cmsls
178  totcmsls=int(r[2])
179  totOldDeliveredLS+=sls
180  totOldCMSLS+=totcmsls
181  totOldDelivered+=dl
182  if(r[5]!='n/a'): #egev
183  egv=float(r[5])
184  r[5]='%.1f'%egv
185  result.append(r)
186  totls=0
187  totcmsls=0
188  totdelivered=0.0
189  totaltable=[]
190  for run in lumidata.keys():
191  lsdata=lumidata[run]
192  if not lsdata:
193  result.append([str(run)+':0','n/a','n/a','n/a','n/a','n/a'])
194  if irunlsdict and not noWarning:
195  datarunlsdict[run]=None
196  continue
197  fillnum=0
198  if lsdata[0] and lsdata[0][9]:
199  fillnum=lsdata[0][9]
200  deliveredData=[]
201  nls=0
202  existdata=[]
203  selectedcmsls=[]
204  for perlsdata in lsdata:
205  lumilsnum=perlsdata[0]
206  cmslsnum=perlsdata[1]
207  if not noWarning:
208  if cmslsnum:
209  existdata.append(cmslsnum)
210  if irunlsdict and irunlsdict[run]:
211  if lumilsnum and lumilsnum in irunlsdict[run]:
212  deliveredData.append(perlsdata[5])
213  if cmslsnum:
214  selectedcmsls.append(cmslsnum)
215  else:
216  deliveredData.append(perlsdata[5])
217  if cmslsnum:
218  selectedcmsls.append(cmslsnum)
219  datarunlsdict[run]=existdata
220  nls=len(deliveredData)
221  ncmsls=0
222  if selectedcmsls:
223  ncmsls=len(selectedcmsls)
224  totcmsls+=ncmsls
225  totls+=nls
226  totlumi=sum(deliveredData)
227  totdelivered+=totlumi
228  (totlumival,lumiunit)=CommonUtil.guessUnit(totlumi)
229  beamenergyPerLS=[float(x[4]) for x in lsdata if x[3]=='STABLE BEAMS']
230  avgbeamenergy=0.0
231  if len(beamenergyPerLS):
232  avgbeamenergy=sum(beamenergyPerLS)/len(beamenergyPerLS)
233  runstarttime='n/a'
234  if lsdata[0] and lsdata[0][2]:
235  runstarttime=lsdata[0][2]
236  runstarttime=runstarttime.strftime("%m/%d/%y %H:%M:%S")
237  if not toFile:
238  result.append([str(run)+':'+str(fillnum),str(nls),str(ncmsls),'%.3f'%(totlumival*scalefactor)+' ('+lumiunit+')',runstarttime,'%.1f'%(avgbeamenergy)])
239  else:
240  result.append([str(run)+':'+str(fillnum),str(nls),str(ncmsls),(totlumi*scalefactor),runstarttime,'%.1f'%(avgbeamenergy)])
241  sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0]))
242  #print 'sortedresult ',sortedresult
243  if not toFile:
244  labels = [('Run:Fill', 'N_LS','N_CMSLS','Delivered','UTCTime','E(GeV)')]
245  print ' == = '
246  print tablePrinter.indent (labels+sortedresult, hasHeader = True, separateRows = False,
247  prefix = '| ', postfix = ' |', justify = 'right',
248  delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,40) )
249  print ' == = Total : '
250  (totalDeliveredVal,totalDeliveredUni)=CommonUtil.guessUnit(totdelivered+totOldDelivered)
251  totrowlabels = [('Delivered LS','Total CMS LS','Delivered('+totalDeliveredUni+')')]
252  totaltable.append([str(totls+totOldDeliveredLS),str(totcmsls+totOldCMSLS),'%.3f'%(totalDeliveredVal*scalefactor)])
253  print tablePrinter.indent (totrowlabels+totaltable, hasHeader = True, separateRows = False, prefix = '| ',
254  postfix = ' |', justify = 'right', delim = ' | ',
255  wrapfunc = lambda x: wrap_onspace (x, 20))
256  else:
257  fieldnames = ['Run:Fill', 'N_LS','N_CMSLS','Delivered(/ub)','UTCTime','E(GeV)']
258  filename=toFile
259  dumptocsv(fieldnames,sortedresult,filename)
def toScreenTotDelivered
Definition: lumiReport.py:148
def dumptocsv
Definition: lumiReport.py:11
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def guessUnit
Definition: CommonUtil.py:59
double split
Definition: MVATrainer.cc:139
def lumiReport.toScreenTotEffective (   lumidata,
  resultlines,
  scalefactor,
  irunlsdict = None,
  noWarning = True,
  toFile = None 
)
input:  {run:[lumilsnum(0),triggeredls(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),{hltpath:[l1name,l1prescale,hltprescale,efflumi]}(8),bxdata(9),beamdata](10),fillnum(11)}
screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective

Definition at line 692 of file lumiReport.py.

References python.multivaluedict.append(), dumptocsv(), CommonUtil.guessUnit(), join(), list(), runtimedef.set(), split, CommonUtil.splitlistToRangeString(), and dataformats.wrap_onspace_strict().

693 def toScreenTotEffective(lumidata,resultlines,scalefactor,irunlsdict=None,noWarning=True,toFile=None):
694 
695  '''
696  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)}
697  screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective
698  '''
699  result=[]#[run,selectedlsStr,recordedofthisrun,hltpath,l1bit,efflumi]
700 
701  totdict={}#{hltpath:[nls,toteff]}
702  selectedcmsls=[]
703  alltotrecorded=0.0
704  alleffective=0.0
705  recordedPerpathPerrun={}#{path:{run:recorded}}
706  selectedPerpathPerrun={}#{path:{run:totselected}}
707  datarunlsdict={}#{run:[ls,...]}from data. construct it only if there is irunlsdict to compare with
708  for rline in resultlines:
709  runfillstr=rline[0]
710  [runnumstr,fillnumstr]=runfillstr.split(':')
711  myls=rline[1]
712  if irunlsdict and not noWarning:
713  if myls is not 'n/a':
714  datarunlsdict[int(runnumstr)]=[]
715  mypath=rline[3]
716  if mypath!='n/a':
717  mypath=mypath.split('(')[0]
718  if not totdict.has_key(mypath):
719  totdict[mypath]=[0,0.0]
720  recordedPerpathPerrun[mypath]={}
721  selectedPerpathPerrun[mypath]={}
722  if myls!='n/a':
723  listcomp=myls.split(', ')
724  for lstr in listcomp:
725  enddigs=lstr[1:-1].split('-')
726  lsmin=int(enddigs[0])
727  lsmax=int(enddigs[1])
728  rls=lsmax-lsmin+1
729  totdict[mypath][0]+=rls
730  selectedPerrun[mypath].setdefault(int(myrun),totdict[mypath][0])
731  myrecorded=rline[2]
732  if myrecorded!='n/a':
733  recordedPerpathPerrun[mypath].setdefault(int(myrun),float(myrecorded))
734  (rr,lumiu)=CommonUtil.guessUnit(float(myrecorded))
735  rline[2]='%.3f'%(rr)+' ('+lumiu+')'
736  myeff=rline[5]
737  if myeff!='n/a':
738  reff=float(myeff)
739  (rr,lumiu)=CommonUtil.guessUnit(float(reff))
740  rline[5]='%.3f'%(rr)+' ('+lumiu+')'
741  totdict[mypath][1]+=reff
742  result.append(rline)
743  for run in lumidata.keys():#loop over runs
744  lsdata=lumidata[run]
745  hprescdict={}
746  lprescdict={}
747  if not lsdata:
748  result.append([str(run),'n/a','n/a','n/a','n/a','n/a'])
749  if irunlsdict and irunlsdict[run] and not noWarning:
750  datarunlsdict[run]=None
751  continue
752  fillnum=0
753  if lsdata[0] and lsdata[0][11]:
754  fillnum=lsdata[0][11]
755  selectedcmsls=[x[1] for x in lsdata if x[1]]
756  totefflumiDict={}
757  totrecorded=0.0
758  toteffective=0.0
759  pathmap={}#{hltpathname:1lname}
760  existdata=[]
761  for thisls in lsdata:
762  cmslsnum=thisls[1]
763  if not noWarning:
764  if cmslsnum:
765  existdata.append(cmslsnum)
766  efflumiDict=thisls[8]# this ls has no such path?
767  recordedlumi=0.0
768  if thisls[6]:
769  recordedlumi=thisls[6]
770  totrecorded+=recordedlumi
771  if not efflumiDict:#no hltdata for this LS
772  lumival=0.
773  if cmslsnum in selectedcmsls:
774  selectedcmsls.remove(cmslsnum)
775  continue
776  for hltpathname in sorted(efflumiDict):
777  pathdata=efflumiDict[hltpathname]
778  if not totefflumiDict.has_key(hltpathname):
779  totefflumiDict[hltpathname]=0.0
780  pathmap[hltpathname]='n/a'
781  l1name=pathdata[0]
782  l1presc=pathdata[1]
783  hltpresc=pathdata[2]
784  lumival=pathdata[3]
785  recordedPerpathPerrun.setdefault(hltpathname,{})
786  selectedPerpathPerrun.setdefault(hltpathname,{})
787  if not totdict.has_key(hltpathname):
788  totdict[hltpathname]=[0,0.0]
789  if l1presc is None or hltpresc is None:#if found all null prescales and if it is in the selectedcmsls, remove it because incomplete
790  if cmslsnum in selectedcmsls:
791  selectedcmsls.remove(cmslsnum)
792  else:
793  if not hprescdict.has_key(hltpathname):
794  hprescdict[hltpathname]=[]
795  hprescdict[hltpathname].append(hltpresc)
796  if not lprescdict.has_key(l1name):
797  lprescdict[l1name]=[]
798  lprescdict[l1name].append(l1presc)
799  if cmslsnum!=0:
800  totdict[hltpathname][0]+=1
801  if lumival:
802  totdict[hltpathname][1]+=lumival
803  totefflumiDict[hltpathname]+=lumival
804  pathmap[hltpathname]=l1name
805  recordedPerpathPerrun[hltpathname][run]=totrecorded
806  selectedPerpathPerrun[hltpathname][run]=len(selectedcmsls)
807  if len(selectedcmsls)==0:
808  selectedlsStr='n/a'
809  else:
810  selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls)
811  if irunlsdict and not noWarning:
812  datarunlsdict[run]=selectedcmsls
813 
814  for name in sorted(totefflumiDict):
815  lname=pathmap[name]
816  totrecordedinrun=recordedPerpathPerrun[name][run]
817  hprescs=list(set(hprescdict[name]))
818  hprescStr='('+','.join(['%d'%(x) for x in hprescs])+')'
819  (totrecval,totrecunit)=CommonUtil.guessUnit(totrecordedinrun*scalefactor)
820  effval='n/a'
821 
822  effvalStr='n/a'
823  lprescStr='n/a'
824  cleanlname=''
825  if lname!='n/a':
826  effval=totefflumiDict[name]*scalefactor
827  lprescs=list(set(lprescdict[lname]))
828  lprescStr='('+','.join(['%d'%(x) for x in lprescs])+')'
829  cleanlname=lname.replace('"','')
830  (efflumival,efflumiunit)=CommonUtil.guessUnit(effval)
831  effvalStr='%.3f'%(efflumival)+'('+efflumiunit+')'
832  if not toFile:
833  result.append([str(run)+':'+str(fillnum),selectedlsStr,'%.3f'%(totrecval)+'('+totrecunit+')',name+hprescStr,cleanlname+lprescStr,effvalStr])
834  else:
835  result.append([str(run)+':'+str(fillnum),selectedlsStr,totrecordedinrun*scalefactor,name+hprescStr,cleanlname+lprescStr,effval])
836 
837  if irunlsdict and not noWarning:
838  for run,cmslslist in irunlsdict.items():
839  if run not in datarunlsdict.keys() or datarunlsdict[run] is None:
840  sys.stdout.write('[WARNING] selected run '+str(run)+' not in lumiDB or has no HLT data\n')
841  continue
842  if cmslslist:
843  for ss in cmslslist:
844  if ss not in datarunlsdict[run]:
845  sys.stdout.write('[WARNING] selected run/ls '+str(run)+' '+str(ss)+' not in lumiDB or has no HLT data\n')
846 
847  sortedresult=sorted(result,key=lambda x : int(str(x[0]).split(':')[0]))
848 
849  if not toFile:
850  labels = [('Run:Fill','SelectedLS','Recorded','HLTpath(Presc)','L1bit(Presc)','Effective')]
851  print ' == = '
852  print tablePrinter.indent (labels+sortedresult, hasHeader = True, separateRows = False,
853  prefix = '| ', postfix = ' |', justify = 'right',
854  delim = ' | ', wrapfunc = lambda x: wrap_onspace_strict(x,22) )
855  print ' == = Total : '
856  lastrowlabels=[('HLTPath','SelectedLS','Recorded','Effective')]
857  totresult=[]
858  for hname in sorted(totdict):
859  hdata=totdict[hname]
860  totnls=hdata[0]
861  (toteffval,toteffunit)=CommonUtil.guessUnit(hdata[1]*scalefactor)
862  alltotrecorded=0.0
863  selectedThispath=selectedPerpathPerrun[hname]
864  for runnumber,nselected in selectedThispath.items():
865  if nselected==0: continue
866  alltotrecorded+=recordedPerpathPerrun[hname][runnumber]
867  (alltotrecordedVal,alltotrecordedunit)=CommonUtil.guessUnit(alltotrecorded*scalefactor)
868  totresult.append([hname,str(totnls),'%.3f'%(alltotrecordedVal)+'('+alltotrecordedunit+')','%.3f'%(toteffval)+'('+toteffunit+')'])
869  print tablePrinter.indent (lastrowlabels+totresult, hasHeader = True, separateRows = False,prefix = '| ', postfix = ' |', justify = 'right',
870  delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) )
871  else:
872  fieldnames=['Run:Fill','SelectedLS','Recorded','HLTpath(Presc)','L1bit(Presc)','Effective(/ub)']
873  filename=toFile
874  dumptocsv(fieldnames,sortedresult,filename)
def splitlistToRangeString
Definition: CommonUtil.py:256
def toScreenTotEffective
Definition: lumiReport.py:692
def dumptocsv
Definition: lumiReport.py:11
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def guessUnit
Definition: CommonUtil.py:59
def wrap_onspace_strict
Definition: dataformats.py:63
double split
Definition: MVATrainer.cc:139
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
void set(const std::string &name, int value)
set the flag, with a run-time name