CMS 3D CMS Logo

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

Functions

def addCorrToBranch
 
def addHLTRunDataToBranch
 
def addLumiRunDataToBranch
 
def addNormToBranch
 
def addTrgRunDataToBranch
 
def allfillschemes
 
def beamInfoById
 
def beamstatusByIds
 
def bulkInsertHltLSData
 
def bulkInsertLumiLSSummary
 
def bulkInsertTrgLSData
 
def dataentryIdByRun
 
def fillInRange
 
def fillrunMap
 
def fillschemePatternMap
 
def guesscorrIdByName
 LumiDB DML API # # Author: Zhen Xie #. More...
 
def guessDataIdByRun
 
def guessDataIdForRange
 
def guessHltDataIdByRunInBranch
 
def guessLumiDataIdByRunInBranch
 
def guessnormIdByContext
 
def guessnormIdByName
 
def guessTrgDataIdByRunInBranch
 
def hltLSById
 
def hltRunById
 
def hlttrgMappingByrun
 
def insertRunSummaryData
 
def insertTrgHltMap
 
def intglumiForRange
 
def latestdataIdByEntry
 
def lumiBXByAlgo
 
def lumicorrById
 
def lumiLSById
 
def luminormById
 
def lumiRunById
 
def lumiRunByIds
 
def runList
 
def runsummary
 
def trgLSById
 
def trgRunById
 

Variables

tuple branchinfo = (branchid,'DATA')
 
tuple datainfo = revisionDML.createBranch(schema,'DATA','TRUNK',comment='hold data')
 
tuple hltdata = generateDummyData.hlt(schema,20)
 
list hltlsdata = hltdata[2]
 
list hltrundata = [hltdata[0],hltdata[1]]
 
tuple hlttrgmap = generateDummyData.hlttrgmap(schema)
 
tuple latestNorms = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.luminormTableName(),luminormentry_id,normrevlist)
 
tuple latestrevision = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist)
 
tuple lumidummydata = generateDummyData.lumiSummary(schema,20)
 
tuple lumientry_id = revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA')
 
list lumilsdata = lumidummydata[1]
 
tuple luminormentry_id = revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),'pp7TeV','NORM')
 
list lumirundata = [lumidummydata[0]]
 
string myconstr = 'oracle://devdb10/cms_xiezhen_dev'
 
tuple normbranchinfo = (normbranchid,'NORM')
 
tuple norminfo = revisionDML.createBranch(schema,'NORM','TRUNK',comment='hold normalization factor')
 
tuple normrevlist = revisionDML.revisionsInBranchName(schema,'NORM')
 
tuple revlist = revisionDML.revisionsInBranchName(schema,'DATA')
 
tuple runsummarydata = generateDummyData.runsummary(schema,'PROTPHYS',3500)
 
tuple schema = session.nominalSchema()
 
tuple session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
 
tuple svc = sessionManager.sessionManager(myconstr,authpath='/afs/cern.ch/user/x/xiezhen',debugON=False)
 
tuple tables = lumidbDDL.createTables(schema)
 
tuple trgdata = generateDummyData.trg(schema,20)
 
tuple trgentry_id = revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),'1222','DATA')
 
list trglsdata = trgdata[3]
 
list trgrundata = [trgdata[0],trgdata[1],trgdata[2]]
 
tuple trunkinfo = revisionDML.createBranch(schema,'TRUNK',None,comment='main')
 

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

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

1923 def addCorrToBranch(schema,corrname,a1,optionalcorrdata,branchinfo):
1924  '''
1925  input:
1926  branchinfo(corrrevisionid,branchname)
1927  optionalcorrdata {'a2':a2,'drift':drif}
1928  output:
1929  (revision_id,entry_id,data_id)
1930  '''
1931  a2=1.0
1932  if optionalcorrdata.has_key('a2'):
1933  a2=optionalcorrdata['a2']
1934  drift=1.0
1935  if optionalcorrdata.has_key('drift'):
1936  drift=optionalcorrdata['drift']
1937  try:
1938  entry_id=revisionDML.entryInBranch(schema,nameDealer.lumicorrectionsTableName(),corrname,branchinfo[1])
1939  if entry_id is None:
1940  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.lumicorrectionsTableName())
1941  entryinfo=(revision_id,entry_id,corrname,data_id)
1942  revisionDML.addEntry(schema,nameDealer.lumicorrectionsTableName(),entryinfo,branchinfo)
1943  else:
1944  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.lumicorrectionsTableName() )
1945  revisionDML.addRevision(schema,nameDealer.lumicorrectionsTableName(),(revision_id,data_id),branchinfo)
1946  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','A1':'float','A2':'float','DRIFT':'float'}
1947  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':corrname,'A1':a1,'A2':a2,'DRIFT':drift}
1948  db=dbUtil.dbUtil(schema)
1949  db.insertOneRow(nameDealer.lumicorrectionsTableName(),tabrowDefDict,tabrowValueDict)
1950  return (revision_id,entry_id,data_id)
1951  except :
1952  raise
def bookNewRevision
Definition: revisionDML.py:330
def bookNewEntry
Definition: revisionDML.py:316
def addCorrToBranch
Definition: dataDML.py:1922
def entryInBranch
Definition: revisionDML.py:188
def dataDML.addHLTRunDataToBranch (   schema,
  runnumber,
  hltrundata,
  branchinfo 
)
input:
    hltrundata [pathnameclob(0),datasource(1)]
output:
    (revision_id,entry_id,data_id)

Definition at line 2019 of file dataDML.py.

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

2020 def addHLTRunDataToBranch(schema,runnumber,hltrundata,branchinfo):
2021  '''
2022  input:
2023  hltrundata [pathnameclob(0),datasource(1)]
2024  output:
2025  (revision_id,entry_id,data_id)
2026  '''
2027  try:
2028  pathnames=hltrundata[0]
2029  datasource=hltrundata[1]
2030  npath=len(pathnames.split(','))
2031  entry_id=revisionDML.entryInBranch(schema,nameDealer.hltdataTableName(),str(runnumber),branchinfo[1])
2032  if entry_id is None:
2033  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName())
2034  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
2035  revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo)
2036  else:
2037  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() )
2038  revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo)
2039  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'}
2040  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames}
2041  db=dbUtil.dbUtil(schema)
2042  db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict)
2043  return (revision_id,entry_id,data_id)
2044  except :
2045  raise
def hltdataTableName
Definition: nameDealer.py:58
def bookNewRevision
Definition: revisionDML.py:330
def bookNewEntry
Definition: revisionDML.py:316
def entryInBranch
Definition: revisionDML.py:188
def addHLTRunDataToBranch
Definition: dataDML.py:2019
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 1953 of file dataDML.py.

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

1954 def addLumiRunDataToBranch(schema,runnumber,lumirundata,branchinfo,tableName):
1955  '''
1956  input:
1957  lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls]
1958  branchinfo (branch_id,branch_name)
1959  tableName lumiruntablename
1960  output:
1961  (revision_id,entry_id,data_id)
1962  '''
1963  try:
1964  datasource=lumirundata[0]
1965  nominalegev=3500.0
1966  ncollidingbunches=0
1967  starttime=coral.TimeStamp()
1968  stoptime=coral.TimeStamp()
1969  nls=0
1970  if len(lumirundata)>1:
1971  nominalenergy=lumirundata[1]
1972  ncollidingbunches=lumirundata[2]
1973  starttime=lumirundata[3]
1974  stoptime=lumirundata[4]
1975  nls=lumirundata[5]
1976  entry_id=revisionDML.entryInBranch(schema,tableName,str(runnumber),branchinfo[1])
1977  if entry_id is None:
1978  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,tableName)
1979  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
1980  revisionDML.addEntry(schema,tableName,entryinfo,branchinfo)
1981  else:
1982  (revision_id,data_id)=revisionDML.bookNewRevision(schema,tableName)
1983  #print 'revision_id,data_id ',revision_id,data_id
1984  revisionDML.addRevision(schema,tableName,(revision_id,data_id),branchinfo)
1985  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'}
1986  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}
1987  db=dbUtil.dbUtil(schema)
1988  db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
1989  return (revision_id,entry_id,data_id)
1990  except :
1991  raise
def addLumiRunDataToBranch
Definition: dataDML.py:1953
def bookNewRevision
Definition: revisionDML.py:330
def bookNewEntry
Definition: revisionDML.py:316
def entryInBranch
Definition: revisionDML.py:188
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 1884 of file dataDML.py.

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

1885 def addNormToBranch(schema,normname,amodetag,norm1,egev1,optionalnormdata,branchinfo):
1886  '''
1887  input:
1888  branchinfo(normrevisionid,branchname)
1889  optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
1890  output:
1891  (revision_id,entry_id,data_id)
1892  '''
1893  #print 'branchinfo ',branchinfo
1894  norm_occ2=1.0
1895  if optionalnormdata.has_key('normOcc2'):
1896  norm_occ2=optionalnormdata['norm_occ2']
1897  norm_et=1.0
1898  if optionalnormdata.has_key('norm_et'):
1899  norm_et=optionalnormdata['norm_et']
1900  norm_pu=1.0
1901  if optionalnormdata.has_key('norm_pu'):
1902  norm_pu=optionalnormdata['norm_pu']
1903  constfactor=1.0
1904  if optionalnormdata.has_key('constfactor'):
1905  constfactor=optionalnormdata['constfactor']
1906  try:
1907  entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1])
1908  if entry_id is None:
1909  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName())
1910  entryinfo=(revision_id,entry_id,normname,data_id)
1911  revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo)
1912  else:
1913  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() )
1914  revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo)
1915  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'}
1916  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}
1917  db=dbUtil.dbUtil(schema)
1918  db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict)
1919  return (revision_id,entry_id,data_id)
1920  except :
1921  raise
def bookNewRevision
Definition: revisionDML.py:330
def luminormTableName
Definition: nameDealer.py:37
def bookNewEntry
Definition: revisionDML.py:316
def addNormToBranch
Definition: dataDML.py:1884
def entryInBranch
Definition: revisionDML.py:188
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 1992 of file dataDML.py.

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

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

Definition at line 1054 of file dataDML.py.

References data, and nameDealer.fillschemeTableName().

1055 def allfillschemes(schema):
1056  afterglows=[]
1058  try:
1059  qHandle.addToTableList(s)
1060  qResult=coral.AttributeList()
1061  qResult.extend('FILLSCHEMEPATTERN','string')
1062  qResult.extend('CORRECTIONFACTOR','float')
1063  qHandle.defineOutput(qResult)
1064  qHandle.addToOutputList('FILLSCHEMEPATTERN')
1065  qHandle.addToOutputList('CORRECTIONFACTOR')
1066  cursor=qHandle.execute()
1067  while cursor.next():
1068  fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
1069  afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
1070  afterglows.append((fillschemePattern,afterglowfac))
1071  except :
1072  del qHandle
1073  raise
1074  del qHandle
1075  return afterglows
def allfillschemes
Definition: dataDML.py:1054
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 1183 of file dataDML.py.

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

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

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

Definition at line 911 of file dataDML.py.

References data, and nameDealer.lumisummaryv2TableName().

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

References nameDealer.lshltTableName().

2159 def bulkInsertHltLSData(session,runnumber,data_id,hltlsdata,bulksize=500):
2160  '''
2161  input:
2162  hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
2163  '''
2164  print 'total number of hlt rows ',len(hltlsdata)
2165  lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')]
2166  committedrows=0
2167  nrows=0
2168  bulkvalues=[]
2169  try:
2170  for cmslsnum,perlshlt in hltlsdata.items():
2171  inputcountblob=perlshlt[0]
2172  acceptcountblob=perlshlt[1]
2173  prescaleblob=perlshlt[2]
2174  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)])
2175 
2176  nrows+=1
2177  committedrows+=1
2178  if nrows==bulksize:
2179  print 'committing hlt in LS chunck ',nrows
2180  db=dbUtil.dbUtil(session.nominalSchema())
2181  session.transaction().start(False)
2182  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
2183  session.transaction().commit()
2184  nrows=0
2185  bulkvalues=[]
2186  elif committedrows==len(hltlsdata):
2187  print 'committing hlt at the end '
2188  db=dbUtil.dbUtil(session.nominalSchema())
2189  session.transaction().start(False)
2190  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
2191  session.transaction().commit()
2192  except :
2193  print 'error in bulkInsertHltLSData'
2194  raise
Definition: start.py:1
def bulkInsertHltLSData
Definition: dataDML.py:2158
def lshltTableName
Definition: nameDealer.py:61
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 2195 of file dataDML.py.

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

References nameDealer.lstrgTableName().

2119 def bulkInsertTrgLSData(session,runnumber,data_id,trglsdata,bulksize=500):
2120  '''
2121  insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks
2122  input:
2123  trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
2124  result nrows inserted
2125  if nrows==0, then this insertion failed
2126  '''
2127  print 'total number of trg rows ',len(trglsdata)
2128  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')]
2129  committedrows=0
2130  nrows=0
2131  bulkvalues=[]
2132  try:
2133  for cmslsnum,perlstrg in trglsdata.items():
2134  deadtimecount=perlstrg[0]
2135  bitzerocount=perlstrg[1]
2136  bitzeroprescale=perlstrg[2]
2137  trgcountblob=perlstrg[3]
2138  trgprescaleblob=perlstrg[4]
2139  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)])
2140  nrows+=1
2141  committedrows+=1
2142  if nrows==bulksize:
2143  print 'committing trg in LS chunck ',nrows
2144  db=dbUtil.dbUtil(session.nominalSchema())
2145  session.transaction().start(False)
2146  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
2147  session.transaction().commit()
2148  nrows=0
2149  bulkvalues=[]
2150  elif committedrows==len(trglsdata):
2151  print 'committing trg at the end '
2152  db=dbUtil.dbUtil(session.nominalSchema())
2153  session.transaction().start(False)
2154  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
2155  session.transaction().commit()
2156  except :
2157  print 'error in bulkInsertTrgLSData'
raise
def bulkInsertTrgLSData
Definition: dataDML.py:2118
Definition: start.py:1
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 1797 of file dataDML.py.

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

1798 def dataentryIdByRun(schema,runnum,branchfilter):
1799  '''
1800  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;
1801  check on entryrev
1802 
1803  return [lumientryid,trgentryid,hltentryid]
1804  '''
1805  result=[]
1806  qHandle=schema.newQuery()
1807  try:
1808  qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() ))
1809  qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() ))
1810  qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() ))
1811  qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid')
1812  qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid')
1813  qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid')
1814  qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr'
1815  qCondition=coral.AttributeList()
1816  qCondition.extend('runnumstr','string')
1817  qCondition['runnumstr'].setData(str(runnum))
1818  qResult=coral.AttributeList()
1819  qResult.extend('lumientryid','unsigned long long')
1820  qResult.extend('trgentryid','unsigned long long')
1821  qResult.extend('hltentryid','unsigned long long')
1822  qHandle.defineOutput(qResult)
1823  qHandle.setCondition(qConditionStr,qCondition)
1824  cursor=qHandle.execute()
1825  while cursor.next():
1826  lumientryid=cursor.currentRow()['lumientryid'].data()
1827  trgentryid=cursor.currentRow()['trgentryid'].data()
1828  hltentryid=cursor.currentRow()['hltentryid'].data()
1829  if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter:
1830  result.extend([lumientryid,trgentryid,hltentryid])
1831  except:
1832  del qHandle
1833  raise
1834  del qHandle
1835  return result
def trgdataTableName
Definition: nameDealer.py:46
def hltdataTableName
Definition: nameDealer.py:58
def entryTableName
Definition: nameDealer.py:103
def lumidataTableName
Definition: nameDealer.py:19
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def dataentryIdByRun
Definition: dataDML.py:1797
def dataDML.fillInRange (   schema,
  fillmin,
  fillmax,
  amodetag,
  startT,
  stopT 
)
select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag]
output: [fill]

Definition at line 89 of file dataDML.py.

References python.multivaluedict.append(), nameDealer.cmsrunsummaryTableName(), data, and join().

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

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

Definition at line 160 of file dataDML.py.

References python.multivaluedict.append(), nameDealer.cmsrunsummaryTableName(), data, and join().

Referenced by lumiCalcAPI.fillrunMap().

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

References data, and nameDealer.fillschemeTableName().

Referenced by lumiCalcAPI.deliveredLumiForIds().

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

LumiDB DML API # # Author: Zhen Xie #.

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

Definition at line 16 of file dataDML.py.

References data, and max().

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

References data, and max().

Referenced by guessDataIdForRange().

1612 def guessDataIdByRun(schema,runnum,tablename,revfilter=None):
1613  '''
1614  select max data_id of the given run. In current design, it's the most recent data of the run
1615  '''
1616  result=None
1617  ids=[]
1618  qHandle=schema.newQuery()
1619  try:
1620  qHandle.addToTableList(tablename)
1621  qHandle.addToOutputList('DATA_ID')
1622  qConditionStr='RUNNUM=:runnum '
1623  qCondition=coral.AttributeList()
1624  qCondition.extend('runnum','unsigned int')
1625  qCondition['runnum'].setData(runnum)
1626  qResult=coral.AttributeList()
1627  qResult.extend('DATA_ID','unsigned long long')
1628  qHandle.defineOutput(qResult)
1629  qHandle.setCondition(qConditionStr,qCondition)
1630  cursor=qHandle.execute()
1631  while cursor.next():
1632  dataid=cursor.currentRow()['DATA_ID'].data()
1633  ids.append(dataid)
1634  except :
1635  del qHandle
1636  raise
1637  del qHandle
1638  if len(ids)>0 :
1639  return max(ids)
1640  else:
1641  return result
const T & max(const T &a, const T &b)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def guessDataIdByRun
Definition: dataDML.py:1611
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 1642 of file dataDML.py.

References data, guessDataIdByRun(), max(), and min.

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

Definition at line 1605 of file dataDML.py.

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

1606 def guessHltDataIdByRunInBranch(schema,runnum,tablename,branchName):
1607  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1608  hltentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1609  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,hltentry_id,revlist)
1610  return latestrevision
def revisionsInBranchName
Definition: revisionDML.py:177
def entryInBranch
Definition: revisionDML.py:188
def guessHltDataIdByRunInBranch
Definition: dataDML.py:1605
def latestDataRevisionOfEntry
Definition: revisionDML.py:274
def dataDML.guessLumiDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1593 of file dataDML.py.

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

1594 def guessLumiDataIdByRunInBranch(schema,runnum,tablename,branchName):
1595  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1596  lumientry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1597  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,lumientry_id,revlist)
1598  return latestrevision
def guessLumiDataIdByRunInBranch
Definition: dataDML.py:1593
def revisionsInBranchName
Definition: revisionDML.py:177
def entryInBranch
Definition: revisionDML.py:188
def latestDataRevisionOfEntry
Definition: revisionDML.py:274
def dataDML.guessnormIdByContext (   schema,
  amodetag,
  egev1 
)
get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1   

Definition at line 1730 of file dataDML.py.

References data, nameDealer.luminormTableName(), and max().

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

References data, nameDealer.luminormTableName(), and max().

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

Definition at line 1599 of file dataDML.py.

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

1600 def guessTrgDataIdByRunInBranch(schema,runnum,tablename,branchName):
1601  revlist=revisionDML.revisionsInBranchName(schema,branchName)
1602  trgentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
1603  latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,trgentry_id,revlist)
1604  return latestrevision
def revisionsInBranchName
Definition: revisionDML.py:177
def guessTrgDataIdByRunInBranch
Definition: dataDML.py:1599
def entryInBranch
Definition: revisionDML.py:188
def latestDataRevisionOfEntry
Definition: revisionDML.py:274
def dataDML.hltLSById (   schema,
  dataid,
  hltpathname = None,
  hltpathpattern = None,
  withL1Pass = False,
  withHLTAccept = False 
)
result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 

Definition at line 1428 of file dataDML.py.

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

Referenced by lumiCalcAPI.hltForIds().

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

References data, and nameDealer.hltdataTableName().

Referenced by hltLSById().

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

References nameDealer.cmsrunsummaryTableName(), data, and nameDealer.trghltMapTableName().

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

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

Definition at line 2046 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName().

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

Definition at line 2088 of file dataDML.py.

References nameDealer.trghltMapTableName().

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

Definition at line 1527 of file dataDML.py.

References data, nameDealer.intglumiv2TableName(), max(), and min.

Referenced by lumiCalcAPI.deliveredLumiForIds().

1528 def intglumiForRange(schema,runlist):
1529  '''
1530  output: {run:intglumi_in_fb}
1531  '''
1532  result={}
1533  if not runlist:
1534  return result
1535  minrun=min(runlist)
1536  maxrun=max(runlist)
1537  qHandle=schema.newQuery()
1538  try:
1539  qHandle.addToTableList(nameDealer.intglumiv2TableName())
1540  qResult=coral.AttributeList()
1541  qResult.extend('RUNNUM','unsigned int')
1542  qResult.extend('INTGLUMI','float')
1543  qConditionStr='RUNNUM>=:minrun AND RUNNUM<=:maxrun'
1544  qCondition=coral.AttributeList()
1545  qCondition.extend('minrun','unsigned int')
1546  qCondition.extend('maxrun','unsigned int')
1547  qCondition['minrun'].setData(minrun)
1548  qCondition['maxrun'].setData(maxrun)
1549  qHandle.addToOutputList('RUNNUM')
1550  qHandle.addToOutputList('INTGLUMI')
1551  qHandle.setCondition(qConditionStr,qCondition)
1552  qHandle.defineOutput(qResult)
1553  cursor=qHandle.execute()
1554  while cursor.next():
1555  runnum=cursor.currentRow()['RUNNUM'].data()
1556  intglumi=cursor.currentRow()['INTGLUMI'].data()
1557  result[runnum]=intglumi
1558  except :
1559  del qHandle
1560  raise
1561  del qHandle
1562  return result
def intglumiv2TableName
Definition: nameDealer.py:91
#define min(a, b)
Definition: mlp_lapack.h:161
const T & max(const T &a, const T &b)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
def intglumiForRange
Definition: dataDML.py:1527
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 1836 of file dataDML.py.

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

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

Definition at line 1274 of file dataDML.py.

References data, and nameDealer.lumisummaryv2TableName().

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

Definition at line 49 of file dataDML.py.

References data.

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

Definition at line 1076 of file dataDML.py.

References data, nameDealer.lumisummaryv2TableName(), and CommonUtil.unpackBlobtoArray().

Referenced by lumiCalcAPI.instLumiForIds().

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

References data, and nameDealer.luminormTableName().

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

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

Referenced by lumiRunByIds().

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

References lumiRunById().

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

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

Definition at line 240 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName(), data, nameDealer.hltdataTableName(), nameDealer.lumidataTableName(), nameDealer.pixellumidataTableName(), nameDealer.pixeltagRunsTableName(), nameDealer.tagRunsTableName(), and nameDealer.trgdataTableName().

Referenced by lumiCalcAPI.runList().

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

References nameDealer.cmsrunsummaryTableName(), and data.

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

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

References python.multivaluedict.append(), data, nameDealer.lstrgTableName(), trgRunById(), and CommonUtil.unpackBlobtoArray().

Referenced by lumiCalcAPI.trgForIds().

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

References data, and nameDealer.trgdataTableName().

Referenced by trgLSById().

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

Variable Documentation

tuple dataDML.branchinfo = (branchid,'DATA')

Definition at line 2346 of file dataDML.py.

Referenced by TrackerMap.TrackerMap().

tuple dataDML.datainfo = revisionDML.createBranch(schema,'DATA','TRUNK',comment='hold data')

Definition at line 2334 of file dataDML.py.

tuple dataDML.hltdata = generateDummyData.hlt(schema,20)

Definition at line 2362 of file dataDML.py.

list dataDML.hltlsdata = hltdata[2]

Definition at line 2364 of file dataDML.py.

list dataDML.hltrundata = [hltdata[0],hltdata[1]]

Definition at line 2363 of file dataDML.py.

Referenced by lumi::RevisionDML.insertHltRunData(), and lumi::HLTV32DB.writeHltDataToSchema2().

tuple dataDML.hlttrgmap = generateDummyData.hlttrgmap(schema)

Definition at line 2350 of file dataDML.py.

tuple dataDML.latestNorms = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.luminormTableName(),luminormentry_id,normrevlist)

Definition at line 2373 of file dataDML.py.

tuple dataDML.latestrevision = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist)

Definition at line 2381 of file dataDML.py.

tuple dataDML.lumidummydata = generateDummyData.lumiSummary(schema,20)

Definition at line 2352 of file dataDML.py.

tuple dataDML.lumientry_id = revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA')

Definition at line 2380 of file dataDML.py.

list dataDML.lumilsdata = lumidummydata[1]

Definition at line 2354 of file dataDML.py.

tuple dataDML.luminormentry_id = revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),'pp7TeV','NORM')

Definition at line 2372 of file dataDML.py.

list dataDML.lumirundata = [lumidummydata[0]]

Definition at line 2353 of file dataDML.py.

Referenced by lumi::RevisionDML.insertLumiRunData(), and lumi::Lumi2DB.writeAllLumiDataToSchema2().

string dataDML.myconstr = 'oracle://devdb10/cms_xiezhen_dev'

Definition at line 2322 of file dataDML.py.

tuple dataDML.normbranchinfo = (normbranchid,'NORM')

Definition at line 2342 of file dataDML.py.

tuple dataDML.norminfo = revisionDML.createBranch(schema,'NORM','TRUNK',comment='hold normalization factor')

Definition at line 2336 of file dataDML.py.

tuple dataDML.normrevlist = revisionDML.revisionsInBranchName(schema,'NORM')

Definition at line 2371 of file dataDML.py.

tuple dataDML.revlist = revisionDML.revisionsInBranchName(schema,'DATA')

Definition at line 2378 of file dataDML.py.

tuple dataDML.runsummarydata = generateDummyData.runsummary(schema,'PROTPHYS',3500)

Definition at line 2348 of file dataDML.py.

tuple dataDML.schema = session.nominalSchema()

Definition at line 2325 of file dataDML.py.

tuple dataDML.session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])

Definition at line 2324 of file dataDML.py.

tuple dataDML.svc = sessionManager.sessionManager(myconstr,authpath='/afs/cern.ch/user/x/xiezhen',debugON=False)

Definition at line 2323 of file dataDML.py.

tuple dataDML.tables = lumidbDDL.createTables(schema)

Definition at line 2329 of file dataDML.py.

Referenced by ora::SchemaUtils.cleanUp(), and FFTJetLookupTableESProducer< CT >.produce().

tuple dataDML.trgdata = generateDummyData.trg(schema,20)

Definition at line 2357 of file dataDML.py.

tuple dataDML.trgentry_id = revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),'1222','DATA')

Definition at line 2386 of file dataDML.py.

list dataDML.trglsdata = trgdata[3]

Definition at line 2359 of file dataDML.py.

list dataDML.trgrundata = [trgdata[0],trgdata[1],trgdata[2]]

Definition at line 2358 of file dataDML.py.

Referenced by lumi::RevisionDML.insertTrgRunData(), and lumi::TRGScalers2DB.writeTrgDataToSchema2().

tuple dataDML.trunkinfo = revisionDML.createBranch(schema,'TRUNK',None,comment='main')

Definition at line 2332 of file dataDML.py.