Functions | |
def | addHLTRunDataToBranch |
def | addLumiRunDataToBranch |
def | addNormToBranch |
def | addTrgRunDataToBranch |
def | beamInfoById |
def | bulkInsertHltLSData |
def | bulkInsertLumiLSSummary |
def | bulkInsertTrgLSData |
def | dataentryIdByRun |
def | fillInRange |
def | fillrunMap |
def | guessHltDataIdByRun |
def | guessHltDataIdByRunInBranch |
def | guessLumiDataIdByRun |
def | guessLumiDataIdByRunInBranch |
def | guessnormIdByContext |
def | guessnormIdByName |
def | guessTrgDataIdByRun |
def | guessTrgDataIdByRunInBranch |
def | hltLSById |
def | hltRunById |
def | hlttrgMappingByrun |
def | insertRunSummaryData |
def | insertTrgHltMap |
def | latestdataIdByEntry |
def | lumiBXByAlgo |
def | lumiLSById |
def | luminormById |
def | lumiRunById |
def | mostRecentLuminorms |
def | runList |
def | runsummary |
def | trgLSById |
def | trgRunById |
Variables | |
tuple | branchinfo = (branchid,'DATA') |
tuple | datainfo = revisionDML.createBranch(schema,'DATA','TRUNK',comment='hold data') |
tuple | hltdata = generateDummyData.hlt(schema,20) |
list | hltlsdata = hltdata[2] |
list | hltrundata = [hltdata[0],hltdata[1]] |
tuple | hlttrgmap = generateDummyData.hlttrgmap(schema) |
tuple | latestNorms = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.luminormTableName(),luminormentry_id,normrevlist) |
tuple | latestrevision = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist) |
tuple | lumidummydata = generateDummyData.lumiSummary(schema,20) |
tuple | lumientry_id = revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA') |
list | lumilsdata = lumidummydata[1] |
tuple | luminormentry_id = revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),'pp7TeV','NORM') |
list | lumirundata = [lumidummydata[0]] |
string | myconstr = 'oracle://devdb10/cms_xiezhen_dev' |
tuple | normbranchinfo = (normbranchid,'NORM') |
tuple | norminfo = revisionDML.createBranch(schema,'NORM','TRUNK',comment='hold normalization factor') |
tuple | normrevlist = revisionDML.revisionsInBranchName(schema,'NORM') |
tuple | revlist = revisionDML.revisionsInBranchName(schema,'DATA') |
tuple | runsummarydata = generateDummyData.runsummary(schema,'PROTPHYS',3500) |
tuple | schema = session.nominalSchema() |
tuple | session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')]) |
tuple | svc = sessionManager.sessionManager(myconstr,authpath='/afs/cern.ch/user/x/xiezhen',debugON=False) |
tuple | tables = lumidbDDL.createTables(schema) |
tuple | trgdata = generateDummyData.trg(schema,20) |
tuple | trgentry_id = revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),'1222','DATA') |
list | trglsdata = trgdata[3] |
list | trgrundata = [trgdata[0],trgdata[1],trgdata[2]] |
tuple | trunkinfo = revisionDML.createBranch(schema,'TRUNK',None,comment='main') |
def dataDML::addHLTRunDataToBranch | ( | schema, | |
runnumber, | |||
hltrundata, | |||
branchinfo | |||
) |
input: hltrundata [pathnameclob(0),datasource(1)] output: (revision_id,entry_id,data_id)
Definition at line 1438 of file dataDML.py.
01439 : 01440 ''' 01441 input: 01442 hltrundata [pathnameclob(0),datasource(1)] 01443 output: 01444 (revision_id,entry_id,data_id) 01445 ''' 01446 try: 01447 pathnames=hltrundata[0] 01448 datasource=hltrundata[1] 01449 npath=len(pathnames.split(',')) 01450 entry_id=revisionDML.entryInBranch(schema,nameDealer.hltdataTableName(),str(runnumber),branchinfo[1]) 01451 if entry_id is None: 01452 (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.hltdataTableName()) 01453 entryinfo=(revision_id,entry_id,str(runnumber),data_id) 01454 revisionDML.addEntry(schema,nameDealer.hltdataTableName(),entryinfo,branchinfo) 01455 else: 01456 (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.hltdataTableName() ) 01457 revisionDML.addRevision(schema,nameDealer.hltdataTableName(),(revision_id,data_id),branchinfo) 01458 tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NPATH':'unsigned int','PATHNAMECLOB':'string'} 01459 tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NPATH':npath,'PATHNAMECLOB':pathnames} 01460 db=dbUtil.dbUtil(schema) 01461 db.insertOneRow(nameDealer.hltdataTableName(),tabrowDefDict,tabrowValueDict) 01462 return (revision_id,entry_id,data_id) 01463 except : 01464 raise
def dataDML::addLumiRunDataToBranch | ( | schema, | |
runnumber, | |||
lumirundata, | |||
branchinfo, | |||
tableName | |||
) |
input: lumirundata [datasource,nominalenergy] branchinfo (branch_id,branch_name) tableName lumiruntablename output: (revision_id,entry_id,data_id)
Definition at line 1379 of file dataDML.py.
01380 : 01381 ''' 01382 input: 01383 lumirundata [datasource,nominalenergy] 01384 branchinfo (branch_id,branch_name) 01385 tableName lumiruntablename 01386 output: 01387 (revision_id,entry_id,data_id) 01388 ''' 01389 try: 01390 datasource=lumirundata[0] 01391 nominalegev=3500.0 01392 if len(lumirundata)>1: 01393 nominalenergy=lumirundata[1] 01394 entry_id=revisionDML.entryInBranch(schema,tableName,str(runnumber),branchinfo[1]) 01395 print 'entry_id ',entry_id 01396 if entry_id is None: 01397 (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,tableName) 01398 entryinfo=(revision_id,entry_id,str(runnumber),data_id) 01399 revisionDML.addEntry(schema,tableName,entryinfo,branchinfo) 01400 else: 01401 (revision_id,data_id)=revisionDML.bookNewRevision(schema,tableName) 01402 print 'revision_id,data_id ',revision_id,data_id 01403 revisionDML.addRevision(schema,tableName,(revision_id,data_id),branchinfo) 01404 tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','RUNNUM':'unsigned int','SOURCE':'string','NOMINALEGEV':'float'} 01405 tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'RUNNUM':int(runnumber),'SOURCE':datasource,'NOMINALEGEV':nominalegev} 01406 db=dbUtil.dbUtil(schema) 01407 db.insertOneRow(tableName,tabrowDefDict,tabrowValueDict) 01408 return (revision_id,entry_id,data_id) 01409 except : 01410 raise
def dataDML::addNormToBranch | ( | schema, | |
normname, | |||
amodetag, | |||
norm1, | |||
egev1, | |||
optionalnormdata, | |||
branchinfo | |||
) |
input: branchinfo(normrevisionid,branchname) optionalnormdata {'norm2':norm2,'egev2':egev2} output: (revision_id,entry_id,data_id)
Definition at line 1347 of file dataDML.py.
01348 : 01349 ''' 01350 input: 01351 branchinfo(normrevisionid,branchname) 01352 optionalnormdata {'norm2':norm2,'egev2':egev2} 01353 output: 01354 (revision_id,entry_id,data_id) 01355 ''' 01356 #print 'branchinfo ',branchinfo 01357 norm2=None 01358 if optionalnormdata.has_key('norm2'): 01359 norm2=optionalnormdata['norm2'] 01360 egev2=None 01361 if optionalnormdata.has_key('egev2'): 01362 egev2=optionalnormdata['egev2'] 01363 try: 01364 entry_id=revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),normname,branchinfo[1]) 01365 if entry_id is None: 01366 (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.luminormTableName()) 01367 entryinfo=(revision_id,entry_id,normname,data_id) 01368 revisionDML.addEntry(schema,nameDealer.luminormTableName(),entryinfo,branchinfo) 01369 else: 01370 (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.luminormTableName() ) 01371 revisionDML.addRevision(schema,nameDealer.luminormTableName(),(revision_id,data_id),branchinfo) 01372 tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','AMODETAG':'string','NORM_1':'float','EGEV_1':'unsigned int','NORM_2':'float','EGEV_2':'unsigned int'} 01373 tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':normname,'AMODETAG':amodetag,'NORM_1':norm1,'EGEV_1':egev1,'NORM_2':norm2,'EGEV_2':egev2} 01374 db=dbUtil.dbUtil(schema) 01375 db.insertOneRow(nameDealer.luminormTableName(),tabrowDefDict,tabrowValueDict) 01376 return (revision_id,entry_id,data_id) 01377 except : 01378 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 1411 of file dataDML.py.
01412 : 01413 ''' 01414 input: 01415 trgrundata [datasource(0),bitzeroname(1),bitnameclob(2)] 01416 bitnames clob, bitnames separated by ',' 01417 output: 01418 (revision_id,entry_id,data_id) 01419 ''' 01420 try: #fixme: need to consider revision only case 01421 datasource=trgrundata[0] 01422 bitzeroname=trgrundata[1] 01423 bitnames=trgrundata[2] 01424 entry_id=revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),str(runnumber),branchinfo[1]) 01425 if entry_id is None: 01426 (revision_id,entry_id,data_id)=revisionDML.bookNewEntry(schema,nameDealer.trgdataTableName()) 01427 entryinfo=(revision_id,entry_id,str(runnumber),data_id) 01428 revisionDML.addEntry(schema,nameDealer.trgdataTableName(),entryinfo,branchinfo) 01429 else: 01430 (revision_id,data_id)=revisionDML.bookNewRevision( schema,nameDealer.trgdataTableName() ) 01431 revisionDML.addRevision(schema,nameDealer.trgdataTableName(),(revision_id,data_id),branchinfo) 01432 tabrowDefDict={'DATA_ID':'unsigned long long','ENTRY_ID':'unsigned long long','ENTRY_NAME':'string','SOURCE':'string','RUNNUM':'unsigned int','BITZERONAME':'string','BITNAMECLOB':'string'} 01433 tabrowValueDict={'DATA_ID':data_id,'ENTRY_ID':entry_id,'ENTRY_NAME':str(runnumber),'SOURCE':datasource,'RUNNUM':int(runnumber),'BITZERONAME':bitzeroname,'BITNAMECLOB':bitnames} 01434 db=dbUtil.dbUtil(schema) 01435 db.insertOneRow(nameDealer.trgdataTableName(),tabrowDefDict,tabrowValueDict) 01436 return (revision_id,entry_id,data_id) 01437 except : raise
def dataDML::beamInfoById | ( | schema, | |
dataid, | |||
withBeamIntensity = False , |
|||
minIntensity = 0.1 |
|||
) |
result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),beaminfolist(4),..]) beaminfolist=[(bxidx,beam1intensity,beam2intensity)]
Definition at line 717 of file dataDML.py.
00718 : 00719 ''' 00720 result (runnum,[(lumilsnum(0),cmslsnum(1),beamstatus(2),beamenergy(3),beaminfolist(4),..]) 00721 beaminfolist=[(bxidx,beam1intensity,beam2intensity)] 00722 ''' 00723 runnum=0 00724 result=[] 00725 qHandle=schema.newQuery() 00726 try: 00727 qHandle.addToTableList(nameDealer.lumisummaryv2TableName()) 00728 qHandle.addToOutputList('RUNNUM','runnum') 00729 qHandle.addToOutputList('CMSLSNUM','cmslsnum') 00730 qHandle.addToOutputList('LUMILSNUM','lumilsnum') 00731 qHandle.addToOutputList('BEAMSTATUS','beamstatus') 00732 qHandle.addToOutputList('BEAMENERGY','beamenergy') 00733 if withBeamIntensity: 00734 qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob') 00735 qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity') 00736 qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity') 00737 qConditionStr='DATA_ID=:dataid' 00738 qCondition=coral.AttributeList() 00739 qCondition.extend('dataid','unsigned long long') 00740 qCondition['dataid'].setData(dataid) 00741 qResult=coral.AttributeList() 00742 qResult.extend('runnum','unsigned int') 00743 qResult.extend('cmslsnum','unsigned int') 00744 qResult.extend('lumilsnum','unsigned int') 00745 qResult.extend('beamstatus','string') 00746 qResult.extend('beamenergy','float') 00747 if withBeamIntensity: 00748 qResult.extend('bxindexblob','blob') 00749 qResult.extend('beam1intensity','blob') 00750 qResult.extend('beam2intensity','blob') 00751 qHandle.defineOutput(qResult) 00752 qHandle.setCondition(qConditionStr,qCondition) 00753 cursor=qHandle.execute() 00754 while cursor.next(): 00755 runnum=cursor.currentRow()['runnum'].data() 00756 cmslsnum=cursor.currentRow()['cmslsnum'].data() 00757 lumilsnum=cursor.currentRow()['lumilsnum'].data() 00758 beamstatus=cursor.currentRow()['beamstatus'].data() 00759 beamenergy=cursor.currentRow()['beamenergy'].data() 00760 bxindexblob=None 00761 beaminfotupleList=[] 00762 if withBeamIntensity: 00763 bxindexblob=cursor.currentRow()['bxindexblob'].data() 00764 beam1intensityblob=cursor.currentRow()['beam1intensity'].data() 00765 beam2intensityblob=cursor.currentRow()['beam2intensity'].data() 00766 bxindexArray=None 00767 beam1intensityArray=None 00768 beam2intensityArray=None 00769 if bxindexblob: 00770 bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h') 00771 if beam1intensityblob: 00772 beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensityblob,'f') 00773 if beam2intensityblob: 00774 beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensityblob,'f') 00775 if bxindexArray and beam1intensityArray and beam2intensityArray: 00776 for idx,bxindex in enumerate(bxindexArray): 00777 if beam1intensityArray[idx] and beam1intensityArray[idx]>minIntensity and beam2intensityArray[idx] and beam2intensityArray[idx]>minIntensity: 00778 beaminfotuple=(bxindex,beam1intensityArray[idx],beam2intensityArray[idx]) 00779 beaminfotupleList.append(beaminfotuple) 00780 del bxindexArray[:] 00781 del beam1intensityArray[:] 00782 del beam2intensityArray[:] 00783 result.append((lumilsnum,cmslsnum,beamstatus,beamenergy,beaminfotupleList)) 00784 except : 00785 del qHandle 00786 raise 00787 del qHandle return (runnum,result)
def dataDML::bulkInsertHltLSData | ( | session, | |
runnumber, | |||
data_id, | |||
hltlsdata, | |||
bulksize = 500 |
|||
) |
input: hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]}
Definition at line 1577 of file dataDML.py.
01578 : 01579 ''' 01580 input: 01581 hltlsdata {cmslsnum:[inputcountBlob,acceptcountBlob,prescaleBlob]} 01582 ''' 01583 print 'total number of hlt rows ',len(hltlsdata) 01584 lshltDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('CMSLSNUM','unsigned int'),('PRESCALEBLOB','blob'),('HLTCOUNTBLOB','blob'),('HLTACCEPTBLOB','blob')] 01585 committedrows=0 01586 nrows=0 01587 bulkvalues=[] 01588 try: 01589 for cmslsnum,perlshlt in hltlsdata.items(): 01590 inputcountblob=perlshlt[0] 01591 acceptcountblob=perlshlt[1] 01592 prescaleblob=perlshlt[2] 01593 bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('PRESCALEBLOB',prescaleblob),('HLTCOUNTBLOB',inputcountblob),('HLTACCEPTBLOB',acceptcountblob)]) 01594 01595 nrows+=1 01596 committedrows+=1 01597 if nrows==bulksize: 01598 print 'committing hlt in LS chunck ',nrows 01599 db=dbUtil.dbUtil(session.nominalSchema()) 01600 session.transaction().start(False) 01601 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues) 01602 session.transaction().commit() 01603 nrows=0 01604 bulkvalues=[] 01605 elif committedrows==len(hltlsdata): 01606 print 'committing hlt at the end ' 01607 db=dbUtil.dbUtil(session.nominalSchema()) 01608 session.transaction().start(False) 01609 db.bulkInsert(nameDealer.lshltTableName(),lshltDefDict,bulkvalues) 01610 session.transaction().commit() 01611 except : 01612 print 'error in bulkInsertHltLSData' 01613 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 1614 of file dataDML.py.
01615 : 01616 ''' 01617 input: 01618 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]} 01619 ''' 01620 lslumiDefDict=[] 01621 if withDetails: 01622 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')] 01623 else: 01624 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')] 01625 print 'total number of lumi rows ',len(lumilsdata) 01626 try: 01627 committedrows=0 01628 nrows=0 01629 bulkvalues=[] 01630 for lumilsnum,perlslumi in lumilsdata.items(): 01631 cmslsnum=perlslumi[0] 01632 instlumi=perlslumi[1] 01633 instlumierror=perlslumi[2] 01634 instlumiquality=perlslumi[3] 01635 beamstatus=perlslumi[4] 01636 beamenergy=perlslumi[5] 01637 numorbit=perlslumi[6] 01638 startorbit=perlslumi[7] 01639 if withDetails: 01640 cmsbxindexindexblob=perlslumi[8] 01641 beam1intensity=perlslumi[9] 01642 beam2intensity=perlslumi[10] 01643 bxlumivalue_occ1=perlslumi[11] 01644 bxlumierror_occ1=perlslumi[12] 01645 bxlumiquality_occ1=perlslumi[13] 01646 bxlumivalue_occ2=perlslumi[14] 01647 bxlumierror_occ2=perlslumi[15] 01648 bxlumiquality_occ2=perlslumi[16] 01649 bxlumivalue_et=perlslumi[17] 01650 bxlumierror_et=perlslumi[18] 01651 bxlumiquality_et=perlslumi[19] 01652 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)]) 01653 else: 01654 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)]) 01655 nrows+=1 01656 committedrows+=1 01657 if nrows==bulksize: 01658 print 'committing lumi in LS chunck ',nrows 01659 db=dbUtil.dbUtil(session.nominalSchema()) 01660 session.transaction().start(False) 01661 db.bulkInsert(tableName,lslumiDefDict,bulkvalues) 01662 session.transaction().commit() 01663 nrows=0 01664 bulkvalues=[] 01665 elif committedrows==len(lumilsdata): 01666 print 'committing lumi at the end ' 01667 db=dbUtil.dbUtil(session.nominalSchema()) 01668 session.transaction().start(False) 01669 db.bulkInsert(tableName,lslumiDefDict,bulkvalues) 01670 session.transaction().commit() 01671 except : 01672 raise 01673 01674 #def insertLumiLSDetail(schema,runnumber,data_id,lumibxdata): 01675 # ''' 01676 # input: 01677 # lumibxdata [(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]}),(algoname,{lumilsnum:[cmslsnum,bxlumivalue,bxlumierror,bxlumiquality]})] 01678 # output: 01679 # nrows 01680 # ''' 01681 # try: 01682 # nrow=0 01683 # bulkvalues=[] 01684 # lslumiDefDict=[('DATA_ID','unsigned long long'),('RUNNUM','unsigned int'),('LUMILSNUM','unsigned int'),('CMSLSNUM','unsigned int'),('ALGONAME','string'),('BXLUMIVALUE','blob'),('BXLUMIERROR','blob'),('BXLUMIQUALITY','blob')] 01685 # for (algoname,peralgobxdata) in lumibxdata: 01686 # for lumilsnum,bxdata in peralgobxdata.items(): 01687 # cmslsnum=bxdata[0] 01688 # bxlumivalue=bxdata[1] 01689 # bxlumierror=bxdata[2] 01690 # bxlumiquality=bxdata[3] 01691 # bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('LUMILSNUM',lumilsnum),('CMSLSNUM',cmslsnum),('ALGONAME',algoname),('BXLUMIVALUE',bxlumivalue),('BXLUMIERROR',bxlumierror),('BXLUMIQUALITY',bxlumiquality)]) 01692 # db=dbUtil.dbUtil(schema) 01693 # db.bulkInsert(nameDealer.lumidetailTableName(),lslumiDefDict,bulkvalues) 01694 # return len(bulkvalues) 01695 # except: 01696 # raise 01697 01698 #def completeOldLumiData(schema,runnumber,lsdata,data_id): 01699 # ''' 01700 # input: 01701 # lsdata [[lumisummary_id,lumilsnum,cmslsnum]] 01702 # ''' 01703 # try: 01704 # #update in lumisummary table 01705 # #print 'insert in lumisummary table' 01706 # setClause='DATA_ID=:data_id' 01707 # updateCondition='RUNNUM=:runnum AND DATA_ID is NULL' 01708 # updateData=coral.AttributeList() 01709 # updateData.extend('data_id','unsigned long long') 01710 # updateData.extend('runnum','unsigned int') 01711 # updateData['data_id'].setData(data_id) 01712 # updateData['runnum'].setData(int(runnumber)) 01713 # db=dbUtil.dbUtil(schema) 01714 # db.singleUpdate(nameDealer.lumisummaryTableName(),setClause,updateCondition,updateData) 01715 # #updates in lumidetail table 01716 # updateAction='DATA_ID=:data_id,RUNNUM=:runnum,CMSLSNUM=:cmslsnum,LUMILSNUM=:lumilsnum' 01717 # updateCondition='LUMISUMMARY_ID=:lumisummary_id' 01718 # bindvarDef=[] 01719 # bindvarDef.append(('data_id','unsigned long long')) 01720 # bindvarDef.append(('runnum','unsigned int')) 01721 # bindvarDef.append(('cmslsnum','unsigned int')) 01722 # bindvarDef.append(('lumilsnum','unsigned int')) 01723 # inputData=[] 01724 # for [lumisummary_id,lumilsnum,cmslsnum] in lsdata: 01725 # inputData.append([('data_id',data_id),('runnum',int(runnumber)),('cmslsnum',cmslsnum),('lumilsnum',lumilsnum)]) 01726 # db.updateRows(nameDealer.lumidetailTableName(),updateAction,updateCondition,bindvarDef,inputData) 01727 # except: 01728 # raise 01729 01730 #======================================================= 01731 # DELETE 01732 #======================================================= 01733 01734 01735 #======================================================= 01736 # 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 1537 of file dataDML.py.
01538 : 01539 ''' 01540 insert trg per-LS data for given run and data_id, this operation can be split in transaction chuncks 01541 input: 01542 trglsdata {cmslsnum:[deadtime,bitzerocount,bitzeroprescale,trgcountBlob,trgprescaleBlob]} 01543 result nrows inserted 01544 if nrows==0, then this insertion failed 01545 ''' 01546 print 'total number of trg rows ',len(trglsdata) 01547 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')] 01548 committedrows=0 01549 nrows=0 01550 bulkvalues=[] 01551 try: 01552 for cmslsnum,perlstrg in trglsdata.items(): 01553 deadtimecount=perlstrg[0] 01554 bitzerocount=perlstrg[1] 01555 bitzeroprescale=perlstrg[2] 01556 trgcountblob=perlstrg[3] 01557 trgprescaleblob=perlstrg[4] 01558 bulkvalues.append([('DATA_ID',data_id),('RUNNUM',runnumber),('CMSLSNUM',cmslsnum),('DEADTIMECOUNT',deadtimecount),('BITZEROCOUNT',bitzerocount),('BITZEROPRESCALE',bitzeroprescale),('PRESCALEBLOB',trgprescaleblob),('TRGCOUNTBLOB',trgcountblob)]) 01559 nrows+=1 01560 committedrows+=1 01561 if nrows==bulksize: 01562 print 'committing trg in LS chunck ',nrows 01563 db=dbUtil.dbUtil(session.nominalSchema()) 01564 session.transaction().start(False) 01565 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues) 01566 session.transaction().commit() 01567 nrows=0 01568 bulkvalues=[] 01569 elif committedrows==len(trglsdata): 01570 print 'committing trg at the end ' 01571 db=dbUtil.dbUtil(session.nominalSchema()) 01572 session.transaction().start(False) 01573 db.bulkInsert(nameDealer.lstrgTableName(),lstrgDefDict,bulkvalues) 01574 session.transaction().commit() 01575 except : 01576 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 1261 of file dataDML.py.
01262 : 01263 ''' 01264 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; 01265 check on entryrev 01266 01267 return [lumientryid,trgentryid,hltentryid] 01268 ''' 01269 result=[] 01270 qHandle=schema.newQuery() 01271 try: 01272 qHandle.addToTableList(nameDealer.entryTableName( lumidataTableName() )) 01273 qHandle.addToTableList(nameDealer.entryTableName( trgdataTableName() )) 01274 qHandle.addToTableList(nameDealer.entryTableName( hltdataTableName() )) 01275 qHandle.addToOutputList(lumidataTableName()+'.ENTRY_ID','lumientryid') 01276 qHandle.addToOutputList(trgdataTableName()+'.ENTRY_ID','trgentryid') 01277 qHandle.addToOutputList(hltdataTableName()+'.ENTRY_ID','hltentryid') 01278 qConditionStr=lumidataTableName()+'.NAME='+trgdataTableName()+'.NAME AND '+trgdataTableName()+'.NAME='+hltdataTableName()+'.NAME AND '+lumidataTableName()+'.NAME=:runnumstr' 01279 qCondition=coral.AttributeList() 01280 qCondition.extend('runnumstr','string') 01281 qCondition['runnumstr'].setData(str(runnum)) 01282 qResult=coral.AttributeList() 01283 qResult.extend('lumientryid','unsigned long long') 01284 qResult.extend('trgentryid','unsigned long long') 01285 qResult.extend('hltentryid','unsigned long long') 01286 qHandle.defineOutput(qResult) 01287 qHandle.setCondition(qConditionStr,qCondition) 01288 cursor=qHandle.execute() 01289 while cursor.next(): 01290 lumientryid=cursor.currentRow()['lumientryid'].data() 01291 trgentryid=cursor.currentRow()['trgentryid'].data() 01292 hltentryid=cursor.currentRow()['hltentryid'].data() 01293 if lumientryid in branchfilter and trgentryid in branchfilter and hltentryid in branchfilter: 01294 result.extend([lumientryid,trgentryid,hltentryid]) 01295 except: 01296 del qHandle 01297 raise 01298 del qHandle 01299 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 12 of file dataDML.py.
00013 : 00014 ''' 00015 select fillnum,runnum,starttime from cmsrunsummary where [where fillnum>=:fillmin and fillnum<=:fillmax and amodetag=:amodetag] 00016 output: [fill] 00017 ''' 00018 result=[] 00019 tmpresult={} 00020 qHandle=schema.newQuery() 00021 r=nameDealer.cmsrunsummaryTableName() 00022 lute=lumiTime.lumiTime() 00023 try: 00024 qHandle.addToTableList(r) 00025 qConditionPieces=[] 00026 qConditionStr='' 00027 qCondition=coral.AttributeList() 00028 if fillmin: 00029 qConditionPieces.append('FILLNUM>=:fillmin') 00030 qCondition.extend('fillmin','unsigned int') 00031 qCondition['fillmin'].setData(int(fillmin)) 00032 if fillmax: 00033 qConditionPieces.append('FILLNUM<=:fillmax') 00034 qCondition.extend('fillmax','unsigned int') 00035 qCondition['fillmax'].setData(int(fillmax)) 00036 if amodetag: 00037 qConditionPieces.append('AMODETAG=:amodetag') 00038 qCondition.extend('amodetag','string') 00039 qCondition['amodetag'].setData(amodetag) 00040 if len(qConditionPieces)!=0: 00041 qConditionStr=(' AND ').join(qConditionPieces) 00042 qResult=coral.AttributeList() 00043 qResult.extend('fillnum','unsigned int') 00044 qResult.extend('runnum','unsigned int') 00045 qResult.extend('starttime','string') 00046 qHandle.defineOutput(qResult) 00047 if len(qConditionStr)!=0: 00048 qHandle.setCondition(qConditionStr,qCondition) 00049 qHandle.addToOutputList('FILLNUM','fillnum') 00050 qHandle.addToOutputList('RUNNUM','runnum') 00051 qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime') 00052 cursor=qHandle.execute() 00053 while cursor.next(): 00054 currentfill=cursor.currentRow()['fillnum'].data() 00055 runnum=cursor.currentRow()['runnum'].data() 00056 starttimeStr=cursor.currentRow()['starttime'].data() 00057 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S') 00058 minTime=None 00059 maxTime=None 00060 if startT and stopT: 00061 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S') 00062 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S') 00063 if runTime>=minTime and runTime<=maxTime: 00064 tmpresult.setdefault(currentfill,[]).append(runnum) 00065 elif startT is not None: 00066 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S') 00067 if runTime>=minTime: 00068 tmpresult.setdefault(currentfill,[]).append(runnum) 00069 elif stopT is not None: 00070 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S') 00071 if runTime<=maxTime: 00072 tmpresult.setdefault(currentfill,[]).append(runnum) 00073 else: 00074 tmpresult.setdefault(currentfill,[]).append(runnum) 00075 #print tmpresult 00076 for f in sorted(tmpresult): 00077 if tmpresult[f]: 00078 result.append(f) 00079 except : 00080 del qHandle 00081 raise 00082 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 83 of file dataDML.py.
00084 : 00085 ''' 00086 select fillnum,runnum,starttime from cmsrunsummary [where fillnum=:fillnum and runnum>=runmin and runnum<=runmax and amodetag=:amodetag ] 00087 output: {fill:[runnum,...]} 00088 ''' 00089 result={} 00090 timelesslist=[] 00091 qHandle=schema.newQuery() 00092 r=nameDealer.cmsrunsummaryTableName() 00093 lute=lumiTime.lumiTime() 00094 try: 00095 qHandle.addToTableList(r) 00096 qConditionPieces=[] 00097 qConditionStr='' 00098 qCondition=coral.AttributeList() 00099 if fillnum: 00100 qConditionPieces.append('FILLNUM=:fillnum') 00101 qCondition.extend('fillnum','unsigned int') 00102 qCondition['fillnum'].setData(int(fillnum)) 00103 if runmin: 00104 qConditionPieces.append('RUNNUM>=:runmin') 00105 qCondition.extend('runmin','unsigned int') 00106 qCondition['runmin'].setData(runmin) 00107 if runmax: 00108 qConditionPieces.append('RUNNUM<=:runmax') 00109 qCondition.extend('runmax','unsigned int') 00110 qCondition['runmax'].setData(runmax) 00111 if amodetag: 00112 qConditionPieces.append('AMODETAG=:amodetag') 00113 qCondition.extend('amodetag','string') 00114 qCondition['amodetag'].setData(amodetag) 00115 if l1keyPattern: 00116 qConditionPieces.append('regexp_like(L1KEY,:l1keypattern)') 00117 qCondition.extend('l1keypattern','string') 00118 qCondition['l1keypattern'].setData(l1keyPattern) 00119 if hltkeyPattern: 00120 qConditionPieces.append('regexp_like(HLTKEY,:hltkeypattern)') 00121 qCondition.extend('hltkeypattern','string') 00122 qCondition['hltkeypattern'].setData(hltkeyPattern) 00123 if len(qConditionPieces)!=0: 00124 qConditionStr=(' AND ').join(qConditionPieces) 00125 qResult=coral.AttributeList() 00126 qResult.extend('fillnum','unsigned int') 00127 qResult.extend('runnum','unsigned int') 00128 qResult.extend('starttime','string') 00129 qHandle.defineOutput(qResult) 00130 if len(qConditionStr) !=0: 00131 qHandle.setCondition(qConditionStr,qCondition) 00132 qHandle.addToOutputList('FILLNUM','fillnum') 00133 qHandle.addToOutputList('RUNNUM','runnum') 00134 qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime') 00135 cursor=qHandle.execute() 00136 while cursor.next(): 00137 currentfill=cursor.currentRow()['fillnum'].data() 00138 starttimeStr=cursor.currentRow()['starttime'].data() 00139 runnum=cursor.currentRow()['runnum'].data() 00140 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S') 00141 minTime=None 00142 maxTime=None 00143 if startT and stopT: 00144 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S') 00145 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S') 00146 if runTime>=minTime and runTime<=maxTime: 00147 result.setdefault(currentfill,[]).append(runnum) 00148 elif startT is not None: 00149 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S') 00150 if runTime>=minTime: 00151 result.setdefault(currentfill,[]).append(runnum) 00152 elif stopT is not None: 00153 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S') 00154 if runTime<=maxTime: 00155 result.setdefault(currentfill,[]).append(runnum) 00156 else: 00157 result.setdefault(currentfill,[]).append(runnum) 00158 except : 00159 del qHandle 00160 raise 00161 del qHandle 00162 return result
def dataDML::guessHltDataIdByRun | ( | schema, | |
runnum, | |||
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 1120 of file dataDML.py.
01121 : 01122 ''' 01123 select max data_id of the given run. In current design, it's the most recent data of the run 01124 ''' 01125 result=None 01126 hltids=[] 01127 qHandle=schema.newQuery() 01128 try: 01129 qHandle.addToTableList(nameDealer.hltdataTableName()) 01130 qHandle.addToOutputList('DATA_ID','hltdataid') 01131 qConditionStr='RUNNUM=:runnum ' 01132 qCondition=coral.AttributeList() 01133 qCondition.extend('runnum','unsigned int') 01134 qCondition['runnum'].setData(runnum) 01135 qResult=coral.AttributeList() 01136 qResult.extend('hltdataid','unsigned long long') 01137 qHandle.defineOutput(qResult) 01138 qHandle.setCondition(qConditionStr,qCondition) 01139 cursor=qHandle.execute() 01140 while cursor.next(): 01141 hltdataid=cursor.currentRow()['hltdataid'].data() 01142 hltids.append(hltdataid) 01143 except : 01144 del qHandle 01145 raise 01146 del qHandle 01147 if len(hltids)>0 : 01148 return max(hltids) 01149 else: 01150 return result 01151 01152 #def guessAllDataIdByRun(schema,runnum): 01153 # ''' 01154 # get dataids by runnumber, if there are duplicates, pick max(dataid).Bypass full version lookups 01155 # result (lumidataid(0),trgdataid(1),hltdataid(2)) 01156 # ''' 01157 # lumiids=[] 01158 # trgids=[] 01159 # hltids=[] 01160 # qHandle=schema.newQuery() 01161 # try: 01162 # qHandle.addToTableList(nameDealer.lumidataTableName(),'l') 01163 # qHandle.addToTableList(nameDealer.trgdataTableName(),'t') 01164 # qHandle.addToTableList(nameDealer.hltdataTableName(),'h') 01165 # qHandle.addToOutputList('l.DATA_ID','lumidataid') 01166 # qHandle.addToOutputList('t.DATA_ID','trgdataid') 01167 # qHandle.addToOutputList('h.DATA_ID','hltdataid') 01168 # qConditionStr='l.RUNNUM=t.RUNNUM and t.RUNNUM=h.RUNNUM and l.RUNNUM=:runnum ' 01169 # qCondition=coral.AttributeList() 01170 # qCondition.extend('runnum','unsigned int') 01171 # qCondition['runnum'].setData(runnum) 01172 # qResult=coral.AttributeList() 01173 # qResult.extend('lumidataid','unsigned long long') 01174 # qResult.extend('trgdataid','unsigned long long') 01175 # qResult.extend('hltdataid','unsigned long long') 01176 # qHandle.defineOutput(qResult) 01177 # qHandle.setCondition(qConditionStr,qCondition) 01178 # cursor=qHandle.execute() 01179 # while cursor.next(): 01180 # lumidataid=cursor.currentRow()['lumidataid'].data() 01181 # trgdataid=cursor.currentRow()['trgdataid'].data() 01182 # hltdataid=cursor.currentRow()['hltdataid'].data() 01183 # lumiids.append(lumidataid) 01184 # trgids.append(trgdataid) 01185 # hltids.append(hltdataid) 01186 # except : 01187 # del qHandle 01188 # raise 01189 # del qHandle 01190 # if len(lumiids)>0 and len(trgids)>0 and len(hltids)>0: 01191 # return (max(lumiids),max(trgids),max(hltids)) 01192 # else: 01193 # return (None,None,None)
def dataDML::guessHltDataIdByRunInBranch | ( | schema, | |
runnum, | |||
tablename, | |||
branchName | |||
) |
Definition at line 1114 of file dataDML.py.
01114 : 01115 revlist=revisionDML.revisionsInBranchName(schema,branchName) 01116 hltentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName) 01117 latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,hltentry_id,revlist) 01118 return latestrevision 01119
def dataDML::guessLumiDataIdByRun | ( | 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 1045 of file dataDML.py.
01046 : 01047 ''' 01048 select max data_id of the given run. In current design, it's the most recent data of the run 01049 ''' 01050 result=None 01051 lumiids=[] 01052 qHandle=schema.newQuery() 01053 try: 01054 qHandle.addToTableList(tablename) 01055 qHandle.addToOutputList('DATA_ID','lumidataid') 01056 qConditionStr='RUNNUM=:runnum' 01057 qCondition=coral.AttributeList() 01058 qCondition.extend('runnum','unsigned int') 01059 qCondition['runnum'].setData(runnum) 01060 qResult=coral.AttributeList() 01061 qResult.extend('lumidataid','unsigned long long') 01062 qHandle.defineOutput(qResult) 01063 qHandle.setCondition(qConditionStr,qCondition) 01064 cursor=qHandle.execute() 01065 while cursor.next(): 01066 lumidataid=cursor.currentRow()['lumidataid'].data() 01067 lumiids.append(lumidataid) 01068 except : 01069 del qHandle 01070 raise 01071 del qHandle 01072 if not lumiids: 01073 return None 01074 else: 01075 result=max(lumiids) 01076 return result
def dataDML::guessLumiDataIdByRunInBranch | ( | schema, | |
runnum, | |||
tablename, | |||
branchName | |||
) |
Definition at line 1039 of file dataDML.py.
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 1194 of file dataDML.py.
01195 : 01196 ''' 01197 get norm dataids by amodetag, egev if there are duplicates, pick max(dataid).Bypass full version lookups 01198 select data_id from luminorm where amodetag=:amodetag and egev_1=:egev1 01199 ''' 01200 luminormids=[] 01201 qHandle=schema.newQuery() 01202 egevmin=egev1*0.95 01203 egevmax=egev1*1.05 01204 try: 01205 qHandle.addToTableList( nameDealer.luminormTableName() ) 01206 qHandle.addToOutputList('DATA_ID','normdataid') 01207 qConditionStr='AMODETAG=:amodetag AND EGEV_1>=:egevmin AND EGEV_1<=:egevmax' 01208 qCondition=coral.AttributeList() 01209 qCondition.extend('amodetag','string') 01210 qCondition.extend('egevmin','unsigned int') 01211 qCondition.extend('egevmax','unsigned int') 01212 qCondition['amodetag'].setData(amodetag) 01213 qCondition['egevmin'].setData(int(egevmin)) 01214 qCondition['egevmax'].setData(int(egevmax)) 01215 qResult=coral.AttributeList() 01216 qResult.extend('normdataid','unsigned long long') 01217 qHandle.defineOutput(qResult) 01218 qHandle.setCondition(qConditionStr,qCondition) 01219 cursor=qHandle.execute() 01220 while cursor.next(): 01221 normdataid=cursor.currentRow()['normdataid'].data() 01222 luminormids.append(normdataid) 01223 except : 01224 del qHandle 01225 raise 01226 del qHandle 01227 if len(luminormids) !=0:return max(luminormids) 01228 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 1229 of file dataDML.py.
01230 : 01231 ''' 01232 get norm dataids by name, if there are duplicates, pick max(dataid).Bypass full version lookups 01233 select data_id from luminorms where entry_name=:normname 01234 result luminormdataid 01235 ''' 01236 luminormids=[] 01237 qHandle=schema.newQuery() 01238 try: 01239 qHandle.addToTableList( nameDealer.luminormTableName() ) 01240 qHandle.addToOutputList('DATA_ID','normdataid') 01241 qConditionStr='ENTRY_NAME=:normname ' 01242 qCondition=coral.AttributeList() 01243 qCondition.extend('normname','string') 01244 qCondition['normname'].setData(normname) 01245 qResult=coral.AttributeList() 01246 qResult.extend('normdataid','unsigned long long') 01247 qHandle.defineOutput(qResult) 01248 qHandle.setCondition(qConditionStr,qCondition) 01249 cursor=qHandle.execute() 01250 while cursor.next(): 01251 normdataid=cursor.currentRow()['normdataid'].data() 01252 luminormids.append(normdataid) 01253 except : 01254 del qHandle 01255 raise 01256 del qHandle 01257 if len(luminormids) !=0:return max(luminormids) 01258 return None
def dataDML::guessTrgDataIdByRun | ( | schema, | |
runnum, | |||
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 1083 of file dataDML.py.
01084 : 01085 ''' 01086 select max data_id of the given run. In current design, it's the most recent data of the run 01087 ''' 01088 result=None 01089 trgids=[] 01090 qHandle=schema.newQuery() 01091 try: 01092 qHandle.addToTableList(nameDealer.trgdataTableName()) 01093 qHandle.addToOutputList('DATA_ID','trgdataid') 01094 qConditionStr='RUNNUM=:runnum' 01095 qCondition=coral.AttributeList() 01096 qCondition.extend('runnum','unsigned int') 01097 qCondition['runnum'].setData(runnum) 01098 qResult=coral.AttributeList() 01099 qResult.extend('trgdataid','unsigned long long') 01100 qHandle.defineOutput(qResult) 01101 qHandle.setCondition(qConditionStr,qCondition) 01102 cursor=qHandle.execute() 01103 while cursor.next(): 01104 trgdataid=cursor.currentRow()['trgdataid'].data() 01105 trgids.append(trgdataid) 01106 except : 01107 del qHandle 01108 raise 01109 del qHandle 01110 if len(trgids)>0: 01111 return max(trgids) 01112 else: 01113 return result
def dataDML::guessTrgDataIdByRunInBranch | ( | schema, | |
runnum, | |||
tablename, | |||
branchName | |||
) |
Definition at line 1077 of file dataDML.py.
01077 : 01078 revlist=revisionDML.revisionsInBranchName(schema,branchName) 01079 trgentry_id=revisionDML.entryInBranch(schema,tablename,str(runnum),branchName) 01080 latestrevision=revisionDML.latestDataRevisionOfEntry(schema,tablename,trgentry_id,revlist) 01081 return latestrevision 01082
def dataDML::hltLSById | ( | schema, | |
dataid, | |||
hltpathname = None , |
|||
hltpathpattern = None , |
|||
withL1Pass = False , |
|||
withHLTAccept = False |
|||
) |
result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]}
Definition at line 944 of file dataDML.py.
00945 : 00946 ''' 00947 result (runnum, {cmslsnum:[(pathname,prescale,1lpass,hltaccept)](0)]} 00948 ''' 00949 #print 'entering hltLSById ' 00950 #t0=time.time() 00951 result={} 00952 hltrundata=hltRunById(schema,dataid,hltpathname=hltpathname,hltpathpattern=hltpathpattern) 00953 hltnamedict=hltrundata[3] 00954 #tt1=time.time() 00955 #print '\thltrunbyid time ',tt1-t0 00956 #tt0=time.time() 00957 qHandle=schema.newQuery() 00958 try: 00959 qHandle.addToTableList(nameDealer.lshltTableName()) 00960 qHandle.addToOutputList('RUNNUM','runnum') 00961 qHandle.addToOutputList('CMSLSNUM','cmslsnum') 00962 if len(hltnamedict)!=0: 00963 qHandle.addToOutputList('PRESCALEBLOB','prescaleblob') 00964 if withL1Pass: 00965 qHandle.addToOutputList('HLTCOUNTBLOB','hltcountblob') 00966 if withHLTAccept: 00967 qHandle.addToOutputList('HLTACCEPTBLOB','hltacceptblob') 00968 qConditionStr='DATA_ID=:dataid' 00969 qCondition=coral.AttributeList() 00970 qCondition.extend('dataid','unsigned long long') 00971 qCondition['dataid'].setData(dataid) 00972 qResult=coral.AttributeList() 00973 qResult.extend('runnum','unsigned int') 00974 qResult.extend('cmslsnum','unsigned int') 00975 if len(hltnamedict)!=0: 00976 qResult.extend('prescaleblob','blob') 00977 if withL1Pass: 00978 qResult.extend('hltcountblob','blob') 00979 if withHLTAccept: 00980 qResult.extend('hltacceptblob','blob') 00981 qHandle.defineOutput(qResult) 00982 qHandle.setCondition(qConditionStr,qCondition) 00983 cursor=qHandle.execute() 00984 while cursor.next(): 00985 runnum=cursor.currentRow()['runnum'].data() 00986 cmslsnum=cursor.currentRow()['cmslsnum'].data() 00987 prescaleblob=None 00988 hltcountblob=None 00989 hltacceptblob=None 00990 if len(hltnamedict)!=0: 00991 prescaleblob=cursor.currentRow()['prescaleblob'].data() 00992 if withL1Pass: 00993 hltcountblob=cursor.currentRow()['hltcountblob'].data() 00994 if withHLTAccept: 00995 hltacceptblob=cursor.currentRow()['hltacceptblob'].data() 00996 if not result.has_key(cmslsnum): 00997 result[cmslsnum]=[] 00998 pathinfo=[] 00999 prescales=None 01000 hltcounts=None 01001 hltaccepts=None 01002 if prescaleblob: 01003 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ### 01004 prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'l') 01005 else: 01006 prescales=CommonUtil.unpackBlobtoArray(prescaleblob,'I') 01007 if hltcountblob: 01008 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ### 01009 hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'l') 01010 else: 01011 hltcounts=CommonUtil.unpackBlobtoArray(hltcountblob,'I') 01012 if hltacceptblob: 01013 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ### 01014 hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'l') 01015 else: 01016 hltaccepts=CommonUtil.unpackBlobtoArray(hltacceptblob,'I') 01017 for (hltpathidx,thispathname) in hltnamedict:#loop over selected paths 01018 thispresc=0 01019 thishltcount=0 01020 thisaccept=0 01021 if prescales: 01022 thispresc=prescales[hltpathidx] 01023 if hltcounts: 01024 thishltcount=hltcounts[hltpathidx] 01025 if hltaccepts: 01026 thisaccept=hltaccepts[hltpathidx] 01027 thispathinfo=(thispathname,thispresc,thishltcount,thisaccept) 01028 pathinfo.append(thispathinfo) 01029 result[cmslsnum]=pathinfo 01030 except : 01031 del qHandle 01032 raise 01033 del qHandle 01034 #tt1=time.time() 01035 #print '\tdb stuff time ',tt1-tt0 01036 #t1=time.time() 01037 #print 'tot hltLSById time ',t1-t0 01038 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 838 of file dataDML.py.
00839 : 00840 ''' 00841 result [runnum(0),datasource(1),npath(2),hltnamedict(3)] 00842 output : 00843 npath : total number of hltpath in DB 00844 hltnamedict : list of all selected paths [(hltpathidx,hltname),(hltpathidx,hltname)] 00845 ''' 00846 result=[] 00847 qHandle=schema.newQuery() 00848 runnum=None 00849 datasource=None 00850 npath=None 00851 hltnamedict=[] 00852 try: 00853 qHandle.addToTableList(nameDealer.hltdataTableName()) 00854 qHandle.addToOutputList('RUNNUM','runnum') 00855 qHandle.addToOutputList('SOURCE','datasource') 00856 qHandle.addToOutputList('NPATH','npath') 00857 qHandle.addToOutputList('PATHNAMECLOB','pathnameclob') 00858 qConditionStr='DATA_ID=:dataid' 00859 qCondition=coral.AttributeList() 00860 qCondition.extend('dataid','unsigned long long') 00861 qCondition['dataid'].setData(dataid) 00862 qResult=coral.AttributeList() 00863 qResult.extend('runnum','unsigned int') 00864 qResult.extend('datasource','string') 00865 qResult.extend('npath','unsigned int') 00866 qResult.extend('pathnameclob','string') 00867 qHandle.defineOutput(qResult) 00868 qHandle.setCondition(qConditionStr,qCondition) 00869 cursor=qHandle.execute() 00870 pathnameclob=None 00871 pathnames=[] 00872 while cursor.next(): 00873 runnum=cursor.currentRow()['runnum'].data() 00874 datasource=cursor.currentRow()['datasource'].data() 00875 npath=cursor.currentRow()['npath'].data() 00876 pathnameclob=cursor.currentRow()['pathnameclob'].data() 00877 if pathnameclob: 00878 pathnames=pathnameclob.split(',') 00879 for pathnameidx,hltname in enumerate(pathnames): 00880 if hltpathname: 00881 if hltpathname==hltname: 00882 hltnamedict.append((pathnameidx,hltname)) 00883 break 00884 elif hltpathpattern: 00885 if fnmatch.fnmatch(hltname,hltpathpattern): 00886 hltnamedict.append((pathnameidx,hltname)) 00887 else: 00888 hltnamedict.append((pathnameidx,hltname)) 00889 result=[runnum,datasource,npath,hltnamedict] 00890 except : 00891 del qHandle 00892 raise 00893 del qHandle 00894 return result
def dataDML::hlttrgMappingByrun | ( | schema, | |
runnum, | |||
hltpathname = None , |
|||
hltpathpattern = None |
|||
) |
select m.hltkey,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 895 of file dataDML.py.
00896 : 00897 ''' 00898 select m.hltkey,m.hltpathname,m.l1seed from cmsrunsummary r,trghltmap m where r.runnum=:runnum and m.hltkey=r.hltkey and [m.hltpathname=:hltpathname] 00899 output: {hltpath:l1seed} 00900 ''' 00901 result={} 00902 queryHandle=schema.newQuery() 00903 r=nameDealer.cmsrunsummaryTableName() 00904 m=nameDealer.trghltMapTableName() 00905 if hltpathpattern and hltpathpattern in ['*','all','All','ALL']: 00906 hltpathpattern=None 00907 try: 00908 queryHandle.addToTableList(r) 00909 queryHandle.addToTableList(m) 00910 queryCondition=coral.AttributeList() 00911 queryCondition.extend('runnum','unsigned int') 00912 queryCondition['runnum'].setData(int(runnum)) 00913 #queryHandle.addToOutputList(m+'.HLTKEY','hltkey') 00914 queryHandle.addToOutputList(m+'.HLTPATHNAME','hltpathname') 00915 queryHandle.addToOutputList(m+'.L1SEED','l1seed') 00916 conditionStr=r+'.RUNNUM=:runnum and '+m+'.HLTKEY='+r+'.HLTKEY' 00917 if hltpathname: 00918 hltpathpattern=None 00919 conditionStr+=m+'.HLTPATHNAME=:hltpathname' 00920 queryCondition.extend('hltpathname','string') 00921 queryCondition['hltpathname'].setData(hltpathname) 00922 queryHandle.setCondition(conditionStr,queryCondition) 00923 queryResult=coral.AttributeList() 00924 #queryResult.extend('hltkey','string') 00925 queryResult.extend('pname','string') 00926 queryResult.extend('l1seed','string') 00927 queryHandle.defineOutput(queryResult) 00928 cursor=queryHandle.execute() 00929 while cursor.next(): 00930 #hltkey=cursor.currentRow()['hltkey'].data() 00931 pname=cursor.currentRow()['pname'].data() 00932 l1seed=cursor.currentRow()['l1seed'].data() 00933 if not result.has_key(hltpathname): 00934 if hltpathpattern: 00935 if fnmatch.fnmatch(pname,hltpathpattern): 00936 result[pname]=l1seed 00937 else: 00938 result[pname]=l1seed 00939 except : 00940 del queryHandle 00941 raise 00942 del queryHandle 00943 return result
def dataDML::insertRunSummaryData | ( | schema, | |
runnumber, | |||
runsummarydata, | |||
complementalOnly = False |
|||
) |
input: runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] output:
Definition at line 1465 of file dataDML.py.
01466 : 01467 ''' 01468 input: 01469 runsummarydata [l1key,amodetag,egev,sequence,hltkey,fillnum,starttime,stoptime] 01470 output: 01471 ''' 01472 l1key=runsummarydata[0] 01473 amodetag=runsummarydata[1] 01474 egev=runsummarydata[2] 01475 hltkey='' 01476 fillnum=0 01477 sequence='' 01478 starttime='' 01479 stoptime='' 01480 if not complementalOnly: 01481 sequence=runsummarydata[3] 01482 hltkey=runsummarydata[4] 01483 fillnum=runsummarydata[5] 01484 starttime=runsummarydata[6] 01485 stoptime=runsummarydata[7] 01486 try: 01487 if not complementalOnly: 01488 tabrowDefDict={'RUNNUM':'unsigned int','L1KEY':'string','AMODETAG':'string','EGEV':'unsigned int','SEQUENCE':'string','HLTKEY':'string','FILLNUM':'unsigned int','STARTTIME':'time stamp','STOPTIME':'time stamp'} 01489 tabrowValueDict={'RUNNUM':int(runnumber),'L1KEY':l1key,'AMODETAG':amodetag,'EGEV':int(egev),'SEQUENCE':sequence,'HLTKEY':hltkey,'FILLNUM':int(fillnum),'STARTTIME':starttime,'STOPTIME':stoptime} 01490 db=dbUtil.dbUtil(schema) 01491 db.insertOneRow(nameDealer.cmsrunsummaryTableName(),tabrowDefDict,tabrowValueDict) 01492 else: 01493 setClause='L1KEY=:l1key,AMODETAG=:amodetag,EGEV=:egev' 01494 updateCondition='RUNNUM=:runnum' 01495 inputData=coral.AttributeList() 01496 inputData.extend('l1key','string') 01497 inputData.extend('amodetag','string') 01498 inputData.extend('egev','unsigned int') 01499 inputData.extend('runnum','unsigned int') 01500 inputData['l1key'].setData(l1key) 01501 inputData['amodetag'].setData(amodetag) 01502 inputData['egev'].setData(int(egev)) 01503 inputData['runnum'].setData(int(runnumber)) 01504 db=dbUtil.dbUtil(schema) 01505 db.singleUpdate(nameDealer.cmsrunsummaryTableName(),setClause,updateCondition,inputData) 01506 except : raise
def dataDML::insertTrgHltMap | ( | schema, | |
hltkey, | |||
trghltmap | |||
) |
input: trghltmap {hltpath:l1seed} output:
Definition at line 1507 of file dataDML.py.
01508 : 01509 ''' 01510 input: 01511 trghltmap {hltpath:l1seed} 01512 output: 01513 ''' 01514 hltkeyExists=False 01515 nrows=0 01516 try: 01517 kQueryBindList=coral.AttributeList() 01518 kQueryBindList.extend('hltkey','string') 01519 kQuery=schema.newQuery() 01520 kQuery.addToTableList(nameDealer.trghltMapTableName()) 01521 kQuery.setCondition('HLTKEY=:hltkey',kQueryBindList) 01522 kQueryBindList['hltkey'].setData(hltkey) 01523 kResult=kQuery.execute() 01524 while kResult.next(): 01525 hltkeyExists=True 01526 if not hltkeyExists: 01527 bulkvalues=[] 01528 trghltDefDict=[('HLTKEY','string'),('HLTPATHNAME','string'),('L1SEED','string')] 01529 for hltpath,l1seed in trghltmap.items(): 01530 bulkvalues.append([('HLTKEY',hltkey),('HLTPATHNAME',hltpath),('L1SEED',l1seed)]) 01531 db=dbUtil.dbUtil(schema) 01532 db.bulkInsert(nameDealer.trghltMapTableName(),trghltDefDict,bulkvalues) 01533 nrows=len(bulkvalues) 01534 return nrows 01535 except : 01536 print 'error in insertTrgHltMap ' raise
def dataDML::latestdataIdByEntry | ( | schema, | |
entryid, | |||
datatype, | |||
branchfilter | |||
) |
select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid check revision_id is in branch
Definition at line 1300 of file dataDML.py.
01301 : 01302 ''' 01303 select l.data_id,rl.revision_id from lumidatatable l,lumirevisions rl where l.data_id=rl.data_id and l.entry_id=:entryid 01304 check revision_id is in branch 01305 ''' 01306 dataids=[] 01307 datatablename='' 01308 revmaptablename='' 01309 if datatype=='lumi': 01310 datatablename=nameDealer.lumidataTableName() 01311 elif datatype=='trg': 01312 datatablename=nameDealer.trgdataTableName() 01313 elif dataytpe=='hlt': 01314 tablename=nameDealer.hltdataTableName() 01315 else: 01316 raise RunTimeError('datatype '+datatype+' is not supported') 01317 revmaptablename=nameDealer.revmapTableName(datatablename) 01318 qHandle=schema.newQuery() 01319 try: 01320 qHandle.addToTableList(revmaptablename) 01321 qHandle.addToTableList(datatablename) 01322 qHandle.addToOutputList('l.DATA_ID','dataid') 01323 qHandle.addToOutputList(revmaptablename+'.REVISION_ID','revisionid') 01324 qConditionStr=datatablename+'.DATA_ID='+revmaptablename+'.DATA_ID AND '+datatablename+'.ENTRY_ID=:entryid' 01325 qCondition=coral.AttributeList() 01326 qCondition.extend('entryid','unsigned long long') 01327 qResult=coral.AttributeList() 01328 qResult.extend('dataid','unsigned long long') 01329 qResult.extend('revisionid','unsigned long long') 01330 qHandle.defineOutput(qResult) 01331 qHandle.setCondition(qConditionStr,qCondition) 01332 cursor=qHandle.execute() 01333 while cursor.next(): 01334 dataid=cursor.currentRow()['dataid'].data() 01335 revisionid=cursor.currentRow()['revisionid'].data() 01336 if revisionid in branchfilter: 01337 dataids.append(dataid) 01338 except: 01339 del qHandle 01340 raise 01341 del qHandle 01342 if len(dataids)!=0:return max(dataids) 01343 return None 01344 01345 #======================================================= 01346 # INSERT requires in update transaction #=======================================================
def dataDML::lumiBXByAlgo | ( | schema, | |
dataid, | |||
algoname | |||
) |
result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]}
Definition at line 788 of file dataDML.py.
00789 : 00790 ''' 00791 result {lumilsnum:[cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]} 00792 ''' 00793 result={} 00794 qHandle=schema.newQuery() 00795 try: 00796 qHandle.addToTableList(nameDealer.lumisummaryv2TableName()) 00797 qHandle.addToOutputList('CMSLSNUM','cmslsnum') 00798 qHandle.addToOutputList('LUMILSNUM','lumilsnum') 00799 #qHandle.addToOutputList('ALGONAME','algoname') 00800 qHandle.addToOutputList('NUMORBIT','numorbit') 00801 qHandle.addToOutputList('STARTORBIT','startorbit') 00802 qHandle.addToOutputList('BXLUMIVALUE_'+algoname,'bxlumivalue') 00803 qHandle.addToOutputList('BXLUMIERROR_'+algoname,'bxlumierr') 00804 qHandle.addToOutputList('BXLUMIQUALITY_'+algoname,'bxlumiqlty') 00805 qConditionStr='DATA_ID=:dataid' 00806 qCondition=coral.AttributeList() 00807 qCondition.extend('dataid','unsigned long long') 00808 qCondition['dataid'].setData(dataid) 00809 qResult=coral.AttributeList() 00810 qResult.extend('cmslsnum','unsigned int') 00811 qResult.extend('lumilsnum','unsigned int') 00812 qResult.extend('numorbit','unsigned int') 00813 qResult.extend('startorbit','unsigned int') 00814 qResult.extend('bxlumivalue','blob') 00815 qResult.extend('bxlumierr','blob') 00816 qResult.extend('bxlumiqlty','blob') 00817 qHandle.defineOutput(qResult) 00818 qHandle.setCondition(qConditionStr,qCondition) 00819 cursor=qHandle.execute() 00820 while cursor.next(): 00821 cmslsnum=cursor.currentRow()['cmslsnum'].data() 00822 lumilsnum=cursor.currentRow()['lumilsnum'].data() 00823 numorbit=cursor.currentRow()['numorbit'].data() 00824 startorbit=cursor.currentRow()['startorbit'].data() 00825 bxlumivalue=cursor.currentRow()['bxlumivalue'].data() 00826 bxlumierr=cursor.currentRow()['bxlumierr'].data() 00827 bxlumiqlty=cursor.currentRow()['bxlumiqlty'].data() 00828 if not result.has_key(algoname): 00829 result[algoname]={} 00830 if not result[algoname].has_key(lumilsnum): 00831 result[algoname][lumilsnum]=[] 00832 result[algoname][lumilsnum].extend([cmslsnum,numorbit,startorbit,bxlumivalue,bxlumierr,bxlumiqlty]) 00833 except : 00834 del qHandle 00835 raise RuntimeError(' dataDML.lumiBXById: '+str(e)) 00836 del qHandle 00837 return result
def dataDML::lumiLSById | ( | schema, | |
dataid, | |||
beamstatus = None , |
|||
withBXInfo = False , |
|||
bxAlgo = 'OCC1' , |
|||
withBeamIntensity = False , |
|||
tableName = None |
|||
) |
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 613 of file dataDML.py.
00614 : 00615 ''' 00616 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)]}) 00617 ''' 00618 runnum=0 00619 result={} 00620 qHandle=schema.newQuery() 00621 if withBXInfo and bxAlgo not in ['OCC1','OCC2','ET']: 00622 raise ValueError('unknown lumi algo '+bxAlgo) 00623 if beamstatus and beamstatus not in ['STABLE BEAMS',]: 00624 raise ValueError('unknown beam status '+beamstatus) 00625 try: 00626 if tableName is None: 00627 lls=nameDealer.lumisummaryv2TableName() 00628 else: 00629 lls=tableName 00630 qHandle.addToTableList(lls) 00631 qHandle.addToOutputList('RUNNUM','runnum') 00632 qHandle.addToOutputList('LUMILSNUM','lumilsnum') 00633 qHandle.addToOutputList('CMSLSNUM','cmslsnum') 00634 qHandle.addToOutputList('INSTLUMI','instlumi') 00635 qHandle.addToOutputList('INSTLUMIERROR','instlumierr') 00636 qHandle.addToOutputList('INSTLUMIQUALITY','instlumiqlty') 00637 qHandle.addToOutputList('BEAMSTATUS','beamstatus') 00638 qHandle.addToOutputList('BEAMENERGY','beamenergy') 00639 qHandle.addToOutputList('NUMORBIT','numorbit') 00640 qHandle.addToOutputList('STARTORBIT','startorbit') 00641 if withBXInfo: 00642 qHandle.addToOutputList('BXLUMIVALUE_'+bxAlgo,'bxvalue') 00643 qHandle.addToOutputList('BXLUMIERROR_'+bxAlgo,'bxerror') 00644 if withBeamIntensity: 00645 qHandle.addToOutputList('CMSBXINDEXBLOB','bxindexblob') 00646 qHandle.addToOutputList('BEAMINTENSITYBLOB_1','beam1intensity') 00647 qHandle.addToOutputList('BEAMINTENSITYBLOB_2','beam2intensity') 00648 00649 qConditionStr='DATA_ID=:dataid' 00650 qCondition=coral.AttributeList() 00651 qCondition.extend('dataid','unsigned long long') 00652 qCondition['dataid'].setData(int(dataid)) 00653 if beamstatus: 00654 qConditionStr+=' and BEAMSTATUS=:beamstatus' 00655 qCondition.extend('beamstatus','string') 00656 qCondition['beamstatus'].setData(beamstatus) 00657 qResult=coral.AttributeList() 00658 qResult.extend('runnum','unsigned int') 00659 qResult.extend('lumilsnum','unsigned int') 00660 qResult.extend('cmslsnum','unsigned int') 00661 qResult.extend('instlumi','float') 00662 qResult.extend('instlumierr','float') 00663 qResult.extend('instlumiqlty','short') 00664 qResult.extend('beamstatus','string') 00665 qResult.extend('beamenergy','float') 00666 qResult.extend('numorbit','unsigned int') 00667 qResult.extend('startorbit','unsigned int') 00668 if withBXInfo: 00669 qResult.extend('bxvalue','blob') 00670 qResult.extend('bxerror','blob') 00671 if withBeamIntensity: 00672 qResult.extend('bxindexblob','blob') 00673 qResult.extend('beam1intensity','blob') 00674 qResult.extend('beam2intensity','blob') 00675 qHandle.defineOutput(qResult) 00676 qHandle.setCondition(qConditionStr,qCondition) 00677 cursor=qHandle.execute() 00678 while cursor.next(): 00679 runnum=cursor.currentRow()['runnum'].data() 00680 lumilsnum=cursor.currentRow()['lumilsnum'].data() 00681 cmslsnum=cursor.currentRow()['cmslsnum'].data() 00682 instlumi=cursor.currentRow()['instlumi'].data() 00683 instlumierr=cursor.currentRow()['instlumierr'].data() 00684 instlumiqlty=cursor.currentRow()['instlumiqlty'].data() 00685 bs=cursor.currentRow()['beamstatus'].data() 00686 begev=cursor.currentRow()['beamenergy'].data() 00687 numorbit=cursor.currentRow()['numorbit'].data() 00688 startorbit=cursor.currentRow()['startorbit'].data() 00689 bxinfo=None 00690 bxvalueblob=None 00691 bxerrblob=None 00692 if withBXInfo: 00693 bxvalueblob=cursor.currentRow()['bxvalue'].data() 00694 bxerrblob=cursor.currentRow()['bxerror'].data() 00695 if bxvalueblob and bxerrblob: 00696 bxvaluesArray=CommonUtil.unpackBlobtoArray(bxvalueblob,'f') 00697 bxerrArray=CommonUtil.unpackBlobtoArray(bxerrblob,'f') 00698 bxinfo=(bxvaluesArray,bxerrArray) 00699 bxindexblob=None 00700 beam1intensity=None 00701 beam2intensity=None 00702 beaminfo=None 00703 if withBeamIntensity: 00704 bxindexblob=cursor.currentRow()['bxindexblob'].data() 00705 beam1intensity=cursor.currentRow()['beam1intensity'].data() 00706 beam2intensity=cursor.currentRow()['beam2intensity'].data() 00707 if bxindexblob : 00708 bxindexArray=CommonUtil.unpackBlobtoArray(bxindexblob,'h') 00709 beam1intensityArray=CommonUtil.unpackBlobtoArray(beam1intensity,'f') 00710 beam2intensityArray=CommonUtil.unpackBlobtoArray(beam2intensity,'f') 00711 beaminfo=(bxindexArray,beam1intensityArray,beam2intensityArray) 00712 result[lumilsnum]=[cmslsnum,instlumi,instlumierr,instlumiqlty,bs,begev,numorbit,startorbit,bxinfo,beaminfo] 00713 except : 00714 del qHandle 00715 raise 00716 del qHandle return (runnum,result)
def dataDML::luminormById | ( | schema, | |
dataid | |||
) |
select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid result [name(0),amodetag(1),norm_1(2),egev_1(3),norm_2(4),energy_2(5) ]
Definition at line 380 of file dataDML.py.
00381 : 00382 ''' 00383 select entry_name,amodetag,norm_1,egev_1,norm_2,egev_2 from luminorms where DATA_ID=:dataid 00384 result [name(0),amodetag(1),norm_1(2),egev_1(3),norm_2(4),energy_2(5) ] 00385 ''' 00386 result=[] 00387 qHandle=schema.newQuery() 00388 try: 00389 qHandle.addToTableList(nameDealer.luminormTableName()) 00390 qHandle.addToOutputList('ENTRY_NAME','normname') 00391 qHandle.addToOutputList('AMODETAG','amodetag') 00392 qHandle.addToOutputList('NORM_1','norm_1') 00393 qHandle.addToOutputList('EGEV_1','energy_1') 00394 qHandle.addToOutputList('NORM_2','norm_2') 00395 qHandle.addToOutputList('EGEV_2','energy_2') 00396 qCondition=coral.AttributeList() 00397 qCondition.extend('dataid','unsigned long long') 00398 qCondition['dataid'].setData(dataid) 00399 qResult=coral.AttributeList() 00400 qResult.extend('normname','string') 00401 qResult.extend('amodetag','string') 00402 qResult.extend('norm_1','float') 00403 qResult.extend('energy_1','unsigned int') 00404 qResult.extend('norm_2','float') 00405 qResult.extend('energy_2','unsigned int') 00406 qHandle.defineOutput(qResult) 00407 qHandle.setCondition('DATA_ID=:dataid',qCondition) 00408 cursor=qHandle.execute() 00409 while cursor.next(): 00410 normname=cursor.currentRow()['normname'].data() 00411 amodetag=cursor.currentRow()['amodetag'].data() 00412 norm_1=cursor.currentRow()['norm_1'].data() 00413 energy_1=cursor.currentRow()['energy_1'].data() 00414 norm_2=None 00415 if cursor.currentRow()['norm_2'].data(): 00416 norm_2=cursor.currentRow()['norm_2'].data() 00417 energy_2=None 00418 if cursor.currentRow()['energy_2'].data(): 00419 energy_2=cursor.currentRow()['energy_2'].data() 00420 result.extend([normname,amodetag,norm_1,energy_1,norm_2,energy_2]) 00421 except : 00422 del qHandle 00423 raise 00424 del qHandle 00425 return result
def dataDML::lumiRunById | ( | schema, | |
dataid, | |||
tableName = None |
|||
) |
result [runnum(0),datasource(1),nominalegev(2)]
Definition at line 579 of file dataDML.py.
00580 : 00581 ''' 00582 result [runnum(0),datasource(1),nominalegev(2)] 00583 ''' 00584 result=[] 00585 qHandle=schema.newQuery() 00586 if tableName is None: 00587 tableName=nameDealer.lumidataTableName() 00588 try: 00589 qHandle.addToTableList(tableName) 00590 qHandle.addToOutputList('RUNNUM','runnum') 00591 qHandle.addToOutputList('SOURCE','datasource') 00592 qHandle.addToOutputList('NOMINALEGEV','nominalegev') 00593 qConditionStr='DATA_ID=:dataid' 00594 qCondition=coral.AttributeList() 00595 qCondition.extend('dataid','unsigned long long') 00596 qCondition['dataid'].setData(dataid) 00597 qResult=coral.AttributeList() 00598 qResult.extend('runnum','unsigned int') 00599 qResult.extend('datasource','string') 00600 qResult.extend('nominalegev','float') 00601 qHandle.defineOutput(qResult) 00602 qHandle.setCondition(qConditionStr,qCondition) 00603 cursor=qHandle.execute() 00604 while cursor.next(): 00605 runnum=cursor.currentRow()['runnum'].data() 00606 datasource=cursor.currentRow()['datasource'].data() 00607 nominalegev=cursor.currentRow()['nominalegev'].data() 00608 result.extend([runnum,datasource]) 00609 except : 00610 del qHandle 00611 raise 00612 del qHandle return result
def dataDML::mostRecentLuminorms | ( | schema, | |
branchfilter | |||
) |
this overview query should be only for norm select e.name,max(n.data_id),r.revision_id , n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2 from luminorms_entries e,luminorms_rev r,luminorms n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter) group by e.entry_name,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2; output {norm_name:[data_id,amodetag,norm_1,egev_1,norm_2,egev_2]}
Definition at line 318 of file dataDML.py.
00319 : 00320 ''' 00321 this overview query should be only for norm 00322 select e.name,max(n.data_id),r.revision_id , n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2 from luminorms_entries e,luminorms_rev r,luminorms n where n.entry_id=e.entry_id and n.data_id=r.data_id and r.revision_id>=min(branchfilter) and r.revision_id<=max(branchfilter) group by e.entry_name,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2; 00323 output {norm_name:[data_id,amodetag,norm_1,egev_1,norm_2,egev_2]} 00324 ''' 00325 #print branchfilter 00326 result={} 00327 entry2datamap={} 00328 branchmin=0 00329 branchmax=0 00330 if branchfilter and len(branchfilter)!=0: 00331 branchmin=min(branchfilter) 00332 branchmax=max(branchfilter) 00333 else: 00334 return result 00335 qHandle=schema.newQuery() 00336 try: 00337 qHandle.addToTableList(nameDealer.entryTableName(nameDealer.luminormTableName()),'e') 00338 qHandle.addToTableList(nameDealer.luminormTableName(),'n') 00339 qHandle.addToTableList(nameDealer.revmapTableName(nameDealer.luminormTableName()),'r') 00340 qHandle.addToOutputList('e.NAME','normname') 00341 qHandle.addToOutputList('max(r.DATA_ID)','data_id') 00342 qHandle.addToOutputList('r.REVISION_ID','revision_id') 00343 qHandle.addToOutputList('n.AMODETAG','amodetag') 00344 qHandle.addToOutputList('n.NORM_1','norm_1') 00345 qHandle.addToOutputList('n.EGEV_1','energy_1') 00346 qHandle.addToOutputList('n.NORM_2','norm_2') 00347 qHandle.addToOutputList('n.EGEV_2','energy_2') 00348 qCondition=coral.AttributeList() 00349 qCondition.extend('branchmin','unsigned long long') 00350 qCondition.extend('branchmax','unsigned long long') 00351 qCondition['branchmin'].setData(branchmin) 00352 qCondition['branchmax'].setData(branchmax) 00353 qResult=coral.AttributeList() 00354 qResult.extend('normname','string') 00355 qResult.extend('data_id','unsigned long long') 00356 qResult.extend('revision_id','unsigned long long') 00357 qResult.extend('amodetag','string') 00358 qResult.extend('norm_1','float') 00359 qResult.extend('energy_1','unsigned int') 00360 qResult.extend('norm_2','float') 00361 qResult.extend('energy_2','unsigned int') 00362 qHandle.defineOutput(qResult) 00363 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) 00364 qHandle.groupBy('e.name,r.revision_id,n.amodetag,n.norm_1,n.egev_1,n.norm_2,n.egev_2') 00365 cursor=qHandle.execute() 00366 while cursor.next(): 00367 normname=cursor.currentRow()['normname'].data() 00368 amodetag=cursor.currentRow()['amodetag'].data() 00369 norm_1=cursor.currentRow()['norm_1'].data() 00370 energy_1=cursor.currentRow()['energy_1'].data() 00371 norm_2=None 00372 if cursor.currentRow()['norm_2'].data(): 00373 norm_2=cursor.currentRow()['norm_2'].data() 00374 energy_2=None 00375 if cursor.currentRow()['energy_2'].data(): 00376 energy_2=cursor.currentRow()['energy_2'].data() 00377 result[normname]=[amodetag,norm_1,energy_1,norm_2,energy_2] 00378 except: 00379 raise return result
def dataDML::runList | ( | schema, | |
fillnum = None , |
|||
runmin = None , |
|||
runmax = None , |
|||
startT = None , |
|||
stopT = None , |
|||
l1keyPattern = None , |
|||
hltkeyPattern = None , |
|||
amodetag = None , |
|||
nominalEnergy = None , |
|||
energyFlut = 0.2 , |
|||
requiretrg = True , |
|||
requirehlt = True , |
|||
lumitype = None |
|||
) |
select runnum,starttime from cmsrunsummary r,lumidata l,trgdata t,hltdata h where r.runnum=l.runnum and l.runnum=t.runnum and t.runnum=h.runnum and r.fillnum=:fillnum and r.runnum>:runmin and r.runnum<:runmax and r.amodetag=:amodetag and regexp_like(r.l1key,:l1keypattern) and regexp_like(hltkey,:hltkeypattern) and l.nominalEnergy>=:nominalEnergy*(1-energyFlut) and l.nominalEnergy<=:nominalEnergy*(1+energyFlut)
Definition at line 163 of file dataDML.py.
00164 : 00165 ''' 00166 select runnum,starttime from cmsrunsummary r,lumidata l,trgdata t,hltdata h where r.runnum=l.runnum and l.runnum=t.runnum and t.runnum=h.runnum and r.fillnum=:fillnum and r.runnum>:runmin and r.runnum<:runmax and r.amodetag=:amodetag and regexp_like(r.l1key,:l1keypattern) and regexp_like(hltkey,:hltkeypattern) and l.nominalEnergy>=:nominalEnergy*(1-energyFlut) and l.nominalEnergy<=:nominalEnergy*(1+energyFlut) 00167 ''' 00168 if lumitype not in ['HF','PIXEL']: 00169 raise ValueError('unknown lumitype '+lumitype) 00170 lumitableName='' 00171 if lumitype=='HF': 00172 lumitableName=nameDealer.lumidataTableName() 00173 elif lumitype == 'PIXEL': 00174 lumitableName = nameDealer.pixellumidataTableName() 00175 else: 00176 assert False, "ERROR Unknown lumitype '%s'" % lumitype 00177 result=[] 00178 timelesslist=[] 00179 qHandle=schema.newQuery() 00180 r=nameDealer.cmsrunsummaryTableName() 00181 l=lumitableName 00182 t=nameDealer.trgdataTableName() 00183 h=nameDealer.hltdataTableName() 00184 lute=lumiTime.lumiTime() 00185 try: 00186 qHandle.addToTableList(r) 00187 qHandle.addToTableList(l) 00188 qConditionStr=r+'.runnum='+l+'.runnum' 00189 if requiretrg: 00190 qHandle.addToTableList(t) 00191 qConditionStr+=' and '+l+'.runnum='+t+'.runnum' 00192 if requirehlt: 00193 qHandle.addToTableList(h) 00194 qConditionStr+=' and '+l+'.runnum='+h+'.runnum' 00195 qCondition=coral.AttributeList() 00196 if fillnum: 00197 qConditionStr+=' and '+r+'.fillnum=:fillnum' 00198 qCondition.extend('fillnum','unsigned int') 00199 qCondition['fillnum'].setData(int(fillnum)) 00200 if runmin: 00201 qConditionStr+=' and '+r+'.runnum>=:runmin' 00202 qCondition.extend('runmin','unsigned int') 00203 qCondition['runmin'].setData(runmin) 00204 if runmax: 00205 qConditionStr+=' and '+r+'.runnum<=:runmax' 00206 qCondition.extend('runmax','unsigned int') 00207 qCondition['runmax'].setData(runmax) 00208 if amodetag: 00209 qConditionStr+=' and '+r+'.amodetag=:amodetag' 00210 qCondition.extend('amodetag','string') 00211 qCondition['amodetag'].setData(amodetag) 00212 if l1keyPattern: 00213 qConditionStr+=' and regexp_like('+r+'.l1key,:l1keypattern)' 00214 qCondition.extend('l1keypattern','string') 00215 qCondition['l1keypattern'].setData(l1keyPattern) 00216 if hltkeyPattern: 00217 qConditionStr+=' and regexp_like('+r+'.hltkey,:hltkeypattern)' 00218 qCondition.extend('hltkeypattern','string') 00219 qCondition['hltkeypattern'].setData(hltkeyPattern) 00220 if nominalEnergy: 00221 emin=nominalEnergy*(1.0-energyFlut) 00222 emax=nominalEnergy*(1.0+energyFlut) 00223 qConditionStr+=' and '+l+'.nominalegev>=:emin and '+l+'.nominalegev<=:emax' 00224 qCondition.extend('emin','float') 00225 qCondition.extend('emax','float') 00226 qCondition['emin'].setData(emin) 00227 qCondition['emax'].setData(emax) 00228 qResult=coral.AttributeList() 00229 qResult.extend('runnum','unsigned int') 00230 qResult.extend('starttime','string') 00231 qHandle.defineOutput(qResult) 00232 qHandle.setCondition(qConditionStr,qCondition) 00233 qHandle.addToOutputList(r+'.RUNNUM','runnum') 00234 qHandle.addToOutputList('TO_CHAR('+r+'.STARTTIME,\'MM/DD/YY HH24:MI:SS\')','starttime') 00235 cursor=qHandle.execute() 00236 00237 while cursor.next(): 00238 starttimeStr=cursor.currentRow()['starttime'].data() 00239 runnum=cursor.currentRow()['runnum'].data() 00240 minTime=None 00241 maxTime=None 00242 if startT and stopT: 00243 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S') 00244 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S') 00245 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S') 00246 if runTime>=minTime and runTime<=maxTime and runnum not in result: 00247 result.append(runnum) 00248 elif startT is not None: 00249 minTime=lute.StrToDatetime(startT,customfm='%m/%d/%y %H:%M:%S') 00250 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S') 00251 if runTime>=minTime and runnum not in result: 00252 result.append(runnum) 00253 elif stopT is not None: 00254 maxTime=lute.StrToDatetime(stopT,customfm='%m/%d/%y %H:%M:%S') 00255 runTime=lute.StrToDatetime(starttimeStr,customfm='%m/%d/%y %H:%M:%S') 00256 if runTime<=maxTime and runnum not in result: 00257 result.append(runnum) 00258 else: 00259 if runnum not in result: 00260 result.append(runnum) 00261 except : 00262 del qHandle 00263 raise 00264 del qHandle 00265 return result
def dataDML::runsummary | ( | schema, | |
runnum, | |||
sessionflavor = '' |
|||
) |
select l1key,amodetag,egev,hltkey,fillnum,sequence,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum output: [l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),sequence(5),starttime(6),stoptime(7)]
Definition at line 266 of file dataDML.py.
Referenced by SiStripFineDelayHit::produce().
00267 : 00268 ''' 00269 select l1key,amodetag,egev,hltkey,fillnum,sequence,to_char(starttime),to_char(stoptime) from cmsrunsummary where runnum=:runnum 00270 output: [l1key(0),amodetag(1),egev(2),hltkey(3),fillnum(4),sequence(5),starttime(6),stoptime(7)] 00271 ''' 00272 result=[] 00273 qHandle=schema.newQuery() 00274 t=lumiTime.lumiTime() 00275 try: 00276 qHandle.addToTableList(nameDealer.cmsrunsummaryTableName()) 00277 qCondition=coral.AttributeList() 00278 qCondition.extend('runnum','unsigned int') 00279 qCondition['runnum'].setData(int(runnum)) 00280 qHandle.addToOutputList('L1KEY','l1key') 00281 qHandle.addToOutputList('AMODETAG','amodetag') 00282 qHandle.addToOutputList('EGEV','egev') 00283 qHandle.addToOutputList('HLTKEY','hltkey') 00284 qHandle.addToOutputList('FILLNUM','fillnum') 00285 qHandle.addToOutputList('SEQUENCE','sequence') 00286 if sessionflavor=='SQLite': 00287 qHandle.addToOutputList('STARTTIME','starttime') 00288 qHandle.addToOutputList('STOPTIME','stoptime') 00289 else: 00290 qHandle.addToOutputList('to_char(STARTTIME,\''+t.coraltimefm+'\')','starttime') 00291 qHandle.addToOutputList('to_char(STOPTIME,\''+t.coraltimefm+'\')','stoptime') 00292 qHandle.setCondition('RUNNUM=:runnum',qCondition) 00293 qResult=coral.AttributeList() 00294 qResult.extend('l1key','string') 00295 qResult.extend('amodetag','string') 00296 qResult.extend('egev','unsigned int') 00297 qResult.extend('hltkey','string') 00298 qResult.extend('fillnum','unsigned int') 00299 qResult.extend('sequence','string') 00300 qResult.extend('starttime','string') 00301 qResult.extend('stoptime','string') 00302 qHandle.defineOutput(qResult) 00303 cursor=qHandle.execute() 00304 while cursor.next(): 00305 result.append(cursor.currentRow()['l1key'].data()) 00306 result.append(cursor.currentRow()['amodetag'].data()) 00307 result.append(cursor.currentRow()['egev'].data()) 00308 result.append(cursor.currentRow()['hltkey'].data()) 00309 result.append(cursor.currentRow()['fillnum'].data()) 00310 result.append(cursor.currentRow()['sequence'].data()) 00311 result.append(cursor.currentRow()['starttime'].data()) 00312 result.append(cursor.currentRow()['stoptime'].data()) 00313 except : 00314 del qHandle 00315 raise 00316 del qHandle 00317 return result
def dataDML::trgLSById | ( | schema, | |
dataid, | |||
trgbitname = None , |
|||
trgbitnamepattern = None , |
|||
withL1Count = False , |
|||
withPrescale = False |
|||
) |
output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale)](4)]})
Definition at line 485 of file dataDML.py.
00486 : 00487 ''' 00488 output: (runnum,{cmslsnum:[deadtimecount(0),bitzerocount(1),bitzeroprescale(2),deadfrac(3),[(bitname,trgcount,prescale)](4)]}) 00489 ''' 00490 # print 'entering trgLSById ',dataid 00491 # t0=time.time() 00492 runnum=0 00493 result={} 00494 trgnamedict=[] 00495 if withPrescale or withL1Count: 00496 trgrundata=trgRunById(schema,dataid,trgbitname=trgbitname,trgbitnamepattern=trgbitnamepattern) 00497 trgnamedict=trgrundata[3] 00498 00499 qHandle=schema.newQuery() 00500 try: 00501 qHandle.addToTableList(nameDealer.lstrgTableName()) 00502 qHandle.addToOutputList('RUNNUM','runnum') 00503 qHandle.addToOutputList('CMSLSNUM','cmslsnum') 00504 qHandle.addToOutputList('DEADTIMECOUNT','deadtimecount') 00505 qHandle.addToOutputList('BITZEROCOUNT','bitzerocount') 00506 qHandle.addToOutputList('BITZEROPRESCALE','bitzeroprescale') 00507 qHandle.addToOutputList('DEADFRAC','deadfrac') 00508 if withPrescale: 00509 qHandle.addToOutputList('PRESCALEBLOB','prescalesblob') 00510 if withL1Count: 00511 qHandle.addToOutputList('TRGCOUNTBLOB','trgcountblob') 00512 qConditionStr='DATA_ID=:dataid' 00513 qCondition=coral.AttributeList() 00514 qCondition.extend('dataid','unsigned long long') 00515 qCondition['dataid'].setData(dataid) 00516 qResult=coral.AttributeList() 00517 qResult.extend('runnum','unsigned int') 00518 qResult.extend('cmslsnum','unsigned int') 00519 qResult.extend('deadtimecount','unsigned long long') 00520 qResult.extend('bitzerocount','unsigned int') 00521 qResult.extend('bitzeroprescale','unsigned int') 00522 qResult.extend('deadfrac','float') 00523 if withPrescale: 00524 qResult.extend('prescalesblob','blob') 00525 if withL1Count: 00526 qResult.extend('trgcountblob','blob') 00527 qHandle.defineOutput(qResult) 00528 qHandle.setCondition(qConditionStr,qCondition) 00529 cursor=qHandle.execute() 00530 while cursor.next(): 00531 runnum=cursor.currentRow()['runnum'].data() 00532 cmslsnum=cursor.currentRow()['cmslsnum'].data() 00533 deadtimecount=cursor.currentRow()['deadtimecount'].data() 00534 bitzerocount=cursor.currentRow()['bitzerocount'].data() 00535 bitzeroprescale=cursor.currentRow()['bitzeroprescale'].data() 00536 deadfrac=cursor.currentRow()['deadfrac'].data() 00537 if not result.has_key(cmslsnum): 00538 result[cmslsnum]=[] 00539 result[cmslsnum].append(deadtimecount) 00540 result[cmslsnum].append(bitzerocount) 00541 result[cmslsnum].append(bitzeroprescale) 00542 result[cmslsnum].append(deadfrac) 00543 prescalesblob=None 00544 trgcountblob=None 00545 if withPrescale: 00546 prescalesblob=cursor.currentRow()['prescalesblob'].data() 00547 if withL1Count: 00548 trgcountblob=cursor.currentRow()['trgcountblob'].data() 00549 prescales=[] 00550 trgcounts=[] 00551 if prescalesblob: 00552 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ### 00553 prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'l') 00554 else: 00555 prescales=CommonUtil.unpackBlobtoArray(prescalesblob,'I') 00556 if trgcountblob: 00557 if runnum <150008: ###WORKAROUND PATCH!! because the 2010 blobs were packed as type l ### 00558 trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'l') 00559 else: 00560 trgcounts=CommonUtil.unpackBlobtoArray(trgcountblob,'I') 00561 00562 bitinfo=[] 00563 for (bitidx,thisbitname) in trgnamedict: 00564 thispresc=None 00565 thistrgcount=None 00566 if prescales: 00567 thispresc=prescales[bitidx] 00568 if trgcounts: 00569 thistrgcount=trgcounts[bitidx] 00570 thisbitinfo=(thisbitname,thistrgcount,thispresc) 00571 bitinfo.append(thisbitinfo) 00572 result[cmslsnum].append(bitinfo) 00573 except: 00574 del qHandle 00575 raise 00576 del qHandle 00577 # t1=time.time() 00578 # print 'trgLSById time ',t1-t0 return (runnum,result)
def dataDML::trgRunById | ( | schema, | |
dataid, | |||
trgbitname = None , |
|||
trgbitnamepattern = None |
|||
) |
query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB from trgdata where DATA_ID=:dataid output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3)] -- runnumber -- original source database name -- deadtime norm bitname -- bitnamedict [(bitidx,bitname),...]
Definition at line 426 of file dataDML.py.
00427 : 00428 ''' 00429 query: select RUNNUM,SOURCE,BITZERONAME,BITNAMECLOB from trgdata where DATA_ID=:dataid 00430 00431 output: [runnum(0),datasource(1),bitzeroname(2),bitnamedict(3)] 00432 -- runnumber 00433 -- original source database name 00434 -- deadtime norm bitname 00435 -- bitnamedict [(bitidx,bitname),...] 00436 ''' 00437 result=[] 00438 qHandle=schema.newQuery() 00439 runnum=None 00440 datasource=None 00441 bitzeroname=None 00442 bitnamedict=[] 00443 try: 00444 qHandle.addToTableList(nameDealer.trgdataTableName()) 00445 qHandle.addToOutputList('RUNNUM','runnum') 00446 qHandle.addToOutputList('SOURCE','source') 00447 qHandle.addToOutputList('BITZERONAME','bitzeroname') 00448 qHandle.addToOutputList('BITNAMECLOB','bitnameclob') 00449 qCondition=coral.AttributeList() 00450 qCondition.extend('dataid','unsigned long long') 00451 qCondition['dataid'].setData(dataid) 00452 qResult=coral.AttributeList() 00453 qResult.extend('runnum','unsigned int') 00454 qResult.extend('source','string') 00455 qResult.extend('bitzeroname','string') 00456 qResult.extend('bitnameclob','string') 00457 qHandle.defineOutput(qResult) 00458 qHandle.setCondition('DATA_ID=:dataid',qCondition) 00459 cursor=qHandle.execute() 00460 bitnameclob=None 00461 bitnames=[] 00462 while cursor.next(): 00463 runnum=cursor.currentRow()['runnum'].data() 00464 source=cursor.currentRow()['source'].data() 00465 bitzeroname=cursor.currentRow()['bitzeroname'].data() 00466 bitnameclob=cursor.currentRow()['bitnameclob'].data() 00467 if bitnameclob: 00468 bitnames=bitnameclob.split(',') 00469 for trgnameidx,trgname in enumerate(bitnames): 00470 if trgbitname : 00471 if trgname==trgbitname: 00472 bitnamedict.append((trgnameidx,trgname)) 00473 break 00474 elif trgbitnamepattern: 00475 if fnmatch.fnmatch(trgname,trgbitnamepattern): 00476 bitnamedict.append((trgnameidx,trgname)) 00477 else: 00478 bitnamedict.append((trgnameidx,trgname)) 00479 result=[runnum,source,bitzeroname,bitnamedict] 00480 except : 00481 del qHandle 00482 raise 00483 del qHandle 00484 return result
tuple dataDML::branchinfo = (branchid,'DATA') |
Definition at line 1765 of file dataDML.py.
Referenced by TrackerMap::TrackerMap().
tuple dataDML::datainfo = revisionDML.createBranch(schema,'DATA','TRUNK',comment='hold data') |
Definition at line 1753 of file dataDML.py.
tuple dataDML::hltdata = generateDummyData.hlt(schema,20) |
Definition at line 1781 of file dataDML.py.
list dataDML::hltlsdata = hltdata[2] |
Definition at line 1783 of file dataDML.py.
list dataDML::hltrundata = [hltdata[0],hltdata[1]] |
Definition at line 1782 of file dataDML.py.
Referenced by lumi::RevisionDML::insertHltRunData(), and lumi::HLTV32DB::writeHltDataToSchema2().
tuple dataDML::hlttrgmap = generateDummyData.hlttrgmap(schema) |
Definition at line 1769 of file dataDML.py.
tuple dataDML::latestNorms = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.luminormTableName(),luminormentry_id,normrevlist) |
Definition at line 1792 of file dataDML.py.
tuple dataDML::latestrevision = revisionDML.latestDataRevisionOfEntry(schema,nameDealer.lumidataTableName(),lumientry_id,revlist) |
Definition at line 1800 of file dataDML.py.
tuple dataDML::lumidummydata = generateDummyData.lumiSummary(schema,20) |
Definition at line 1771 of file dataDML.py.
tuple dataDML::lumientry_id = revisionDML.entryInBranch(schema,nameDealer.lumidataTableName(),'1211','DATA') |
Definition at line 1799 of file dataDML.py.
list dataDML::lumilsdata = lumidummydata[1] |
Definition at line 1773 of file dataDML.py.
tuple dataDML::luminormentry_id = revisionDML.entryInBranch(schema,nameDealer.luminormTableName(),'pp7TeV','NORM') |
Definition at line 1791 of file dataDML.py.
list dataDML::lumirundata = [lumidummydata[0]] |
Definition at line 1772 of file dataDML.py.
Referenced by lumi::RevisionDML::insertLumiRunData(), and lumi::Lumi2DB::writeAllLumiDataToSchema2().
string dataDML::myconstr = 'oracle://devdb10/cms_xiezhen_dev' |
Definition at line 1741 of file dataDML.py.
tuple dataDML::normbranchinfo = (normbranchid,'NORM') |
Definition at line 1761 of file dataDML.py.
tuple dataDML::norminfo = revisionDML.createBranch(schema,'NORM','TRUNK',comment='hold normalization factor') |
Definition at line 1755 of file dataDML.py.
tuple dataDML::normrevlist = revisionDML.revisionsInBranchName(schema,'NORM') |
Definition at line 1790 of file dataDML.py.
tuple dataDML::revlist = revisionDML.revisionsInBranchName(schema,'DATA') |
Definition at line 1797 of file dataDML.py.
tuple dataDML::runsummarydata = generateDummyData.runsummary(schema,'PROTPHYS',3500) |
Definition at line 1767 of file dataDML.py.
tuple dataDML::schema = session.nominalSchema() |
Definition at line 1744 of file dataDML.py.
tuple dataDML::session = svc.openSession(isReadOnly=False,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')]) |
Definition at line 1743 of file dataDML.py.
tuple dataDML::svc = sessionManager.sessionManager(myconstr,authpath='/afs/cern.ch/user/x/xiezhen',debugON=False) |
Definition at line 1742 of file dataDML.py.
tuple dataDML::tables = lumidbDDL.createTables(schema) |
Definition at line 1748 of file dataDML.py.
Referenced by ora::SchemaUtils::cleanUp().
tuple dataDML::trgdata = generateDummyData.trg(schema,20) |
Definition at line 1776 of file dataDML.py.
tuple dataDML::trgentry_id = revisionDML.entryInBranch(schema,nameDealer.trgdataTableName(),'1222','DATA') |
Definition at line 1805 of file dataDML.py.
list dataDML::trglsdata = trgdata[3] |
Definition at line 1778 of file dataDML.py.
list dataDML::trgrundata = [trgdata[0],trgdata[1],trgdata[2]] |
Definition at line 1777 of file dataDML.py.
Referenced by lumi::RevisionDML::insertTrgRunData(), and lumi::TRGScalers2DB::writeTrgDataToSchema2().
tuple dataDML::trunkinfo = revisionDML.createBranch(schema,'TRUNK',None,comment='main') |
Definition at line 1751 of file dataDML.py.