CMS 3D CMS Logo

Functions | Variables

dataDML Namespace Reference

Functions

def addCorrToBranch
def addHLTRunDataToBranch
def addLumiRunDataToBranch
def addNormToBranch
def addTrgRunDataToBranch
def allfillschemes
def beamInfoById
def bulkInsertHltLSData
def bulkInsertLumiLSSummary
def bulkInsertTrgLSData
def correctionByName
def dataentryIdByRun
def fillInRange
def fillrunMap
def fillschemeByRun
def fillschemePatternMap
def guesscorrIdByName
 LumiDB DML API # # Author: Zhen Xie #.
def guessDataIdByRun
def guessDataIdForRange
def guessHltDataIdByRunInBranch
def guessLumiDataIdByRunInBranch
def guessnormIdByContext
def guessnormIdByName
def guessTrgDataIdByRunInBranch
def hltLSById
def hltRunById
def hlttrgMappingByrun
def insertRunSummaryData
def insertTrgHltMap
def intglumiForRange
def latestdataIdByEntry
def lumiBXByAlgo
def lumicorrById
def lumiLSById
def luminormById
def lumiRunById
def lumiRunByIds
def mostRecentLumicorrs
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::addCorrToBranch (   schema,
  corrname,
  a1,
  optionalcorrdata,
  branchinfo 
)
input:
   branchinfo(corrrevisionid,branchname)
   optionalcorrdata {'a2':a2,'drift':drif}
output:
   (revision_id,entry_id,data_id)

Definition at line 1782 of file dataDML.py.

01783                                                                    :
01784     '''
01785     input:
01786        branchinfo(corrrevisionid,branchname)
01787        optionalcorrdata {'a2':a2,'drift':drif}
01788     output:
01789        (revision_id,entry_id,data_id)
01790     '''
01791     a2=1.0
01792     if optionalcorrdata.has_key('a2'):
01793         a2=optionalcorrdata['a2']
01794     drift=1.0
01795     if optionalcorrdata.has_key('drift'):
01796         drift=optionalcorrdata['drift']
01797     try:
01798         entry_id=revisionDML.entryInBranch(schema,nameDealer.lumicorrectionsTableName(),corrname,branchinfo[1])
01799         if entry_id is None:
01800             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.lumicorrectionsTableName())
01801             entryinfo=(revision_id,entry_id,corrname,data_id)
01802             revisionDML.addEntry(schema,nameDealer.lumicorrectionsTableName(),entryinfo,branchinfo)
01803         else:
01804             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.lumicorrectionsTableName() )
01805             revisionDML.addRevision(schema,nameDealer.lumicorrectionsTableName(),(revision_id,data_id),branchinfo)
01806         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','A1':'float','A2':'float','DRIFT':'float'}
01807         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':corrname,'A1':a1,'A2':a2,'DRIFT':drift}
01808         db=dbUtil.dbUtil(schema)
01809         db.insertOneRow(nameDealer.lumicorrectionsTableName(),tabrowDefDict,tabrowValueDict)
01810         return (revision_id,entry_id,data_id)
01811     except :
01812         raise

def dataDML::addHLTRunDataToBranch (   schema,
  runnumber,
  hltrundata,
  branchinfo 
)
input:
    hltrundata [pathnameclob(0),datasource(1)]
output:
    (revision_id,entry_id,data_id)

Definition at line 1871 of file dataDML.py.

01872                                                                  :
01873     '''
01874     input:
01875         hltrundata [pathnameclob(0),datasource(1)]
01876     output:
01877         (revision_id,entry_id,data_id)
01878     '''
01879     try:
01880          pathnames=hltrundata[0]
01881          datasource=hltrundata[1]
01882          npath=len(pathnames.split(','))
01883          entry_id=revisionDML.entryInBranch(schema,nameDealer.hltdataTableName(),str(runnumber),branchinfo[1])
01884          if entry_id is None:
01885              (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName())
01886              entryinfo=(revision_id,entry_id,str(runnumber),data_id)
01887              revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo)
01888          else:
01889              (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() )
01890              revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo)
01891          tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'}
01892          tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames}
01893          db=dbUtil.dbUtil(schema)
01894          db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict)
01895          return (revision_id,entry_id,data_id)
01896     except :
01897         raise 

def dataDML::addLumiRunDataToBranch (   schema,
  runnumber,
  lumirundata,
  branchinfo,
  tableName 
)
input:
      lumirundata [datasource,nominalenergy]
      branchinfo (branch_id,branch_name)
      tableName lumiruntablename
output:
      (revision_id,entry_id,data_id)

Definition at line 1813 of file dataDML.py.

01814                                                                              :
01815     '''
01816     input:
01817           lumirundata [datasource,nominalenergy]
01818           branchinfo (branch_id,branch_name)
01819           tableName lumiruntablename
01820     output:
01821           (revision_id,entry_id,data_id)
01822     '''
01823     try:
01824         datasource=lumirundata[0]
01825         nominalegev=3500.0
01826         if len(lumirundata)>1:
01827             nominalenergy=lumirundata[1]
01828         entry_id=revisionDML.entryInBranch(schema,tableName,str(runnumber),branchinfo[1])
01829         if entry_id is None:
01830             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,tableName)
01831             entryinfo=(revision_id,entry_id,str(runnumber),data_id)
01832             revisionDML.addEntry(schema,tableName,entryinfo,branchinfo)
01833         else:
01834             (revision_id,data_id)=revisionDML.bookNewRevision(schema,tableName)
01835             #print 'revision_id,data_id ',revision_id,data_id
01836             revisionDML.addRevision(schema,tableName,(revision_id,data_id),branchinfo)
01837         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NOMINALEGEV':'float'}
01838         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NOMINALEGEV':nominalegev}
01839         db=dbUtil.dbUtil(schema)
01840         db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
01841         return (revision_id,entry_id,data_id)
01842     except :
01843         raise

def dataDML::addNormToBranch (   schema,
  normname,
  amodetag,
  norm1,
  egev1,
  optionalnormdata,
  branchinfo 
)
input:
   branchinfo(normrevisionid,branchname)
   optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
output:
   (revision_id,entry_id,data_id)

Definition at line 1744 of file dataDML.py.

01745                                                                                      :
01746     '''
01747     input:
01748        branchinfo(normrevisionid,branchname)
01749        optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
01750     output:
01751        (revision_id,entry_id,data_id)
01752     '''
01753     #print 'branchinfo ',branchinfo
01754     norm_occ2=1.0
01755     if optionalnormdata.has_key('normOcc2'):
01756         norm_occ2=optionalnormdata['norm_occ2']
01757     norm_et=1.0
01758     if optionalnormdata.has_key('norm_et'):
01759         norm_et=optionalnormdata['norm_et']
01760     norm_pu=1.0
01761     if optionalnormdata.has_key('norm_pu'):
01762         norm_pu=optionalnormdata['norm_pu']
01763     constfactor=1.0
01764     if optionalnormdata.has_key('constfactor'):
01765         constfactor=optionalnormdata['constfactor']
01766     try:
01767         entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1])
01768         if entry_id is None:
01769             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName())
01770             entryinfo=(revision_id,entry_id,normname,data_id)
01771             revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo)
01772         else:
01773             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() )
01774             revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo)
01775         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','AMODETAG':'string','NORM_1':'float','EGEV_1':'unsigned int','NORM_OCC2':'float','NORM_ET':'float','NORM_PU':'float','CONSTFACTOR':'float'}
01776         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':normname,'AMODETAG':amodetag,'NORM_1':norm1,'EGEV_1':egev1,'NORM_OCC2':norm_occ2,'NORM_ET':norm_et,'NORM_PU':norm_pu,'CONSTFACTOR':constfactor}
01777         db=dbUtil.dbUtil(schema)
01778         db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict)
01779         return (revision_id,entry_id,data_id)
01780     except :
01781         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 1844 of file dataDML.py.

01845                                                                  :
01846     '''
01847     input:
01848        trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)]
01849        bitnames clob, bitnames separated by ','
01850     output:
01851        (revision_id,entry_id,data_id)
01852     '''
01853     try:   #fixme: need to consider revision only case
01854         datasource=trgrundata[0]
01855         bitzeroname=trgrundata[1]
01856         bitnames=trgrundata[2]
01857         entry_id=revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),str(runnumber),branchinfo[1])
01858         if entry_id is None:
01859             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.trgdataTableName())
01860             entryinfo=(revision_id,entry_id,str(runnumber),data_id)
01861             revisionDML.addEntry(schema,nameDealer.trgdataTableName(),entryinfo,branchinfo)
01862         else:
01863             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.trgdataTableName() )
01864             revisionDML.addRevision(schema,nameDealer.trgdataTableName(),(revision_id,data_id),branchinfo)
01865         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','SOURCE':'string','RUNNUM':'unsigned int','BITZERONAME':'string','BITNAMECLOB':'string'}
01866         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'SOURCE':datasource,'RUNNUM':int(runnumber),'BITZERONAME':bitzeroname,'BITNAMECLOB':bitnames}
01867         db=dbUtil.dbUtil(schema)
01868         db.insertOneRow(nameDealer.trgdataTableName(),tabrowDefDict,tabrowValueDict)
01869         return (revision_id,entry_id,data_id)
01870     except :
        raise
def dataDML::allfillschemes (   schema)

Definition at line 914 of file dataDML.py.

00915                           :
00916     afterglows=[]
00917     s=nameDealer.fillschemeTableName()
00918     try:
00919         qHandle.addToTableList(s)
00920         qResult=coral.AttributeList()
00921         qResult.extend('FILLSCHEMEPATTERN','string')
00922         qResult.extend('CORRECTIONFACTOR','float')
00923         qHandle.defineOutput(qResult)
00924         qHandle.addToOutputList('FILLSCHEMEPATTERN')
00925         qHandle.addToOutputList('CORRECTIONFACTOR')
00926         cursor=qHandle.execute()
00927         while cursor.next():
00928             fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
00929             afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
00930             afterglows.append((fillschemePattern,afterglowfac))
00931     except :
00932         del qHandle
00933         raise
00934     del qHandle
00935     return afterglows
    
def dataDML::beamInfoById (   schema,
  dataid,
  withBeamIntensity = False,
  minIntensity = 0.1 
)
result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..])
     beaminfolist=[(bxidx,beam1intensity,beam2intensity)]

Definition at line 1043 of file dataDML.py.

01044                                                                         :
01045     '''
01046     result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..])
01047          beaminfolist=[(bxidx,beam1intensity,beam2intensity)]
01048     '''
01049     runnum=0
01050     result=[]
01051     ncollidingbunches=0
01052     qHandle=schema.newQuery()
01053     try:
01054         qHandle.addToTableList(nameDealer.lumidataTableName())
01055         qHandle.addToOutputList('NCOLLIDINGBUNCHES')
01056         qConditionStr='DATA_ID=:dataid'
01057         qCondition=coral.AttributeList()
01058         qCondition.extend('dataid','unsigned long long')
01059         qCondition['dataid'].setData(dataid)
01060         qResult=coral.AttributeList()
01061         qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
01062         qHandle.defineOutput(qResult)
01063         qHandle.setCondition(qConditionStr,qCondition)
01064         cursor=qHandle.execute()
01065         while cursor.next():
01066             ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
01067     except :
01068         del qHandle
01069         raise
01070     del qHandle
01071     qHandle=schema.newQuery()
01072     try:
01073        qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
01074        qHandle.addToOutputList('RUNNUM')
01075        qHandle.addToOutputList('CMSLSNUM')
01076        qHandle.addToOutputList('LUMILSNUM')
01077        qHandle.addToOutputList('BEAMSTATUS')
01078        qHandle.addToOutputList('BEAMENERGY')
01079        if withBeamIntensity:
01080            qHandle.addToOutputList('CMSBXINDEXBLOB')
01081            qHandle.addToOutputList('BEAMINTENSITYBLOB_1')
01082            qHandle.addToOutputList('BEAMINTENSITYBLOB_2')
01083        qConditionStr='DATA_ID=:dataid'
01084        qCondition=coral.AttributeList()
01085        qCondition.extend('dataid','unsigned long long')
01086        qCondition['dataid'].setData(dataid)
01087        qResult=coral.AttributeList()
01088        qResult.extend('RUNNUM','unsigned int')
01089        qResult.extend('CMSLSNUM','unsigned int')
01090        qResult.extend('LUMILSNUM','unsigned int')
01091        qResult.extend('BEAMSTATUS','string')
01092        qResult.extend('BEAMENERGY','float')
01093        if withBeamIntensity:
01094            qResult.extend('BXINDEXBLOB','blob')
01095            qResult.extend('BEAM1INTENSITY','blob')
01096            qResult.extend('BEAM2INTENSITY','blob')
01097        qHandle.defineOutput(qResult)
01098        qHandle.setCondition(qConditionStr,qCondition)
01099        cursor=qHandle.execute()
01100        while cursor.next():
01101            runnum=cursor.currentRow()['RUNNUM'].data()
01102            cmslsnum=cursor.currentRow()['CMSLSNUM'].data()
01103            lumilsnum=cursor.currentRow()['LUMILSNUM'].data()
01104            beamstatus=cursor.currentRow()['BEAMSTATUS'].data()
01105            beamenergy=cursor.currentRow()['BEAMENERGY'].data()
01106            bxindexblob=None
01107            beaminfotupleList=[]
01108            if withBeamIntensity:
01109                bxindexblob=cursor.currentRow()['BXINDEXBLOB'].data()
01110                beam1intensityblob=cursor.currentRow()['BEAM1INTENSITY'].data()
01111                beam2intensityblob=cursor.currentRow()['BEAM2INTENSITY'].data()
01112                bxindexArray=None
01113                beam1intensityArray=None
01114                beam2intensityArray=None
01115                if bxindexblob:
01116                    bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h')
01117                if beam1intensityblob:
01118                    beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensityblob,'f')
01119                if beam2intensityblob:
01120                    beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensityblob,'f')
01121                if bxindexArray and beam1intensityArray and beam2intensityArray:
01122                    for idx,bxindex in enumerate(bxindexArray):
01123                        if (beam1intensityArray[idx] and beam1intensityArray[idx]>minIntensity) or (beam2intensityArray[idx] and beam2intensityArray[idx]>minIntensity):
01124                            beaminfotuple=(bxindex,beam1intensityArray[idx],beam2intensityArray[idx])                   
01125                            beaminfotupleList.append(beaminfotuple)
01126                    del bxindexArray[:]
01127                    del beam1intensityArray[:]
01128                    del beam2intensityArray[:]           
01129            result.append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beaminfotupleList))
01130     except:
01131        del qHandle
01132        raise
01133     del qHandle
    return (runnum,result)
def dataDML::bulkInsertHltLSData (   session,
  runnumber,
  data_id,
  hltlsdata,
  bulksize = 500 
)
input:
hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}

Definition at line 2010 of file dataDML.py.

02011                                                                          :
02012     '''
02013     input:
02014     hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
02015     '''
02016     print 'total number of hlt rows ',len(hltlsdata)
02017     lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')]
02018     committedrows=0
02019     nrows=0
02020     bulkvalues=[]   
02021     try:             
02022         for cmslsnum,perlshlt in hltlsdata.items():
02023             inputcountblob=perlshlt[0]
02024             acceptcountblob=perlshlt[1]
02025             prescaleblob=perlshlt[2]
02026             bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)])
02027             
02028             nrows+=1
02029             committedrows+=1
02030             if nrows==bulksize:
02031                 print 'committing hlt in LS chunck ',nrows
02032                 db=dbUtil.dbUtil(session.nominalSchema())
02033                 session.transaction().start(False)
02034                 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
02035                 session.transaction().commit()
02036                 nrows=0
02037                 bulkvalues=[]
02038             elif committedrows==len(hltlsdata):
02039                 print 'committing hlt at the end '
02040                 db=dbUtil.dbUtil(session.nominalSchema())
02041                 session.transaction().start(False)
02042                 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
02043                 session.transaction().commit()
02044     except  :
02045         print 'error in bulkInsertHltLSData'
02046         raise 
    
def dataDML::bulkInsertLumiLSSummary (   session,
  runnumber,
  data_id,
  lumilsdata,
  tableName,
  bulksize = 500,
  withDetails = True 
)
input:
      lumilsdata {lumilsnum:[cmslsnum,instlumi,instlumierror,instlumiquality,beamstatus,beamenergy,numorbit,startorbit,cmsbxindexblob,beam1intensity,beam2intensity,bxlumivalue_occ1,bxlumierror_occ1,bxlumiquality_occ1,bxlumivalue_occ2,bxlumierror_occ2,bxlumiquality_occ2,bxlumivalue_et,bxlumierror_et,bxlumiquality_et]}

Definition at line 2047 of file dataDML.py.

02048                                                                                                          :
02049     '''
02050     input:
02051           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]}
02052     '''
02053     lslumiDefDict=[]
02054     if withDetails:
02055         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')]
02056     else:
02057         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')]
02058     print 'total number of lumi rows ',len(lumilsdata)
02059     try:
02060         committedrows=0
02061         nrows=0
02062         bulkvalues=[]
02063         for lumilsnum,perlslumi in lumilsdata.items():
02064             cmslsnum=perlslumi[0]
02065             instlumi=perlslumi[1]
02066             instlumierror=perlslumi[2]
02067             instlumiquality=perlslumi[3]
02068             beamstatus=perlslumi[4]
02069             beamenergy=perlslumi[5]
02070             numorbit=perlslumi[6]
02071             startorbit=perlslumi[7]
02072             if withDetails:
02073                 cmsbxindexindexblob=perlslumi[8]
02074                 beam1intensity=perlslumi[9]
02075                 beam2intensity=perlslumi[10]
02076                 bxlumivalue_occ1=perlslumi[11]
02077                 bxlumierror_occ1=perlslumi[12]
02078                 bxlumiquality_occ1=perlslumi[13]
02079                 bxlumivalue_occ2=perlslumi[14]
02080                 bxlumierror_occ2=perlslumi[15]
02081                 bxlumiquality_occ2=perlslumi[16]
02082                 bxlumivalue_et=perlslumi[17]
02083                 bxlumierror_et=perlslumi[18]
02084                 bxlumiquality_et=perlslumi[19]
02085                 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)])
02086             else:
02087                 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)])
02088             nrows+=1
02089             committedrows+=1
02090             if nrows==bulksize:
02091                 print 'committing lumi in LS chunck ',nrows
02092                 db=dbUtil.dbUtil(session.nominalSchema())
02093                 session.transaction().start(False)
02094                 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
02095                 session.transaction().commit()
02096                 nrows=0
02097                 bulkvalues=[]
02098             elif committedrows==len(lumilsdata):
02099                 print 'committing lumi at the end '
02100                 db=dbUtil.dbUtil(session.nominalSchema())
02101                 session.transaction().start(False)
02102                 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
02103                 session.transaction().commit()
02104     except :
02105         raise
02106 
02107 #def insertLumiLSDetail(schema,runnumber,data_id,lumibxdata):
02108 #    '''
02109 #    input:
02110 #          lumibxdata [(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]})]
02111 #    output:
02112 #          nrows
02113 #    '''
02114 #    try:
02115 #        nrow=0
02116 #        bulkvalues=[]
02117 #        lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('ALGONAME','string'),('BXLUMIVALUE','blob'),('BXLUMIERROR','blob'),('BXLUMIQUALITY','blob')]
02118 #        for (algoname,peralgobxdata) in lumibxdata:
02119 #            for lumilsnum,bxdata in peralgobxdata.items():
02120 #                cmslsnum=bxdata[0]
02121 #                bxlumivalue=bxdata[1]
02122 #                bxlumierror=bxdata[2]
02123 #                bxlumiquality=bxdata[3]
02124 #                bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('ALGONAME',algoname),('BXLUMIVALUE',bxlumivalue),('BXLUMIERROR',bxlumierror),('BXLUMIQUALITY',bxlumiquality)])
02125 #        db=dbUtil.dbUtil(schema)
02126 #        db.bulkInsert(nameDealer.lumidetailTableName(),lslumiDefDict,bulkvalues)
02127 #        return len(bulkvalues)
02128 #    except:
02129 #        raise 
02130     
02131 #def completeOldLumiData(schema,runnumber,lsdata,data_id):
02132 #    '''
02133 #    input:
02134 #    lsdata [[lumisummary_id,lumilsnum,cmslsnum]]
02135 #    '''
02136 #    try:
02137 #        #update in lumisummary table
02138 #        #print 'insert in lumisummary table'
02139 #        setClause='DATA_ID=:data_id'
02140 #        updateCondition='RUNNUM=:runnum AND DATA_ID is NULL'
02141 #        updateData=coral.AttributeList()
02142 #        updateData.extend('data_id','unsigned long long')
02143 #        updateData.extend('runnum','unsigned int')
02144 #        updateData['data_id'].setData(data_id)
02145 #        updateData['runnum'].setData(int(runnumber))
02146 #        db=dbUtil.dbUtil(schema)
02147 #        db.singleUpdate(nameDealer.lumisummaryTableName(),setClause,updateCondition,updateData)
02148 #        #updates in lumidetail table
02149 #        updateAction='DATA_ID=:data_id,RUNNUM=:runnum,CMSLSNUM=:cmslsnum,LUMILSNUM=:lumilsnum'
02150 #        updateCondition='LUMISUMMARY_ID=:lumisummary_id'
02151 #        bindvarDef=[]
02152 #        bindvarDef.append(('data_id','unsigned long long'))
02153 #        bindvarDef.append(('runnum','unsigned int'))
02154 #        bindvarDef.append(('cmslsnum','unsigned int'))
02155 #        bindvarDef.append(('lumilsnum','unsigned int'))        
02156 #        inputData=[]
02157 #        for [lumisummary_id,lumilsnum,cmslsnum] in lsdata:
02158 #            inputData.append([('data_id',data_id),('runnum',int(runnumber)),('cmslsnum',cmslsnum),('lumilsnum',lumilsnum)])
02159 #        db.updateRows(nameDealer.lumidetailTableName(),updateAction,updateCondition,bindvarDef,inputData)
02160 #    except:
02161 #        raise
02162     
02163 #=======================================================
02164 #   DELETE
02165 #=======================================================
02166 
02167 
02168 #=======================================================
02169 #   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 1970 of file dataDML.py.

01971                                                                          :
01972     '''
01973     insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks 
01974     input:
01975         trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
01976     result nrows inserted
01977     if nrows==0, then this insertion failed
01978     '''
01979     print 'total number of trg rows ',len(trglsdata)
01980     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')]
01981     committedrows=0
01982     nrows=0
01983     bulkvalues=[]
01984     try:
01985         for cmslsnum,perlstrg in trglsdata.items():
01986             deadtimecount=perlstrg[0]           
01987             bitzerocount=perlstrg[1]
01988             bitzeroprescale=perlstrg[2]
01989             trgcountblob=perlstrg[3]
01990             trgprescaleblob=perlstrg[4]
01991             bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)])
01992             nrows+=1
01993             committedrows+=1
01994             if nrows==bulksize:
01995                 print 'committing trg in LS chunck ',nrows
01996                 db=dbUtil.dbUtil(session.nominalSchema())
01997                 session.transaction().start(False)
01998                 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
01999                 session.transaction().commit()
02000                 nrows=0
02001                 bulkvalues=[]
02002             elif committedrows==len(trglsdata):
02003                 print 'committing trg at the end '
02004                 db=dbUtil.dbUtil(session.nominalSchema())
02005                 session.transaction().start(False)
02006                 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
02007                 session.transaction().commit()
02008     except :
02009         print 'error in bulkInsertTrgLSData'
        raise 
def dataDML::correctionByName (   schema,
  correctiontagname = None 
)
get correction coefficients by name
input: correctiontagname if None,get current default
output: [tagname,a1,a2,drift]
if not correctiontagname
select entry_name,data_id,a1,a2,drift from lumicorrections where 
else:
select entry_name,data_id,a1,a2,drift from lumicorrections where entry_name=:correctiontagname

Definition at line 873 of file dataDML.py.

00874                                                    :
00875     '''
00876     get correction coefficients by name
00877     input: correctiontagname if None,get current default
00878     output: [tagname,a1,a2,drift]
00879     if not correctiontagname
00880     select entry_name,data_id,a1,a2,drift from lumicorrections where 
00881     else:
00882     select entry_name,data_id,a1,a2,drift from lumicorrections where entry_name=:correctiontagname
00883     '''
00884 
    
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 1657 of file dataDML.py.

01658                                                 :
01659     '''
01660     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;
01661     check on entryrev
01662    
01663     return [lumientryid,trgentryid,hltentryid]
01664     '''
01665     result=[]
01666     qHandle=schema.newQuery()
01667     try:
01668         qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() ))
01669         qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() ))
01670         qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() ))
01671         qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid')
01672         qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid')
01673         qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid')
01674         qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr'
01675         qCondition=coral.AttributeList()
01676         qCondition.extend('runnumstr','string')
01677         qCondition['runnumstr'].setData(str(runnum))
01678         qResult=coral.AttributeList()
01679         qResult.extend('lumientryid','unsigned long long')
01680         qResult.extend('trgentryid','unsigned long long')
01681         qResult.extend('hltentryid','unsigned long long')
01682         qHandle.defineOutput(qResult)
01683         qHandle.setCondition(qConditionStr,qCondition)
01684         cursor=qHandle.execute()
01685         while cursor.next():
01686             lumientryid=cursor.currentRow()['lumientryid'].data()
01687             trgentryid=cursor.currentRow()['trgentryid'].data()
01688             hltentryid=cursor.currentRow()['hltentryid'].data()
01689             if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter:
01690                 result.extend([lumientryid,trgentryid,hltentryid])
01691     except:
01692         del qHandle
01693         raise 
01694     del qHandle
01695     return result

def dataDML::fillInRange (   schema,
  fillmin,
  fillmax,
  amodetag,
  startT,
  stopT 
)
select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag]
output: [fill]

Definition at line 87 of file dataDML.py.

00088                                                              :
00089     '''
00090     select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag]
00091     output: [fill]
00092     '''
00093     result=[]
00094     tmpresult={}
00095     qHandle=schema.newQuery()
00096     r=nameDealer.cmsrunsummaryTableName()
00097     lute=lumiTime.lumiTime()
00098     try:
00099         qHandle.addToTableList(r)
00100         qConditionPieces=[]
00101         qConditionStr=''
00102         qCondition=coral.AttributeList()
00103         if fillmin:
00104             qConditionPieces.append('FILLNUM>=:fillmin')
00105             qCondition.extend('fillmin','unsigned int')
00106             qCondition['fillmin'].setData(int(fillmin))
00107         if fillmax:
00108             qConditionPieces.append('FILLNUM<=:fillmax')
00109             qCondition.extend('fillmax','unsigned int')
00110             qCondition['fillmax'].setData(int(fillmax))
00111         if amodetag:
00112             qConditionPieces.append('AMODETAG=:amodetag')
00113             qCondition.extend('amodetag','string')
00114             qCondition['amodetag'].setData(amodetag)
00115         if len(qConditionPieces)!=0:
00116             qConditionStr=(' AND ').join(qConditionPieces)
00117         qResult=coral.AttributeList()
00118         qResult.extend('fillnum','unsigned int')
00119         qResult.extend('runnum','unsigned int')
00120         qResult.extend('starttime','string')
00121         qHandle.defineOutput(qResult)
00122         if len(qConditionStr)!=0:
00123             qHandle.setCondition(qConditionStr,qCondition)
00124         qHandle.addToOutputList('FILLNUM','fillnum')
00125         qHandle.addToOutputList('RUNNUM','runnum')
00126         qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime')
00127         cursor=qHandle.execute()
00128         while cursor.next():
00129             currentfill=cursor.currentRow()['fillnum'].data()
00130             runnum=cursor.currentRow()['runnum'].data()
00131             starttimeStr=cursor.currentRow()['starttime'].data()
00132             runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
00133             minTime=None
00134             maxTime=None
00135             if startT and stopT:
00136                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00137                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')                
00138                 if runTime>=minTime and runTime<=maxTime:
00139                     tmpresult.setdefault(currentfill,[]).append(runnum)
00140             elif startT is not None:
00141                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00142                 if runTime>=minTime:
00143                     tmpresult.setdefault(currentfill,[]).append(runnum)
00144             elif stopT is not None:
00145                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
00146                 if runTime<=maxTime:
00147                     tmpresult.setdefault(currentfill,[]).append(runnum)
00148             else:                
00149                 tmpresult.setdefault(currentfill,[]).append(runnum)
00150         #print tmpresult
00151         for f in sorted(tmpresult):
00152             if tmpresult[f]:
00153                 result.append(f)
00154     except :
00155         del qHandle
00156         raise
00157     del qHandle
    return result    
def dataDML::fillrunMap (   schema,
  fillnum = None,
  runmin = None,
  runmax = None,
  startT = None,
  stopT = None,
  l1keyPattern = None,
  hltkeyPattern = None,
  amodetag = None 
)
select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ]
output: {fill:[runnum,...]}

Definition at line 158 of file dataDML.py.

00159                                                                                                                                      :
00160     '''
00161     select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ]
00162     output: {fill:[runnum,...]}
00163     '''
00164     result={}
00165     timelesslist=[]
00166     qHandle=schema.newQuery()
00167     r=nameDealer.cmsrunsummaryTableName()
00168     lute=lumiTime.lumiTime()
00169     try:
00170         qHandle.addToTableList(r)
00171         qConditionPieces=[]
00172         qConditionStr=''
00173         qCondition=coral.AttributeList()        
00174         if fillnum:
00175             qConditionPieces.append('FILLNUM=:fillnum')
00176             qCondition.extend('fillnum','unsigned int')
00177             qCondition['fillnum'].setData(int(fillnum))
00178         if runmin:
00179             qConditionPieces.append('RUNNUM>=:runmin')
00180             qCondition.extend('runmin','unsigned int')
00181             qCondition['runmin'].setData(runmin)
00182         if runmax:
00183             qConditionPieces.append('RUNNUM<=:runmax')
00184             qCondition.extend('runmax','unsigned int')
00185             qCondition['runmax'].setData(runmax)
00186         if amodetag:
00187             qConditionPieces.append('AMODETAG=:amodetag')
00188             qCondition.extend('amodetag','string')
00189             qCondition['amodetag'].setData(amodetag)
00190         if l1keyPattern:
00191             qConditionPieces.append('regexp_like(L1KEY,:l1keypattern)')
00192             qCondition.extend('l1keypattern','string')
00193             qCondition['l1keypattern'].setData(l1keyPattern)
00194         if hltkeyPattern:
00195             qConditionPieces.append('regexp_like(HLTKEY,:hltkeypattern)')
00196             qCondition.extend('hltkeypattern','string')
00197             qCondition['hltkeypattern'].setData(hltkeyPattern)
00198         if len(qConditionPieces)!=0:
00199             qConditionStr=(' AND ').join(qConditionPieces)        
00200         qResult=coral.AttributeList()
00201         qResult.extend('fillnum','unsigned int')
00202         qResult.extend('runnum','unsigned int')
00203         qResult.extend('starttime','string')
00204         qHandle.defineOutput(qResult)
00205         if len(qConditionStr) !=0:
00206             qHandle.setCondition(qConditionStr,qCondition)
00207         qHandle.addToOutputList('FILLNUM','fillnum')    
00208         qHandle.addToOutputList('RUNNUM','runnum')
00209         qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime')
00210         cursor=qHandle.execute()        
00211         while cursor.next():
00212             currentfill=cursor.currentRow()['fillnum'].data()
00213             starttimeStr=cursor.currentRow()['starttime'].data()
00214             runnum=cursor.currentRow()['runnum'].data()
00215             runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
00216             minTime=None
00217             maxTime=None
00218             if startT and stopT:
00219                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00220                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')                
00221                 if runTime>=minTime and runTime<=maxTime:
00222                     result.setdefault(currentfill,[]).append(runnum)
00223             elif startT is not None:
00224                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00225                 if runTime>=minTime:
00226                     result.setdefault(currentfill,[]).append(runnum)
00227             elif stopT is not None:
00228                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
00229                 if runTime<=maxTime:
00230                     result.setdefault(currentfill,[]).append(runnum)
00231             else:                
00232                 result.setdefault(currentfill,[]).append(runnum)
00233     except :
00234         del qHandle
00235         raise
00236     del qHandle
00237     return result
    
def dataDML::fillschemeByRun (   schema,
  runnum 
)

Definition at line 885 of file dataDML.py.

00886                                   :
00887     fillscheme=''
00888     ncollidingbunches=0
00889     r=nameDealer.cmsrunsummaryTableName()
00890     qHandle=schema.newQuery()
00891     try:
00892         qHandle.addToTableList(r)
00893         qHandle.addToOutputList('FILLSCHEME')
00894         qHandle.addToOutputList('NCOLLIDINGBUNCHES')
00895         qResult=coral.AttributeList()
00896         qResult.extend('FILLSCHEME','string')
00897         qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
00898         qConditionStr='RUNNUM=:runnum'
00899         qCondition=coral.AttributeList()
00900         qCondition.extend('runnum','unsigned int')
00901         qCondition['runnum'].setData(int(runnum))
00902         qHandle.defineOutput(qResult)
00903         qHandle.setCondition(qConditionStr,qCondition)
00904         cursor=qHandle.execute()
00905         while cursor.next(): 
00906             if not cursor.currentRow()['NCOLLIDINGBUNCHES'].isNull():
00907                 ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
00908             if not cursor.currentRow()['FILLSCHEME'].isNull():
00909                 fillscheme=cursor.currentRow()['FILLSCHEME'].data()
00910     except :
00911         del qHandle
00912         raise
00913     del qHandle
    return (fillscheme,ncollidingbunches)
def dataDML::fillschemePatternMap (   schema,
  lumitype 
)
output:(patternStr:correctionFac)

Definition at line 1423 of file dataDML.py.

01424                                          :
01425     '''
01426     output:(patternStr:correctionFac)
01427     '''
01428     if lumitype not in ['PIXEL','HF']:
01429         raise ValueError('[ERROR] unsupported lumitype '+lumitype)
01430     correctorField='CORRECTIONFACTOR'
01431     if lumitype=='PIXEL':
01432         correctorField='PIXELCORRECTIONFACTOR'
01433     result={}
01434     qHandle=schema.newQuery()
01435     try:
01436         qHandle.addToTableList(nameDealer.fillschemeTableName())
01437         qResult=coral.AttributeList()
01438         qResult.extend('FILLSCHEMEPATTERN','string')
01439         qResult.extend('CORRECTIONFACTOR','float')
01440         qHandle.defineOutput(qResult)
01441         qHandle.addToOutputList('FILLSCHEMEPATTERN')
01442         qHandle.addToOutputList(correctorField)
01443         cursor=qHandle.execute()
01444         while cursor.next():
01445             fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
01446             afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
01447             result[fillschemePattern]=afterglowfac
01448     except :
01449         del qHandle
01450         raise
01451     del qHandle
01452     return result

def dataDML::guesscorrIdByName (   schema,
  tagname = None 
)

LumiDB DML API # # Author: Zhen Xie #.

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

Definition at line 14 of file dataDML.py.

00015                                           :
00016     '''
00017     select data_id from lumicorrectionss [where entry_name=:tagname]
00018     result lumicorrectionsdataid
00019     
00020     '''
00021     lumicorrectionids=[]
00022     result=None
00023     qHandle=schema.newQuery()
00024     try:
00025         qHandle.addToTableList( nameDealer.lumicorrectionsTableName() )
00026         qHandle.addToOutputList('DATA_ID')
00027         if tagname:
00028             qConditionStr='ENTRY_NAME=:tagname '
00029             qCondition=coral.AttributeList()
00030             qCondition.extend('tagname','string')
00031             qCondition['tagname'].setData(tagname)
00032         qResult=coral.AttributeList()
00033         qResult.extend('DATA_ID','unsigned long long')
00034         qHandle.defineOutput(qResult)
00035         if tagname:
00036             qHandle.setCondition(qConditionStr,qCondition)
00037         cursor=qHandle.execute()
00038         while cursor.next():
00039             dataid=cursor.currentRow()['DATA_ID'].data()
00040             lumicorrectionids.append(dataid)
00041     except :
00042         del qHandle
00043         raise
00044     del qHandle
00045     if len(lumicorrectionids) !=0:return max(lumicorrectionids)
00046     return result

def dataDML::guessDataIdByRun (   schema,
  runnum,
  tablename,
  revfilter = None 
)
select max data_id of the given run. In current design, it's the most recent data of the run

Definition at line 1471 of file dataDML.py.

01472                                                             :
01473     '''
01474     select max data_id of the given run. In current design, it's the most recent data of the run
01475     '''
01476     result=None
01477     ids=[]
01478     qHandle=schema.newQuery()
01479     try:
01480         qHandle.addToTableList(tablename)
01481         qHandle.addToOutputList('DATA_ID')
01482         qConditionStr='RUNNUM=:runnum '
01483         qCondition=coral.AttributeList()
01484         qCondition.extend('runnum','unsigned int')
01485         qCondition['runnum'].setData(runnum)
01486         qResult=coral.AttributeList()
01487         qResult.extend('DATA_ID','unsigned long long')
01488         qHandle.defineOutput(qResult)
01489         qHandle.setCondition(qConditionStr,qCondition)
01490         cursor=qHandle.execute()
01491         while cursor.next():
01492             dataid=cursor.currentRow()['DATA_ID'].data()
01493             ids.append(dataid)
01494     except :
01495         del qHandle
01496         raise 
01497     del qHandle
01498     if len(ids)>0 :
01499         return max(ids)
01500     else:
01501         return result
        
def dataDML::guessDataIdForRange (   schema,
  inputRange,
  tablename 
)
input: inputRange [run]
output: {run:lumiid}
select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin 

Definition at line 1502 of file dataDML.py.

01503                                                     :
01504     '''
01505     input: inputRange [run]
01506     output: {run:lumiid}
01507     select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin 
01508     '''
01509     result={}
01510     if not inputRange : return result
01511     if len(inputRange)==1:
01512         trgid=guessDataIdByRun(schema,inputRange[0],tablename)
01513         result[inputRange[0]]=trgid
01514         return result
01515     rmin=min(inputRange)
01516     rmax=max(inputRange)
01517     result=dict.fromkeys(inputRange,None)
01518     qHandle=schema.newQuery()
01519     try:
01520         qHandle.addToTableList(tablename)
01521         qHandle.addToOutputList('DATA_ID')
01522         qHandle.addToOutputList('RUNNUM')
01523         qConditionStr='RUNNUM>=:rmin'
01524         qCondition=coral.AttributeList()
01525         qCondition.extend('rmin','unsigned int')
01526         qCondition['rmin'].setData(rmin)
01527         if rmin!=rmax:
01528             qConditionStr+=' AND RUNNUM<=:rmax'
01529             qCondition.extend('rmax','unsigned int')
01530             qCondition['rmax'].setData(rmax)
01531         qResult=coral.AttributeList()
01532         qResult.extend('DATA_ID','unsigned long long')
01533         qResult.extend('RUNNUM','unsigned int')
01534         qHandle.defineOutput(qResult)
01535         qHandle.setCondition(qConditionStr,qCondition)
01536         cursor=qHandle.execute()
01537         while cursor.next():
01538             dataid=cursor.currentRow()['DATA_ID'].data()
01539             runnum=cursor.currentRow()['RUNNUM'].data()
01540             if result.has_key(runnum):
01541                 if dataid>result[runnum]:
01542                     result[runnum]=dataid
01543     except :
01544         del qHandle
01545         raise 
01546     del qHandle
01547     return result
01548 #def guessAllDataIdByRun(schema,runnum):
01549 #    '''
01550 #    get dataids by runnumber, if there are duplicates, pick max(dataid).Bypass full version lookups
01551 #    result (lumidataid(0),trgdataid(1),hltdataid(2)) 
01552 #    '''
01553 #    lumiids=[]
01554 #    trgids=[]
01555 #    hltids=[]
01556 #    qHandle=schema.newQuery()
01557 #    try:
01558 #        qHandle.addToTableList(nameDealer.lumidataTableName(),'l')
01559 #        qHandle.addToTableList(nameDealer.trgdataTableName(),'t')
01560 #        qHandle.addToTableList(nameDealer.hltdataTableName(),'h')
01561 #        qHandle.addToOutputList('l.DATA_ID','lumidataid')
01562 #        qHandle.addToOutputList('t.DATA_ID','trgdataid')
01563 #        qHandle.addToOutputList('h.DATA_ID','hltdataid')
01564 #        qConditionStr='l.RUNNUM=t.RUNNUM and t.RUNNUM=h.RUNNUM and l.RUNNUM=:runnum '
01565 #        qCondition=coral.AttributeList()
01566 #        qCondition.extend('runnum','unsigned int')
01567 #        qCondition['runnum'].setData(runnum)
01568 #        qResult=coral.AttributeList()
01569 #        qResult.extend('lumidataid','unsigned long long')
01570 #        qResult.extend('trgdataid','unsigned long long')
01571 #        qResult.extend('hltdataid','unsigned long long')
01572 #        qHandle.defineOutput(qResult)
01573 #        qHandle.setCondition(qConditionStr,qCondition)
01574 #        cursor=qHandle.execute()
01575 #        while cursor.next():
01576 #            lumidataid=cursor.currentRow()['lumidataid'].data()
01577 #            trgdataid=cursor.currentRow()['trgdataid'].data()
01578 #            hltdataid=cursor.currentRow()['hltdataid'].data()
01579 #            lumiids.append(lumidataid)
01580 #            trgids.append(trgdataid)
01581 #            hltids.append(hltdataid)
01582 #    except :
01583 #        del qHandle
01584 #        raise 
01585 #    del qHandle
01586 #    if len(lumiids)>0 and len(trgids)>0 and len(hltids)>0:
01587 #        return (max(lumiids),max(trgids),max(hltids))
01588 #    else:
01589 #        return (None,None,None)

def dataDML::guessHltDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1465 of file dataDML.py.

01465                                                                    :    
01466     revlist=revisionDML.revisionsInBranchName(schema,branchName)
01467     hltentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
01468     latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,hltentry_id,revlist)
01469     return latestrevision
01470 
def dataDML::guessLumiDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1453 of file dataDML.py.

01454                                                                     :
01455     revlist=revisionDML.revisionsInBranchName(schema,branchName)
01456     lumientry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
01457     latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,lumientry_id,revlist)
01458     return latestrevision
        
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 1590 of file dataDML.py.

01591                                                :
01592     '''
01593     get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
01594     select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1   
01595     '''
01596     luminormids=[]
01597     qHandle=schema.newQuery()
01598     egevmin=egev1*0.95
01599     egevmax=egev1*1.05
01600     try:
01601         qHandle.addToTableList( nameDealer.luminormTableName() )
01602         qHandle.addToOutputList('DATA_ID','normdataid')
01603         qConditionStr='AMODETAG=:amodetag AND EGEV_1>=:egevmin AND  EGEV_1<=:egevmax'
01604         qCondition=coral.AttributeList()
01605         qCondition.extend('amodetag','string')
01606         qCondition.extend('egevmin','unsigned int')
01607         qCondition.extend('egevmax','unsigned int')
01608         qCondition['amodetag'].setData(amodetag)
01609         qCondition['egevmin'].setData(int(egevmin))
01610         qCondition['egevmax'].setData(int(egevmax))
01611         qResult=coral.AttributeList()
01612         qResult.extend('normdataid','unsigned long long')
01613         qHandle.defineOutput(qResult)
01614         qHandle.setCondition(qConditionStr,qCondition)
01615         cursor=qHandle.execute()
01616         while cursor.next():
01617             normdataid=cursor.currentRow()['normdataid'].data()
01618             luminormids.append(normdataid)
01619     except :
01620         del qHandle
01621         raise
01622     del qHandle
01623     if len(luminormids) !=0:return max(luminormids)
01624     return None

def dataDML::guessnormIdByName (   schema,
  normname 
)
get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
select data_id from luminorms where entry_name=:normname
result luminormdataid

Definition at line 1625 of file dataDML.py.

01626                                       :
01627     '''
01628     get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
01629     select data_id from luminorms where entry_name=:normname
01630     result luminormdataid
01631     '''   
01632     luminormids=[]
01633     qHandle=schema.newQuery()
01634     try:
01635         qHandle.addToTableList( nameDealer.luminormTableName() )
01636         qHandle.addToOutputList('DATA_ID','normdataid')
01637         qConditionStr='ENTRY_NAME=:normname '
01638         qCondition=coral.AttributeList()
01639         qCondition.extend('normname','string')
01640         qCondition['normname'].setData(normname)
01641         qResult=coral.AttributeList()
01642         qResult.extend('normdataid','unsigned long long')
01643         qHandle.defineOutput(qResult)
01644         qHandle.setCondition(qConditionStr,qCondition)
01645         cursor=qHandle.execute()
01646         while cursor.next():
01647             normdataid=cursor.currentRow()['normdataid'].data()
01648             luminormids.append(normdataid)
01649     except :
01650         del qHandle
01651         raise
01652     del qHandle
01653     if len(luminormids) !=0:return max(luminormids)
01654     return None

def dataDML::guessTrgDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1459 of file dataDML.py.

01459                                                                    :    
01460     revlist=revisionDML.revisionsInBranchName(schema,branchName)
01461     trgentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
01462     latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,trgentry_id,revlist)
01463     return latestrevision
01464 
def dataDML::hltLSById (   schema,
  dataid,
  hltpathname = None,
  hltpathpattern = None,
  withL1Pass = False,
  withHLTAccept = False 
)
result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 

Definition at line 1288 of file dataDML.py.

01289                                                                                                       :
01290     '''
01291     result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 
01292     '''
01293     #print 'entering hltLSById '
01294     #t0=time.time()
01295     result={}
01296     hltrundata=hltRunById(schema,dataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
01297     if not hltrundata:
01298         return result        
01299     hltnamedict=hltrundata[3]
01300     if not hltnamedict:
01301         return (hltrundata[0],{})
01302     #tt1=time.time()
01303     #print '\thltrunbyid time ',tt1-t0
01304     #tt0=time.time()
01305     qHandle=schema.newQuery()
01306     try:
01307         qHandle.addToTableList(nameDealer.lshltTableName())
01308         qHandle.addToOutputList('RUNNUM','runnum')
01309         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
01310         if len(hltnamedict)!=0:
01311             qHandle.addToOutputList('PRESCALEBLOB','prescaleblob')
01312         if withL1Pass:
01313             qHandle.addToOutputList('HLTCOUNTBLOB','hltcountblob')
01314         if withHLTAccept:
01315             qHandle.addToOutputList('HLTACCEPTBLOB','hltacceptblob')
01316         qConditionStr='DATA_ID=:dataid'
01317         qCondition=coral.AttributeList()
01318         qCondition.extend('dataid','unsigned long long')
01319         qCondition['dataid'].setData(dataid)
01320         qResult=coral.AttributeList()
01321         qResult.extend('runnum','unsigned int')
01322         qResult.extend('cmslsnum','unsigned int')
01323         if len(hltnamedict)!=0:
01324             qResult.extend('prescaleblob','blob')
01325         if withL1Pass:
01326             qResult.extend('hltcountblob','blob')
01327         if withHLTAccept:
01328             qResult.extend('hltacceptblob','blob')
01329         qHandle.defineOutput(qResult)
01330         qHandle.setCondition(qConditionStr,qCondition)
01331         cursor=qHandle.execute()
01332         while cursor.next():
01333             runnum=cursor.currentRow()['runnum'].data()
01334             cmslsnum=cursor.currentRow()['cmslsnum'].data()
01335             prescaleblob=None
01336             hltcountblob=None
01337             hltacceptblob=None
01338             if len(hltnamedict)!=0:
01339                 prescaleblob=cursor.currentRow()['prescaleblob'].data()
01340             if withL1Pass:
01341                 hltcountblob=cursor.currentRow()['hltcountblob'].data()
01342             if withHLTAccept:
01343                 hltacceptblob=cursor.currentRow()['hltacceptblob'].data()
01344             if not result.has_key(cmslsnum):
01345                 result[cmslsnum]=[]
01346             pathinfo=[]
01347             prescales=None
01348             hltcounts=None
01349             hltaccepts=None
01350             if prescaleblob:
01351                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
01352                     prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'l')
01353                 else:
01354                     prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'I')
01355             if hltcountblob:
01356                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
01357                     hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'l')
01358                 else:
01359                     hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'I')
01360             if hltacceptblob:
01361                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
01362                     hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'l')
01363                 else:
01364                     hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'I')
01365             for (hltpathidx,thispathname) in hltnamedict:#loop over selected paths
01366                 thispresc=0
01367                 thishltcount=0
01368                 thisaccept=0
01369                 if prescales:
01370                     thispresc=prescales[hltpathidx]
01371                 if hltcounts:
01372                     thishltcount=hltcounts[hltpathidx]
01373                 if hltaccepts:
01374                     thisaccept=hltaccepts[hltpathidx]
01375                 thispathinfo=(thispathname,thispresc,thishltcount,thisaccept)
01376                 pathinfo.append(thispathinfo)
01377             result[cmslsnum]=pathinfo
01378     except :
01379         del qHandle
01380         raise
01381     del qHandle
01382     #tt1=time.time()
01383     #print '\tdb stuff time ',tt1-tt0
01384     #t1=time.time()
01385     #print 'tot hltLSById time ',t1-t0
01386     return (runnum,result)

def dataDML::hltRunById (   schema,
  dataid,
  hltpathname = None,
  hltpathpattern = None 
)
result [runnum(0),datasource(1),npath(2),hltnamedict(3)]
output :
     npath : total number of hltpath in DB
     hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)]

Definition at line 1184 of file dataDML.py.

01185                                                                   :
01186     '''
01187     result [runnum(0),datasource(1),npath(2),hltnamedict(3)]
01188     output :
01189          npath : total number of hltpath in DB
01190          hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)]
01191     '''
01192     result=[]    
01193     qHandle=schema.newQuery()
01194     runnum=None
01195     datasource=None
01196     npath=None
01197     hltnamedict=[]
01198     try:
01199         qHandle.addToTableList(nameDealer.hltdataTableName())
01200         qHandle.addToOutputList('RUNNUM','runnum')
01201         qHandle.addToOutputList('SOURCE','datasource')
01202         qHandle.addToOutputList('NPATH','npath')
01203         qHandle.addToOutputList('PATHNAMECLOB','pathnameclob')
01204         qConditionStr='DATA_ID=:dataid'
01205         qCondition=coral.AttributeList()
01206         qCondition.extend('dataid','unsigned long long')
01207         qCondition['dataid'].setData(dataid)
01208         qResult=coral.AttributeList()
01209         qResult.extend('runnum','unsigned int')
01210         qResult.extend('datasource','string')
01211         qResult.extend('npath','unsigned int')
01212         qResult.extend('pathnameclob','string')
01213         qHandle.defineOutput(qResult)
01214         qHandle.setCondition(qConditionStr,qCondition)
01215         cursor=qHandle.execute()
01216         pathnameclob=None
01217         pathnames=[]
01218         while cursor.next():
01219             runnum=cursor.currentRow()['runnum'].data()
01220             datasource=cursor.currentRow()['datasource'].data()
01221             npath=cursor.currentRow()['npath'].data()
01222             pathnameclob=cursor.currentRow()['pathnameclob'].data()
01223         if pathnameclob:
01224             pathnames=pathnameclob.split(',')
01225             for pathnameidx,hltname in enumerate(pathnames):
01226                 if hltpathname:
01227                     if hltpathname==hltname:
01228                         hltnamedict.append((pathnameidx,hltname))
01229                         break
01230                 elif hltpathpattern:
01231                     if fnmatch.fnmatch(hltname,hltpathpattern):
01232                         hltnamedict.append((pathnameidx,hltname))
01233                 #else:
01234                     #hltnamedict.append((pathnameidx,hltname))
01235         result=[runnum,datasource,npath,hltnamedict]
01236     except :
01237         del qHandle
01238         raise 
01239     del qHandle
01240     return result

def dataDML::hlttrgMappingByrun (   schema,
  runnum,
  hltpathname = None,
  hltpathpattern = None 
)
select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname] 
output: {hltpath:l1seed}

Definition at line 1241 of file dataDML.py.

01242                                                                           :
01243     '''
01244     select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname] 
01245     output: {hltpath:l1seed}
01246     '''
01247     result={}
01248     queryHandle=schema.newQuery()
01249     r=nameDealer.cmsrunsummaryTableName()
01250     m=nameDealer.trghltMapTableName()
01251     if hltpathpattern and hltpathpattern in ['*','all','All','ALL']:
01252         hltpathpattern=None
01253     try:
01254         queryHandle.addToTableList(r)
01255         queryHandle.addToTableList(m)
01256         queryCondition=coral.AttributeList()
01257         queryCondition.extend('runnum','unsigned int')
01258         queryCondition['runnum'].setData(int(runnum))
01259         #queryHandle.addToOutputList(m+'.HLTKEY','hltkey')
01260         queryHandle.addToOutputList(m+'.HLTPATHNAME','hltpathname')
01261         queryHandle.addToOutputList(m+'.L1SEED','l1seed')
01262         conditionStr=r+'.RUNNUM=:runnum and '+m+'.HLTKEY='+r+'.HLTKEY'
01263         if hltpathname:
01264             hltpathpattern=None
01265             conditionStr+=' AND '+m+'.HLTPATHNAME=:hltpathname'
01266             queryCondition.extend('hltpathname','string')
01267             queryCondition['hltpathname'].setData(hltpathname)
01268         queryHandle.setCondition(conditionStr,queryCondition)
01269         queryResult=coral.AttributeList()
01270         queryResult.extend('pname','string')
01271         queryResult.extend('l1seed','string')
01272         queryHandle.defineOutput(queryResult)
01273         cursor=queryHandle.execute()
01274         while cursor.next():
01275             pname=cursor.currentRow()['pname'].data()
01276             l1seed=cursor.currentRow()['l1seed'].data()
01277             if not result.has_key(hltpathname):
01278                 if hltpathpattern:
01279                     if fnmatch.fnmatch(pname,hltpathpattern):
01280                         result[pname]=l1seed
01281                 else:
01282                     result[pname]=l1seed
01283     except :
01284         del queryHandle
01285         raise
01286     del queryHandle
01287     return result

def dataDML::insertRunSummaryData (   schema,
  runnumber,
  runsummarydata,
  complementalOnly = False 
)
input:
    runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
output:

Definition at line 1898 of file dataDML.py.

01899                                                                                 :
01900     '''
01901     input:
01902         runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
01903     output:
01904     '''
01905     l1key=runsummarydata[0]
01906     amodetag=runsummarydata[1]
01907     egev=runsummarydata[2]
01908     hltkey=''
01909     fillnum=0
01910     sequence=''
01911     starttime=''
01912     stoptime=''
01913     if not complementalOnly:
01914         sequence=runsummarydata[3]
01915         hltkey=runsummarydata[4]
01916         fillnum=runsummarydata[5]
01917         starttime=runsummarydata[6]
01918         stoptime=runsummarydata[7]
01919     try:
01920         if not complementalOnly:
01921             tabrowDefDict={'RUNNUM':'unsigned int','L1KEY':'string','AMODETAG':'string','EGEV':'unsigned int','SEQUENCE':'string','HLTKEY':'string','FILLNUM':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp'}
01922             tabrowValueDict={'RUNNUM':int(runnumber),'L1KEY':l1key,'AMODETAG':amodetag,'EGEV':int(egev),'SEQUENCE':sequence,'HLTKEY':hltkey,'FILLNUM':int(fillnum),'STARTTIME':starttime,'STOPTIME':stoptime}
01923             db=dbUtil.dbUtil(schema)
01924             db.insertOneRow(nameDealer.cmsrunsummaryTableName(),tabrowDefDict,tabrowValueDict)
01925         else:
01926             setClause='L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev'
01927             updateCondition='RUNNUM=:runnum'
01928             inputData=coral.AttributeList()
01929             inputData.extend('l1key','string')
01930             inputData.extend('amodetag','string')
01931             inputData.extend('egev','unsigned int')
01932             inputData.extend('runnum','unsigned int')
01933             inputData['l1key'].setData(l1key)
01934             inputData['amodetag'].setData(amodetag)
01935             inputData['egev'].setData(int(egev))
01936             inputData['runnum'].setData(int(runnumber))
01937             db=dbUtil.dbUtil(schema)
01938             db.singleUpdate(nameDealer.cmsrunsummaryTableName(),setClause,updateCondition,inputData)
01939     except :
        raise   
def dataDML::insertTrgHltMap (   schema,
  hltkey,
  trghltmap 
)
input:
    trghltmap {hltpath:l1seed}
output:

Definition at line 1940 of file dataDML.py.

01941                                             :
01942     '''
01943     input:
01944         trghltmap {hltpath:l1seed}
01945     output:
01946     '''
01947     hltkeyExists=False
01948     nrows=0
01949     try:
01950         kQueryBindList=coral.AttributeList()
01951         kQueryBindList.extend('hltkey','string')
01952         kQuery=schema.newQuery()
01953         kQuery.addToTableList(nameDealer.trghltMapTableName())
01954         kQuery.setCondition('HLTKEY=:hltkey',kQueryBindList)
01955         kQueryBindList['hltkey'].setData(hltkey)
01956         kResult=kQuery.execute()
01957         while kResult.next():
01958             hltkeyExists=True
01959         if not hltkeyExists:
01960             bulkvalues=[]   
01961             trghltDefDict=[('HLTKEY','string'),('HLTPATHNAME','string'),('L1SEED','string')]
01962             for hltpath,l1seed in trghltmap.items():
01963                 bulkvalues.append([('HLTKEY',hltkey),('HLTPATHNAME',hltpath),('L1SEED',l1seed)])
01964             db=dbUtil.dbUtil(schema)
01965             db.bulkInsert(nameDealer.trghltMapTableName(),trghltDefDict,bulkvalues)
01966             nrows=len(bulkvalues)
01967         return nrows
01968     except :
01969         print 'error in insertTrgHltMap '
        raise
def dataDML::intglumiForRange (   schema,
  runlist 
)
output: {run:intglumi_in_fb}

Definition at line 1387 of file dataDML.py.

01388                                     :
01389     '''
01390     output: {run:intglumi_in_fb}
01391     '''
01392     result={}
01393     if not runlist:
01394         return result
01395     minrun=min(runlist)
01396     maxrun=max(runlist)
01397     qHandle=schema.newQuery()
01398     try:
01399         qHandle.addToTableList(nameDealer.intglumiv2TableName())
01400         qResult=coral.AttributeList()
01401         qResult.extend('RUNNUM','unsigned int')
01402         qResult.extend('INTGLUMI','float')
01403         qConditionStr='RUNNUM>=:minrun AND RUNNUM<=:maxrun'
01404         qCondition=coral.AttributeList()
01405         qCondition.extend('minrun','unsigned int')
01406         qCondition.extend('maxrun','unsigned int')
01407         qCondition['minrun'].setData(minrun)
01408         qCondition['maxrun'].setData(maxrun)
01409         qHandle.addToOutputList('RUNNUM')
01410         qHandle.addToOutputList('INTGLUMI')
01411         qHandle.setCondition(qConditionStr,qCondition)
01412         qHandle.defineOutput(qResult)
01413         cursor=qHandle.execute()
01414         while cursor.next():
01415             runnum=cursor.currentRow()['RUNNUM'].data()
01416             intglumi=cursor.currentRow()['INTGLUMI'].data()
01417             result[runnum]=intglumi
01418     except :
01419         del qHandle
01420         raise
01421     del qHandle
01422     return result

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

01697                                                              :
01698     '''
01699     select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where  l.data_id=rl.data_id and l.entry_id=:entryid
01700     check revision_id is in branch
01701     '''
01702     dataids=[]
01703     datatablename=''
01704     revmaptablename=''
01705     if datatype=='lumi':
01706         datatablename=nameDealer.lumidataTableName()
01707     elif datatype=='trg':
01708         datatablename=nameDealer.trgdataTableName()
01709     elif dataytpe=='hlt':
01710         tablename=nameDealer.hltdataTableName()
01711     else:
01712         raise RunTimeError('datatype '+datatype+' is not supported')
01713     revmaptablename=nameDealer.revmapTableName(datatablename)
01714     qHandle=schema.newQuery()
01715     try:
01716         qHandle.addToTableList(revmaptablename)
01717         qHandle.addToTableList(datatablename)
01718         qHandle.addToOutputList('l.DATA_ID','dataid')
01719         qHandle.addToOutputList(revmaptablename+'.REVISION_ID','revisionid')
01720         qConditionStr=datatablename+'.DATA_ID='+revmaptablename+'.DATA_ID AND '+datatablename+'.ENTRY_ID=:entryid'
01721         qCondition=coral.AttributeList()
01722         qCondition.extend('entryid','unsigned long long')
01723         qResult=coral.AttributeList()
01724         qResult.extend('dataid','unsigned long long')
01725         qResult.extend('revisionid','unsigned long long')
01726         qHandle.defineOutput(qResult)
01727         qHandle.setCondition(qConditionStr,qCondition)
01728         cursor=qHandle.execute()
01729         while cursor.next():
01730             dataid=cursor.currentRow()['dataid'].data()
01731             revisionid=cursor.currentRow()['revisionid'].data()
01732             if revisionid in branchfilter:
01733                 dataids.append(dataid)
01734     except:
01735         del qHandle
01736         raise
01737     del qHandle
01738     if len(dataids)!=0:return max(dataids)
01739     return None
01740 
01741 
01742 #=======================================================
01743 #   INSERT requires in update transaction
#=======================================================
def dataDML::lumiBXByAlgo (   schema,
  dataid,
  algoname 
)
result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}

Definition at line 1134 of file dataDML.py.

01135                                         :
01136     '''
01137     result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
01138     '''
01139     result={}
01140     qHandle=schema.newQuery()
01141     try:
01142         qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
01143         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
01144         qHandle.addToOutputList('LUMILSNUM','lumilsnum')
01145         #qHandle.addToOutputList('ALGONAME','algoname')
01146         qHandle.addToOutputList('NUMORBIT','numorbit')
01147         qHandle.addToOutputList('STARTORBIT','startorbit')
01148         qHandle.addToOutputList('BXLUMIVALUE_'+algoname,'bxlumivalue')
01149         qHandle.addToOutputList('BXLUMIERROR_'+algoname,'bxlumierr')
01150         qHandle.addToOutputList('BXLUMIQUALITY_'+algoname,'bxlumiqlty')
01151         qConditionStr='DATA_ID=:dataid'
01152         qCondition=coral.AttributeList()
01153         qCondition.extend('dataid','unsigned long long')
01154         qCondition['dataid'].setData(dataid)
01155         qResult=coral.AttributeList()
01156         qResult.extend('cmslsnum','unsigned int')
01157         qResult.extend('lumilsnum','unsigned int')
01158         qResult.extend('numorbit','unsigned int')
01159         qResult.extend('startorbit','unsigned int')
01160         qResult.extend('bxlumivalue','blob')
01161         qResult.extend('bxlumierr','blob')
01162         qResult.extend('bxlumiqlty','blob')
01163         qHandle.defineOutput(qResult)
01164         qHandle.setCondition(qConditionStr,qCondition)
01165         cursor=qHandle.execute()
01166         while cursor.next():
01167             cmslsnum=cursor.currentRow()['cmslsnum'].data()
01168             lumilsnum=cursor.currentRow()['lumilsnum'].data()
01169             numorbit=cursor.currentRow()['numorbit'].data()
01170             startorbit=cursor.currentRow()['startorbit'].data()
01171             bxlumivalue=cursor.currentRow()['bxlumivalue'].data()
01172             bxlumierr=cursor.currentRow()['bxlumierr'].data()
01173             bxlumiqlty=cursor.currentRow()['bxlumiqlty'].data()
01174             if not result.has_key(algoname):
01175                 result[algoname]={}
01176             if not result[algoname].has_key(lumilsnum):
01177                 result[algoname][lumilsnum]=[]
01178             result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
01179     except :
01180         del qHandle
01181         raise RuntimeError(' dataDML.lumiBXById: '+str(e)) 
01182     del qHandle
01183     return result

def dataDML::lumicorrById (   schema,
  correctiondataid 
)
select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid
output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))}

Definition at line 47 of file dataDML.py.

00048                                          :
00049     '''
00050     select entry_name,a1,a2,drift from lumicorrections where DATA_ID=:dataid
00051     output: {tagname:(data_id(0),a1(1),a2(2),driftcoeff(3))}
00052     '''
00053     result=None
00054     qHandle=schema.newQuery()
00055     try:
00056         qHandle.addToTableList(nameDealer.lumicorrectionsTableName())
00057         qHandle.addToOutputList('ENTRY_NAME')
00058         qHandle.addToOutputList('A1')
00059         qHandle.addToOutputList('A2')
00060         qHandle.addToOutputList('DRIFT')
00061         qCondition=coral.AttributeList()
00062         qCondition.extend('dataid','unsigned long long')
00063         qCondition['dataid'].setData(correctiondataid)
00064         qResult=coral.AttributeList()
00065         qResult.extend('ENTRY_NAME','string')
00066         qResult.extend('A1','float')
00067         qResult.extend('A2','float')
00068         qResult.extend('DRIFT','float')
00069         qHandle.defineOutput(qResult)
00070         qHandle.setCondition('DATA_ID=:dataid',qCondition)
00071         cursor=qHandle.execute()
00072         while cursor.next():
00073             tagname=cursor.currentRow()['ENTRY_NAME'].data()
00074             a1=cursor.currentRow()['A1'].data()
00075             a2=0.0
00076             if cursor.currentRow()['A2'].data():
00077                 a2=cursor.currentRow()['A2'].data()
00078             drift=0.0
00079             if cursor.currentRow()['DRIFT'].data():
00080                 drift=cursor.currentRow()['DRIFT'].data()
00081             result={tagname:(correctiondataid,a1,a2,drift)}
00082     except :
00083         del qHandle
00084         raise
00085     del qHandle
00086     return result

def dataDML::lumiLSById (   schema,
  dataid,
  beamstatus = None,
  withBXInfo = False,
  bxAlgo = 'OCC1',
  withBeamIntensity = False,
  tableName = None 
)
input:
   beamstatus: filter on beam status flag
output:
result (runnum,{lumilsnum,[cmslsnum(0),instlumi(1),instlumierr(2),instlumiqlty(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),(bxvalueArray,bxerrArray)(8),(bxindexArray,beam1intensityArray,beam2intensityArray)(9)]})

Definition at line 936 of file dataDML.py.

00937                                                                                                                    :
00938     '''
00939     input:
00940        beamstatus: filter on beam status flag
00941     output:
00942     result (runnum,{lumilsnum,[cmslsnum(0),instlumi(1),instlumierr(2),instlumiqlty(3),beamstatus(4),beamenergy(5),numorbit(6),startorbit(7),(bxvalueArray,bxerrArray)(8),(bxindexArray,beam1intensityArray,beam2intensityArray)(9)]})
00943     '''
00944     runnum=0
00945     result={}
00946     qHandle=schema.newQuery()
00947     if withBXInfo and bxAlgo not in ['OCC1','OCC2','ET']:
00948         raise ValueError('unknown lumi algo '+bxAlgo)
00949     if beamstatus and beamstatus not in ['STABLE BEAMS',]:
00950         raise ValueError('unknown beam status '+beamstatus)
00951     try:
00952         if tableName is None:
00953             lls=nameDealer.lumisummaryv2TableName()
00954         else:
00955             lls=tableName
00956         qHandle.addToTableList(lls)
00957         qHandle.addToOutputList('RUNNUM','runnum')
00958         qHandle.addToOutputList('LUMILSNUM','lumilsnum')
00959         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00960         qHandle.addToOutputList('INSTLUMI','instlumi')
00961         qHandle.addToOutputList('INSTLUMIERROR','instlumierr')
00962         qHandle.addToOutputList('INSTLUMIQUALITY','instlumiqlty')
00963         qHandle.addToOutputList('BEAMSTATUS','beamstatus')
00964         qHandle.addToOutputList('BEAMENERGY','beamenergy')
00965         qHandle.addToOutputList('NUMORBIT','numorbit')
00966         qHandle.addToOutputList('STARTORBIT','startorbit')
00967         if withBXInfo:
00968             qHandle.addToOutputList('BXLUMIVALUE_'+bxAlgo,'bxvalue')
00969             qHandle.addToOutputList('BXLUMIERROR_'+bxAlgo,'bxerror')
00970         if withBeamIntensity:
00971             qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob')
00972             qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity')
00973             qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity')
00974         
00975         qConditionStr='DATA_ID=:dataid'
00976         qCondition=coral.AttributeList()
00977         qCondition.extend('dataid','unsigned long long')
00978         qCondition['dataid'].setData(int(dataid))
00979         if beamstatus:
00980             qConditionStr+=' and BEAMSTATUS=:beamstatus'
00981             qCondition.extend('beamstatus','string')
00982             qCondition['beamstatus'].setData(beamstatus)
00983         qResult=coral.AttributeList()
00984         qResult.extend('runnum','unsigned int')
00985         qResult.extend('lumilsnum','unsigned int')
00986         qResult.extend('cmslsnum','unsigned int')
00987         qResult.extend('instlumi','float')
00988         qResult.extend('instlumierr','float')
00989         qResult.extend('instlumiqlty','short')
00990         qResult.extend('beamstatus','string')
00991         qResult.extend('beamenergy','float')
00992         qResult.extend('numorbit','unsigned int')
00993         qResult.extend('startorbit','unsigned int')
00994         if withBXInfo:
00995             qResult.extend('bxvalue','blob')
00996             qResult.extend('bxerror','blob')          
00997         if withBeamIntensity:
00998             qResult.extend('bxindexblob','blob')
00999             qResult.extend('beam1intensity','blob')
01000             qResult.extend('beam2intensity','blob')
01001         qHandle.defineOutput(qResult)
01002         qHandle.setCondition(qConditionStr,qCondition)
01003         cursor=qHandle.execute()
01004         while cursor.next():
01005             runnum=cursor.currentRow()['runnum'].data()
01006             lumilsnum=cursor.currentRow()['lumilsnum'].data()
01007             cmslsnum=cursor.currentRow()['cmslsnum'].data()
01008             instlumi=cursor.currentRow()['instlumi'].data()
01009             instlumierr=cursor.currentRow()['instlumierr'].data()
01010             instlumiqlty=cursor.currentRow()['instlumiqlty'].data()
01011             bs=cursor.currentRow()['beamstatus'].data()
01012             begev=cursor.currentRow()['beamenergy'].data()
01013             numorbit=cursor.currentRow()['numorbit'].data()
01014             startorbit=cursor.currentRow()['startorbit'].data()
01015             bxinfo=None
01016             bxvalueblob=None
01017             bxerrblob=None
01018             if withBXInfo:
01019                 bxvalueblob=cursor.currentRow()['bxvalue'].data()
01020                 bxerrblob=cursor.currentRow()['bxerror'].data()
01021                 if bxvalueblob and bxerrblob:
01022                     bxvaluesArray=CommonUtil.unpackBlobtoArray(bxvalueblob,'f')
01023                     bxerrArray=CommonUtil.unpackBlobtoArray(bxerrblob,'f')
01024                     bxinfo=(bxvaluesArray,bxerrArray)
01025             bxindexblob=None
01026             beam1intensity=None
01027             beam2intensity=None
01028             beaminfo=None
01029             if withBeamIntensity:
01030                 bxindexblob=cursor.currentRow()['bxindexblob'].data()
01031                 beam1intensity=cursor.currentRow()['beam1intensity'].data()
01032                 beam2intensity=cursor.currentRow()['beam2intensity'].data()
01033                 if bxindexblob :
01034                     bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h')
01035                     beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensity,'f')
01036                     beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensity,'f')
01037                     beaminfo=(bxindexArray,beam1intensityArray,beam2intensityArray)
01038             result[lumilsnum]=[cmslsnum,instlumi,instlumierr,instlumiqlty,bs,begev,numorbit,startorbit,bxinfo,beaminfo]
01039     except :
01040         del qHandle
01041         raise 
01042     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
output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
result (normname(0),amodetag(1),egev(2),norm(3),norm_occ2(4),norm_et(5),norm_pu(6),constfactor(7))

Definition at line 482 of file dataDML.py.

00483                                :
00484     '''
00485     select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
00486     output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
00487     '''
00488     result=None
00489     qHandle=schema.newQuery()
00490     try:
00491         qHandle.addToTableList(nameDealer.luminormTableName())
00492         qHandle.addToOutputList('ENTRY_NAME','normname')
00493         qHandle.addToOutputList('AMODETAG','amodetag')
00494         qHandle.addToOutputList('NORM_1','norm_1')
00495         qHandle.addToOutputList('EGEV_1','energy_1')
00496         qHandle.addToOutputList('NORM_OCC2','norm_occ2')
00497         qHandle.addToOutputList('NORM_ET','norm_et')
00498         qHandle.addToOutputList('NORM_PU','norm_pu')
00499         qHandle.addToOutputList('CONSTFACTOR','constfactor')        
00500         qCondition=coral.AttributeList()
00501         qCondition.extend('dataid','unsigned long long')
00502         qCondition['dataid'].setData(dataid)
00503         qResult=coral.AttributeList()
00504         qResult.extend('normname','string')
00505         qResult.extend('amodetag','string')
00506         qResult.extend('norm_1','float')
00507         qResult.extend('energy_1','unsigned int')
00508         qResult.extend('norm_occ2','float')
00509         qResult.extend('norm_et','float')
00510         qResult.extend('norm_pu','float')
00511         qResult.extend('constfactor','float')
00512         qHandle.defineOutput(qResult)
00513         qHandle.setCondition('DATA_ID=:dataid',qCondition)
00514         cursor=qHandle.execute()
00515         while cursor.next():
00516             normname=cursor.currentRow()['normname'].data()
00517             amodetag=cursor.currentRow()['amodetag'].data()
00518             norm_1=cursor.currentRow()['norm_1'].data()
00519             energy_1=cursor.currentRow()['energy_1'].data()
00520             norm_occ2=1.0
00521             if cursor.currentRow()['norm_occ2'].data():
00522                 norm_occ2=cursor.currentRow()['norm_occ2'].data()
00523             norm_et=1.0
00524             if cursor.currentRow()['norm_et'].data():
00525                 norm_et=cursor.currentRow()['norm_et'].data()
00526             norm_pu=1.0
00527             if cursor.currentRow()['norm_pu'].data():
00528                 norm_pu=cursor.currentRow()['norm_pu'].data()
00529             constfactor=1.0
00530             if cursor.currentRow()['constfactor'].data():
00531                 constfactor=cursor.currentRow()['constfactor'].data()
00532             result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
00533     except :
00534         del qHandle
00535         raise
00536     del qHandle
00537     return result

def dataDML::lumiRunById (   schema,
  lumidataid,
  lumitype = 'HF' 
)
input: lumidataid
output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3))

Definition at line 826 of file dataDML.py.

00827                                                 :
00828     '''
00829     input: lumidataid
00830     output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3))
00831     '''
00832     if lumitype not in ['HF','PIXEL']:
00833         raise ValueError('unknown lumitype '+lumitype)
00834     lumitableName=''
00835     if lumitype=='HF':
00836         lumitableName = nameDealer.lumidataTableName()
00837     else:
00838         lumitableName = nameDealer.pixellumidataTableName()
00839     qHandle=schema.newQuery()
00840     try:
00841         qHandle.addToTableList(lumitableName)
00842         qHandle.addToOutputList('RUNNUM')
00843         qHandle.addToOutputList('SOURCE')
00844         qHandle.addToOutputList('NOMINALEGEV')
00845         qHandle.addToOutputList('NCOLLIDINGBUNCHES')
00846         qConditionStr='DATA_ID=:dataid'
00847         qCondition=coral.AttributeList()
00848         qCondition.extend('dataid','unsigned long long')
00849         qCondition['dataid'].setData(lumidataid)
00850         qResult=coral.AttributeList()
00851         qResult.extend('RUNNUM','unsigned int')
00852         qResult.extend('SOURCE','string')
00853         qResult.extend('NOMINALEGEV','float')
00854         qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
00855         qHandle.defineOutput(qResult)
00856         qHandle.setCondition(qConditionStr,qCondition)
00857         cursor=qHandle.execute()
00858         while cursor.next():
00859             runnum=cursor.currentRow()['RUNNUM'].data()
00860             datasource=cursor.currentRow()['SOURCE'].data()
00861             nominalegev=0
00862             if not cursor.currentRow()['NOMINALEGEV'].isNull():
00863                 nominalegev=cursor.currentRow()['NOMINALEGEV'].data()
00864             ncollidingbunches=0
00865             if not cursor.currentRow()['NCOLLIDINGBUNCHES'].isNull():
00866                 ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
00867             result=(runnum,datasource,nominalegev,ncollidingbunches)
00868     except :
00869         del qHandle
00870         raise
00871     del qHandle
00872     return result

def dataDML::lumiRunByIds (   schema,
  dataidMap,
  lumitype = 'HF' 
)
input dataidMap : {run:lumidataid}
result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2)}

Definition at line 810 of file dataDML.py.

00811                                                 :
00812     '''
00813     input dataidMap : {run:lumidataid}
00814     result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2)}
00815     '''
00816     result={}
00817     if not dataidMap:
00818         return result
00819     inputRange=dataidMap.keys()
00820     for r in inputRange:
00821         lumidataid=dataidMap[r][0]
00822         if lumidataid:
00823             perrundata=lumiRunById(schema,lumidataid,lumitype=lumitype)
00824             result[r]=(perrundata[1],perrundata[2],perrundata[3])
00825     return result

def dataDML::mostRecentLumicorrs (   schema,
  branchfilter 
)
this overview query should be only for corr
select e.name,n.data_id,r.revision_id , n.a1,n.a2,n.drift from lumicorrections_entries e,lumicorrections_rev r,lumicorrections n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter) group by e.entry_name,r.revision_id,n.a1,n.a2,n.drift;
output {corrname:(data_id,a1,a2,drift)}

Definition at line 538 of file dataDML.py.

00539                                             :
00540     '''
00541     this overview query should be only for corr
00542     select e.name,n.data_id,r.revision_id , n.a1,n.a2,n.drift from lumicorrections_entries e,lumicorrections_rev r,lumicorrections n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter) group by e.entry_name,r.revision_id,n.a1,n.a2,n.drift;
00543     output {corrname:(data_id,a1,a2,drift)}
00544     '''
00545     #print branchfilter
00546     result={}
00547     entry2datamap={}
00548     branchmin=0
00549     branchmax=0
00550     if branchfilter and len(branchfilter)!=0:
00551         branchmin=min(branchfilter)
00552         branchmax=max(branchfilter)
00553     else:
00554         return result
00555     qHandle=schema.newQuery()
00556     corrdict={}
00557     try:
00558         qHandle.addToTableList(nameDealer.entryTableName(nameDealer.lumicorrectionsTableName()),'e')
00559         qHandle.addToTableList(nameDealer.lumicorrectionsTableName(),'n')
00560         qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.lumicorrectionsTableName()),'r')
00561         qHandle.addToOutputList('e.NAME','corrname')
00562         qHandle.addToOutputList('r.DATA_ID','data_id')
00563         qHandle.addToOutputList('r.REVISION_ID','revision_id')
00564         qHandle.addToOutputList('n.A1','a1')
00565         qHandle.addToOutputList('n.A2','a2')
00566         qHandle.addToOutputList('n.DRIFT','drift')
00567         qCondition=coral.AttributeList()
00568         qCondition.extend('branchmin','unsigned long long')
00569         qCondition.extend('branchmax','unsigned long long')
00570         qCondition['branchmin'].setData(branchmin)
00571         qCondition['branchmax'].setData(branchmax)
00572         qResult=coral.AttributeList()
00573         qResult.extend('corrname','string')
00574         qResult.extend('data_id','unsigned long long')
00575         qResult.extend('revision_id','unsigned long long')
00576         qResult.extend('a1','float')
00577         qResult.extend('a2','float')
00578         qResult.extend('drift','float')
00579         qHandle.defineOutput(qResult)
00580         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)
00581         cursor=qHandle.execute()
00582         while cursor.next():
00583             corrname=cursor.currentRow()['corrname'].data()
00584             data_id=cursor.currentRow()['data_id'].data()
00585             if not corrdict.has_key(corrname):
00586                 corrdict[corrname]=0
00587             if data_id>corrdict[corrname]:
00588                 corrdict[corrname]=data_id
00589                 a1=cursor.currentRow()['a1'].data() #required
00590                 a2=0.0
00591                 if not cursor.currentRow()['a2'].isNull():
00592                     a2=cursor.currentRow()['a2'].data()
00593                 drift=0.0
00594                 if not cursor.currentRow()['drift'].isNull():
00595                     drift=cursor.currentRow()['drift'].data()
00596                 result[corrname]=(data_id,a1,a2,drift)
00597     except:
00598         raise
00599     return result

def dataDML::mostRecentLuminorms (   schema,
  branchfilter 
)
this overview query should be only for norm
select e.name,n.data_id,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_occ2,n.norm_et,n.norm_pu,n.constfactor from luminorms_entries e,luminorms_rev r,luminorms n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter);
output {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}

Definition at line 404 of file dataDML.py.

00405                                             :
00406     '''
00407     this overview query should be only for norm
00408     select e.name,n.data_id,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_occ2,n.norm_et,n.norm_pu,n.constfactor from luminorms_entries e,luminorms_rev r,luminorms n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter);
00409     output {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
00410     '''
00411     #print branchfilter
00412     result={}
00413     entry2datamap={}
00414     branchmin=0
00415     branchmax=0
00416     if branchfilter and len(branchfilter)!=0:
00417         branchmin=min(branchfilter)
00418         branchmax=max(branchfilter)
00419     else:
00420         return result
00421     #print branchmin,branchmax
00422     qHandle=schema.newQuery()
00423     normdict={}
00424     try:
00425         qHandle.addToTableList(nameDealer.entryTableName(nameDealer.luminormTableName()),'e')
00426         qHandle.addToTableList(nameDealer.luminormTableName(),'n')
00427         qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.luminormTableName()),'r')
00428         qHandle.addToOutputList('e.NAME','normname')
00429         qHandle.addToOutputList('r.DATA_ID','data_id')
00430         qHandle.addToOutputList('r.REVISION_ID','revision_id')
00431         qHandle.addToOutputList('n.AMODETAG','amodetag')
00432         qHandle.addToOutputList('n.NORM_1','norm_1')
00433         qHandle.addToOutputList('n.EGEV_1','energy_1')
00434         qHandle.addToOutputList('n.NORM_OCC2','norm_occ2')
00435         qHandle.addToOutputList('n.NORM_ET','norm_et')
00436         qHandle.addToOutputList('n.NORM_PU','norm_pu')
00437         qHandle.addToOutputList('n.CONSTFACTOR','constfactor')
00438         qCondition=coral.AttributeList()
00439         qCondition.extend('branchmin','unsigned long long')
00440         qCondition.extend('branchmax','unsigned long long')
00441         qCondition['branchmin'].setData(branchmin)
00442         qCondition['branchmax'].setData(branchmax)
00443         qResult=coral.AttributeList()
00444         qResult.extend('normname','string')
00445         qResult.extend('data_id','unsigned long long')
00446         qResult.extend('revision_id','unsigned long long')
00447         qResult.extend('amodetag','string')
00448         qResult.extend('norm_1','float')
00449         qResult.extend('energy_1','unsigned int')
00450         qResult.extend('norm_occ2','float')
00451         qResult.extend('norm_et','float')
00452         qResult.extend('norm_pu','float')
00453         qResult.extend('constfactor','float')
00454         qHandle.defineOutput(qResult)
00455         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)
00456         cursor=qHandle.execute()
00457         while cursor.next():
00458             data_id=cursor.currentRow()['data_id'].data()
00459             normname=cursor.currentRow()['normname'].data()
00460             if not normdict.has_key(normname):
00461                 normdict[normname]=0
00462             if data_id>normdict[normname]:
00463                 normdict[normname]=data_id
00464                 amodetag=cursor.currentRow()['amodetag'].data()
00465                 norm_1=cursor.currentRow()['norm_1'].data()
00466                 energy_1=cursor.currentRow()['energy_1'].data()
00467                 norm_occ2=1.0
00468                 if not cursor.currentRow()['norm_occ2'].isNull():
00469                     norm_occ2=cursor.currentRow()['norm_occ2'].data()
00470                 norm_et=1.0
00471                 if not cursor.currentRow()['norm_et'].isNull():
00472                     norm_et=cursor.currentRow()['norm_et'].data()
00473                 norm_pu=1.0
00474                 if not cursor.currentRow()['norm_pu'].isNull():
00475                     norm_pu=cursor.currentRow()['norm_pu'].data()
00476                 constfactor=1.0
00477                 if not cursor.currentRow()['constfactor'].isNull():
00478                     constfactor=cursor.currentRow()['constfactor'].data()
00479                 result[normname]=(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)
00480     except:
00481         raise
    return result
def dataDML::runList (   schema,
  fillnum = None,
  runmin = None,
  runmax = None,
  fillmin = None,
  fillmax = None,
  startT = None,
  stopT = None,
  l1keyPattern = None,
  hltkeyPattern = None,
  amodetag = None,
  nominalEnergy = None,
  energyFlut = 0.2,
  requiretrg = True,
  requirehlt = True,
  lumitype = None 
)
select runnum,starttime 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.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 238 of file dataDML.py.

00239                                                                                                                                                                                                                                             :
00240     '''
00241     select runnum,starttime 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.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)
00242     '''
00243     if lumitype not in ['HF','PIXEL']:
00244         raise ValueError('unknown lumitype '+lumitype)
00245     lumitableName=''
00246     if lumitype=='HF':
00247         lumitableName=nameDealer.lumidataTableName()
00248     elif lumitype == 'PIXEL':
00249         lumitableName = nameDealer.pixellumidataTableName()
00250     else:
00251         assert False, "ERROR Unknown lumitype '%s'" % lumitype
00252     result=[]
00253     timelesslist=[]
00254     qHandle=schema.newQuery()
00255     r=nameDealer.cmsrunsummaryTableName()
00256     l=lumitableName
00257     t=nameDealer.trgdataTableName()
00258     h=nameDealer.hltdataTableName()
00259     lute=lumiTime.lumiTime()
00260     try:
00261         qHandle.addToTableList(r)
00262         qHandle.addToTableList(l)
00263         qConditionStr=r+'.RUNNUM='+l+'.RUNNUM'
00264         if requiretrg:
00265             qHandle.addToTableList(t)
00266             qConditionStr+=' and '+l+'.RUNNUM='+t+'.RUNNUM'
00267         if requirehlt:
00268             qHandle.addToTableList(h)
00269             qConditionStr+=' and '+l+'.RUNNUM='+h+'.RUNNUM'
00270         qCondition=coral.AttributeList()        
00271         if fillnum:
00272             qConditionStr+=' and '+r+'.FILLNUM=:fillnum'
00273             qCondition.extend('fillnum','unsigned int')
00274             qCondition['fillnum'].setData(int(fillnum))
00275         if runmin:
00276             qConditionStr+=' and '+r+'.RUNNUM>=:runmin'
00277             qCondition.extend('runmin','unsigned int')
00278             qCondition['runmin'].setData(runmin)
00279         if runmax:
00280             qConditionStr+=' and '+r+'.RUNNUM<=:runmax'
00281             qCondition.extend('runmax','unsigned int')
00282             qCondition['runmax'].setData(runmax)
00283         if fillmin:
00284             qConditionStr+=' and '+r+'.FILLNUM>=:fillmin'
00285             qCondition.extend('fillmin','unsigned int')
00286             qCondition['fillmin'].setData(fillmin)
00287         if fillmax:
00288             qConditionStr+=' and '+r+'.FILLNUM<=:fillmax'
00289             qCondition.extend('fillmax','unsigned int')
00290             qCondition['fillmax'].setData(fillmax)
00291         if amodetag:
00292             qConditionStr+=' and '+r+'.AMODETAG=:amodetag'
00293             qCondition.extend('amodetag','string')
00294             qCondition['amodetag'].setData(amodetag)
00295         if l1keyPattern:
00296             qConditionStr+=' and regexp_like('+r+'.L1KEY,:l1keypattern)'
00297             qCondition.extend('l1keypattern','string')
00298             qCondition['l1keypattern'].setData(l1keyPattern)
00299         if hltkeyPattern:
00300             qConditionStr+=' and regexp_like('+r+'.HLTKEY,:hltkeypattern)'
00301             qCondition.extend('hltkeypattern','string')
00302             qCondition['hltkeypattern'].setData(hltkeyPattern)
00303         if nominalEnergy:
00304             emin=nominalEnergy*(1.0-energyFlut)
00305             emax=nominalEnergy*(1.0+energyFlut)
00306             qConditionStr+=' and '+l+'.NOMINALEGEV>=:emin and '+l+'.NOMINALEGEV<=:emax'
00307             qCondition.extend('emin','float')
00308             qCondition.extend('emax','float')
00309             qCondition['emin'].setData(emin)
00310             qCondition['emax'].setData(emax)
00311         qResult=coral.AttributeList()
00312         qResult.extend('runnum','unsigned int')
00313         qResult.extend('starttime','string')
00314         qHandle.defineOutput(qResult)
00315         qHandle.setCondition(qConditionStr,qCondition)
00316         qHandle.addToOutputList(r+'.RUNNUM','runnum')
00317         qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime')
00318         cursor=qHandle.execute()
00319         
00320         while cursor.next():
00321             starttimeStr=cursor.currentRow()['starttime'].data()
00322             runnum=cursor.currentRow()['runnum'].data()
00323             minTime=None
00324             maxTime=None
00325             if startT and stopT:
00326                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00327                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
00328                 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
00329                 if runTime>=minTime and runTime<=maxTime and runnum not in result:
00330                     result.append(runnum)
00331             elif startT is not None:
00332                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00333                 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
00334                 if runTime>=minTime and runnum not in result:
00335                     result.append(runnum)
00336             elif stopT is not None:
00337                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
00338                 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
00339                 if runTime<=maxTime and runnum not in result:
00340                     result.append(runnum)
00341             else:
00342                 if runnum not in result:
00343                     result.append(runnum)
00344     except :
00345         del qHandle
00346         raise
00347     del qHandle
00348     return result

def dataDML::runsummary (   schema,
  runnum,
  sessionflavor = '' 
)
select l1key,amodetag,egev,hltkey,fillnum,fillscheme,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum
output: [l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]

Definition at line 349 of file dataDML.py.

Referenced by SiStripFineDelayHit::produce().

00350                                               :
00351     '''
00352     select l1key,amodetag,egev,hltkey,fillnum,fillscheme,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum
00353     output: [l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),fillscheme(5),starttime(6),stoptime(7)]
00354     '''
00355     result=[]
00356     qHandle=schema.newQuery()
00357     t=lumiTime.lumiTime()
00358     try:
00359         qHandle.addToTableList(nameDealer.cmsrunsummaryTableName())
00360         qCondition=coral.AttributeList()
00361         qCondition.extend('runnum','unsigned int')
00362         qCondition['runnum'].setData(int(runnum))
00363         qHandle.addToOutputList('L1KEY','l1key')
00364         qHandle.addToOutputList('AMODETAG','amodetag')
00365         qHandle.addToOutputList('EGEV','egev')
00366         qHandle.addToOutputList('HLTKEY','hltkey')
00367         qHandle.addToOutputList('FILLNUM','fillnum')
00368         qHandle.addToOutputList('FILLSCHEME','fillscheme')
00369         if sessionflavor=='SQLite':
00370             qHandle.addToOutputList('STARTTIME','starttime')
00371             qHandle.addToOutputList('STOPTIME','stoptime')
00372         else:
00373             qHandle.addToOutputList('to_char(STARTTIME,\''+t.coraltimefm+'\')','starttime')
00374             qHandle.addToOutputList('to_char(STOPTIME,\''+t.coraltimefm+'\')','stoptime')
00375         qHandle.setCondition('RUNNUM=:runnum',qCondition)
00376         qResult=coral.AttributeList()
00377         qResult.extend('l1key','string')
00378         qResult.extend('amodetag','string')
00379         qResult.extend('egev','unsigned int')
00380         qResult.extend('hltkey','string')
00381         qResult.extend('fillnum','unsigned int')
00382         qResult.extend('fillscheme','string')
00383         qResult.extend('starttime','string')
00384         qResult.extend('stoptime','string')
00385         qHandle.defineOutput(qResult)
00386         cursor=qHandle.execute()
00387         while cursor.next():
00388             result.append(cursor.currentRow()['l1key'].data())
00389             result.append(cursor.currentRow()['amodetag'].data())
00390             result.append(cursor.currentRow()['egev'].data())
00391             result.append(cursor.currentRow()['hltkey'].data())
00392             result.append(cursor.currentRow()['fillnum'].data())
00393             fillscheme=''
00394             if not cursor.currentRow()['fillscheme'].isNull():
00395                 fillscheme=cursor.currentRow()['fillscheme'].data()
00396             result.append(fillscheme)
00397             result.append(cursor.currentRow()['starttime'].data())
00398             result.append(cursor.currentRow()['stoptime'].data())
00399     except :
00400         del qHandle
00401         raise
00402     del qHandle
00403     return result

def dataDML::trgLSById (   schema,
  dataid,
  trgbitname = None,
  trgbitnamepattern = None,
  withL1Count = False,
  withPrescale = False 
)
output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale)](4)]})

Definition at line 715 of file dataDML.py.

00716                                                                                                         :
00717     '''
00718     output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale)](4)]})
00719     '''
00720     runnum=0
00721     result={}
00722     trgnamedict=[]
00723     if  trgbitname or trgbitnamepattern or withPrescale or withL1Count:
00724         trgrundata=trgRunById(schema,dataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern)
00725         trgnamedict=trgrundata[3]
00726 
00727     qHandle=schema.newQuery()
00728     try:
00729         qHandle.addToTableList(nameDealer.lstrgTableName())
00730         qHandle.addToOutputList('RUNNUM','runnum')
00731         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00732         qHandle.addToOutputList('DEADTIMECOUNT','deadtimecount')
00733         #qHandle.addToOutputList('BITZEROCOUNT','bitzerocount')
00734         #qHandle.addToOutputList('BITZEROPRESCALE','bitzeroprescale')
00735         qHandle.addToOutputList('DEADFRAC','deadfrac')
00736         if withPrescale:
00737             qHandle.addToOutputList('PRESCALEBLOB','prescalesblob')
00738         if withL1Count:
00739             qHandle.addToOutputList('TRGCOUNTBLOB','trgcountblob')
00740         qConditionStr='DATA_ID=:dataid'
00741         qCondition=coral.AttributeList()
00742         qCondition.extend('dataid','unsigned long long')
00743         qCondition['dataid'].setData(dataid)
00744         qResult=coral.AttributeList()
00745         qResult.extend('runnum','unsigned int')
00746         qResult.extend('cmslsnum','unsigned int')
00747         qResult.extend('deadtimecount','unsigned long long')
00748         #qResult.extend('bitzerocount','unsigned int')
00749         #qResult.extend('bitzeroprescale','unsigned int')
00750         qResult.extend('deadfrac','float')
00751         if withPrescale:
00752             qResult.extend('prescalesblob','blob')
00753         if withL1Count:
00754             qResult.extend('trgcountblob','blob')
00755         qHandle.defineOutput(qResult)
00756         qHandle.setCondition(qConditionStr,qCondition)
00757         cursor=qHandle.execute()
00758         while cursor.next():
00759             runnum=cursor.currentRow()['runnum'].data()
00760             cmslsnum=cursor.currentRow()['cmslsnum'].data()
00761             deadtimecount=cursor.currentRow()['deadtimecount'].data()
00762             #bitzerocount=cursor.currentRow()['bitzerocount'].data()
00763             #bitzeroprescale=cursor.currentRow()['bitzeroprescale'].data()
00764             bitzerocount=0
00765             bitzeroprescale=0
00766             deadfrac=cursor.currentRow()['deadfrac'].data()
00767             if not result.has_key(cmslsnum):
00768                 result[cmslsnum]=[]
00769             result[cmslsnum].append(deadtimecount)
00770             result[cmslsnum].append(bitzerocount)
00771             result[cmslsnum].append(bitzeroprescale)
00772             result[cmslsnum].append(deadfrac)
00773             prescalesblob=None
00774             trgcountblob=None
00775             if withPrescale:
00776                 prescalesblob=cursor.currentRow()['prescalesblob'].data()
00777             if withL1Count:
00778                 trgcountblob=cursor.currentRow()['trgcountblob'].data()
00779             prescales=[]
00780             trgcounts=[]
00781             if prescalesblob:
00782                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
00783                     prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'l')
00784                 else:
00785                     prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'I')
00786             if trgcountblob:
00787                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
00788                     trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'l')
00789                 else:
00790                     trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'I')
00791                     
00792             bitinfo=[]
00793             for (bitidx,thisbitname) in trgnamedict:
00794                 thispresc=None
00795                 thistrgcount=None
00796                 if prescales:
00797                     thispresc=prescales[bitidx]
00798                 if trgcounts:
00799                     thistrgcount=trgcounts[bitidx]
00800                 thisbitinfo=(thisbitname,thistrgcount,thispresc)
00801                 bitinfo.append(thisbitinfo)
00802             result[cmslsnum].append(bitinfo)
00803     except:
00804         del qHandle
00805         raise 
00806     del qHandle
00807 #    t1=time.time()
00808 #    print 'trgLSById time ',t1-t0
00809     return (runnum,result)

def dataDML::trgRunById (   schema,
  dataid,
  trgbitname = None,
  trgbitnamepattern = None 
)
query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB from trgdata where DATA_ID=:dataid

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

Definition at line 656 of file dataDML.py.

00657                                                                     :
00658     '''
00659     query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB from trgdata where DATA_ID=:dataid
00660     
00661     output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3)]
00662              -- runnumber
00663              -- original source database name
00664              -- deadtime norm bitname
00665              -- bitnamedict [(bitidx,bitname),...]
00666     '''
00667     result=[]
00668     qHandle=schema.newQuery()
00669     runnum=None
00670     datasource=None
00671     bitzeroname=None
00672     bitnamedict=[]
00673     try:
00674         qHandle.addToTableList(nameDealer.trgdataTableName())
00675         qHandle.addToOutputList('RUNNUM','runnum')
00676         qHandle.addToOutputList('SOURCE','source')
00677         qHandle.addToOutputList('BITZERONAME','bitzeroname')
00678         qHandle.addToOutputList('BITNAMECLOB','bitnameclob')
00679         qCondition=coral.AttributeList()
00680         qCondition.extend('dataid','unsigned long long')
00681         qCondition['dataid'].setData(dataid)
00682         qResult=coral.AttributeList()
00683         qResult.extend('runnum','unsigned int')
00684         qResult.extend('source','string')
00685         qResult.extend('bitzeroname','string')
00686         qResult.extend('bitnameclob','string')
00687         qHandle.defineOutput(qResult)
00688         qHandle.setCondition('DATA_ID=:dataid',qCondition)        
00689         cursor=qHandle.execute()
00690         bitnameclob=None
00691         bitnames=[]
00692         while cursor.next():
00693             runnum=cursor.currentRow()['runnum'].data()
00694             source=cursor.currentRow()['source'].data()
00695             bitzeroname=cursor.currentRow()['bitzeroname'].data()
00696             bitnameclob=cursor.currentRow()['bitnameclob'].data()
00697         if bitnameclob:
00698             bitnames=bitnameclob.split(',')
00699             for trgnameidx,trgname in enumerate(bitnames):
00700                 if trgbitname :
00701                     if trgname==trgbitname:
00702                         bitnamedict.append((trgnameidx,trgname))
00703                         break
00704                 elif trgbitnamepattern:
00705                     if fnmatch.fnmatch(trgname,trgbitnamepattern):
00706                         bitnamedict.append((trgnameidx,trgname))
00707                 else:
00708                     bitnamedict.append((trgnameidx,trgname))
00709         result=[runnum,source,bitzeroname,bitnamedict]
00710     except :
00711         del qHandle
00712         raise 
00713     del qHandle
00714     return result


Variable Documentation

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

Definition at line 2198 of file dataDML.py.

Referenced by TrackerMap::TrackerMap().

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

Definition at line 2186 of file dataDML.py.

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

Definition at line 2214 of file dataDML.py.

Definition at line 2216 of file dataDML.py.

tuple dataDML::hlttrgmap = generateDummyData.hlttrgmap(schema)

Definition at line 2202 of file dataDML.py.

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

Definition at line 2225 of file dataDML.py.

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

Definition at line 2233 of file dataDML.py.

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

Definition at line 2204 of file dataDML.py.

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

Definition at line 2232 of file dataDML.py.

Definition at line 2206 of file dataDML.py.

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

Definition at line 2224 of file dataDML.py.

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

Definition at line 2174 of file dataDML.py.

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

Definition at line 2194 of file dataDML.py.

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

Definition at line 2188 of file dataDML.py.

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

Definition at line 2223 of file dataDML.py.

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

Definition at line 2230 of file dataDML.py.

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

Definition at line 2200 of file dataDML.py.

tuple dataDML::schema = session.nominalSchema()

Definition at line 2177 of file dataDML.py.

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

Definition at line 2176 of file dataDML.py.

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

Definition at line 2175 of file dataDML.py.

tuple dataDML::tables = lumidbDDL.createTables(schema)
tuple dataDML::trgdata = generateDummyData.trg(schema,20)

Definition at line 2209 of file dataDML.py.

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

Definition at line 2238 of file dataDML.py.

Definition at line 2211 of file dataDML.py.

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

Definition at line 2184 of file dataDML.py.