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 1934 of file dataDML.py.

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

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

Definition at line 2031 of file dataDML.py.

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

2031 def addHLTRunDataToBranch(schema,runnumber,hltrundata,branchinfo):
2032  '''
2033  input:
2034  hltrundata [pathnameclob(0),datasource(1)]
2035  output:
2036  (revision_id,entry_id,data_id)
2037  '''
2038  try:
2039  pathnames=hltrundata[0]
2040  datasource=hltrundata[1]
2041  npath=len(pathnames.split(','))
2042  entry_id=revisionDML.entryInBranch(schema,nameDealer.hltdataTableName(),str(runnumber),branchinfo[1])
2043  if entry_id is None:
2044  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName())
2045  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
2046  revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo)
2047  else:
2048  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() )
2049  revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo)
2050  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'}
2051  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames}
2052  db=dbUtil.dbUtil(schema)
2053  db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict)
2054  return (revision_id,entry_id,data_id)
2055  except :
2056  raise
2057 
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:344
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:190
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:332
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:318
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:396
def hltdataTableName()
Definition: nameDealer.py:58
#define str(s)
def addHLTRunDataToBranch(schema, runnumber, hltrundata, branchinfo)
Definition: dataDML.py:2031
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 1965 of file dataDML.py.

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

1965 def addLumiRunDataToBranch(schema,runnumber,lumirundata,branchinfo,tableName):
1966  '''
1967  input:
1968  lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls]
1969  branchinfo (branch_id,branch_name)
1970  tableName lumiruntablename
1971  output:
1972  (revision_id,entry_id,data_id)
1973  '''
1974  try:
1975  datasource=lumirundata[0]
1976  nominalegev=3500.0
1977  ncollidingbunches=0
1978  starttime=coral.TimeStamp()
1979  stoptime=coral.TimeStamp()
1980  nls=0
1981  if len(lumirundata)>1:
1982  nominalenergy=lumirundata[1]
1983  ncollidingbunches=lumirundata[2]
1984  starttime=lumirundata[3]
1985  stoptime=lumirundata[4]
1986  nls=lumirundata[5]
1987  entry_id=revisionDML.entryInBranch(schema,tableName,str(runnumber),branchinfo[1])
1988  if entry_id is None:
1989  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,tableName)
1990  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
1991  revisionDML.addEntry(schema,tableName,entryinfo,branchinfo)
1992  else:
1993  (revision_id,data_id)=revisionDML.bookNewRevision(schema,tableName)
1994  #print 'revision_id,data_id ',revision_id,data_id
1995  revisionDML.addRevision(schema,tableName,(revision_id,data_id),branchinfo)
1996  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'}
1997  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}
1998  db=dbUtil.dbUtil(schema)
1999  db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
2000  return (revision_id,entry_id,data_id)
2001  except :
2002  raise
2003 
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:344
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:190
def addLumiRunDataToBranch(schema, runnumber, lumirundata, branchinfo, tableName)
Definition: dataDML.py:1965
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:332
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:318
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:396
#define str(s)
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 1896 of file dataDML.py.

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

1896 def addNormToBranch(schema,normname,amodetag,norm1,egev1,optionalnormdata,branchinfo):
1897  '''
1898  input:
1899  branchinfo(normrevisionid,branchname)
1900  optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
1901  output:
1902  (revision_id,entry_id,data_id)
1903  '''
1904  #print 'branchinfo ',branchinfo
1905  norm_occ2=1.0
1906  if 'normOcc2' in optionalnormdata:
1907  norm_occ2=optionalnormdata['norm_occ2']
1908  norm_et=1.0
1909  if 'norm_et' in optionalnormdata:
1910  norm_et=optionalnormdata['norm_et']
1911  norm_pu=1.0
1912  if 'norm_pu' in optionalnormdata:
1913  norm_pu=optionalnormdata['norm_pu']
1914  constfactor=1.0
1915  if 'constfactor' in optionalnormdata:
1916  constfactor=optionalnormdata['constfactor']
1917  try:
1918  entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1])
1919  if entry_id is None:
1920  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName())
1921  entryinfo=(revision_id,entry_id,normname,data_id)
1922  revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo)
1923  else:
1924  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() )
1925  revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo)
1926  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'}
1927  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}
1928  db=dbUtil.dbUtil(schema)
1929  db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict)
1930  return (revision_id,entry_id,data_id)
1931  except :
1932  raise
1933 
def addEntry(schema, datatableName, entryinfo, branchinfo)
Definition: revisionDML.py:344
def luminormTableName()
Definition: nameDealer.py:37
def addNormToBranch(schema, normname, amodetag, norm1, egev1, optionalnormdata, branchinfo)
Definition: dataDML.py:1896
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:190
def bookNewRevision(schema, datatableName)
Definition: revisionDML.py:332
def bookNewEntry(schema, datatableName)
Definition: revisionDML.py:318
def addRevision(schema, datatableName, revisioninfo, branchinfo)
Definition: revisionDML.py:396
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 2004 of file dataDML.py.

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

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

Definition at line 1066 of file dataDML.py.

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

1066 def allfillschemes(schema):
1067  afterglows=[]
1069  try:
1070  qHandle.addToTableList(s)
1071  qResult=coral.AttributeList()
1072  qResult.extend('FILLSCHEMEPATTERN','string')
1073  qResult.extend('CORRECTIONFACTOR','float')
1074  qHandle.defineOutput(qResult)
1075  qHandle.addToOutputList('FILLSCHEMEPATTERN')
1076  qHandle.addToOutputList('CORRECTIONFACTOR')
1077  cursor=qHandle.execute()
1078  while next(cursor):
1079  fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
1080  afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
1081  afterglows.append((fillschemePattern,afterglowfac))
1082  except :
1083  del qHandle
1084  raise
1085  del qHandle
1086  return afterglows
1087 
def allfillschemes(schema)
Definition: dataDML.py:1066
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 1195 of file dataDML.py.

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

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

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

Definition at line 923 of file dataDML.py.

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

923 def beamstatusByIds(schema,dataidMap):
924  '''
925  input dataidMap : {run:lumidataid}
926  result {runnum:{cmslsnum:beamstatus}}
927  '''
928  result={}
929  if not dataidMap:
930  return result
931  inputRange=dataidMap.keys()
932  for r in inputRange:
933  if r not in result:
934  result[r]={}
935  lumidataid=dataidMap[r][0]
936  if lumidataid:
937  qHandle=schema.newQuery()
938  try:
939  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
940  qHandle.addToOutputList('CMSLSNUM')
941  qHandle.addToOutputList('BEAMSTATUS')
942  qConditionStr='DATA_ID=:dataid'
943  qCondition=coral.AttributeList()
944  qCondition.extend('dataid','unsigned long long')
945  qCondition['dataid'].setData(int(lumidataid))
946  qResult=coral.AttributeList()
947  qResult.extend('CMSLSNUM','unsigned int')
948  qResult.extend('BEAMSTATUS','string')
949  qHandle.defineOutput(qResult)
950  qHandle.setCondition(qConditionStr,qCondition)
951  cursor=qHandle.execute()
952  while next(cursor):
953  cmslsnum=cursor.currentRow()['CMSLSNUM'].data()
954  bs=cursor.currentRow()['BEAMSTATUS'].data()
955  if bs!='STABLE BEAMS':
956  result[r][cmslsnum]=bs
957  except:
958  del qHandle
959  raise
960  del qHandle
961  return result
962 
def beamstatusByIds(schema, dataidMap)
Definition: dataDML.py:923
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 2170 of file dataDML.py.

References nameDealer.lshltTableName(), and edm.print().

2170 def bulkInsertHltLSData(session,runnumber,data_id,hltlsdata,bulksize=500):
2171  '''
2172  input:
2173  hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
2174  '''
2175  print('total number of hlt rows ',len(hltlsdata))
2176  lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')]
2177  committedrows=0
2178  nrows=0
2179  bulkvalues=[]
2180  try:
2181  for cmslsnum,perlshlt in hltlsdata.items():
2182  inputcountblob=perlshlt[0]
2183  acceptcountblob=perlshlt[1]
2184  prescaleblob=perlshlt[2]
2185  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)])
2186 
2187  nrows+=1
2188  committedrows+=1
2189  if nrows==bulksize:
2190  print('committing hlt in LS chunck ',nrows)
2191  db=dbUtil.dbUtil(session.nominalSchema())
2192  session.transaction().start(False)
2193  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
2194  session.transaction().commit()
2195  nrows=0
2196  bulkvalues=[]
2197  elif committedrows==len(hltlsdata):
2198  print('committing hlt at the end ')
2199  db=dbUtil.dbUtil(session.nominalSchema())
2200  session.transaction().start(False)
2201  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
2202  session.transaction().commit()
2203  except :
2204  print('error in bulkInsertHltLSData')
2205  raise
2206 
Definition: start.py:1
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def lshltTableName()
Definition: nameDealer.py:61
def bulkInsertHltLSData(session, runnumber, data_id, hltlsdata, bulksize=500)
Definition: dataDML.py:2170
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 2207 of file dataDML.py.

References edm.print().

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

References nameDealer.lstrgTableName(), and edm.print().

2130 def bulkInsertTrgLSData(session,runnumber,data_id,trglsdata,bulksize=500):
2131  '''
2132  insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks
2133  input:
2134  trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
2135  result nrows inserted
2136  if nrows==0, then this insertion failed
2137  '''
2138  print('total number of trg rows ',len(trglsdata))
2139  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')]
2140  committedrows=0
2141  nrows=0
2142  bulkvalues=[]
2143  try:
2144  for cmslsnum,perlstrg in trglsdata.items():
2145  deadtimecount=perlstrg[0]
2146  bitzerocount=perlstrg[1]
2147  bitzeroprescale=perlstrg[2]
2148  trgcountblob=perlstrg[3]
2149  trgprescaleblob=perlstrg[4]
2150  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)])
2151  nrows+=1
2152  committedrows+=1
2153  if nrows==bulksize:
2154  print('committing trg in LS chunck ',nrows)
2155  db=dbUtil.dbUtil(session.nominalSchema())
2156  session.transaction().start(False)
2157  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
2158  session.transaction().commit()
2159  nrows=0
2160  bulkvalues=[]
2161  elif committedrows==len(trglsdata):
2162  print('committing trg at the end ')
2163  db=dbUtil.dbUtil(session.nominalSchema())
2164  session.transaction().start(False)
2165  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
2166  session.transaction().commit()
2167  except :
2168  print('error in bulkInsertTrgLSData')
2169  raise
Definition: start.py:1
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def bulkInsertTrgLSData(session, runnumber, data_id, trglsdata, bulksize=500)
Definition: dataDML.py:2130
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 1809 of file dataDML.py.

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

1809 def dataentryIdByRun(schema,runnum,branchfilter):
1810  '''
1811  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;
1812  check on entryrev
1813 
1814  return [lumientryid,trgentryid,hltentryid]
1815  '''
1816  result=[]
1817  qHandle=schema.newQuery()
1818  try:
1819  qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() ))
1820  qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() ))
1821  qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() ))
1822  qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid')
1823  qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid')
1824  qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid')
1825  qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr'
1826  qCondition=coral.AttributeList()
1827  qCondition.extend('runnumstr','string')
1828  qCondition['runnumstr'].setData(str(runnum))
1829  qResult=coral.AttributeList()
1830  qResult.extend('lumientryid','unsigned long long')
1831  qResult.extend('trgentryid','unsigned long long')
1832  qResult.extend('hltentryid','unsigned long long')
1833  qHandle.defineOutput(qResult)
1834  qHandle.setCondition(qConditionStr,qCondition)
1835  cursor=qHandle.execute()
1836  while next(cursor):
1837  lumientryid=cursor.currentRow()['lumientryid'].data()
1838  trgentryid=cursor.currentRow()['trgentryid'].data()
1839  hltentryid=cursor.currentRow()['hltentryid'].data()
1840  if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter:
1841  result.extend([lumientryid,trgentryid,hltentryid])
1842  except:
1843  del qHandle
1844  raise
1845  del qHandle
1846  return result
1847 
def entryTableName(dataTableName)
Definition: nameDealer.py:103
def trgdataTableName()
Definition: nameDealer.py:46
def dataentryIdByRun(schema, runnum, branchfilter)
Definition: dataDML.py:1809
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def hltdataTableName()
Definition: nameDealer.py:58
#define str(s)
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 92 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().

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

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

Referenced by lumiCalcAPI.fillrunMap().

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

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

Referenced by lumiCalcAPI.deliveredLumiForIds().

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

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

19 def guesscorrIdByName(schema,tagname=None):
20  '''
21  select data_id from lumicorrectionss [where entry_name=:tagname]
22  result lumicorrectionsdataid
23 
24  '''
25  lumicorrectionids=[]
26  result=None
27  qHandle=schema.newQuery()
28  try:
29  qHandle.addToTableList( nameDealer.lumicorrectionsTableName() )
30  qHandle.addToOutputList('DATA_ID')
31  if tagname:
32  qConditionStr='ENTRY_NAME=:tagname '
33  qCondition=coral.AttributeList()
34  qCondition.extend('tagname','string')
35  qCondition['tagname'].setData(tagname)
36  qResult=coral.AttributeList()
37  qResult.extend('DATA_ID','unsigned long long')
38  qHandle.defineOutput(qResult)
39  if tagname:
40  qHandle.setCondition(qConditionStr,qCondition)
41  cursor=qHandle.execute()
42  while next(cursor):
43  dataid=cursor.currentRow()['DATA_ID'].data()
44  lumicorrectionids.append(dataid)
45  except :
46  del qHandle
47  raise
48  del qHandle
49  if len(lumicorrectionids) !=0:return max(lumicorrectionids)
50  return result
51 
def guesscorrIdByName(schema, tagname=None)
LumiDB DML API # # Author: Zhen Xie #.
Definition: dataDML.py:19
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 1623 of file dataDML.py.

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

Referenced by guessDataIdForRange().

1623 def guessDataIdByRun(schema,runnum,tablename,revfilter=None):
1624  '''
1625  select max data_id of the given run. In current design, it's the most recent data of the run
1626  '''
1627  result=None
1628  ids=[]
1629  qHandle=schema.newQuery()
1630  try:
1631  qHandle.addToTableList(tablename)
1632  qHandle.addToOutputList('DATA_ID')
1633  qConditionStr='RUNNUM=:runnum '
1634  qCondition=coral.AttributeList()
1635  qCondition.extend('runnum','unsigned int')
1636  qCondition['runnum'].setData(runnum)
1637  qResult=coral.AttributeList()
1638  qResult.extend('DATA_ID','unsigned long long')
1639  qHandle.defineOutput(qResult)
1640  qHandle.setCondition(qConditionStr,qCondition)
1641  cursor=qHandle.execute()
1642  while next(cursor):
1643  dataid=cursor.currentRow()['DATA_ID'].data()
1644  ids.append(dataid)
1645  except :
1646  del qHandle
1647  raise
1648  del qHandle
1649  if len(ids)>0 :
1650  return max(ids)
1651  else:
1652  return result
1653 
def guessDataIdByRun(schema, runnum, tablename, revfilter=None)
Definition: dataDML.py:1623
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 1654 of file dataDML.py.

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

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

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

1617 def guessHltDataIdByRunInBranch(schema,runnum,tablename,branchName):
1618  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1619  hltentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1620  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,hltentry_id,revlist)
1621  return latestrevision
1622 
def revisionsInBranchName(schema, branchname)
Definition: revisionDML.py:179
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:190
def guessHltDataIdByRunInBranch(schema, runnum, tablename, branchName)
Definition: dataDML.py:1617
#define str(s)
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)
Definition: revisionDML.py:276
def dataDML.guessLumiDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1605 of file dataDML.py.

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

1605 def guessLumiDataIdByRunInBranch(schema,runnum,tablename,branchName):
1606  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1607  lumientry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1608  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,lumientry_id,revlist)
1609  return latestrevision
1610 
def revisionsInBranchName(schema, branchname)
Definition: revisionDML.py:179
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:190
def guessLumiDataIdByRunInBranch(schema, runnum, tablename, branchName)
Definition: dataDML.py:1605
#define str(s)
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)
Definition: revisionDML.py:276
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 1742 of file dataDML.py.

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

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

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

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

Definition at line 1611 of file dataDML.py.

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

1611 def guessTrgDataIdByRunInBranch(schema,runnum,tablename,branchName):
1612  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1613  trgentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1614  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,trgentry_id,revlist)
1615  return latestrevision
1616 
def revisionsInBranchName(schema, branchname)
Definition: revisionDML.py:179
def entryInBranch(schema, datatableName, entryname, branch)
Definition: revisionDML.py:190
#define str(s)
def guessTrgDataIdByRunInBranch(schema, runnum, tablename, branchName)
Definition: dataDML.py:1611
def latestDataRevisionOfEntry(schema, datatableName, entry, revrange)
Definition: revisionDML.py:276
def dataDML.hltLSById (   schema,
  dataid,
  hltpathname = None,
  hltpathpattern = None,
  withL1Pass = False,
  withHLTAccept = False 
)
result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 

Definition at line 1440 of file dataDML.py.

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

Referenced by lumiCalcAPI.hltForIds().

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

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

Referenced by hltLSById().

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

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

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

1393 def hlttrgMappingByrun(schema,runnum,hltpathname=None,hltpathpattern=None):
1394  '''
1395  select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname]
1396  output: {hltpath:l1seed}
1397  '''
1398  result={}
1399  queryHandle=schema.newQuery()
1402  if hltpathpattern and hltpathpattern in ['*','all','All','ALL']:
1403  hltpathpattern=None
1404  try:
1405  queryHandle.addToTableList(r)
1406  queryHandle.addToTableList(m)
1407  queryCondition=coral.AttributeList()
1408  queryCondition.extend('runnum','unsigned int')
1409  queryCondition['runnum'].setData(int(runnum))
1410  #queryHandle.addToOutputList(m+'.HLTKEY','hltkey')
1411  queryHandle.addToOutputList(m+'.HLTPATHNAME','hltpathname')
1412  queryHandle.addToOutputList(m+'.L1SEED','l1seed')
1413  conditionStr=r+'.RUNNUM=:runnum and '+m+'.HLTKEY='+r+'.HLTKEY'
1414  if hltpathname:
1415  hltpathpattern=None
1416  conditionStr+=' AND '+m+'.HLTPATHNAME=:hltpathname'
1417  queryCondition.extend('hltpathname','string')
1418  queryCondition['hltpathname'].setData(hltpathname)
1419  queryHandle.setCondition(conditionStr,queryCondition)
1420  queryResult=coral.AttributeList()
1421  queryResult.extend('pname','string')
1422  queryResult.extend('l1seed','string')
1423  queryHandle.defineOutput(queryResult)
1424  cursor=queryHandle.execute()
1425  while next(cursor):
1426  pname=cursor.currentRow()['pname'].data()
1427  l1seed=cursor.currentRow()['l1seed'].data()
1428  if hltpathname not in result:
1429  if hltpathpattern:
1430  if fnmatch.fnmatch(pname,hltpathpattern):
1431  result[pname]=l1seed
1432  else:
1433  result[pname]=l1seed
1434  except :
1435  del queryHandle
1436  raise
1437  del queryHandle
1438  return result
1439 
def hlttrgMappingByrun(schema, runnum, hltpathname=None, hltpathpattern=None)
Definition: dataDML.py:1393
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 2058 of file dataDML.py.

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

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

Definition at line 2100 of file dataDML.py.

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

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

Definition at line 1539 of file dataDML.py.

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

Referenced by lumiCalcAPI.deliveredLumiForIds().

1539 def intglumiForRange(schema,runlist):
1540  '''
1541  output: {run:intglumi_in_fb}
1542  '''
1543  result={}
1544  if not runlist:
1545  return result
1546  minrun=min(runlist)
1547  maxrun=max(runlist)
1548  qHandle=schema.newQuery()
1549  try:
1550  qHandle.addToTableList(nameDealer.intglumiv2TableName())
1551  qResult=coral.AttributeList()
1552  qResult.extend('RUNNUM','unsigned int')
1553  qResult.extend('INTGLUMI','float')
1554  qConditionStr='RUNNUM>=:minrun AND RUNNUM<=:maxrun'
1555  qCondition=coral.AttributeList()
1556  qCondition.extend('minrun','unsigned int')
1557  qCondition.extend('maxrun','unsigned int')
1558  qCondition['minrun'].setData(minrun)
1559  qCondition['maxrun'].setData(maxrun)
1560  qHandle.addToOutputList('RUNNUM')
1561  qHandle.addToOutputList('INTGLUMI')
1562  qHandle.setCondition(qConditionStr,qCondition)
1563  qHandle.defineOutput(qResult)
1564  cursor=qHandle.execute()
1565  while next(cursor):
1566  runnum=cursor.currentRow()['RUNNUM'].data()
1567  intglumi=cursor.currentRow()['INTGLUMI'].data()
1568  result[runnum]=intglumi
1569  except :
1570  del qHandle
1571  raise
1572  del qHandle
1573  return result
1574 
def intglumiForRange(schema, runlist)
Definition: dataDML.py:1539
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 1848 of file dataDML.py.

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

1848 def latestdataIdByEntry(schema,entryid,datatype,branchfilter):
1849  '''
1850  select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid
1851  check revision_id is in branch
1852  '''
1853  dataids=[]
1854  datatablename=''
1855  revmaptablename=''
1856  if datatype=='lumi':
1857  datatablename=nameDealer.lumidataTableName()
1858  elif datatype=='trg':
1859  datatablename=nameDealer.trgdataTableName()
1860  elif dataytpe=='hlt':
1861  tablename=nameDealer.hltdataTableName()
1862  else:
1863  raise RunTimeError('datatype '+datatype+' is not supported')
1864  revmaptablename=nameDealer.revmapTableName(datatablename)
1865  qHandle=schema.newQuery()
1866  try:
1867  qHandle.addToTableList(revmaptablename)
1868  qHandle.addToTableList(datatablename)
1869  qHandle.addToOutputList('l.DATA_ID','dataid')
1870  qHandle.addToOutputList(revmaptablename+'.REVISION_ID','revisionid')
1871  qConditionStr=datatablename+'.DATA_ID='+revmaptablename+'.DATA_ID AND '+datatablename+'.ENTRY_ID=:entryid'
1872  qCondition=coral.AttributeList()
1873  qCondition.extend('entryid','unsigned long long')
1874  qResult=coral.AttributeList()
1875  qResult.extend('dataid','unsigned long long')
1876  qResult.extend('revisionid','unsigned long long')
1877  qHandle.defineOutput(qResult)
1878  qHandle.setCondition(qConditionStr,qCondition)
1879  cursor=qHandle.execute()
1880  while next(cursor):
1881  dataid=cursor.currentRow()['dataid'].data()
1882  revisionid=cursor.currentRow()['revisionid'].data()
1883  if revisionid in branchfilter:
1884  dataids.append(dataid)
1885  except:
1886  del qHandle
1887  raise
1888  del qHandle
1889  if len(dataids)!=0:return max(dataids)
1890  return None
1891 
1892 
1893 #=======================================================
1894 # INSERT requires in update transaction
1895 #=======================================================
def latestdataIdByEntry(schema, entryid, datatype, branchfilter)
Definition: dataDML.py:1848
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 1286 of file dataDML.py.

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

1286 def lumiBXByAlgo(schema,dataid,algoname):
1287  '''
1288  result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
1289  '''
1290  result={}
1291  qHandle=schema.newQuery()
1292  try:
1293  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
1294  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
1295  qHandle.addToOutputList('LUMILSNUM','lumilsnum')
1296  #qHandle.addToOutputList('ALGONAME','algoname')
1297  qHandle.addToOutputList('NUMORBIT','numorbit')
1298  qHandle.addToOutputList('STARTORBIT','startorbit')
1299  qHandle.addToOutputList('BXLUMIVALUE_'+algoname,'bxlumivalue')
1300  qHandle.addToOutputList('BXLUMIERROR_'+algoname,'bxlumierr')
1301  qHandle.addToOutputList('BXLUMIQUALITY_'+algoname,'bxlumiqlty')
1302  qConditionStr='DATA_ID=:dataid'
1303  qCondition=coral.AttributeList()
1304  qCondition.extend('dataid','unsigned long long')
1305  qCondition['dataid'].setData(dataid)
1306  qResult=coral.AttributeList()
1307  qResult.extend('cmslsnum','unsigned int')
1308  qResult.extend('lumilsnum','unsigned int')
1309  qResult.extend('numorbit','unsigned int')
1310  qResult.extend('startorbit','unsigned int')
1311  qResult.extend('bxlumivalue','blob')
1312  qResult.extend('bxlumierr','blob')
1313  qResult.extend('bxlumiqlty','blob')
1314  qHandle.defineOutput(qResult)
1315  qHandle.setCondition(qConditionStr,qCondition)
1316  cursor=qHandle.execute()
1317  while next(cursor):
1318  cmslsnum=cursor.currentRow()['cmslsnum'].data()
1319  lumilsnum=cursor.currentRow()['lumilsnum'].data()
1320  numorbit=cursor.currentRow()['numorbit'].data()
1321  startorbit=cursor.currentRow()['startorbit'].data()
1322  bxlumivalue=cursor.currentRow()['bxlumivalue'].data()
1323  bxlumierr=cursor.currentRow()['bxlumierr'].data()
1324  bxlumiqlty=cursor.currentRow()['bxlumiqlty'].data()
1325  if algoname not in result:
1326  result[algoname]={}
1327  if lumilsnum not in result[algoname]:
1328  result[algoname][lumilsnum]=[]
1329  result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
1330  except :
1331  del qHandle
1332  raise RuntimeError(' dataDML.lumiBXById: '+str(e))
1333  del qHandle
1334  return result
1335 
def lumisummaryv2TableName()
Definition: nameDealer.py:28
def lumiBXByAlgo(schema, dataid, algoname)
Definition: dataDML.py:1286
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
#define str(s)
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 52 of file dataDML.py.

References data, and GetRecoTauVFromDQM_MC_cff.next.

52 def lumicorrById(schema,correctiondataid):
53  '''
54  select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid
55  output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))}
56  '''
57  result=None
58  qHandle=schema.newQuery()
59  try:
60  qHandle.addToTableList(nameDealer.lumicorrectionsTableName())
61  qHandle.addToOutputList('ENTRY_NAME')
62  qHandle.addToOutputList('A1')
63  qHandle.addToOutputList('A2')
64  qHandle.addToOutputList('DRIFT')
65  qCondition=coral.AttributeList()
66  qCondition.extend('dataid','unsigned long long')
67  qCondition['dataid'].setData(correctiondataid)
68  qResult=coral.AttributeList()
69  qResult.extend('ENTRY_NAME','string')
70  qResult.extend('A1','float')
71  qResult.extend('A2','float')
72  qResult.extend('DRIFT','float')
73  qHandle.defineOutput(qResult)
74  qHandle.setCondition('DATA_ID=:dataid',qCondition)
75  cursor=qHandle.execute()
76  while next(cursor):
77  tagname=cursor.currentRow()['ENTRY_NAME'].data()
78  a1=cursor.currentRow()['A1'].data()
79  a2=0.0
80  if cursor.currentRow()['A2'].data():
81  a2=cursor.currentRow()['A2'].data()
82  drift=0.0
83  if cursor.currentRow()['DRIFT'].data():
84  drift=cursor.currentRow()['DRIFT'].data()
85  result={tagname:(correctiondataid,a1,a2,drift)}
86  except :
87  del qHandle
88  raise
89  del qHandle
90  return result
91 
def lumicorrById(schema, correctiondataid)
Definition: dataDML.py:52
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 1088 of file dataDML.py.

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

Referenced by lumiCalcAPI.instLumiForIds().

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

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

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

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

Referenced by lumiRunByIds().

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

References lumiRunById().

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

907 def lumiRunByIds(schema,dataidMap,lumitype='HF'):
908  '''
909  input dataidMap : {run:lumidataid}
910  result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)}
911  '''
912  result={}
913  if not dataidMap:
914  return result
915  inputRange=dataidMap.keys()
916  for r in inputRange:
917  lumidataid=dataidMap[r][0]
918  if lumidataid:
919  perrundata=lumiRunById(schema,lumidataid,lumitype=lumitype)
920  result[r]=(perrundata[1],perrundata[2],perrundata[3],perrundata[4],perrundata[5])
921  return result
922 
def lumiRunById(schema, lumidataid, lumitype='HF')
Definition: dataDML.py:963
def lumiRunByIds(schema, dataidMap, lumitype='HF')
Definition: dataDML.py:907
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 243 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().

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

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

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

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

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

Referenced by lumiCalcAPI.trgForIds().

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

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

Referenced by trgLSById().

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

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

dataDML.branchinfo

Definition at line 2358 of file dataDML.py.

Referenced by TrackerMap.TrackerMap().

dataDML.branchparent

Definition at line 2357 of file dataDML.py.

dataDML.comment

Definition at line 2344 of file dataDML.py.

dataDML.cpp2sqltype

Definition at line 2336 of file dataDML.py.

dataDML.datainfo

Definition at line 2346 of file dataDML.py.

dataDML.debugON

Definition at line 2335 of file dataDML.py.

dataDML.False

Definition at line 2336 of file dataDML.py.

dataDML.hltdata

Definition at line 2374 of file dataDML.py.

Referenced by LumiSummary.~LumiSummary().

dataDML.hltdataid

Definition at line 2377 of file dataDML.py.

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

dataDML.hltentryid

Definition at line 2377 of file dataDML.py.

dataDML.hltlsdata

Definition at line 2376 of file dataDML.py.

dataDML.hltrevid

Definition at line 2377 of file dataDML.py.

dataDML.hltrundata
dataDML.hlttrgmap

Definition at line 2362 of file dataDML.py.

dataDML.isReadOnly
dataDML.latestNorms

Definition at line 2385 of file dataDML.py.

dataDML.latestrevision

Definition at line 2393 of file dataDML.py.

dataDML.lumidataid

Definition at line 2367 of file dataDML.py.

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

dataDML.lumidummydata

Definition at line 2364 of file dataDML.py.

dataDML.lumientry_id

Definition at line 2392 of file dataDML.py.

dataDML.lumientryid

Definition at line 2367 of file dataDML.py.

dataDML.lumilsdata

Definition at line 2366 of file dataDML.py.

dataDML.luminormentry_id

Definition at line 2384 of file dataDML.py.

dataDML.lumirevid

Definition at line 2367 of file dataDML.py.

dataDML.lumirundata
dataDML.myconstr

Definition at line 2334 of file dataDML.py.

dataDML.None

Definition at line 2344 of file dataDML.py.

dataDML.normbranchid

Definition at line 2353 of file dataDML.py.

dataDML.normbranchinfo

Definition at line 2354 of file dataDML.py.

dataDML.normbranchparent

Definition at line 2353 of file dataDML.py.

dataDML.norminfo

Definition at line 2348 of file dataDML.py.

dataDML.normrevlist

Definition at line 2383 of file dataDML.py.

dataDML.parentid

Definition at line 2404 of file dataDML.py.

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

dataDML.parentname

Definition at line 2404 of file dataDML.py.

dataDML.revisionid

Definition at line 2404 of file dataDML.py.

dataDML.revlist

Definition at line 2390 of file dataDML.py.

dataDML.runsummarydata

Definition at line 2360 of file dataDML.py.

dataDML.schema

Definition at line 2337 of file dataDML.py.

Referenced by 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.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(), cond::CredentialStore.resetAdmin(), 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 2336 of file dataDML.py.

Referenced by LumiProducer.beginRun(), popcon::PopConBTransitionSourceHandler< T >.checkBOn(), popcon::PopConESTransitionSourceHandler< T >.checkLowGain(), 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(), popcon::PopConESTransitionSourceHandler< T >.getObjectsForESTransition(), cond::CredentialStore.importForPrincipal(), 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(), cond::CredentialStore.resetAdmin(), 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::DataWriter.writeKeyList(), and l1t::DataWriterExt.writeKeyList().

dataDML.svc
dataDML.tables

Definition at line 2341 of file dataDML.py.

Referenced by NanoAODDQM.analyze().

dataDML.trgdata

Definition at line 2369 of file dataDML.py.

dataDML.trgdataid

Definition at line 2372 of file dataDML.py.

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

dataDML.trgentry_id

Definition at line 2398 of file dataDML.py.

dataDML.trgentryid

Definition at line 2372 of file dataDML.py.

dataDML.trglsdata

Definition at line 2371 of file dataDML.py.

dataDML.trgrevid

Definition at line 2372 of file dataDML.py.

dataDML.trgrundata
dataDML.trunkinfo

Definition at line 2344 of file dataDML.py.

dataDML.withblobdata

Definition at line 2448 of file dataDML.py.