CMS 3D CMS Logo

Functions | Variables
dataDML Namespace Reference

Functions

def addCorrToBranch (schema, corrname, a1, optionalcorrdata, branchinfo)
 
def addHLTRunDataToBranch (schema, runnumber, hltrundata, branchinfo)
 
def addLumiRunDataToBranch (schema, runnumber, lumirundata, branchinfo, tableName)
 
def addNormToBranch (schema, normname, amodetag, norm1, egev1, optionalnormdata, branchinfo)
 
def addTrgRunDataToBranch (schema, runnumber, trgrundata, branchinfo)
 
def allfillschemes (schema)
 
def beamInfoById (schema, dataid, withBeamIntensity=False, minIntensity=0.1)
 
def beamstatusByIds (schema, dataidMap)
 
def bulkInsertHltLSData (session, runnumber, data_id, hltlsdata, bulksize=500)
 
def bulkInsertLumiLSSummary (session, runnumber, data_id, lumilsdata, tableName, bulksize=500, withDetails=True)
 
def bulkInsertTrgLSData (session, runnumber, data_id, trglsdata, bulksize=500)
 
def dataentryIdByRun (schema, runnum, branchfilter)
 
def fillInRange (schema, fillmin, fillmax, amodetag, startT, stopT)
 
def fillrunMap (schema, fillnum=None, runmin=None, runmax=None, startT=None, stopT=None, l1keyPattern=None, hltkeyPattern=None, amodetag=None)
 
def fillschemePatternMap (schema, lumitype)
 
def guesscorrIdByName (schema, tagname=None)
 LumiDB DML API # # Author: Zhen Xie #. More...
 
def guessDataIdByRun (schema, runnum, tablename, revfilter=None)
 
def guessDataIdForRange (schema, inputRange, tablename)
 
def guessHltDataIdByRunInBranch (schema, runnum, tablename, branchName)
 
def guessLumiDataIdByRunInBranch (schema, runnum, tablename, branchName)
 
def guessnormIdByContext (schema, amodetag, egev1)
 
def guessnormIdByName (schema, normname)
 
def guessTrgDataIdByRunInBranch (schema, runnum, tablename, branchName)
 
def hltLSById (schema, dataid, hltpathname=None, hltpathpattern=None, withL1Pass=False, withHLTAccept=False)
 
def hltRunById (schema, dataid, hltpathname=None, hltpathpattern=None)
 
def hlttrgMappingByrun (schema, runnum, hltpathname=None, hltpathpattern=None)
 
def insertRunSummaryData (schema, runnumber, runsummarydata, complementalOnly=False)
 
def insertTrgHltMap (schema, hltkey, trghltmap)
 
def intglumiForRange (schema, runlist)
 
def latestdataIdByEntry (schema, entryid, datatype, branchfilter)
 
def lumiBXByAlgo (schema, dataid, algoname)
 
def lumicorrById (schema, correctiondataid)
 
def lumiLSById (schema, dataid, beamstatus=None, withBXInfo=False, bxAlgo='OCC1', withBeamIntensity=False, tableName=None)
 
def luminormById (schema, dataid)
 
def lumiRunById (schema, lumidataid, lumitype='HF')
 
def lumiRunByIds (schema, dataidMap, lumitype='HF')
 
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=None)
 
def runsummary (schema, runnum, sessionflavor='')
 
def trgLSById (schema, dataid, trgbitname=None, trgbitnamepattern=None, withL1Count=False, withPrescale=False)
 
def trgRunById (schema, dataid, trgbitname=None, trgbitnamepattern=None)
 

Variables

 authpath
 
 branchid
 
 branchinfo
 
 branchparent
 
 comment
 
 cpp2sqltype
 
 datainfo
 
 debugON
 
 False
 
 hltdata
 
 hltdataid
 
 hltentryid
 
 hltlsdata
 
 hltrevid
 
 hltrundata
 
 hlttrgmap
 
 isReadOnly
 
 latestNorms
 
 latestrevision
 
 lumidataid
 
 lumidummydata
 
 lumientry_id
 
 lumientryid
 
 lumilsdata
 
 luminormentry_id
 
 lumirevid
 
 lumirundata
 
 myconstr
 
 None
 
 normbranchid
 
 normbranchinfo
 
 normbranchparent
 
 norminfo
 
 normrevlist
 
 parentid
 
 parentname
 
 revisionid
 
 revlist
 
 runsummarydata
 
 schema
 
 session
 
 svc
 
 tables
 
 trgdata
 
 trgdataid
 
 trgentry_id
 
 trgentryid
 
 trglsdata
 
 trgrevid
 
 trgrundata
 
 trunkinfo
 
 withblobdata
 

Function Documentation

def dataDML.addCorrToBranch (   schema,
  corrname,
  a1,
  optionalcorrdata,
  branchinfo 
)
input:
   branchinfo(corrrevisionid,branchname)
   optionalcorrdata {'a2':a2,'drift':drif}
output:
   (revision_id,entry_id,data_id)

Definition at line 1931 of file dataDML.py.

References revisionDML.addEntry(), revisionDML.addRevision(), revisionDML.bookNewEntry(), revisionDML.bookNewRevision(), and revisionDML.entryInBranch().

1931 def addCorrToBranch(schema,corrname,a1,optionalcorrdata,branchinfo):
1932  '''
1933  input:
1934  branchinfo(corrrevisionid,branchname)
1935  optionalcorrdata {'a2':a2,'drift':drif}
1936  output:
1937  (revision_id,entry_id,data_id)
1938  '''
1939  a2=1.0
1940  if 'a2' in optionalcorrdata:
1941  a2=optionalcorrdata['a2']
1942  drift=1.0
1943  if 'drift' in optionalcorrdata:
1944  drift=optionalcorrdata['drift']
1945  try:
1946  entry_id=revisionDML.entryInBranch(schema,nameDealer.lumicorrectionsTableName(),corrname,branchinfo[1])
1947  if entry_id is None:
1948  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.lumicorrectionsTableName())
1949  entryinfo=(revision_id,entry_id,corrname,data_id)
1950  revisionDML.addEntry(schema,nameDealer.lumicorrectionsTableName(),entryinfo,branchinfo)
1951  else:
1952  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.lumicorrectionsTableName() )
1953  revisionDML.addRevision(schema,nameDealer.lumicorrectionsTableName(),(revision_id,data_id),branchinfo)
1954  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','A1':'float','A2':'float','DRIFT':'float'}
1955  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':corrname,'A1':a1,'A2':a2,'DRIFT':drift}
1956  db=dbUtil.dbUtil(schema)
1957  db.insertOneRow(nameDealer.lumicorrectionsTableName(),tabrowDefDict,tabrowValueDict)
1958  return (revision_id,entry_id,data_id)
1959  except :
1960  raise
1961 
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:342
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:330
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:316
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:394
def addCorrToBranch(schema, corrname, a1, optionalcorrdata, branchinfo)
Definition: dataDML.py:1931
def dataDML.addHLTRunDataToBranch (   schema,
  runnumber,
  hltrundata,
  branchinfo 
)
input:
    hltrundata [pathnameclob(0),datasource(1)]
output:
    (revision_id,entry_id,data_id)

Definition at line 2028 of file dataDML.py.

References revisionDML.addEntry(), revisionDML.addRevision(), revisionDML.bookNewEntry(), revisionDML.bookNewRevision(), revisionDML.entryInBranch(), nameDealer.hltdataTableName(), createfilelist.int, and harvestTrackValidationPlots.str.

2028 def addHLTRunDataToBranch(schema,runnumber,hltrundata,branchinfo):
2029  '''
2030  input:
2031  hltrundata [pathnameclob(0),datasource(1)]
2032  output:
2033  (revision_id,entry_id,data_id)
2034  '''
2035  try:
2036  pathnames=hltrundata[0]
2037  datasource=hltrundata[1]
2038  npath=len(pathnames.split(','))
2039  entry_id=revisionDML.entryInBranch(schema,nameDealer.hltdataTableName(),str(runnumber),branchinfo[1])
2040  if entry_id is None:
2041  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName())
2042  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
2043  revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo)
2044  else:
2045  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() )
2046  revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo)
2047  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'}
2048  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames}
2049  db=dbUtil.dbUtil(schema)
2050  db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict)
2051  return (revision_id,entry_id,data_id)
2052  except :
2053  raise
2054 
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:342
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:330
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:316
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:394
def hltdataTableName()
Definition: nameDealer.py:58
def addHLTRunDataToBranch(schema, runnumber, hltrundata, branchinfo)
Definition: dataDML.py:2028
def dataDML.addLumiRunDataToBranch (   schema,
  runnumber,
  lumirundata,
  branchinfo,
  tableName 
)
input:
      lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls]
      branchinfo (branch_id,branch_name)
      tableName lumiruntablename
output:
      (revision_id,entry_id,data_id)

Definition at line 1962 of file dataDML.py.

References revisionDML.addEntry(), revisionDML.addRevision(), revisionDML.bookNewEntry(), revisionDML.bookNewRevision(), revisionDML.entryInBranch(), createfilelist.int, and harvestTrackValidationPlots.str.

1962 def addLumiRunDataToBranch(schema,runnumber,lumirundata,branchinfo,tableName):
1963  '''
1964  input:
1965  lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls]
1966  branchinfo (branch_id,branch_name)
1967  tableName lumiruntablename
1968  output:
1969  (revision_id,entry_id,data_id)
1970  '''
1971  try:
1972  datasource=lumirundata[0]
1973  nominalegev=3500.0
1974  ncollidingbunches=0
1975  starttime=coral.TimeStamp()
1976  stoptime=coral.TimeStamp()
1977  nls=0
1978  if len(lumirundata)>1:
1979  nominalenergy=lumirundata[1]
1980  ncollidingbunches=lumirundata[2]
1981  starttime=lumirundata[3]
1982  stoptime=lumirundata[4]
1983  nls=lumirundata[5]
1984  entry_id=revisionDML.entryInBranch(schema,tableName,str(runnumber),branchinfo[1])
1985  if entry_id is None:
1986  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,tableName)
1987  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
1988  revisionDML.addEntry(schema,tableName,entryinfo,branchinfo)
1989  else:
1990  (revision_id,data_id)=revisionDML.bookNewRevision(schema,tableName)
1991  #print 'revision_id,data_id ',revision_id,data_id
1992  revisionDML.addRevision(schema,tableName,(revision_id,data_id),branchinfo)
1993  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NOMINALEGEV':'float','NCOLLIDINGBUNCHES':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp','NLS':'unsigned int'}
1994  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NOMINALEGEV':nominalegev,'NCOLLIDINGBUNCHES':ncollidingbunches,'STARTTIME':starttime,'STOPTIME':stoptime,'NLS':nls}
1995  db=dbUtil.dbUtil(schema)
1996  db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
1997  return (revision_id,entry_id,data_id)
1998  except :
1999  raise
2000 
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:342
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def addLumiRunDataToBranch(schema, runnumber, lumirundata, branchinfo, tableName)
Definition: dataDML.py:1962
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:330
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:316
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:394
def dataDML.addNormToBranch (   schema,
  normname,
  amodetag,
  norm1,
  egev1,
  optionalnormdata,
  branchinfo 
)
input:
   branchinfo(normrevisionid,branchname)
   optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
output:
   (revision_id,entry_id,data_id)

Definition at line 1893 of file dataDML.py.

References revisionDML.addEntry(), revisionDML.addRevision(), revisionDML.bookNewEntry(), revisionDML.bookNewRevision(), revisionDML.entryInBranch(), and nameDealer.luminormTableName().

1893 def addNormToBranch(schema,normname,amodetag,norm1,egev1,optionalnormdata,branchinfo):
1894  '''
1895  input:
1896  branchinfo(normrevisionid,branchname)
1897  optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
1898  output:
1899  (revision_id,entry_id,data_id)
1900  '''
1901  #print 'branchinfo ',branchinfo
1902  norm_occ2=1.0
1903  if 'normOcc2' in optionalnormdata:
1904  norm_occ2=optionalnormdata['norm_occ2']
1905  norm_et=1.0
1906  if 'norm_et' in optionalnormdata:
1907  norm_et=optionalnormdata['norm_et']
1908  norm_pu=1.0
1909  if 'norm_pu' in optionalnormdata:
1910  norm_pu=optionalnormdata['norm_pu']
1911  constfactor=1.0
1912  if 'constfactor' in optionalnormdata:
1913  constfactor=optionalnormdata['constfactor']
1914  try:
1915  entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1])
1916  if entry_id is None:
1917  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName())
1918  entryinfo=(revision_id,entry_id,normname,data_id)
1919  revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo)
1920  else:
1921  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() )
1922  revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo)
1923  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','AMODETAG':'string','NORM_1':'float','EGEV_1':'unsigned int','NORM_OCC2':'float','NORM_ET':'float','NORM_PU':'float','CONSTFACTOR':'float'}
1924  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':normname,'AMODETAG':amodetag,'NORM_1':norm1,'EGEV_1':egev1,'NORM_OCC2':norm_occ2,'NORM_ET':norm_et,'NORM_PU':norm_pu,'CONSTFACTOR':constfactor}
1925  db=dbUtil.dbUtil(schema)
1926  db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict)
1927  return (revision_id,entry_id,data_id)
1928  except :
1929  raise
1930 
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:342
def luminormTableName()
Definition: nameDealer.py:37
def addNormToBranch(schema, normname, amodetag, norm1, egev1, optionalnormdata, branchinfo)
Definition: dataDML.py:1893
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:330
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:316
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:394
def dataDML.addTrgRunDataToBranch (   schema,
  runnumber,
  trgrundata,
  branchinfo 
)
input:
   trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)]
   bitnames clob, bitnames separated by ','
output:
   (revision_id,entry_id,data_id)

Definition at line 2001 of file dataDML.py.

References revisionDML.addEntry(), revisionDML.addRevision(), revisionDML.bookNewEntry(), revisionDML.bookNewRevision(), revisionDML.entryInBranch(), createfilelist.int, harvestTrackValidationPlots.str, and nameDealer.trgdataTableName().

2001 def addTrgRunDataToBranch(schema,runnumber,trgrundata,branchinfo):
2002  '''
2003  input:
2004  trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)]
2005  bitnames clob, bitnames separated by ','
2006  output:
2007  (revision_id,entry_id,data_id)
2008  '''
2009  try: #fixme: need to consider revision only case
2010  datasource=trgrundata[0]
2011  bitzeroname=trgrundata[1]
2012  bitnames=trgrundata[2]
2013  entry_id=revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),str(runnumber),branchinfo[1])
2014  if entry_id is None:
2015  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.trgdataTableName())
2016  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
2017  revisionDML.addEntry(schema,nameDealer.trgdataTableName(),entryinfo,branchinfo)
2018  else:
2019  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.trgdataTableName() )
2020  revisionDML.addRevision(schema,nameDealer.trgdataTableName(),(revision_id,data_id),branchinfo)
2021  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','SOURCE':'string','RUNNUM':'unsigned int','BITZERONAME':'string','BITNAMECLOB':'string'}
2022  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'SOURCE':datasource,'RUNNUM':int(runnumber),'BITZERONAME':bitzeroname,'BITNAMECLOB':bitnames}
2023  db=dbUtil.dbUtil(schema)
2024  db.insertOneRow(nameDealer.trgdataTableName(),tabrowDefDict,tabrowValueDict)
2025  return (revision_id,entry_id,data_id)
2026  except :
2027  raise
def addTrgRunDataToBranch(schema, runnumber, trgrundata, branchinfo)
Definition: dataDML.py:2001
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:342
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:330
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:316
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:394
def trgdataTableName()
Definition: nameDealer.py:46
def dataDML.allfillschemes (   schema)

Definition at line 1063 of file dataDML.py.

References data, nameDealer.fillschemeTableName(), and GetRecoTauVFromDQM_MC_cff.next.

1063 def allfillschemes(schema):
1064  afterglows=[]
1066  try:
1067  qHandle.addToTableList(s)
1068  qResult=coral.AttributeList()
1069  qResult.extend('FILLSCHEMEPATTERN','string')
1070  qResult.extend('CORRECTIONFACTOR','float')
1071  qHandle.defineOutput(qResult)
1072  qHandle.addToOutputList('FILLSCHEMEPATTERN')
1073  qHandle.addToOutputList('CORRECTIONFACTOR')
1074  cursor=qHandle.execute()
1075  while next(cursor):
1076  fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
1077  afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
1078  afterglows.append((fillschemePattern,afterglowfac))
1079  except :
1080  del qHandle
1081  raise
1082  del qHandle
1083  return afterglows
1084 
def allfillschemes(schema)
Definition: dataDML.py:1063
def fillschemeTableName()
Definition: nameDealer.py:13
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.beamInfoById (   schema,
  dataid,
  withBeamIntensity = False,
  minIntensity = 0.1 
)
result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..])
     beaminfolist=[(bxidx,beam1intensity,beam2intensity)]

Definition at line 1192 of file dataDML.py.

References data, nameDealer.lumidataTableName(), nameDealer.lumisummaryv2TableName(), GetRecoTauVFromDQM_MC_cff.next, and CommonUtil.unpackBlobtoArray().

Referenced by lumiCalcAPI.beamForIds(), and lumiCalcAPI.beamForRange().

1192 def beamInfoById(schema,dataid,withBeamIntensity=False,minIntensity=0.1):
1193  '''
1194  result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..])
1195  beaminfolist=[(bxidx,beam1intensity,beam2intensity)]
1196  '''
1197  runnum=0
1198  result=[]
1199  ncollidingbunches=0
1200  qHandle=schema.newQuery()
1201  try:
1202  qHandle.addToTableList(nameDealer.lumidataTableName())
1203  qHandle.addToOutputList('NCOLLIDINGBUNCHES')
1204  qConditionStr='DATA_ID=:dataid'
1205  qCondition=coral.AttributeList()
1206  qCondition.extend('dataid','unsigned long long')
1207  qCondition['dataid'].setData(dataid)
1208  qResult=coral.AttributeList()
1209  qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
1210  qHandle.defineOutput(qResult)
1211  qHandle.setCondition(qConditionStr,qCondition)
1212  cursor=qHandle.execute()
1213  while next(cursor):
1214  ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
1215  except :
1216  del qHandle
1217  raise
1218  del qHandle
1219  qHandle=schema.newQuery()
1220  try:
1221  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
1222  qHandle.addToOutputList('RUNNUM')
1223  qHandle.addToOutputList('CMSLSNUM')
1224  qHandle.addToOutputList('LUMILSNUM')
1225  qHandle.addToOutputList('BEAMSTATUS')
1226  qHandle.addToOutputList('BEAMENERGY')
1227  if withBeamIntensity:
1228  qHandle.addToOutputList('CMSBXINDEXBLOB')
1229  qHandle.addToOutputList('BEAMINTENSITYBLOB_1')
1230  qHandle.addToOutputList('BEAMINTENSITYBLOB_2')
1231  qConditionStr='DATA_ID=:dataid'
1232  qCondition=coral.AttributeList()
1233  qCondition.extend('dataid','unsigned long long')
1234  qCondition['dataid'].setData(dataid)
1235  qResult=coral.AttributeList()
1236  qResult.extend('RUNNUM','unsigned int')
1237  qResult.extend('CMSLSNUM','unsigned int')
1238  qResult.extend('LUMILSNUM','unsigned int')
1239  qResult.extend('BEAMSTATUS','string')
1240  qResult.extend('BEAMENERGY','float')
1241  if withBeamIntensity:
1242  qResult.extend('BXINDEXBLOB','blob')
1243  qResult.extend('BEAM1INTENSITY','blob')
1244  qResult.extend('BEAM2INTENSITY','blob')
1245  qHandle.defineOutput(qResult)
1246  qHandle.setCondition(qConditionStr,qCondition)
1247  cursor=qHandle.execute()
1248  while next(cursor):
1249  runnum=cursor.currentRow()['RUNNUM'].data()
1250  cmslsnum=cursor.currentRow()['CMSLSNUM'].data()
1251  lumilsnum=cursor.currentRow()['LUMILSNUM'].data()
1252  beamstatus=cursor.currentRow()['BEAMSTATUS'].data()
1253  beamenergy=cursor.currentRow()['BEAMENERGY'].data()
1254  bxindexblob=None
1255  beaminfotupleList=[]
1256  if withBeamIntensity:
1257  bxindexblob=cursor.currentRow()['BXINDEXBLOB'].data()
1258  beam1intensityblob=cursor.currentRow()['BEAM1INTENSITY'].data()
1259  beam2intensityblob=cursor.currentRow()['BEAM2INTENSITY'].data()
1260  bxindexArray=None
1261  beam1intensityArray=None
1262  beam2intensityArray=None
1263  if bxindexblob:
1264  bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h')
1265  if beam1intensityblob:
1266  beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensityblob,'f')
1267  if beam2intensityblob:
1268  beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensityblob,'f')
1269  if bxindexArray and beam1intensityArray and beam2intensityArray:
1270  for idx,bxindex in enumerate(bxindexArray):
1271  if (beam1intensityArray[idx] and beam1intensityArray[idx]>minIntensity) or (beam2intensityArray[idx] and beam2intensityArray[idx]>minIntensity):
1272  beaminfotuple=(bxindex,beam1intensityArray[idx],beam2intensityArray[idx])
1273  beaminfotupleList.append(beaminfotuple)
1274  del bxindexArray[:]
1275  del beam1intensityArray[:]
1276  del beam2intensityArray[:]
1277  result.append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beaminfotupleList))
1278  except:
1279  del qHandle
1280  raise
1281  del qHandle
1282  return (runnum,result)
def lumisummaryv2TableName()
Definition: nameDealer.py:28
def unpackBlobtoArray(iblob, itemtypecode)
Definition: CommonUtil.py:229
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def beamInfoById(schema, dataid, withBeamIntensity=False, minIntensity=0.1)
Definition: dataDML.py:1192
def lumidataTableName()
Definition: nameDealer.py:19
def dataDML.beamstatusByIds (   schema,
  dataidMap 
)
input dataidMap : {run:lumidataid}
result {runnum:{cmslsnum:beamstatus}}

Definition at line 920 of file dataDML.py.

References data, createfilelist.int, nameDealer.lumisummaryv2TableName(), and GetRecoTauVFromDQM_MC_cff.next.

920 def beamstatusByIds(schema,dataidMap):
921  '''
922  input dataidMap : {run:lumidataid}
923  result {runnum:{cmslsnum:beamstatus}}
924  '''
925  result={}
926  if not dataidMap:
927  return result
928  inputRange=dataidMap.keys()
929  for r in inputRange:
930  if r not in result:
931  result[r]={}
932  lumidataid=dataidMap[r][0]
933  if lumidataid:
934  qHandle=schema.newQuery()
935  try:
936  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
937  qHandle.addToOutputList('CMSLSNUM')
938  qHandle.addToOutputList('BEAMSTATUS')
939  qConditionStr='DATA_ID=:dataid'
940  qCondition=coral.AttributeList()
941  qCondition.extend('dataid','unsigned long long')
942  qCondition['dataid'].setData(int(lumidataid))
943  qResult=coral.AttributeList()
944  qResult.extend('CMSLSNUM','unsigned int')
945  qResult.extend('BEAMSTATUS','string')
946  qHandle.defineOutput(qResult)
947  qHandle.setCondition(qConditionStr,qCondition)
948  cursor=qHandle.execute()
949  while next(cursor):
950  cmslsnum=cursor.currentRow()['CMSLSNUM'].data()
951  bs=cursor.currentRow()['BEAMSTATUS'].data()
952  if bs!='STABLE BEAMS':
953  result[r][cmslsnum]=bs
954  except:
955  del qHandle
956  raise
957  del qHandle
958  return result
959 
def beamstatusByIds(schema, dataidMap)
Definition: dataDML.py:920
def lumisummaryv2TableName()
Definition: nameDealer.py:28
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.bulkInsertHltLSData (   session,
  runnumber,
  data_id,
  hltlsdata,
  bulksize = 500 
)
input:
hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}

Definition at line 2167 of file dataDML.py.

References nameDealer.lshltTableName().

2167 def bulkInsertHltLSData(session,runnumber,data_id,hltlsdata,bulksize=500):
2168  '''
2169  input:
2170  hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
2171  '''
2172  print 'total number of hlt rows ',len(hltlsdata)
2173  lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')]
2174  committedrows=0
2175  nrows=0
2176  bulkvalues=[]
2177  try:
2178  for cmslsnum,perlshlt in hltlsdata.items():
2179  inputcountblob=perlshlt[0]
2180  acceptcountblob=perlshlt[1]
2181  prescaleblob=perlshlt[2]
2182  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)])
2183 
2184  nrows+=1
2185  committedrows+=1
2186  if nrows==bulksize:
2187  print 'committing hlt in LS chunck ',nrows
2188  db=dbUtil.dbUtil(session.nominalSchema())
2189  session.transaction().start(False)
2190  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
2191  session.transaction().commit()
2192  nrows=0
2193  bulkvalues=[]
2194  elif committedrows==len(hltlsdata):
2195  print 'committing hlt at the end '
2196  db=dbUtil.dbUtil(session.nominalSchema())
2197  session.transaction().start(False)
2198  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
2199  session.transaction().commit()
2200  except :
2201  print 'error in bulkInsertHltLSData'
2202  raise
2203 
Definition: start.py:1
def lshltTableName()
Definition: nameDealer.py:61
def bulkInsertHltLSData(session, runnumber, data_id, hltlsdata, bulksize=500)
Definition: dataDML.py:2167
def dataDML.bulkInsertLumiLSSummary (   session,
  runnumber,
  data_id,
  lumilsdata,
  tableName,
  bulksize = 500,
  withDetails = True 
)
input:
      lumilsdata {lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beam1intensity,beam2intensity,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}

Definition at line 2204 of file dataDML.py.

2204 def bulkInsertLumiLSSummary(session,runnumber,data_id,lumilsdata,tableName,bulksize=500,withDetails=True):
2205  '''
2206  input:
2207  lumilsdata {lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beam1intensity,beam2intensity,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}
2208  '''
2209  lslumiDefDict=[]
2210  if withDetails:
2211  lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('INSTLUMI','float'),('INSTLUMIERROR','float'),('INSTLUMIQUALITY','short'),('BEAMSTATUS','string'),('BEAMENERGY','float'),('NUMORBIT','unsigned int'),('STARTORBIT','unsigned int'),('CMSBXINDEXBLOB','blob'),('BEAMINTENSITYBLOB_1','blob'),('BEAMINTENSITYBLOB_2','blob'),('BXLUMIVALUE_OCC1','blob'),('BXLUMIERROR_OCC1','blob'),('BXLUMIQUALITY_OCC1','blob'),('BXLUMIVALUE_OCC2','blob'),('BXLUMIERROR_OCC2','blob'),('BXLUMIQUALITY_OCC2','blob'),('BXLUMIVALUE_ET','blob'),('BXLUMIERROR_ET','blob'),('BXLUMIQUALITY_ET','blob')]
2212  else:
2213  lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('INSTLUMI','float'),('INSTLUMIERROR','float'),('INSTLUMIQUALITY','short'),('BEAMSTATUS','string'),('BEAMENERGY','float'),('NUMORBIT','unsigned int'),('STARTORBIT','unsigned int')]
2214  print 'total number of lumi rows ',len(lumilsdata)
2215  try:
2216  committedrows=0
2217  nrows=0
2218  bulkvalues=[]
2219  for lumilsnum,perlslumi in lumilsdata.items():
2220  cmslsnum=perlslumi[0]
2221  instlumi=perlslumi[1]
2222  instlumierror=perlslumi[2]
2223  instlumiquality=perlslumi[3]
2224  beamstatus=perlslumi[4]
2225  beamenergy=perlslumi[5]
2226  numorbit=perlslumi[6]
2227  startorbit=perlslumi[7]
2228  if withDetails:
2229  cmsbxindexindexblob=perlslumi[8]
2230  beam1intensity=perlslumi[9]
2231  beam2intensity=perlslumi[10]
2232  bxlumivalue_occ1=perlslumi[11]
2233  bxlumierror_occ1=perlslumi[12]
2234  bxlumiquality_occ1=perlslumi[13]
2235  bxlumivalue_occ2=perlslumi[14]
2236  bxlumierror_occ2=perlslumi[15]
2237  bxlumiquality_occ2=perlslumi[16]
2238  bxlumivalue_et=perlslumi[17]
2239  bxlumierror_et=perlslumi[18]
2240  bxlumiquality_et=perlslumi[19]
2241  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('INSTLUMI',instlumi),('INSTLUMIERROR',instlumierror),('INSTLUMIQUALITY',instlumiquality),('BEAMSTATUS',beamstatus),('BEAMENERGY',beamenergy),('NUMORBIT',numorbit),('STARTORBIT',startorbit),('CMSBXINDEXBLOB',cmsbxindexindexblob),('BEAMINTENSITYBLOB_1',beam1intensity),('BEAMINTENSITYBLOB_2',beam2intensity),('BXLUMIVALUE_OCC1',bxlumivalue_occ1),('BXLUMIERROR_OCC1',bxlumierror_occ1),('BXLUMIQUALITY_OCC1',bxlumiquality_occ1),('BXLUMIVALUE_OCC2',bxlumivalue_occ2),('BXLUMIERROR_OCC2',bxlumierror_occ2),('BXLUMIQUALITY_OCC2',bxlumiquality_occ2),('BXLUMIVALUE_ET',bxlumivalue_et),('BXLUMIERROR_ET',bxlumierror_et),('BXLUMIQUALITY_ET',bxlumiquality_et)])
2242  else:
2243  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('INSTLUMI',instlumi),('INSTLUMIERROR',instlumierror),('INSTLUMIQUALITY',instlumiquality),('BEAMSTATUS',beamstatus),('BEAMENERGY',beamenergy),('NUMORBIT',numorbit),('STARTORBIT',startorbit)])
2244  nrows+=1
2245  committedrows+=1
2246  if nrows==bulksize:
2247  print 'committing lumi in LS chunck ',nrows
2248  db=dbUtil.dbUtil(session.nominalSchema())
2249  session.transaction().start(False)
2250  db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2251  session.transaction().commit()
2252  nrows=0
2253  bulkvalues=[]
2254  elif committedrows==len(lumilsdata):
2255  print 'committing lumi at the end '
2256  db=dbUtil.dbUtil(session.nominalSchema())
2257  session.transaction().start(False)
2258  db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
2259  session.transaction().commit()
2260  except :
2261  raise
2262 
2263 #def insertLumiLSDetail(schema,runnumber,data_id,lumibxdata):
2264 # '''
2265 # input:
2266 # lumibxdata [(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]})]
2267 # output:
2268 # nrows
2269 # '''
2270 # try:
2271 # nrow=0
2272 # bulkvalues=[]
2273 # lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('ALGONAME','string'),('BXLUMIVALUE','blob'),('BXLUMIERROR','blob'),('BXLUMIQUALITY','blob')]
2274 # for (algoname,peralgobxdata) in lumibxdata:
2275 # for lumilsnum,bxdata in peralgobxdata.items():
2276 # cmslsnum=bxdata[0]
2277 # bxlumivalue=bxdata[1]
2278 # bxlumierror=bxdata[2]
2279 # bxlumiquality=bxdata[3]
2280 # bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('ALGONAME',algoname),('BXLUMIVALUE',bxlumivalue),('BXLUMIERROR',bxlumierror),('BXLUMIQUALITY',bxlumiquality)])
2281 # db=dbUtil.dbUtil(schema)
2282 # db.bulkInsert(nameDealer.lumidetailTableName(),lslumiDefDict,bulkvalues)
2283 # return len(bulkvalues)
2284 # except:
2285 # raise
2286 
2287 #def completeOldLumiData(schema,runnumber,lsdata,data_id):
2288 # '''
2289 # input:
2290 # lsdata [[lumisummary_id,lumilsnum,cmslsnum]]
2291 # '''
2292 # try:
2293 # #update in lumisummary table
2294 # #print 'insert in lumisummary table'
2295 # setClause='DATA_ID=:data_id'
2296 # updateCondition='RUNNUM=:runnum AND DATA_ID is NULL'
2297 # updateData=coral.AttributeList()
2298 # updateData.extend('data_id','unsigned long long')
2299 # updateData.extend('runnum','unsigned int')
2300 # updateData['data_id'].setData(data_id)
2301 # updateData['runnum'].setData(int(runnumber))
2302 # db=dbUtil.dbUtil(schema)
2303 # db.singleUpdate(nameDealer.lumisummaryTableName(),setClause,updateCondition,updateData)
2304 # #updates in lumidetail table
2305 # updateAction='DATA_ID=:data_id,RUNNUM=:runnum,CMSLSNUM=:cmslsnum,LUMILSNUM=:lumilsnum'
2306 # updateCondition='LUMISUMMARY_ID=:lumisummary_id'
2307 # bindvarDef=[]
2308 # bindvarDef.append(('data_id','unsigned long long'))
2309 # bindvarDef.append(('runnum','unsigned int'))
2310 # bindvarDef.append(('cmslsnum','unsigned int'))
2311 # bindvarDef.append(('lumilsnum','unsigned int'))
2312 # inputData=[]
2313 # for [lumisummary_id,lumilsnum,cmslsnum] in lsdata:
2314 # inputData.append([('data_id',data_id),('runnum',int(runnumber)),('cmslsnum',cmslsnum),('lumilsnum',lumilsnum)])
2315 # db.updateRows(nameDealer.lumidetailTableName(),updateAction,updateCondition,bindvarDef,inputData)
2316 # except:
2317 # raise
2318 
2319 #=======================================================
2320 # DELETE
2321 #=======================================================
2322 
2323 
2324 #=======================================================
2325 # Unit Test
2326 #=======================================================
Definition: start.py:1
def bulkInsertLumiLSSummary(session, runnumber, data_id, lumilsdata, tableName, bulksize=500, withDetails=True)
Definition: dataDML.py:2204
def dataDML.bulkInsertTrgLSData (   session,
  runnumber,
  data_id,
  trglsdata,
  bulksize = 500 
)
insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks 
input:
    trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
result nrows inserted
if nrows==0, then this insertion failed

Definition at line 2127 of file dataDML.py.

References nameDealer.lstrgTableName().

2127 def bulkInsertTrgLSData(session,runnumber,data_id,trglsdata,bulksize=500):
2128  '''
2129  insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks
2130  input:
2131  trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
2132  result nrows inserted
2133  if nrows==0, then this insertion failed
2134  '''
2135  print 'total number of trg rows ',len(trglsdata)
2136  lstrgDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('DEADTIMECOUNT','unsigned long long'),('BITZEROCOUNT','unsigned int'),('BITZEROPRESCALE','unsigned int'),('PRESCALEBLOB','blob'),('TRGCOUNTBLOB','blob')]
2137  committedrows=0
2138  nrows=0
2139  bulkvalues=[]
2140  try:
2141  for cmslsnum,perlstrg in trglsdata.items():
2142  deadtimecount=perlstrg[0]
2143  bitzerocount=perlstrg[1]
2144  bitzeroprescale=perlstrg[2]
2145  trgcountblob=perlstrg[3]
2146  trgprescaleblob=perlstrg[4]
2147  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)])
2148  nrows+=1
2149  committedrows+=1
2150  if nrows==bulksize:
2151  print 'committing trg in LS chunck ',nrows
2152  db=dbUtil.dbUtil(session.nominalSchema())
2153  session.transaction().start(False)
2154  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
2155  session.transaction().commit()
2156  nrows=0
2157  bulkvalues=[]
2158  elif committedrows==len(trglsdata):
2159  print 'committing trg at the end '
2160  db=dbUtil.dbUtil(session.nominalSchema())
2161  session.transaction().start(False)
2162  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
2163  session.transaction().commit()
2164  except :
2165  print 'error in bulkInsertTrgLSData'
2166  raise
Definition: start.py:1
def bulkInsertTrgLSData(session, runnumber, data_id, trglsdata, bulksize=500)
Definition: dataDML.py:2127
def lstrgTableName()
Definition: nameDealer.py:49
def dataDML.dataentryIdByRun (   schema,
  runnum,
  branchfilter 
)
select el.entry_id,et.entry_id,eh.entry_id,el.revision_id,et.revision_id,eh.revision_id from lumidataentiries el,trgdataentries et,hltdataentries eh where el.name=et.name and et.name=eh.name and el.name=:entryname;
check on entryrev
   
return [lumientryid,trgentryid,hltentryid]

Definition at line 1806 of file dataDML.py.

References data, nameDealer.entryTableName(), nameDealer.hltdataTableName(), nameDealer.lumidataTableName(), GetRecoTauVFromDQM_MC_cff.next, harvestTrackValidationPlots.str, and nameDealer.trgdataTableName().

1806 def dataentryIdByRun(schema,runnum,branchfilter):
1807  '''
1808  select el.entry_id,et.entry_id,eh.entry_id,el.revision_id,et.revision_id,eh.revision_id from lumidataentiries el,trgdataentries et,hltdataentries eh where el.name=et.name and et.name=eh.name and el.name=:entryname;
1809  check on entryrev
1810 
1811  return [lumientryid,trgentryid,hltentryid]
1812  '''
1813  result=[]
1814  qHandle=schema.newQuery()
1815  try:
1816  qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() ))
1817  qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() ))
1818  qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() ))
1819  qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid')
1820  qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid')
1821  qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid')
1822  qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr'
1823  qCondition=coral.AttributeList()
1824  qCondition.extend('runnumstr','string')
1825  qCondition['runnumstr'].setData(str(runnum))
1826  qResult=coral.AttributeList()
1827  qResult.extend('lumientryid','unsigned long long')
1828  qResult.extend('trgentryid','unsigned long long')
1829  qResult.extend('hltentryid','unsigned long long')
1830  qHandle.defineOutput(qResult)
1831  qHandle.setCondition(qConditionStr,qCondition)
1832  cursor=qHandle.execute()
1833  while next(cursor):
1834  lumientryid=cursor.currentRow()['lumientryid'].data()
1835  trgentryid=cursor.currentRow()['trgentryid'].data()
1836  hltentryid=cursor.currentRow()['hltentryid'].data()
1837  if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter:
1838  result.extend([lumientryid,trgentryid,hltentryid])
1839  except:
1840  del qHandle
1841  raise
1842  del qHandle
1843  return result
1844 
def entryTableName(dataTableName)
Definition: nameDealer.py:103
def trgdataTableName()
Definition: nameDealer.py:46
def dataentryIdByRun(schema, runnum, branchfilter)
Definition: dataDML.py:1806
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def hltdataTableName()
Definition: nameDealer.py:58
def lumidataTableName()
Definition: nameDealer.py:19
def dataDML.fillInRange (   schema,
  fillmin,
  fillmax,
  amodetag,
  startT,
  stopT 
)
select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag]
output: [fill]

Definition at line 89 of file dataDML.py.

References mps_setup.append, nameDealer.cmsrunsummaryTableName(), data, createfilelist.int, join(), and GetRecoTauVFromDQM_MC_cff.next.

Referenced by MuonPFAnalyzer.analyze(), and lumiCalcAPI.fillInRange().

89 def fillInRange(schema,fillmin,fillmax,amodetag,startT,stopT):
90  '''
91  select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag]
92  output: [fill]
93  '''
94  result=[]
95  tmpresult={}
96  qHandle=schema.newQuery()
98  lute=lumiTime.lumiTime()
99  try:
100  qHandle.addToTableList(r)
101  qConditionPieces=[]
102  qConditionStr=''
103  qCondition=coral.AttributeList()
104  if fillmin:
105  qConditionPieces.append('FILLNUM>=:fillmin')
106  qCondition.extend('fillmin','unsigned int')
107  qCondition['fillmin'].setData(int(fillmin))
108  if fillmax:
109  qConditionPieces.append('FILLNUM<=:fillmax')
110  qCondition.extend('fillmax','unsigned int')
111  qCondition['fillmax'].setData(int(fillmax))
112  if amodetag:
113  qConditionPieces.append('AMODETAG=:amodetag')
114  qCondition.extend('amodetag','string')
115  qCondition['amodetag'].setData(amodetag)
116  if len(qConditionPieces)!=0:
117  qConditionStr=(' AND ').join(qConditionPieces)
118  qResult=coral.AttributeList()
119  qResult.extend('fillnum','unsigned int')
120  qResult.extend('runnum','unsigned int')
121  qResult.extend('starttime','string')
122  qHandle.defineOutput(qResult)
123  if len(qConditionStr)!=0:
124  qHandle.setCondition(qConditionStr,qCondition)
125  qHandle.addToOutputList('FILLNUM','fillnum')
126  qHandle.addToOutputList('RUNNUM','runnum')
127  qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime')
128  cursor=qHandle.execute()
129  while next(cursor):
130  currentfill=cursor.currentRow()['fillnum'].data()
131  runnum=cursor.currentRow()['runnum'].data()
132  starttimeStr=cursor.currentRow()['starttime'].data()
133  runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
134  minTime=None
135  maxTime=None
136  if startT and stopT:
137  minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
138  maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
139  if runTime>=minTime and runTime<=maxTime:
140  tmpresult.setdefault(currentfill,[]).append(runnum)
141  elif startT is not None:
142  minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
143  if runTime>=minTime:
144  tmpresult.setdefault(currentfill,[]).append(runnum)
145  elif stopT is not None:
146  maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
147  if runTime<=maxTime:
148  tmpresult.setdefault(currentfill,[]).append(runnum)
149  else:
150  tmpresult.setdefault(currentfill,[]).append(runnum)
151  #print tmpresult
152  for f in sorted(tmpresult):
153  if tmpresult[f]:
154  result.append(f)
155  except :
156  del qHandle
157  raise
158  del qHandle
159  return result
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def fillInRange(schema, fillmin, fillmax, amodetag, startT, stopT)
Definition: dataDML.py:89
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def dataDML.fillrunMap (   schema,
  fillnum = None,
  runmin = None,
  runmax = None,
  startT = None,
  stopT = None,
  l1keyPattern = None,
  hltkeyPattern = None,
  amodetag = None 
)
select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ]
output: {fill:[runnum,...]}

Definition at line 160 of file dataDML.py.

References mps_setup.append, nameDealer.cmsrunsummaryTableName(), data, createfilelist.int, join(), and GetRecoTauVFromDQM_MC_cff.next.

Referenced by lumiCalcAPI.fillrunMap().

160 def fillrunMap(schema,fillnum=None,runmin=None,runmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None):
161  '''
162  select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ]
163  output: {fill:[runnum,...]}
164  '''
165  result={}
166  timelesslist=[]
167  qHandle=schema.newQuery()
169  lute=lumiTime.lumiTime()
170  try:
171  qHandle.addToTableList(r)
172  qConditionPieces=[]
173  qConditionStr=''
174  qCondition=coral.AttributeList()
175  if fillnum:
176  qConditionPieces.append('FILLNUM=:fillnum')
177  qCondition.extend('fillnum','unsigned int')
178  qCondition['fillnum'].setData(int(fillnum))
179  if runmin:
180  qConditionPieces.append('RUNNUM>=:runmin')
181  qCondition.extend('runmin','unsigned int')
182  qCondition['runmin'].setData(runmin)
183  if runmax:
184  qConditionPieces.append('RUNNUM<=:runmax')
185  qCondition.extend('runmax','unsigned int')
186  qCondition['runmax'].setData(runmax)
187  if amodetag:
188  qConditionPieces.append('AMODETAG=:amodetag')
189  qCondition.extend('amodetag','string')
190  qCondition['amodetag'].setData(amodetag)
191  if l1keyPattern:
192  qConditionPieces.append('regexp_like(L1KEY,:l1keypattern)')
193  qCondition.extend('l1keypattern','string')
194  qCondition['l1keypattern'].setData(l1keyPattern)
195  if hltkeyPattern:
196  qConditionPieces.append('regexp_like(HLTKEY,:hltkeypattern)')
197  qCondition.extend('hltkeypattern','string')
198  qCondition['hltkeypattern'].setData(hltkeyPattern)
199  if len(qConditionPieces)!=0:
200  qConditionStr=(' AND ').join(qConditionPieces)
201  qResult=coral.AttributeList()
202  qResult.extend('fillnum','unsigned int')
203  qResult.extend('runnum','unsigned int')
204  qResult.extend('starttime','string')
205  qHandle.defineOutput(qResult)
206  if len(qConditionStr) !=0:
207  qHandle.setCondition(qConditionStr,qCondition)
208  qHandle.addToOutputList('FILLNUM','fillnum')
209  qHandle.addToOutputList('RUNNUM','runnum')
210  qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime')
211  cursor=qHandle.execute()
212  while next(cursor):
213  currentfill=cursor.currentRow()['fillnum'].data()
214  starttimeStr=cursor.currentRow()['starttime'].data()
215  runnum=cursor.currentRow()['runnum'].data()
216  runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
217  minTime=None
218  maxTime=None
219  if startT and stopT:
220  minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
221  maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
222  if runTime>=minTime and runTime<=maxTime:
223  result.setdefault(currentfill,[]).append(runnum)
224  elif startT is not None:
225  minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
226  if runTime>=minTime:
227  result.setdefault(currentfill,[]).append(runnum)
228  elif stopT is not None:
229  maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
230  if runTime<=maxTime:
231  result.setdefault(currentfill,[]).append(runnum)
232  else:
233  result.setdefault(currentfill,[]).append(runnum)
234  except :
235  del qHandle
236  raise
237  del qHandle
238  return result
239 
def fillrunMap(schema, fillnum=None, runmin=None, runmax=None, startT=None, stopT=None, l1keyPattern=None, hltkeyPattern=None, amodetag=None)
Definition: dataDML.py:160
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def dataDML.fillschemePatternMap (   schema,
  lumitype 
)
output:(patternStr:correctionFac)

Definition at line 1572 of file dataDML.py.

References data, nameDealer.fillschemeTableName(), and GetRecoTauVFromDQM_MC_cff.next.

Referenced by lumiCalcAPI.deliveredLumiForIds().

1572 def fillschemePatternMap(schema,lumitype):
1573  '''
1574  output:(patternStr:correctionFac)
1575  '''
1576  if lumitype not in ['PIXEL','HF']:
1577  raise ValueError('[ERROR] unsupported lumitype '+lumitype)
1578  correctorField='CORRECTIONFACTOR'
1579  if lumitype=='PIXEL':
1580  correctorField='PIXELCORRECTIONFACTOR'
1581  result={}
1582  qHandle=schema.newQuery()
1583  try:
1584  qHandle.addToTableList(nameDealer.fillschemeTableName())
1585  qResult=coral.AttributeList()
1586  qResult.extend('FILLSCHEMEPATTERN','string')
1587  qResult.extend('CORRECTIONFACTOR','float')
1588  qHandle.defineOutput(qResult)
1589  qHandle.addToOutputList('FILLSCHEMEPATTERN')
1590  qHandle.addToOutputList(correctorField)
1591  cursor=qHandle.execute()
1592  while next(cursor):
1593  fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
1594  afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
1595  result[fillschemePattern]=afterglowfac
1596  except :
1597  del qHandle
1598  raise
1599  del qHandle
1600  return result
1601 
def fillschemeTableName()
Definition: nameDealer.py:13
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def fillschemePatternMap(schema, lumitype)
Definition: dataDML.py:1572
def dataDML.guesscorrIdByName (   schema,
  tagname = None 
)

LumiDB DML API # # Author: Zhen Xie #.

select data_id from lumicorrectionss [where entry_name=:tagname]
result lumicorrectionsdataid

Definition at line 16 of file dataDML.py.

References data, SiStripPI.max, and GetRecoTauVFromDQM_MC_cff.next.

16 def guesscorrIdByName(schema,tagname=None):
17  '''
18  select data_id from lumicorrectionss [where entry_name=:tagname]
19  result lumicorrectionsdataid
20 
21  '''
22  lumicorrectionids=[]
23  result=None
24  qHandle=schema.newQuery()
25  try:
26  qHandle.addToTableList( nameDealer.lumicorrectionsTableName() )
27  qHandle.addToOutputList('DATA_ID')
28  if tagname:
29  qConditionStr='ENTRY_NAME=:tagname '
30  qCondition=coral.AttributeList()
31  qCondition.extend('tagname','string')
32  qCondition['tagname'].setData(tagname)
33  qResult=coral.AttributeList()
34  qResult.extend('DATA_ID','unsigned long long')
35  qHandle.defineOutput(qResult)
36  if tagname:
37  qHandle.setCondition(qConditionStr,qCondition)
38  cursor=qHandle.execute()
39  while next(cursor):
40  dataid=cursor.currentRow()['DATA_ID'].data()
41  lumicorrectionids.append(dataid)
42  except :
43  del qHandle
44  raise
45  del qHandle
46  if len(lumicorrectionids) !=0:return max(lumicorrectionids)
47  return result
48 
def guesscorrIdByName(schema, tagname=None)
LumiDB DML API # # Author: Zhen Xie #.
Definition: dataDML.py:16
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.guessDataIdByRun (   schema,
  runnum,
  tablename,
  revfilter = None 
)
select max data_id of the given run. In current design, it's the most recent data of the run

Definition at line 1620 of file dataDML.py.

References data, SiStripPI.max, and GetRecoTauVFromDQM_MC_cff.next.

Referenced by guessDataIdForRange().

1620 def guessDataIdByRun(schema,runnum,tablename,revfilter=None):
1621  '''
1622  select max data_id of the given run. In current design, it's the most recent data of the run
1623  '''
1624  result=None
1625  ids=[]
1626  qHandle=schema.newQuery()
1627  try:
1628  qHandle.addToTableList(tablename)
1629  qHandle.addToOutputList('DATA_ID')
1630  qConditionStr='RUNNUM=:runnum '
1631  qCondition=coral.AttributeList()
1632  qCondition.extend('runnum','unsigned int')
1633  qCondition['runnum'].setData(runnum)
1634  qResult=coral.AttributeList()
1635  qResult.extend('DATA_ID','unsigned long long')
1636  qHandle.defineOutput(qResult)
1637  qHandle.setCondition(qConditionStr,qCondition)
1638  cursor=qHandle.execute()
1639  while next(cursor):
1640  dataid=cursor.currentRow()['DATA_ID'].data()
1641  ids.append(dataid)
1642  except :
1643  del qHandle
1644  raise
1645  del qHandle
1646  if len(ids)>0 :
1647  return max(ids)
1648  else:
1649  return result
1650 
def guessDataIdByRun(schema, runnum, tablename, revfilter=None)
Definition: dataDML.py:1620
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.guessDataIdForRange (   schema,
  inputRange,
  tablename 
)
input: inputRange [run]
output: {run:lumiid}
select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin 

Definition at line 1651 of file dataDML.py.

References data, guessDataIdByRun(), SiStripPI.max, min(), and GetRecoTauVFromDQM_MC_cff.next.

1651 def guessDataIdForRange(schema,inputRange,tablename):
1652  '''
1653  input: inputRange [run]
1654  output: {run:lumiid}
1655  select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin
1656  '''
1657  result={}
1658  if not inputRange : return result
1659  if len(inputRange)==1:
1660  trgid=guessDataIdByRun(schema,inputRange[0],tablename)
1661  result[inputRange[0]]=trgid
1662  return result
1663  rmin=min(inputRange)
1664  rmax=max(inputRange)
1665  result=dict.fromkeys(inputRange,None)
1666  qHandle=schema.newQuery()
1667  try:
1668  qHandle.addToTableList(tablename)
1669  qHandle.addToOutputList('DATA_ID')
1670  qHandle.addToOutputList('RUNNUM')
1671  qConditionStr='RUNNUM>=:rmin'
1672  qCondition=coral.AttributeList()
1673  qCondition.extend('rmin','unsigned int')
1674  qCondition['rmin'].setData(rmin)
1675  if rmin!=rmax:
1676  qConditionStr+=' AND RUNNUM<=:rmax'
1677  qCondition.extend('rmax','unsigned int')
1678  qCondition['rmax'].setData(rmax)
1679  qResult=coral.AttributeList()
1680  qResult.extend('DATA_ID','unsigned long long')
1681  qResult.extend('RUNNUM','unsigned int')
1682  qHandle.defineOutput(qResult)
1683  qHandle.setCondition(qConditionStr,qCondition)
1684  cursor=qHandle.execute()
1685  while next(cursor):
1686  dataid=cursor.currentRow()['DATA_ID'].data()
1687  runnum=cursor.currentRow()['RUNNUM'].data()
1688  if runnum in result:
1689  if dataid>result[runnum]:
1690  result[runnum]=dataid
1691  except :
1692  del qHandle
1693  raise
1694  del qHandle
1695  return result
1696 #def guessAllDataIdByRun(schema,runnum):
1697 # '''
1698 # get dataids by runnumber, if there are duplicates, pick max(dataid).Bypass full version lookups
1699 # result (lumidataid(0),trgdataid(1),hltdataid(2))
1700 # '''
1701 # lumiids=[]
1702 # trgids=[]
1703 # hltids=[]
1704 # qHandle=schema.newQuery()
1705 # try:
1706 # qHandle.addToTableList(nameDealer.lumidataTableName(),'l')
1707 # qHandle.addToTableList(nameDealer.trgdataTableName(),'t')
1708 # qHandle.addToTableList(nameDealer.hltdataTableName(),'h')
1709 # qHandle.addToOutputList('l.DATA_ID','lumidataid')
1710 # qHandle.addToOutputList('t.DATA_ID','trgdataid')
1711 # qHandle.addToOutputList('h.DATA_ID','hltdataid')
1712 # qConditionStr='l.RUNNUM=t.RUNNUM and t.RUNNUM=h.RUNNUM and l.RUNNUM=:runnum '
1713 # qCondition=coral.AttributeList()
1714 # qCondition.extend('runnum','unsigned int')
1715 # qCondition['runnum'].setData(runnum)
1716 # qResult=coral.AttributeList()
1717 # qResult.extend('lumidataid','unsigned long long')
1718 # qResult.extend('trgdataid','unsigned long long')
1719 # qResult.extend('hltdataid','unsigned long long')
1720 # qHandle.defineOutput(qResult)
1721 # qHandle.setCondition(qConditionStr,qCondition)
1722 # cursor=qHandle.execute()
1723 # while cursor.next():
1724 # lumidataid=cursor.currentRow()['lumidataid'].data()
1725 # trgdataid=cursor.currentRow()['trgdataid'].data()
1726 # hltdataid=cursor.currentRow()['hltdataid'].data()
1727 # lumiids.append(lumidataid)
1728 # trgids.append(trgdataid)
1729 # hltids.append(hltdataid)
1730 # except :
1731 # del qHandle
1732 # raise
1733 # del qHandle
1734 # if len(lumiids)>0 and len(trgids)>0 and len(hltids)>0:
1735 # return (max(lumiids),max(trgids),max(hltids))
1736 # else:
1737 # return (None,None,None)
1738 
def guessDataIdForRange(schema, inputRange, tablename)
Definition: dataDML.py:1651
def guessDataIdByRun(schema, runnum, tablename, revfilter=None)
Definition: dataDML.py:1620
T min(T a, T b)
Definition: MathUtil.h:58
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.guessHltDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1614 of file dataDML.py.

References revisionDML.entryInBranch(), revisionDML.latestDataRevisionOfEntry(), revisionDML.revisionsInBranchName(), and harvestTrackValidationPlots.str.

1614 def guessHltDataIdByRunInBranch(schema,runnum,tablename,branchName):
1615  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1616  hltentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1617  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,hltentry_id,revlist)
1618  return latestrevision
1619 
def revisionsInBranchName(schema, branchname)
Definition: revisionDML.py:177
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def guessHltDataIdByRunInBranch(schema, runnum, tablename, branchName)
Definition: dataDML.py:1614
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)
Definition: revisionDML.py:274
def dataDML.guessLumiDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1602 of file dataDML.py.

References revisionDML.entryInBranch(), revisionDML.latestDataRevisionOfEntry(), revisionDML.revisionsInBranchName(), and harvestTrackValidationPlots.str.

1602 def guessLumiDataIdByRunInBranch(schema,runnum,tablename,branchName):
1603  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1604  lumientry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1605  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,lumientry_id,revlist)
1606  return latestrevision
1607 
def revisionsInBranchName(schema, branchname)
Definition: revisionDML.py:177
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def guessLumiDataIdByRunInBranch(schema, runnum, tablename, branchName)
Definition: dataDML.py:1602
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)
Definition: revisionDML.py:274
def dataDML.guessnormIdByContext (   schema,
  amodetag,
  egev1 
)
get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1   

Definition at line 1739 of file dataDML.py.

References data, createfilelist.int, nameDealer.luminormTableName(), SiStripPI.max, and GetRecoTauVFromDQM_MC_cff.next.

1739 def guessnormIdByContext(schema,amodetag,egev1):
1740  '''
1741  get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
1742  select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1
1743  '''
1744  luminormids=[]
1745  qHandle=schema.newQuery()
1746  egevmin=egev1*0.95
1747  egevmax=egev1*1.05
1748  try:
1749  qHandle.addToTableList( nameDealer.luminormTableName() )
1750  qHandle.addToOutputList('DATA_ID','normdataid')
1751  qConditionStr='AMODETAG=:amodetag AND EGEV_1>=:egevmin AND EGEV_1<=:egevmax'
1752  qCondition=coral.AttributeList()
1753  qCondition.extend('amodetag','string')
1754  qCondition.extend('egevmin','unsigned int')
1755  qCondition.extend('egevmax','unsigned int')
1756  qCondition['amodetag'].setData(amodetag)
1757  qCondition['egevmin'].setData(int(egevmin))
1758  qCondition['egevmax'].setData(int(egevmax))
1759  qResult=coral.AttributeList()
1760  qResult.extend('normdataid','unsigned long long')
1761  qHandle.defineOutput(qResult)
1762  qHandle.setCondition(qConditionStr,qCondition)
1763  cursor=qHandle.execute()
1764  while next(cursor):
1765  normdataid=cursor.currentRow()['normdataid'].data()
1766  luminormids.append(normdataid)
1767  except :
1768  del qHandle
1769  raise
1770  del qHandle
1771  if len(luminormids) !=0:return max(luminormids)
1772  return None
1773 
def guessnormIdByContext(schema, amodetag, egev1)
Definition: dataDML.py:1739
def luminormTableName()
Definition: nameDealer.py:37
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.guessnormIdByName (   schema,
  normname 
)
get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
select data_id from luminorms where entry_name=:normname
result luminormdataid

Definition at line 1774 of file dataDML.py.

References data, nameDealer.luminormTableName(), SiStripPI.max, and GetRecoTauVFromDQM_MC_cff.next.

1774 def guessnormIdByName(schema,normname):
1775  '''
1776  get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
1777  select data_id from luminorms where entry_name=:normname
1778  result luminormdataid
1779  '''
1780  luminormids=[]
1781  qHandle=schema.newQuery()
1782  try:
1783  qHandle.addToTableList( nameDealer.luminormTableName() )
1784  qHandle.addToOutputList('DATA_ID','normdataid')
1785  qConditionStr='ENTRY_NAME=:normname '
1786  qCondition=coral.AttributeList()
1787  qCondition.extend('normname','string')
1788  qCondition['normname'].setData(normname)
1789  qResult=coral.AttributeList()
1790  qResult.extend('normdataid','unsigned long long')
1791  qHandle.defineOutput(qResult)
1792  qHandle.setCondition(qConditionStr,qCondition)
1793  cursor=qHandle.execute()
1794  while next(cursor):
1795  normdataid=cursor.currentRow()['normdataid'].data()
1796  luminormids.append(normdataid)
1797  except :
1798  del qHandle
1799  raise
1800  del qHandle
1801  if len(luminormids) !=0:return max(luminormids)
1802  return None
1803 
def luminormTableName()
Definition: nameDealer.py:37
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def guessnormIdByName(schema, normname)
Definition: dataDML.py:1774
def dataDML.guessTrgDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1608 of file dataDML.py.

References revisionDML.entryInBranch(), revisionDML.latestDataRevisionOfEntry(), revisionDML.revisionsInBranchName(), and harvestTrackValidationPlots.str.

1608 def guessTrgDataIdByRunInBranch(schema,runnum,tablename,branchName):
1609  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1610  trgentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1611  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,trgentry_id,revlist)
1612  return latestrevision
1613 
def revisionsInBranchName(schema, branchname)
Definition: revisionDML.py:177
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:188
def guessTrgDataIdByRunInBranch(schema, runnum, tablename, branchName)
Definition: dataDML.py:1608
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)
Definition: revisionDML.py:274
def dataDML.hltLSById (   schema,
  dataid,
  hltpathname = None,
  hltpathpattern = None,
  withL1Pass = False,
  withHLTAccept = False 
)
result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 

Definition at line 1437 of file dataDML.py.

References data, hltRunById(), nameDealer.lshltTableName(), GetRecoTauVFromDQM_MC_cff.next, and CommonUtil.unpackBlobtoArray().

Referenced by lumiCalcAPI.hltForIds().

1437 def hltLSById(schema,dataid,hltpathname=None,hltpathpattern=None,withL1Pass=False,withHLTAccept=False):
1438  '''
1439  result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]}
1440  '''
1441  #print 'entering hltLSById '
1442  #t0=time.time()
1443  result={}
1444  hltrundata=hltRunById(schema,dataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
1445  if not hltrundata:
1446  return result
1447  hltnamedict=hltrundata[3]
1448  if not hltnamedict:
1449  return (hltrundata[0],{})
1450  #tt1=time.time()
1451  #print '\thltrunbyid time ',tt1-t0
1452  #tt0=time.time()
1453  qHandle=schema.newQuery()
1454  try:
1455  qHandle.addToTableList(nameDealer.lshltTableName())
1456  qHandle.addToOutputList('RUNNUM','runnum')
1457  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
1458  if len(hltnamedict)!=0:
1459  qHandle.addToOutputList('PRESCALEBLOB','prescaleblob')
1460  if withL1Pass:
1461  qHandle.addToOutputList('HLTCOUNTBLOB','hltcountblob')
1462  if withHLTAccept:
1463  qHandle.addToOutputList('HLTACCEPTBLOB','hltacceptblob')
1464  qConditionStr='DATA_ID=:dataid'
1465  qCondition=coral.AttributeList()
1466  qCondition.extend('dataid','unsigned long long')
1467  qCondition['dataid'].setData(dataid)
1468  qResult=coral.AttributeList()
1469  qResult.extend('runnum','unsigned int')
1470  qResult.extend('cmslsnum','unsigned int')
1471  if len(hltnamedict)!=0:
1472  qResult.extend('prescaleblob','blob')
1473  if withL1Pass:
1474  qResult.extend('hltcountblob','blob')
1475  if withHLTAccept:
1476  qResult.extend('hltacceptblob','blob')
1477  qHandle.defineOutput(qResult)
1478  qHandle.setCondition(qConditionStr,qCondition)
1479  cursor=qHandle.execute()
1480  while next(cursor):
1481  runnum=cursor.currentRow()['runnum'].data()
1482  cmslsnum=cursor.currentRow()['cmslsnum'].data()
1483  prescaleblob=None
1484  hltcountblob=None
1485  hltacceptblob=None
1486  if len(hltnamedict)!=0:
1487  prescaleblob=cursor.currentRow()['prescaleblob'].data()
1488  if withL1Pass:
1489  hltcountblob=cursor.currentRow()['hltcountblob'].data()
1490  if withHLTAccept:
1491  hltacceptblob=cursor.currentRow()['hltacceptblob'].data()
1492  if cmslsnum not in result:
1493  result[cmslsnum]=[]
1494  pathinfo=[]
1495  prescales=None
1496  hltcounts=None
1497  hltaccepts=None
1498  if prescaleblob:
1499  if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
1500  prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'l')
1501  else:
1502  prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'I')
1503  if hltcountblob:
1504  if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
1505  hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'l')
1506  else:
1507  hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'I')
1508  if hltacceptblob:
1509  if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
1510  hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'l')
1511  else:
1512  hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'I')
1513  for (hltpathidx,thispathname) in hltnamedict:#loop over selected paths
1514  thispresc=0
1515  thishltcount=0
1516  thisaccept=0
1517  if prescales:
1518  thispresc=prescales[hltpathidx]
1519  if hltcounts:
1520  thishltcount=hltcounts[hltpathidx]
1521  if hltaccepts:
1522  thisaccept=hltaccepts[hltpathidx]
1523  thispathinfo=(thispathname,thispresc,thishltcount,thisaccept)
1524  pathinfo.append(thispathinfo)
1525  result[cmslsnum]=pathinfo
1526  except :
1527  del qHandle
1528  raise
1529  del qHandle
1530  #tt1=time.time()
1531  #print '\tdb stuff time ',tt1-tt0
1532  #t1=time.time()
1533  #print 'tot hltLSById time ',t1-t0
1534  return (runnum,result)
1535 
def unpackBlobtoArray(iblob, itemtypecode)
Definition: CommonUtil.py:229
def hltRunById(schema, dataid, hltpathname=None, hltpathpattern=None)
Definition: dataDML.py:1333
def lshltTableName()
Definition: nameDealer.py:61
def hltLSById(schema, dataid, hltpathname=None, hltpathpattern=None, withL1Pass=False, withHLTAccept=False)
Definition: dataDML.py:1437
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.hltRunById (   schema,
  dataid,
  hltpathname = None,
  hltpathpattern = None 
)
result [runnum(0),datasource(1),npath(2),hltnamedict(3)]
output :
     npath : total number of hltpath in DB
     hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)]

Definition at line 1333 of file dataDML.py.

References data, nameDealer.hltdataTableName(), and GetRecoTauVFromDQM_MC_cff.next.

Referenced by hltLSById().

1333 def hltRunById(schema,dataid,hltpathname=None,hltpathpattern=None):
1334  '''
1335  result [runnum(0),datasource(1),npath(2),hltnamedict(3)]
1336  output :
1337  npath : total number of hltpath in DB
1338  hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)]
1339  '''
1340  result=[]
1341  qHandle=schema.newQuery()
1342  runnum=None
1343  datasource=None
1344  npath=None
1345  hltnamedict=[]
1346  try:
1347  qHandle.addToTableList(nameDealer.hltdataTableName())
1348  qHandle.addToOutputList('RUNNUM','runnum')
1349  qHandle.addToOutputList('SOURCE','datasource')
1350  qHandle.addToOutputList('NPATH','npath')
1351  qHandle.addToOutputList('PATHNAMECLOB','pathnameclob')
1352  qConditionStr='DATA_ID=:dataid'
1353  qCondition=coral.AttributeList()
1354  qCondition.extend('dataid','unsigned long long')
1355  qCondition['dataid'].setData(dataid)
1356  qResult=coral.AttributeList()
1357  qResult.extend('runnum','unsigned int')
1358  qResult.extend('datasource','string')
1359  qResult.extend('npath','unsigned int')
1360  qResult.extend('pathnameclob','string')
1361  qHandle.defineOutput(qResult)
1362  qHandle.setCondition(qConditionStr,qCondition)
1363  cursor=qHandle.execute()
1364  pathnameclob=None
1365  pathnames=[]
1366  while next(cursor):
1367  runnum=cursor.currentRow()['runnum'].data()
1368  datasource=cursor.currentRow()['datasource'].data()
1369  npath=cursor.currentRow()['npath'].data()
1370  pathnameclob=cursor.currentRow()['pathnameclob'].data()
1371  if pathnameclob:
1372  pathnames=pathnameclob.split(',')
1373  for pathnameidx,hltname in enumerate(pathnames):
1374  if hltpathname:
1375  if hltpathname==hltname:
1376  hltnamedict.append((pathnameidx,hltname))
1377  break
1378  elif hltpathpattern:
1379  if fnmatch.fnmatch(hltname,hltpathpattern):
1380  hltnamedict.append((pathnameidx,hltname))
1381  #else:
1382  #hltnamedict.append((pathnameidx,hltname))
1383  result=[runnum,datasource,npath,hltnamedict]
1384  except :
1385  del qHandle
1386  raise
1387  del qHandle
1388  return result
1389 
def hltRunById(schema, dataid, hltpathname=None, hltpathpattern=None)
Definition: dataDML.py:1333
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def hltdataTableName()
Definition: nameDealer.py:58
def dataDML.hlttrgMappingByrun (   schema,
  runnum,
  hltpathname = None,
  hltpathpattern = None 
)
select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname] 
output: {hltpath:l1seed}

Definition at line 1390 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName(), data, createfilelist.int, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.trghltMapTableName().

Referenced by lumiCalcAPI.effectiveLumiForIds(), and lumiCalcAPI.hltpathsForRange().

1390 def hlttrgMappingByrun(schema,runnum,hltpathname=None,hltpathpattern=None):
1391  '''
1392  select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname]
1393  output: {hltpath:l1seed}
1394  '''
1395  result={}
1396  queryHandle=schema.newQuery()
1399  if hltpathpattern and hltpathpattern in ['*','all','All','ALL']:
1400  hltpathpattern=None
1401  try:
1402  queryHandle.addToTableList(r)
1403  queryHandle.addToTableList(m)
1404  queryCondition=coral.AttributeList()
1405  queryCondition.extend('runnum','unsigned int')
1406  queryCondition['runnum'].setData(int(runnum))
1407  #queryHandle.addToOutputList(m+'.HLTKEY','hltkey')
1408  queryHandle.addToOutputList(m+'.HLTPATHNAME','hltpathname')
1409  queryHandle.addToOutputList(m+'.L1SEED','l1seed')
1410  conditionStr=r+'.RUNNUM=:runnum and '+m+'.HLTKEY='+r+'.HLTKEY'
1411  if hltpathname:
1412  hltpathpattern=None
1413  conditionStr+=' AND '+m+'.HLTPATHNAME=:hltpathname'
1414  queryCondition.extend('hltpathname','string')
1415  queryCondition['hltpathname'].setData(hltpathname)
1416  queryHandle.setCondition(conditionStr,queryCondition)
1417  queryResult=coral.AttributeList()
1418  queryResult.extend('pname','string')
1419  queryResult.extend('l1seed','string')
1420  queryHandle.defineOutput(queryResult)
1421  cursor=queryHandle.execute()
1422  while next(cursor):
1423  pname=cursor.currentRow()['pname'].data()
1424  l1seed=cursor.currentRow()['l1seed'].data()
1425  if hltpathname not in result:
1426  if hltpathpattern:
1427  if fnmatch.fnmatch(pname,hltpathpattern):
1428  result[pname]=l1seed
1429  else:
1430  result[pname]=l1seed
1431  except :
1432  del queryHandle
1433  raise
1434  del queryHandle
1435  return result
1436 
def hlttrgMappingByrun(schema, runnum, hltpathname=None, hltpathpattern=None)
Definition: dataDML.py:1390
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def trghltMapTableName()
Definition: nameDealer.py:76
def dataDML.insertRunSummaryData (   schema,
  runnumber,
  runsummarydata,
  complementalOnly = False 
)
input:
    runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
output:

Definition at line 2055 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName(), and createfilelist.int.

2055 def insertRunSummaryData(schema,runnumber,runsummarydata,complementalOnly=False):
2056  '''
2057  input:
2058  runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
2059  output:
2060  '''
2061  l1key=runsummarydata[0]
2062  amodetag=runsummarydata[1]
2063  egev=runsummarydata[2]
2064  hltkey=''
2065  fillnum=0
2066  sequence=''
2067  starttime=''
2068  stoptime=''
2069  if not complementalOnly:
2070  sequence=runsummarydata[3]
2071  hltkey=runsummarydata[4]
2072  fillnum=runsummarydata[5]
2073  starttime=runsummarydata[6]
2074  stoptime=runsummarydata[7]
2075  try:
2076  if not complementalOnly:
2077  tabrowDefDict={'RUNNUM':'unsigned int','L1KEY':'string','AMODETAG':'string','EGEV':'unsigned int','SEQUENCE':'string','HLTKEY':'string','FILLNUM':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp'}
2078  tabrowValueDict={'RUNNUM':int(runnumber),'L1KEY':l1key,'AMODETAG':amodetag,'EGEV':int(egev),'SEQUENCE':sequence,'HLTKEY':hltkey,'FILLNUM':int(fillnum),'STARTTIME':starttime,'STOPTIME':stoptime}
2079  db=dbUtil.dbUtil(schema)
2080  db.insertOneRow(nameDealer.cmsrunsummaryTableName(),tabrowDefDict,tabrowValueDict)
2081  else:
2082  setClause='L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev'
2083  updateCondition='RUNNUM=:runnum'
2084  inputData=coral.AttributeList()
2085  inputData.extend('l1key','string')
2086  inputData.extend('amodetag','string')
2087  inputData.extend('egev','unsigned int')
2088  inputData.extend('runnum','unsigned int')
2089  inputData['l1key'].setData(l1key)
2090  inputData['amodetag'].setData(amodetag)
2091  inputData['egev'].setData(int(egev))
2092  inputData['runnum'].setData(int(runnumber))
2093  db=dbUtil.dbUtil(schema)
2094  db.singleUpdate(nameDealer.cmsrunsummaryTableName(),setClause,updateCondition,inputData)
2095  except :
2096  raise
def insertRunSummaryData(schema, runnumber, runsummarydata, complementalOnly=False)
Definition: dataDML.py:2055
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def dataDML.insertTrgHltMap (   schema,
  hltkey,
  trghltmap 
)
input:
    trghltmap {hltpath:l1seed}
output:

Definition at line 2097 of file dataDML.py.

References GetRecoTauVFromDQM_MC_cff.next, and nameDealer.trghltMapTableName().

2097 def insertTrgHltMap(schema,hltkey,trghltmap):
2098  '''
2099  input:
2100  trghltmap {hltpath:l1seed}
2101  output:
2102  '''
2103  hltkeyExists=False
2104  nrows=0
2105  try:
2106  kQueryBindList=coral.AttributeList()
2107  kQueryBindList.extend('hltkey','string')
2108  kQuery=schema.newQuery()
2109  kQuery.addToTableList(nameDealer.trghltMapTableName())
2110  kQuery.setCondition('HLTKEY=:hltkey',kQueryBindList)
2111  kQueryBindList['hltkey'].setData(hltkey)
2112  kResult=kQuery.execute()
2113  while next(kResult):
2114  hltkeyExists=True
2115  if not hltkeyExists:
2116  bulkvalues=[]
2117  trghltDefDict=[('HLTKEY','string'),('HLTPATHNAME','string'),('L1SEED','string')]
2118  for hltpath,l1seed in trghltmap.items():
2119  bulkvalues.append([('HLTKEY',hltkey),('HLTPATHNAME',hltpath),('L1SEED',l1seed)])
2120  db=dbUtil.dbUtil(schema)
2121  db.bulkInsert(nameDealer.trghltMapTableName(),trghltDefDict,bulkvalues)
2122  nrows=len(bulkvalues)
2123  return nrows
2124  except :
2125  print 'error in insertTrgHltMap '
2126  raise
def insertTrgHltMap(schema, hltkey, trghltmap)
Definition: dataDML.py:2097
def trghltMapTableName()
Definition: nameDealer.py:76
def dataDML.intglumiForRange (   schema,
  runlist 
)
output: {run:intglumi_in_fb}

Definition at line 1536 of file dataDML.py.

References data, nameDealer.intglumiv2TableName(), SiStripPI.max, min(), and GetRecoTauVFromDQM_MC_cff.next.

Referenced by lumiCalcAPI.deliveredLumiForIds().

1536 def intglumiForRange(schema,runlist):
1537  '''
1538  output: {run:intglumi_in_fb}
1539  '''
1540  result={}
1541  if not runlist:
1542  return result
1543  minrun=min(runlist)
1544  maxrun=max(runlist)
1545  qHandle=schema.newQuery()
1546  try:
1547  qHandle.addToTableList(nameDealer.intglumiv2TableName())
1548  qResult=coral.AttributeList()
1549  qResult.extend('RUNNUM','unsigned int')
1550  qResult.extend('INTGLUMI','float')
1551  qConditionStr='RUNNUM>=:minrun AND RUNNUM<=:maxrun'
1552  qCondition=coral.AttributeList()
1553  qCondition.extend('minrun','unsigned int')
1554  qCondition.extend('maxrun','unsigned int')
1555  qCondition['minrun'].setData(minrun)
1556  qCondition['maxrun'].setData(maxrun)
1557  qHandle.addToOutputList('RUNNUM')
1558  qHandle.addToOutputList('INTGLUMI')
1559  qHandle.setCondition(qConditionStr,qCondition)
1560  qHandle.defineOutput(qResult)
1561  cursor=qHandle.execute()
1562  while next(cursor):
1563  runnum=cursor.currentRow()['RUNNUM'].data()
1564  intglumi=cursor.currentRow()['INTGLUMI'].data()
1565  result[runnum]=intglumi
1566  except :
1567  del qHandle
1568  raise
1569  del qHandle
1570  return result
1571 
def intglumiForRange(schema, runlist)
Definition: dataDML.py:1536
T min(T a, T b)
Definition: MathUtil.h:58
def intglumiv2TableName()
Definition: nameDealer.py:91
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.latestdataIdByEntry (   schema,
  entryid,
  datatype,
  branchfilter 
)
select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where  l.data_id=rl.data_id and l.entry_id=:entryid
check revision_id is in branch

Definition at line 1845 of file dataDML.py.

References data, nameDealer.hltdataTableName(), nameDealer.lumidataTableName(), SiStripPI.max, GetRecoTauVFromDQM_MC_cff.next, nameDealer.revmapTableName(), and nameDealer.trgdataTableName().

1845 def latestdataIdByEntry(schema,entryid,datatype,branchfilter):
1846  '''
1847  select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid
1848  check revision_id is in branch
1849  '''
1850  dataids=[]
1851  datatablename=''
1852  revmaptablename=''
1853  if datatype=='lumi':
1854  datatablename=nameDealer.lumidataTableName()
1855  elif datatype=='trg':
1856  datatablename=nameDealer.trgdataTableName()
1857  elif dataytpe=='hlt':
1858  tablename=nameDealer.hltdataTableName()
1859  else:
1860  raise RunTimeError('datatype '+datatype+' is not supported')
1861  revmaptablename=nameDealer.revmapTableName(datatablename)
1862  qHandle=schema.newQuery()
1863  try:
1864  qHandle.addToTableList(revmaptablename)
1865  qHandle.addToTableList(datatablename)
1866  qHandle.addToOutputList('l.DATA_ID','dataid')
1867  qHandle.addToOutputList(revmaptablename+'.REVISION_ID','revisionid')
1868  qConditionStr=datatablename+'.DATA_ID='+revmaptablename+'.DATA_ID AND '+datatablename+'.ENTRY_ID=:entryid'
1869  qCondition=coral.AttributeList()
1870  qCondition.extend('entryid','unsigned long long')
1871  qResult=coral.AttributeList()
1872  qResult.extend('dataid','unsigned long long')
1873  qResult.extend('revisionid','unsigned long long')
1874  qHandle.defineOutput(qResult)
1875  qHandle.setCondition(qConditionStr,qCondition)
1876  cursor=qHandle.execute()
1877  while next(cursor):
1878  dataid=cursor.currentRow()['dataid'].data()
1879  revisionid=cursor.currentRow()['revisionid'].data()
1880  if revisionid in branchfilter:
1881  dataids.append(dataid)
1882  except:
1883  del qHandle
1884  raise
1885  del qHandle
1886  if len(dataids)!=0:return max(dataids)
1887  return None
1888 
1889 
1890 #=======================================================
1891 # INSERT requires in update transaction
1892 #=======================================================
def latestdataIdByEntry(schema, entryid, datatype, branchfilter)
Definition: dataDML.py:1845
def revmapTableName(dataTableName)
Definition: nameDealer.py:100
def trgdataTableName()
Definition: nameDealer.py:46
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def hltdataTableName()
Definition: nameDealer.py:58
def lumidataTableName()
Definition: nameDealer.py:19
def dataDML.lumiBXByAlgo (   schema,
  dataid,
  algoname 
)
result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}

Definition at line 1283 of file dataDML.py.

References data, nameDealer.lumisummaryv2TableName(), GetRecoTauVFromDQM_MC_cff.next, and harvestTrackValidationPlots.str.

1283 def lumiBXByAlgo(schema,dataid,algoname):
1284  '''
1285  result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
1286  '''
1287  result={}
1288  qHandle=schema.newQuery()
1289  try:
1290  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
1291  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
1292  qHandle.addToOutputList('LUMILSNUM','lumilsnum')
1293  #qHandle.addToOutputList('ALGONAME','algoname')
1294  qHandle.addToOutputList('NUMORBIT','numorbit')
1295  qHandle.addToOutputList('STARTORBIT','startorbit')
1296  qHandle.addToOutputList('BXLUMIVALUE_'+algoname,'bxlumivalue')
1297  qHandle.addToOutputList('BXLUMIERROR_'+algoname,'bxlumierr')
1298  qHandle.addToOutputList('BXLUMIQUALITY_'+algoname,'bxlumiqlty')
1299  qConditionStr='DATA_ID=:dataid'
1300  qCondition=coral.AttributeList()
1301  qCondition.extend('dataid','unsigned long long')
1302  qCondition['dataid'].setData(dataid)
1303  qResult=coral.AttributeList()
1304  qResult.extend('cmslsnum','unsigned int')
1305  qResult.extend('lumilsnum','unsigned int')
1306  qResult.extend('numorbit','unsigned int')
1307  qResult.extend('startorbit','unsigned int')
1308  qResult.extend('bxlumivalue','blob')
1309  qResult.extend('bxlumierr','blob')
1310  qResult.extend('bxlumiqlty','blob')
1311  qHandle.defineOutput(qResult)
1312  qHandle.setCondition(qConditionStr,qCondition)
1313  cursor=qHandle.execute()
1314  while next(cursor):
1315  cmslsnum=cursor.currentRow()['cmslsnum'].data()
1316  lumilsnum=cursor.currentRow()['lumilsnum'].data()
1317  numorbit=cursor.currentRow()['numorbit'].data()
1318  startorbit=cursor.currentRow()['startorbit'].data()
1319  bxlumivalue=cursor.currentRow()['bxlumivalue'].data()
1320  bxlumierr=cursor.currentRow()['bxlumierr'].data()
1321  bxlumiqlty=cursor.currentRow()['bxlumiqlty'].data()
1322  if algoname not in result:
1323  result[algoname]={}
1324  if lumilsnum not in result[algoname]:
1325  result[algoname][lumilsnum]=[]
1326  result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
1327  except :
1328  del qHandle
1329  raise RuntimeError(' dataDML.lumiBXById: '+str(e))
1330  del qHandle
1331  return result
1332 
def lumisummaryv2TableName()
Definition: nameDealer.py:28
def lumiBXByAlgo(schema, dataid, algoname)
Definition: dataDML.py:1283
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.lumicorrById (   schema,
  correctiondataid 
)
select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid
output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))}

Definition at line 49 of file dataDML.py.

References data, and GetRecoTauVFromDQM_MC_cff.next.

49 def lumicorrById(schema,correctiondataid):
50  '''
51  select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid
52  output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))}
53  '''
54  result=None
55  qHandle=schema.newQuery()
56  try:
57  qHandle.addToTableList(nameDealer.lumicorrectionsTableName())
58  qHandle.addToOutputList('ENTRY_NAME')
59  qHandle.addToOutputList('A1')
60  qHandle.addToOutputList('A2')
61  qHandle.addToOutputList('DRIFT')
62  qCondition=coral.AttributeList()
63  qCondition.extend('dataid','unsigned long long')
64  qCondition['dataid'].setData(correctiondataid)
65  qResult=coral.AttributeList()
66  qResult.extend('ENTRY_NAME','string')
67  qResult.extend('A1','float')
68  qResult.extend('A2','float')
69  qResult.extend('DRIFT','float')
70  qHandle.defineOutput(qResult)
71  qHandle.setCondition('DATA_ID=:dataid',qCondition)
72  cursor=qHandle.execute()
73  while next(cursor):
74  tagname=cursor.currentRow()['ENTRY_NAME'].data()
75  a1=cursor.currentRow()['A1'].data()
76  a2=0.0
77  if cursor.currentRow()['A2'].data():
78  a2=cursor.currentRow()['A2'].data()
79  drift=0.0
80  if cursor.currentRow()['DRIFT'].data():
81  drift=cursor.currentRow()['DRIFT'].data()
82  result={tagname:(correctiondataid,a1,a2,drift)}
83  except :
84  del qHandle
85  raise
86  del qHandle
87  return result
88 
def lumicorrById(schema, correctiondataid)
Definition: dataDML.py:49
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.lumiLSById (   schema,
  dataid,
  beamstatus = None,
  withBXInfo = False,
  bxAlgo = 'OCC1',
  withBeamIntensity = False,
  tableName = None 
)
input:
   beamstatus: filter on beam status flag
output:
result (runnum,{lumilsnum,[cmslsnum(0),instlumi(1),instlumierr(2),instlumiqlty(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),(bxvalueArray,bxerrArray)(8),(bxindexArray,beam1intensityArray,beam2intensityArray)(9)]})

Definition at line 1085 of file dataDML.py.

References data, createfilelist.int, nameDealer.lumisummaryv2TableName(), GetRecoTauVFromDQM_MC_cff.next, and CommonUtil.unpackBlobtoArray().

Referenced by lumiCalcAPI.instLumiForIds().

1085 def lumiLSById(schema,dataid,beamstatus=None,withBXInfo=False,bxAlgo='OCC1',withBeamIntensity=False,tableName=None):
1086  '''
1087  input:
1088  beamstatus: filter on beam status flag
1089  output:
1090  result (runnum,{lumilsnum,[cmslsnum(0),instlumi(1),instlumierr(2),instlumiqlty(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),(bxvalueArray,bxerrArray)(8),(bxindexArray,beam1intensityArray,beam2intensityArray)(9)]})
1091  '''
1092  runnum=0
1093  result={}
1094  qHandle=schema.newQuery()
1095  if withBXInfo and bxAlgo not in ['OCC1','OCC2','ET']:
1096  raise ValueError('unknown lumi algo '+bxAlgo)
1097  if beamstatus and beamstatus not in ['STABLE BEAMS',]:
1098  raise ValueError('unknown beam status '+beamstatus)
1099  try:
1100  if tableName is None:
1102  else:
1103  lls=tableName
1104  qHandle.addToTableList(lls)
1105  qHandle.addToOutputList('RUNNUM','runnum')
1106  qHandle.addToOutputList('LUMILSNUM','lumilsnum')
1107  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
1108  qHandle.addToOutputList('INSTLUMI','instlumi')
1109  qHandle.addToOutputList('INSTLUMIERROR','instlumierr')
1110  qHandle.addToOutputList('INSTLUMIQUALITY','instlumiqlty')
1111  qHandle.addToOutputList('BEAMSTATUS','beamstatus')
1112  qHandle.addToOutputList('BEAMENERGY','beamenergy')
1113  qHandle.addToOutputList('NUMORBIT','numorbit')
1114  qHandle.addToOutputList('STARTORBIT','startorbit')
1115  if withBXInfo:
1116  qHandle.addToOutputList('BXLUMIVALUE_'+bxAlgo,'bxvalue')
1117  qHandle.addToOutputList('BXLUMIERROR_'+bxAlgo,'bxerror')
1118  if withBeamIntensity:
1119  qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob')
1120  qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity')
1121  qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity')
1122 
1123  qConditionStr='DATA_ID=:dataid'
1124  qCondition=coral.AttributeList()
1125  qCondition.extend('dataid','unsigned long long')
1126  qCondition['dataid'].setData(int(dataid))
1127  if beamstatus:
1128  qConditionStr+=' and BEAMSTATUS=:beamstatus'
1129  qCondition.extend('beamstatus','string')
1130  qCondition['beamstatus'].setData(beamstatus)
1131  qResult=coral.AttributeList()
1132  qResult.extend('runnum','unsigned int')
1133  qResult.extend('lumilsnum','unsigned int')
1134  qResult.extend('cmslsnum','unsigned int')
1135  qResult.extend('instlumi','float')
1136  qResult.extend('instlumierr','float')
1137  qResult.extend('instlumiqlty','short')
1138  qResult.extend('beamstatus','string')
1139  qResult.extend('beamenergy','float')
1140  qResult.extend('numorbit','unsigned int')
1141  qResult.extend('startorbit','unsigned int')
1142  if withBXInfo:
1143  qResult.extend('bxvalue','blob')
1144  qResult.extend('bxerror','blob')
1145  if withBeamIntensity:
1146  qResult.extend('bxindexblob','blob')
1147  qResult.extend('beam1intensity','blob')
1148  qResult.extend('beam2intensity','blob')
1149  qHandle.defineOutput(qResult)
1150  qHandle.setCondition(qConditionStr,qCondition)
1151  cursor=qHandle.execute()
1152  while next(cursor):
1153  runnum=cursor.currentRow()['runnum'].data()
1154  lumilsnum=cursor.currentRow()['lumilsnum'].data()
1155  cmslsnum=cursor.currentRow()['cmslsnum'].data()
1156  instlumi=cursor.currentRow()['instlumi'].data()
1157  instlumierr=cursor.currentRow()['instlumierr'].data()
1158  instlumiqlty=cursor.currentRow()['instlumiqlty'].data()
1159  bs=cursor.currentRow()['beamstatus'].data()
1160  begev=cursor.currentRow()['beamenergy'].data()
1161  numorbit=cursor.currentRow()['numorbit'].data()
1162  startorbit=cursor.currentRow()['startorbit'].data()
1163  bxinfo=None
1164  bxvalueblob=None
1165  bxerrblob=None
1166  if withBXInfo:
1167  bxvalueblob=cursor.currentRow()['bxvalue'].data()
1168  bxerrblob=cursor.currentRow()['bxerror'].data()
1169  if bxvalueblob and bxerrblob:
1170  bxvaluesArray=CommonUtil.unpackBlobtoArray(bxvalueblob,'f')
1171  bxerrArray=CommonUtil.unpackBlobtoArray(bxerrblob,'f')
1172  bxinfo=(bxvaluesArray,bxerrArray)
1173  bxindexblob=None
1174  beam1intensity=None
1175  beam2intensity=None
1176  beaminfo=None
1177  if withBeamIntensity:
1178  bxindexblob=cursor.currentRow()['bxindexblob'].data()
1179  beam1intensity=cursor.currentRow()['beam1intensity'].data()
1180  beam2intensity=cursor.currentRow()['beam2intensity'].data()
1181  if bxindexblob :
1182  bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h')
1183  beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensity,'f')
1184  beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensity,'f')
1185  beaminfo=(bxindexArray,beam1intensityArray,beam2intensityArray)
1186  result[lumilsnum]=[cmslsnum,instlumi,instlumierr,instlumiqlty,bs,begev,numorbit,startorbit,bxinfo,beaminfo]
1187  except :
1188  del qHandle
1189  raise
1190  del qHandle
1191  return (runnum,result)
def lumisummaryv2TableName()
Definition: nameDealer.py:28
def unpackBlobtoArray(iblob, itemtypecode)
Definition: CommonUtil.py:229
def lumiLSById(schema, dataid, beamstatus=None, withBXInfo=False, bxAlgo='OCC1', withBeamIntensity=False, tableName=None)
Definition: dataDML.py:1085
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.luminormById (   schema,
  dataid 
)
select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
result (normname(0),amodetag(1),egev(2),norm(3),norm_occ2(4),norm_et(5),norm_pu(6),constfactor(7))

Definition at line 555 of file dataDML.py.

References data, nameDealer.luminormTableName(), and GetRecoTauVFromDQM_MC_cff.next.

555 def luminormById(schema,dataid):
556  '''
557  select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
558  output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
559  '''
560  result=None
561  qHandle=schema.newQuery()
562  try:
563  qHandle.addToTableList(nameDealer.luminormTableName())
564  qHandle.addToOutputList('ENTRY_NAME','normname')
565  qHandle.addToOutputList('AMODETAG','amodetag')
566  qHandle.addToOutputList('NORM_1','norm_1')
567  qHandle.addToOutputList('EGEV_1','energy_1')
568  qHandle.addToOutputList('NORM_OCC2','norm_occ2')
569  qHandle.addToOutputList('NORM_ET','norm_et')
570  qHandle.addToOutputList('NORM_PU','norm_pu')
571  qHandle.addToOutputList('CONSTFACTOR','constfactor')
572  qCondition=coral.AttributeList()
573  qCondition.extend('dataid','unsigned long long')
574  qCondition['dataid'].setData(dataid)
575  qResult=coral.AttributeList()
576  qResult.extend('normname','string')
577  qResult.extend('amodetag','string')
578  qResult.extend('norm_1','float')
579  qResult.extend('energy_1','unsigned int')
580  qResult.extend('norm_occ2','float')
581  qResult.extend('norm_et','float')
582  qResult.extend('norm_pu','float')
583  qResult.extend('constfactor','float')
584  qHandle.defineOutput(qResult)
585  qHandle.setCondition('DATA_ID=:dataid',qCondition)
586  cursor=qHandle.execute()
587  while next(cursor):
588  normname=cursor.currentRow()['normname'].data()
589  amodetag=cursor.currentRow()['amodetag'].data()
590  norm_1=cursor.currentRow()['norm_1'].data()
591  energy_1=cursor.currentRow()['energy_1'].data()
592  norm_occ2=1.0
593  if cursor.currentRow()['norm_occ2'].data():
594  norm_occ2=cursor.currentRow()['norm_occ2'].data()
595  norm_et=1.0
596  if cursor.currentRow()['norm_et'].data():
597  norm_et=cursor.currentRow()['norm_et'].data()
598  norm_pu=1.0
599  if cursor.currentRow()['norm_pu'].data():
600  norm_pu=cursor.currentRow()['norm_pu'].data()
601  constfactor=1.0
602  if cursor.currentRow()['constfactor'].data():
603  constfactor=cursor.currentRow()['constfactor'].data()
604  result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
605  except :
606  del qHandle
607  raise
608  del qHandle
609  return result
610 
611 #def mostRecentLumicorrs(schema,branchfilter):
612 # '''
613 # this overview query should be only for corr
614 # select e.name,n.data_id,r.revision_id , n.a1,n.a2,n.drift from lumicorrections_entries e,lumicorrections_rev r,lumicorrections n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter) group by e.entry_name,r.revision_id,n.a1,n.a2,n.drift;
615 # output {corrname:(data_id,a1,a2,drift)}
616 # '''
617 # #print branchfilter
618 # result={}
619 # entry2datamap={}
620 # branchmin=0
621 # branchmax=0
622 # if branchfilter and len(branchfilter)!=0:
623 # branchmin=min(branchfilter)
624 # branchmax=max(branchfilter)
625 # else:
626 # return result
627 # qHandle=schema.newQuery()
628 # corrdict={}
629 # try:
630 # qHandle.addToTableList(nameDealer.entryTableName(nameDealer.lumicorrectionsTableName()),'e')
631 # qHandle.addToTableList(nameDealer.lumicorrectionsTableName(),'n')
632 # qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.lumicorrectionsTableName()),'r')
633 # qHandle.addToOutputList('e.NAME','corrname')
634 # qHandle.addToOutputList('r.DATA_ID','data_id')
635 # qHandle.addToOutputList('r.REVISION_ID','revision_id')
636 # qHandle.addToOutputList('n.A1','a1')
637 # qHandle.addToOutputList('n.A2','a2')
638 # qHandle.addToOutputList('n.DRIFT','drift')
639 # qCondition=coral.AttributeList()
640 # qCondition.extend('branchmin','unsigned long long')
641 # qCondition.extend('branchmax','unsigned long long')
642 # qCondition['branchmin'].setData(branchmin)
643 # qCondition['branchmax'].setData(branchmax)
644 # qResult=coral.AttributeList()
645 # qResult.extend('corrname','string')
646 # qResult.extend('data_id','unsigned long long')
647 # qResult.extend('revision_id','unsigned long long')
648 # qResult.extend('a1','float')
649 # qResult.extend('a2','float')
650 # qResult.extend('drift','float')
651 # qHandle.defineOutput(qResult)
652 # qHandle.setCondition('n.ENTRY_ID=e.ENTRY_ID and n.DATA_ID=r.DATA_ID AND n.DATA_ID=r.DATA_ID AND r.REVISION_ID>=:branchmin AND r.REVISION_ID<=:branchmax',qCondition)
653 # cursor=qHandle.execute()
654 # while cursor.next():
655 # corrname=cursor.currentRow()['corrname'].data()
656 # data_id=cursor.currentRow()['data_id'].data()
657 # if not corrdict.has_key(corrname):
658 # corrdict[corrname]=0
659 # if data_id>corrdict[corrname]:
660 # corrdict[corrname]=data_id
661 # a1=cursor.currentRow()['a1'].data() #required
662 # a2=0.0
663 # if not cursor.currentRow()['a2'].isNull():
664 # a2=cursor.currentRow()['a2'].data()
665 # drift=0.0
666 # if not cursor.currentRow()['drift'].isNull():
667 # drift=cursor.currentRow()['drift'].data()
668 # result[corrname]=(data_id,a1,a2,drift)
669 # except:
670 # raise
671 # return result
672 
def luminormById(schema, dataid)
Definition: dataDML.py:555
def luminormTableName()
Definition: nameDealer.py:37
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.lumiRunById (   schema,
  lumidataid,
  lumitype = 'HF' 
)
input: lumidataid
output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3),starttimestr(4),stoptimestr(5),nls(6))

Definition at line 960 of file dataDML.py.

References data, nameDealer.lumidataTableName(), GetRecoTauVFromDQM_MC_cff.next, and nameDealer.pixellumidataTableName().

Referenced by lumiRunByIds().

960 def lumiRunById(schema,lumidataid,lumitype='HF'):
961  '''
962  input: lumidataid
963  output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3),starttimestr(4),stoptimestr(5),nls(6))
964  '''
965  result=None
966  if lumitype not in ['HF','PIXEL']:
967  raise ValueError('unknown lumitype '+lumitype)
968  lumitableName=''
969  if lumitype=='HF':
970  lumitableName = nameDealer.lumidataTableName()
971  else:
972  lumitableName = nameDealer.pixellumidataTableName()
973  qHandle=schema.newQuery()
974  try:
975  qHandle.addToTableList(lumitableName)
976  qHandle.addToOutputList('RUNNUM')
977  qHandle.addToOutputList('SOURCE')
978  qHandle.addToOutputList('NOMINALEGEV')
979  qHandle.addToOutputList('NCOLLIDINGBUNCHES')
980  qHandle.addToOutputList('TO_CHAR('+lumitableName+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','startT')
981  qHandle.addToOutputList('TO_CHAR('+lumitableName+'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')','stopT')
982  qHandle.addToOutputList('NLS')
983  qConditionStr='DATA_ID=:dataid'
984  qCondition=coral.AttributeList()
985  qCondition.extend('dataid','unsigned long long')
986  qCondition['dataid'].setData(lumidataid)
987  qResult=coral.AttributeList()
988  qResult.extend('RUNNUM','unsigned int')
989  qResult.extend('SOURCE','string')
990  qResult.extend('NOMINALEGEV','float')
991  qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
992  qResult.extend('startT','string')
993  qResult.extend('stopT','string')
994  qResult.extend('NLS','unsigned int')
995  qHandle.defineOutput(qResult)
996  qHandle.setCondition(qConditionStr,qCondition)
997  cursor=qHandle.execute()
998  lu=lumiTime.lumiTime()
999  nls=0
1000  while next(cursor):
1001  runnum=cursor.currentRow()['RUNNUM'].data()
1002  datasource=cursor.currentRow()['SOURCE'].data()
1003  nominalegev=0
1004  if not cursor.currentRow()['NOMINALEGEV'].isNull():
1005  nominalegev=cursor.currentRow()['NOMINALEGEV'].data()
1006  ncollidingbunches=0
1007  if not cursor.currentRow()['NCOLLIDINGBUNCHES'].isNull():
1008  ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
1009  startTstr=cursor.currentRow()['startT'].data()
1010  stopTstr=cursor.currentRow()['stopT'].data()
1011  #startT=lu.StrToDatetime(startTstr)
1012  #stopT=lu.StrToDatetime(stopTstr)
1013  if not cursor.currentRow()['NLS'].isNull():
1014  nls=cursor.currentRow()['NLS'].data()
1015  result=(runnum,datasource,nominalegev,ncollidingbunches,startTstr,stopTstr,nls)
1016  except :
1017  del qHandle
1018  raise
1019  del qHandle
1020  return result
1021 
1022 #def correctionByName(schema,correctiontagname=None):
1023 # '''
1024 # get correction coefficients by name
1025 # input: correctiontagname if None,get current default
1026 # output: [tagname,a1,a2,drift]
1027 # if not correctiontagname
1028 # select entry_name,data_id,a1,a2,drift from lumicorrections where
1029 # else:
1030 # select entry_name,data_id,a1,a2,drift from lumicorrections where entry_name=:correctiontagname
1031 # '''
1032 
1033 
1034 #def fillschemeByRun(schema,runnum):
1035 # fillscheme=''
1036 # ncollidingbunches=0
1037 # r=nameDealer.cmsrunsummaryTableName()
1038 # qHandle=schema.newQuery()
1039 # try:
1040 # qHandle.addToTableList(r)
1041 # qHandle.addToOutputList('FILLSCHEME')
1042 # qHandle.addToOutputList('NCOLLIDINGBUNCHES')
1043 # qResult=coral.AttributeList()
1044 # qResult.extend('FILLSCHEME','string')
1045 # qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
1046 # qConditionStr='RUNNUM=:runnum'
1047 # qCondition=coral.AttributeList()
1048 # qCondition.extend('runnum','unsigned int')
1049 # qCondition['runnum'].setData(int(runnum))
1050 # qHandle.defineOutput(qResult)
1051 # qHandle.setCondition(qConditionStr,qCondition)
1052 # cursor=qHandle.execute()
1053 # while cursor.next():
1054 # if not cursor.currentRow()['NCOLLIDINGBUNCHES'].isNull():
1055 # ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
1056 # if not cursor.currentRow()['FILLSCHEME'].isNull():
1057 # fillscheme=cursor.currentRow()['FILLSCHEME'].data()
1058 # except :
1059 # del qHandle
1060 # raise
1061 # del qHandle
1062 # return (fillscheme,ncollidingbunches)
def lumiRunById(schema, lumidataid, lumitype='HF')
Definition: dataDML.py:960
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def pixellumidataTableName()
Definition: nameDealer.py:22
def lumidataTableName()
Definition: nameDealer.py:19
def dataDML.lumiRunByIds (   schema,
  dataidMap,
  lumitype = 'HF' 
)
input dataidMap : {run:lumidataid}
result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)}

Definition at line 904 of file dataDML.py.

References lumiRunById().

Referenced by lumiCalcAPI.deliveredLumiForIds(), and lumiCalcAPI.runsummaryMap().

904 def lumiRunByIds(schema,dataidMap,lumitype='HF'):
905  '''
906  input dataidMap : {run:lumidataid}
907  result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)}
908  '''
909  result={}
910  if not dataidMap:
911  return result
912  inputRange=dataidMap.keys()
913  for r in inputRange:
914  lumidataid=dataidMap[r][0]
915  if lumidataid:
916  perrundata=lumiRunById(schema,lumidataid,lumitype=lumitype)
917  result[r]=(perrundata[1],perrundata[2],perrundata[3],perrundata[4],perrundata[5])
918  return result
919 
def lumiRunById(schema, lumidataid, lumitype='HF')
Definition: dataDML.py:960
def lumiRunByIds(schema, dataidMap, lumitype='HF')
Definition: dataDML.py:904
def dataDML.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 = None 
)
select r.runnum,l.starttime,l.stoptime,l.data_id,tag.trgdataid,tag.hltdataid from cmsrunsummary r,tagruns tag,lumidata l,trgdata t,hltdata h where l.runnum=tag.runnum and r.runnum=l.runnum (and l.runnum=t.runnum and t.runnum=h.runnum) and r.fillnum>=:fillmin and r.fillnum<=fillmax and r.runnum>:runmin and r.runnum<:runmax and r.amodetag=:amodetag (and regexp_like(r.l1key,:l1keypattern) and regexp_like(hltkey,:hltkeypattern) ) and l.nominalEnergy>=:nominalEnergy*(1-energyFlut) and l.nominalEnergy<=:nominalEnergy*(1+energyFlut) and tag.tagid<=:tagid and l.starttime is not null and l.stoptime is not null
output: {runnum:[lumiid,trgid,hltid]}

Definition at line 240 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName(), data, nameDealer.hltdataTableName(), createfilelist.int, nameDealer.lumidataTableName(), GetRecoTauVFromDQM_MC_cff.next, nameDealer.pixellumidataTableName(), nameDealer.pixeltagRunsTableName(), nameDealer.tagRunsTableName(), and nameDealer.trgdataTableName().

Referenced by lumiCalcAPI.runList().

240 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=None):
241  '''
242  select r.runnum,l.starttime,l.stoptime,l.data_id,tag.trgdataid,tag.hltdataid from cmsrunsummary r,tagruns tag,lumidata l,trgdata t,hltdata h where l.runnum=tag.runnum and r.runnum=l.runnum (and l.runnum=t.runnum and t.runnum=h.runnum) and r.fillnum>=:fillmin and r.fillnum<=fillmax and r.runnum>:runmin and r.runnum<:runmax and r.amodetag=:amodetag (and regexp_like(r.l1key,:l1keypattern) and regexp_like(hltkey,:hltkeypattern) ) and l.nominalEnergy>=:nominalEnergy*(1-energyFlut) and l.nominalEnergy<=:nominalEnergy*(1+energyFlut) and tag.tagid<=:tagid and l.starttime is not null and l.stoptime is not null
243  output: {runnum:[lumiid,trgid,hltid]}
244  '''
245  #print datatagid,runmin,runmax,fillmin,fillmax,preselectedruns
246  if lumitype not in ['HF','PIXEL']:
247  raise ValueError('unknown lumitype '+lumitype)
248  lumitableName=''
249  tagrunstablename=''
250  if lumitype=='HF':
251  lumitableName=nameDealer.lumidataTableName()
252  tagrunstablename=nameDealer.tagRunsTableName()
253  elif lumitype == 'PIXEL':
254  lumitableName = nameDealer.pixellumidataTableName()
255  tagrunstablename=nameDealer.pixeltagRunsTableName()
256  else:
257  assert False, "ERROR Unknown lumitype '%s'" % lumitype
258 
259  result={}#{runnum,[[lumiid,trgid,hltid]]}
260  qHandle=schema.newQuery()
262  l=lumitableName
263  tag=tagrunstablename
266  lute=lumiTime.lumiTime()
267  try:
268  qHandle.addToTableList(r)
269  qHandle.addToTableList(l)
270  qHandle.addToTableList(tag)
271  qConditionStr=r+'.RUNNUM='+l+'.RUNNUM AND '+tag+'.RUNNUM='+l+'.RUNNUM AND '+tag+'.TAGID<=:tagid'
272  qCondition=coral.AttributeList()
273  qCondition.extend('tagid','unsigned long long')
274  qCondition['tagid'].setData(datatagid)
275  #if requiretrg:
276  # qHandle.addToTableList(t)
277  # qConditionStr+=' and '+l+'.RUNNUM='+t+'.RUNNUM'
278  #if requirehlt:
279  # qHandle.addToTableList(h)
280  # qConditionStr+=' and '+l+'.RUNNUM='+h+'.RUNNUM'
281  if runmin and runmax :
282  if runmin==runmax:
283  qConditionStr+=' AND '+r+'.RUNNUM=:runmin'
284  qCondition.extend('runmin','unsigned int')
285  qCondition['runmin'].setData(int(runmin))
286  elif runmax>runmin:
287  qConditionStr+=' AND '+r+'.RUNNUM>=:runmin AND '+r+'.RUNNUM<=:runmax'
288  qCondition.extend('runmin','unsigned int')
289  qCondition.extend('runmax','unsigned int')
290  qCondition['runmin'].setData(int(runmin))
291  qCondition['runmax'].setData(int(runmax))
292  else:
293  raise 'runmin > runmax'
294  elif runmin:
295  qConditionStr+=' AND '+r+'.RUNNUM>=:runmin'
296  qCondition.extend('runmin','unsigned int')
297  qCondition['runmin'].setData(int(runmin))
298  elif runmax:
299  qConditionStr+=' AND '+r+'.RUNNUM<=:runmax'
300  qCondition.extend('runmax','unsigned int')
301  qCondition['runmax'].setData(int(runmax))
302  else:
303  pass
304  if fillmin and fillmax:
305  if fillmin==fillmax:
306  qConditionStr+=' AND '+r+'.FILLNUM=:fillnum'
307  qCondition.extend('fillnum','unsigned int')
308  qCondition['fillnum'].setData(int(fillmin))
309  elif fillmax>fillmin:
310  qConditionStr+=' AND '+r+'.FILLNUM>=:fillmin AND '+r+'.FILLNUM<=:fillmax'
311  qCondition.extend('fillmin','unsigned int')
312  qCondition.extend('fillmax','unsigned int')
313  qCondition['fillmin'].setData(int(fillmin))
314  qCondition['fillmax'].setData(int(fillmax))
315  else:
316  raise 'fillmin > fillmax'
317  if amodetag:
318  qConditionStr+=' AND '+r+'.AMODETAG=:amodetag'
319  qCondition.extend('amodetag','string')
320  qCondition['amodetag'].setData(amodetag)
321  if l1keyPattern:
322  qHandle.addToTableList(t)
323  qConditionStr+=' AND regexp_like('+r+'.L1KEY,:l1keypattern )'+' AND '+l+'.RUNNUM='+t+'.RUNNUM'
324  qCondition.extend('l1keypattern','string')
325  qCondition['l1keypattern'].setData(l1keyPattern)
326  if hltkeyPattern:
327  qHandle.addToTableList(h)
328  qConditionStr+=' AND regexp_like('+r+'.HLTKEY,:hltkeypattern)'+' AND '+l+'.RUNNUM='+h+'.RUNNUM'
329  qCondition.extend('hltkeypattern','string')
330  qCondition['hltkeypattern'].setData(hltkeyPattern)
331  if nominalEnergy:
332  emin=nominalEnergy*(1.0-energyFlut)
333  emax=nominalEnergy*(1.0+energyFlut)
334  qConditionStr+=' AND '+l+'.NOMINALEGEV>=:emin and '+l+'.NOMINALEGEV<=:emax'
335  qCondition.extend('emin','float')
336  qCondition.extend('emax','float')
337  qCondition['emin'].setData(emin)
338  qCondition['emax'].setData(emax)
339  qResult=coral.AttributeList()
340  qResult.extend('runnum','unsigned int')
341  qResult.extend('starttime','string')
342  qResult.extend('stoptime','string')
343  qResult.extend('lumiid','unsigned long long')
344  if requiretrg:
345  qResult.extend('trgid','unsigned long long')
346  if requirehlt:
347  qResult.extend('hltid','unsigned long long')
348  qHandle.setCondition(qConditionStr,qCondition)
349  qHandle.addToOutputList(r+'.RUNNUM','runnum')
350  qHandle.addToOutputList('TO_CHAR('+l+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime')
351  qHandle.addToOutputList('TO_CHAR('+l+'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')','stoptime')
352  qHandle.addToOutputList(l+'.DATA_ID','lumiid')
353  #if requiretrg:
354  # qHandle.addToOutputList(t+'.DATA_ID','trgid')
355  #if requirehlt:
356  # qHandle.addToOutputList(h+'.DATA_ID','hltid')
357  if requiretrg:
358  qHandle.addToOutputList(tag+'.TRGDATAID','trgid')
359  if requirehlt:
360  qHandle.addToOutputList(tag+'.HLTDATAID','hltid')
361  qHandle.defineOutput(qResult)
362  cursor=qHandle.execute()
363  lumiid=0
364  trgid=0
365  hltid=0
366  while next(cursor):
367  runnum=cursor.currentRow()['runnum'].data()
368  if preselectedruns and runnum not in preselectedruns:
369  continue
370  if cursor.currentRow()['starttime'].isNull():
371  continue
372  if cursor.currentRow()['stoptime'].isNull():
373  continue
374  starttimeStr=cursor.currentRow()['starttime'].data()
375  stoptimeStr=cursor.currentRow()['stoptime'].data()
376  runstartTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
377  runstopTime=lute.StrToDatetime(stoptimeStr,customfm='%m/%d/%y %H:%M:%S')
378  minTime=datetime(2010,1,1,0,0,0,0)
379  maxTime=datetime.now()
380  if startT and stopT:
381  minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
382  maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
383  if not (runstopTime>=minTime and runstartTime<=maxTime):
384  continue
385  elif startT is not None:
386  minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
387  if not (runstopTime>=minTime):
388  continue
389  elif stopT is not None:
390  maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
391  runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
392  if not (runTime<=maxTime):
393  continue
394  else:
395  pass
396  if not cursor.currentRow()['lumiid'].isNull():
397  lumiid=cursor.currentRow()['lumiid'].data()
398  if runnum in result:
399  if lumiid>result[runnum][0]:
400  result[runnum][0]=lumiid
401  else:
402  result[runnum]=[lumiid,0,0]
403  if requiretrg :
404  if cursor.currentRow()['trgid'].isNull():
405  trgid=0
406  else:
407  trgid=cursor.currentRow()['trgid'].data()
408  if runnum in result:
409  if trgid>result[runnum][1]:
410  result[runnum][1]=trgid
411  if requirehlt and not cursor.currentRow()['hltid'].isNull():
412  hltid=cursor.currentRow()['hltid'].data()
413  if runnum in result:
414  if hltid>result[runnum][2]:
415  result[runnum][2]=hltid
416  except :
417  del qHandle
418  raise
419  del qHandle
420  return result
421 
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=None)
Definition: dataDML.py:240
def pixeltagRunsTableName()
Definition: nameDealer.py:70
def trgdataTableName()
Definition: nameDealer.py:46
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def hltdataTableName()
Definition: nameDealer.py:58
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def pixellumidataTableName()
Definition: nameDealer.py:22
def tagRunsTableName()
Definition: nameDealer.py:64
def lumidataTableName()
Definition: nameDealer.py:19
def dataDML.runsummary (   schema,
  runnum,
  sessionflavor = '' 
)
select l1key,amodetag,hltkey,fillnum,fillscheme from cmsrunsummary where runnum=:runnum
output: [l1key(0),amodetag(1),hltkey(3),fillnum(4),fillscheme(5)]

Definition at line 422 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName(), data, createfilelist.int, and GetRecoTauVFromDQM_MC_cff.next.

Referenced by SiStripFineDelayHit.produce(), and lumiCalcAPI.runsummary().

422 def runsummary(schema,runnum,sessionflavor=''):
423  '''
424  select l1key,amodetag,hltkey,fillnum,fillscheme from cmsrunsummary where runnum=:runnum
425  output: [l1key(0),amodetag(1),hltkey(3),fillnum(4),fillscheme(5)]
426  '''
427  result=[]
428  qHandle=schema.newQuery()
430  try:
431  qHandle.addToTableList(nameDealer.cmsrunsummaryTableName())
432  qCondition=coral.AttributeList()
433  qCondition.extend('runnum','unsigned int')
434  qCondition['runnum'].setData(int(runnum))
435  qHandle.addToOutputList('L1KEY','l1key')
436  qHandle.addToOutputList('AMODETAG','amodetag')
437  #qHandle.addToOutputList('EGEV','egev')
438  qHandle.addToOutputList('HLTKEY','hltkey')
439  qHandle.addToOutputList('FILLNUM','fillnum')
440  qHandle.addToOutputList('FILLSCHEME','fillscheme')
441  #if sessionflavor=='SQLite':
442  # qHandle.addToOutputList('STARTTIME','starttime')
443  # qHandle.addToOutputList('STOPTIME','stoptime')
444  #else:
445  # qHandle.addToOutputList('to_char(STARTTIME,\''+t.coraltimefm+'\')','starttime')
446  # qHandle.addToOutputList('to_char(STOPTIME,\''+t.coraltimefm+'\')','stoptime')
447  qHandle.setCondition('RUNNUM=:runnum',qCondition)
448  qResult=coral.AttributeList()
449  qResult.extend('l1key','string')
450  qResult.extend('amodetag','string')
451  #qResult.extend('egev','unsigned int')
452  qResult.extend('hltkey','string')
453  qResult.extend('fillnum','unsigned int')
454  qResult.extend('fillscheme','string')
455  #qResult.extend('starttime','string')
456  #qResult.extend('stoptime','string')
457  qHandle.defineOutput(qResult)
458  cursor=qHandle.execute()
459  while next(cursor):
460  result.append(cursor.currentRow()['l1key'].data())
461  result.append(cursor.currentRow()['amodetag'].data())
462  #result.append(cursor.currentRow()['egev'].data())
463  result.append(cursor.currentRow()['hltkey'].data())
464  result.append(cursor.currentRow()['fillnum'].data())
465  fillscheme=''
466  if not cursor.currentRow()['fillscheme'].isNull():
467  fillscheme=cursor.currentRow()['fillscheme'].data()
468  result.append(fillscheme)
469  #result.append(cursor.currentRow()['starttime'].data())
470  #result.append(cursor.currentRow()['stoptime'].data())
471  except :
472  del qHandle
473  raise
474  del qHandle
475  return result
476 
477 #def mostRecentLuminorms(schema,branchfilter):
478 # '''
479 # this overview query should be only for norm
480 # select e.name,n.data_id,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_occ2,n.norm_et,n.norm_pu,n.constfactor from luminorms_entries e,luminorms_rev r,luminorms n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter);
481 # output {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
482 # '''
483 # #print branchfilter
484 # result={}
485 # entry2datamap={}
486 # branchmin=0
487 # branchmax=0
488 # if branchfilter and len(branchfilter)!=0:
489 # branchmin=min(branchfilter)
490 # branchmax=max(branchfilter)
491 # else:
492 # return result
493 # #print branchmin,branchmax
494 # qHandle=schema.newQuery()
495 # normdict={}
496 # try:
497 # qHandle.addToTableList(nameDealer.entryTableName(nameDealer.luminormTableName()),'e')
498 # qHandle.addToTableList(nameDealer.luminormTableName(),'n')
499 # qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.luminormTableName()),'r')
500 # qHandle.addToOutputList('e.NAME','normname')
501 # qHandle.addToOutputList('r.DATA_ID','data_id')
502 # qHandle.addToOutputList('r.REVISION_ID','revision_id')
503 # qHandle.addToOutputList('n.AMODETAG','amodetag')
504 # qHandle.addToOutputList('n.NORM_1','norm_1')
505 # qHandle.addToOutputList('n.EGEV_1','energy_1')
506 # qHandle.addToOutputList('n.NORM_OCC2','norm_occ2')
507 # qHandle.addToOutputList('n.NORM_ET','norm_et')
508 # qHandle.addToOutputList('n.NORM_PU','norm_pu')
509 # qHandle.addToOutputList('n.CONSTFACTOR','constfactor')
510 # qCondition=coral.AttributeList()
511 # qCondition.extend('branchmin','unsigned long long')
512 # qCondition.extend('branchmax','unsigned long long')
513 # qCondition['branchmin'].setData(branchmin)
514 # qCondition['branchmax'].setData(branchmax)
515 # qResult=coral.AttributeList()
516 # qResult.extend('normname','string')
517 # qResult.extend('data_id','unsigned long long')
518 # qResult.extend('revision_id','unsigned long long')
519 # qResult.extend('amodetag','string')
520 # qResult.extend('norm_1','float')
521 # qResult.extend('energy_1','unsigned int')
522 # qResult.extend('norm_occ2','float')
523 # qResult.extend('norm_et','float')
524 # qResult.extend('norm_pu','float')
525 # qResult.extend('constfactor','float')
526 # qHandle.defineOutput(qResult)
527 # qHandle.setCondition('n.ENTRY_ID=e.ENTRY_ID and n.DATA_ID=r.DATA_ID AND n.DATA_ID=r.DATA_ID AND r.REVISION_ID>=:branchmin AND r.REVISION_ID<=:branchmax',qCondition)
528 # cursor=qHandle.execute()
529 # while cursor.next():
530 # data_id=cursor.currentRow()['data_id'].data()
531 # normname=cursor.currentRow()['normname'].data()
532 # if not normdict.has_key(normname):
533 # normdict[normname]=0
534 # if data_id>normdict[normname]:
535 # normdict[normname]=data_id
536 # amodetag=cursor.currentRow()['amodetag'].data()
537 # norm_1=cursor.currentRow()['norm_1'].data()
538 # energy_1=cursor.currentRow()['energy_1'].data()
539 # norm_occ2=1.0
540 # if not cursor.currentRow()['norm_occ2'].isNull():
541 # norm_occ2=cursor.currentRow()['norm_occ2'].data()
542 # norm_et=1.0
543 # if not cursor.currentRow()['norm_et'].isNull():
544 # norm_et=cursor.currentRow()['norm_et'].data()
545 # norm_pu=1.0
546 # if not cursor.currentRow()['norm_pu'].isNull():
547 # norm_pu=cursor.currentRow()['norm_pu'].data()
548 # constfactor=1.0
549 # if not cursor.currentRow()['constfactor'].isNull():
550 # constfactor=cursor.currentRow()['constfactor'].data()
551 # result[normname]=(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)
552 # except:
553 # raise
554 # return result
def runsummary(schema, runnum, sessionflavor='')
Definition: dataDML.py:422
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def cmsrunsummaryTableName()
Definition: nameDealer.py:16
def dataDML.trgLSById (   schema,
  dataid,
  trgbitname = None,
  trgbitnamepattern = None,
  withL1Count = False,
  withPrescale = False 
)
output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale,mask)](4)]})

Definition at line 797 of file dataDML.py.

References mps_setup.append, data, nameDealer.lstrgTableName(), GetRecoTauVFromDQM_MC_cff.next, trgRunById(), and CommonUtil.unpackBlobtoArray().

Referenced by lumiCalcAPI.trgForIds().

797 def trgLSById(schema,dataid,trgbitname=None,trgbitnamepattern=None,withL1Count=False,withPrescale=False):
798  '''
799  output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale,mask)](4)]})
800  '''
801  runnum=0
802  result={}
803  trgnamedict=[]
804  if trgbitname or trgbitnamepattern or withPrescale or withL1Count:
805  trgrundata=trgRunById(schema,dataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern)
806  trgnamedict=trgrundata[3]#[runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)]
807  algomask_h=trgrundata[4]
808  algomask_l=trgrundata[5]
809  techmask=trgrundata[6]
810  qHandle=schema.newQuery()
811  try:
812  qHandle.addToTableList(nameDealer.lstrgTableName())
813  qHandle.addToOutputList('RUNNUM','runnum')
814  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
815  qHandle.addToOutputList('DEADTIMECOUNT','deadtimecount')
816  #qHandle.addToOutputList('BITZEROCOUNT','bitzerocount')
817  #qHandle.addToOutputList('BITZEROPRESCALE','bitzeroprescale')
818  qHandle.addToOutputList('DEADFRAC','deadfrac')
819  if withPrescale:
820  qHandle.addToOutputList('PRESCALEBLOB','prescalesblob')
821  if withL1Count:
822  qHandle.addToOutputList('TRGCOUNTBLOB','trgcountblob')
823  qConditionStr='DATA_ID=:dataid'
824  qCondition=coral.AttributeList()
825  qCondition.extend('dataid','unsigned long long')
826  qCondition['dataid'].setData(dataid)
827  qResult=coral.AttributeList()
828  qResult.extend('runnum','unsigned int')
829  qResult.extend('cmslsnum','unsigned int')
830  qResult.extend('deadtimecount','unsigned long long')
831  #qResult.extend('bitzerocount','unsigned int')
832  #qResult.extend('bitzeroprescale','unsigned int')
833  qResult.extend('deadfrac','float')
834  if withPrescale:
835  qResult.extend('prescalesblob','blob')
836  if withL1Count:
837  qResult.extend('trgcountblob','blob')
838  qHandle.defineOutput(qResult)
839  qHandle.setCondition(qConditionStr,qCondition)
840  cursor=qHandle.execute()
841  while next(cursor):
842  runnum=cursor.currentRow()['runnum'].data()
843  cmslsnum=cursor.currentRow()['cmslsnum'].data()
844  deadtimecount=cursor.currentRow()['deadtimecount'].data()
845  #bitzerocount=cursor.currentRow()['bitzerocount'].data()
846  #bitzeroprescale=cursor.currentRow()['bitzeroprescale'].data()
847  bitzerocount=0
848  bitzeroprescale=0
849  deadfrac=cursor.currentRow()['deadfrac'].data()
850  if cmslsnum not in result:
851  result[cmslsnum]=[]
852  result[cmslsnum].append(deadtimecount)
853  result[cmslsnum].append(bitzerocount)
854  result[cmslsnum].append(bitzeroprescale)
855  result[cmslsnum].append(deadfrac)
856  prescalesblob=None
857  trgcountblob=None
858  if withPrescale:
859  prescalesblob=cursor.currentRow()['prescalesblob'].data()
860  if withL1Count:
861  trgcountblob=cursor.currentRow()['trgcountblob'].data()
862  prescales=[]
863  trgcounts=[]
864  if prescalesblob:
865  if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
866  prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'l')
867  else:
868  prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'I')
869  if trgcountblob:
870  if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
871  trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'l')
872  else:
873  trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'I')
874 
875  bitinfo=[]
876  for (bitidx,thisbitname) in trgnamedict:
877  thispresc=None
878  thistrgcount=None
879  if prescales:
880  thispresc=prescales[bitidx]
881  if trgcounts:
882  thistrgcount=trgcounts[bitidx]
883  maskval=0
884  #[0-127] is algobit
885  if bitidx in range(0,128):
886  if bitidx<64 :#0-63 is in algo_l
887  maskval=algomask_l>>bitidx&1
888  else:#64-127 is in algo_h
889  maskval=algomask_h>>(bitidx-64)&1
890  else:
891  #[128-191] is techbit
892  maskval=techmask>>(bitidx-128)&1
893  thisbitinfo=(thisbitname,thistrgcount,thispresc,maskval)
894  bitinfo.append(thisbitinfo)
895  result[cmslsnum].append(bitinfo)
896  except:
897  del qHandle
898  raise
899  del qHandle
900 # t1=time.time()
901 # print 'trgLSById time ',t1-t0
902  return (runnum,result)
903 
def trgRunById(schema, dataid, trgbitname=None, trgbitnamepattern=None)
Definition: dataDML.py:729
def unpackBlobtoArray(iblob, itemtypecode)
Definition: CommonUtil.py:229
def lstrgTableName()
Definition: nameDealer.py:49
def trgLSById(schema, dataid, trgbitname=None, trgbitnamepattern=None, withL1Count=False, withPrescale=False)
Definition: dataDML.py:797
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataDML.trgRunById (   schema,
  dataid,
  trgbitname = None,
  trgbitnamepattern = None 
)
query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB,ALGOMASK_H,ALGOMASK_L,TECHMASK from trgdata where DATA_ID=:dataid

output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)]
         -- runnumber
         -- original source database name
         -- deadtime norm bitname
         -- bitnamedict [(bitidx,bitname),...]

Definition at line 729 of file dataDML.py.

References data, GetRecoTauVFromDQM_MC_cff.next, and nameDealer.trgdataTableName().

Referenced by trgLSById().

729 def trgRunById(schema,dataid,trgbitname=None,trgbitnamepattern=None):
730  '''
731  query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB,ALGOMASK_H,ALGOMASK_L,TECHMASK from trgdata where DATA_ID=:dataid
732 
733  output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)]
734  -- runnumber
735  -- original source database name
736  -- deadtime norm bitname
737  -- bitnamedict [(bitidx,bitname),...]
738  '''
739  result=[]
740  qHandle=schema.newQuery()
741  runnum=None
742  datasource=None
743  bitzeroname=None
744  bitnamedict=[]
745  try:
746  qHandle.addToTableList(nameDealer.trgdataTableName())
747  qHandle.addToOutputList('RUNNUM','runnum')
748  qHandle.addToOutputList('SOURCE','source')
749  qHandle.addToOutputList('BITZERONAME','bitzeroname')
750  qHandle.addToOutputList('BITNAMECLOB','bitnameclob')
751  qHandle.addToOutputList('ALGOMASK_H','algomask_h')
752  qHandle.addToOutputList('ALGOMASK_L','algomask_l')
753  qHandle.addToOutputList('TECHMASK','techmask')
754  qCondition=coral.AttributeList()
755  qCondition.extend('dataid','unsigned long long')
756  qCondition['dataid'].setData(dataid)
757  qResult=coral.AttributeList()
758  qResult.extend('runnum','unsigned int')
759  qResult.extend('source','string')
760  qResult.extend('bitzeroname','string')
761  qResult.extend('bitnameclob','string')
762  qResult.extend('algomask_h','unsigned long long')
763  qResult.extend('algomask_l','unsigned long long')
764  qResult.extend('techmask','unsigned long long')
765  qHandle.defineOutput(qResult)
766  qHandle.setCondition('DATA_ID=:dataid',qCondition)
767  cursor=qHandle.execute()
768  bitnameclob=None
769  bitnames=[]
770  while next(cursor):
771  runnum=cursor.currentRow()['runnum'].data()
772  source=cursor.currentRow()['source'].data()
773  bitzeroname=cursor.currentRow()['bitzeroname'].data()
774  bitnameclob=cursor.currentRow()['bitnameclob'].data()
775  algomask_h=cursor.currentRow()['algomask_h'].data()
776  algomask_l=cursor.currentRow()['algomask_l'].data()
777  techmask=cursor.currentRow()['techmask'].data()
778  if bitnameclob:
779  bitnames=bitnameclob.split(',')
780  for trgnameidx,trgname in enumerate(bitnames):
781  if trgbitname :
782  if trgname==trgbitname:
783  bitnamedict.append((trgnameidx,trgname))
784  break
785  elif trgbitnamepattern:
786  if fnmatch.fnmatch(trgname,trgbitnamepattern):
787  bitnamedict.append((trgnameidx,trgname))
788  else:
789  bitnamedict.append((trgnameidx,trgname))
790  result=[runnum,source,bitzeroname,bitnamedict,algomask_h,algomask_l,techmask]
791  except :
792  del qHandle
793  raise
794  del qHandle
795  return result
796 
def trgRunById(schema, dataid, trgbitname=None, trgbitnamepattern=None)
Definition: dataDML.py:729
def trgdataTableName()
Definition: nameDealer.py:46
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Variable Documentation

dataDML.authpath
dataDML.branchid

Definition at line 2354 of file dataDML.py.

Referenced by lumi::RevisionDML.addEntry(), and lumi::RevisionDML.addRevision().

dataDML.branchinfo

Definition at line 2355 of file dataDML.py.

Referenced by TrackerMap.TrackerMap().

dataDML.branchparent

Definition at line 2354 of file dataDML.py.

dataDML.comment

Definition at line 2341 of file dataDML.py.

dataDML.cpp2sqltype

Definition at line 2333 of file dataDML.py.

dataDML.datainfo

Definition at line 2343 of file dataDML.py.

dataDML.debugON

Definition at line 2332 of file dataDML.py.

dataDML.False

Definition at line 2333 of file dataDML.py.

dataDML.hltdata

Definition at line 2371 of file dataDML.py.

Referenced by LumiSummary.~LumiSummary().

dataDML.hltdataid

Definition at line 2374 of file dataDML.py.

Referenced by LumiProducer.getHltDataId(), and lumi::HLTV32DB.retrieveData().

dataDML.hltentryid

Definition at line 2374 of file dataDML.py.

dataDML.hltlsdata

Definition at line 2373 of file dataDML.py.

dataDML.hltrevid

Definition at line 2374 of file dataDML.py.

dataDML.hltrundata
dataDML.hlttrgmap

Definition at line 2359 of file dataDML.py.

dataDML.isReadOnly
dataDML.latestNorms

Definition at line 2382 of file dataDML.py.

dataDML.latestrevision

Definition at line 2390 of file dataDML.py.

dataDML.lumidataid

Definition at line 2364 of file dataDML.py.

Referenced by LumiProducer.getLumiDataId(), and lumi::Lumi2DB.retrieveData().

dataDML.lumidummydata

Definition at line 2361 of file dataDML.py.

dataDML.lumientry_id

Definition at line 2389 of file dataDML.py.

dataDML.lumientryid

Definition at line 2364 of file dataDML.py.

dataDML.lumilsdata

Definition at line 2363 of file dataDML.py.

dataDML.luminormentry_id

Definition at line 2381 of file dataDML.py.

dataDML.lumirevid

Definition at line 2364 of file dataDML.py.

dataDML.lumirundata
dataDML.myconstr

Definition at line 2331 of file dataDML.py.

dataDML.None

Definition at line 2341 of file dataDML.py.

dataDML.normbranchid

Definition at line 2350 of file dataDML.py.

dataDML.normbranchinfo

Definition at line 2351 of file dataDML.py.

dataDML.normbranchparent

Definition at line 2350 of file dataDML.py.

dataDML.norminfo

Definition at line 2345 of file dataDML.py.

dataDML.normrevlist

Definition at line 2380 of file dataDML.py.

dataDML.parentid

Definition at line 2401 of file dataDML.py.

Referenced by Folder.children(), Folder.parents(), and Folder.symbols().

dataDML.parentname

Definition at line 2401 of file dataDML.py.

dataDML.revisionid

Definition at line 2401 of file dataDML.py.

dataDML.revlist

Definition at line 2387 of file dataDML.py.

dataDML.runsummarydata

Definition at line 2357 of file dataDML.py.

dataDML.schema

Definition at line 2334 of file dataDML.py.

Referenced by cond::CredentialStore.addUser(), MonitorElementsDb.analyze(), l1t::OMDSReader.basicQuery(), l1t::OMDSReader.basicQueryGenericKey(), l1t::OMDSReader.basicQueryView(), l1t::OMDSReader.columnNames(), l1t::OMDSReader.columnNamesView(), RPCFw.createFEB(), RPCFw.createGAS(), RPCFw.createIDMAP(), RPCFw.createIMON(), RPCFw.createMix(), cond::CredentialStore.createSchema(), RPCFw.createSTATUS(), RPCFw.createT(), RPCFw.createUXC(), RPCFw.createVMON(), cond::CredentialStore.drop(), L1TriggerScalerRead.dropTable(), cond::CredentialStore.exportAll(), DIPLumiProducer.filldetailcache(), ExpressLumiProducer.fillLSCache(), LumiProducer.fillLSCache(), LumiCorrectionSource.fillparamcache(), DIPLumiProducer.fillsummarycache(), cond::CredentialStore.importForPrincipal(), cond::CredentialStore.installAdmin(), cond::CredentialStore.listConnections(), cond::CredentialStore.listPrincipals(), CovarianceParameterization.load(), CovarianceParameterization.loadedVersion(), L1CaloHcalScaleConfigOnlineProd.newObject(), L1RCTOmdsFedVectorProducer.produce(), RunInfoRead.readData(), DQMSummaryReader.readData(), RunSummaryRead.readData(), L1TriggerScalerRead.readData(), popcon::RPCEMapSourceHandler.readEMap1(), popcon::L1RPCHwConfigSourceHandler.readHwConfig1(), cond::CredentialStore.removeConnection(), cond::CredentialStore.removePrincipal(), lumi::CMSRunSummaryDummy2DB.retrieveData(), lumi::HLTDummy2DB.retrieveData(), lumi::HLTConfDummy2DB.retrieveData(), lumi::TRGDummy2DB.retrieveData(), lumi::LumiDummy2DB.retrieveData(), cond::CredentialStore.selectForUser(), cond::CredentialStore.selectPermissions(), cond::CredentialStore.setPermission(), cond::CredentialStore.startSession(), cond::CredentialStore.unsetPermission(), cond::CredentialStore.updateConnection(), cond::CredentialStore.updatePrincipal(), and lumi::NormDML.~NormDML().

dataDML.session

Definition at line 2333 of file dataDML.py.

Referenced by LumiProducer.beginRun(), popcon::PopConBTransitionSourceHandler< T >.checkBOn(), tensorflow.closeSession(), RPCDBCom.connect(), TestBase.connect(), RPCFw.createFEB(), RPCFw.createGAS(), RPCFw.createIDMAP(), RPCFw.createIMON(), RPCFw.createMix(), cond::CredentialStore.createSchema(), tensorflow.createSession(), RPCFw.createSTATUS(), RPCFw.createT(), RPCFw.createUXC(), RPCFw.createVMON(), tensorflow::NTSessionFactory.Deregister(), tensorflow::TBBSessionFactory.Deregister(), DTOccupancyTestML.dqmEndLuminosityBlock(), cond::CredentialStore.drop(), L1TriggerScalerRead.dropTable(), cond::CredentialStore.exportAll(), DIPLumiProducer.filldetailcache(), ExpressLumiProducer.fillLSCache(), LumiProducer.fillLSCache(), LumiCorrectionSource.fillparamcache(), DIPLumiProducer.fillsummarycache(), CondDBESSource.fillTagCollectionFromGT(), FillInfoPopConSourceHandler.getNewObjects(), LHCInfoPopConSourceHandler.getNewObjects(), popcon::PopConBTransitionSourceHandler< T >.getObjectsForBTransition(), cond::CredentialStore.importForPrincipal(), cond::CredentialStore.installAdmin(), cond::CredentialStore.listConnections(), cond::CredentialStore.listPrincipals(), tensorflow::NTSessionFactory.NewSession(), tensorflow::TBBSessionFactory.NewSession(), l1t::DataWriter.payloadToken(), l1t::DataWriterExt.payloadToken(), L1RCTOmdsFedVectorProducer.produce(), RunInfoRead.readData(), DQMSummaryReader.readData(), RunSummaryRead.readData(), L1TriggerScalerRead.readData(), l1t::DataWriter.readObject(), l1t::DataWriterExt.readObject(), cond::CredentialStore.removeConnection(), cond::CredentialStore.removePrincipal(), tensorflow::NTSessionFactory.Reset(), tensorflow::TBBSessionFactory.Reset(), lumi::CMSRunSummaryDummy2DB.retrieveData(), lumi::HLTDummy2DB.retrieveData(), lumi::HLTConfDummy2DB.retrieveData(), lumi::TRGDummy2DB.retrieveData(), lumi::LumiDummy2DB.retrieveData(), lumi::Lumi2DB.retrieveData(), l1t::WriterProxyT< Record, Type >.save(), cond::CredentialStore.selectForUser(), cond::CredentialStore.selectPermissions(), cond::CredentialStore.setPermission(), cond::CredentialStore.unsetPermission(), cond::CredentialStore.updateConnection(), cond::CredentialStore.updatePrincipal(), l1t::DataWriterExt.writeKeyList(), and l1t::DataWriter.writeKeyList().

dataDML.svc
dataDML.tables

Definition at line 2338 of file dataDML.py.

Referenced by NanoAODDQM.analyze().

dataDML.trgdata

Definition at line 2366 of file dataDML.py.

dataDML.trgdataid

Definition at line 2369 of file dataDML.py.

Referenced by LumiProducer.getTrgDataId(), and lumi::TRGScalers2DB.retrieveData().

dataDML.trgentry_id

Definition at line 2395 of file dataDML.py.

dataDML.trgentryid

Definition at line 2369 of file dataDML.py.

dataDML.trglsdata

Definition at line 2368 of file dataDML.py.

dataDML.trgrevid

Definition at line 2369 of file dataDML.py.

dataDML.trgrundata
dataDML.trunkinfo

Definition at line 2341 of file dataDML.py.

dataDML.withblobdata

Definition at line 2445 of file dataDML.py.