test
CMS 3D CMS Logo

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

Functions

def beamForIds
 
def beamForRange
 
def deliveredLumiForIds
 
def effectiveLumiForIds
 
def fillInRange
 
def fillrunMap
 
def hltForIds
 
def hltpathsForRange
 
def instLumiForIds
 
def lumiForIds
 
def runList
 
def runsummary
 Lumi data management and calculation API # # Author: Zhen Xie #. More...
 
def runsummaryMap
 
def trgForIds
 

Function Documentation

def lumiCalcAPI.beamForIds (   schema,
  irunlsdict,
  dataidmap,
  withBeamIntensity = False,
  minIntensity = 0.1 
)
input:
       inputRange: {run:[cmsls]} (required)
       dataidmap: {run:(lumiid,trgid,hltid)}
output : {runnumber:[(lumicmslnum(0),cmslsnum(1),beamenergy(2),beamstatus(3),ncollidingbx(4),[(ibx,b1,b2)])...](5)}

Definition at line 115 of file lumiCalcAPI.py.

References bitset_utilities.append(), and dataDML.beamInfoById().

116 def beamForIds(schema,irunlsdict,dataidmap,withBeamIntensity=False,minIntensity=0.1):
117  '''
118  input:
119  inputRange: {run:[cmsls]} (required)
120  dataidmap: {run:(lumiid,trgid,hltid)}
121  output : {runnumber:[(lumicmslnum(0),cmslsnum(1),beamenergy(2),beamstatus(3),ncollidingbx(4),[(ibx,b1,b2)])...](5)}
122  '''
123  result={}
124  for run in irunlsdict.keys():
125  result[run]=[]
126  lslist=irunlsdict[run]
127  if lslist is not None and len(lslist)==0:
128  continue
129  if run not in dataidmap:
130  continue #run non exist
131  lumidataid=dataidmap[run][0]
132  if lumidataid is None:
133  result[run]=None
134  continue
135  lumidata=dataDML.beamInfoById(schema,lumidataid,withBeamIntensity=withBeamIntensity,minIntensity=minIntensity)
136  #(runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..])
137  if lumidata and lumidata[1]:
138  perrundata=lumidata[1]
139  for perlsdata in perrundata:
140  lumilsnum=perlsdata[0]
141  cmslsnum=perlsdata[1]
142  if lslist is not None and cmslsnum not in lslist:
143  continue
144  beamstatus=perlsdata[2]
145  beamenergy=perlsdata[3]
146  ncollidingbunches=perlsdata[4]
147  beamintInfolist=[]
148  if withBeamIntensity:
149  beamintInfolist=perlsdata[5]
150  result[run].append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beamintInfolist))
151  return result
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def beamInfoById
Definition: dataDML.py:1192
def lumiCalcAPI.beamForRange (   schema,
  inputRange,
  withBeamIntensity = False,
  minIntensity = 0.1,
  tableName = None,
  branchName = None 
)
input:
       inputRange: {run:[cmsls]} (required)
output : {runnumber:[(lumicmslnum,cmslsnum,beamenergy,beamstatus,[(ibx,b1,b2)])...](4)}

Definition at line 75 of file lumiCalcAPI.py.

References bitset_utilities.append(), dataDML.beamInfoById(), and nameDealer.lumidataTableName().

75 
76 def beamForRange(schema,inputRange,withBeamIntensity=False,minIntensity=0.1,tableName=None,branchName=None):
77  '''
78  input:
79  inputRange: {run:[cmsls]} (required)
80  output : {runnumber:[(lumicmslnum,cmslsnum,beamenergy,beamstatus,[(ibx,b1,b2)])...](4)}
81  '''
82  if tableName is None:
84  if branchName is None:
85  branchName='DATA'
86  result={}
87  for run in inputRange.keys():
88  lslist=inputRange[run]
89  if lslist is not None and len(lslist)==0:
90  result[run]=[]#if no LS is selected for a run
91  continue
92  lumidataid=dataDML.guessLumiDataIdByRun(schema,run,tableName)
93  if lumidataid is None:
94  result[run]=None
95  continue #run non exist
96  lumidata=dataDML.beamInfoById(schema,lumidataid,withBeamIntensity=withBeamIntensity,minIntensity=minIntensity)
97  #(runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),beaminfolist(4)),..])
98  result[run]=[]
99  perrundata=lumidata[1]
100  if not perrundata:
101  result[run]=[]
102  continue
103  for perlsdata in perrundata:
104  lumilsnum=perlsdata[0]
105  cmslsnum=perlsdata[1]
106  if lslist is not None and cmslsnum not in lslist:
107  continue
108  beamstatus=perlsdata[2]
109  beamenergy=perlsdata[3]
110  beamintInfolist=[]
111  if withBeamIntensity:
112  beamintInfolist=perlsdata[4]
113  result[run].append((lumilsnum,cmslsnum,beamstatus,beamenergy,beamintInfolist))
114  return result
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def lumidataTableName
Definition: nameDealer.py:19
def beamInfoById
Definition: dataDML.py:1192
def beamForRange
Definition: lumiCalcAPI.py:75
def lumiCalcAPI.deliveredLumiForIds (   schema,
  irunlsdict,
  dataidmap,
  runsummaryMap,
  beamstatusfilter = None,
  timeFilter = None,
  normmap = None,
  withBXInfo = False,
  bxAlgo = None,
  xingMinLum = None,
  withBeamIntensity = False,
  lumitype = 'HF',
  minbiasXsec = None 
)
delivered lumi (including calibration,time integral)
input:
   irunlsdict:  {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls
   dataidmap : {run:(lumiid,trgid,hltid)}
   runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
   beamstatus: LS filter on beamstatus 
   normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction
   withBXInfo: get per bunch info (optional)
   bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
   xingMinLum: cut on bx lumi value (optional)
   withBeamIntensity: get beam intensity info (optional)
   lumitype: luminosity source
output:
   result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierr(6),(bxidxlist,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum(9),pu(10)]}
   
   special meanings:
   {run:None}  None means no run in lumiDB, 
   {run:[]} [] means no lumi for this run in lumiDB
   {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected 
   lumi unit: /ub

Definition at line 369 of file lumiCalcAPI.py.

References bitset_utilities.append(), dataDML.fillschemePatternMap(), instLumiForIds(), dataDML.intglumiForRange(), dataDML.lumiRunByIds(), and normFunctors.normFunctionCaller().

Referenced by effectiveLumiForIds(), specificLumi.getSpecificLumi(), and lumiForIds().

370 def deliveredLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=None,timeFilter=None,normmap=None,withBXInfo=False,bxAlgo=None,xingMinLum=None,withBeamIntensity=False,lumitype='HF',minbiasXsec=None):
371  '''
372  delivered lumi (including calibration,time integral)
373  input:
374  irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls
375  dataidmap : {run:(lumiid,trgid,hltid)}
376  runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
377  beamstatus: LS filter on beamstatus
378  normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction
379  withBXInfo: get per bunch info (optional)
380  bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
381  xingMinLum: cut on bx lumi value (optional)
382  withBeamIntensity: get beam intensity info (optional)
383  lumitype: luminosity source
384  output:
385  result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),calibratedlumierr(6),(bxidxlist,bxvalues,bxerrs)(7),(bxidx,b1intensities,b2intensities)(8),fillnum(9),pu(10)]}
386 
387  special meanings:
388  {run:None} None means no run in lumiDB,
389  {run:[]} [] means no lumi for this run in lumiDB
390  {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected
391  lumi unit: /ub
392  '''
393  result = {}
395  lumirundata=dataDML.lumiRunByIds(schema,dataidmap,lumitype=lumitype)
396  instresult=instLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=beamstatusfilter,timeFilter=timeFilter,withBXInfo=withBXInfo,bxAlgo=bxAlgo,withBeamIntensity=withBeamIntensity,lumitype=lumitype)
397 
398  intglumimap={}
399  if lumitype=='HF':
400  intglumimap=dataDML.intglumiForRange(schema,irunlsdict.keys())#some runs need drift correction
401  allsince=[]
402  if normmap:
403  allsince=normmap.keys()
404  allsince.sort()
405  correctorname='fPoly' #HF default
406  correctionparams={'a0':1.0}
407  runfillschemeMap={}
408  fillschemePatternMap={}
409  if lumitype=='PIXEL':
410  correctorname='fPolyScheme' #PIXEL default
411  fillschemePatternMap=dataDML.fillschemePatternMap(schema,'PIXEL')
412  for run,perrundata in instresult.items():
413  if perrundata is None:
414  result[run]=None
415  continue
416  intglumi=0.
417  if normmap and intglumimap and run in intglumimap and intglumimap[run]:
418  intglumi=intglumimap[run]
419  nBXs=0
420  if normmap and lumirundata and run in lumirundata and lumirundata[run][2]:
421  nBXs=lumirundata[run][2]
422  fillschemeStr=''
423  if normmap and runsummaryMap and run in runsummaryMap and runsummaryMap[run][5]:
424  fillschemeStr=runsummaryMap[run][5]
425  if allsince:
426  lastsince=allsince[0]
427  for since in allsince:
428  if run>=since:
429  lastsince=since
430  correctorname=normmap[lastsince][0]
431  correctionparams=normmap[lastsince][1]
432 
433  correctioninput=[0.,intglumi,nBXs,fillschemeStr,fillschemePatternMap]
434  result[run]=[]
435  for perlsdata in perrundata:#loop over ls
436  lumilsnum=perlsdata[0]
437  cmslsnum=perlsdata[1]
438  timestamp=perlsdata[2]
439  bs=perlsdata[3]
440  beamenergy=perlsdata[4]
441  instluminonorm=perlsdata[5]
442  correctioninput[0]=instluminonorm
443  totcorrectionFac=normFunctors.normFunctionCaller(correctorname,*correctioninput,**correctionparams)
444  fillnum=perlsdata[11]
445  instcorrectedlumi=totcorrectionFac*instluminonorm
446  numorbit=perlsdata[8]
447  numbx=lumip.NBX
448  lslen=lumip.lslengthsec()
449  deliveredlumi=instcorrectedlumi*lslen
450  calibratedbxdata=None
451  beamdata=None
452  pu=0.#avgPU
453  if nBXs and minbiasXsec:
454  pu=(instcorrectedlumi/nBXs)*minbiasXsec/lumip.rotationRate
455  if withBXInfo:
456  (bxidxData,bxvaluesData,bxerrsData)=perlsdata[9]
457  if lumitype=='HF':
458  if xingMinLum:
459  bxidxList=[]
460  bxvalueList=[]
461  bxerrList=[]
462  for idx,bxval in enumerate(bxvaluesData):
463  correctedbxintlumi=totcorrectionFac*bxval
464  correctedbxintlumierr=totcorrectionFac*bxerrsData[idx]
465  if correctedbxintlumi>xingMinLum:
466  bxidxList.append(bxidxData[idx])
467  bxvalueList.append(correctedbxintlumi)
468  bxerrList.append(correctedbxintlumierr)
469  calibratedbxdata=(bxidxList,bxvalueList,bxerrList)
470  else:
471  calibratedbxvalue=[totcorrectionFac*x for x in bxvaluesData]
472  calibratedlumierr=[totcorrectionFac*x for x in bxerrsData]
473  calibratedbxdata=(bxidxData,calibratedbxvalue,calibratedlumierr)
474  if withBeamIntensity:
475  beamdata=perlsdata[10]
476  calibratedlumierr=0.0
477  result[run].append([lumilsnum,cmslsnum,timestamp,bs,beamenergy,deliveredlumi,calibratedlumierr,calibratedbxdata,beamdata,fillnum,pu])
478  del perlsdata[:]
479  return result
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def fillschemePatternMap
Definition: dataDML.py:1572
def normFunctionCaller
Definition: normFunctors.py:49
def lumiRunByIds
Definition: dataDML.py:904
def instLumiForIds
Definition: lumiCalcAPI.py:250
def deliveredLumiForIds
Definition: lumiCalcAPI.py:369
def intglumiForRange
Definition: dataDML.py:1536
def lumiCalcAPI.effectiveLumiForIds (   schema,
  irunlsdict,
  dataidmap,
  runsummaryMap = None,
  beamstatusfilter = None,
  timeFilter = None,
  normmap = None,
  hltpathname = None,
  hltpathpattern = None,
  withBXInfo = False,
  bxAlgo = None,
  xingMinLum = None,
  withBeamIntensity = False,
  lumitype = 'HF',
  minbiasXsec = None 
)
delivered/recorded/eff lumi in selected hlt path  (including calibration,time integral)
input:
       irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls
       dataidmap : {run:(lumiid,trgid,hltid)}
       runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
       beamstatusfilter: LS filter on beamstatus
       normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction
       hltpathname: selected hltpathname
       hltpathpattern: regex select hltpaths           
       withBXInfo: get per bunch info (optional)
       bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
       xingMinLum: cut on bx lumi value (optional)
       withBeamIntensity: get beam intensity info (optional)
       lumitype: luminosity source
output:
       result {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),ncollidingbunches(12)]}
       {run:None}  None means no run in lumiDB, 
       {run:[]} [] means no lumi for this run in lumiDB
       {run:[....deliveredlumi(5),recorded(6)==None,]} means no trigger in lumiDB
       {run:[....deliveredlumi(5),recorded(6),calibratedlumierror(7)==None]} means no hlt in lumiDB
       
       lumi unit: 1/ub

Definition at line 532 of file lumiCalcAPI.py.

References deliveredLumiForIds(), hltTrgSeedMapper.findUniqueSeed(), hltForIds(), dataDML.hlttrgMappingByrun(), and trgForIds().

533 def effectiveLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap=None,beamstatusfilter=None,timeFilter=None,normmap=None,hltpathname=None,hltpathpattern=None,withBXInfo=False,bxAlgo=None,xingMinLum=None,withBeamIntensity=False,lumitype='HF',minbiasXsec=None):
534  '''
535  delivered/recorded/eff lumi in selected hlt path (including calibration,time integral)
536  input:
537  irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means selected ls
538  dataidmap : {run:(lumiid,trgid,hltid)}
539  runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
540  beamstatusfilter: LS filter on beamstatus
541  normmap: {since:[corrector(0),{paramname:paramvalue}(1),amodetag(2),egev(3),comment(4)]} if normmap empty, means without-correction , if notnormmap means without-correction
542  hltpathname: selected hltpathname
543  hltpathpattern: regex select hltpaths
544  withBXInfo: get per bunch info (optional)
545  bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
546  xingMinLum: cut on bx lumi value (optional)
547  withBeamIntensity: get beam intensity info (optional)
548  lumitype: luminosity source
549  output:
550  result {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),ncollidingbunches(12)]}
551  {run:None} None means no run in lumiDB,
552  {run:[]} [] means no lumi for this run in lumiDB
553  {run:[....deliveredlumi(5),recorded(6)==None,]} means no trigger in lumiDB
554  {run:[....deliveredlumi(5),recorded(6),calibratedlumierror(7)==None]} means no hlt in lumiDB
555 
556  lumi unit: 1/ub
557  '''
558  deliveredresult=deliveredLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=beamstatusfilter,timeFilter=timeFilter,normmap=normmap,withBXInfo=withBXInfo,bxAlgo=bxAlgo,xingMinLum=xingMinLum,withBeamIntensity=withBeamIntensity,lumitype=lumitype,minbiasXsec=minbiasXsec)
559  trgresult=trgForIds(schema,irunlsdict,dataidmap,withPrescale=True) #{run:[cmslsnum,deadfrac,deadtimecount,bitzero_count,bitzero_prescale,[(bitname,prescale,counts,mask)]]}
560  hltresult=hltForIds(schema,irunlsdict,dataidmap,hltpathname=hltpathname,hltpathpattern=hltpathpattern,withL1Pass=False,withHLTAccept=False) #{runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})}
561  for run in deliveredresult.keys(): #loop over delivered
562  perrundata=deliveredresult[run]
563  if perrundata is None or len(perrundata)==0:#pass through
564  continue
565  alltrgls=[]
566  if run in trgresult and trgresult[run]:
567  alltrgls=[x[0] for x in trgresult[run]]
568  allhltls=[]
569  if run in hltresult and hltresult[run]:
570  allhltls=[x[0] for x in hltresult[run]]
571  l1bitinfo=[]
572  hltpathinfo=[]
573  hlttrgmap=dataDML.hlttrgMappingByrun(schema,run,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
574 
575  for perlsdata in perrundata: #loop over ls
576  if not perlsdata: continue #no lumi for this ls
577  perlsdata.insert(6,None)
578  perlsdata.insert(8,None)
579  if not alltrgls: continue #no trg for this run
580  cmslsnum=perlsdata[1]
581  recordedlumi=0.0
582  if cmslsnum==0:#if not a cmsls or not selected by cms list, set recordedlumi,efflumi to 0
583  continue
584  else:
585  try:
586  trglsidx=alltrgls.index(cmslsnum)
587  deadfrac=trgresult[run][trglsidx][1]
588  l1bitinfo=trgresult[run][trglsidx][5]
589  if deadfrac<0 or deadfrac>1.0:deadfrac=1.0
590  deliveredlumi=perlsdata[5]
591  recordedlumi=(1.0-deadfrac)*deliveredlumi
592  except ValueError:
593  #print '[WARNING] no trigger for LS=',cmslsnum
594  continue #do not go further
595  perlsdata[6]=recordedlumi
596  if not allhltls: continue #no hlt for this run
597  try:
598  hltlsidx=allhltls.index(cmslsnum)
599  except ValueError:
600  #print '[WARNING] no hlt for LS=',cmslsnum
601  continue #do not go further
602  trgprescalemap={} #{bitname:l1prescale} for this lumi section
603  if l1bitinfo:
604  for thisbitinfo in l1bitinfo:
605  thisbitname=thisbitinfo[0]
606  thisbitprescale=thisbitinfo[2]
607  trgprescalemap['"'+thisbitname+'"']=thisbitprescale
608  else:
609  continue
610  hltpathdata=hltresult[run][hltlsidx][1]
611  efflumidict={}#{pathname:[[l1bitname,l1prescale,hltprescale,efflumi]]}
612  for pathidx,thispathinfo in enumerate(hltpathdata):
613  thispathname=thispathinfo[0]
614  thisprescale=thispathinfo[1]
615  thisl1seed=None
616  l1bitname=None
617  l1prescale=None
618  try:
619  thisl1seed=hlttrgmap[thispathname]
620  except KeyError:
621  thisl1seed=None
622  if thisl1seed:
623  try:
624  (exptype,l1bits)=hltTrgSeedMapper.findUniqueSeed(thispathname,thisl1seed)
625  if l1bits:
626  if not exptype:
627  l1bitname=l1bits[0]
628  l1prescale=trgprescalemap[l1bits[0]]#need to match double quoted string!
629  else:
630  pmin=99999999
631  pmax=0
632  for bit in l1bits:
633  l1p=trgprescalemap[bit]
634  if exptype=='OR':
635  if l1p!=0 and l1p<pmin:
636  pmin=l1p
637  l1prescale=l1p
638  l1bitname=bit
639  if exptype=='AND':
640  if l1p!=0 and l1p>pmax:
641  pmax=l1p
642  l1prescale=l1p
643  l1bitname=bit
644  else:
645  l1prescale=None
646  except KeyError:
647  l1prescale=None
648 
649  efflumi=0.0
650  if l1prescale and thisprescale:#normal both prescaled
651  efflumi=recordedlumi/(float(l1prescale)*float(thisprescale))
652  efflumidict[thispathname]=[l1bitname,l1prescale,thisprescale,efflumi]
653  elif l1prescale and thisprescale==0: #hltpath in menu but masked
654  efflumidict[thispathname]=[l1bitname,l1prescale,thisprescale,efflumi]
655  else:
656  efflumidict[thispathname]=[None,0,thisprescale,efflumi]
657  perlsdata[8]=efflumidict
658  return deliveredresult
659 
def hlttrgMappingByrun
Definition: dataDML.py:1390
def effectiveLumiForIds
Definition: lumiCalcAPI.py:532
def deliveredLumiForIds
Definition: lumiCalcAPI.py:369
def lumiCalcAPI.fillInRange (   schema,
  fillmin = 1000,
  fillmax = 9999,
  amodetag = 'PROTPHYS',
  startT = None,
  stopT = None 
)
output [fill]

Definition at line 35 of file lumiCalcAPI.py.

References dataDML.fillInRange().

35 
36 def fillInRange(schema,fillmin=1000,fillmax=9999,amodetag='PROTPHYS',startT=None,stopT=None):
37  '''
38  output [fill]
39  '''
40  fills=dataDML.fillInRange(schema,fillmin,fillmax,amodetag,startT,stopT)
return fills
def fillInRange
Definition: lumiCalcAPI.py:35
def fillInRange
Definition: dataDML.py:89
def lumiCalcAPI.fillrunMap (   schema,
  fillnum = None,
  runmin = None,
  runmax = None,
  startT = None,
  stopT = None,
  l1keyPattern = None,
  hltkeyPattern = None,
  amodetag = None 
)
output: {fill:[runnum,...]}

Definition at line 41 of file lumiCalcAPI.py.

References dataDML.fillrunMap().

Referenced by specificLumi.getFillFromDB().

41 
42 def fillrunMap(schema,fillnum=None,runmin=None,runmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None):
43  '''
44  output: {fill:[runnum,...]}
45  '''
46  return dataDML.fillrunMap(schema,fillnum=fillnum,runmin=runmin,runmax=runmax,startT=startT,stopT=stopT,l1keyPattern=l1keyPattern,hltkeyPattern=hltkeyPattern,amodetag=amodetag)
def fillrunMap
Definition: lumiCalcAPI.py:41
def fillrunMap
Definition: dataDML.py:160
def lumiCalcAPI.hltForIds (   schema,
  irunlsdict,
  dataidmap,
  hltpathname = None,
  hltpathpattern = None,
  withL1Pass = False,
  withHLTAccept = False 
)
input:
       irunlsdict: {run:[cmsls]} (required)
       dataidmap: {run:(lumiid,trgid,hltid)}
       hltpathname: exact match hltpathname  (optional) 
       hltpathpattern: regex match hltpathpattern (optional)
       withL1Pass: with L1 pass count
       withHLTAccept: with HLT accept
output: {runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})}

Definition at line 152 of file lumiCalcAPI.py.

References bitset_utilities.append(), and dataDML.hltLSById().

Referenced by effectiveLumiForIds().

153 def hltForIds(schema,irunlsdict,dataidmap,hltpathname=None,hltpathpattern=None,withL1Pass=False,withHLTAccept=False):
154  '''
155  input:
156  irunlsdict: {run:[cmsls]} (required)
157  dataidmap: {run:(lumiid,trgid,hltid)}
158  hltpathname: exact match hltpathname (optional)
159  hltpathpattern: regex match hltpathpattern (optional)
160  withL1Pass: with L1 pass count
161  withHLTAccept: with HLT accept
162  output: {runnumber:[(cmslsnum,[(hltpath,hltprescale,l1pass,hltaccept),...]),(cmslsnum,[])})}
163  '''
164  result={}
165  for run in irunlsdict.keys():
166  lslist=irunlsdict[run]
167  if lslist is not None and len(lslist)==0:
168  result[run]=[]#if no LS is selected for a run
169  continue
170  if run not in dataidmap:
171  continue
172  hltdataid=dataidmap[run][2]
173  if hltdataid is None:
174  result[run]=None
175  continue #run non exist
176  hltdata=dataDML.hltLSById(schema,hltdataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern,withL1Pass=withL1Pass,withHLTAccept=withHLTAccept)
177  #(runnum,{cmslsnum:[(pathname,prescale,l1pass,hltaccept),...]})
178  result[run]=[]
179  if hltdata and hltdata[1]:
180  lsdict={}
181  for cmslsnum in sorted(hltdata[1]):
182  if lslist is not None and cmslsnum not in lslist:
183  continue
184  lsdata=[]
185  for perpathdata in hltdata[1][cmslsnum]:
186  pathname=perpathdata[0]
187  prescale=perpathdata[1]
188  l1pass=None
189  hltaccept=None
190  if withL1Pass:
191  l1pass=perpathdata[2]
192  if withHLTAccept:
193  hltaccept=perpathdata[3]
194  lsdata.append((pathname,prescale,l1pass,hltaccept))
195  result[run].append((cmslsnum,lsdata))
196  return result
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def hltLSById
Definition: dataDML.py:1437
def lumiCalcAPI.hltpathsForRange (   schema,
  runlist,
  hltpathname = None,
  hltpathpattern = None 
)
input: runlist [run],     (required)      
       datatag: data version (optional)
output : {runnumber,[(hltpath,l1seedexpr,l1bitname)...]}

Definition at line 53 of file lumiCalcAPI.py.

References bitset_utilities.append(), hltTrgSeedMapper.findUniqueSeed(), and dataDML.hlttrgMappingByrun().

53 
54 def hltpathsForRange(schema,runlist,hltpathname=None,hltpathpattern=None):
55  '''
56  input: runlist [run], (required)
57  datatag: data version (optional)
58  output : {runnumber,[(hltpath,l1seedexpr,l1bitname)...]}
59  '''
60  result={}
61  for run in runlist:
62  hlttrgmap=dataDML.hlttrgMappingByrun(schema,run,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
63  result[run]=[]
64  for hltpath in sorted(hlttrgmap):
65  l1seedexpr=hlttrgmap[hltpath]
66  (exptype,l1bits)=hltTrgSeedMapper.findUniqueSeed(hltpath,l1seedexpr)
67  l1bitname='n/a'
68  if l1bits:
69  if exptype:
70  l1bitname=l1seedexpr
71  else:
72  l1bitname=l1bits[0]
73  result[run].append((hltpath,l1seedexpr,l1bitname))
74  return result
def hlttrgMappingByrun
Definition: dataDML.py:1390
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def hltpathsForRange
Definition: lumiCalcAPI.py:53
def lumiCalcAPI.instLumiForIds (   schema,
  irunlsdict,
  dataidmap,
  runsummaryMap,
  beamstatusfilter = None,
  timeFilter = None,
  withBXInfo = False,
  bxAlgo = None,
  xingMinLum = None,
  withBeamIntensity = False,
  lumitype = 'HF' 
)
FROM ROOT FILE NO CORRECTION AT ALL 
input:
       irunlsdict: {run:[cmsls]} 
       dataidmap: {run:(lumiid,trgid,hltid)}
       runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
       beamstatus: LS filter on beamstatus (optional)
       timeFilter: (minLSBegTime,maxLSBegTime)
       withBXInfo: get per bunch info (optional)
       bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
       xingMinLum: None means apply no cut
       withBeamIntensity: get beam intensity info (optional)
       lumitype: luminosity measurement source
output:
       result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),instlumi(5),instlumierr(6),startorbit(7),numorbit(8),(bxidx,bxvalues,bxerrs)(9),(bxidx,b1intensities,b2intensities)(10),fillnum(11)]}}
       
       special meanings:
       {run:None}  None means selected run not in lumiDB, 
       {run:[]} [] means no lumi data for this run in lumiDB
       {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected
       instlumi unit in Hz/ub

Definition at line 250 of file lumiCalcAPI.py.

References nameDealer.lumidataTableName(), dataDML.lumiLSById(), nameDealer.lumisummaryv2TableName(), nameDealer.pixellumidataTableName(), and nameDealer.pixellumisummaryv2TableName().

Referenced by deliveredLumiForIds().

251 def instLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=None,timeFilter=None,withBXInfo=False,bxAlgo=None,xingMinLum=None,withBeamIntensity=False,lumitype='HF'):
252  '''
253  FROM ROOT FILE NO CORRECTION AT ALL
254  input:
255  irunlsdict: {run:[cmsls]}
256  dataidmap: {run:(lumiid,trgid,hltid)}
257  runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
258  beamstatus: LS filter on beamstatus (optional)
259  timeFilter: (minLSBegTime,maxLSBegTime)
260  withBXInfo: get per bunch info (optional)
261  bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
262  xingMinLum: None means apply no cut
263  withBeamIntensity: get beam intensity info (optional)
264  lumitype: luminosity measurement source
265  output:
266  result {run:[lumilsnum(0),cmslsnum(1),timestamp(2),beamstatus(3),beamenergy(4),instlumi(5),instlumierr(6),startorbit(7),numorbit(8),(bxidx,bxvalues,bxerrs)(9),(bxidx,b1intensities,b2intensities)(10),fillnum(11)]}}
267 
268  special meanings:
269  {run:None} None means selected run not in lumiDB,
270  {run:[]} [] means no lumi data for this run in lumiDB
271  {run:cmslsnum(1)==0} means either not cmslsnum or iscms but not selected
272  instlumi unit in Hz/ub
273  '''
274  if lumitype not in ['HF','PIXEL']:
275  raise ValueError('unknown lumitype '+lumitype)
276  lumitableName=''
277  lumilstableName=''
278  if lumitype=='HF':
279  lumitableName=nameDealer.lumidataTableName()
280  lumilstableName=nameDealer.lumisummaryv2TableName()
281  else:
282  lumitableName=nameDealer.pixellumidataTableName()
284  result={}
285  for run in irunlsdict.keys():
286  #for run,(lumidataid,trgid,hltid ) in dataidmap.items():
287  lslist=irunlsdict[run]
288  if lslist is not None and len(lslist)==0:
289  result[run]=[]#no lumi data for this run in lumiDB
290  continue
291  fillnum=runsummaryMap[run][4]
292  runstarttimeStr=runsummaryMap[run][6]
293  if run not in dataidmap:
294  result[run]=[]#no lumi data for this run in lumiDB
295  continue
296  (lumidataid,trgid,hltid )=dataidmap[run]
297  if lumidataid is None: #selected run not in lumiDB
298  result[run]=None
299  continue
300  (lumirunnum,perlsresult)=dataDML.lumiLSById(schema,lumidataid,beamstatus=beamstatusfilter,withBXInfo=withBXInfo,bxAlgo=bxAlgo,withBeamIntensity=withBeamIntensity,tableName=lumilstableName)
301  lsresult=[]
303  for lumilsnum in perlsresult.keys():
304  perlsdata=perlsresult[lumilsnum]
305  cmslsnum=perlsdata[0]
306  if lslist is not None and cmslsnum not in lslist: #ls exists but not selected
307  cmslsnum=0
308  numorbit=perlsdata[6]
309  startorbit=perlsdata[7]
310  orbittime=c.OrbitToTime(runstarttimeStr,startorbit,begorbit=0,customfm='%m/%d/%y %H:%M:%S')
311  if timeFilter:
312  if timeFilter[0]:
313  if orbittime<timeFilter[0]: continue
314  if timeFilter[1]:
315  if orbittime>timeFilter[1]: continue
316  if lumitype=='HF':
317  instlumi=perlsdata[1]*1000.0 #HF db avg values are in Hz/mb,change it to Hz/ub
318  instlumierr=perlsdata[2]*1000.0
319  else:
320  instlumi=perlsdata[1] #PIXEL avg values are in Hz/ub, need no conversion
321  instlumierr=perlsdata[2]
322  beamstatus=perlsdata[4]
323  beamenergy=perlsdata[5]
324  bxidxlist=[]
325  bxvaluelist=[]
326  bxerrorlist=[]
327  bxdata=None
328  beamdata=None
329  if withBXInfo:
330  bxinfo=perlsdata[8]
331  bxvalueArray=None
332  bxerrArray=None
333  if bxinfo:
334  bxvalueArray=bxinfo[0]
335  bxerrArray=bxinfo[1]
336  if xingMinLum :
337  for idx,bxval in enumerate(bxvalueArray):
338  if bxval>xingMinLum:
339  bxidxlist.append(idx)
340  bxvaluelist.append(bxval)
341  bxerrorlist.append(bxerrArray[idx])
342  else:
343  bxidxlist=range(0,len(bxvalueArray))
344  bxvaluelist=bxvalueArray.tolist()
345  bxerrorlist=bxerrArray.tolist()
346  del bxvalueArray[:]
347  del bxerrArray[:]
348  bxdata=(bxidxlist,bxvaluelist,bxerrorlist)
349  if withBeamIntensity:
350  beaminfo=perlsdata[9]
351  bxindexlist=[]
352  b1intensitylist=[]
353  b2intensitylist=[]
354  if beaminfo[0] and beaminfo[1] and beaminfo[2]:
355  bxindexarray=beaminfo[0]
356  beam1intensityarray=beaminfo[1]
357  beam2intensityarray=beaminfo[2]
358  bxindexlist=bxindexarray.tolist()
359  b1intensitylist=beam1intensityarray.tolist()
360  b2intensitylist=beam2intensityarray.tolist()
361  del bxindexarray[:]
362  del beam1intensityarray[:]
363  del beam2intensityarray[:]
364  beamdata=(bxindexlist,b1intensitylist,b2intensitylist)
365  lsresult.append([lumilsnum,cmslsnum,orbittime,beamstatus,beamenergy,instlumi,instlumierr,startorbit,numorbit,bxdata,beamdata,fillnum])
366  del perlsdata[:]
367  result[run]=lsresult
368  return result
def instLumiForIds
Definition: lumiCalcAPI.py:250
def lumidataTableName
Definition: nameDealer.py:19
def pixellumidataTableName
Definition: nameDealer.py:22
def lumisummaryv2TableName
Definition: nameDealer.py:28
def lumiLSById
Definition: dataDML.py:1085
def pixellumisummaryv2TableName
Definition: nameDealer.py:31
def lumiCalcAPI.lumiForIds (   schema,
  irunlsdict,
  dataidmap,
  runsummaryMap,
  beamstatusfilter = None,
  timeFilter = None,
  normmap = None,
  withBXInfo = False,
  bxAlgo = None,
  xingMinLum = None,
  withBeamIntensity = False,
  lumitype = 'HF',
  minbiasXsec = None 
)
delivered/recorded lumi  (including calibration,time integral)
input:
   irunlsdict:  {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means no selected ls
   dataidmap : {run:(lumiid,trgid,hltid)}
   runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
   beamstatus: LS filter on beamstatus 
   normmap: 
   withBXInfo: get per bunch info (optional)
   bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
   xingMinLum: cut on bx lumi value (optional)
   withBeamIntensity: get beam intensity info (optional)
   lumitype: luminosity source
output:
   result {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),ncollidingbunches(11)]...]}
   special meanings:
   {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
   lumi unit: 1/ub

Definition at line 480 of file lumiCalcAPI.py.

References deliveredLumiForIds(), and trgForIds().

481 def lumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=None,timeFilter=None,normmap=None,withBXInfo=False,bxAlgo=None,xingMinLum=None,withBeamIntensity=False,lumitype='HF',minbiasXsec=None):
482  '''
483  delivered/recorded lumi (including calibration,time integral)
484  input:
485  irunlsdict: {run:[lsnum]}, where [lsnum]==None means all ; [lsnum]==[] means no selected ls
486  dataidmap : {run:(lumiid,trgid,hltid)}
487  runsummaryMap: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
488  beamstatus: LS filter on beamstatus
489  normmap:
490  withBXInfo: get per bunch info (optional)
491  bxAlgo: algoname for bx values (optional) ['OCC1','OCC2','ET']
492  xingMinLum: cut on bx lumi value (optional)
493  withBeamIntensity: get beam intensity info (optional)
494  lumitype: luminosity source
495  output:
496  result {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),ncollidingbunches(11)]...]}
497  special meanings:
498  {run:None} None means no run in lumiDB,
499  {run:[]} [] means no lumi for this run in lumiDB
500  {run:[....deliveredlumi(5),recordedlumi(6)None]} means no trigger in lumiDB
501  {run:cmslsnum(1)==0} means either not cmslsnum or is cms but not selected, therefore set recordedlumi=0,efflumi=0
502  lumi unit: 1/ub
503  '''
504  deliveredresult=deliveredLumiForIds(schema,irunlsdict,dataidmap,runsummaryMap,beamstatusfilter=beamstatusfilter,timeFilter=timeFilter,normmap=normmap,withBXInfo=withBXInfo,bxAlgo=bxAlgo,xingMinLum=xingMinLum,withBeamIntensity=withBeamIntensity,lumitype=lumitype,minbiasXsec=minbiasXsec)
505  trgresult=trgForIds(schema,irunlsdict,dataidmap)
506  for run in deliveredresult.keys():#loop over delivered,already selected
507  perrundata=deliveredresult[run]
508  if perrundata is None or len(perrundata)==0: #pass through
509  continue
510  alltrgls=[]
511  if run in trgresult and trgresult[run]:
512  alltrgls=[x[0] for x in trgresult[run]]
513  for perlsdata in perrundata:#loop over ls
514  if not perlsdata: continue #no lumi data for this ls
515  perlsdata.insert(6,None)
516  if not alltrgls: continue #no trg for this run,recorded=None
517  cmslsnum=perlsdata[1]
518  if cmslsnum==0:#if not a cmsls or not selected by cms list, set recordedlumi to 0
519  recordedlumi=0.0
520  else:
521  try:
522  trglsidx=alltrgls.index(cmslsnum)
523  deadfrac=trgresult[run][trglsidx][1]
524  if deadfrac<0 or deadfrac>1.0: deadfrac=1.0
525  deliveredlumi=perlsdata[5]
526  recordedlumi=(1.0-deadfrac)*deliveredlumi
527  except ValueError:
528  #print '[WARNING] no trigger for LS=',cmslsnum
529  recordedlumi=None
530  perlsdata[6]=recordedlumi
531  return deliveredresult
def deliveredLumiForIds
Definition: lumiCalcAPI.py:369
def lumiCalcAPI.runList (   schema,
  datatagid,
  runmin = None,
  runmax = None,
  fillmin = None,
  fillmax = None,
  startT = None,
  stopT = None,
  l1keyPattern = None,
  hltkeyPattern = None,
  amodetag = None,
  nominalEnergy = None,
  energyFlut = 0.2,
  requiretrg = True,
  requirehlt = True,
  preselectedruns = None,
  lumitype = 'HF' 
)
output: [runnumber,...]

Definition at line 47 of file lumiCalcAPI.py.

References dataDML.runList().

Referenced by lumiData2.main().

47 
48 def runList(schema,datatagid,runmin=None,runmax=None,fillmin=None,fillmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None,nominalEnergy=None,energyFlut=0.2,requiretrg=True,requirehlt=True,preselectedruns=None,lumitype='HF'):
49  '''
50  output: [runnumber,...]
51  '''
52  return dataDML.runList(schema,datatagid,runmin=runmin,runmax=runmax,fillmin=fillmin,fillmax=fillmax,startT=startT,stopT=stopT,l1keyPattern=l1keyPattern,hltkeyPattern=hltkeyPattern,amodetag=amodetag,nominalEnergy=nominalEnergy,energyFlut=energyFlut,requiretrg=requiretrg,requirehlt=requirehlt,lumitype=lumitype)
def runList
Definition: dataDML.py:240
def lumiCalcAPI.runsummary (   schema,
  irunlsdict 
)

Lumi data management and calculation API # # Author: Zhen Xie #.

output  [[run(0),l1key(1),amodetag(2),egev(3),hltkey(4),fillnum(5),fillscheme(6),starttime(7),stoptime(8)]]

Definition at line 10 of file lumiCalcAPI.py.

References dataDML.runsummary().

Referenced by specificLumi.getFillFromDB(), and runsummaryMap().

10 
11 def runsummary(schema,irunlsdict):
12  '''
13  output [[run(0),l1key(1),amodetag(2),egev(3),hltkey(4),fillnum(5),fillscheme(6),starttime(7),stoptime(8)]]
14  '''
15  result=[]
16  for run in sorted(irunlsdict):
17  runinfo=dataDML.runsummary(schema,run)
18  runinfo.insert(0,run)
19  result.append(runinfo)
20  return result
def runsummary
Definition: dataDML.py:422
def runsummary
Lumi data management and calculation API # # Author: Zhen Xie #.
Definition: lumiCalcAPI.py:10
def lumiCalcAPI.runsummaryMap (   schema,
  irunlsdict,
  dataidmap,
  lumitype = 'HF' 
)
output: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}

Definition at line 21 of file lumiCalcAPI.py.

References dataDML.lumiRunByIds(), and runsummary().

Referenced by specificLumi.getSpecificLumi().

21 
22 def runsummaryMap(schema,irunlsdict,dataidmap,lumitype='HF'):
23  '''
24  output: {run:[l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]}
25  '''
26  result={}
27  seqresult=runsummary(schema,irunlsdict)
28  idresult=dataDML.lumiRunByIds(schema,dataidmap,lumitype)
29  for [run,l1key,amodetag,hltkey,fillnum,fillscheme] in seqresult:
30  egev=idresult[run][2]
31  startT=idresult[run][3]
32  stopT=idresult[run][4]
33  result[run]=[l1key,amodetag,egev,hltkey,fillnum,fillscheme,startT,stopT]
34  return result
def lumiRunByIds
Definition: dataDML.py:904
def runsummary
Lumi data management and calculation API # # Author: Zhen Xie #.
Definition: lumiCalcAPI.py:10
def runsummaryMap
Definition: lumiCalcAPI.py:21
def lumiCalcAPI.trgForIds (   schema,
  irunlsdict,
  dataidmap,
  trgbitname = None,
  trgbitnamepattern = None,
  withL1Count = False,
  withPrescale = False 
)
input :
        irunlsdict  {run:[cmsls]} (required)
        dataidmap: {run:(lumiid,trgid,hltid)}
        trgbitname exact match  trgbitname (optional)
        trgbitnamepattern match trgbitname (optional)
output
        result {run:[[cmslsnum(0),deadfrac(1),deadtimecount(2),bitzero_count(3),bitzero_prescale(4),[(bitname,prescale,counts,mask)](5)]]}

Definition at line 197 of file lumiCalcAPI.py.

References bitset_utilities.append(), and dataDML.trgLSById().

Referenced by effectiveLumiForIds(), and lumiForIds().

198 def trgForIds(schema,irunlsdict,dataidmap,trgbitname=None,trgbitnamepattern=None,withL1Count=False,withPrescale=False):
199  '''
200  input :
201  irunlsdict {run:[cmsls]} (required)
202  dataidmap: {run:(lumiid,trgid,hltid)}
203  trgbitname exact match trgbitname (optional)
204  trgbitnamepattern match trgbitname (optional)
205  output
206  result {run:[[cmslsnum(0),deadfrac(1),deadtimecount(2),bitzero_count(3),bitzero_prescale(4),[(bitname,prescale,counts,mask)](5)]]}
207  '''
208  result={}
209  for run in irunlsdict.keys():
210  result[run]=[]
211  lslist=irunlsdict[run]
212  if lslist is not None and len(lslist)==0:
213  #if no LS is selected for a run
214  continue
215  if run not in dataidmap:
216  continue
217  trgdataid=dataidmap[run][1]
218  if trgdataid is None:
219  result[run]=None
220  continue #if run non exist
221  if trgdataid==0:
222  continue
223  trgdata=dataDML.trgLSById(schema,trgdataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern,withL1Count=withL1Count,withPrescale=withPrescale)
224 
225  #(runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale)](4)]})
226  if trgdata and trgdata[1]:
227  lsdict={}
228  for cmslsnum in sorted(trgdata[1]):
229  if lslist is not None and cmslsnum not in lslist:
230  continue
231  lsdata=[]
232  #print trgdata[1][cmslsnum]
233  deadtimecount=trgdata[1][cmslsnum][0]
234  #bitzerocount=trgdata[1][cmslsnum][1]
235  #bitzeroprescale=trgdata[1][cmslsnum][2]
236  bitzerocount=0
237  bitzeroprescale=0
238  deadfrac=trgdata[1][cmslsnum][3]
239  if deadfrac<0 or deadfrac>1.0:
240  deadfrac=1.0
241  allbitsinfo=trgdata[1][cmslsnum][4]
242  lsdata.append(cmslsnum)
243  lsdata.append(deadfrac)
244  lsdata.append(deadtimecount)
245  lsdata.append(bitzerocount)
246  lsdata.append(bitzeroprescale)
247  lsdata.append(allbitsinfo)
248  result[run].append(lsdata)
249  return result
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def trgLSById
Definition: dataDML.py:797