CMS 3D CMS Logo

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.

00959                                                                  :
00960     '''
00961     input:
00962         hltrundata [pathnameclob(0),datasource(1)]
00963     output:
00964         (revision_id,entry_id,data_id)
00965     '''
00966     try:
00967          pathnames=hltrundata[0]
00968          datasource=hltrundata[1]
00969          npath=len(pathnames.split(','))
00970          entry_id=revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),str(runnumber),branchinfo[1])
00971          if entry_id is None:
00972              (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName())
00973              entryinfo=(revision_id,entry_id,str(runnumber),data_id)
00974              revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo)
00975          else:
00976              (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() )
00977              revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo)
00978          tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'}
00979          tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames}
00980          db=dbUtil.dbUtil(schema)
00981          db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict)
00982          return (revision_id,entry_id,data_id)
00983     except :
00984         raise 

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.

00907                                                                    :
00908     '''
00909     input:
00910           lumirundata [datasource]
00911           branchinfo (branch_id,branch_name)
00912     output:
00913           (revision_id,entry_id,data_id)
00914     '''
00915     try:
00916          datasource=lumirundata[0]
00917          entry_id=revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),str(runnumber),branchinfo[1])
00918          if entry_id is None:
00919              (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.lumidataTableName())
00920              entryinfo=(revision_id,entry_id,str(runnumber),data_id)
00921              revisionDML.addEntry(schema,nameDealer.lumidataTableName(),entryinfo,branchinfo)
00922          else:
00923              (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.lumidataTableName() )
00924              revisionDML.addRevision(schema,nameDealer.lumidataTableName(),(revision_id,data_id),branchinfo)
00925          tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string'}
00926          tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource}
00927          db=dbUtil.dbUtil(schema)
00928          db.insertOneRow(nameDealer.lumidataTableName(),tabrowDefDict,tabrowValueDict)
00929          return (revision_id,entry_id,data_id)
00930     except :
        raise
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.

00876                                                                                      :
00877     '''
00878     input:
00879        branchinfo(normrevisionid,branchname)
00880        optionalnormdata {'norm2':norm2,'egev2':egev2}
00881     output:
00882        (revision_id,entry_id,data_id)
00883     '''
00884     print 'branchinfo ',branchinfo
00885     norm2=None
00886     if optionalnormdata.has_key('norm2'):
00887         norm2=optionalnormdata['norm2']
00888     egev2=None
00889     if optionalnormdata.has_key('egev2'):
00890         egev2=optionalnormdata['egev2']
00891     try:
00892         entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1])
00893         if entry_id is None:
00894             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName())
00895             entryinfo=(revision_id,entry_id,normname,data_id)
00896             revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo)
00897         else:
00898             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() )
00899             revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo)
00900         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'}
00901         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}
00902         db=dbUtil.dbUtil(schema)
00903         db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict)
00904         return (revision_id,entry_id,data_id)
00905     except :
        raise
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.

00932                                                                  :
00933     '''
00934     input:
00935        trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)]
00936        bitnames clob, bitnames separated by ','
00937     output:
00938        (revision_id,entry_id,data_id)
00939     '''
00940     try:   #fixme: need to consider revision only case
00941         datasource=trgrundata[0]
00942         bitzeroname=trgrundata[1]
00943         bitnames=trgrundata[2]
00944         entry_id=revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),str(runnumber),branchinfo[1])
00945         if entry_id is None:
00946             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.trgdataTableName())
00947             entryinfo=(revision_id,entry_id,str(runnumber),data_id)
00948             revisionDML.addEntry(schema,nameDealer.trgdataTableName(),entryinfo,branchinfo)
00949         else:
00950             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.trgdataTableName() )
00951             revisionDML.addRevision(schema,nameDealer.trgdataTableName(),(revision_id,data_id),branchinfo)
00952         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','SOURCE':'string','RUNNUM':'unsigned int','BITZERONAME':'string','BITNAMECLOB':'string'}
00953         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'SOURCE':datasource,'RUNNUM':int(runnumber),'BITZERONAME':bitzeroname,'BITNAMECLOB':bitnames}
00954         db=dbUtil.dbUtil(schema)
00955         db.insertOneRow(nameDealer.trgdataTableName(),tabrowDefDict,tabrowValueDict)
00956         return (revision_id,entry_id,data_id)
00957     except :
        raise
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.

00473                                :
00474     '''
00475     result (runnum,{lumilsnum,[cmslsnum(0),beamstatus(1),beamenergy(2),beam1intensity(3),beam2intensity(4)]})
00476     '''
00477     runnum=0
00478     result={}
00479     qHandle=schema.newQuery()
00480     try:
00481         qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
00482         qHandle.addToOutputList('RUNNUM','runnum')
00483         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00484         qHandle.addToOutputList('LUMILSNUM','lumilsnum')
00485         qHandle.addToOutputList('BEAMSTATUS','beamstatus')
00486         qHandle.addToOutputList('BEAMENERGY','beamenergy')
00487         qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob')
00488         qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity')
00489         qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity')
00490         qConditionStr='DATA_ID=:dataid'
00491         qCondition=coral.AttributeList()
00492         qCondition.extend('dataid','unsigned long long')
00493         qCondition['dataid'].setData(dataid)
00494         qResult=coral.AttributeList()
00495         qResult.extend('runnum','unsigned int')
00496         qResult.extend('cmslsnum','unsigned int')
00497         qResult.extend('lumilsnum','unsigned int')
00498         qResult.extend('beamstatus','string')
00499         qResult.extend('beamenergy','float')
00500         qResult.extend('bxindexblob','blob')
00501         qResult.extend('beam1intensity','blob')
00502         qResult.extend('beam2intensity','blob')
00503         qHandle.defineOutput(qResult)
00504         qHandle.setCondition(qConditionStr,qCondition)
00505         cursor=qHandle.execute()
00506         while cursor.next():
00507             runnum=cursor.currentRow()['runnum'].data()
00508             cmslsnum=cursor.currentRow()['cmslsnum'].data()
00509             lumilsnum=cursor.currentRow()['lumilsnum'].data()
00510             beamstatus=cursor.currentRow()['beamstatus'].data()
00511             beamenergy=cursor.currentRow()['beamenergy'].data()
00512             bxindexblob=cursor.currentRow()['bxindexblob'].data()
00513             beam1intensity=cursor.currentRow()['beam1intensity'].data()
00514             beam2intensity=cursor.currentRow()['beam2intensity'].data()
00515             if not result.has_key(lumilsnum):
00516                 result[lumilsnum]=[]
00517             result[lumilsnum].extend([lumilsnum,beamstatus,beamenergy,bxindexblob,beam1intensity,beam2intensity])
00518     except :
00519         del qHandle
00520         raise
00521     del qHandle
    return (runnum,result)
def dataDML::bulkInsertHltLSData (   session,
  runnumber,
  data_id,
  hltlsdata,
  bulksize = 500 
)
input:
hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}

Definition at line 1097 of file dataDML.py.

01098                                                                          :
01099     '''
01100     input:
01101     hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
01102     '''
01103     print 'total number of hlt rows ',len(hltlsdata)
01104     lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')]
01105     committedrows=0
01106     nrows=0
01107     bulkvalues=[]   
01108     try:             
01109         for cmslsnum,perlshlt in hltlsdata.items():
01110             inputcountblob=perlshlt[0]
01111             acceptcountblob=perlshlt[1]
01112             prescaleblob=perlshlt[2]
01113             bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)])
01114             
01115             nrows+=1
01116             committedrows+=1
01117             if nrows==bulksize:
01118                 print 'committing hlt in LS chunck ',nrows
01119                 db=dbUtil.dbUtil(session.nominalSchema())
01120                 session.transaction().start(False)
01121                 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
01122                 session.transaction().commit()
01123                 nrows=0
01124                 bulkvalues=[]
01125             elif committedrows==len(hltlsdata):
01126                 print 'committing hlt at the end '
01127                 db=dbUtil.dbUtil(session.nominalSchema())
01128                 session.transaction().start(False)
01129                 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
01130                 session.transaction().commit()
01131     except  :
01132         print 'error in bulkInsertHltLSData'
01133         raise 
    
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.

01135                                                                               :
01136     '''
01137     input:
01138           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]}
01139     '''
01140     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')]
01141     print 'total number of lumi rows ',len(lumilsdata)
01142     try:
01143         committedrows=0
01144         nrows=0
01145         bulkvalues=[]
01146         for lumilsnum,perlslumi in lumilsdata.items():
01147             cmslsnum=perlslumi[0]
01148             instlumi=perlslumi[1]
01149             instlumierror=perlslumi[2]
01150             instlumiquality=perlslumi[3]
01151             beamstatus=perlslumi[4]
01152             beamenergy=perlslumi[5]
01153             numorbit=perlslumi[6]
01154             startorbit=perlslumi[7]
01155             cmsbxindexindexblob=perlslumi[8]
01156             beam1intensity=perlslumi[9]
01157             beam2intensity=perlslumi[10]
01158             bxlumivalue_occ1=perlslumi[11]
01159             bxlumierror_occ1=perlslumi[12]
01160             bxlumiquality_occ1=perlslumi[13]
01161             bxlumivalue_occ2=perlslumi[14]
01162             bxlumierror_occ2=perlslumi[15]
01163             bxlumiquality_occ2=perlslumi[16]
01164             bxlumivalue_et=perlslumi[17]
01165             bxlumierror_et=perlslumi[18]
01166             bxlumiquality_et=perlslumi[19]
01167             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)])
01168             nrows+=1
01169             committedrows+=1
01170             if nrows==bulksize:
01171                 print 'committing lumi in LS chunck ',nrows
01172                 db=dbUtil.dbUtil(session.nominalSchema())
01173                 session.transaction().start(False)
01174                 db.bulkInsert(nameDealer.lumisummaryv2TableName(),lslumiDefDict,bulkvalues)
01175                 session.transaction().commit()
01176                 nrows=0
01177                 bulkvalues=[]
01178             elif committedrows==len(lumilsdata):
01179                 print 'committing lumi at the end '
01180                 db=dbUtil.dbUtil(session.nominalSchema())
01181                 session.transaction().start(False)
01182                 db.bulkInsert(nameDealer.lumisummaryv2TableName(),lslumiDefDict,bulkvalues)
01183                 session.transaction().commit()
01184     except :
01185         raise
01186 
01187 #def insertLumiLSDetail(schema,runnumber,data_id,lumibxdata):
01188 #    '''
01189 #    input:
01190 #          lumibxdata [(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]})]
01191 #    output:
01192 #          nrows
01193 #    '''
01194 #    try:
01195 #        nrow=0
01196 #        bulkvalues=[]
01197 #        lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('ALGONAME','string'),('BXLUMIVALUE','blob'),('BXLUMIERROR','blob'),('BXLUMIQUALITY','blob')]
01198 #        for (algoname,peralgobxdata) in lumibxdata:
01199 #            for lumilsnum,bxdata in peralgobxdata.items():
01200 #                cmslsnum=bxdata[0]
01201 #                bxlumivalue=bxdata[1]
01202 #                bxlumierror=bxdata[2]
01203 #                bxlumiquality=bxdata[3]
01204 #                bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('ALGONAME',algoname),('BXLUMIVALUE',bxlumivalue),('BXLUMIERROR',bxlumierror),('BXLUMIQUALITY',bxlumiquality)])
01205 #        db=dbUtil.dbUtil(schema)
01206 #        db.bulkInsert(nameDealer.lumidetailTableName(),lslumiDefDict,bulkvalues)
01207 #        return len(bulkvalues)
01208 #    except:
01209 #        raise 
01210     
01211 #def completeOldLumiData(schema,runnumber,lsdata,data_id):
01212 #    '''
01213 #    input:
01214 #    lsdata [[lumisummary_id,lumilsnum,cmslsnum]]
01215 #    '''
01216 #    try:
01217 #        #update in lumisummary table
01218 #        #print 'insert in lumisummary table'
01219 #        setClause='DATA_ID=:data_id'
01220 #        updateCondition='RUNNUM=:runnum AND DATA_ID is NULL'
01221 #        updateData=coral.AttributeList()
01222 #        updateData.extend('data_id','unsigned long long')
01223 #        updateData.extend('runnum','unsigned int')
01224 #        updateData['data_id'].setData(data_id)
01225 #        updateData['runnum'].setData(int(runnumber))
01226 #        db=dbUtil.dbUtil(schema)
01227 #        db.singleUpdate(nameDealer.lumisummaryTableName(),setClause,updateCondition,updateData)
01228 #        #updates in lumidetail table
01229 #        updateAction='DATA_ID=:data_id,RUNNUM=:runnum,CMSLSNUM=:cmslsnum,LUMILSNUM=:lumilsnum'
01230 #        updateCondition='LUMISUMMARY_ID=:lumisummary_id'
01231 #        bindvarDef=[]
01232 #        bindvarDef.append(('data_id','unsigned long long'))
01233 #        bindvarDef.append(('runnum','unsigned int'))
01234 #        bindvarDef.append(('cmslsnum','unsigned int'))
01235 #        bindvarDef.append(('lumilsnum','unsigned int'))        
01236 #        inputData=[]
01237 #        for [lumisummary_id,lumilsnum,cmslsnum] in lsdata:
01238 #            inputData.append([('data_id',data_id),('runnum',int(runnumber)),('cmslsnum',cmslsnum),('lumilsnum',lumilsnum)])
01239 #        db.updateRows(nameDealer.lumidetailTableName(),updateAction,updateCondition,bindvarDef,inputData)
01240 #    except:
01241 #        raise
01242     
01243 #=======================================================
01244 #   DELETE
01245 #=======================================================
01246 
01247 
01248 #=======================================================
01249 #   Unit Test
#=======================================================
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.

01058                                                                          :
01059     '''
01060     insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks 
01061     input:
01062         trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
01063     result nrows inserted
01064     if nrows==0, then this insertion failed
01065     '''
01066     print 'total number of trg rows ',len(trglsdata)
01067     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')]
01068     committedrows=0
01069     nrows=0
01070     bulkvalues=[]
01071     try:
01072         for cmslsnum,perlstrg in trglsdata.items():
01073             deadtimecount=perlstrg[0]           
01074             bitzerocount=perlstrg[1]
01075             bitzeroprescale=perlstrg[2]
01076             trgcountblob=perlstrg[3]
01077             trgprescaleblob=perlstrg[4]
01078             bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)])
01079             nrows+=1
01080             committedrows+=1
01081             if nrows==bulksize:
01082                 print 'committing trg in LS chunck ',nrows
01083                 db=dbUtil.dbUtil(session.nominalSchema())
01084                 session.transaction().start(False)
01085                 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
01086                 session.transaction().commit()
01087                 nrows=0
01088                 bulkvalues=[]
01089             elif committedrows==len(trglsdata):
01090                 print 'committing trg at the end '
01091                 db=dbUtil.dbUtil(session.nominalSchema())
01092                 session.transaction().start(False)
01093                 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
01094                 session.transaction().commit()
01095     except :
01096         print 'error in bulkInsertTrgLSData'
        raise 
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.

00790                                                 :
00791     '''
00792     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;
00793     check on entryrev
00794    
00795     return [lumientryid,trgentryid,hltentryid]
00796     '''
00797     result=[]
00798     qHandle=schema.newQuery()
00799     try:
00800         qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() ))
00801         qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() ))
00802         qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() ))
00803         qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid')
00804         qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid')
00805         qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid')
00806         qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr'
00807         qCondition=coral.AttributeList()
00808         qCondition.extend('runnumstr','string')
00809         qCondition['runnumstr'].setData(str(runnum))
00810         qResult=coral.AttributeList()
00811         qResult.extend('lumientryid','unsigned long long')
00812         qResult.extend('trgentryid','unsigned long long')
00813         qResult.extend('hltentryid','unsigned long long')
00814         qHandle.defineOutput(qResult)
00815         qHandle.setCondition(qConditionStr,qCondition)
00816         cursor=qHandle.execute()
00817         while cursor.next():
00818             lumientryid=cursor.currentRow()['lumientryid'].data()
00819             trgentryid=cursor.currentRow()['trgentryid'].data()
00820             hltentryid=cursor.currentRow()['hltentryid'].data()
00821             if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter:
00822                 result.extend([lumientryid,trgentryid,hltentryid])
00823     except:
00824         del qHandle
00825         raise 
00826     del qHandle
00827     return result

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.

00686                                    :
00687     '''
00688     get dataids by runnumber, if there are duplicates, pick max(dataid).Bypass full version lookups
00689     result (lumidataid(0),trgdataid(1),hltdataid(2)) 
00690     '''
00691     lumiids=[]
00692     trgids=[]
00693     hltids=[]
00694     qHandle=schema.newQuery()
00695     try:
00696         qHandle.addToTableList(nameDealer.lumidataTableName(),'l')
00697         qHandle.addToTableList(nameDealer.trgdataTableName(),'t')
00698         qHandle.addToTableList(nameDealer.hltdataTableName(),'h')
00699         qHandle.addToOutputList('l.DATA_ID','lumidataid')
00700         qHandle.addToOutputList('t.DATA_ID','trgdataid')
00701         qHandle.addToOutputList('h.DATA_ID','hltdataid')
00702         qConditionStr='l.RUNNUM=t.RUNNUM and t.RUNNUM=h.RUNNUM and l.RUNNUM=:runnum '
00703         qCondition=coral.AttributeList()
00704         qCondition.extend('runnum','unsigned int')
00705         qCondition['runnum'].setData(runnum)
00706         qResult=coral.AttributeList()
00707         qResult.extend('lumidataid','unsigned long long')
00708         qResult.extend('trgdataid','unsigned long long')
00709         qResult.extend('hltdataid','unsigned long long')
00710         qHandle.defineOutput(qResult)
00711         qHandle.setCondition(qConditionStr,qCondition)
00712         cursor=qHandle.execute()
00713         while cursor.next():
00714             lumidataid=cursor.currentRow()['lumidataid'].data()
00715             trgdataid=cursor.currentRow()['trgdataid'].data()
00716             hltdataid=cursor.currentRow()['hltdataid'].data()
00717             lumiids.append(lumidataid)
00718             trgids.append(trgdataid)
00719             hltids.append(hltdataid)
00720     except :
00721         del qHandle
00722         raise 
00723     del qHandle
00724     return (max(lumiids),max(trgids),max(hltids))

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.

00726                                                :
00727     '''
00728     get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
00729     select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1   
00730     '''
00731     luminormids=[]
00732     qHandle=schema.newQuery()
00733     try:
00734         qHandle.addToTableList( nameDealer.luminormTableName() )
00735         qHandle.addToOutputList('DATA_ID','normdataid')
00736         qConditionStr='AMODETAG=:amodetag AND EGEV_1=:egev1'
00737         qCondition=coral.AttributeList()
00738         qCondition.extend('amodetag','string')
00739         qCondition.extend('egev1','unsigned int')
00740         qCondition['amodetag'].setData(amodetag)
00741         qCondition['egev1'].setData(egev1)
00742         qResult=coral.AttributeList()
00743         qResult.extend('normdataid','unsigned long long')
00744         qHandle.defineOutput(qResult)
00745         qHandle.setCondition(qConditionStr,qCondition)
00746         cursor=qHandle.execute()
00747         while cursor.next():
00748             normdataid=cursor.currentRow()['normdataid'].data()
00749             luminormids.append(normdataid)
00750     except :
00751         del qHandle
00752         raise
00753     del qHandle
00754     if len(luminormids) !=0:return max(luminormids)
00755     return None

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.

00757                                       :
00758     '''
00759     get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
00760     select luminorm.data_id from luminorm where name=:normname
00761     result luminormdataid
00762     '''   
00763     luminormids=[]
00764     qHandle=schema.newQuery()
00765     try:
00766         qHandle.addToTableList( nameDealer.entryTableName(nameDealer.luminormTableName()) )
00767         qHandle.addToTableList( nameDealer.luminormTableName() )
00768         qHandle.addToOutputList('DATA_ID','normdataid')
00769         qConditionStr='ENTRY_NAME=:normname '
00770         qCondition=coral.AttributeList()
00771         qCondition.extend('normname','string')
00772         qCondition['normname'].setData(normname)
00773         qResult=coral.AttributeList()
00774         qResult.extend('normdataid','unsigned long long')
00775         qHandle.defineOutput(qResult)
00776         qHandle.setCondition(qConditionStr,qCondition)
00777         cursor=qHandle.execute()
00778         while cursor.next():
00779             normdataid=cursor.currentRow()['normdataid'].data()
00780             luminormids.append(normdataid)
00781     except :
00782         del qHandle
00783         raise
00784     del qHandle
00785     if len(luminormids) !=0:return max(luminormids)
00786     return None

def dataDML::hltLSById (   schema,
  dataid 
)
result (runnum, {cmslsnum:[prescaleblob,hltcountblob,hltacceptblob]} 

Definition at line 645 of file dataDML.py.

00646                             :
00647     '''
00648     result (runnum, {cmslsnum:[prescaleblob,hltcountblob,hltacceptblob]} 
00649     '''
00650     result={}
00651     qHandle=schema.newQuery()
00652     try:
00653         qHandle.addToTableList(nameDealer.lshltTableName())
00654         qHandle.addToOutputList('RUNNUM','runnum')
00655         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00656         qHandle.addToOutputList('PRESCALEBLOB','prescaleblob')
00657         qHandle.addToOutputList('HLTCOUNTBLOB','hltcountblob')
00658         qHandle.addToOutputList('HLTACCEPTBLOB','hltacceptblob')
00659         qConditionStr='DATA_ID=:dataid'
00660         qCondition=coral.AttributeList()
00661         qCondition.extend('dataid','unsigned long long')
00662         qCondition['dataid'].setData(dataid)
00663         qResult=coral.AttributeList()
00664         qResult.extend('runnum','unsigned int')
00665         qResult.extend('cmslsnum','unsigned int')
00666         qResult.extend('prescaleblob','blob')
00667         qResult.extend('hltcountblob','blob')
00668         qResult.extend('hltacceptblob','blob')
00669         qHandle.defineOutput(qResult)
00670         qHandle.setCondition(qConditionStr,qCondition)
00671         cursor=qHandle.execute()
00672         while cursor.next():
00673             runnum=cursor.currentRow()['runnum'].data()
00674             cmslsnum=cursor.currentRow()['cmslsnum'].data()
00675             prescaleblob=cursor.currentRow()['prescaleblob'].data()
00676             hltcountblob=cursor.currentRow()['hltcountblob'].data()
00677             hltacceptblob=cursor.currentRow()['hltacceptblob'].data()
00678             if not result.has_key(cmslsnum):
00679                 result[cmslsnum]=[]
00680             result[cmslsnum].extend([prescaleblob,hltcountblob,hltacceptblob])
00681     except :
00682         del qHandle
00683         raise
00684     del qHandle
    return (runnum,result)
def dataDML::hltRunById (   schema,
  dataid 
)
result [runnum(0),datasource(1),npath(2),pathnameclob(3)]

Definition at line 572 of file dataDML.py.

00573                              :
00574     '''
00575     result [runnum(0),datasource(1),npath(2),pathnameclob(3)]
00576     '''
00577     result=[]
00578     qHandle=schema.newQuery()
00579     try:
00580         qHandle.addToTableList(nameDealer.hltdataTableName())
00581         qHandle.addToOutputList('RUNNUM','runnum')
00582         qHandle.addToOutputList('SOURCE','datasource')
00583         qHandle.addToOutputList('NPATH','npath')
00584         qHandle.addToOutputList('PATHNAMECLOB','pathnameclob')
00585         qConditionStr='DATA_ID=:dataid'
00586         qCondition=coral.AttributeList()
00587         qCondition.extend('dataid','unsigned long long')
00588         qCondition['dataid'].setData(dataid)
00589         qResult=coral.AttributeList()
00590         qResult.extend('runnum','unsigned int')
00591         qResult.extend('datasource','string')
00592         qResult.extend('npath','unsigned int')
00593         qResult.extend('pathnameclob','string')
00594         qHandle.defineOutput(qResult)
00595         qHandle.setCondition(qConditionStr,qCondition)
00596         cursor=qHandle.execute()
00597         while cursor.next():
00598             runnum=cursor.currentRow()['runnum'].data()
00599             datasource=cursor.currentRow()['datasource'].data()
00600             npath=cursor.currentRow()['npath'].data()
00601             pathnameclob=cursor.currentRow()['pathnameclob'].data()
00602             result.extend([runnum,datasource,npath,pathnameclob])
00603     except :
00604         del qHandle
00605         raise 
00606     del qHandle
00607     return result

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.

00609                                      :
00610     '''
00611     select m.hltkey,m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey
00612     output: {hltpath:l1seed}
00613     '''
00614     result={}
00615     queryHandle=schema.newQuery()
00616     r=nameDealer.cmsrunsummaryTableName()
00617     m=nameDealer.trghltMapTableName()
00618     try:
00619         queryHandle.addToTableList(r)
00620         queryHandle.addToTableList(m)
00621         queryCondition=coral.AttributeList()
00622         queryCondition.extend('runnum','unsigned int')
00623         queryCondition['runnum'].setData(int(runnum))
00624         #queryHandle.addToOutputList(m+'.HLTKEY','hltkey')
00625         queryHandle.addToOutputList(m+'.HLTPATHNAME','hltpathname')
00626         queryHandle.addToOutputList(m+'.L1SEED','l1seed')
00627         queryHandle.setCondition(r+'.RUNNUM=:runnum and '+m+'.HLTKEY='+r+'.HLTKEY',queryCondition)
00628         queryResult=coral.AttributeList()
00629         #queryResult.extend('hltkey','string')
00630         queryResult.extend('hltpathname','string')
00631         queryResult.extend('l1seed','string')
00632         queryHandle.defineOutput(queryResult)
00633         cursor=queryHandle.execute()
00634         while cursor.next():
00635             #hltkey=cursor.currentRow()['hltkey'].data()
00636             hltpathname=cursor.currentRow()['hltpathname'].data()
00637             l1seed=cursor.currentRow()['l1seed'].data()
00638             if not result.has_key(hltpathname):
00639                 result[hltpathname]=l1seed
00640     except :
00641         del queryHandle
00642         raise
00643     del queryHandle
00644     return result

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.

00986                                                                                 :
00987     '''
00988     input:
00989         runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
00990     output:
00991     '''
00992     l1key=runsummarydata[0]
00993     amodetag=runsummarydata[1]
00994     egev=runsummarydata[2]
00995     hltkey=''
00996     fillnum=0
00997     sequence=''
00998     starttime=''
00999     stoptime=''
01000     if not complementalOnly:
01001         sequence=runsummarydata[3]
01002         hltkey=runsummarydata[4]
01003         fillnum=runsummarydata[5]
01004         starttime=runsummarydata[6]
01005         stoptime=runsummarydata[7]
01006     try:
01007         if not complementalOnly:
01008             tabrowDefDict={'RUNNUM':'unsigned int','L1KEY':'string','AMODETAG':'string','EGEV':'unsigned int','SEQUENCE':'string','HLTKEY':'string','FILLNUM':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp'}
01009             tabrowValueDict={'RUNNUM':int(runnumber),'L1KEY':l1key,'AMODETAG':amodetag,'EGEV':int(egev),'SEQUENCE':sequence,'HLTKEY':hltkey,'FILLNUM':int(fillnum),'STARTTIME':starttime,'STOPTIME':stoptime}
01010             db=dbUtil.dbUtil(schema)
01011             db.insertOneRow(nameDealer.cmsrunsummaryTableName(),tabrowDefDict,tabrowValueDict)
01012         else:
01013             setClause='L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev'
01014             updateCondition='RUNNUM=:runnum'
01015             inputData=coral.AttributeList()
01016             inputData.extend('l1key','string')
01017             inputData.extend('amodetag','string')
01018             inputData.extend('egev','unsigned int')
01019             inputData.extend('runnum','unsigned int')
01020             inputData['l1key'].setData(l1key)
01021             inputData['amodetag'].setData(amodetag)
01022             inputData['egev'].setData(int(egev))
01023             inputData['runnum'].setData(int(runnumber))
01024             db=dbUtil.dbUtil(schema)
01025             db.singleUpdate(nameDealer.cmsrunsummaryTableName(),setClause,updateCondition,inputData)
01026     except :
        raise   
def dataDML::insertTrgHltMap (   schema,
  hltkey,
  trghltmap 
)
input:
    trghltmap {hltpath:l1seed}
output:

Definition at line 1027 of file dataDML.py.

01028                                             :
01029     '''
01030     input:
01031         trghltmap {hltpath:l1seed}
01032     output:
01033     '''
01034     hltkeyExists=False
01035     nrows=0
01036     try:
01037         kQueryBindList=coral.AttributeList()
01038         kQueryBindList.extend('hltkey','string')
01039         kQuery=schema.newQuery()
01040         kQuery.addToTableList(nameDealer.trghltMapTableName())
01041         kQuery.setCondition('HLTKEY=:hltkey',kQueryBindList)
01042         kQueryBindList['hltkey'].setData(hltkey)
01043         kResult=kQuery.execute()
01044         while kResult.next():
01045             hltkeyExists=True
01046         if not hltkeyExists:
01047             bulkvalues=[]   
01048             trghltDefDict=[('HLTKEY','string'),('HLTPATHNAME','string'),('L1SEED','string')]
01049             for hltpath,l1seed in trghltmap.items():
01050                 bulkvalues.append([('HLTKEY',hltkey),('HLTPATHNAME',hltpath),('L1SEED',l1seed)])
01051             db=dbUtil.dbUtil(schema)
01052             db.bulkInsert(nameDealer.trghltMapTableName(),trghltDefDict,bulkvalues)
01053             nrows=len(bulkvalues)
01054         return nrows
01055     except :
01056         print 'error in insertTrgHltMap '
        raise
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.

00829                                                              :
00830     '''
00831     select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where  l.data_id=rl.data_id and l.entry_id=:entryid
00832     check revision_id is in branch
00833     '''
00834     dataids=[]
00835     datatablename=''
00836     revmaptablename=''
00837     if datatype=='lumi':
00838         datatablename=nameDealer.lumidataTableName()
00839     elif datatype=='trg':
00840         datatablename=nameDealer.trgdataTableName()
00841     elif dataytpe=='hlt':
00842         tablename=nameDealer.hltdataTableName()
00843     else:
00844         raise RunTimeError('datatype '+datatype+' is not supported')
00845     revmaptablename=nameDealer.revmapTableName(datatablename)
00846     qHandle=schema.newQuery()
00847     try:
00848         qHandle.addToTableList(revmaptablename)
00849         qHandle.addToTableList(datatablename)
00850         qHandle.addToOutputList('l.DATA_ID','dataid')
00851         qHandle.addToOutputList(revmaptablename+'.REVISION_ID','revisionid')
00852         qConditionStr=datatablename+'.DATA_ID='+revmaptablename+'.DATA_ID AND '+datatablename+'.ENTRY_ID=:entryid'
00853         qCondition=coral.AttributeList()
00854         qCondition.extend('entryid','unsigned long long')
00855         qResult=coral.AttributeList()
00856         qResult.extend('dataid','unsigned long long')
00857         qResult.extend('revisionid','unsigned long long')
00858         qHandle.defineOutput(qResult)
00859         qHandle.setCondition(qConditionStr,qCondition)
00860         cursor=qHandle.execute()
00861         while cursor.next():
00862             dataid=cursor.currentRow()['dataid'].data()
00863             revisionid=cursor.currentRow()['revisionid'].data()
00864             if revisionid in branchfilter:
00865                 dataids.append(dataid)
00866     except:
00867         del qHandle
00868         raise
00869     del qHandle
00870     if len(dataids)!=0:return max(dataids)
00871     return None
00872 
00873 #=======================================================
00874 #   INSERT requires in update transaction
#=======================================================
def dataDML::lumiBXByAlgo (   schema,
  dataid,
  algoname 
)
result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}

Definition at line 522 of file dataDML.py.

00523                                         :
00524     '''
00525     result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
00526     '''
00527     result={}
00528     qHandle=schema.newQuery()
00529     try:
00530         qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
00531         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00532         qHandle.addToOutputList('LUMILSNUM','lumilsnum')
00533         #qHandle.addToOutputList('ALGONAME','algoname')
00534         qHandle.addToOutputList('NUMORBIT','numorbit')
00535         qHandle.addToOutputList('STARTORBIT','startorbit')
00536         qHandle.addToOutputList('BXLUMIVALUE_'+algoname,'bxlumivalue')
00537         qHandle.addToOutputList('BXLUMIERROR_'+algoname,'bxlumierr')
00538         qHandle.addToOutputList('BXLUMIQUALITY_'+algoname,'bxlumiqlty')
00539         qConditionStr='DATA_ID=:dataid'
00540         qCondition=coral.AttributeList()
00541         qCondition.extend('dataid','unsigned long long')
00542         qCondition['dataid'].setData(dataid)
00543         qResult=coral.AttributeList()
00544         qResult.extend('cmslsnum','unsigned int')
00545         qResult.extend('lumilsnum','unsigned int')
00546         qResult.extend('numorbit','unsigned int')
00547         qResult.extend('startorbit','unsigned int')
00548         qResult.extend('bxlumivalue','blob')
00549         qResult.extend('bxlumierr','blob')
00550         qResult.extend('bxlumiqlty','blob')
00551         qHandle.defineOutput(qResult)
00552         qHandle.setCondition(qConditionStr,qCondition)
00553         cursor=qHandle.execute()
00554         while cursor.next():
00555             cmslsnum=cursor.currentRow()['cmslsnum'].data()
00556             lumilsnum=cursor.currentRow()['lumilsnum'].data()
00557             numorbit=cursor.currentRow()['numorbit'].data()
00558             startorbit=cursor.currentRow()['startorbit'].data()
00559             bxlumivalue=cursor.currentRow()['bxlumivalue'].data()
00560             bxlumierr=cursor.currentRow()['bxlumierr'].data()
00561             bxlumiqlty=cursor.currentRow()['bxlumiqlty'].data()
00562             if not result.has_key(algoname):
00563                 result[algoname]={}
00564             if not result[algoname].has_key(lumilsnum):
00565                 result[algoname][lumilsnum]=[]
00566             result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
00567     except :
00568         del qHandle
00569         raise RuntimeError(' dataDML.lumiBXById: '+str(e)) 
00570     del qHandle
00571     return result

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.

00375                                                                                                                                        :
00376     '''    
00377     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)]})
00378     '''
00379     runnum=0
00380     result={}
00381     qHandle=schema.newQuery()
00382     if withBXInfo and bxAlgo not in ['OCC1','OCC2','ET']:
00383         raise ValueError('unknown lumi algo '+bxAlgo)
00384     if beamstatus and beamstatus not in ['STABLE BEAMS',]:
00385         raise ValueError('unknown beam status '+beamstatus)
00386     try:
00387         qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
00388         qHandle.addToOutputList('RUNNUM','runnum')
00389         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00390         qHandle.addToOutputList('LUMILSNUM','lumilsnum')
00391         qHandle.addToOutputList('INSTLUMI','instlumi')
00392         qHandle.addToOutputList('INSTLUMIERROR','instlumierr')
00393         qHandle.addToOutputList('INSTLUMIQUALITY','instlumiqlty')
00394         qHandle.addToOutputList('BEAMSTATUS','beamstatus')
00395         qHandle.addToOutputList('BEAMENERGY','beamenergy')
00396         qHandle.addToOutputList('NUMORBIT','numorbit')
00397         qHandle.addToOutputList('STARTORBIT','startorbit')       
00398         if withBXInfo:
00399             qHandle.addToOutputList('BXLUMIVALUE_'+bxAlgo,'bxvalue')
00400             qHandle.addToOutputList('BXLUMIERROR_'+bxAlgo,'bxerror')
00401         if withBeamIntensity:
00402             qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob')
00403             qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity')
00404             qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity')
00405         
00406         qConditionStr='DATA_ID=:dataid'
00407         qCondition=coral.AttributeList()
00408         qCondition.extend('dataid','unsigned long long')
00409         qCondition['dataid'].setData(dataid)
00410         if beamstatus:
00411             qConditionStr+=' and BEAMSTATUS=:beamstatus'
00412             qCondition.extend('beamstatus','string')
00413             qCondition['beamstatus'].setData(beamstatus)
00414         if beamenergy:
00415             emin=float(beamenergy)*(1.0-beamenergyFluc)
00416             emax=float(beamenergy)*(1.0+beamenergyFluc)
00417             qConditionStr+=' and BEAMENERGY>=:emin and  BEAMENERGY<=:emax'
00418             qCondition.extend('beamenergy','float')
00419             qCondition['emin'].setData(emin)
00420             qCondition['emax'].setData(emax)
00421         qResult=coral.AttributeList()
00422         qResult.extend('runnum','unsigned int')
00423         qResult.extend('cmslsnum','unsigned int')
00424         qResult.extend('lumilsnum','unsigned int')
00425         qResult.extend('instlumi','float')
00426         qResult.extend('instlumierr','float')
00427         qResult.extend('instlumiqlty','short')
00428         qResult.extend('beamstatus','string')
00429         qResult.extend('beamenergy','float')
00430         qResult.extend('numorbit','unsigned int')
00431         qResult.extend('startorbit','unsigned int')
00432         if withBXInfo:
00433             qResult.extend('bxvalue','blob')
00434             qResult.extend('bxerror','blob')          
00435         if withBeamIntensity:
00436             qResult.extend('bxindexblob','blob')
00437             qResult.extend('beam1intensity','blob')
00438             qResult.extend('beam2intensity','blob')
00439         qHandle.defineOutput(qResult)
00440         qHandle.setCondition(qConditionStr,qCondition)
00441         cursor=qHandle.execute()
00442         while cursor.next():
00443             runnum=cursor.currentRow()['runnum'].data()
00444             cmslsnum=cursor.currentRow()['cmslsnum'].data()
00445             lumilsnum=cursor.currentRow()['lumilsnum'].data()
00446             instlumi=cursor.currentRow()['instlumi'].data()
00447             instlumierr=cursor.currentRow()['instlumierr'].data()
00448             instlumiqlty=cursor.currentRow()['instlumiqlty'].data()
00449             beamstatus=cursor.currentRow()['beamstatus'].data()
00450             beamenergy=cursor.currentRow()['beamenergy'].data()
00451             numorbit=cursor.currentRow()['numorbit'].data()
00452             startorbit=cursor.currentRow()['startorbit'].data()
00453             bxvalueblob=None
00454             bxerrblob=None
00455             if withBXInfo:
00456                 bxvalueblob=cursor.currentRow()['bxvalue'].data()
00457                 bxerrblob==cursor.currentRow()['bxerror'].data()
00458             bxindexblob=None
00459             beam1intensity=None
00460             beam2intensity=None
00461             if withBeamIntensity:
00462                 bxindexblob=cursor.currentRow()['bxindexblob'].data()
00463                 beam1intensity=cursor.currentRow()['beam1intensity'].data()
00464                 beam2intensity=cursor.currentRow()['beam2intensity'].data()
00465             if not result.has_key(lumilsnum):
00466                 result[lumilsnum]=[]
00467             result[lumilsnum].extend([cmslsnum,instlumi,instlumierr,instlumiqlty,beamstatus,beamenergy,numorbit,startorbit,bxvalueblob,bxerrblob,bxindexblob,beam1intensity,beam2intensity])           
00468     except :
00469         del qHandle
00470         raise 
00471     del qHandle
    return (runnum,result)
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.

00200                                :
00201     '''
00202     select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
00203     result [name(0),amodetag(1),norm_1(2),egev_1(3),norm_2(4),energy_2(5) ]
00204     '''
00205     result=[]
00206     qHandle=schema.newQuery()
00207     try:
00208         qHandle.addToTableList(nameDealer.luminormTableName())
00209         qHandle.addToOutputList('ENTRY_NAME','normname')
00210         qHandle.addToOutputList('AMODETAG','amodetag')
00211         qHandle.addToOutputList('NORM_1','norm_1')
00212         qHandle.addToOutputList('EGEV_1','energy_1')
00213         qHandle.addToOutputList('NORM_2','norm_2')
00214         qHandle.addToOutputList('EGEV_2','energy_2')        
00215         qCondition=coral.AttributeList()
00216         qCondition.extend('dataid','unsigned long long')
00217         qCondition['dataid'].setData(dataid)
00218         qResult=coral.AttributeList()
00219         qResult.extend('normname','string')
00220         qResult.extend('amodetag','string')
00221         qResult.extend('norm_1','float')
00222         qResult.extend('energy_1','unsigned int')
00223         qResult.extend('norm_2','float')
00224         qResult.extend('energy_2','unsigned int')
00225         qHandle.defineOutput(qResult)
00226         qHandle.setCondition('DATA_ID=:dataid',qCondition)
00227         cursor=qHandle.execute()
00228         while cursor.next():
00229             normname=cursor.currentRow()['normname'].data()
00230             amodetag=cursor.currentRow()['amodetag'].data()
00231             norm_1=cursor.currentRow()['norm_1'].data()
00232             energy_1=cursor.currentRow()['energy_1'].data()
00233             norm_2=None
00234             if cursor.currentRow()['norm_2'].data():
00235                 norm_2=cursor.currentRow()['norm_2'].data()
00236             energy_2=None
00237             if cursor.currentRow()['energy_2'].data():
00238                 energy_2=cursor.currentRow()['energy_2'].data()
00239             result.extend([normname,amodetag,norm_1,energy_1,norm_2,energy_2])
00240     except :
00241         del qHandle
00242         raise
00243     del qHandle
00244     return result

def dataDML::lumiRunById (   schema,
  dataid 
)
result [runnum(0),datasource(1)]

Definition at line 345 of file dataDML.py.

00346                               :
00347     '''
00348     result [runnum(0),datasource(1)]
00349     '''
00350     result=[]
00351     qHandle=schema.newQuery()
00352     try:
00353         qHandle.addToTableList(nameDealer.lumidataTableName())
00354         qHandle.addToOutputList('RUNNUM','runnum')
00355         qHandle.addToOutputList('SOURCE','datasource')
00356         qConditionStr='DATA_ID=:dataid'
00357         qCondition=coral.AttributeList()
00358         qCondition.extend('dataid','unsigned long long')
00359         qCondition['dataid'].setData(dataid)
00360         qResult=coral.AttributeList()
00361         qResult.extend('runnum','unsigned int')
00362         qResult.extend('datasource','string')
00363         qHandle.defineOutput(qResult)
00364         qHandle.setCondition(qConditionStr,qCondition)
00365         cursor=qHandle.execute()
00366         while cursor.next():
00367             runnum=cursor.currentRow()['runnum'].data()
00368             datasource=cursor.currentRow()['datasource'].data()
00369             result.extend([runnum,datasource])
00370     except :
00371         del qHandle
00372         raise    
00373     del qHandle
    return result
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.

00138                                             :
00139     '''
00140     this overview query should be only for norm
00141     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;
00142     output {norm_name:[data_id,amodetag,norm_1,egev_1,norm_2,egev_2]}
00143     '''
00144     print branchfilter
00145     result={}
00146     entry2datamap={}
00147     branchmin=0
00148     branchmax=0
00149     if branchfilter and len(branchfilter)!=0:
00150         branchmin=min(branchfilter)
00151         branchmax=max(branchfilter)
00152     else:
00153         return result
00154     qHandle=schema.newQuery()
00155     try:
00156         qHandle.addToTableList(nameDealer.entryTableName(nameDealer.luminormTableName()),'e')
00157         qHandle.addToTableList(nameDealer.luminormTableName(),'n')
00158         qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.luminormTableName()),'r')
00159         qHandle.addToOutputList('e.NAME','normname')
00160         qHandle.addToOutputList('max(r.DATA_ID)','data_id')
00161         qHandle.addToOutputList('r.REVISION_ID','revision_id')
00162         qHandle.addToOutputList('n.AMODETAG','amodetag')
00163         qHandle.addToOutputList('n.NORM_1','norm_1')
00164         qHandle.addToOutputList('n.EGEV_1','energy_1')
00165         qHandle.addToOutputList('n.NORM_2','norm_2')
00166         qHandle.addToOutputList('n.EGEV_2','energy_2')
00167         qCondition=coral.AttributeList()
00168         qCondition.extend('branchmin','unsigned long long')
00169         qCondition.extend('branchmax','unsigned long long')
00170         qCondition['branchmin'].setData(branchmin)
00171         qCondition['branchmax'].setData(branchmax)
00172         qResult=coral.AttributeList()
00173         qResult.extend('normname','string')
00174         qResult.extend('data_id','unsigned long long')
00175         qResult.extend('revision_id','unsigned long long')
00176         qResult.extend('amodetag','string')
00177         qResult.extend('norm_1','float')
00178         qResult.extend('energy_1','unsigned int')
00179         qResult.extend('norm_2','float')
00180         qResult.extend('energy_2','unsigned int')
00181         qHandle.defineOutput(qResult)
00182         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)
00183         qHandle.groupBy('e.name,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2')
00184         cursor=qHandle.execute()
00185         while cursor.next():
00186             normname=cursor.currentRow()['normname'].data()
00187             amodetag=cursor.currentRow()['amodetag'].data()
00188             norm_1=cursor.currentRow()['norm_1'].data()
00189             energy_1=cursor.currentRow()['energy_1'].data()
00190             norm_2=None
00191             if cursor.currentRow()['norm_2'].data():
00192                 norm_2=cursor.currentRow()['norm_2'].data()
00193             energy_2=None
00194             if cursor.currentRow()['energy_2'].data():
00195                 energy_2=cursor.currentRow()['energy_2'].data()
00196             result[normname]=[amodetag,norm_1,energy_1,norm_2,energy_2]
00197     except:
00198         raise
    return result
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.

00013                                                                                                                                                                                                     :
00014     '''
00015     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)
00016     '''
00017     result=[]
00018     qHandle=schema.newQuery()
00019     r=nameDealer.cmsrunsummaryTableName()
00020     l=nameDealer.lumidataTableName()
00021     t=nameDealer.trgdataTableName()
00022     h=nameDealer.hltdataTableName()
00023     try:
00024         qHandle.addToTableList(r)
00025         qHandle.addToTableList(l)
00026         if requiretrg:
00027             qHandle.addToTableList(t)
00028         if requirehlt:
00029             qHandle.addToTableList(h)
00030         qConditionStr=r+'.runnum='+l+'.runnum and '+l+'.runnum='+t+'.runnum and '+t+'.runnum='+h+'.runnum'
00031         qCondition=coral.AttributeList()        
00032         if fillnum:
00033             qConditionStr+=' and '+r+'.fillnum=:fillnum'
00034             qCondition.extend('fillnum','unsigned int')
00035             qCondition['fillnum'].setData(fillnum)
00036         if runmin:
00037             qConditionStr+=' and '+r+'.runnum>=:runmin'
00038             qCondition.extend('runmin','unsigned int')
00039             qCondition['runmin'].setData(runmin)
00040         if runmax:
00041             qConditionStr+=' and '+r+'.runnum<=:runmax'
00042             qCondition.extend('runmax','unsigned int')
00043             qCondition['runmax'].setData(runmax)
00044         if startT:
00045             qConditionStr+=' and '+r+'.starttime>=:startT'
00046             qCondition.extend('start','time stamp')
00047             qCondition['startT'].setData(startT)
00048         if stopT:
00049             qConditionStr+=' and '+r+'.stoptime<=:stopT'
00050             qCondition.extend('stop','time stamp')
00051             qCondition['stop'].setData(stopT)
00052         if amodetag:
00053             qConditionStr+=' and '+r+'.amodetag=:amodetag'
00054             qCondition.extend('amodetag','string')
00055             qCondition['amodetag'].setData(amodetag)
00056         if l1keyPattern:
00057             qConditionStr+=' and regexp_like('+r+'.l1key,:l1keypattern)'
00058             qCondition.extend('l1keypattern','string')
00059             qCondition['l1keypattern'].setData(l1keyPattern)
00060         if hltkeyPattern:
00061             qConditionStr+=' and regexp_like('+r+'.hltkey,:hltkeypattern)'
00062             qCondition.extend('hltkeypattern','string')
00063             qCondition['hltkeypattern'].setData(hltkeyPattern)
00064         if nominalEnergy:
00065             emin=nominalEnergy*(1.0-energyFlut)
00066             emax=nominalEnergy*(1.0+energyFlut)
00067             qConditionStr+=' and '+l+'.nominalegev>=:emin and '+l+'.nominalegev<=:emax'
00068             qCondition.extend('emin','float')
00069             qCondition.extend('emax','float')
00070             qCondition['emin'].setData(emin)
00071             qCondition['emax'].setData(emax)
00072         qResult=coral.AttributeList()
00073         qResult.extend('runnum','unsigned int')
00074         qHandle.defineOutput(qResult)
00075         qHandle.setCondition(qConditionStr,qCondition)
00076         qHandle.addToOutputList(r+'.RUNNUM','runnum')
00077         cursor=qHandle.execute()
00078         while cursor.next():
00079             result.append(cursor.currentRow()['runnum'].data())
00080     except :
00081         del qHandle
00082         raise
00083     del qHandle
00084     return result

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.

Referenced by SiStripFineDelayHit::produce().

00086                                               :
00087     '''
00088     select l1key,amodetag,egev,hltkey,fillnum,sequence,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum
00089     output: [l1key,amodetag,egev,hltkey,fillnum,sequence,starttime,stoptime]
00090     '''
00091     result=[]
00092     qHandle=schema.newQuery()
00093     t=lumiTime.lumiTime()
00094     try:
00095         qHandle.addToTableList(nameDealer.cmsrunsummaryTableName())
00096         qCondition=coral.AttributeList()
00097         qCondition.extend('runnum','unsigned int')
00098         qCondition['runnum'].setData(int(runnum))
00099         qHandle.addToOutputList('L1KEY','l1key')
00100         qHandle.addToOutputList('AMODETAG','amodetag')
00101         qHandle.addToOutputList('EGEV','egev')
00102         qHandle.addToOutputList('HLTKEY','hltkey')
00103         qHandle.addToOutputList('FILLNUM','fillnum')
00104         qHandle.addToOutputList('SEQUENCE','sequence')
00105         if sessionflavor=='SQLite':
00106             qHandle.addToOutputList('STARTTIME','starttime')
00107             qHandle.addToOutputList('STOPTIME','stoptime')
00108         else:
00109             qHandle.addToOutputList('to_char(STARTTIME,\''+t.coraltimefm+'\')','starttime')
00110             qHandle.addToOutputList('to_char(STOPTIME,\''+t.coraltimefm+'\')','stoptime')
00111         qHandle.setCondition('RUNNUM=:runnum',qCondition)
00112         qResult=coral.AttributeList()
00113         qResult.extend('l1key','string')
00114         qResult.extend('amodetag','string')
00115         qResult.extend('egev','unsigned int')
00116         qResult.extend('hltkey','string')
00117         qResult.extend('fillnum','unsigned int')
00118         qResult.extend('sequence','string')
00119         qResult.extend('starttime','string')
00120         qResult.extend('stoptime','string')
00121         qHandle.defineOutput(qResult)
00122         cursor=qHandle.execute()
00123         while cursor.next():
00124             result.append(cursor.currentRow()['l1key'].data())
00125             result.append(cursor.currentRow()['amodetag'].data())
00126             result.append(cursor.currentRow()['egev'].data())
00127             result.append(cursor.currentRow()['hltkey'].data())
00128             result.append(cursor.currentRow()['fillnum'].data())
00129             result.append(cursor.currentRow()['sequence'].data())
00130             result.append(cursor.currentRow()['starttime'].data())
00131             result.append(cursor.currentRow()['stoptime'].data())
00132     except :
00133         del qHandle
00134         raise
00135     del qHandle
00136     return result

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.

00287                                                :
00288     '''
00289     result (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),prescalesblob(4),trgcountblob(5)]})
00290     '''
00291     runnum=0
00292     result={}
00293     qHandle=schema.newQuery()
00294     try:
00295         qHandle.addToTableList(nameDealer.lstrgTableName())
00296         qHandle.addToOutputList('RUNNUM','runnum')
00297         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00298         qHandle.addToOutputList('DEADTIMECOUNT','deadtimecount')
00299         qHandle.addToOutputList('BITZEROCOUNT','bitzerocount')
00300         qHandle.addToOutputList('BITZEROPRESCALE','bitzeroprescale')
00301         qHandle.addToOutputList('DEADFRAC','deadfrac')
00302         if withblobdata:
00303             qHandle.addToOutputList('PRESCALESBLOB','prescalesblob')
00304             qHandle.addToOutputList('TRGCOUNTBLOB','trgcountblob')
00305         qConditionStr='DATA_ID=:dataid'
00306         qCondition=coral.AttributeList()
00307         qCondition.extend('dataid','unsigned long long')
00308         qCondition['dataid'].setData(dataid)
00309         qResult=coral.AttributeList()
00310         qResult.extend('runnum','unsigned int')
00311         qResult.extend('cmslsnum','unsigned int')
00312         qResult.extend('deadtimecount','unsigned long long')
00313         qResult.extend('bitzerocount','unsigned int')
00314         qResult.extend('bitzeroprescale','unsigned int')
00315         qResult.extend('deadfrac','float')
00316         if withblobdata:
00317             qResult.extend('prescalesblob','blob')
00318             qResult.extend('trgcountblob','blob')
00319         qHandle.defineOutput(qResult)
00320         qHandle.setCondition(qConditionStr,qCondition)
00321         cursor=qHandle.execute()
00322         while cursor.next():
00323             runnum=cursor.currentRow()['runnum'].data()
00324             cmslsnum=cursor.currentRow()['cmslsnum'].data()
00325             deadtimecount=cursor.currentRow()['deadtimecount'].data()
00326             bitzerocount=cursor.currentRow()['bitzerocount'].data()
00327             bitzeroprescale=cursor.currentRow()['bitzeroprescale'].data()
00328             deadfrac=cursor.currentRow()['deadfrac'].data()
00329             if not result.has_key(cmslsnum):
00330                 result[cmslsnum]=[]
00331             result[cmslsnum].append(deadtimecount)
00332             result[cmslsnum].append(bitzerocount)
00333             result[cmslsnum].append(bitzeroprescale)
00334             result[cmslsnum].append(deadfrac)
00335             prescalesblob=None
00336             trgcountblob=None
00337             if withblobdata:
00338                 prescalesblob=cursor.currentRow()['prescalesblob']
00339                 trgcountblob=cursor.currentRow()['trgcountblob']
00340                 result[cmslsnum].extend([prescalesblob,trgcountblob])
00341     except:
00342         del qHandle
00343         raise 
00344     del qHandle
    return (runnum,result)
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.

00246                              :
00247     '''
00248     select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB from trgdata where DATA_ID=:dataid
00249     result [runnum(0),datasource(1),bitzeroname(2),bitnameclob(3)]
00250     '''
00251     result=[]
00252     qHandle=schema.newQuery()
00253     try:
00254         qHandle.addToTableList(nameDealer.trgdataTableName())
00255         qHandle.addToOutputList('RUNNUM','runnum')
00256         qHandle.addToOutputList('SOURCE','source')
00257         qHandle.addToOutputList('BITZERONAME','bitzeroname')
00258         qHandle.addToOutputList('BITNAMECLOB','bitnameclob')
00259         qCondition=coral.AttributeList()
00260         qCondition.extend('dataid','unsigned long long')
00261         qCondition['dataid'].setData(dataid)
00262         qResult=coral.AttributeList()
00263         qResult.extend('runnum','unsigned int')
00264         qResult.extend('source','string')
00265         qResult.extend('bitzeroname','string')
00266         qResult.extend('bitnameclob','string')
00267         qHandle.defineOutput(qResult)
00268         qHandle.setCondition('DATA_ID=:dataid',qCondition)
00269         cursor=qHandle.execute()
00270         while cursor.next():
00271             runnum=cursor.currentRow()['runnum'].data()
00272             print 'runnum ',runnum
00273             source=cursor.currentRow()['source'].data()
00274             print 'source ',source
00275             bitzeroname=cursor.currentRow()['bitzeroname'].data()
00276             print 'bitzeroname ',bitzeroname
00277             bitnameclob=cursor.currentRow()['bitnameclob'].data()
00278             print 'bitnameclob ',bitnameclob
00279             #print 'bitnameclob ',bitnameclob
00280             result.extend([runnum,source,bitzeroname,bitnameclob])
00281     except :
00282         del qHandle
00283         raise 
00284     del qHandle
00285     return result


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.

Definition at line 1296 of file dataDML.py.

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.

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.

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.

Definition at line 1291 of file dataDML.py.

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.