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 beamstatusByIds
def bulkInsertHltLSData
def bulkInsertLumiLSSummary
def bulkInsertTrgLSData
def dataentryIdByRun
def fillInRange
def fillrunMap
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 runList
def runsummary
def trgLSById
def trgRunById

Variables

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

Function Documentation

def dataDML::addCorrToBranch (   schema,
  corrname,
  a1,
  optionalcorrdata,
  branchinfo 
)
input:
   branchinfo(corrrevisionid,branchname)
   optionalcorrdata {'a2':a2,'drift':drif}
output:
   (revision_id,entry_id,data_id)

Definition at line 1922 of file dataDML.py.

01923                                                                    :
01924     '''
01925     input:
01926        branchinfo(corrrevisionid,branchname)
01927        optionalcorrdata {'a2':a2,'drift':drif}
01928     output:
01929        (revision_id,entry_id,data_id)
01930     '''
01931     a2=1.0
01932     if optionalcorrdata.has_key('a2'):
01933         a2=optionalcorrdata['a2']
01934     drift=1.0
01935     if optionalcorrdata.has_key('drift'):
01936         drift=optionalcorrdata['drift']
01937     try:
01938         entry_id=revisionDML.entryInBranch(schema,nameDealer.lumicorrectionsTableName(),corrname,branchinfo[1])
01939         if entry_id is None:
01940             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.lumicorrectionsTableName())
01941             entryinfo=(revision_id,entry_id,corrname,data_id)
01942             revisionDML.addEntry(schema,nameDealer.lumicorrectionsTableName(),entryinfo,branchinfo)
01943         else:
01944             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.lumicorrectionsTableName() )
01945             revisionDML.addRevision(schema,nameDealer.lumicorrectionsTableName(),(revision_id,data_id),branchinfo)
01946         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','A1':'float','A2':'float','DRIFT':'float'}
01947         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':corrname,'A1':a1,'A2':a2,'DRIFT':drift}
01948         db=dbUtil.dbUtil(schema)
01949         db.insertOneRow(nameDealer.lumicorrectionsTableName(),tabrowDefDict,tabrowValueDict)
01950         return (revision_id,entry_id,data_id)
01951     except :
01952         raise

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

Definition at line 2019 of file dataDML.py.

02020                                                                  :
02021     '''
02022     input:
02023         hltrundata [pathnameclob(0),datasource(1)]
02024     output:
02025         (revision_id,entry_id,data_id)
02026     '''
02027     try:
02028          pathnames=hltrundata[0]
02029          datasource=hltrundata[1]
02030          npath=len(pathnames.split(','))
02031          entry_id=revisionDML.entryInBranch(schema,nameDealer.hltdataTableName(),str(runnumber),branchinfo[1])
02032          if entry_id is None:
02033              (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName())
02034              entryinfo=(revision_id,entry_id,str(runnumber),data_id)
02035              revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo)
02036          else:
02037              (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() )
02038              revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo)
02039          tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'}
02040          tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames}
02041          db=dbUtil.dbUtil(schema)
02042          db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict)
02043          return (revision_id,entry_id,data_id)
02044     except :
02045         raise 

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

Definition at line 1953 of file dataDML.py.

01954                                                                              :
01955     '''
01956     input:
01957           lumirundata [datasource,nominalenergy,ncollidingbunches,starttime,stoptime,nls]
01958           branchinfo (branch_id,branch_name)
01959           tableName lumiruntablename
01960     output:
01961           (revision_id,entry_id,data_id)
01962     '''
01963     try:
01964         datasource=lumirundata[0]
01965         nominalegev=3500.0
01966         ncollidingbunches=0
01967         starttime=coral.TimeStamp()
01968         stoptime=coral.TimeStamp()
01969         nls=0
01970         if len(lumirundata)>1:
01971             nominalenergy=lumirundata[1]
01972             ncollidingbunches=lumirundata[2]
01973             starttime=lumirundata[3]
01974             stoptime=lumirundata[4]
01975             nls=lumirundata[5]
01976         entry_id=revisionDML.entryInBranch(schema,tableName,str(runnumber),branchinfo[1])
01977         if entry_id is None:
01978             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,tableName)
01979             entryinfo=(revision_id,entry_id,str(runnumber),data_id)
01980             revisionDML.addEntry(schema,tableName,entryinfo,branchinfo)
01981         else:
01982             (revision_id,data_id)=revisionDML.bookNewRevision(schema,tableName)
01983             #print 'revision_id,data_id ',revision_id,data_id
01984             revisionDML.addRevision(schema,tableName,(revision_id,data_id),branchinfo)
01985         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NOMINALEGEV':'float','NCOLLIDINGBUNCHES':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp','NLS':'unsigned int'}
01986         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NOMINALEGEV':nominalegev,'NCOLLIDINGBUNCHES':ncollidingbunches,'STARTTIME':starttime,'STOPTIME':stoptime,'NLS':nls}
01987         db=dbUtil.dbUtil(schema)
01988         db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict)
01989         return (revision_id,entry_id,data_id)
01990     except :
01991         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 1884 of file dataDML.py.

01885                                                                                      :
01886     '''
01887     input:
01888        branchinfo(normrevisionid,branchname)
01889        optionalnormdata {'norm_occ2':norm_occ2,'norm_et':norm_et,'norm_pu':norm_pu,'constfactor':constfactor}
01890     output:
01891        (revision_id,entry_id,data_id)
01892     '''
01893     #print 'branchinfo ',branchinfo
01894     norm_occ2=1.0
01895     if optionalnormdata.has_key('normOcc2'):
01896         norm_occ2=optionalnormdata['norm_occ2']
01897     norm_et=1.0
01898     if optionalnormdata.has_key('norm_et'):
01899         norm_et=optionalnormdata['norm_et']
01900     norm_pu=1.0
01901     if optionalnormdata.has_key('norm_pu'):
01902         norm_pu=optionalnormdata['norm_pu']
01903     constfactor=1.0
01904     if optionalnormdata.has_key('constfactor'):
01905         constfactor=optionalnormdata['constfactor']
01906     try:
01907         entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1])
01908         if entry_id is None:
01909             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName())
01910             entryinfo=(revision_id,entry_id,normname,data_id)
01911             revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo)
01912         else:
01913             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() )
01914             revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo)
01915         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'}
01916         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}
01917         db=dbUtil.dbUtil(schema)
01918         db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict)
01919         return (revision_id,entry_id,data_id)
01920     except :
01921         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 1992 of file dataDML.py.

01993                                                                  :
01994     '''
01995     input:
01996        trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)]
01997        bitnames clob, bitnames separated by ','
01998     output:
01999        (revision_id,entry_id,data_id)
02000     '''
02001     try:   #fixme: need to consider revision only case
02002         datasource=trgrundata[0]
02003         bitzeroname=trgrundata[1]
02004         bitnames=trgrundata[2]
02005         entry_id=revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),str(runnumber),branchinfo[1])
02006         if entry_id is None:
02007             (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.trgdataTableName())
02008             entryinfo=(revision_id,entry_id,str(runnumber),data_id)
02009             revisionDML.addEntry(schema,nameDealer.trgdataTableName(),entryinfo,branchinfo)
02010         else:
02011             (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.trgdataTableName() )
02012             revisionDML.addRevision(schema,nameDealer.trgdataTableName(),(revision_id,data_id),branchinfo)
02013         tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','SOURCE':'string','RUNNUM':'unsigned int','BITZERONAME':'string','BITNAMECLOB':'string'}
02014         tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'SOURCE':datasource,'RUNNUM':int(runnumber),'BITZERONAME':bitzeroname,'BITNAMECLOB':bitnames}
02015         db=dbUtil.dbUtil(schema)
02016         db.insertOneRow(nameDealer.trgdataTableName(),tabrowDefDict,tabrowValueDict)
02017         return (revision_id,entry_id,data_id)
02018     except :
        raise
def dataDML::allfillschemes (   schema)

Definition at line 1054 of file dataDML.py.

01055                           :
01056     afterglows=[]
01057     s=nameDealer.fillschemeTableName()
01058     try:
01059         qHandle.addToTableList(s)
01060         qResult=coral.AttributeList()
01061         qResult.extend('FILLSCHEMEPATTERN','string')
01062         qResult.extend('CORRECTIONFACTOR','float')
01063         qHandle.defineOutput(qResult)
01064         qHandle.addToOutputList('FILLSCHEMEPATTERN')
01065         qHandle.addToOutputList('CORRECTIONFACTOR')
01066         cursor=qHandle.execute()
01067         while cursor.next():
01068             fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
01069             afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
01070             afterglows.append((fillschemePattern,afterglowfac))
01071     except :
01072         del qHandle
01073         raise
01074     del qHandle
01075     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 1183 of file dataDML.py.

01184                                                                         :
01185     '''
01186     result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),ncollidingbunches(4),beaminfolist(5),..])
01187          beaminfolist=[(bxidx,beam1intensity,beam2intensity)]
01188     '''
01189     runnum=0
01190     result=[]
01191     ncollidingbunches=0
01192     qHandle=schema.newQuery()
01193     try:
01194         qHandle.addToTableList(nameDealer.lumidataTableName())
01195         qHandle.addToOutputList('NCOLLIDINGBUNCHES')
01196         qConditionStr='DATA_ID=:dataid'
01197         qCondition=coral.AttributeList()
01198         qCondition.extend('dataid','unsigned long long')
01199         qCondition['dataid'].setData(dataid)
01200         qResult=coral.AttributeList()
01201         qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
01202         qHandle.defineOutput(qResult)
01203         qHandle.setCondition(qConditionStr,qCondition)
01204         cursor=qHandle.execute()
01205         while cursor.next():
01206             ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
01207     except :
01208         del qHandle
01209         raise
01210     del qHandle
01211     qHandle=schema.newQuery()
01212     try:
01213        qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
01214        qHandle.addToOutputList('RUNNUM')
01215        qHandle.addToOutputList('CMSLSNUM')
01216        qHandle.addToOutputList('LUMILSNUM')
01217        qHandle.addToOutputList('BEAMSTATUS')
01218        qHandle.addToOutputList('BEAMENERGY')
01219        if withBeamIntensity:
01220            qHandle.addToOutputList('CMSBXINDEXBLOB')
01221            qHandle.addToOutputList('BEAMINTENSITYBLOB_1')
01222            qHandle.addToOutputList('BEAMINTENSITYBLOB_2')
01223        qConditionStr='DATA_ID=:dataid'
01224        qCondition=coral.AttributeList()
01225        qCondition.extend('dataid','unsigned long long')
01226        qCondition['dataid'].setData(dataid)
01227        qResult=coral.AttributeList()
01228        qResult.extend('RUNNUM','unsigned int')
01229        qResult.extend('CMSLSNUM','unsigned int')
01230        qResult.extend('LUMILSNUM','unsigned int')
01231        qResult.extend('BEAMSTATUS','string')
01232        qResult.extend('BEAMENERGY','float')
01233        if withBeamIntensity:
01234            qResult.extend('BXINDEXBLOB','blob')
01235            qResult.extend('BEAM1INTENSITY','blob')
01236            qResult.extend('BEAM2INTENSITY','blob')
01237        qHandle.defineOutput(qResult)
01238        qHandle.setCondition(qConditionStr,qCondition)
01239        cursor=qHandle.execute()
01240        while cursor.next():
01241            runnum=cursor.currentRow()['RUNNUM'].data()
01242            cmslsnum=cursor.currentRow()['CMSLSNUM'].data()
01243            lumilsnum=cursor.currentRow()['LUMILSNUM'].data()
01244            beamstatus=cursor.currentRow()['BEAMSTATUS'].data()
01245            beamenergy=cursor.currentRow()['BEAMENERGY'].data()
01246            bxindexblob=None
01247            beaminfotupleList=[]
01248            if withBeamIntensity:
01249                bxindexblob=cursor.currentRow()['BXINDEXBLOB'].data()
01250                beam1intensityblob=cursor.currentRow()['BEAM1INTENSITY'].data()
01251                beam2intensityblob=cursor.currentRow()['BEAM2INTENSITY'].data()
01252                bxindexArray=None
01253                beam1intensityArray=None
01254                beam2intensityArray=None
01255                if bxindexblob:
01256                    bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h')
01257                if beam1intensityblob:
01258                    beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensityblob,'f')
01259                if beam2intensityblob:
01260                    beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensityblob,'f')
01261                if bxindexArray and beam1intensityArray and beam2intensityArray:
01262                    for idx,bxindex in enumerate(bxindexArray):
01263                        if (beam1intensityArray[idx] and beam1intensityArray[idx]>minIntensity) or (beam2intensityArray[idx] and beam2intensityArray[idx]>minIntensity):
01264                            beaminfotuple=(bxindex,beam1intensityArray[idx],beam2intensityArray[idx])                   
01265                            beaminfotupleList.append(beaminfotuple)
01266                    del bxindexArray[:]
01267                    del beam1intensityArray[:]
01268                    del beam2intensityArray[:]           
01269            result.append((lumilsnum,cmslsnum,beamstatus,beamenergy,ncollidingbunches,beaminfotupleList))
01270     except:
01271        del qHandle
01272        raise
01273     del qHandle
    return (runnum,result)
def dataDML::beamstatusByIds (   schema,
  dataidMap 
)
input dataidMap : {run:lumidataid}
result {runnum:{cmslsnum:beamstatus}}

Definition at line 911 of file dataDML.py.

00912                                      :
00913     '''
00914     input dataidMap : {run:lumidataid}
00915     result {runnum:{cmslsnum:beamstatus}}
00916     '''
00917     result={}
00918     if not dataidMap:
00919         return result
00920     inputRange=dataidMap.keys()
00921     for r in inputRange:
00922         if not result.has_key(r):
00923             result[r]={}
00924         lumidataid=dataidMap[r][0]
00925         if lumidataid:
00926             qHandle=schema.newQuery()
00927             try:
00928                 qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
00929                 qHandle.addToOutputList('CMSLSNUM')
00930                 qHandle.addToOutputList('BEAMSTATUS')
00931                 qConditionStr='DATA_ID=:dataid'
00932                 qCondition=coral.AttributeList()
00933                 qCondition.extend('dataid','unsigned long long')
00934                 qCondition['dataid'].setData(int(lumidataid))
00935                 qResult=coral.AttributeList()
00936                 qResult.extend('CMSLSNUM','unsigned int')
00937                 qResult.extend('BEAMSTATUS','string')
00938                 qHandle.defineOutput(qResult)
00939                 qHandle.setCondition(qConditionStr,qCondition)
00940                 cursor=qHandle.execute()
00941                 while cursor.next():
00942                     cmslsnum=cursor.currentRow()['CMSLSNUM'].data()
00943                     bs=cursor.currentRow()['BEAMSTATUS'].data()
00944                     if bs!='STABLE BEAMS':
00945                         result[r][cmslsnum]=bs
00946             except:
00947                 del qHandle
00948                 raise 
00949             del qHandle
00950     return result

def dataDML::bulkInsertHltLSData (   session,
  runnumber,
  data_id,
  hltlsdata,
  bulksize = 500 
)
input:
hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}

Definition at line 2158 of file dataDML.py.

02159                                                                          :
02160     '''
02161     input:
02162     hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
02163     '''
02164     print 'total number of hlt rows ',len(hltlsdata)
02165     lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')]
02166     committedrows=0
02167     nrows=0
02168     bulkvalues=[]   
02169     try:             
02170         for cmslsnum,perlshlt in hltlsdata.items():
02171             inputcountblob=perlshlt[0]
02172             acceptcountblob=perlshlt[1]
02173             prescaleblob=perlshlt[2]
02174             bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)])
02175             
02176             nrows+=1
02177             committedrows+=1
02178             if nrows==bulksize:
02179                 print 'committing hlt in LS chunck ',nrows
02180                 db=dbUtil.dbUtil(session.nominalSchema())
02181                 session.transaction().start(False)
02182                 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
02183                 session.transaction().commit()
02184                 nrows=0
02185                 bulkvalues=[]
02186             elif committedrows==len(hltlsdata):
02187                 print 'committing hlt at the end '
02188                 db=dbUtil.dbUtil(session.nominalSchema())
02189                 session.transaction().start(False)
02190                 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues)
02191                 session.transaction().commit()
02192     except  :
02193         print 'error in bulkInsertHltLSData'
02194         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 2195 of file dataDML.py.

02196                                                                                                          :
02197     '''
02198     input:
02199           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]}
02200     '''
02201     lslumiDefDict=[]
02202     if withDetails:
02203         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')]
02204     else:
02205         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')]
02206     print 'total number of lumi rows ',len(lumilsdata)
02207     try:
02208         committedrows=0
02209         nrows=0
02210         bulkvalues=[]
02211         for lumilsnum,perlslumi in lumilsdata.items():
02212             cmslsnum=perlslumi[0]
02213             instlumi=perlslumi[1]
02214             instlumierror=perlslumi[2]
02215             instlumiquality=perlslumi[3]
02216             beamstatus=perlslumi[4]
02217             beamenergy=perlslumi[5]
02218             numorbit=perlslumi[6]
02219             startorbit=perlslumi[7]
02220             if withDetails:
02221                 cmsbxindexindexblob=perlslumi[8]
02222                 beam1intensity=perlslumi[9]
02223                 beam2intensity=perlslumi[10]
02224                 bxlumivalue_occ1=perlslumi[11]
02225                 bxlumierror_occ1=perlslumi[12]
02226                 bxlumiquality_occ1=perlslumi[13]
02227                 bxlumivalue_occ2=perlslumi[14]
02228                 bxlumierror_occ2=perlslumi[15]
02229                 bxlumiquality_occ2=perlslumi[16]
02230                 bxlumivalue_et=perlslumi[17]
02231                 bxlumierror_et=perlslumi[18]
02232                 bxlumiquality_et=perlslumi[19]
02233                 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)])
02234             else:
02235                 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)])
02236             nrows+=1
02237             committedrows+=1
02238             if nrows==bulksize:
02239                 print 'committing lumi in LS chunck ',nrows
02240                 db=dbUtil.dbUtil(session.nominalSchema())
02241                 session.transaction().start(False)
02242                 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
02243                 session.transaction().commit()
02244                 nrows=0
02245                 bulkvalues=[]
02246             elif committedrows==len(lumilsdata):
02247                 print 'committing lumi at the end '
02248                 db=dbUtil.dbUtil(session.nominalSchema())
02249                 session.transaction().start(False)
02250                 db.bulkInsert(tableName,lslumiDefDict,bulkvalues)
02251                 session.transaction().commit()
02252     except :
02253         raise
02254 
02255 #def insertLumiLSDetail(schema,runnumber,data_id,lumibxdata):
02256 #    '''
02257 #    input:
02258 #          lumibxdata [(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]})]
02259 #    output:
02260 #          nrows
02261 #    '''
02262 #    try:
02263 #        nrow=0
02264 #        bulkvalues=[]
02265 #        lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('ALGONAME','string'),('BXLUMIVALUE','blob'),('BXLUMIERROR','blob'),('BXLUMIQUALITY','blob')]
02266 #        for (algoname,peralgobxdata) in lumibxdata:
02267 #            for lumilsnum,bxdata in peralgobxdata.items():
02268 #                cmslsnum=bxdata[0]
02269 #                bxlumivalue=bxdata[1]
02270 #                bxlumierror=bxdata[2]
02271 #                bxlumiquality=bxdata[3]
02272 #                bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('ALGONAME',algoname),('BXLUMIVALUE',bxlumivalue),('BXLUMIERROR',bxlumierror),('BXLUMIQUALITY',bxlumiquality)])
02273 #        db=dbUtil.dbUtil(schema)
02274 #        db.bulkInsert(nameDealer.lumidetailTableName(),lslumiDefDict,bulkvalues)
02275 #        return len(bulkvalues)
02276 #    except:
02277 #        raise 
02278     
02279 #def completeOldLumiData(schema,runnumber,lsdata,data_id):
02280 #    '''
02281 #    input:
02282 #    lsdata [[lumisummary_id,lumilsnum,cmslsnum]]
02283 #    '''
02284 #    try:
02285 #        #update in lumisummary table
02286 #        #print 'insert in lumisummary table'
02287 #        setClause='DATA_ID=:data_id'
02288 #        updateCondition='RUNNUM=:runnum AND DATA_ID is NULL'
02289 #        updateData=coral.AttributeList()
02290 #        updateData.extend('data_id','unsigned long long')
02291 #        updateData.extend('runnum','unsigned int')
02292 #        updateData['data_id'].setData(data_id)
02293 #        updateData['runnum'].setData(int(runnumber))
02294 #        db=dbUtil.dbUtil(schema)
02295 #        db.singleUpdate(nameDealer.lumisummaryTableName(),setClause,updateCondition,updateData)
02296 #        #updates in lumidetail table
02297 #        updateAction='DATA_ID=:data_id,RUNNUM=:runnum,CMSLSNUM=:cmslsnum,LUMILSNUM=:lumilsnum'
02298 #        updateCondition='LUMISUMMARY_ID=:lumisummary_id'
02299 #        bindvarDef=[]
02300 #        bindvarDef.append(('data_id','unsigned long long'))
02301 #        bindvarDef.append(('runnum','unsigned int'))
02302 #        bindvarDef.append(('cmslsnum','unsigned int'))
02303 #        bindvarDef.append(('lumilsnum','unsigned int'))        
02304 #        inputData=[]
02305 #        for [lumisummary_id,lumilsnum,cmslsnum] in lsdata:
02306 #            inputData.append([('data_id',data_id),('runnum',int(runnumber)),('cmslsnum',cmslsnum),('lumilsnum',lumilsnum)])
02307 #        db.updateRows(nameDealer.lumidetailTableName(),updateAction,updateCondition,bindvarDef,inputData)
02308 #    except:
02309 #        raise
02310     
02311 #=======================================================
02312 #   DELETE
02313 #=======================================================
02314 
02315 
02316 #=======================================================
02317 #   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 2118 of file dataDML.py.

02119                                                                          :
02120     '''
02121     insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks 
02122     input:
02123         trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]}
02124     result nrows inserted
02125     if nrows==0, then this insertion failed
02126     '''
02127     print 'total number of trg rows ',len(trglsdata)
02128     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')]
02129     committedrows=0
02130     nrows=0
02131     bulkvalues=[]
02132     try:
02133         for cmslsnum,perlstrg in trglsdata.items():
02134             deadtimecount=perlstrg[0]           
02135             bitzerocount=perlstrg[1]
02136             bitzeroprescale=perlstrg[2]
02137             trgcountblob=perlstrg[3]
02138             trgprescaleblob=perlstrg[4]
02139             bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)])
02140             nrows+=1
02141             committedrows+=1
02142             if nrows==bulksize:
02143                 print 'committing trg in LS chunck ',nrows
02144                 db=dbUtil.dbUtil(session.nominalSchema())
02145                 session.transaction().start(False)
02146                 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
02147                 session.transaction().commit()
02148                 nrows=0
02149                 bulkvalues=[]
02150             elif committedrows==len(trglsdata):
02151                 print 'committing trg at the end '
02152                 db=dbUtil.dbUtil(session.nominalSchema())
02153                 session.transaction().start(False)
02154                 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues)
02155                 session.transaction().commit()
02156     except :
02157         print 'error in bulkInsertTrgLSData'
        raise 
def dataDML::dataentryIdByRun (   schema,
  runnum,
  branchfilter 
)
select el.entry_id,et.entry_id,eh.entry_id,el.revision_id,et.revision_id,eh.revision_id from lumidataentiries el,trgdataentries et,hltdataentries eh where el.name=et.name and et.name=eh.name and el.name=:entryname;
check on entryrev
   
return [lumientryid,trgentryid,hltentryid]

Definition at line 1797 of file dataDML.py.

01798                                                 :
01799     '''
01800     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;
01801     check on entryrev
01802    
01803     return [lumientryid,trgentryid,hltentryid]
01804     '''
01805     result=[]
01806     qHandle=schema.newQuery()
01807     try:
01808         qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() ))
01809         qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() ))
01810         qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() ))
01811         qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid')
01812         qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid')
01813         qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid')
01814         qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr'
01815         qCondition=coral.AttributeList()
01816         qCondition.extend('runnumstr','string')
01817         qCondition['runnumstr'].setData(str(runnum))
01818         qResult=coral.AttributeList()
01819         qResult.extend('lumientryid','unsigned long long')
01820         qResult.extend('trgentryid','unsigned long long')
01821         qResult.extend('hltentryid','unsigned long long')
01822         qHandle.defineOutput(qResult)
01823         qHandle.setCondition(qConditionStr,qCondition)
01824         cursor=qHandle.execute()
01825         while cursor.next():
01826             lumientryid=cursor.currentRow()['lumientryid'].data()
01827             trgentryid=cursor.currentRow()['trgentryid'].data()
01828             hltentryid=cursor.currentRow()['hltentryid'].data()
01829             if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter:
01830                 result.extend([lumientryid,trgentryid,hltentryid])
01831     except:
01832         del qHandle
01833         raise 
01834     del qHandle
01835     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 89 of file dataDML.py.

Referenced by MuonPFAnalyzer::analyze().

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

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

Definition at line 1563 of file dataDML.py.

01564                                          :
01565     '''
01566     output:(patternStr:correctionFac)
01567     '''
01568     if lumitype not in ['PIXEL','HF']:
01569         raise ValueError('[ERROR] unsupported lumitype '+lumitype)
01570     correctorField='CORRECTIONFACTOR'
01571     if lumitype=='PIXEL':
01572         correctorField='PIXELCORRECTIONFACTOR'
01573     result={}
01574     qHandle=schema.newQuery()
01575     try:
01576         qHandle.addToTableList(nameDealer.fillschemeTableName())
01577         qResult=coral.AttributeList()
01578         qResult.extend('FILLSCHEMEPATTERN','string')
01579         qResult.extend('CORRECTIONFACTOR','float')
01580         qHandle.defineOutput(qResult)
01581         qHandle.addToOutputList('FILLSCHEMEPATTERN')
01582         qHandle.addToOutputList(correctorField)
01583         cursor=qHandle.execute()
01584         while cursor.next():
01585             fillschemePattern=cursor.currentRow()['FILLSCHEMEPATTERN'].data()
01586             afterglowfac=cursor.currentRow()['CORRECTIONFACTOR'].data()
01587             result[fillschemePattern]=afterglowfac
01588     except :
01589         del qHandle
01590         raise
01591     del qHandle
01592     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 16 of file dataDML.py.

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

01612                                                             :
01613     '''
01614     select max data_id of the given run. In current design, it's the most recent data of the run
01615     '''
01616     result=None
01617     ids=[]
01618     qHandle=schema.newQuery()
01619     try:
01620         qHandle.addToTableList(tablename)
01621         qHandle.addToOutputList('DATA_ID')
01622         qConditionStr='RUNNUM=:runnum '
01623         qCondition=coral.AttributeList()
01624         qCondition.extend('runnum','unsigned int')
01625         qCondition['runnum'].setData(runnum)
01626         qResult=coral.AttributeList()
01627         qResult.extend('DATA_ID','unsigned long long')
01628         qHandle.defineOutput(qResult)
01629         qHandle.setCondition(qConditionStr,qCondition)
01630         cursor=qHandle.execute()
01631         while cursor.next():
01632             dataid=cursor.currentRow()['DATA_ID'].data()
01633             ids.append(dataid)
01634     except :
01635         del qHandle
01636         raise 
01637     del qHandle
01638     if len(ids)>0 :
01639         return max(ids)
01640     else:
01641         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 1642 of file dataDML.py.

01643                                                     :
01644     '''
01645     input: inputRange [run]
01646     output: {run:lumiid}
01647     select data_id,runnum from hltdata where runnum<=runmax and runnum>=:runmin 
01648     '''
01649     result={}
01650     if not inputRange : return result
01651     if len(inputRange)==1:
01652         trgid=guessDataIdByRun(schema,inputRange[0],tablename)
01653         result[inputRange[0]]=trgid
01654         return result
01655     rmin=min(inputRange)
01656     rmax=max(inputRange)
01657     result=dict.fromkeys(inputRange,None)
01658     qHandle=schema.newQuery()
01659     try:
01660         qHandle.addToTableList(tablename)
01661         qHandle.addToOutputList('DATA_ID')
01662         qHandle.addToOutputList('RUNNUM')
01663         qConditionStr='RUNNUM>=:rmin'
01664         qCondition=coral.AttributeList()
01665         qCondition.extend('rmin','unsigned int')
01666         qCondition['rmin'].setData(rmin)
01667         if rmin!=rmax:
01668             qConditionStr+=' AND RUNNUM<=:rmax'
01669             qCondition.extend('rmax','unsigned int')
01670             qCondition['rmax'].setData(rmax)
01671         qResult=coral.AttributeList()
01672         qResult.extend('DATA_ID','unsigned long long')
01673         qResult.extend('RUNNUM','unsigned int')
01674         qHandle.defineOutput(qResult)
01675         qHandle.setCondition(qConditionStr,qCondition)
01676         cursor=qHandle.execute()
01677         while cursor.next():
01678             dataid=cursor.currentRow()['DATA_ID'].data()
01679             runnum=cursor.currentRow()['RUNNUM'].data()
01680             if result.has_key(runnum):
01681                 if dataid>result[runnum]:
01682                     result[runnum]=dataid
01683     except :
01684         del qHandle
01685         raise 
01686     del qHandle
01687     return result
01688 #def guessAllDataIdByRun(schema,runnum):
01689 #    '''
01690 #    get dataids by runnumber, if there are duplicates, pick max(dataid).Bypass full version lookups
01691 #    result (lumidataid(0),trgdataid(1),hltdataid(2)) 
01692 #    '''
01693 #    lumiids=[]
01694 #    trgids=[]
01695 #    hltids=[]
01696 #    qHandle=schema.newQuery()
01697 #    try:
01698 #        qHandle.addToTableList(nameDealer.lumidataTableName(),'l')
01699 #        qHandle.addToTableList(nameDealer.trgdataTableName(),'t')
01700 #        qHandle.addToTableList(nameDealer.hltdataTableName(),'h')
01701 #        qHandle.addToOutputList('l.DATA_ID','lumidataid')
01702 #        qHandle.addToOutputList('t.DATA_ID','trgdataid')
01703 #        qHandle.addToOutputList('h.DATA_ID','hltdataid')
01704 #        qConditionStr='l.RUNNUM=t.RUNNUM and t.RUNNUM=h.RUNNUM and l.RUNNUM=:runnum '
01705 #        qCondition=coral.AttributeList()
01706 #        qCondition.extend('runnum','unsigned int')
01707 #        qCondition['runnum'].setData(runnum)
01708 #        qResult=coral.AttributeList()
01709 #        qResult.extend('lumidataid','unsigned long long')
01710 #        qResult.extend('trgdataid','unsigned long long')
01711 #        qResult.extend('hltdataid','unsigned long long')
01712 #        qHandle.defineOutput(qResult)
01713 #        qHandle.setCondition(qConditionStr,qCondition)
01714 #        cursor=qHandle.execute()
01715 #        while cursor.next():
01716 #            lumidataid=cursor.currentRow()['lumidataid'].data()
01717 #            trgdataid=cursor.currentRow()['trgdataid'].data()
01718 #            hltdataid=cursor.currentRow()['hltdataid'].data()
01719 #            lumiids.append(lumidataid)
01720 #            trgids.append(trgdataid)
01721 #            hltids.append(hltdataid)
01722 #    except :
01723 #        del qHandle
01724 #        raise 
01725 #    del qHandle
01726 #    if len(lumiids)>0 and len(trgids)>0 and len(hltids)>0:
01727 #        return (max(lumiids),max(trgids),max(hltids))
01728 #    else:
01729 #        return (None,None,None)

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

Definition at line 1605 of file dataDML.py.

01605                                                                    :    
01606     revlist=revisionDML.revisionsInBranchName(schema,branchName)
01607     hltentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
01608     latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,hltentry_id,revlist)
01609     return latestrevision
01610 
def dataDML::guessLumiDataIdByRunInBranch (   schema,
  runnum,
  tablename,
  branchName 
)

Definition at line 1593 of file dataDML.py.

01594                                                                     :
01595     revlist=revisionDML.revisionsInBranchName(schema,branchName)
01596     lumientry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
01597     latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,lumientry_id,revlist)
01598     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 1730 of file dataDML.py.

01731                                                :
01732     '''
01733     get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups
01734     select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1   
01735     '''
01736     luminormids=[]
01737     qHandle=schema.newQuery()
01738     egevmin=egev1*0.95
01739     egevmax=egev1*1.05
01740     try:
01741         qHandle.addToTableList( nameDealer.luminormTableName() )
01742         qHandle.addToOutputList('DATA_ID','normdataid')
01743         qConditionStr='AMODETAG=:amodetag AND EGEV_1>=:egevmin AND  EGEV_1<=:egevmax'
01744         qCondition=coral.AttributeList()
01745         qCondition.extend('amodetag','string')
01746         qCondition.extend('egevmin','unsigned int')
01747         qCondition.extend('egevmax','unsigned int')
01748         qCondition['amodetag'].setData(amodetag)
01749         qCondition['egevmin'].setData(int(egevmin))
01750         qCondition['egevmax'].setData(int(egevmax))
01751         qResult=coral.AttributeList()
01752         qResult.extend('normdataid','unsigned long long')
01753         qHandle.defineOutput(qResult)
01754         qHandle.setCondition(qConditionStr,qCondition)
01755         cursor=qHandle.execute()
01756         while cursor.next():
01757             normdataid=cursor.currentRow()['normdataid'].data()
01758             luminormids.append(normdataid)
01759     except :
01760         del qHandle
01761         raise
01762     del qHandle
01763     if len(luminormids) !=0:return max(luminormids)
01764     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 1765 of file dataDML.py.

01766                                       :
01767     '''
01768     get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups
01769     select data_id from luminorms where entry_name=:normname
01770     result luminormdataid
01771     '''   
01772     luminormids=[]
01773     qHandle=schema.newQuery()
01774     try:
01775         qHandle.addToTableList( nameDealer.luminormTableName() )
01776         qHandle.addToOutputList('DATA_ID','normdataid')
01777         qConditionStr='ENTRY_NAME=:normname '
01778         qCondition=coral.AttributeList()
01779         qCondition.extend('normname','string')
01780         qCondition['normname'].setData(normname)
01781         qResult=coral.AttributeList()
01782         qResult.extend('normdataid','unsigned long long')
01783         qHandle.defineOutput(qResult)
01784         qHandle.setCondition(qConditionStr,qCondition)
01785         cursor=qHandle.execute()
01786         while cursor.next():
01787             normdataid=cursor.currentRow()['normdataid'].data()
01788             luminormids.append(normdataid)
01789     except :
01790         del qHandle
01791         raise
01792     del qHandle
01793     if len(luminormids) !=0:return max(luminormids)
01794     return None

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

Definition at line 1599 of file dataDML.py.

01599                                                                    :    
01600     revlist=revisionDML.revisionsInBranchName(schema,branchName)
01601     trgentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName)
01602     latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,trgentry_id,revlist)
01603     return latestrevision
01604 
def dataDML::hltLSById (   schema,
  dataid,
  hltpathname = None,
  hltpathpattern = None,
  withL1Pass = False,
  withHLTAccept = False 
)
result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 

Definition at line 1428 of file dataDML.py.

01429                                                                                                       :
01430     '''
01431     result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 
01432     '''
01433     #print 'entering hltLSById '
01434     #t0=time.time()
01435     result={}
01436     hltrundata=hltRunById(schema,dataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern)
01437     if not hltrundata:
01438         return result        
01439     hltnamedict=hltrundata[3]
01440     if not hltnamedict:
01441         return (hltrundata[0],{})
01442     #tt1=time.time()
01443     #print '\thltrunbyid time ',tt1-t0
01444     #tt0=time.time()
01445     qHandle=schema.newQuery()
01446     try:
01447         qHandle.addToTableList(nameDealer.lshltTableName())
01448         qHandle.addToOutputList('RUNNUM','runnum')
01449         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
01450         if len(hltnamedict)!=0:
01451             qHandle.addToOutputList('PRESCALEBLOB','prescaleblob')
01452         if withL1Pass:
01453             qHandle.addToOutputList('HLTCOUNTBLOB','hltcountblob')
01454         if withHLTAccept:
01455             qHandle.addToOutputList('HLTACCEPTBLOB','hltacceptblob')
01456         qConditionStr='DATA_ID=:dataid'
01457         qCondition=coral.AttributeList()
01458         qCondition.extend('dataid','unsigned long long')
01459         qCondition['dataid'].setData(dataid)
01460         qResult=coral.AttributeList()
01461         qResult.extend('runnum','unsigned int')
01462         qResult.extend('cmslsnum','unsigned int')
01463         if len(hltnamedict)!=0:
01464             qResult.extend('prescaleblob','blob')
01465         if withL1Pass:
01466             qResult.extend('hltcountblob','blob')
01467         if withHLTAccept:
01468             qResult.extend('hltacceptblob','blob')
01469         qHandle.defineOutput(qResult)
01470         qHandle.setCondition(qConditionStr,qCondition)
01471         cursor=qHandle.execute()
01472         while cursor.next():
01473             runnum=cursor.currentRow()['runnum'].data()
01474             cmslsnum=cursor.currentRow()['cmslsnum'].data()
01475             prescaleblob=None
01476             hltcountblob=None
01477             hltacceptblob=None
01478             if len(hltnamedict)!=0:
01479                 prescaleblob=cursor.currentRow()['prescaleblob'].data()
01480             if withL1Pass:
01481                 hltcountblob=cursor.currentRow()['hltcountblob'].data()
01482             if withHLTAccept:
01483                 hltacceptblob=cursor.currentRow()['hltacceptblob'].data()
01484             if not result.has_key(cmslsnum):
01485                 result[cmslsnum]=[]
01486             pathinfo=[]
01487             prescales=None
01488             hltcounts=None
01489             hltaccepts=None
01490             if prescaleblob:
01491                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
01492                     prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'l')
01493                 else:
01494                     prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'I')
01495             if hltcountblob:
01496                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
01497                     hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'l')
01498                 else:
01499                     hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'I')
01500             if hltacceptblob:
01501                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
01502                     hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'l')
01503                 else:
01504                     hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'I')
01505             for (hltpathidx,thispathname) in hltnamedict:#loop over selected paths
01506                 thispresc=0
01507                 thishltcount=0
01508                 thisaccept=0
01509                 if prescales:
01510                     thispresc=prescales[hltpathidx]
01511                 if hltcounts:
01512                     thishltcount=hltcounts[hltpathidx]
01513                 if hltaccepts:
01514                     thisaccept=hltaccepts[hltpathidx]
01515                 thispathinfo=(thispathname,thispresc,thishltcount,thisaccept)
01516                 pathinfo.append(thispathinfo)
01517             result[cmslsnum]=pathinfo
01518     except :
01519         del qHandle
01520         raise
01521     del qHandle
01522     #tt1=time.time()
01523     #print '\tdb stuff time ',tt1-tt0
01524     #t1=time.time()
01525     #print 'tot hltLSById time ',t1-t0
01526     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 1324 of file dataDML.py.

01325                                                                   :
01326     '''
01327     result [runnum(0),datasource(1),npath(2),hltnamedict(3)]
01328     output :
01329          npath : total number of hltpath in DB
01330          hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)]
01331     '''
01332     result=[]    
01333     qHandle=schema.newQuery()
01334     runnum=None
01335     datasource=None
01336     npath=None
01337     hltnamedict=[]
01338     try:
01339         qHandle.addToTableList(nameDealer.hltdataTableName())
01340         qHandle.addToOutputList('RUNNUM','runnum')
01341         qHandle.addToOutputList('SOURCE','datasource')
01342         qHandle.addToOutputList('NPATH','npath')
01343         qHandle.addToOutputList('PATHNAMECLOB','pathnameclob')
01344         qConditionStr='DATA_ID=:dataid'
01345         qCondition=coral.AttributeList()
01346         qCondition.extend('dataid','unsigned long long')
01347         qCondition['dataid'].setData(dataid)
01348         qResult=coral.AttributeList()
01349         qResult.extend('runnum','unsigned int')
01350         qResult.extend('datasource','string')
01351         qResult.extend('npath','unsigned int')
01352         qResult.extend('pathnameclob','string')
01353         qHandle.defineOutput(qResult)
01354         qHandle.setCondition(qConditionStr,qCondition)
01355         cursor=qHandle.execute()
01356         pathnameclob=None
01357         pathnames=[]
01358         while cursor.next():
01359             runnum=cursor.currentRow()['runnum'].data()
01360             datasource=cursor.currentRow()['datasource'].data()
01361             npath=cursor.currentRow()['npath'].data()
01362             pathnameclob=cursor.currentRow()['pathnameclob'].data()
01363         if pathnameclob:
01364             pathnames=pathnameclob.split(',')
01365             for pathnameidx,hltname in enumerate(pathnames):
01366                 if hltpathname:
01367                     if hltpathname==hltname:
01368                         hltnamedict.append((pathnameidx,hltname))
01369                         break
01370                 elif hltpathpattern:
01371                     if fnmatch.fnmatch(hltname,hltpathpattern):
01372                         hltnamedict.append((pathnameidx,hltname))
01373                 #else:
01374                     #hltnamedict.append((pathnameidx,hltname))
01375         result=[runnum,datasource,npath,hltnamedict]
01376     except :
01377         del qHandle
01378         raise 
01379     del qHandle
01380     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 1381 of file dataDML.py.

01382                                                                           :
01383     '''
01384     select m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname] 
01385     output: {hltpath:l1seed}
01386     '''
01387     result={}
01388     queryHandle=schema.newQuery()
01389     r=nameDealer.cmsrunsummaryTableName()
01390     m=nameDealer.trghltMapTableName()
01391     if hltpathpattern and hltpathpattern in ['*','all','All','ALL']:
01392         hltpathpattern=None
01393     try:
01394         queryHandle.addToTableList(r)
01395         queryHandle.addToTableList(m)
01396         queryCondition=coral.AttributeList()
01397         queryCondition.extend('runnum','unsigned int')
01398         queryCondition['runnum'].setData(int(runnum))
01399         #queryHandle.addToOutputList(m+'.HLTKEY','hltkey')
01400         queryHandle.addToOutputList(m+'.HLTPATHNAME','hltpathname')
01401         queryHandle.addToOutputList(m+'.L1SEED','l1seed')
01402         conditionStr=r+'.RUNNUM=:runnum and '+m+'.HLTKEY='+r+'.HLTKEY'
01403         if hltpathname:
01404             hltpathpattern=None
01405             conditionStr+=' AND '+m+'.HLTPATHNAME=:hltpathname'
01406             queryCondition.extend('hltpathname','string')
01407             queryCondition['hltpathname'].setData(hltpathname)
01408         queryHandle.setCondition(conditionStr,queryCondition)
01409         queryResult=coral.AttributeList()
01410         queryResult.extend('pname','string')
01411         queryResult.extend('l1seed','string')
01412         queryHandle.defineOutput(queryResult)
01413         cursor=queryHandle.execute()
01414         while cursor.next():
01415             pname=cursor.currentRow()['pname'].data()
01416             l1seed=cursor.currentRow()['l1seed'].data()
01417             if not result.has_key(hltpathname):
01418                 if hltpathpattern:
01419                     if fnmatch.fnmatch(pname,hltpathpattern):
01420                         result[pname]=l1seed
01421                 else:
01422                     result[pname]=l1seed
01423     except :
01424         del queryHandle
01425         raise
01426     del queryHandle
01427     return result

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

Definition at line 2046 of file dataDML.py.

02047                                                                                 :
02048     '''
02049     input:
02050         runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime]
02051     output:
02052     '''
02053     l1key=runsummarydata[0]
02054     amodetag=runsummarydata[1]
02055     egev=runsummarydata[2]
02056     hltkey=''
02057     fillnum=0
02058     sequence=''
02059     starttime=''
02060     stoptime=''
02061     if not complementalOnly:
02062         sequence=runsummarydata[3]
02063         hltkey=runsummarydata[4]
02064         fillnum=runsummarydata[5]
02065         starttime=runsummarydata[6]
02066         stoptime=runsummarydata[7]
02067     try:
02068         if not complementalOnly:
02069             tabrowDefDict={'RUNNUM':'unsigned int','L1KEY':'string','AMODETAG':'string','EGEV':'unsigned int','SEQUENCE':'string','HLTKEY':'string','FILLNUM':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp'}
02070             tabrowValueDict={'RUNNUM':int(runnumber),'L1KEY':l1key,'AMODETAG':amodetag,'EGEV':int(egev),'SEQUENCE':sequence,'HLTKEY':hltkey,'FILLNUM':int(fillnum),'STARTTIME':starttime,'STOPTIME':stoptime}
02071             db=dbUtil.dbUtil(schema)
02072             db.insertOneRow(nameDealer.cmsrunsummaryTableName(),tabrowDefDict,tabrowValueDict)
02073         else:
02074             setClause='L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev'
02075             updateCondition='RUNNUM=:runnum'
02076             inputData=coral.AttributeList()
02077             inputData.extend('l1key','string')
02078             inputData.extend('amodetag','string')
02079             inputData.extend('egev','unsigned int')
02080             inputData.extend('runnum','unsigned int')
02081             inputData['l1key'].setData(l1key)
02082             inputData['amodetag'].setData(amodetag)
02083             inputData['egev'].setData(int(egev))
02084             inputData['runnum'].setData(int(runnumber))
02085             db=dbUtil.dbUtil(schema)
02086             db.singleUpdate(nameDealer.cmsrunsummaryTableName(),setClause,updateCondition,inputData)
02087     except :
        raise   
def dataDML::insertTrgHltMap (   schema,
  hltkey,
  trghltmap 
)
input:
    trghltmap {hltpath:l1seed}
output:

Definition at line 2088 of file dataDML.py.

02089                                             :
02090     '''
02091     input:
02092         trghltmap {hltpath:l1seed}
02093     output:
02094     '''
02095     hltkeyExists=False
02096     nrows=0
02097     try:
02098         kQueryBindList=coral.AttributeList()
02099         kQueryBindList.extend('hltkey','string')
02100         kQuery=schema.newQuery()
02101         kQuery.addToTableList(nameDealer.trghltMapTableName())
02102         kQuery.setCondition('HLTKEY=:hltkey',kQueryBindList)
02103         kQueryBindList['hltkey'].setData(hltkey)
02104         kResult=kQuery.execute()
02105         while kResult.next():
02106             hltkeyExists=True
02107         if not hltkeyExists:
02108             bulkvalues=[]   
02109             trghltDefDict=[('HLTKEY','string'),('HLTPATHNAME','string'),('L1SEED','string')]
02110             for hltpath,l1seed in trghltmap.items():
02111                 bulkvalues.append([('HLTKEY',hltkey),('HLTPATHNAME',hltpath),('L1SEED',l1seed)])
02112             db=dbUtil.dbUtil(schema)
02113             db.bulkInsert(nameDealer.trghltMapTableName(),trghltDefDict,bulkvalues)
02114             nrows=len(bulkvalues)
02115         return nrows
02116     except :
02117         print 'error in insertTrgHltMap '
        raise
def dataDML::intglumiForRange (   schema,
  runlist 
)
output: {run:intglumi_in_fb}

Definition at line 1527 of file dataDML.py.

01528                                     :
01529     '''
01530     output: {run:intglumi_in_fb}
01531     '''
01532     result={}
01533     if not runlist:
01534         return result
01535     minrun=min(runlist)
01536     maxrun=max(runlist)
01537     qHandle=schema.newQuery()
01538     try:
01539         qHandle.addToTableList(nameDealer.intglumiv2TableName())
01540         qResult=coral.AttributeList()
01541         qResult.extend('RUNNUM','unsigned int')
01542         qResult.extend('INTGLUMI','float')
01543         qConditionStr='RUNNUM>=:minrun AND RUNNUM<=:maxrun'
01544         qCondition=coral.AttributeList()
01545         qCondition.extend('minrun','unsigned int')
01546         qCondition.extend('maxrun','unsigned int')
01547         qCondition['minrun'].setData(minrun)
01548         qCondition['maxrun'].setData(maxrun)
01549         qHandle.addToOutputList('RUNNUM')
01550         qHandle.addToOutputList('INTGLUMI')
01551         qHandle.setCondition(qConditionStr,qCondition)
01552         qHandle.defineOutput(qResult)
01553         cursor=qHandle.execute()
01554         while cursor.next():
01555             runnum=cursor.currentRow()['RUNNUM'].data()
01556             intglumi=cursor.currentRow()['INTGLUMI'].data()
01557             result[runnum]=intglumi
01558     except :
01559         del qHandle
01560         raise
01561     del qHandle
01562     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 1836 of file dataDML.py.

01837                                                              :
01838     '''
01839     select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where  l.data_id=rl.data_id and l.entry_id=:entryid
01840     check revision_id is in branch
01841     '''
01842     dataids=[]
01843     datatablename=''
01844     revmaptablename=''
01845     if datatype=='lumi':
01846         datatablename=nameDealer.lumidataTableName()
01847     elif datatype=='trg':
01848         datatablename=nameDealer.trgdataTableName()
01849     elif dataytpe=='hlt':
01850         tablename=nameDealer.hltdataTableName()
01851     else:
01852         raise RunTimeError('datatype '+datatype+' is not supported')
01853     revmaptablename=nameDealer.revmapTableName(datatablename)
01854     qHandle=schema.newQuery()
01855     try:
01856         qHandle.addToTableList(revmaptablename)
01857         qHandle.addToTableList(datatablename)
01858         qHandle.addToOutputList('l.DATA_ID','dataid')
01859         qHandle.addToOutputList(revmaptablename+'.REVISION_ID','revisionid')
01860         qConditionStr=datatablename+'.DATA_ID='+revmaptablename+'.DATA_ID AND '+datatablename+'.ENTRY_ID=:entryid'
01861         qCondition=coral.AttributeList()
01862         qCondition.extend('entryid','unsigned long long')
01863         qResult=coral.AttributeList()
01864         qResult.extend('dataid','unsigned long long')
01865         qResult.extend('revisionid','unsigned long long')
01866         qHandle.defineOutput(qResult)
01867         qHandle.setCondition(qConditionStr,qCondition)
01868         cursor=qHandle.execute()
01869         while cursor.next():
01870             dataid=cursor.currentRow()['dataid'].data()
01871             revisionid=cursor.currentRow()['revisionid'].data()
01872             if revisionid in branchfilter:
01873                 dataids.append(dataid)
01874     except:
01875         del qHandle
01876         raise
01877     del qHandle
01878     if len(dataids)!=0:return max(dataids)
01879     return None
01880 
01881 
01882 #=======================================================
01883 #   INSERT requires in update transaction
#=======================================================
def dataDML::lumiBXByAlgo (   schema,
  dataid,
  algoname 
)
result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}

Definition at line 1274 of file dataDML.py.

01275                                         :
01276     '''
01277     result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
01278     '''
01279     result={}
01280     qHandle=schema.newQuery()
01281     try:
01282         qHandle.addToTableList(nameDealer.lumisummaryv2TableName())
01283         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
01284         qHandle.addToOutputList('LUMILSNUM','lumilsnum')
01285         #qHandle.addToOutputList('ALGONAME','algoname')
01286         qHandle.addToOutputList('NUMORBIT','numorbit')
01287         qHandle.addToOutputList('STARTORBIT','startorbit')
01288         qHandle.addToOutputList('BXLUMIVALUE_'+algoname,'bxlumivalue')
01289         qHandle.addToOutputList('BXLUMIERROR_'+algoname,'bxlumierr')
01290         qHandle.addToOutputList('BXLUMIQUALITY_'+algoname,'bxlumiqlty')
01291         qConditionStr='DATA_ID=:dataid'
01292         qCondition=coral.AttributeList()
01293         qCondition.extend('dataid','unsigned long long')
01294         qCondition['dataid'].setData(dataid)
01295         qResult=coral.AttributeList()
01296         qResult.extend('cmslsnum','unsigned int')
01297         qResult.extend('lumilsnum','unsigned int')
01298         qResult.extend('numorbit','unsigned int')
01299         qResult.extend('startorbit','unsigned int')
01300         qResult.extend('bxlumivalue','blob')
01301         qResult.extend('bxlumierr','blob')
01302         qResult.extend('bxlumiqlty','blob')
01303         qHandle.defineOutput(qResult)
01304         qHandle.setCondition(qConditionStr,qCondition)
01305         cursor=qHandle.execute()
01306         while cursor.next():
01307             cmslsnum=cursor.currentRow()['cmslsnum'].data()
01308             lumilsnum=cursor.currentRow()['lumilsnum'].data()
01309             numorbit=cursor.currentRow()['numorbit'].data()
01310             startorbit=cursor.currentRow()['startorbit'].data()
01311             bxlumivalue=cursor.currentRow()['bxlumivalue'].data()
01312             bxlumierr=cursor.currentRow()['bxlumierr'].data()
01313             bxlumiqlty=cursor.currentRow()['bxlumiqlty'].data()
01314             if not result.has_key(algoname):
01315                 result[algoname]={}
01316             if not result[algoname].has_key(lumilsnum):
01317                 result[algoname][lumilsnum]=[]
01318             result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty])
01319     except :
01320         del qHandle
01321         raise RuntimeError(' dataDML.lumiBXById: '+str(e)) 
01322     del qHandle
01323     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 49 of file dataDML.py.

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

01077                                                                                                                    :
01078     '''
01079     input:
01080        beamstatus: filter on beam status flag
01081     output:
01082     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)]})
01083     '''
01084     runnum=0
01085     result={}
01086     qHandle=schema.newQuery()
01087     if withBXInfo and bxAlgo not in ['OCC1','OCC2','ET']:
01088         raise ValueError('unknown lumi algo '+bxAlgo)
01089     if beamstatus and beamstatus not in ['STABLE BEAMS',]:
01090         raise ValueError('unknown beam status '+beamstatus)
01091     try:
01092         if tableName is None:
01093             lls=nameDealer.lumisummaryv2TableName()
01094         else:
01095             lls=tableName
01096         qHandle.addToTableList(lls)
01097         qHandle.addToOutputList('RUNNUM','runnum')
01098         qHandle.addToOutputList('LUMILSNUM','lumilsnum')
01099         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
01100         qHandle.addToOutputList('INSTLUMI','instlumi')
01101         qHandle.addToOutputList('INSTLUMIERROR','instlumierr')
01102         qHandle.addToOutputList('INSTLUMIQUALITY','instlumiqlty')
01103         qHandle.addToOutputList('BEAMSTATUS','beamstatus')
01104         qHandle.addToOutputList('BEAMENERGY','beamenergy')
01105         qHandle.addToOutputList('NUMORBIT','numorbit')
01106         qHandle.addToOutputList('STARTORBIT','startorbit')
01107         if withBXInfo:
01108             qHandle.addToOutputList('BXLUMIVALUE_'+bxAlgo,'bxvalue')
01109             qHandle.addToOutputList('BXLUMIERROR_'+bxAlgo,'bxerror')
01110         if withBeamIntensity:
01111             qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob')
01112             qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity')
01113             qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity')
01114         
01115         qConditionStr='DATA_ID=:dataid'
01116         qCondition=coral.AttributeList()
01117         qCondition.extend('dataid','unsigned long long')
01118         qCondition['dataid'].setData(int(dataid))
01119         if beamstatus:
01120             qConditionStr+=' and BEAMSTATUS=:beamstatus'
01121             qCondition.extend('beamstatus','string')
01122             qCondition['beamstatus'].setData(beamstatus)
01123         qResult=coral.AttributeList()
01124         qResult.extend('runnum','unsigned int')
01125         qResult.extend('lumilsnum','unsigned int')
01126         qResult.extend('cmslsnum','unsigned int')
01127         qResult.extend('instlumi','float')
01128         qResult.extend('instlumierr','float')
01129         qResult.extend('instlumiqlty','short')
01130         qResult.extend('beamstatus','string')
01131         qResult.extend('beamenergy','float')
01132         qResult.extend('numorbit','unsigned int')
01133         qResult.extend('startorbit','unsigned int')
01134         if withBXInfo:
01135             qResult.extend('bxvalue','blob')
01136             qResult.extend('bxerror','blob')          
01137         if withBeamIntensity:
01138             qResult.extend('bxindexblob','blob')
01139             qResult.extend('beam1intensity','blob')
01140             qResult.extend('beam2intensity','blob')
01141         qHandle.defineOutput(qResult)
01142         qHandle.setCondition(qConditionStr,qCondition)
01143         cursor=qHandle.execute()
01144         while cursor.next():
01145             runnum=cursor.currentRow()['runnum'].data()
01146             lumilsnum=cursor.currentRow()['lumilsnum'].data()
01147             cmslsnum=cursor.currentRow()['cmslsnum'].data()
01148             instlumi=cursor.currentRow()['instlumi'].data()
01149             instlumierr=cursor.currentRow()['instlumierr'].data()
01150             instlumiqlty=cursor.currentRow()['instlumiqlty'].data()
01151             bs=cursor.currentRow()['beamstatus'].data()
01152             begev=cursor.currentRow()['beamenergy'].data()
01153             numorbit=cursor.currentRow()['numorbit'].data()
01154             startorbit=cursor.currentRow()['startorbit'].data()
01155             bxinfo=None
01156             bxvalueblob=None
01157             bxerrblob=None
01158             if withBXInfo:
01159                 bxvalueblob=cursor.currentRow()['bxvalue'].data()
01160                 bxerrblob=cursor.currentRow()['bxerror'].data()
01161                 if bxvalueblob and bxerrblob:
01162                     bxvaluesArray=CommonUtil.unpackBlobtoArray(bxvalueblob,'f')
01163                     bxerrArray=CommonUtil.unpackBlobtoArray(bxerrblob,'f')
01164                     bxinfo=(bxvaluesArray,bxerrArray)
01165             bxindexblob=None
01166             beam1intensity=None
01167             beam2intensity=None
01168             beaminfo=None
01169             if withBeamIntensity:
01170                 bxindexblob=cursor.currentRow()['bxindexblob'].data()
01171                 beam1intensity=cursor.currentRow()['beam1intensity'].data()
01172                 beam2intensity=cursor.currentRow()['beam2intensity'].data()
01173                 if bxindexblob :
01174                     bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h')
01175                     beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensity,'f')
01176                     beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensity,'f')
01177                     beaminfo=(bxindexArray,beam1intensityArray,beam2intensityArray)
01178             result[lumilsnum]=[cmslsnum,instlumi,instlumierr,instlumiqlty,bs,begev,numorbit,startorbit,bxinfo,beaminfo]
01179     except :
01180         del qHandle
01181         raise 
01182     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 546 of file dataDML.py.

00547                                :
00548     '''
00549     select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid
00550     output: {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
00551     '''
00552     result=None
00553     qHandle=schema.newQuery()
00554     try:
00555         qHandle.addToTableList(nameDealer.luminormTableName())
00556         qHandle.addToOutputList('ENTRY_NAME','normname')
00557         qHandle.addToOutputList('AMODETAG','amodetag')
00558         qHandle.addToOutputList('NORM_1','norm_1')
00559         qHandle.addToOutputList('EGEV_1','energy_1')
00560         qHandle.addToOutputList('NORM_OCC2','norm_occ2')
00561         qHandle.addToOutputList('NORM_ET','norm_et')
00562         qHandle.addToOutputList('NORM_PU','norm_pu')
00563         qHandle.addToOutputList('CONSTFACTOR','constfactor')        
00564         qCondition=coral.AttributeList()
00565         qCondition.extend('dataid','unsigned long long')
00566         qCondition['dataid'].setData(dataid)
00567         qResult=coral.AttributeList()
00568         qResult.extend('normname','string')
00569         qResult.extend('amodetag','string')
00570         qResult.extend('norm_1','float')
00571         qResult.extend('energy_1','unsigned int')
00572         qResult.extend('norm_occ2','float')
00573         qResult.extend('norm_et','float')
00574         qResult.extend('norm_pu','float')
00575         qResult.extend('constfactor','float')
00576         qHandle.defineOutput(qResult)
00577         qHandle.setCondition('DATA_ID=:dataid',qCondition)
00578         cursor=qHandle.execute()
00579         while cursor.next():
00580             normname=cursor.currentRow()['normname'].data()
00581             amodetag=cursor.currentRow()['amodetag'].data()
00582             norm_1=cursor.currentRow()['norm_1'].data()
00583             energy_1=cursor.currentRow()['energy_1'].data()
00584             norm_occ2=1.0
00585             if cursor.currentRow()['norm_occ2'].data():
00586                 norm_occ2=cursor.currentRow()['norm_occ2'].data()
00587             norm_et=1.0
00588             if cursor.currentRow()['norm_et'].data():
00589                 norm_et=cursor.currentRow()['norm_et'].data()
00590             norm_pu=1.0
00591             if cursor.currentRow()['norm_pu'].data():
00592                 norm_pu=cursor.currentRow()['norm_pu'].data()
00593             constfactor=1.0
00594             if cursor.currentRow()['constfactor'].data():
00595                 constfactor=cursor.currentRow()['constfactor'].data()
00596             result={normname:(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)}
00597     except :
00598         del qHandle
00599         raise
00600     del qHandle
00601     return result
00602 
00603 #def mostRecentLumicorrs(schema,branchfilter):
00604 #    '''
00605 #    this overview query should be only for corr
00606 #    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;
00607 #    output {corrname:(data_id,a1,a2,drift)}
00608 #    '''
00609 #    #print branchfilter
00610 #    result={}
00611 #    entry2datamap={}
00612 #    branchmin=0
00613 #    branchmax=0
00614 #    if branchfilter and len(branchfilter)!=0:
00615 #        branchmin=min(branchfilter)
00616 #        branchmax=max(branchfilter)
00617 #    else:
00618 #        return result
00619 #    qHandle=schema.newQuery()
00620 #    corrdict={}
00621 #    try:
00622 #        qHandle.addToTableList(nameDealer.entryTableName(nameDealer.lumicorrectionsTableName()),'e')
00623 #        qHandle.addToTableList(nameDealer.lumicorrectionsTableName(),'n')
00624 #        qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.lumicorrectionsTableName()),'r')
00625 #        qHandle.addToOutputList('e.NAME','corrname')
00626 #        qHandle.addToOutputList('r.DATA_ID','data_id')
00627 #        qHandle.addToOutputList('r.REVISION_ID','revision_id')
00628 #        qHandle.addToOutputList('n.A1','a1')
00629 #        qHandle.addToOutputList('n.A2','a2')
00630 #        qHandle.addToOutputList('n.DRIFT','drift')
00631 #        qCondition=coral.AttributeList()
00632 #        qCondition.extend('branchmin','unsigned long long')
00633 #        qCondition.extend('branchmax','unsigned long long')
00634 #        qCondition['branchmin'].setData(branchmin)
00635 #        qCondition['branchmax'].setData(branchmax)
00636 #        qResult=coral.AttributeList()
00637 #        qResult.extend('corrname','string')
00638 #        qResult.extend('data_id','unsigned long long')
00639 #        qResult.extend('revision_id','unsigned long long')
00640 #        qResult.extend('a1','float')
00641 #        qResult.extend('a2','float')
00642 #        qResult.extend('drift','float')
00643 #        qHandle.defineOutput(qResult)
00644 #        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)
00645 #        cursor=qHandle.execute()
00646 #        while cursor.next():
00647 #            corrname=cursor.currentRow()['corrname'].data()
00648 #            data_id=cursor.currentRow()['data_id'].data()
00649 #            if not corrdict.has_key(corrname):
00650 #                corrdict[corrname]=0
00651 #            if data_id>corrdict[corrname]:
00652 #                corrdict[corrname]=data_id
00653 #                a1=cursor.currentRow()['a1'].data() #required
00654 #                a2=0.0
00655 #                if not cursor.currentRow()['a2'].isNull():
00656 #                    a2=cursor.currentRow()['a2'].data()
00657 #                drift=0.0
00658 #                if not cursor.currentRow()['drift'].isNull():
00659 #                    drift=cursor.currentRow()['drift'].data()
00660 #                result[corrname]=(data_id,a1,a2,drift)
00661 #    except:
00662 #        raise
00663 #    return result

def dataDML::lumiRunById (   schema,
  lumidataid,
  lumitype = 'HF' 
)
input: lumidataid
output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3),starttimestr(4),stoptimestr(5),nls(6))

Definition at line 951 of file dataDML.py.

00952                                                 :
00953     '''
00954     input: lumidataid
00955     output: (runnum(0),datasource(1),nominalegev(2),ncollidingbunches(3),starttimestr(4),stoptimestr(5),nls(6))
00956     '''
00957     result=None
00958     if lumitype not in ['HF','PIXEL']:
00959         raise ValueError('unknown lumitype '+lumitype)
00960     lumitableName=''
00961     if lumitype=='HF':
00962         lumitableName = nameDealer.lumidataTableName()
00963     else:
00964         lumitableName = nameDealer.pixellumidataTableName()
00965     qHandle=schema.newQuery()
00966     try:
00967         qHandle.addToTableList(lumitableName)
00968         qHandle.addToOutputList('RUNNUM')
00969         qHandle.addToOutputList('SOURCE')
00970         qHandle.addToOutputList('NOMINALEGEV')
00971         qHandle.addToOutputList('NCOLLIDINGBUNCHES')
00972         qHandle.addToOutputList('TO_CHAR('+lumitableName+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','startT')
00973         qHandle.addToOutputList('TO_CHAR('+lumitableName+'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')','stopT')
00974         qHandle.addToOutputList('NLS')
00975         qConditionStr='DATA_ID=:dataid'
00976         qCondition=coral.AttributeList()
00977         qCondition.extend('dataid','unsigned long long')
00978         qCondition['dataid'].setData(lumidataid)
00979         qResult=coral.AttributeList()
00980         qResult.extend('RUNNUM','unsigned int')
00981         qResult.extend('SOURCE','string')
00982         qResult.extend('NOMINALEGEV','float')
00983         qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
00984         qResult.extend('startT','string')
00985         qResult.extend('stopT','string')
00986         qResult.extend('NLS','unsigned int')
00987         qHandle.defineOutput(qResult)
00988         qHandle.setCondition(qConditionStr,qCondition)
00989         cursor=qHandle.execute()
00990         lu=lumiTime.lumiTime()
00991         nls=0
00992         while cursor.next():
00993             runnum=cursor.currentRow()['RUNNUM'].data()
00994             datasource=cursor.currentRow()['SOURCE'].data()
00995             nominalegev=0
00996             if not cursor.currentRow()['NOMINALEGEV'].isNull():
00997                 nominalegev=cursor.currentRow()['NOMINALEGEV'].data()
00998             ncollidingbunches=0
00999             if not cursor.currentRow()['NCOLLIDINGBUNCHES'].isNull():
01000                 ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
01001             startTstr=cursor.currentRow()['startT'].data()
01002             stopTstr=cursor.currentRow()['stopT'].data()
01003             #startT=lu.StrToDatetime(startTstr)
01004             #stopT=lu.StrToDatetime(stopTstr)
01005             if not cursor.currentRow()['NLS'].isNull():
01006                 nls=cursor.currentRow()['NLS'].data()
01007             result=(runnum,datasource,nominalegev,ncollidingbunches,startTstr,stopTstr,nls)
01008     except :
01009         del qHandle
01010         raise
01011     del qHandle
01012     return result
01013 
01014 #def correctionByName(schema,correctiontagname=None):
01015 #    '''
01016 #    get correction coefficients by name
01017 #    input: correctiontagname if None,get current default
01018 #    output: [tagname,a1,a2,drift]
01019 #    if not correctiontagname
01020 #    select entry_name,data_id,a1,a2,drift from lumicorrections where 
01021 #    else:
01022 #    select entry_name,data_id,a1,a2,drift from lumicorrections where entry_name=:correctiontagname
01023 #    '''
01024 
01025     
01026 #def fillschemeByRun(schema,runnum):
01027 #    fillscheme=''
01028 #    ncollidingbunches=0
01029 #    r=nameDealer.cmsrunsummaryTableName()
01030 #    qHandle=schema.newQuery()
01031 #    try:
01032 #        qHandle.addToTableList(r)
01033 #        qHandle.addToOutputList('FILLSCHEME')
01034 #        qHandle.addToOutputList('NCOLLIDINGBUNCHES')
01035 #        qResult=coral.AttributeList()
01036 #        qResult.extend('FILLSCHEME','string')
01037 #        qResult.extend('NCOLLIDINGBUNCHES','unsigned int')
01038 #        qConditionStr='RUNNUM=:runnum'
01039 #        qCondition=coral.AttributeList()
01040 #        qCondition.extend('runnum','unsigned int')
01041 #        qCondition['runnum'].setData(int(runnum))
01042 #        qHandle.defineOutput(qResult)
01043 #        qHandle.setCondition(qConditionStr,qCondition)
01044 #        cursor=qHandle.execute()
01045 #        while cursor.next(): 
01046 #            if not cursor.currentRow()['NCOLLIDINGBUNCHES'].isNull():
01047 #                ncollidingbunches=cursor.currentRow()['NCOLLIDINGBUNCHES'].data()
01048 #            if not cursor.currentRow()['FILLSCHEME'].isNull():
01049 #                fillscheme=cursor.currentRow()['FILLSCHEME'].data()
01050 #    except :
01051 #        del qHandle
01052 #        raise
01053 #    del qHandle
#    return (fillscheme,ncollidingbunches)
def dataDML::lumiRunByIds (   schema,
  dataidMap,
  lumitype = 'HF' 
)
input dataidMap : {run:lumidataid}
result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)}

Definition at line 895 of file dataDML.py.

00896                                                 :
00897     '''
00898     input dataidMap : {run:lumidataid}
00899     result {runnum: (datasource(0),nominalegev(1),ncollidingbunches(2),starttime(3),stoptime(4),nls(5)}
00900     '''
00901     result={}
00902     if not dataidMap:
00903         return result
00904     inputRange=dataidMap.keys()
00905     for r in inputRange:
00906         lumidataid=dataidMap[r][0]
00907         if lumidataid:
00908             perrundata=lumiRunById(schema,lumidataid,lumitype=lumitype)
00909             result[r]=(perrundata[1],perrundata[2],perrundata[3],perrundata[4],perrundata[5])
00910     return result

def dataDML::runList (   schema,
  datatagid,
  runmin = None,
  runmax = None,
  fillmin = None,
  fillmax = None,
  startT = None,
  stopT = None,
  l1keyPattern = None,
  hltkeyPattern = None,
  amodetag = None,
  nominalEnergy = None,
  energyFlut = 0.2,
  requiretrg = True,
  requirehlt = True,
  preselectedruns = None,
  lumitype = None 
)
select r.runnum,l.starttime,l.stoptime,l.data_id,t.data_id,h.data_id from cmsrunsummary r,tagruns tag,lumidata l,trgdata t,hltdata h where l.runnum=tag.runnum and r.runnum=l.runnum and l.runnum=t.runnum and t.runnum=h.runnum and r.fillnum>=:fillmin and r.fillnum<=fillmax and r.runnum>:runmin and r.runnum<:runmax and r.amodetag=:amodetag and regexp_like(r.l1key,:l1keypattern) and regexp_like(hltkey,:hltkeypattern) and l.nominalEnergy>=:nominalEnergy*(1-energyFlut) and l.nominalEnergy<=:nominalEnergy*(1+energyFlut) and tag.tagid<=:tagid and l.starttime is not null and l.stoptime is not null
output: {runnum:[lumiid,trgid,hltid]}

Definition at line 240 of file dataDML.py.

00241                                                                                                                                                                                                                                                               :
00242     '''
00243     select r.runnum,l.starttime,l.stoptime,l.data_id,t.data_id,h.data_id from cmsrunsummary r,tagruns tag,lumidata l,trgdata t,hltdata h where l.runnum=tag.runnum and r.runnum=l.runnum and l.runnum=t.runnum and t.runnum=h.runnum and r.fillnum>=:fillmin and r.fillnum<=fillmax and r.runnum>:runmin and r.runnum<:runmax and r.amodetag=:amodetag and regexp_like(r.l1key,:l1keypattern) and regexp_like(hltkey,:hltkeypattern) and l.nominalEnergy>=:nominalEnergy*(1-energyFlut) and l.nominalEnergy<=:nominalEnergy*(1+energyFlut) and tag.tagid<=:tagid and l.starttime is not null and l.stoptime is not null
00244     output: {runnum:[lumiid,trgid,hltid]}
00245     '''
00246     #print datatagid,runmin,runmax,fillmin,fillmax,preselectedruns
00247     if lumitype not in ['HF','PIXEL']:
00248         raise ValueError('unknown lumitype '+lumitype)
00249     lumitableName=''
00250     tagrunstablename=''
00251     if lumitype=='HF':
00252         lumitableName=nameDealer.lumidataTableName()
00253         tagrunstablename=nameDealer.tagRunsTableName()
00254     elif lumitype == 'PIXEL':
00255         lumitableName = nameDealer.pixellumidataTableName()
00256         tagrunstablename=nameDealer.pixeltagRunsTableName()
00257     else:
00258         assert False, "ERROR Unknown lumitype '%s'" % lumitype
00259     
00260     result={}#{runnum,[[lumiid,trgid,hltid]]}
00261     qHandle=schema.newQuery()
00262     r=nameDealer.cmsrunsummaryTableName()
00263     l=lumitableName
00264     tag=tagrunstablename
00265     t=nameDealer.trgdataTableName()
00266     h=nameDealer.hltdataTableName()
00267     lute=lumiTime.lumiTime()
00268     try:
00269         qHandle.addToTableList(r)
00270         qHandle.addToTableList(l)
00271         qHandle.addToTableList(tag)
00272         qConditionStr=r+'.RUNNUM='+l+'.RUNNUM AND '+tag+'.RUNNUM='+l+'.RUNNUM AND '+tag+'.TAGID<=:tagid'
00273         qCondition=coral.AttributeList()
00274         qCondition.extend('tagid','unsigned long long')
00275         qCondition['tagid'].setData(datatagid)
00276         if requiretrg:
00277             qHandle.addToTableList(t)
00278             qConditionStr+=' and '+l+'.RUNNUM='+t+'.RUNNUM'
00279         if requirehlt:
00280             qHandle.addToTableList(h)
00281             qConditionStr+=' and '+l+'.RUNNUM='+h+'.RUNNUM'
00282         if runmin and runmax :
00283             if runmin==runmax:
00284                 qConditionStr+=' AND '+r+'.RUNNUM=:runmin'
00285                 qCondition.extend('runmin','unsigned int')
00286                 qCondition['runmin'].setData(int(runmin))
00287             elif runmax>runmin:
00288                 qConditionStr+=' AND '+r+'.RUNNUM>=:runmin AND '+r+'.RUNNUM<=:runmax'
00289                 qCondition.extend('runmin','unsigned int')
00290                 qCondition.extend('runmax','unsigned int')
00291                 qCondition['runmin'].setData(int(runmin))
00292                 qCondition['runmax'].setData(int(runmax))
00293             else:
00294                 raise 'runmin > runmax'
00295         elif runmin:
00296             qConditionStr+=' AND '+r+'.RUNNUM>=:runmin'
00297             qCondition.extend('runmin','unsigned int')
00298             qCondition['runmin'].setData(int(runmin))
00299         elif runmax:
00300             qConditionStr+=' AND '+r+'.RUNNUM<=:runmax'
00301             qCondition.extend('runmax','unsigned int')
00302             qCondition['runmax'].setData(int(runmax))
00303         else:
00304             pass
00305         if fillmin and fillmax:
00306             if fillmin==fillmax:
00307                 qConditionStr+=' AND '+r+'.FILLNUM=:fillnum'
00308                 qCondition.extend('fillnum','unsigned int')
00309                 qCondition['fillnum'].setData(int(fillmin))
00310             elif fillmax>fillmin:
00311                 qConditionStr+=' AND '+r+'.FILLNUM>=:fillmin AND '+r+'.FILLNUM<=:fillmax'
00312                 qCondition.extend('fillmin','unsigned int')
00313                 qCondition.extend('fillmax','unsigned int')
00314                 qCondition['fillmin'].setData(int(fillmin))
00315                 qCondition['fillmax'].setData(int(fillmax))
00316             else:
00317                 raise 'fillmin > fillmax'
00318         if amodetag:
00319             qConditionStr+=' AND '+r+'.AMODETAG=:amodetag'
00320             qCondition.extend('amodetag','string')
00321             qCondition['amodetag'].setData(amodetag)
00322         if l1keyPattern:
00323             qConditionStr+=' AND regexp_like('+r+'.L1KEY,:l1keypattern)'
00324             qCondition.extend('l1keypattern','string')
00325             qCondition['l1keypattern'].setData(l1keyPattern)
00326         if hltkeyPattern:
00327             qConditionStr+=' AND regexp_like('+r+'.HLTKEY,:hltkeypattern)'
00328             qCondition.extend('hltkeypattern','string')
00329             qCondition['hltkeypattern'].setData(hltkeyPattern)
00330         if nominalEnergy:
00331             emin=nominalEnergy*(1.0-energyFlut)
00332             emax=nominalEnergy*(1.0+energyFlut)
00333             qConditionStr+=' AND '+l+'.NOMINALEGEV>=:emin and '+l+'.NOMINALEGEV<=:emax'
00334             qCondition.extend('emin','float')
00335             qCondition.extend('emax','float')
00336             qCondition['emin'].setData(emin)
00337             qCondition['emax'].setData(emax)
00338         qResult=coral.AttributeList()
00339         qResult.extend('runnum','unsigned int')
00340         qResult.extend('starttime','string')
00341         qResult.extend('stoptime','string')
00342         qResult.extend('lumiid','unsigned long long')
00343         if requiretrg:
00344             qResult.extend('trgid','unsigned long long')
00345         if requirehlt:
00346             qResult.extend('hltid','unsigned long long')
00347         qHandle.setCondition(qConditionStr,qCondition)
00348         qHandle.addToOutputList(r+'.RUNNUM','runnum')
00349         qHandle.addToOutputList('TO_CHAR('+l+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime')
00350         qHandle.addToOutputList('TO_CHAR('+l+'.STOPTIME,\'MM/DD/YY HH24:MI:SS\')','stoptime')
00351         qHandle.addToOutputList(l+'.DATA_ID','lumiid')
00352         if requiretrg:
00353             qHandle.addToOutputList(t+'.DATA_ID','trgid')
00354         if requirehlt:
00355             qHandle.addToOutputList(h+'.DATA_ID','hltid')
00356         qHandle.defineOutput(qResult)
00357         cursor=qHandle.execute()
00358         lumiid=0
00359         trgid=0
00360         hltid=0
00361         while cursor.next():
00362             runnum=cursor.currentRow()['runnum'].data()
00363             if preselectedruns and runnum not in preselectedruns:
00364                 continue
00365             if cursor.currentRow()['starttime'].isNull():
00366                 continue
00367             if cursor.currentRow()['stoptime'].isNull():
00368                 continue
00369             starttimeStr=cursor.currentRow()['starttime'].data()
00370             stoptimeStr=cursor.currentRow()['stoptime'].data()
00371             runstartTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
00372             runstopTime=lute.StrToDatetime(stoptimeStr,customfm='%m/%d/%y %H:%M:%S')
00373             minTime=datetime(2010,1,1,0,0,0,0)
00374             maxTime=datetime.now()
00375             if startT and stopT:
00376                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00377                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
00378                 if not (runstopTime>=minTime and runstartTime<=maxTime):
00379                     continue
00380             elif startT is not None:
00381                 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S')
00382                 if not (runstopTime>=minTime):
00383                         continue
00384             elif stopT is not None:
00385                 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S')
00386                 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S')
00387                 if not (runTime<=maxTime):
00388                     continue
00389             else:
00390                 pass
00391             if not cursor.currentRow()['lumiid'].isNull():
00392                 lumiid=cursor.currentRow()['lumiid'].data()
00393                 if result.has_key(runnum):
00394                     if lumiid>result[runnum][0]:
00395                         result[runnum][0]=lumiid
00396                 else:
00397                     result[runnum]=[lumiid,0,0]
00398             if requiretrg and not cursor.currentRow()['trgid'].isNull():
00399                 trgid=cursor.currentRow()['trgid'].data()
00400                 if result.has_key(runnum):
00401                     if trgid>result[runnum][1]:
00402                         result[runnum][1]=trgid
00403             if requirehlt and not cursor.currentRow()['hltid'].isNull():
00404                 hltid=cursor.currentRow()['hltid'].data()
00405                 if result.has_key(runnum):
00406                     if hltid>result[runnum][2]:
00407                         result[runnum][2]=hltid
00408     except :
00409         del qHandle
00410         raise
00411     del qHandle
00412     return result

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

Definition at line 413 of file dataDML.py.

Referenced by SiStripFineDelayHit::produce().

00414                                               :
00415     '''
00416     select l1key,amodetag,hltkey,fillnum,fillscheme from cmsrunsummary where runnum=:runnum
00417     output: [l1key(0),amodetag(1),hltkey(3),fillnum(4),fillscheme(5)]
00418     '''
00419     result=[]
00420     qHandle=schema.newQuery()
00421     t=lumiTime.lumiTime()
00422     try:
00423         qHandle.addToTableList(nameDealer.cmsrunsummaryTableName())
00424         qCondition=coral.AttributeList()
00425         qCondition.extend('runnum','unsigned int')
00426         qCondition['runnum'].setData(int(runnum))
00427         qHandle.addToOutputList('L1KEY','l1key')
00428         qHandle.addToOutputList('AMODETAG','amodetag')
00429         #qHandle.addToOutputList('EGEV','egev')
00430         qHandle.addToOutputList('HLTKEY','hltkey')
00431         qHandle.addToOutputList('FILLNUM','fillnum')
00432         qHandle.addToOutputList('FILLSCHEME','fillscheme')
00433         #if sessionflavor=='SQLite':
00434         #    qHandle.addToOutputList('STARTTIME','starttime')
00435         #    qHandle.addToOutputList('STOPTIME','stoptime')
00436         #else:
00437         #    qHandle.addToOutputList('to_char(STARTTIME,\''+t.coraltimefm+'\')','starttime')
00438         #    qHandle.addToOutputList('to_char(STOPTIME,\''+t.coraltimefm+'\')','stoptime')
00439         qHandle.setCondition('RUNNUM=:runnum',qCondition)
00440         qResult=coral.AttributeList()
00441         qResult.extend('l1key','string')
00442         qResult.extend('amodetag','string')
00443         #qResult.extend('egev','unsigned int')
00444         qResult.extend('hltkey','string')
00445         qResult.extend('fillnum','unsigned int')
00446         qResult.extend('fillscheme','string')
00447         #qResult.extend('starttime','string')
00448         #qResult.extend('stoptime','string')
00449         qHandle.defineOutput(qResult)
00450         cursor=qHandle.execute()
00451         while cursor.next():
00452             result.append(cursor.currentRow()['l1key'].data())
00453             result.append(cursor.currentRow()['amodetag'].data())
00454             #result.append(cursor.currentRow()['egev'].data())
00455             result.append(cursor.currentRow()['hltkey'].data())
00456             result.append(cursor.currentRow()['fillnum'].data())
00457             fillscheme=''
00458             if not cursor.currentRow()['fillscheme'].isNull():
00459                 fillscheme=cursor.currentRow()['fillscheme'].data()
00460             result.append(fillscheme)
00461             #result.append(cursor.currentRow()['starttime'].data())
00462             #result.append(cursor.currentRow()['stoptime'].data())
00463     except :
00464         del qHandle
00465         raise
00466     del qHandle
00467     return result
00468 
00469 #def mostRecentLuminorms(schema,branchfilter):
00470 #    '''
00471 #    this overview query should be only for norm
00472 #    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);
00473 #    output {norm_name:(amodetag(0),norm_1(1),egev_1(2),norm_occ2(3),norm_et(4),norm_pu(5),constfactor(6))}
00474 #    '''
00475 #    #print branchfilter
00476 #    result={}
00477 #    entry2datamap={}
00478 #    branchmin=0
00479 #    branchmax=0
00480 #    if branchfilter and len(branchfilter)!=0:
00481 #        branchmin=min(branchfilter)
00482 #        branchmax=max(branchfilter)
00483 #    else:
00484 #        return result
00485 #    #print branchmin,branchmax
00486 #    qHandle=schema.newQuery()
00487 #    normdict={}
00488 #    try:
00489 #        qHandle.addToTableList(nameDealer.entryTableName(nameDealer.luminormTableName()),'e')
00490 #        qHandle.addToTableList(nameDealer.luminormTableName(),'n')
00491 #        qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.luminormTableName()),'r')
00492 #        qHandle.addToOutputList('e.NAME','normname')
00493 #        qHandle.addToOutputList('r.DATA_ID','data_id')
00494 #        qHandle.addToOutputList('r.REVISION_ID','revision_id')
00495 #        qHandle.addToOutputList('n.AMODETAG','amodetag')
00496 #        qHandle.addToOutputList('n.NORM_1','norm_1')
00497 #        qHandle.addToOutputList('n.EGEV_1','energy_1')
00498 #        qHandle.addToOutputList('n.NORM_OCC2','norm_occ2')
00499 #        qHandle.addToOutputList('n.NORM_ET','norm_et')
00500 #        qHandle.addToOutputList('n.NORM_PU','norm_pu')
00501 #        qHandle.addToOutputList('n.CONSTFACTOR','constfactor')
00502 #        qCondition=coral.AttributeList()
00503 #        qCondition.extend('branchmin','unsigned long long')
00504 #        qCondition.extend('branchmax','unsigned long long')
00505 #        qCondition['branchmin'].setData(branchmin)
00506 #        qCondition['branchmax'].setData(branchmax)
00507 #        qResult=coral.AttributeList()
00508 #        qResult.extend('normname','string')
00509 #        qResult.extend('data_id','unsigned long long')
00510 #        qResult.extend('revision_id','unsigned long long')
00511 #        qResult.extend('amodetag','string')
00512 #        qResult.extend('norm_1','float')
00513 #        qResult.extend('energy_1','unsigned int')
00514 #        qResult.extend('norm_occ2','float')
00515 #        qResult.extend('norm_et','float')
00516 #        qResult.extend('norm_pu','float')
00517 #        qResult.extend('constfactor','float')
00518 #        qHandle.defineOutput(qResult)
00519 #        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)
00520 #        cursor=qHandle.execute()
00521 #        while cursor.next():
00522 #            data_id=cursor.currentRow()['data_id'].data()
00523 #            normname=cursor.currentRow()['normname'].data()
00524 #            if not normdict.has_key(normname):
00525 #                normdict[normname]=0
00526 #            if data_id>normdict[normname]:
00527 #                normdict[normname]=data_id
00528 #                amodetag=cursor.currentRow()['amodetag'].data()
00529 #                norm_1=cursor.currentRow()['norm_1'].data()
00530 #                energy_1=cursor.currentRow()['energy_1'].data()
00531 #                norm_occ2=1.0
00532 #                if not cursor.currentRow()['norm_occ2'].isNull():
00533 #                    norm_occ2=cursor.currentRow()['norm_occ2'].data()
00534 #                norm_et=1.0
00535 #                if not cursor.currentRow()['norm_et'].isNull():
00536 #                    norm_et=cursor.currentRow()['norm_et'].data()
00537 #                norm_pu=1.0
00538 #                if not cursor.currentRow()['norm_pu'].isNull():
00539 #                    norm_pu=cursor.currentRow()['norm_pu'].data()
00540 #                constfactor=1.0
00541 #                if not cursor.currentRow()['constfactor'].isNull():
00542 #                    constfactor=cursor.currentRow()['constfactor'].data()
00543 #                result[normname]=(amodetag,norm_1,energy_1,norm_occ2,norm_et,norm_pu,constfactor)
00544 #    except:
00545 #        raise
#    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,mask)](4)]})

Definition at line 788 of file dataDML.py.

00789                                                                                                         :
00790     '''
00791     output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale,mask)](4)]})
00792     '''
00793     runnum=0
00794     result={}
00795     trgnamedict=[]
00796     if  trgbitname or trgbitnamepattern or withPrescale or withL1Count:
00797         trgrundata=trgRunById(schema,dataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern)
00798         trgnamedict=trgrundata[3]#[runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)]
00799         algomask_h=trgrundata[4]
00800         algomask_l=trgrundata[5]
00801         techmask=trgrundata[6]
00802     qHandle=schema.newQuery()
00803     try:
00804         qHandle.addToTableList(nameDealer.lstrgTableName())
00805         qHandle.addToOutputList('RUNNUM','runnum')
00806         qHandle.addToOutputList('CMSLSNUM','cmslsnum')
00807         qHandle.addToOutputList('DEADTIMECOUNT','deadtimecount')
00808         #qHandle.addToOutputList('BITZEROCOUNT','bitzerocount')
00809         #qHandle.addToOutputList('BITZEROPRESCALE','bitzeroprescale')
00810         qHandle.addToOutputList('DEADFRAC','deadfrac')
00811         if withPrescale:
00812             qHandle.addToOutputList('PRESCALEBLOB','prescalesblob')
00813         if withL1Count:
00814             qHandle.addToOutputList('TRGCOUNTBLOB','trgcountblob')
00815         qConditionStr='DATA_ID=:dataid'
00816         qCondition=coral.AttributeList()
00817         qCondition.extend('dataid','unsigned long long')
00818         qCondition['dataid'].setData(dataid)
00819         qResult=coral.AttributeList()
00820         qResult.extend('runnum','unsigned int')
00821         qResult.extend('cmslsnum','unsigned int')
00822         qResult.extend('deadtimecount','unsigned long long')
00823         #qResult.extend('bitzerocount','unsigned int')
00824         #qResult.extend('bitzeroprescale','unsigned int')
00825         qResult.extend('deadfrac','float')
00826         if withPrescale:
00827             qResult.extend('prescalesblob','blob')
00828         if withL1Count:
00829             qResult.extend('trgcountblob','blob')
00830         qHandle.defineOutput(qResult)
00831         qHandle.setCondition(qConditionStr,qCondition)
00832         cursor=qHandle.execute()
00833         while cursor.next():
00834             runnum=cursor.currentRow()['runnum'].data()
00835             cmslsnum=cursor.currentRow()['cmslsnum'].data()
00836             deadtimecount=cursor.currentRow()['deadtimecount'].data()
00837             #bitzerocount=cursor.currentRow()['bitzerocount'].data()
00838             #bitzeroprescale=cursor.currentRow()['bitzeroprescale'].data()
00839             bitzerocount=0
00840             bitzeroprescale=0
00841             deadfrac=cursor.currentRow()['deadfrac'].data()
00842             if not result.has_key(cmslsnum):
00843                 result[cmslsnum]=[]
00844             result[cmslsnum].append(deadtimecount)
00845             result[cmslsnum].append(bitzerocount)
00846             result[cmslsnum].append(bitzeroprescale)
00847             result[cmslsnum].append(deadfrac)
00848             prescalesblob=None
00849             trgcountblob=None
00850             if withPrescale:
00851                 prescalesblob=cursor.currentRow()['prescalesblob'].data()
00852             if withL1Count:
00853                 trgcountblob=cursor.currentRow()['trgcountblob'].data()
00854             prescales=[]
00855             trgcounts=[]
00856             if prescalesblob:
00857                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
00858                     prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'l')
00859                 else:
00860                     prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'I')
00861             if trgcountblob:
00862                 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ###
00863                     trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'l')
00864                 else:
00865                     trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'I')
00866                     
00867             bitinfo=[]
00868             for (bitidx,thisbitname) in trgnamedict:
00869                 thispresc=None
00870                 thistrgcount=None
00871                 if prescales:
00872                     thispresc=prescales[bitidx]
00873                 if trgcounts:
00874                     thistrgcount=trgcounts[bitidx]
00875                 maskval=0
00876                 #[0-127] is algobit
00877                 if bitidx in range(0,128):
00878                     if bitidx<64 :#0-63 is in algo_l
00879                         maskval=algomask_l>>bitidx&1
00880                     else:#64-127 is in algo_h
00881                         maskval=algomask_h>>(bitidx-64)&1
00882                 else:
00883                 #[128-191] is techbit
00884                     maskval=techmask>>(bitidx-128)&1
00885                 thisbitinfo=(thisbitname,thistrgcount,thispresc,maskval)
00886                 bitinfo.append(thisbitinfo)
00887             result[cmslsnum].append(bitinfo)
00888     except:
00889         del qHandle
00890         raise 
00891     del qHandle
00892 #    t1=time.time()
00893 #    print 'trgLSById time ',t1-t0
00894     return (runnum,result)

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

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

Definition at line 720 of file dataDML.py.

00721                                                                     :
00722     '''
00723     query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB,ALGOMASK_H,ALGOMASK_L,TECHMASK from trgdata where DATA_ID=:dataid
00724     
00725     output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3),algomask_h(4),algomask_l(5),techmask(6)]
00726              -- runnumber
00727              -- original source database name
00728              -- deadtime norm bitname
00729              -- bitnamedict [(bitidx,bitname),...]
00730     '''
00731     result=[]
00732     qHandle=schema.newQuery()
00733     runnum=None
00734     datasource=None
00735     bitzeroname=None
00736     bitnamedict=[]
00737     try:
00738         qHandle.addToTableList(nameDealer.trgdataTableName())
00739         qHandle.addToOutputList('RUNNUM','runnum')
00740         qHandle.addToOutputList('SOURCE','source')
00741         qHandle.addToOutputList('BITZERONAME','bitzeroname')
00742         qHandle.addToOutputList('BITNAMECLOB','bitnameclob')
00743         qHandle.addToOutputList('ALGOMASK_H','algomask_h')
00744         qHandle.addToOutputList('ALGOMASK_L','algomask_l')
00745         qHandle.addToOutputList('TECHMASK','techmask')
00746         qCondition=coral.AttributeList()
00747         qCondition.extend('dataid','unsigned long long')
00748         qCondition['dataid'].setData(dataid)
00749         qResult=coral.AttributeList()
00750         qResult.extend('runnum','unsigned int')
00751         qResult.extend('source','string')
00752         qResult.extend('bitzeroname','string')
00753         qResult.extend('bitnameclob','string')
00754         qResult.extend('algomask_h','unsigned long long')
00755         qResult.extend('algomask_l','unsigned long long')
00756         qResult.extend('techmask','unsigned long long')
00757         qHandle.defineOutput(qResult)
00758         qHandle.setCondition('DATA_ID=:dataid',qCondition)        
00759         cursor=qHandle.execute()
00760         bitnameclob=None
00761         bitnames=[]
00762         while cursor.next():
00763             runnum=cursor.currentRow()['runnum'].data()
00764             source=cursor.currentRow()['source'].data()
00765             bitzeroname=cursor.currentRow()['bitzeroname'].data()
00766             bitnameclob=cursor.currentRow()['bitnameclob'].data()
00767             algomask_h=cursor.currentRow()['algomask_h'].data()
00768             algomask_l=cursor.currentRow()['algomask_l'].data()
00769             techmask=cursor.currentRow()['techmask'].data()
00770         if bitnameclob:
00771             bitnames=bitnameclob.split(',')
00772             for trgnameidx,trgname in enumerate(bitnames):
00773                 if trgbitname :
00774                     if trgname==trgbitname:
00775                         bitnamedict.append((trgnameidx,trgname))
00776                         break
00777                 elif trgbitnamepattern:
00778                     if fnmatch.fnmatch(trgname,trgbitnamepattern):
00779                         bitnamedict.append((trgnameidx,trgname))
00780                 else:
00781                     bitnamedict.append((trgnameidx,trgname))
00782         result=[runnum,source,bitzeroname,bitnamedict,algomask_h,algomask_l,techmask]
00783     except :
00784         del qHandle
00785         raise 
00786     del qHandle
00787     return result


Variable Documentation

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

Definition at line 2346 of file dataDML.py.

Referenced by TrackerMap::TrackerMap().

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

Definition at line 2334 of file dataDML.py.

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

Definition at line 2362 of file dataDML.py.

Definition at line 2364 of file dataDML.py.

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

Definition at line 2350 of file dataDML.py.

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

Definition at line 2373 of file dataDML.py.

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

Definition at line 2381 of file dataDML.py.

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

Definition at line 2352 of file dataDML.py.

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

Definition at line 2380 of file dataDML.py.

Definition at line 2354 of file dataDML.py.

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

Definition at line 2372 of file dataDML.py.

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

Definition at line 2322 of file dataDML.py.

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

Definition at line 2342 of file dataDML.py.

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

Definition at line 2336 of file dataDML.py.

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

Definition at line 2371 of file dataDML.py.

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

Definition at line 2378 of file dataDML.py.

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

Definition at line 2348 of file dataDML.py.

tuple dataDML::schema = session.nominalSchema()

Definition at line 2325 of file dataDML.py.

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

Definition at line 2324 of file dataDML.py.

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

Definition at line 2323 of file dataDML.py.

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

Definition at line 2357 of file dataDML.py.

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

Definition at line 2386 of file dataDML.py.

Definition at line 2359 of file dataDML.py.

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

Definition at line 2332 of file dataDML.py.