CMS 3D CMS Logo

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

Functions

def addHLTRunDataToBranch
 
def addLumiRunDataToBranch
 
def addNormToBranch
 
def addTrgRunDataToBranch
 
def beamInfoById
 
def bulkInsertHltLSData
 
def bulkInsertLumiLSSummary
 
def bulkInsertTrgLSData
 
def dataentryIdByRun
 
def guessDataIdByRun
 
def guessnormIdByContext
 
def guessnormIdByName
 
def hltLSById
 
def hltRunById
 
def hlttrgMappingByrun
 
def insertRunSummaryData
 
def insertTrgHltMap
 
def latestdataIdByEntry
 
def lumiBXByAlgo
 
def lumiLSById
 
def luminormById
 
def lumiRunById
 
def mostRecentLuminorms
 
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.addHLTRunDataToBranch (   schema,
  runnumber,
  hltrundata,
  branchinfo 
)
input:
    hltrundata [pathnameclob(0),datasource(1)]
output:
    (revision_id,entry_id,data_id)

Definition at line 958 of file dataDML.py.

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

959 def addHLTRunDataToBranch(schema,runnumber,hltrundata,branchinfo):
960  '''
961  input:
962  hltrundata [pathnameclob(0),datasource(1)]
963  output:
964  (revision_id,entry_id,data_id)
965  '''
966  try:
967  pathnames=hltrundata[0]
968  datasource=hltrundata[1]
969  npath=len(pathnames.split(','))
970  entry_id=revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),str(runnumber),branchinfo[1])
971  if entry_id is None:
972  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName())
973  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
974  revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo)
975  else:
976  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() )
977  revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo)
978  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'}
979  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames}
980  db=dbUtil.dbUtil(schema)
981  db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict)
982  return (revision_id,entry_id,data_id)
983  except :
984  raise
def hltdataTableName
Definition: nameDealer.py:41
def lumidataTableName
Definition: nameDealer.py:17
def bookNewRevision
Definition: revisionDML.py:328
def bookNewEntry
Definition: revisionDML.py:314
def entryInBranch
Definition: revisionDML.py:186
def addHLTRunDataToBranch
Definition: dataDML.py:958
def dataDML.addLumiRunDataToBranch (   schema,
  runnumber,
  lumirundata,
  branchinfo 
)
input:
      lumirundata [datasource]
      branchinfo (branch_id,branch_name)
output:
      (revision_id,entry_id,data_id)

Definition at line 906 of file dataDML.py.

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

907 def addLumiRunDataToBranch(schema,runnumber,lumirundata,branchinfo):
908  '''
909  input:
910  lumirundata [datasource]
911  branchinfo (branch_id,branch_name)
912  output:
913  (revision_id,entry_id,data_id)
914  '''
915  try:
916  datasource=lumirundata[0]
917  entry_id=revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),str(runnumber),branchinfo[1])
918  if entry_id is None:
919  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.lumidataTableName())
920  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
921  revisionDML.addEntry(schema,nameDealer.lumidataTableName(),entryinfo,branchinfo)
922  else:
923  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.lumidataTableName() )
924  revisionDML.addRevision(schema,nameDealer.lumidataTableName(),(revision_id,data_id),branchinfo)
925  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string'}
926  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource}
927  db=dbUtil.dbUtil(schema)
928  db.insertOneRow(nameDealer.lumidataTableName(),tabrowDefDict,tabrowValueDict)
929  return (revision_id,entry_id,data_id)
930  except :
raise
def addLumiRunDataToBranch
Definition: dataDML.py:906
def lumidataTableName
Definition: nameDealer.py:17
def bookNewRevision
Definition: revisionDML.py:328
def bookNewEntry
Definition: revisionDML.py:314
def entryInBranch
Definition: revisionDML.py:186
def dataDML.addNormToBranch (   schema,
  normname,
  amodetag,
  norm1,
  egev1,
  optionalnormdata,
  branchinfo 
)
input:
   branchinfo(normrevisionid,branchname)
   optionalnormdata {'norm2':norm2,'egev2':egev2}
output:
   (revision_id,entry_id,data_id)

Definition at line 875 of file dataDML.py.

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

876 def addNormToBranch(schema,normname,amodetag,norm1,egev1,optionalnormdata,branchinfo):
877  '''
878  input:
879  branchinfo(normrevisionid,branchname)
880  optionalnormdata {'norm2':norm2,'egev2':egev2}
881  output:
882  (revision_id,entry_id,data_id)
883  '''
884  print 'branchinfo ',branchinfo
885  norm2=None
886  if optionalnormdata.has_key('norm2'):
887  norm2=optionalnormdata['norm2']
888  egev2=None
889  if optionalnormdata.has_key('egev2'):
890  egev2=optionalnormdata['egev2']
891  try:
892  entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1])
893  if entry_id is None:
894  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName())
895  entryinfo=(revision_id,entry_id,normname,data_id)
896  revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo)
897  else:
898  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() )
899  revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo)
900  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','AMODETAG':'string','NORM_1':'float','EGEV_1':'unsigned int','NORM_2':'float','EGEV_2':'unsigned int'}
901  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':normname,'AMODETAG':amodetag,'NORM_1':norm1,'EGEV_1':egev1,'NORM_2':norm2,'EGEV_2':egev2}
902  db=dbUtil.dbUtil(schema)
903  db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict)
904  return (revision_id,entry_id,data_id)
905  except :
raise
def bookNewRevision
Definition: revisionDML.py:328
def luminormTableName
Definition: nameDealer.py:27
def bookNewEntry
Definition: revisionDML.py:314
def addNormToBranch
Definition: dataDML.py:875
def entryInBranch
Definition: revisionDML.py:186
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 931 of file dataDML.py.

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

932 def addTrgRunDataToBranch(schema,runnumber,trgrundata,branchinfo):
933  '''
934  input:
935  trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)]
936  bitnames clob, bitnames separated by ','
937  output:
938  (revision_id,entry_id,data_id)
939  '''
940  try: #fixme: need to consider revision only case
941  datasource=trgrundata[0]
942  bitzeroname=trgrundata[1]
943  bitnames=trgrundata[2]
944  entry_id=revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),str(runnumber),branchinfo[1])
945  if entry_id is None:
946  (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.trgdataTableName())
947  entryinfo=(revision_id,entry_id,str(runnumber),data_id)
948  revisionDML.addEntry(schema,nameDealer.trgdataTableName(),entryinfo,branchinfo)
949  else:
950  (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.trgdataTableName() )
951  revisionDML.addRevision(schema,nameDealer.trgdataTableName(),(revision_id,data_id),branchinfo)
952  tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','SOURCE':'string','RUNNUM':'unsigned int','BITZERONAME':'string','BITNAMECLOB':'string'}
953  tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'SOURCE':datasource,'RUNNUM':int(runnumber),'BITZERONAME':bitzeroname,'BITNAMECLOB':bitnames}
954  db=dbUtil.dbUtil(schema)
955  db.insertOneRow(nameDealer.trgdataTableName(),tabrowDefDict,tabrowValueDict)
956  return (revision_id,entry_id,data_id)
957  except :
raise
def trgdataTableName
Definition: nameDealer.py:29
def addTrgRunDataToBranch
Definition: dataDML.py:931
def bookNewRevision
Definition: revisionDML.py:328
def bookNewEntry
Definition: revisionDML.py:314
def entryInBranch
Definition: revisionDML.py:186
def dataDML.beamInfoById (   schema,
  dataid 
)
result (runnum,{lumilsnum,[cmslsnum(0),beamstatus(1),beamenergy(2),beam1intensity(3),beam2intensity(4)]})

Definition at line 472 of file dataDML.py.

References runTheMatrix.data, and nameDealer.lumisummaryv2TableName().

473 def beamInfoById(schema,dataid):
474  '''
475  result (runnum,{lumilsnum,[cmslsnum(0),beamstatus(1),beamenergy(2),beam1intensity(3),beam2intensity(4)]})
476  '''
477  runnum=0
478  result={}
479  qHandle=schema.newQuery()
480  try:
481  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
482  qHandle.addToOutputList('RUNNUM','runnum')
483  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
484  qHandle.addToOutputList('LUMILSNUM','lumilsnum')
485  qHandle.addToOutputList('BEAMSTATUS','beamstatus')
486  qHandle.addToOutputList('BEAMENERGY','beamenergy')
487  qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob')
488  qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity')
489  qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity')
490  qConditionStr='DATA_ID=:dataid'
491  qCondition=coral.AttributeList()
492  qCondition.extend('dataid','unsigned long long')
493  qCondition['dataid'].setData(dataid)
494  qResult=coral.AttributeList()
495  qResult.extend('runnum','unsigned int')
496  qResult.extend('cmslsnum','unsigned int')
497  qResult.extend('lumilsnum','unsigned int')
498  qResult.extend('beamstatus','string')
499  qResult.extend('beamenergy','float')
500  qResult.extend('bxindexblob','blob')
501  qResult.extend('beam1intensity','blob')
502  qResult.extend('beam2intensity','blob')
503  qHandle.defineOutput(qResult)
504  qHandle.setCondition(qConditionStr,qCondition)
505  cursor=qHandle.execute()
506  while cursor.next():
507  runnum=cursor.currentRow()['runnum'].data()
508  cmslsnum=cursor.currentRow()['cmslsnum'].data()
509  lumilsnum=cursor.currentRow()['lumilsnum'].data()
510  beamstatus=cursor.currentRow()['beamstatus'].data()
511  beamenergy=cursor.currentRow()['beamenergy'].data()
512  bxindexblob=cursor.currentRow()['bxindexblob'].data()
513  beam1intensity=cursor.currentRow()['beam1intensity'].data()
514  beam2intensity=cursor.currentRow()['beam2intensity'].data()
515  if not result.has_key(lumilsnum):
516  result[lumilsnum]=[]
517  result[lumilsnum].extend([lumilsnum,beamstatus,beamenergy,bxindexblob,beam1intensity,beam2intensity])
518  except :
519  del qHandle
520  raise
521  del qHandle
return (runnum,result)
def lumisummaryv2TableName
Definition: nameDealer.py:23
def beamInfoById
Definition: dataDML.py:472
def dataDML.bulkInsertHltLSData (   session,
  runnumber,
  data_id,
  hltlsdata,
  bulksize = 500 
)
input:
hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}

Definition at line 1097 of file dataDML.py.

References nameDealer.lshltTableName().

1098 def bulkInsertHltLSData(session,runnumber,data_id,hltlsdata,bulksize=500):
1099  '''
1100  input:
1101  hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
1102  '''
1103  print 'total number of hlt rows ',len(hltlsdata)
1104  lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')]
1105  committedrows=0
1106  nrows=0
1107  bulkvalues=[]
1108  try:
1109  for cmslsnum,perlshlt in hltlsdata.items():
1110  inputcountblob=perlshlt[0]
1111  acceptcountblob=perlshlt[1]
1112  prescaleblob=perlshlt[2]
1113  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)])
1114 
1115  nrows+=1
1116  committedrows+=1
1117  if nrows==bulksize:
1118  print 'committing hlt in LS chunck ',nrows
1119  db=dbUtil.dbUtil(session.nominalSchema())
1120  session.transaction().start(False)
1121  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
1122  session.transaction().commit()
1123  nrows=0
1124  bulkvalues=[]
1125  elif committedrows==len(hltlsdata):
1126  print 'committing hlt at the end '
1127  db=dbUtil.dbUtil(session.nominalSchema())
1128  session.transaction().start(False)
1129  db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
1130  session.transaction().commit()
1131  except :
1132  print 'error in bulkInsertHltLSData'
1133  raise
Definition: start.py:1
def bulkInsertHltLSData
Definition: dataDML.py:1097
def lshltTableName
Definition: nameDealer.py:44
def dataDML.bulkInsertLumiLSSummary (   session,
  runnumber,
  data_id,
  lumilsdata,
  bulksize = 500 
)
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 1134 of file dataDML.py.

References nameDealer.lumisummaryv2TableName().

1135 def bulkInsertLumiLSSummary(session,runnumber,data_id,lumilsdata,bulksize=500):
1136  '''
1137  input:
1138  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]}
1139  '''
1140  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')]
1141  print 'total number of lumi rows ',len(lumilsdata)
1142  try:
1143  committedrows=0
1144  nrows=0
1145  bulkvalues=[]
1146  for lumilsnum,perlslumi in lumilsdata.items():
1147  cmslsnum=perlslumi[0]
1148  instlumi=perlslumi[1]
1149  instlumierror=perlslumi[2]
1150  instlumiquality=perlslumi[3]
1151  beamstatus=perlslumi[4]
1152  beamenergy=perlslumi[5]
1153  numorbit=perlslumi[6]
1154  startorbit=perlslumi[7]
1155  cmsbxindexindexblob=perlslumi[8]
1156  beam1intensity=perlslumi[9]
1157  beam2intensity=perlslumi[10]
1158  bxlumivalue_occ1=perlslumi[11]
1159  bxlumierror_occ1=perlslumi[12]
1160  bxlumiquality_occ1=perlslumi[13]
1161  bxlumivalue_occ2=perlslumi[14]
1162  bxlumierror_occ2=perlslumi[15]
1163  bxlumiquality_occ2=perlslumi[16]
1164  bxlumivalue_et=perlslumi[17]
1165  bxlumierror_et=perlslumi[18]
1166  bxlumiquality_et=perlslumi[19]
1167  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)])
1168  nrows+=1
1169  committedrows+=1
1170  if nrows==bulksize:
1171  print 'committing lumi in LS chunck ',nrows
1172  db=dbUtil.dbUtil(session.nominalSchema())
1173  session.transaction().start(False)
1174  db.bulkInsert(nameDealer.lumisummaryv2TableName(),lslumiDefDict,bulkvalues)
1175  session.transaction().commit()
1176  nrows=0
1177  bulkvalues=[]
1178  elif committedrows==len(lumilsdata):
1179  print 'committing lumi at the end '
1180  db=dbUtil.dbUtil(session.nominalSchema())
1181  session.transaction().start(False)
1182  db.bulkInsert(nameDealer.lumisummaryv2TableName(),lslumiDefDict,bulkvalues)
1183  session.transaction().commit()
1184  except :
1185  raise
1186 
1187 #def insertLumiLSDetail(schema,runnumber,data_id,lumibxdata):
1188 # '''
1189 # input:
1190 # lumibxdata [(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]})]
1191 # output:
1192 # nrows
1193 # '''
1194 # try:
1195 # nrow=0
1196 # bulkvalues=[]
1197 # lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('ALGONAME','string'),('BXLUMIVALUE','blob'),('BXLUMIERROR','blob'),('BXLUMIQUALITY','blob')]
1198 # for (algoname,peralgobxdata) in lumibxdata:
1199 # for lumilsnum,bxdata in peralgobxdata.items():
1200 # cmslsnum=bxdata[0]
1201 # bxlumivalue=bxdata[1]
1202 # bxlumierror=bxdata[2]
1203 # bxlumiquality=bxdata[3]
1204 # bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('ALGONAME',algoname),('BXLUMIVALUE',bxlumivalue),('BXLUMIERROR',bxlumierror),('BXLUMIQUALITY',bxlumiquality)])
1205 # db=dbUtil.dbUtil(schema)
1206 # db.bulkInsert(nameDealer.lumidetailTableName(),lslumiDefDict,bulkvalues)
1207 # return len(bulkvalues)
1208 # except:
1209 # raise
1210 
1211 #def completeOldLumiData(schema,runnumber,lsdata,data_id):
1212 # '''
1213 # input:
1214 # lsdata [[lumisummary_id,lumilsnum,cmslsnum]]
1215 # '''
1216 # try:
1217 # #update in lumisummary table
1218 # #print 'insert in lumisummary table'
1219 # setClause='DATA_ID=:data_id'
1220 # updateCondition='RUNNUM=:runnum AND DATA_ID is NULL'
1221 # updateData=coral.AttributeList()
1222 # updateData.extend('data_id','unsigned long long')
1223 # updateData.extend('runnum','unsigned int')
1224 # updateData['data_id'].setData(data_id)
1225 # updateData['runnum'].setData(int(runnumber))
1226 # db=dbUtil.dbUtil(schema)
1227 # db.singleUpdate(nameDealer.lumisummaryTableName(),setClause,updateCondition,updateData)
1228 # #updates in lumidetail table
1229 # updateAction='DATA_ID=:data_id,RUNNUM=:runnum,CMSLSNUM=:cmslsnum,LUMILSNUM=:lumilsnum'
1230 # updateCondition='LUMISUMMARY_ID=:lumisummary_id'
1231 # bindvarDef=[]
1232 # bindvarDef.append(('data_id','unsigned long long'))
1233 # bindvarDef.append(('runnum','unsigned int'))
1234 # bindvarDef.append(('cmslsnum','unsigned int'))
1235 # bindvarDef.append(('lumilsnum','unsigned int'))
1236 # inputData=[]
1237 # for [lumisummary_id,lumilsnum,cmslsnum] in lsdata:
1238 # inputData.append([('data_id',data_id),('runnum',int(runnumber)),('cmslsnum',cmslsnum),('lumilsnum',lumilsnum)])
1239 # db.updateRows(nameDealer.lumidetailTableName(),updateAction,updateCondition,bindvarDef,inputData)
1240 # except:
1241 # raise
1242 
1243 #=======================================================
1244 # DELETE
1245 #=======================================================
1246 
1247 
1248 #=======================================================
1249 # Unit Test
#=======================================================
Definition: start.py:1
def bulkInsertLumiLSSummary
Definition: dataDML.py:1134
def lumisummaryv2TableName
Definition: nameDealer.py:23
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 1057 of file dataDML.py.

References nameDealer.lstrgTableName().

1058 def bulkInsertTrgLSData(session,runnumber,data_id,trglsdata,bulksize=500):
1059  '''
1060  insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks
1061  input:
1062  trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
1063  result nrows inserted
1064  if nrows==0, then this insertion failed
1065  '''
1066  print 'total number of trg rows ',len(trglsdata)
1067  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')]
1068  committedrows=0
1069  nrows=0
1070  bulkvalues=[]
1071  try:
1072  for cmslsnum,perlstrg in trglsdata.items():
1073  deadtimecount=perlstrg[0]
1074  bitzerocount=perlstrg[1]
1075  bitzeroprescale=perlstrg[2]
1076  trgcountblob=perlstrg[3]
1077  trgprescaleblob=perlstrg[4]
1078  bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)])
1079  nrows+=1
1080  committedrows+=1
1081  if nrows==bulksize:
1082  print 'committing trg in LS chunck ',nrows
1083  db=dbUtil.dbUtil(session.nominalSchema())
1084  session.transaction().start(False)
1085  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
1086  session.transaction().commit()
1087  nrows=0
1088  bulkvalues=[]
1089  elif committedrows==len(trglsdata):
1090  print 'committing trg at the end '
1091  db=dbUtil.dbUtil(session.nominalSchema())
1092  session.transaction().start(False)
1093  db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
1094  session.transaction().commit()
1095  except :
1096  print 'error in bulkInsertTrgLSData'
raise
def bulkInsertTrgLSData
Definition: dataDML.py:1057
Definition: start.py:1
def lstrgTableName
Definition: nameDealer.py:32
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 789 of file dataDML.py.

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

790 def dataentryIdByRun(schema,runnum,branchfilter):
791  '''
792  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;
793  check on entryrev
794 
795  return [lumientryid,trgentryid,hltentryid]
796  '''
797  result=[]
798  qHandle=schema.newQuery()
799  try:
800  qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() ))
801  qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() ))
802  qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() ))
803  qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid')
804  qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid')
805  qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid')
806  qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr'
807  qCondition=coral.AttributeList()
808  qCondition.extend('runnumstr','string')
809  qCondition['runnumstr'].setData(str(runnum))
810  qResult=coral.AttributeList()
811  qResult.extend('lumientryid','unsigned long long')
812  qResult.extend('trgentryid','unsigned long long')
813  qResult.extend('hltentryid','unsigned long long')
814  qHandle.defineOutput(qResult)
815  qHandle.setCondition(qConditionStr,qCondition)
816  cursor=qHandle.execute()
817  while cursor.next():
818  lumientryid=cursor.currentRow()['lumientryid'].data()
819  trgentryid=cursor.currentRow()['trgentryid'].data()
820  hltentryid=cursor.currentRow()['hltentryid'].data()
821  if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter:
822  result.extend([lumientryid,trgentryid,hltentryid])
823  except:
824  del qHandle
825  raise
826  del qHandle
827  return result
def trgdataTableName
Definition: nameDealer.py:29
def hltdataTableName
Definition: nameDealer.py:41
def entryTableName
Definition: nameDealer.py:68
def lumidataTableName
Definition: nameDealer.py:17
def dataentryIdByRun
Definition: dataDML.py:789
def dataDML.guessDataIdByRun (   schema,
  runnum 
)
get dataids by runnumber, if there are duplicates, pick max(dataid).Bypass full version lookups
result (lumidataid(0),trgdataid(1),hltdataid(2)) 

Definition at line 685 of file dataDML.py.

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

Referenced by lumiCalcAPI.effectiveLumiForRange(), and lumiCalcAPI.lumiForRange().

686 def guessDataIdByRun(schema,runnum):
687  '''
688  get dataids by runnumber, if there are duplicates, pick max(dataid).Bypass full version lookups
689  result (lumidataid(0),trgdataid(1),hltdataid(2))
690  '''
691  lumiids=[]
692  trgids=[]
693  hltids=[]
694  qHandle=schema.newQuery()
695  try:
696  qHandle.addToTableList(nameDealer.lumidataTableName(),'l')
697  qHandle.addToTableList(nameDealer.trgdataTableName(),'t')
698  qHandle.addToTableList(nameDealer.hltdataTableName(),'h')
699  qHandle.addToOutputList('l.DATA_ID','lumidataid')
700  qHandle.addToOutputList('t.DATA_ID','trgdataid')
701  qHandle.addToOutputList('h.DATA_ID','hltdataid')
702  qConditionStr='l.RUNNUM=t.RUNNUM and t.RUNNUM=h.RUNNUM and l.RUNNUM=:runnum '
703  qCondition=coral.AttributeList()
704  qCondition.extend('runnum','unsigned int')
705  qCondition['runnum'].setData(runnum)
706  qResult=coral.AttributeList()
707  qResult.extend('lumidataid','unsigned long long')
708  qResult.extend('trgdataid','unsigned long long')
709  qResult.extend('hltdataid','unsigned long long')
710  qHandle.defineOutput(qResult)
711  qHandle.setCondition(qConditionStr,qCondition)
712  cursor=qHandle.execute()
713  while cursor.next():
714  lumidataid=cursor.currentRow()['lumidataid'].data()
715  trgdataid=cursor.currentRow()['trgdataid'].data()
716  hltdataid=cursor.currentRow()['hltdataid'].data()
717  lumiids.append(lumidataid)
718  trgids.append(trgdataid)
719  hltids.append(hltdataid)
720  except :
721  del qHandle
722  raise
723  del qHandle
724  return (max(lumiids),max(trgids),max(hltids))
def trgdataTableName
Definition: nameDealer.py:29
const T & max(const T &a, const T &b)
def hltdataTableName
Definition: nameDealer.py:41
def lumidataTableName
Definition: nameDealer.py:17
def guessDataIdByRun
Definition: dataDML.py:685
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 725 of file dataDML.py.

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

Referenced by lumiCalcAPI.deliveredLumiForRange(), lumiCalcAPI.effectiveLumiForRange(), and lumiCalcAPI.lumiForRange().

726 def guessnormIdByContext(schema,amodetag,egev1):
727  '''
728  get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
729  select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1
730  '''
731  luminormids=[]
732  qHandle=schema.newQuery()
733  try:
734  qHandle.addToTableList( nameDealer.luminormTableName() )
735  qHandle.addToOutputList('DATA_ID','normdataid')
736  qConditionStr='AMODETAG=:amodetag AND EGEV_1=:egev1'
737  qCondition=coral.AttributeList()
738  qCondition.extend('amodetag','string')
739  qCondition.extend('egev1','unsigned int')
740  qCondition['amodetag'].setData(amodetag)
741  qCondition['egev1'].setData(egev1)
742  qResult=coral.AttributeList()
743  qResult.extend('normdataid','unsigned long long')
744  qHandle.defineOutput(qResult)
745  qHandle.setCondition(qConditionStr,qCondition)
746  cursor=qHandle.execute()
747  while cursor.next():
748  normdataid=cursor.currentRow()['normdataid'].data()
749  luminormids.append(normdataid)
750  except :
751  del qHandle
752  raise
753  del qHandle
754  if len(luminormids) !=0:return max(luminormids)
755  return None
const T & max(const T &a, const T &b)
def guessnormIdByContext
Definition: dataDML.py:725
def luminormTableName
Definition: nameDealer.py:27
def dataDML.guessnormIdByName (   schema,
  normname 
)
get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
select luminorm.data_id from luminorm where name=:normname
result luminormdataid

Definition at line 756 of file dataDML.py.

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

757 def guessnormIdByName(schema,normname):
758  '''
759  get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
760  select luminorm.data_id from luminorm where name=:normname
761  result luminormdataid
762  '''
763  luminormids=[]
764  qHandle=schema.newQuery()
765  try:
766  qHandle.addToTableList( nameDealer.entryTableName(nameDealer.luminormTableName()) )
767  qHandle.addToTableList( nameDealer.luminormTableName() )
768  qHandle.addToOutputList('DATA_ID','normdataid')
769  qConditionStr='ENTRY_NAME=:normname '
770  qCondition=coral.AttributeList()
771  qCondition.extend('normname','string')
772  qCondition['normname'].setData(normname)
773  qResult=coral.AttributeList()
774  qResult.extend('normdataid','unsigned long long')
775  qHandle.defineOutput(qResult)
776  qHandle.setCondition(qConditionStr,qCondition)
777  cursor=qHandle.execute()
778  while cursor.next():
779  normdataid=cursor.currentRow()['normdataid'].data()
780  luminormids.append(normdataid)
781  except :
782  del qHandle
783  raise
784  del qHandle
785  if len(luminormids) !=0:return max(luminormids)
786  return None
const T & max(const T &a, const T &b)
def guessnormIdByName
Definition: dataDML.py:756
def entryTableName
Definition: nameDealer.py:68
def luminormTableName
Definition: nameDealer.py:27
def dataDML.hltLSById (   schema,
  dataid 
)
result (runnum, {cmslsnum:[prescaleblob,hltcountblob,hltacceptblob]} 

Definition at line 645 of file dataDML.py.

References runTheMatrix.data, and nameDealer.lshltTableName().

Referenced by lumiCalcAPI.effectiveLumiForRange().

646 def hltLSById(schema,dataid):
647  '''
648  result (runnum, {cmslsnum:[prescaleblob,hltcountblob,hltacceptblob]}
649  '''
650  result={}
651  qHandle=schema.newQuery()
652  try:
653  qHandle.addToTableList(nameDealer.lshltTableName())
654  qHandle.addToOutputList('RUNNUM','runnum')
655  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
656  qHandle.addToOutputList('PRESCALEBLOB','prescaleblob')
657  qHandle.addToOutputList('HLTCOUNTBLOB','hltcountblob')
658  qHandle.addToOutputList('HLTACCEPTBLOB','hltacceptblob')
659  qConditionStr='DATA_ID=:dataid'
660  qCondition=coral.AttributeList()
661  qCondition.extend('dataid','unsigned long long')
662  qCondition['dataid'].setData(dataid)
663  qResult=coral.AttributeList()
664  qResult.extend('runnum','unsigned int')
665  qResult.extend('cmslsnum','unsigned int')
666  qResult.extend('prescaleblob','blob')
667  qResult.extend('hltcountblob','blob')
668  qResult.extend('hltacceptblob','blob')
669  qHandle.defineOutput(qResult)
670  qHandle.setCondition(qConditionStr,qCondition)
671  cursor=qHandle.execute()
672  while cursor.next():
673  runnum=cursor.currentRow()['runnum'].data()
674  cmslsnum=cursor.currentRow()['cmslsnum'].data()
675  prescaleblob=cursor.currentRow()['prescaleblob'].data()
676  hltcountblob=cursor.currentRow()['hltcountblob'].data()
677  hltacceptblob=cursor.currentRow()['hltacceptblob'].data()
678  if not result.has_key(cmslsnum):
679  result[cmslsnum]=[]
680  result[cmslsnum].extend([prescaleblob,hltcountblob,hltacceptblob])
681  except :
682  del qHandle
683  raise
684  del qHandle
return (runnum,result)
def lshltTableName
Definition: nameDealer.py:44
def hltLSById
Definition: dataDML.py:645
def dataDML.hltRunById (   schema,
  dataid 
)
result [runnum(0),datasource(1),npath(2),pathnameclob(3)]

Definition at line 572 of file dataDML.py.

References runTheMatrix.data, and nameDealer.hltdataTableName().

Referenced by lumiCalcAPI.effectiveLumiForRange().

573 def hltRunById(schema,dataid):
574  '''
575  result [runnum(0),datasource(1),npath(2),pathnameclob(3)]
576  '''
577  result=[]
578  qHandle=schema.newQuery()
579  try:
580  qHandle.addToTableList(nameDealer.hltdataTableName())
581  qHandle.addToOutputList('RUNNUM','runnum')
582  qHandle.addToOutputList('SOURCE','datasource')
583  qHandle.addToOutputList('NPATH','npath')
584  qHandle.addToOutputList('PATHNAMECLOB','pathnameclob')
585  qConditionStr='DATA_ID=:dataid'
586  qCondition=coral.AttributeList()
587  qCondition.extend('dataid','unsigned long long')
588  qCondition['dataid'].setData(dataid)
589  qResult=coral.AttributeList()
590  qResult.extend('runnum','unsigned int')
591  qResult.extend('datasource','string')
592  qResult.extend('npath','unsigned int')
593  qResult.extend('pathnameclob','string')
594  qHandle.defineOutput(qResult)
595  qHandle.setCondition(qConditionStr,qCondition)
596  cursor=qHandle.execute()
597  while cursor.next():
598  runnum=cursor.currentRow()['runnum'].data()
599  datasource=cursor.currentRow()['datasource'].data()
600  npath=cursor.currentRow()['npath'].data()
601  pathnameclob=cursor.currentRow()['pathnameclob'].data()
602  result.extend([runnum,datasource,npath,pathnameclob])
603  except :
604  del qHandle
605  raise
606  del qHandle
607  return result
def hltRunById
Definition: dataDML.py:572
def hltdataTableName
Definition: nameDealer.py:41
def dataDML.hlttrgMappingByrun (   schema,
  runnum 
)
select m.hltkey,m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey
output: {hltpath:l1seed}

Definition at line 608 of file dataDML.py.

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

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

609 def hlttrgMappingByrun(schema,runnum):
610  '''
611  select m.hltkey,m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey
612  output: {hltpath:l1seed}
613  '''
614  result={}
615  queryHandle=schema.newQuery()
618  try:
619  queryHandle.addToTableList(r)
620  queryHandle.addToTableList(m)
621  queryCondition=coral.AttributeList()
622  queryCondition.extend('runnum','unsigned int')
623  queryCondition['runnum'].setData(int(runnum))
624  #queryHandle.addToOutputList(m+'.HLTKEY','hltkey')
625  queryHandle.addToOutputList(m+'.HLTPATHNAME','hltpathname')
626  queryHandle.addToOutputList(m+'.L1SEED','l1seed')
627  queryHandle.setCondition(r+'.RUNNUM=:runnum and '+m+'.HLTKEY='+r+'.HLTKEY',queryCondition)
628  queryResult=coral.AttributeList()
629  #queryResult.extend('hltkey','string')
630  queryResult.extend('hltpathname','string')
631  queryResult.extend('l1seed','string')
632  queryHandle.defineOutput(queryResult)
633  cursor=queryHandle.execute()
634  while cursor.next():
635  #hltkey=cursor.currentRow()['hltkey'].data()
636  hltpathname=cursor.currentRow()['hltpathname'].data()
637  l1seed=cursor.currentRow()['l1seed'].data()
638  if not result.has_key(hltpathname):
639  result[hltpathname]=l1seed
640  except :
641  del queryHandle
642  raise
643  del queryHandle
644  return result
def hlttrgMappingByrun
Definition: dataDML.py:608
def trghltMapTableName
Definition: nameDealer.py:47
def cmsrunsummaryTableName
Definition: nameDealer.py:14
def dataDML.insertRunSummaryData (   schema,
  runnumber,
  runsummarydata,
  complementalOnly = False 
)
input:
    runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
output:

Definition at line 985 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName().

986 def insertRunSummaryData(schema,runnumber,runsummarydata,complementalOnly=False):
987  '''
988  input:
989  runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
990  output:
991  '''
992  l1key=runsummarydata[0]
993  amodetag=runsummarydata[1]
994  egev=runsummarydata[2]
995  hltkey=''
996  fillnum=0
997  sequence=''
998  starttime=''
999  stoptime=''
1000  if not complementalOnly:
1001  sequence=runsummarydata[3]
1002  hltkey=runsummarydata[4]
1003  fillnum=runsummarydata[5]
1004  starttime=runsummarydata[6]
1005  stoptime=runsummarydata[7]
1006  try:
1007  if not complementalOnly:
1008  tabrowDefDict={'RUNNUM':'unsigned int','L1KEY':'string','AMODETAG':'string','EGEV':'unsigned int','SEQUENCE':'string','HLTKEY':'string','FILLNUM':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp'}
1009  tabrowValueDict={'RUNNUM':int(runnumber),'L1KEY':l1key,'AMODETAG':amodetag,'EGEV':int(egev),'SEQUENCE':sequence,'HLTKEY':hltkey,'FILLNUM':int(fillnum),'STARTTIME':starttime,'STOPTIME':stoptime}
1010  db=dbUtil.dbUtil(schema)
1011  db.insertOneRow(nameDealer.cmsrunsummaryTableName(),tabrowDefDict,tabrowValueDict)
1012  else:
1013  setClause='L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev'
1014  updateCondition='RUNNUM=:runnum'
1015  inputData=coral.AttributeList()
1016  inputData.extend('l1key','string')
1017  inputData.extend('amodetag','string')
1018  inputData.extend('egev','unsigned int')
1019  inputData.extend('runnum','unsigned int')
1020  inputData['l1key'].setData(l1key)
1021  inputData['amodetag'].setData(amodetag)
1022  inputData['egev'].setData(int(egev))
1023  inputData['runnum'].setData(int(runnumber))
1024  db=dbUtil.dbUtil(schema)
1025  db.singleUpdate(nameDealer.cmsrunsummaryTableName(),setClause,updateCondition,inputData)
1026  except :
raise
def insertRunSummaryData
Definition: dataDML.py:985
def cmsrunsummaryTableName
Definition: nameDealer.py:14
def dataDML.insertTrgHltMap (   schema,
  hltkey,
  trghltmap 
)
input:
    trghltmap {hltpath:l1seed}
output:

Definition at line 1027 of file dataDML.py.

References nameDealer.trghltMapTableName().

1028 def insertTrgHltMap(schema,hltkey,trghltmap):
1029  '''
1030  input:
1031  trghltmap {hltpath:l1seed}
1032  output:
1033  '''
1034  hltkeyExists=False
1035  nrows=0
1036  try:
1037  kQueryBindList=coral.AttributeList()
1038  kQueryBindList.extend('hltkey','string')
1039  kQuery=schema.newQuery()
1040  kQuery.addToTableList(nameDealer.trghltMapTableName())
1041  kQuery.setCondition('HLTKEY=:hltkey',kQueryBindList)
1042  kQueryBindList['hltkey'].setData(hltkey)
1043  kResult=kQuery.execute()
1044  while kResult.next():
1045  hltkeyExists=True
1046  if not hltkeyExists:
1047  bulkvalues=[]
1048  trghltDefDict=[('HLTKEY','string'),('HLTPATHNAME','string'),('L1SEED','string')]
1049  for hltpath,l1seed in trghltmap.items():
1050  bulkvalues.append([('HLTKEY',hltkey),('HLTPATHNAME',hltpath),('L1SEED',l1seed)])
1051  db=dbUtil.dbUtil(schema)
1052  db.bulkInsert(nameDealer.trghltMapTableName(),trghltDefDict,bulkvalues)
1053  nrows=len(bulkvalues)
1054  return nrows
1055  except :
1056  print 'error in insertTrgHltMap '
raise
def trghltMapTableName
Definition: nameDealer.py:47
def insertTrgHltMap
Definition: dataDML.py:1027
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 828 of file dataDML.py.

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

829 def latestdataIdByEntry(schema,entryid,datatype,branchfilter):
830  '''
831  select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid
832  check revision_id is in branch
833  '''
834  dataids=[]
835  datatablename=''
836  revmaptablename=''
837  if datatype=='lumi':
838  datatablename=nameDealer.lumidataTableName()
839  elif datatype=='trg':
840  datatablename=nameDealer.trgdataTableName()
841  elif dataytpe=='hlt':
842  tablename=nameDealer.hltdataTableName()
843  else:
844  raise RunTimeError('datatype '+datatype+' is not supported')
845  revmaptablename=nameDealer.revmapTableName(datatablename)
846  qHandle=schema.newQuery()
847  try:
848  qHandle.addToTableList(revmaptablename)
849  qHandle.addToTableList(datatablename)
850  qHandle.addToOutputList('l.DATA_ID','dataid')
851  qHandle.addToOutputList(revmaptablename+'.REVISION_ID','revisionid')
852  qConditionStr=datatablename+'.DATA_ID='+revmaptablename+'.DATA_ID AND '+datatablename+'.ENTRY_ID=:entryid'
853  qCondition=coral.AttributeList()
854  qCondition.extend('entryid','unsigned long long')
855  qResult=coral.AttributeList()
856  qResult.extend('dataid','unsigned long long')
857  qResult.extend('revisionid','unsigned long long')
858  qHandle.defineOutput(qResult)
859  qHandle.setCondition(qConditionStr,qCondition)
860  cursor=qHandle.execute()
861  while cursor.next():
862  dataid=cursor.currentRow()['dataid'].data()
863  revisionid=cursor.currentRow()['revisionid'].data()
864  if revisionid in branchfilter:
865  dataids.append(dataid)
866  except:
867  del qHandle
868  raise
869  del qHandle
870  if len(dataids)!=0:return max(dataids)
871  return None
872 
873 #=======================================================
874 # INSERT requires in update transaction
#=======================================================
def revmapTableName
Definition: nameDealer.py:65
def latestdataIdByEntry
Definition: dataDML.py:828
def trgdataTableName
Definition: nameDealer.py:29
const T & max(const T &a, const T &b)
def hltdataTableName
Definition: nameDealer.py:41
def lumidataTableName
Definition: nameDealer.py:17
def dataDML.lumiBXByAlgo (   schema,
  dataid,
  algoname 
)
result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}

Definition at line 522 of file dataDML.py.

References runTheMatrix.data, and nameDealer.lumisummaryv2TableName().

523 def lumiBXByAlgo(schema,dataid,algoname):
524  '''
525  result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
526  '''
527  result={}
528  qHandle=schema.newQuery()
529  try:
530  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
531  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
532  qHandle.addToOutputList('LUMILSNUM','lumilsnum')
533  #qHandle.addToOutputList('ALGONAME','algoname')
534  qHandle.addToOutputList('NUMORBIT','numorbit')
535  qHandle.addToOutputList('STARTORBIT','startorbit')
536  qHandle.addToOutputList('BXLUMIVALUE_'+algoname,'bxlumivalue')
537  qHandle.addToOutputList('BXLUMIERROR_'+algoname,'bxlumierr')
538  qHandle.addToOutputList('BXLUMIQUALITY_'+algoname,'bxlumiqlty')
539  qConditionStr='DATA_ID=:dataid'
540  qCondition=coral.AttributeList()
541  qCondition.extend('dataid','unsigned long long')
542  qCondition['dataid'].setData(dataid)
543  qResult=coral.AttributeList()
544  qResult.extend('cmslsnum','unsigned int')
545  qResult.extend('lumilsnum','unsigned int')
546  qResult.extend('numorbit','unsigned int')
547  qResult.extend('startorbit','unsigned int')
548  qResult.extend('bxlumivalue','blob')
549  qResult.extend('bxlumierr','blob')
550  qResult.extend('bxlumiqlty','blob')
551  qHandle.defineOutput(qResult)
552  qHandle.setCondition(qConditionStr,qCondition)
553  cursor=qHandle.execute()
554  while cursor.next():
555  cmslsnum=cursor.currentRow()['cmslsnum'].data()
556  lumilsnum=cursor.currentRow()['lumilsnum'].data()
557  numorbit=cursor.currentRow()['numorbit'].data()
558  startorbit=cursor.currentRow()['startorbit'].data()
559  bxlumivalue=cursor.currentRow()['bxlumivalue'].data()
560  bxlumierr=cursor.currentRow()['bxlumierr'].data()
561  bxlumiqlty=cursor.currentRow()['bxlumiqlty'].data()
562  if not result.has_key(algoname):
563  result[algoname]={}
564  if not result[algoname].has_key(lumilsnum):
565  result[algoname][lumilsnum]=[]
566  result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
567  except :
568  del qHandle
569  raise RuntimeError(' dataDML.lumiBXById: '+str(e))
570  del qHandle
571  return result
def lumiBXByAlgo
Definition: dataDML.py:522
def lumisummaryv2TableName
Definition: nameDealer.py:23
def dataDML.lumiLSById (   schema,
  dataid,
  beamstatus = None,
  beamenergy = None,
  beamenergyFluc = 0.2,
  withBXInfo = False,
  bxAlgo = 'OCC1',
  withBeamIntensity = False 
)
result (runnum,{lumilsnum,[cmslsnum(0),instlumi(1),instlumierr(2),instlumiqlty(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),bxvalueblob(8),bxerrblob(9),bxindexblob(10),beam1intensity(11),beam2intensity(12)]})

Definition at line 374 of file dataDML.py.

References runTheMatrix.data, and nameDealer.lumisummaryv2TableName().

Referenced by lumiCalcAPI.effectiveLumiForRange(), and lumiCalcAPI.lumiForRange().

375 def lumiLSById(schema,dataid,beamstatus=None,beamenergy=None,beamenergyFluc=0.2,withBXInfo=False,bxAlgo='OCC1',withBeamIntensity=False):
376  '''
377  result (runnum,{lumilsnum,[cmslsnum(0),instlumi(1),instlumierr(2),instlumiqlty(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),bxvalueblob(8),bxerrblob(9),bxindexblob(10),beam1intensity(11),beam2intensity(12)]})
378  '''
379  runnum=0
380  result={}
381  qHandle=schema.newQuery()
382  if withBXInfo and bxAlgo not in ['OCC1','OCC2','ET']:
383  raise ValueError('unknown lumi algo '+bxAlgo)
384  if beamstatus and beamstatus not in ['STABLE BEAMS',]:
385  raise ValueError('unknown beam status '+beamstatus)
386  try:
387  qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
388  qHandle.addToOutputList('RUNNUM','runnum')
389  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
390  qHandle.addToOutputList('LUMILSNUM','lumilsnum')
391  qHandle.addToOutputList('INSTLUMI','instlumi')
392  qHandle.addToOutputList('INSTLUMIERROR','instlumierr')
393  qHandle.addToOutputList('INSTLUMIQUALITY','instlumiqlty')
394  qHandle.addToOutputList('BEAMSTATUS','beamstatus')
395  qHandle.addToOutputList('BEAMENERGY','beamenergy')
396  qHandle.addToOutputList('NUMORBIT','numorbit')
397  qHandle.addToOutputList('STARTORBIT','startorbit')
398  if withBXInfo:
399  qHandle.addToOutputList('BXLUMIVALUE_'+bxAlgo,'bxvalue')
400  qHandle.addToOutputList('BXLUMIERROR_'+bxAlgo,'bxerror')
401  if withBeamIntensity:
402  qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob')
403  qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity')
404  qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity')
405 
406  qConditionStr='DATA_ID=:dataid'
407  qCondition=coral.AttributeList()
408  qCondition.extend('dataid','unsigned long long')
409  qCondition['dataid'].setData(dataid)
410  if beamstatus:
411  qConditionStr+=' and BEAMSTATUS=:beamstatus'
412  qCondition.extend('beamstatus','string')
413  qCondition['beamstatus'].setData(beamstatus)
414  if beamenergy:
415  emin=float(beamenergy)*(1.0-beamenergyFluc)
416  emax=float(beamenergy)*(1.0+beamenergyFluc)
417  qConditionStr+=' and BEAMENERGY>=:emin and BEAMENERGY<=:emax'
418  qCondition.extend('beamenergy','float')
419  qCondition['emin'].setData(emin)
420  qCondition['emax'].setData(emax)
421  qResult=coral.AttributeList()
422  qResult.extend('runnum','unsigned int')
423  qResult.extend('cmslsnum','unsigned int')
424  qResult.extend('lumilsnum','unsigned int')
425  qResult.extend('instlumi','float')
426  qResult.extend('instlumierr','float')
427  qResult.extend('instlumiqlty','short')
428  qResult.extend('beamstatus','string')
429  qResult.extend('beamenergy','float')
430  qResult.extend('numorbit','unsigned int')
431  qResult.extend('startorbit','unsigned int')
432  if withBXInfo:
433  qResult.extend('bxvalue','blob')
434  qResult.extend('bxerror','blob')
435  if withBeamIntensity:
436  qResult.extend('bxindexblob','blob')
437  qResult.extend('beam1intensity','blob')
438  qResult.extend('beam2intensity','blob')
439  qHandle.defineOutput(qResult)
440  qHandle.setCondition(qConditionStr,qCondition)
441  cursor=qHandle.execute()
442  while cursor.next():
443  runnum=cursor.currentRow()['runnum'].data()
444  cmslsnum=cursor.currentRow()['cmslsnum'].data()
445  lumilsnum=cursor.currentRow()['lumilsnum'].data()
446  instlumi=cursor.currentRow()['instlumi'].data()
447  instlumierr=cursor.currentRow()['instlumierr'].data()
448  instlumiqlty=cursor.currentRow()['instlumiqlty'].data()
449  beamstatus=cursor.currentRow()['beamstatus'].data()
450  beamenergy=cursor.currentRow()['beamenergy'].data()
451  numorbit=cursor.currentRow()['numorbit'].data()
452  startorbit=cursor.currentRow()['startorbit'].data()
453  bxvalueblob=None
454  bxerrblob=None
455  if withBXInfo:
456  bxvalueblob=cursor.currentRow()['bxvalue'].data()
457  bxerrblob==cursor.currentRow()['bxerror'].data()
458  bxindexblob=None
459  beam1intensity=None
460  beam2intensity=None
461  if withBeamIntensity:
462  bxindexblob=cursor.currentRow()['bxindexblob'].data()
463  beam1intensity=cursor.currentRow()['beam1intensity'].data()
464  beam2intensity=cursor.currentRow()['beam2intensity'].data()
465  if not result.has_key(lumilsnum):
466  result[lumilsnum]=[]
467  result[lumilsnum].extend([cmslsnum,instlumi,instlumierr,instlumiqlty,beamstatus,beamenergy,numorbit,startorbit,bxvalueblob,bxerrblob,bxindexblob,beam1intensity,beam2intensity])
468  except :
469  del qHandle
470  raise
471  del qHandle
return (runnum,result)
def lumisummaryv2TableName
Definition: nameDealer.py:23
def lumiLSById
Definition: dataDML.py:374
def dataDML.luminormById (   schema,
  dataid 
)
select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
result [name(0),amodetag(1),norm_1(2),egev_1(3),norm_2(4),energy_2(5) ]

Definition at line 199 of file dataDML.py.

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

Referenced by lumiCalcAPI.deliveredLumiForRange(), lumiCalcAPI.effectiveLumiForRange(), and lumiCalcAPI.lumiForRange().

200 def luminormById(schema,dataid):
201  '''
202  select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
203  result [name(0),amodetag(1),norm_1(2),egev_1(3),norm_2(4),energy_2(5) ]
204  '''
205  result=[]
206  qHandle=schema.newQuery()
207  try:
208  qHandle.addToTableList(nameDealer.luminormTableName())
209  qHandle.addToOutputList('ENTRY_NAME','normname')
210  qHandle.addToOutputList('AMODETAG','amodetag')
211  qHandle.addToOutputList('NORM_1','norm_1')
212  qHandle.addToOutputList('EGEV_1','energy_1')
213  qHandle.addToOutputList('NORM_2','norm_2')
214  qHandle.addToOutputList('EGEV_2','energy_2')
215  qCondition=coral.AttributeList()
216  qCondition.extend('dataid','unsigned long long')
217  qCondition['dataid'].setData(dataid)
218  qResult=coral.AttributeList()
219  qResult.extend('normname','string')
220  qResult.extend('amodetag','string')
221  qResult.extend('norm_1','float')
222  qResult.extend('energy_1','unsigned int')
223  qResult.extend('norm_2','float')
224  qResult.extend('energy_2','unsigned int')
225  qHandle.defineOutput(qResult)
226  qHandle.setCondition('DATA_ID=:dataid',qCondition)
227  cursor=qHandle.execute()
228  while cursor.next():
229  normname=cursor.currentRow()['normname'].data()
230  amodetag=cursor.currentRow()['amodetag'].data()
231  norm_1=cursor.currentRow()['norm_1'].data()
232  energy_1=cursor.currentRow()['energy_1'].data()
233  norm_2=None
234  if cursor.currentRow()['norm_2'].data():
235  norm_2=cursor.currentRow()['norm_2'].data()
236  energy_2=None
237  if cursor.currentRow()['energy_2'].data():
238  energy_2=cursor.currentRow()['energy_2'].data()
239  result.extend([normname,amodetag,norm_1,energy_1,norm_2,energy_2])
240  except :
241  del qHandle
242  raise
243  del qHandle
244  return result
def luminormTableName
Definition: nameDealer.py:27
def luminormById
Definition: dataDML.py:199
def dataDML.lumiRunById (   schema,
  dataid 
)
result [runnum(0),datasource(1)]

Definition at line 345 of file dataDML.py.

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

346 def lumiRunById(schema,dataid):
347  '''
348  result [runnum(0),datasource(1)]
349  '''
350  result=[]
351  qHandle=schema.newQuery()
352  try:
353  qHandle.addToTableList(nameDealer.lumidataTableName())
354  qHandle.addToOutputList('RUNNUM','runnum')
355  qHandle.addToOutputList('SOURCE','datasource')
356  qConditionStr='DATA_ID=:dataid'
357  qCondition=coral.AttributeList()
358  qCondition.extend('dataid','unsigned long long')
359  qCondition['dataid'].setData(dataid)
360  qResult=coral.AttributeList()
361  qResult.extend('runnum','unsigned int')
362  qResult.extend('datasource','string')
363  qHandle.defineOutput(qResult)
364  qHandle.setCondition(qConditionStr,qCondition)
365  cursor=qHandle.execute()
366  while cursor.next():
367  runnum=cursor.currentRow()['runnum'].data()
368  datasource=cursor.currentRow()['datasource'].data()
369  result.extend([runnum,datasource])
370  except :
371  del qHandle
372  raise
373  del qHandle
return result
def lumiRunById
Definition: dataDML.py:345
def lumidataTableName
Definition: nameDealer.py:17
def dataDML.mostRecentLuminorms (   schema,
  branchfilter 
)
this overview query should be only for norm
select e.name,max(n.data_id),r.revision_id , n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2 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) group by e.entry_name,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2;
output {norm_name:[data_id,amodetag,norm_1,egev_1,norm_2,egev_2]}

Definition at line 137 of file dataDML.py.

References runTheMatrix.data, nameDealer.entryTableName(), nameDealer.luminormTableName(), max(), min, and nameDealer.revmapTableName().

138 def mostRecentLuminorms(schema,branchfilter):
139  '''
140  this overview query should be only for norm
141  select e.name,max(n.data_id),r.revision_id , n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2 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) group by e.entry_name,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2;
142  output {norm_name:[data_id,amodetag,norm_1,egev_1,norm_2,egev_2]}
143  '''
144  print branchfilter
145  result={}
146  entry2datamap={}
147  branchmin=0
148  branchmax=0
149  if branchfilter and len(branchfilter)!=0:
150  branchmin=min(branchfilter)
151  branchmax=max(branchfilter)
152  else:
153  return result
154  qHandle=schema.newQuery()
155  try:
156  qHandle.addToTableList(nameDealer.entryTableName(nameDealer.luminormTableName()),'e')
157  qHandle.addToTableList(nameDealer.luminormTableName(),'n')
158  qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.luminormTableName()),'r')
159  qHandle.addToOutputList('e.NAME','normname')
160  qHandle.addToOutputList('max(r.DATA_ID)','data_id')
161  qHandle.addToOutputList('r.REVISION_ID','revision_id')
162  qHandle.addToOutputList('n.AMODETAG','amodetag')
163  qHandle.addToOutputList('n.NORM_1','norm_1')
164  qHandle.addToOutputList('n.EGEV_1','energy_1')
165  qHandle.addToOutputList('n.NORM_2','norm_2')
166  qHandle.addToOutputList('n.EGEV_2','energy_2')
167  qCondition=coral.AttributeList()
168  qCondition.extend('branchmin','unsigned long long')
169  qCondition.extend('branchmax','unsigned long long')
170  qCondition['branchmin'].setData(branchmin)
171  qCondition['branchmax'].setData(branchmax)
172  qResult=coral.AttributeList()
173  qResult.extend('normname','string')
174  qResult.extend('data_id','unsigned long long')
175  qResult.extend('revision_id','unsigned long long')
176  qResult.extend('amodetag','string')
177  qResult.extend('norm_1','float')
178  qResult.extend('energy_1','unsigned int')
179  qResult.extend('norm_2','float')
180  qResult.extend('energy_2','unsigned int')
181  qHandle.defineOutput(qResult)
182  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)
183  qHandle.groupBy('e.name,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2')
184  cursor=qHandle.execute()
185  while cursor.next():
186  normname=cursor.currentRow()['normname'].data()
187  amodetag=cursor.currentRow()['amodetag'].data()
188  norm_1=cursor.currentRow()['norm_1'].data()
189  energy_1=cursor.currentRow()['energy_1'].data()
190  norm_2=None
191  if cursor.currentRow()['norm_2'].data():
192  norm_2=cursor.currentRow()['norm_2'].data()
193  energy_2=None
194  if cursor.currentRow()['energy_2'].data():
195  energy_2=cursor.currentRow()['energy_2'].data()
196  result[normname]=[amodetag,norm_1,energy_1,norm_2,energy_2]
197  except:
198  raise
return result
def revmapTableName
Definition: nameDealer.py:65
#define min(a, b)
Definition: mlp_lapack.h:161
def mostRecentLuminorms
Definition: dataDML.py:137
const T & max(const T &a, const T &b)
def entryTableName
Definition: nameDealer.py:68
def luminormTableName
Definition: nameDealer.py:27
def dataDML.runList (   schema,
  fillnum = None,
  runmin = None,
  runmax = None,
  startT = None,
  stopT = None,
  l1keyPattern = None,
  hltkeyPattern = None,
  amodetag = None,
  nominalEnergy = None,
  energyFlut = 0.2,
  requiretrg = True,
  requirehlt = True 
)
select runnum from cmsrunsummary r,lumidata l,trgdata t,hltdata h where r.runnum=l.runnum and l.runnum=t.runnum and t.runnum=h.runnum and r.fillnum=:fillnum and r.runnum>:runmin and r.runnum<:runmax and r.starttime>=:startT and r.stopTime<=:stopT 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)

Definition at line 12 of file dataDML.py.

References nameDealer.cmsrunsummaryTableName(), runTheMatrix.data, nameDealer.hltdataTableName(), nameDealer.lumidataTableName(), and nameDealer.trgdataTableName().

Referenced by lumiCalcAPI.runList().

12 
13 def runList(schema,fillnum=None,runmin=None,runmax=None,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None,nominalEnergy=None,energyFlut=0.2,requiretrg=True,requirehlt=True):
14  '''
15  select runnum from cmsrunsummary r,lumidata l,trgdata t,hltdata h where r.runnum=l.runnum and l.runnum=t.runnum and t.runnum=h.runnum and r.fillnum=:fillnum and r.runnum>:runmin and r.runnum<:runmax and r.starttime>=:startT and r.stopTime<=:stopT 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)
16  '''
17  result=[]
18  qHandle=schema.newQuery()
23  try:
24  qHandle.addToTableList(r)
25  qHandle.addToTableList(l)
26  if requiretrg:
27  qHandle.addToTableList(t)
28  if requirehlt:
29  qHandle.addToTableList(h)
30  qConditionStr=r+'.runnum='+l+'.runnum and '+l+'.runnum='+t+'.runnum and '+t+'.runnum='+h+'.runnum'
31  qCondition=coral.AttributeList()
32  if fillnum:
33  qConditionStr+=' and '+r+'.fillnum=:fillnum'
34  qCondition.extend('fillnum','unsigned int')
35  qCondition['fillnum'].setData(fillnum)
36  if runmin:
37  qConditionStr+=' and '+r+'.runnum>=:runmin'
38  qCondition.extend('runmin','unsigned int')
39  qCondition['runmin'].setData(runmin)
40  if runmax:
41  qConditionStr+=' and '+r+'.runnum<=:runmax'
42  qCondition.extend('runmax','unsigned int')
43  qCondition['runmax'].setData(runmax)
44  if startT:
45  qConditionStr+=' and '+r+'.starttime>=:startT'
46  qCondition.extend('start','time stamp')
47  qCondition['startT'].setData(startT)
48  if stopT:
49  qConditionStr+=' and '+r+'.stoptime<=:stopT'
50  qCondition.extend('stop','time stamp')
51  qCondition['stop'].setData(stopT)
52  if amodetag:
53  qConditionStr+=' and '+r+'.amodetag=:amodetag'
54  qCondition.extend('amodetag','string')
55  qCondition['amodetag'].setData(amodetag)
56  if l1keyPattern:
57  qConditionStr+=' and regexp_like('+r+'.l1key,:l1keypattern)'
58  qCondition.extend('l1keypattern','string')
59  qCondition['l1keypattern'].setData(l1keyPattern)
60  if hltkeyPattern:
61  qConditionStr+=' and regexp_like('+r+'.hltkey,:hltkeypattern)'
62  qCondition.extend('hltkeypattern','string')
63  qCondition['hltkeypattern'].setData(hltkeyPattern)
64  if nominalEnergy:
65  emin=nominalEnergy*(1.0-energyFlut)
66  emax=nominalEnergy*(1.0+energyFlut)
67  qConditionStr+=' and '+l+'.nominalegev>=:emin and '+l+'.nominalegev<=:emax'
68  qCondition.extend('emin','float')
69  qCondition.extend('emax','float')
70  qCondition['emin'].setData(emin)
71  qCondition['emax'].setData(emax)
72  qResult=coral.AttributeList()
73  qResult.extend('runnum','unsigned int')
74  qHandle.defineOutput(qResult)
75  qHandle.setCondition(qConditionStr,qCondition)
76  qHandle.addToOutputList(r+'.RUNNUM','runnum')
77  cursor=qHandle.execute()
78  while cursor.next():
79  result.append(cursor.currentRow()['runnum'].data())
80  except :
81  del qHandle
82  raise
83  del qHandle
84  return result
def trgdataTableName
Definition: nameDealer.py:29
def hltdataTableName
Definition: nameDealer.py:41
def runList
Definition: dataDML.py:12
def lumidataTableName
Definition: nameDealer.py:17
def cmsrunsummaryTableName
Definition: nameDealer.py:14
def dataDML.runsummary (   schema,
  runnum,
  sessionflavor = '' 
)
select l1key,amodetag,egev,hltkey,fillnum,sequence,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum
output: [l1key,amodetag,egev,hltkey,fillnum,sequence,starttime,stoptime]

Definition at line 85 of file dataDML.py.

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

Referenced by lumiCalcAPI.effectiveLumiForRange(), lumiCalcAPI.lumiForRange(), and SiStripFineDelayHit.produce().

85 
86 def runsummary(schema,runnum,sessionflavor=''):
87  '''
88  select l1key,amodetag,egev,hltkey,fillnum,sequence,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum
89  output: [l1key,amodetag,egev,hltkey,fillnum,sequence,starttime,stoptime]
90  '''
91  result=[]
92  qHandle=schema.newQuery()
94  try:
95  qHandle.addToTableList(nameDealer.cmsrunsummaryTableName())
96  qCondition=coral.AttributeList()
97  qCondition.extend('runnum','unsigned int')
98  qCondition['runnum'].setData(int(runnum))
99  qHandle.addToOutputList('L1KEY','l1key')
100  qHandle.addToOutputList('AMODETAG','amodetag')
101  qHandle.addToOutputList('EGEV','egev')
102  qHandle.addToOutputList('HLTKEY','hltkey')
103  qHandle.addToOutputList('FILLNUM','fillnum')
104  qHandle.addToOutputList('SEQUENCE','sequence')
105  if sessionflavor=='SQLite':
106  qHandle.addToOutputList('STARTTIME','starttime')
107  qHandle.addToOutputList('STOPTIME','stoptime')
108  else:
109  qHandle.addToOutputList('to_char(STARTTIME,\''+t.coraltimefm+'\')','starttime')
110  qHandle.addToOutputList('to_char(STOPTIME,\''+t.coraltimefm+'\')','stoptime')
111  qHandle.setCondition('RUNNUM=:runnum',qCondition)
112  qResult=coral.AttributeList()
113  qResult.extend('l1key','string')
114  qResult.extend('amodetag','string')
115  qResult.extend('egev','unsigned int')
116  qResult.extend('hltkey','string')
117  qResult.extend('fillnum','unsigned int')
118  qResult.extend('sequence','string')
119  qResult.extend('starttime','string')
120  qResult.extend('stoptime','string')
121  qHandle.defineOutput(qResult)
122  cursor=qHandle.execute()
123  while cursor.next():
124  result.append(cursor.currentRow()['l1key'].data())
125  result.append(cursor.currentRow()['amodetag'].data())
126  result.append(cursor.currentRow()['egev'].data())
127  result.append(cursor.currentRow()['hltkey'].data())
128  result.append(cursor.currentRow()['fillnum'].data())
129  result.append(cursor.currentRow()['sequence'].data())
130  result.append(cursor.currentRow()['starttime'].data())
131  result.append(cursor.currentRow()['stoptime'].data())
132  except :
133  del qHandle
134  raise
135  del qHandle
136  return result
def runsummary
Definition: dataDML.py:85
def cmsrunsummaryTableName
Definition: nameDealer.py:14
def dataDML.trgLSById (   schema,
  dataid,
  withblobdata = False 
)
result (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),prescalesblob(4),trgcountblob(5)]})

Definition at line 286 of file dataDML.py.

References python.multivaluedict.append(), runTheMatrix.data, and nameDealer.lstrgTableName().

Referenced by lumiCalcAPI.effectiveLumiForRange(), and lumiCalcAPI.lumiForRange().

287 def trgLSById(schema,dataid,withblobdata=False):
288  '''
289  result (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),prescalesblob(4),trgcountblob(5)]})
290  '''
291  runnum=0
292  result={}
293  qHandle=schema.newQuery()
294  try:
295  qHandle.addToTableList(nameDealer.lstrgTableName())
296  qHandle.addToOutputList('RUNNUM','runnum')
297  qHandle.addToOutputList('CMSLSNUM','cmslsnum')
298  qHandle.addToOutputList('DEADTIMECOUNT','deadtimecount')
299  qHandle.addToOutputList('BITZEROCOUNT','bitzerocount')
300  qHandle.addToOutputList('BITZEROPRESCALE','bitzeroprescale')
301  qHandle.addToOutputList('DEADFRAC','deadfrac')
302  if withblobdata:
303  qHandle.addToOutputList('PRESCALESBLOB','prescalesblob')
304  qHandle.addToOutputList('TRGCOUNTBLOB','trgcountblob')
305  qConditionStr='DATA_ID=:dataid'
306  qCondition=coral.AttributeList()
307  qCondition.extend('dataid','unsigned long long')
308  qCondition['dataid'].setData(dataid)
309  qResult=coral.AttributeList()
310  qResult.extend('runnum','unsigned int')
311  qResult.extend('cmslsnum','unsigned int')
312  qResult.extend('deadtimecount','unsigned long long')
313  qResult.extend('bitzerocount','unsigned int')
314  qResult.extend('bitzeroprescale','unsigned int')
315  qResult.extend('deadfrac','float')
316  if withblobdata:
317  qResult.extend('prescalesblob','blob')
318  qResult.extend('trgcountblob','blob')
319  qHandle.defineOutput(qResult)
320  qHandle.setCondition(qConditionStr,qCondition)
321  cursor=qHandle.execute()
322  while cursor.next():
323  runnum=cursor.currentRow()['runnum'].data()
324  cmslsnum=cursor.currentRow()['cmslsnum'].data()
325  deadtimecount=cursor.currentRow()['deadtimecount'].data()
326  bitzerocount=cursor.currentRow()['bitzerocount'].data()
327  bitzeroprescale=cursor.currentRow()['bitzeroprescale'].data()
328  deadfrac=cursor.currentRow()['deadfrac'].data()
329  if not result.has_key(cmslsnum):
330  result[cmslsnum]=[]
331  result[cmslsnum].append(deadtimecount)
332  result[cmslsnum].append(bitzerocount)
333  result[cmslsnum].append(bitzeroprescale)
334  result[cmslsnum].append(deadfrac)
335  prescalesblob=None
336  trgcountblob=None
337  if withblobdata:
338  prescalesblob=cursor.currentRow()['prescalesblob']
339  trgcountblob=cursor.currentRow()['trgcountblob']
340  result[cmslsnum].extend([prescalesblob,trgcountblob])
341  except:
342  del qHandle
343  raise
344  del qHandle
return (runnum,result)
def lstrgTableName
Definition: nameDealer.py:32
def trgLSById
Definition: dataDML.py:286
def dataDML.trgRunById (   schema,
  dataid 
)
select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB from trgdata where DATA_ID=:dataid
result [runnum(0),datasource(1),bitzeroname(2),bitnameclob(3)]

Definition at line 245 of file dataDML.py.

References runTheMatrix.data, and nameDealer.trgdataTableName().

Referenced by lumiCalcAPI.effectiveLumiForRange().

246 def trgRunById(schema,dataid):
247  '''
248  select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB from trgdata where DATA_ID=:dataid
249  result [runnum(0),datasource(1),bitzeroname(2),bitnameclob(3)]
250  '''
251  result=[]
252  qHandle=schema.newQuery()
253  try:
254  qHandle.addToTableList(nameDealer.trgdataTableName())
255  qHandle.addToOutputList('RUNNUM','runnum')
256  qHandle.addToOutputList('SOURCE','source')
257  qHandle.addToOutputList('BITZERONAME','bitzeroname')
258  qHandle.addToOutputList('BITNAMECLOB','bitnameclob')
259  qCondition=coral.AttributeList()
260  qCondition.extend('dataid','unsigned long long')
261  qCondition['dataid'].setData(dataid)
262  qResult=coral.AttributeList()
263  qResult.extend('runnum','unsigned int')
264  qResult.extend('source','string')
265  qResult.extend('bitzeroname','string')
266  qResult.extend('bitnameclob','string')
267  qHandle.defineOutput(qResult)
268  qHandle.setCondition('DATA_ID=:dataid',qCondition)
269  cursor=qHandle.execute()
270  while cursor.next():
271  runnum=cursor.currentRow()['runnum'].data()
272  print 'runnum ',runnum
273  source=cursor.currentRow()['source'].data()
274  print 'source ',source
275  bitzeroname=cursor.currentRow()['bitzeroname'].data()
276  print 'bitzeroname ',bitzeroname
277  bitnameclob=cursor.currentRow()['bitnameclob'].data()
278  print 'bitnameclob ',bitnameclob
279  #print 'bitnameclob ',bitnameclob
280  result.extend([runnum,source,bitzeroname,bitnameclob])
281  except :
282  del qHandle
283  raise
284  del qHandle
285  return result
def trgRunById
Definition: dataDML.py:245
def trgdataTableName
Definition: nameDealer.py:29

Variable Documentation

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

Definition at line 1278 of file dataDML.py.

Referenced by TrackerMap.TrackerMap().

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

Definition at line 1266 of file dataDML.py.

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

Definition at line 1294 of file dataDML.py.

list dataDML.hltlsdata = hltdata[2]

Definition at line 1296 of file dataDML.py.

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

Definition at line 1295 of file dataDML.py.

tuple dataDML.hlttrgmap = generateDummyData.hlttrgmap(schema)

Definition at line 1282 of file dataDML.py.

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

Definition at line 1305 of file dataDML.py.

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

Definition at line 1313 of file dataDML.py.

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

Definition at line 1284 of file dataDML.py.

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

Definition at line 1312 of file dataDML.py.

list dataDML.lumilsdata = lumidummydata[1]

Definition at line 1286 of file dataDML.py.

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

Definition at line 1304 of file dataDML.py.

list dataDML.lumirundata = [lumidummydata[0]]

Definition at line 1285 of file dataDML.py.

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

Definition at line 1254 of file dataDML.py.

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

Definition at line 1274 of file dataDML.py.

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

Definition at line 1268 of file dataDML.py.

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

Definition at line 1303 of file dataDML.py.

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

Definition at line 1310 of file dataDML.py.

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

Definition at line 1280 of file dataDML.py.

tuple dataDML.schema = session.nominalSchema()

Definition at line 1257 of file dataDML.py.

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

Definition at line 1256 of file dataDML.py.

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

Definition at line 1255 of file dataDML.py.

tuple dataDML.tables = lumidbDDL.createTables(schema)

Definition at line 1261 of file dataDML.py.

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

Definition at line 1289 of file dataDML.py.

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

Definition at line 1318 of file dataDML.py.

list dataDML.trglsdata = trgdata[3]

Definition at line 1291 of file dataDML.py.

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

Definition at line 1290 of file dataDML.py.

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

Definition at line 1264 of file dataDML.py.