def deliveredLumiForRunSection(dbsession,c,runnum,section): delivered=0.0 totalls=0 try: dbsession.transaction().start(True) schema=dbsession.nominalSchema() query=schema.newQuery() query.addToTableList(nameDealer.lumidetailTableName(),'lumidetail') query.addToTableList(nameDealer.lumisummaryTableName(),'lumisummary') queryCondition=coral.AttributeList() queryCondition.extend("runnumber","unsigned int") queryCondition.extend("section","unsigned int") queryCondition.extend("lumiversion","string") queryCondition["runnumber"].setData(int(runnum)) queryCondition["section"].setData(int(section)) queryCondition["lumiversion"].setData(c.LUMIVERSION) query.setCondition("lumisummary.RUNNUM=:runnumber and lumisummary.LUMIVERSION =:lumiversion AND lumisummary.LUMILSNUM=:section and lumisummary.LUMISUMMARY_ID=lumidetail.LUMISUMMARY_ID",queryCondition) query.addToOutputList("lumisummary.LUMILSNUM","lumils") query.addToOutputList("lumisummary.INSTLUMI","instlumi") query.addToOutputList("lumisummary.NUMORBIT","norbits") query.addToOutputList("lumidetail.BXLUMIVALUE","lumivalue") result=coral.AttributeList() result.extend("lumils","unsigned int") result.extend("instlumi","float") result.extend("norbits","unsigned int") result.extend("lumivalue","blob") query.defineOutput(result) cursor=query.execute() while cursor.next(): cmsls=cursor.currentRow()["lumils"].data() instlumi=cursor.currentRow()["instlumi"].data()*c.NORM norbits=cursor.currentRow()["norbits"].data() lumivalue=cursor.currentRow()["lumivalue"].data() lumibytes=lumivalue.readline() print "read bytes:", len(lumibytes) buffer=array.array('f') buffer.fromstring(lumibytes) print "got floats :", len(buffer) print "deliveredLumiForRunSection", runnum, section, cmsls, instlumi, norbits, lumivalue for ix in range(len(buffer)): if buffer[ix]>1.e-4: print ix, buffer[ix] cursor.close() del query dbsession.transaction().commit() except Exception,e: print str(e) dbsession.transaction().rollback() del dbsession
def dropLumi(dbsession): print('droping lumi db schema...') dbsession.transaction().start(False) schema = dbsession.nominalSchema() db = dbUtil.dbUtil(schema) db.dropTable(nameDealer.lumidetailTableName()) db.dropTable(nameDealer.cmsrunsummaryTableName()) db.dropTable(nameDealer.lumisummaryTableName()) db.dropTable(nameDealer.trgTableName()) db.dropTable(nameDealer.hltTableName()) db.dropTable(nameDealer.trghltMapTableName()) db.dropTable(nameDealer.lumiresultTableName()) db.dropTable(nameDealer.lumihltresultTableName()) db.dropTable(nameDealer.lumivalidationTableName()) dbsession.transaction().commit()
def dropLumi(dbsession): print('droping lumi db schema...') dbsession.transaction().start(False) schema=dbsession.nominalSchema() db=dbUtil.dbUtil(schema) db.dropTable( nameDealer.lumidetailTableName() ) db.dropTable( nameDealer.cmsrunsummaryTableName() ) db.dropTable( nameDealer.lumisummaryTableName() ) db.dropTable( nameDealer.trgTableName() ) db.dropTable( nameDealer.hltTableName() ) db.dropTable( nameDealer.trghltMapTableName() ) db.dropTable( nameDealer.lumiresultTableName() ) db.dropTable( nameDealer.lumihltresultTableName() ) db.dropTable( nameDealer.lumivalidationTableName() ) dbsession.transaction().commit()
def dropTables(schema, tablelist): try: db = dbUtil.dbUtil(schema) for tablename in tablelist: if tablename in [ nameDealer.luminormTableName(), nameDealer.lumidataTableName(), nameDealer.trgdataTableName(), nameDealer.hltdataTableName() ]: db.dropTable(nameDealer.idTableName(tablename)) db.dropTable(nameDealer.entryTableName(tablename)) db.dropTable(nameDealer.revmapTableName(tablename)) if tablename in [ nameDealer.trgTableName(), nameDealer.lumisummaryTableName(), nameDealer.lumisummaryv2TableName(), nameDealer.lumidetailTableName(), nameDealer.hltTableName() ]: db.dropTable(nameDealer.idTableName(tablename)) db.dropTable(tablename) except: raise
def createLumi(dbsession): print('creating lumi db schema...') dbsession.transaction().start(False) schema = dbsession.nominalSchema() db = dbUtil.dbUtil(schema) #cms run summary table cmsrunsummary = coral.TableDescription() cmsrunsummary.setName(nameDealer.cmsrunsummaryTableName()) cmsrunsummary.insertColumn('RUNNUM', 'unsigned int') cmsrunsummary.insertColumn('HLTKEY', 'string') cmsrunsummary.insertColumn('FILLNUM', 'unsigned int') cmsrunsummary.insertColumn('SEQUENCE', 'string') cmsrunsummary.insertColumn('STARTTIME', 'time stamp', 6) cmsrunsummary.insertColumn('STOPTIME', 'time stamp', 6) cmsrunsummary.setPrimaryKey('RUNNUM') cmsrunsummary.setNotNullConstraint('HLTKEY', True) cmsrunsummary.setNotNullConstraint('FILLNUM', True) cmsrunsummary.setNotNullConstraint('SEQUENCE', True) cmsrunsummary.createIndex('cmsrunsummary_fillnum', ('FILLNUM')) cmsrunsummary.createIndex('cmsrunsummary_startime', ('STARTTIME')) db.createTable(cmsrunsummary, False) #lumi summary table summary = coral.TableDescription() summary.setName(nameDealer.lumisummaryTableName()) summary.insertColumn('LUMISUMMARY_ID', 'unsigned long long') summary.insertColumn('RUNNUM', 'unsigned int') summary.insertColumn('CMSLSNUM', 'unsigned int') summary.insertColumn('LUMILSNUM', 'unsigned int') summary.insertColumn('LUMIVERSION', 'string') summary.insertColumn('DTNORM', 'float') summary.insertColumn('LHCNORM', 'float') summary.insertColumn('INSTLUMI', 'float') summary.insertColumn('INSTLUMIERROR', 'float') summary.insertColumn('INSTLUMIQUALITY', 'short') summary.insertColumn('CMSALIVE', 'short') summary.insertColumn('STARTORBIT', 'unsigned int') summary.insertColumn('NUMORBIT', 'unsigned int') summary.insertColumn('LUMISECTIONQUALITY', 'short') summary.insertColumn('BEAMENERGY', 'float') summary.insertColumn('BEAMSTATUS', 'string') summary.insertColumn('CMSBXINDEXBLOB', 'blob') summary.insertColumn('BEAMINTENSITYBLOB_1', 'blob') summary.insertColumn('BEAMINTENSITYBLOB_2', 'blob') summary.setPrimaryKey('LUMISUMMARY_ID') summary.setNotNullConstraint('RUNNUM', True) summary.setNotNullConstraint('CMSLSNUM', True) summary.setNotNullConstraint('LUMILSNUM', True) summary.setNotNullConstraint('LUMIVERSION', True) summary.setNotNullConstraint('DTNORM', True) summary.setNotNullConstraint('LHCNORM', True) summary.setNotNullConstraint('INSTLUMI', True) summary.setNotNullConstraint('INSTLUMIERROR', True) summary.setNotNullConstraint('INSTLUMIQUALITY', True) summary.setNotNullConstraint('CMSALIVE', True) summary.setNotNullConstraint('STARTORBIT', True) summary.setNotNullConstraint('NUMORBIT', True) summary.setNotNullConstraint('LUMISECTIONQUALITY', True) summary.setNotNullConstraint('BEAMENERGY', True) summary.setNotNullConstraint('BEAMSTATUS', True) summary.setUniqueConstraint(('RUNNUM', 'LUMIVERSION', 'LUMILSNUM')) summary.createIndex('lumisummary_runnum', ('RUNNUM')) db.createTable(summary, True) #lumi detail table detail = coral.TableDescription() detail.setName(nameDealer.lumidetailTableName()) detail.insertColumn('LUMIDETAIL_ID', 'unsigned long long') detail.insertColumn('LUMISUMMARY_ID', 'unsigned long long') detail.insertColumn('BXLUMIVALUE', 'blob') detail.insertColumn('BXLUMIERROR', 'blob') detail.insertColumn('BXLUMIQUALITY', 'blob') detail.insertColumn('ALGONAME', 'string') detail.setPrimaryKey('LUMIDETAIL_ID') detail.createForeignKey('DETAILSOURCE', 'LUMISUMMARY_ID', nameDealer.lumisummaryTableName(), 'LUMISUMMARY_ID') detail.setNotNullConstraint('BXLUMIVALUE', True) detail.setNotNullConstraint('BXLUMIERROR', True) detail.setNotNullConstraint('BXLUMIQUALITY', True) detail.setNotNullConstraint('ALGONAME', True) detail.setUniqueConstraint(('LUMISUMMARY_ID', 'ALGONAME')) db.createTable(detail, True) #trg table trg = coral.TableDescription() trg.setName(nameDealer.trgTableName()) trg.insertColumn('TRG_ID', 'unsigned long long') trg.insertColumn('RUNNUM', 'unsigned int') trg.insertColumn('CMSLSNUM', 'unsigned int') trg.insertColumn('BITNUM', 'unsigned int') trg.insertColumn('BITNAME', 'string') trg.insertColumn('TRGCOUNT', 'unsigned int') trg.insertColumn('DEADTIME', 'unsigned long long') trg.insertColumn('PRESCALE', 'unsigned int') trg.setNotNullConstraint('RUNNUM', True) trg.setNotNullConstraint('CMSLSNUM', True) trg.setNotNullConstraint('BITNUM', True) trg.setNotNullConstraint('BITNAME', True) trg.setNotNullConstraint('TRGCOUNT', True) trg.setNotNullConstraint('DEADTIME', True) trg.setNotNullConstraint('PRESCALE', True) trg.setPrimaryKey('TRG_ID') trg.createIndex('trg_runnum', ('RUNNUM')) db.createTable(trg, True) #hlt table hlt = coral.TableDescription() hlt.setName(nameDealer.hltTableName()) hlt.insertColumn('HLT_ID', 'unsigned long long') hlt.insertColumn('RUNNUM', 'unsigned int') hlt.insertColumn('CMSLSNUM', 'unsigned int') hlt.insertColumn('PATHNAME', 'string') hlt.insertColumn('INPUTCOUNT', 'unsigned int') hlt.insertColumn('ACCEPTCOUNT', 'unsigned int') hlt.insertColumn('PRESCALE', 'unsigned int') hlt.setPrimaryKey('HLT_ID') hlt.setNotNullConstraint('RUNNUM', True) hlt.setNotNullConstraint('CMSLSNUM', True) hlt.setNotNullConstraint('PATHNAME', True) hlt.setNotNullConstraint('INPUTCOUNT', True) hlt.setNotNullConstraint('ACCEPTCOUNT', True) hlt.setNotNullConstraint('PRESCALE', True) hlt.createIndex('hlt_runnum', ('RUNNUM')) db.createTable(hlt, True) #trghlt map table trghlt = coral.TableDescription() trghlt.setName(nameDealer.trghltMapTableName()) #trghlt.insertColumn( 'RUNNUM','unsigned int' ) trghlt.insertColumn('HLTKEY', 'string') trghlt.insertColumn('HLTPATHNAME', 'string') trghlt.insertColumn('L1SEED', 'string') trghlt.setNotNullConstraint('HLTKEY', True) trghlt.setNotNullConstraint('HLTPATHNAME', True) trghlt.setNotNullConstraint('L1SEED', True) db.createTable(trghlt, False) #lumiresult table lumiresult = coral.TableDescription() lumiresult.setName(nameDealer.lumiresultTableName()) lumiresult.insertColumn('RUNNUM', 'unsigned int') lumiresult.insertColumn('LUMIVERSION', 'string') lumiresult.insertColumn('DELIVEREDLUMI', 'float') lumiresult.insertColumn('RECORDEDLUMI', 'float') db.createTable(lumiresult, False) #lumihltresult table lumihltresult = coral.TableDescription() lumihltresult.setName(nameDealer.lumihltresultTableName()) lumihltresult.insertColumn('RUNNUM', 'unsigned int') lumihltresult.insertColumn('LUMIVERSION', 'string') lumihltresult.insertColumn('HLTPATH', 'float') lumihltresult.insertColumn('RECORDEDLUMI', 'float') db.createTable(lumihltresult, False) #lumivalidation table lumivalidation = coral.TableDescription() lumivalidation.setName(nameDealer.lumivalidationTableName()) lumivalidation.insertColumn('RUNNUM', 'unsigned int') lumivalidation.insertColumn('CMSLSNUM', 'unsigned int') lumivalidation.insertColumn('FLAG', 'string') lumivalidation.insertColumn('COMMENT', 'string') lumivalidation.setPrimaryKey(('RUNNUM', 'CMSLSNUM')) lumivalidation.setNotNullConstraint('FLAG', True) db.createTable(lumivalidation, False) dbsession.transaction().commit()
def createOldSchema(schema): ''' create tables of lumidb1 if not exist ''' try: created=[] db=dbUtil.dbUtil(schema) if not schema.existsTable(nameDealer.lumivalidationTableName()): lumivalidation=coral.TableDescription() lumivalidation.setName( nameDealer.lumivalidationTableName() ) lumivalidation.insertColumn( 'RUNNUM','unsigned int' ) lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' ) lumivalidation.insertColumn( 'FLAG','string',28,False ) lumivalidation.insertColumn( 'COMMENT','string',1024,False ) lumivalidation.setPrimaryKey(('RUNNUM','CMSLSNUM')) lumivalidation.setNotNullConstraint('FLAG',True) db.createTable(lumivalidation,withIdTable=False) created.append(nameDealer.lumivalidationTableName()) if not schema.existsTable(nameDealer.cmsrunsummaryTableName()): cmsrunsummary=coral.TableDescription() cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() ) cmsrunsummary.insertColumn('RUNNUM','unsigned int') cmsrunsummary.insertColumn('HLTKEY','string',128,False) cmsrunsummary.insertColumn('FILLNUM','unsigned int') cmsrunsummary.insertColumn('SEQUENCE','string',56,False) cmsrunsummary.insertColumn('STARTTIME','time stamp',6) cmsrunsummary.insertColumn('STOPTIME','time stamp',6) cmsrunsummary.setPrimaryKey('RUNNUM') cmsrunsummary.setNotNullConstraint('HLTKEY',True) cmsrunsummary.setNotNullConstraint('FILLNUM',True) cmsrunsummary.setNotNullConstraint('SEQUENCE',True) cmsrunsummary.createIndex('cmsrunsummary_fillnum',('FILLNUM')) cmsrunsummary.createIndex('cmsrunsummary_startime',('STARTTIME')) db.createTable(cmsrunsummary,withIdTable=False) created.append(nameDealer.cmsrunsummaryTableName()) if not schema.existsTable(nameDealer.lumisummaryTableName()): summary=coral.TableDescription() summary.setName( nameDealer.lumisummaryTableName() ) summary.insertColumn('LUMISUMMARY_ID','unsigned long long') summary.insertColumn('RUNNUM','unsigned int') summary.insertColumn('CMSLSNUM','unsigned int') summary.insertColumn('LUMILSNUM','unsigned int') summary.insertColumn('LUMIVERSION','string',28,False) summary.insertColumn('DTNORM','float') summary.insertColumn('LHCNORM','float') summary.insertColumn('CMSALIVE','short') summary.insertColumn('INSTLUMI','float') summary.insertColumn('INSTLUMIERROR','float') summary.insertColumn('INSTLUMIQUALITY','short') summary.insertColumn('BEAMSTATUS','string',28,False) summary.insertColumn('BEAMENERGY','float') summary.insertColumn('NUMORBIT','unsigned int') summary.insertColumn('STARTORBIT','unsigned int') summary.insertColumn('LUMISECTIONQUALITY','short') summary.insertColumn('CMSBXINDEXBLOB','blob') summary.insertColumn('BEAMINTENSITYBLOB_1','blob') summary.insertColumn('BEAMINTENSITYBLOB_2','blob') summary.setPrimaryKey('LUMISUMMARY_ID') summary.setNotNullConstraint('RUNNUM',True) summary.setNotNullConstraint('CMSLSNUM',True) summary.setNotNullConstraint('LUMILSNUM',True) summary.setNotNullConstraint('CMSALIVE',True) summary.setNotNullConstraint('LUMIVERSION',True) summary.setNotNullConstraint('DTNORM',True) summary.setNotNullConstraint('LHCNORM',True) summary.setNotNullConstraint('INSTLUMI',True) summary.setNotNullConstraint('INSTLUMIERROR',True) summary.setNotNullConstraint('INSTLUMIQUALITY',True) summary.setNotNullConstraint('STARTORBIT',True) summary.setNotNullConstraint('NUMORBIT',True) summary.setNotNullConstraint('LUMISECTIONQUALITY',True) summary.setNotNullConstraint('BEAMENERGY',True) summary.setNotNullConstraint('BEAMSTATUS',True) summary.setUniqueConstraint(('RUNNUM','LUMIVERSION','LUMILSNUM')) summary.createIndex('lumisummary_runnum',('RUNNUM')) db.createTable(summary,withIdTable=True) created.append(nameDealer.lumisummaryTableName()) if not schema.existsTable(nameDealer.lumidetailTableName()): detail=coral.TableDescription() detail.setName( nameDealer.lumidetailTableName() ) detail.insertColumn('LUMIDETAIL_ID','unsigned long long') detail.insertColumn('LUMISUMMARY_ID','unsigned long long') detail.insertColumn('BXLUMIVALUE','blob') detail.insertColumn('BXLUMIERROR','blob') detail.insertColumn('BXLUMIQUALITY','blob') detail.insertColumn('ALGONAME','string',28,False) detail.setPrimaryKey('LUMIDETAIL_ID') detail.createForeignKey('DETAILSOURCE','LUMISUMMARY_ID',nameDealer.lumisummaryTableName(),'LUMISUMMARY_ID') detail.setNotNullConstraint('BXLUMIVALUE',True) detail.setNotNullConstraint('BXLUMIERROR',True) detail.setNotNullConstraint('BXLUMIQUALITY',True) detail.setNotNullConstraint('ALGONAME',True) detail.setUniqueConstraint(('LUMISUMMARY_ID','ALGONAME')) db.createTable(detail,withIdTable=True) created.append(nameDealer.lumidetailTableName()) if not schema.existsTable(nameDealer.trgTableName()): trg=coral.TableDescription() trg.setName( nameDealer.trgTableName() ) trg.insertColumn('TRG_ID','unsigned long long') trg.insertColumn('RUNNUM','unsigned int') trg.insertColumn('CMSLSNUM','unsigned int') trg.insertColumn('BITNUM','unsigned int') trg.insertColumn('BITNAME','string',56,False) trg.insertColumn('TRGCOUNT','unsigned int') trg.insertColumn('DEADTIME','unsigned long long') trg.insertColumn('PRESCALE','unsigned int') trg.setNotNullConstraint('RUNNUM',True) trg.setNotNullConstraint('CMSLSNUM',True) trg.setNotNullConstraint('BITNUM',True) trg.setNotNullConstraint('BITNAME',True) trg.setNotNullConstraint('TRGCOUNT',True) trg.setNotNullConstraint('DEADTIME',True) trg.setNotNullConstraint('PRESCALE',True) trg.setPrimaryKey('TRG_ID') trg.createIndex('trg_runnum',('RUNNUM')) db.createTable(trg,withIdTable=True) created.append( nameDealer.trgTableName() ) if not schema.existsTable( nameDealer.hltTableName() ): hlt=coral.TableDescription() hlt.setName( nameDealer.hltTableName() ) hlt.insertColumn( 'HLT_ID','unsigned long long') hlt.insertColumn( 'RUNNUM','unsigned int') hlt.insertColumn( 'CMSLSNUM','unsigned int') hlt.insertColumn( 'PATHNAME','string',256,False) hlt.insertColumn( 'INPUTCOUNT','unsigned int') hlt.insertColumn( 'ACCEPTCOUNT','unsigned int') hlt.insertColumn( 'PRESCALE','unsigned int') hlt.setPrimaryKey( 'HLT_ID' ) hlt.setNotNullConstraint('RUNNUM',True) hlt.setNotNullConstraint('CMSLSNUM',True) hlt.setNotNullConstraint('PATHNAME',True) hlt.setNotNullConstraint('INPUTCOUNT',True) hlt.setNotNullConstraint('ACCEPTCOUNT',True) hlt.setNotNullConstraint('PRESCALE',True) hlt.createIndex('hlt_runnum',('RUNNUM')) db.createTable(hlt,withIdTable=True) created.append( nameDealer.hltTableName() ) if not schema.existsTable( nameDealer.trghltMapTableName() ): trghlt=coral.TableDescription() trghlt.setName( nameDealer.trghltMapTableName() ) trghlt.insertColumn( 'HLTKEY','string',128,False ) trghlt.insertColumn( 'HLTPATHNAME','string',256,False ) trghlt.insertColumn( 'L1SEED','string',1024,false ) trghlt.setNotNullConstraint('HLTKEY',True) trghlt.setNotNullConstraint('HLTPATHNAME',True) trghlt.setNotNullConstraint('L1SEED',True) db.createTable(trghlt,withIdTable=False) created.append( nameDealer.trghltMapTableName() ) return created except: raise
def dropTables(schema,tablelist): try: db=dbUtil.dbUtil(schema) for tablename in tablelist: if tablename in [nameDealer.luminormTableName(),nameDealer.lumidataTableName(),nameDealer.trgdataTableName(),nameDealer.hltdataTableName()]: db.dropTable( nameDealer.idTableName(tablename) ) db.dropTable( nameDealer.entryTableName(tablename) ) db.dropTable( nameDealer.revmapTableName(tablename) ) if tablename in [nameDealer.trgTableName(),nameDealer.lumisummaryTableName(),nameDealer.lumisummaryv2TableName(),nameDealer.lumidetailTableName(),nameDealer.hltTableName()]: db.dropTable( nameDealer.idTableName(tablename) ) db.dropTable( tablename ) except : raise
def createOldSchema(schema): ''' create tables of lumidb1 if not exist ''' try: created = [] db = dbUtil.dbUtil(schema) if not schema.existsTable(nameDealer.lumivalidationTableName()): lumivalidation = coral.TableDescription() lumivalidation.setName(nameDealer.lumivalidationTableName()) lumivalidation.insertColumn('RUNNUM', 'unsigned int') lumivalidation.insertColumn('CMSLSNUM', 'unsigned int') lumivalidation.insertColumn('FLAG', 'string', 28, False) lumivalidation.insertColumn('COMMENT', 'string', 1024, False) lumivalidation.setPrimaryKey(('RUNNUM', 'CMSLSNUM')) lumivalidation.setNotNullConstraint('FLAG', True) db.createTable(lumivalidation, withIdTable=False) created.append(nameDealer.lumivalidationTableName()) if not schema.existsTable(nameDealer.cmsrunsummaryTableName()): cmsrunsummary = coral.TableDescription() cmsrunsummary.setName(nameDealer.cmsrunsummaryTableName()) cmsrunsummary.insertColumn('RUNNUM', 'unsigned int') cmsrunsummary.insertColumn('HLTKEY', 'string', 128, False) cmsrunsummary.insertColumn('FILLNUM', 'unsigned int') cmsrunsummary.insertColumn('SEQUENCE', 'string', 56, False) cmsrunsummary.insertColumn('STARTTIME', 'time stamp', 6) cmsrunsummary.insertColumn('STOPTIME', 'time stamp', 6) cmsrunsummary.setPrimaryKey('RUNNUM') cmsrunsummary.setNotNullConstraint('HLTKEY', True) cmsrunsummary.setNotNullConstraint('FILLNUM', True) cmsrunsummary.setNotNullConstraint('SEQUENCE', True) cmsrunsummary.createIndex('cmsrunsummary_fillnum', ('FILLNUM')) cmsrunsummary.createIndex('cmsrunsummary_startime', ('STARTTIME')) db.createTable(cmsrunsummary, withIdTable=False) created.append(nameDealer.cmsrunsummaryTableName()) if not schema.existsTable(nameDealer.lumisummaryTableName()): summary = coral.TableDescription() summary.setName(nameDealer.lumisummaryTableName()) summary.insertColumn('LUMISUMMARY_ID', 'unsigned long long') summary.insertColumn('RUNNUM', 'unsigned int') summary.insertColumn('CMSLSNUM', 'unsigned int') summary.insertColumn('LUMILSNUM', 'unsigned int') summary.insertColumn('LUMIVERSION', 'string', 28, False) summary.insertColumn('DTNORM', 'float') summary.insertColumn('LHCNORM', 'float') summary.insertColumn('CMSALIVE', 'short') summary.insertColumn('INSTLUMI', 'float') summary.insertColumn('INSTLUMIERROR', 'float') summary.insertColumn('INSTLUMIQUALITY', 'short') summary.insertColumn('BEAMSTATUS', 'string', 28, False) summary.insertColumn('BEAMENERGY', 'float') summary.insertColumn('NUMORBIT', 'unsigned int') summary.insertColumn('STARTORBIT', 'unsigned int') summary.insertColumn('LUMISECTIONQUALITY', 'short') summary.insertColumn('CMSBXINDEXBLOB', 'blob') summary.insertColumn('BEAMINTENSITYBLOB_1', 'blob') summary.insertColumn('BEAMINTENSITYBLOB_2', 'blob') summary.setPrimaryKey('LUMISUMMARY_ID') summary.setNotNullConstraint('RUNNUM', True) summary.setNotNullConstraint('CMSLSNUM', True) summary.setNotNullConstraint('LUMILSNUM', True) summary.setNotNullConstraint('CMSALIVE', True) summary.setNotNullConstraint('LUMIVERSION', True) summary.setNotNullConstraint('DTNORM', True) summary.setNotNullConstraint('LHCNORM', True) summary.setNotNullConstraint('INSTLUMI', True) summary.setNotNullConstraint('INSTLUMIERROR', True) summary.setNotNullConstraint('INSTLUMIQUALITY', True) summary.setNotNullConstraint('STARTORBIT', True) summary.setNotNullConstraint('NUMORBIT', True) summary.setNotNullConstraint('LUMISECTIONQUALITY', True) summary.setNotNullConstraint('BEAMENERGY', True) summary.setNotNullConstraint('BEAMSTATUS', True) summary.setUniqueConstraint(('RUNNUM', 'LUMIVERSION', 'LUMILSNUM')) summary.createIndex('lumisummary_runnum', ('RUNNUM')) db.createTable(summary, withIdTable=True) created.append(nameDealer.lumisummaryTableName()) if not schema.existsTable(nameDealer.lumidetailTableName()): detail = coral.TableDescription() detail.setName(nameDealer.lumidetailTableName()) detail.insertColumn('LUMIDETAIL_ID', 'unsigned long long') detail.insertColumn('LUMISUMMARY_ID', 'unsigned long long') detail.insertColumn('BXLUMIVALUE', 'blob') detail.insertColumn('BXLUMIERROR', 'blob') detail.insertColumn('BXLUMIQUALITY', 'blob') detail.insertColumn('ALGONAME', 'string', 28, False) detail.setPrimaryKey('LUMIDETAIL_ID') detail.createForeignKey('DETAILSOURCE', 'LUMISUMMARY_ID', nameDealer.lumisummaryTableName(), 'LUMISUMMARY_ID') detail.setNotNullConstraint('BXLUMIVALUE', True) detail.setNotNullConstraint('BXLUMIERROR', True) detail.setNotNullConstraint('BXLUMIQUALITY', True) detail.setNotNullConstraint('ALGONAME', True) detail.setUniqueConstraint(('LUMISUMMARY_ID', 'ALGONAME')) db.createTable(detail, withIdTable=True) created.append(nameDealer.lumidetailTableName()) if not schema.existsTable(nameDealer.trgTableName()): trg = coral.TableDescription() trg.setName(nameDealer.trgTableName()) trg.insertColumn('TRG_ID', 'unsigned long long') trg.insertColumn('RUNNUM', 'unsigned int') trg.insertColumn('CMSLSNUM', 'unsigned int') trg.insertColumn('BITNUM', 'unsigned int') trg.insertColumn('BITNAME', 'string', 56, False) trg.insertColumn('TRGCOUNT', 'unsigned int') trg.insertColumn('DEADTIME', 'unsigned long long') trg.insertColumn('PRESCALE', 'unsigned int') trg.setNotNullConstraint('RUNNUM', True) trg.setNotNullConstraint('CMSLSNUM', True) trg.setNotNullConstraint('BITNUM', True) trg.setNotNullConstraint('BITNAME', True) trg.setNotNullConstraint('TRGCOUNT', True) trg.setNotNullConstraint('DEADTIME', True) trg.setNotNullConstraint('PRESCALE', True) trg.setPrimaryKey('TRG_ID') trg.createIndex('trg_runnum', ('RUNNUM')) db.createTable(trg, withIdTable=True) created.append(nameDealer.trgTableName()) if not schema.existsTable(nameDealer.hltTableName()): hlt = coral.TableDescription() hlt.setName(nameDealer.hltTableName()) hlt.insertColumn('HLT_ID', 'unsigned long long') hlt.insertColumn('RUNNUM', 'unsigned int') hlt.insertColumn('CMSLSNUM', 'unsigned int') hlt.insertColumn('PATHNAME', 'string', 256, False) hlt.insertColumn('INPUTCOUNT', 'unsigned int') hlt.insertColumn('ACCEPTCOUNT', 'unsigned int') hlt.insertColumn('PRESCALE', 'unsigned int') hlt.setPrimaryKey('HLT_ID') hlt.setNotNullConstraint('RUNNUM', True) hlt.setNotNullConstraint('CMSLSNUM', True) hlt.setNotNullConstraint('PATHNAME', True) hlt.setNotNullConstraint('INPUTCOUNT', True) hlt.setNotNullConstraint('ACCEPTCOUNT', True) hlt.setNotNullConstraint('PRESCALE', True) hlt.createIndex('hlt_runnum', ('RUNNUM')) db.createTable(hlt, withIdTable=True) created.append(nameDealer.hltTableName()) if not schema.existsTable(nameDealer.trghltMapTableName()): trghlt = coral.TableDescription() trghlt.setName(nameDealer.trghltMapTableName()) trghlt.insertColumn('HLTKEY', 'string', 128, False) trghlt.insertColumn('HLTPATHNAME', 'string', 256, False) trghlt.insertColumn('L1SEED', 'string', 1024, false) trghlt.setNotNullConstraint('HLTKEY', True) trghlt.setNotNullConstraint('HLTPATHNAME', True) trghlt.setNotNullConstraint('L1SEED', True) db.createTable(trghlt, withIdTable=False) created.append(nameDealer.trghltMapTableName()) return created except: raise
def createLumi(dbsession): print('creating lumi db schema...') dbsession.transaction().start(False) schema=dbsession.nominalSchema() db=dbUtil.dbUtil(schema) #cms run summary table cmsrunsummary=coral.TableDescription() cmsrunsummary.setName( nameDealer.cmsrunsummaryTableName() ) cmsrunsummary.insertColumn('RUNNUM','unsigned int') cmsrunsummary.insertColumn('HLTKEY','string') cmsrunsummary.insertColumn('FILLNUM','unsigned int') cmsrunsummary.insertColumn('SEQUENCE','string') cmsrunsummary.insertColumn('STARTTIME','time stamp',6) cmsrunsummary.insertColumn('STOPTIME','time stamp',6) cmsrunsummary.setPrimaryKey('RUNNUM') cmsrunsummary.setNotNullConstraint('HLTKEY',True) cmsrunsummary.setNotNullConstraint('FILLNUM',True) cmsrunsummary.setNotNullConstraint('SEQUENCE',True) cmsrunsummary.createIndex('cmsrunsummary_fillnum',('FILLNUM')) cmsrunsummary.createIndex('cmsrunsummary_startime',('STARTTIME')) db.createTable(cmsrunsummary,False) #lumi summary table summary=coral.TableDescription() summary.setName( nameDealer.lumisummaryTableName() ) summary.insertColumn('LUMISUMMARY_ID','unsigned long long') summary.insertColumn('RUNNUM','unsigned int') summary.insertColumn('CMSLSNUM','unsigned int') summary.insertColumn('LUMILSNUM','unsigned int') summary.insertColumn('LUMIVERSION','string') summary.insertColumn('DTNORM','float') summary.insertColumn('LHCNORM','float') summary.insertColumn('INSTLUMI','float') summary.insertColumn('INSTLUMIERROR','float') summary.insertColumn('INSTLUMIQUALITY','short') summary.insertColumn('CMSALIVE','short') summary.insertColumn('STARTORBIT','unsigned int') summary.insertColumn('NUMORBIT','unsigned int') summary.insertColumn('LUMISECTIONQUALITY','short') summary.insertColumn('BEAMENERGY','float') summary.insertColumn('BEAMSTATUS','string') summary.insertColumn('CMSBXINDEXBLOB','blob') summary.insertColumn('BEAMINTENSITYBLOB_1','blob') summary.insertColumn('BEAMINTENSITYBLOB_2','blob') summary.setPrimaryKey('LUMISUMMARY_ID') summary.setNotNullConstraint('RUNNUM',True) summary.setNotNullConstraint('CMSLSNUM',True) summary.setNotNullConstraint('LUMILSNUM',True) summary.setNotNullConstraint('LUMIVERSION',True) summary.setNotNullConstraint('DTNORM',True) summary.setNotNullConstraint('LHCNORM',True) summary.setNotNullConstraint('INSTLUMI',True) summary.setNotNullConstraint('INSTLUMIERROR',True) summary.setNotNullConstraint('INSTLUMIQUALITY',True) summary.setNotNullConstraint('CMSALIVE',True) summary.setNotNullConstraint('STARTORBIT',True) summary.setNotNullConstraint('NUMORBIT',True) summary.setNotNullConstraint('LUMISECTIONQUALITY',True) summary.setNotNullConstraint('BEAMENERGY',True) summary.setNotNullConstraint('BEAMSTATUS',True) summary.setUniqueConstraint(('RUNNUM','LUMIVERSION','LUMILSNUM')) summary.createIndex('lumisummary_runnum',('RUNNUM')) db.createTable(summary,True) #lumi detail table detail=coral.TableDescription() detail.setName( nameDealer.lumidetailTableName() ) detail.insertColumn('LUMIDETAIL_ID','unsigned long long') detail.insertColumn('LUMISUMMARY_ID','unsigned long long') detail.insertColumn('BXLUMIVALUE','blob') detail.insertColumn('BXLUMIERROR','blob') detail.insertColumn('BXLUMIQUALITY','blob') detail.insertColumn('ALGONAME','string') detail.setPrimaryKey('LUMIDETAIL_ID') detail.createForeignKey('DETAILSOURCE','LUMISUMMARY_ID',nameDealer.lumisummaryTableName(),'LUMISUMMARY_ID') detail.setNotNullConstraint('BXLUMIVALUE',True) detail.setNotNullConstraint('BXLUMIERROR',True) detail.setNotNullConstraint('BXLUMIQUALITY',True) detail.setNotNullConstraint('ALGONAME',True) detail.setUniqueConstraint(('LUMISUMMARY_ID','ALGONAME')) db.createTable(detail,True) #trg table trg=coral.TableDescription() trg.setName( nameDealer.trgTableName() ) trg.insertColumn('TRG_ID','unsigned long long') trg.insertColumn('RUNNUM','unsigned int') trg.insertColumn('CMSLSNUM','unsigned int') trg.insertColumn('BITNUM','unsigned int') trg.insertColumn('BITNAME','string') trg.insertColumn('TRGCOUNT','unsigned int') trg.insertColumn('DEADTIME','unsigned long long') trg.insertColumn('PRESCALE','unsigned int') trg.setNotNullConstraint('RUNNUM',True) trg.setNotNullConstraint('CMSLSNUM',True) trg.setNotNullConstraint('BITNUM',True) trg.setNotNullConstraint('BITNAME',True) trg.setNotNullConstraint('TRGCOUNT',True) trg.setNotNullConstraint('DEADTIME',True) trg.setNotNullConstraint('PRESCALE',True) trg.setPrimaryKey('TRG_ID') trg.createIndex('trg_runnum',('RUNNUM')) db.createTable(trg,True) #hlt table hlt=coral.TableDescription() hlt.setName( nameDealer.hltTableName() ) hlt.insertColumn( 'HLT_ID','unsigned long long') hlt.insertColumn( 'RUNNUM','unsigned int') hlt.insertColumn( 'CMSLSNUM','unsigned int') hlt.insertColumn( 'PATHNAME','string') hlt.insertColumn( 'INPUTCOUNT','unsigned int') hlt.insertColumn( 'ACCEPTCOUNT','unsigned int') hlt.insertColumn( 'PRESCALE','unsigned int') hlt.setPrimaryKey( 'HLT_ID' ) hlt.setNotNullConstraint('RUNNUM',True) hlt.setNotNullConstraint('CMSLSNUM',True) hlt.setNotNullConstraint('PATHNAME',True) hlt.setNotNullConstraint('INPUTCOUNT',True) hlt.setNotNullConstraint('ACCEPTCOUNT',True) hlt.setNotNullConstraint('PRESCALE',True) hlt.createIndex('hlt_runnum',('RUNNUM')) db.createTable(hlt,True) #trghlt map table trghlt=coral.TableDescription() trghlt.setName( nameDealer.trghltMapTableName() ) #trghlt.insertColumn( 'RUNNUM','unsigned int' ) trghlt.insertColumn( 'HLTKEY','string' ) trghlt.insertColumn( 'HLTPATHNAME','string' ) trghlt.insertColumn( 'L1SEED','string' ) trghlt.setNotNullConstraint('HLTKEY',True) trghlt.setNotNullConstraint('HLTPATHNAME',True) trghlt.setNotNullConstraint('L1SEED',True) db.createTable(trghlt,False) #lumiresult table lumiresult=coral.TableDescription() lumiresult.setName( nameDealer.lumiresultTableName() ) lumiresult.insertColumn( 'RUNNUM','unsigned int' ) lumiresult.insertColumn( 'LUMIVERSION','string' ) lumiresult.insertColumn( 'DELIVEREDLUMI','float' ) lumiresult.insertColumn( 'RECORDEDLUMI','float' ) db.createTable(lumiresult,False) #lumihltresult table lumihltresult=coral.TableDescription() lumihltresult.setName( nameDealer.lumihltresultTableName() ) lumihltresult.insertColumn( 'RUNNUM','unsigned int' ) lumihltresult.insertColumn( 'LUMIVERSION','string' ) lumihltresult.insertColumn( 'HLTPATH','float' ) lumihltresult.insertColumn( 'RECORDEDLUMI','float' ) db.createTable(lumihltresult,False) #lumivalidation table lumivalidation=coral.TableDescription() lumivalidation.setName( nameDealer.lumivalidationTableName() ) lumivalidation.insertColumn( 'RUNNUM','unsigned int' ) lumivalidation.insertColumn( 'CMSLSNUM','unsigned int' ) lumivalidation.insertColumn( 'FLAG','string' ) lumivalidation.insertColumn( 'COMMENT','string' ) lumivalidation.setPrimaryKey(('RUNNUM','CMSLSNUM')) lumivalidation.setNotNullConstraint('FLAG',True) db.createTable(lumivalidation,False) dbsession.transaction().commit()
def createLumi(dbsession): print "creating lumi db schema..." dbsession.transaction().start(False) schema = dbsession.nominalSchema() db = dbUtil.dbUtil(schema) # cms run summary table cmsrunsummary = coral.TableDescription() cmsrunsummary.setName(nameDealer.cmsrunsummaryTableName()) cmsrunsummary.insertColumn("RUNNUM", "unsigned int") cmsrunsummary.insertColumn("HLTKEY", "string") cmsrunsummary.insertColumn("FILLNUM", "unsigned int") cmsrunsummary.insertColumn("SEQUENCE", "string") cmsrunsummary.insertColumn("STARTTIME", "time stamp", 6) cmsrunsummary.insertColumn("STOPTIME", "time stamp", 6) cmsrunsummary.setPrimaryKey("RUNNUM") cmsrunsummary.setNotNullConstraint("HLTKEY", True) cmsrunsummary.setNotNullConstraint("FILLNUM", True) cmsrunsummary.setNotNullConstraint("SEQUENCE", True) cmsrunsummary.createIndex("cmsrunsummary_fillnum", ("FILLNUM")) cmsrunsummary.createIndex("cmsrunsummary_startime", ("STARTTIME")) db.createTable(cmsrunsummary, False) # lumi summary table summary = coral.TableDescription() summary.setName(nameDealer.lumisummaryTableName()) summary.insertColumn("LUMISUMMARY_ID", "unsigned long long") summary.insertColumn("RUNNUM", "unsigned int") summary.insertColumn("CMSLSNUM", "unsigned int") summary.insertColumn("LUMILSNUM", "unsigned int") summary.insertColumn("LUMIVERSION", "string") summary.insertColumn("DTNORM", "float") summary.insertColumn("LHCNORM", "float") summary.insertColumn("INSTLUMI", "float") summary.insertColumn("INSTLUMIERROR", "float") summary.insertColumn("INSTLUMIQUALITY", "short") summary.insertColumn("CMSALIVE", "short") summary.insertColumn("STARTORBIT", "unsigned int") summary.insertColumn("NUMORBIT", "unsigned int") summary.insertColumn("LUMISECTIONQUALITY", "short") summary.insertColumn("BEAMENERGY", "float") summary.insertColumn("BEAMSTATUS", "string") summary.insertColumn("CMSBXINDEXBLOB", "blob") summary.insertColumn("BEAMINTENSITYBLOB_1", "blob") summary.insertColumn("BEAMINTENSITYBLOB_2", "blob") summary.setPrimaryKey("LUMISUMMARY_ID") summary.setNotNullConstraint("RUNNUM", True) summary.setNotNullConstraint("CMSLSNUM", True) summary.setNotNullConstraint("LUMILSNUM", True) summary.setNotNullConstraint("LUMIVERSION", True) summary.setNotNullConstraint("DTNORM", True) summary.setNotNullConstraint("LHCNORM", True) summary.setNotNullConstraint("INSTLUMI", True) summary.setNotNullConstraint("INSTLUMIERROR", True) summary.setNotNullConstraint("INSTLUMIQUALITY", True) summary.setNotNullConstraint("CMSALIVE", True) summary.setNotNullConstraint("STARTORBIT", True) summary.setNotNullConstraint("NUMORBIT", True) summary.setNotNullConstraint("LUMISECTIONQUALITY", True) summary.setNotNullConstraint("BEAMENERGY", True) summary.setNotNullConstraint("BEAMSTATUS", True) summary.setUniqueConstraint(("RUNNUM", "LUMIVERSION", "LUMILSNUM")) summary.createIndex("lumisummary_runnum", ("RUNNUM")) db.createTable(summary, True) # lumi detail table detail = coral.TableDescription() detail.setName(nameDealer.lumidetailTableName()) detail.insertColumn("LUMIDETAIL_ID", "unsigned long long") detail.insertColumn("LUMISUMMARY_ID", "unsigned long long") detail.insertColumn("BXLUMIVALUE", "blob") detail.insertColumn("BXLUMIERROR", "blob") detail.insertColumn("BXLUMIQUALITY", "blob") detail.insertColumn("ALGONAME", "string") detail.setPrimaryKey("LUMIDETAIL_ID") detail.createForeignKey("DETAILSOURCE", "LUMISUMMARY_ID", nameDealer.lumisummaryTableName(), "LUMISUMMARY_ID") detail.setNotNullConstraint("BXLUMIVALUE", True) detail.setNotNullConstraint("BXLUMIERROR", True) detail.setNotNullConstraint("BXLUMIQUALITY", True) detail.setNotNullConstraint("ALGONAME", True) detail.setUniqueConstraint(("LUMISUMMARY_ID", "ALGONAME")) db.createTable(detail, True) # trg table trg = coral.TableDescription() trg.setName(nameDealer.trgTableName()) trg.insertColumn("TRG_ID", "unsigned long long") trg.insertColumn("RUNNUM", "unsigned int") trg.insertColumn("CMSLSNUM", "unsigned int") trg.insertColumn("BITNUM", "unsigned int") trg.insertColumn("BITNAME", "string") trg.insertColumn("TRGCOUNT", "unsigned int") trg.insertColumn("DEADTIME", "unsigned long long") trg.insertColumn("PRESCALE", "unsigned int") trg.setNotNullConstraint("RUNNUM", True) trg.setNotNullConstraint("CMSLSNUM", True) trg.setNotNullConstraint("BITNUM", True) trg.setNotNullConstraint("BITNAME", True) trg.setNotNullConstraint("TRGCOUNT", True) trg.setNotNullConstraint("DEADTIME", True) trg.setNotNullConstraint("PRESCALE", True) trg.setPrimaryKey("TRG_ID") trg.createIndex("trg_runnum", ("RUNNUM")) db.createTable(trg, True) # hlt table hlt = coral.TableDescription() hlt.setName(nameDealer.hltTableName()) hlt.insertColumn("HLT_ID", "unsigned long long") hlt.insertColumn("RUNNUM", "unsigned int") hlt.insertColumn("CMSLSNUM", "unsigned int") hlt.insertColumn("PATHNAME", "string") hlt.insertColumn("INPUTCOUNT", "unsigned int") hlt.insertColumn("ACCEPTCOUNT", "unsigned int") hlt.insertColumn("PRESCALE", "unsigned int") hlt.setPrimaryKey("HLT_ID") hlt.setNotNullConstraint("RUNNUM", True) hlt.setNotNullConstraint("CMSLSNUM", True) hlt.setNotNullConstraint("PATHNAME", True) hlt.setNotNullConstraint("INPUTCOUNT", True) hlt.setNotNullConstraint("ACCEPTCOUNT", True) hlt.setNotNullConstraint("PRESCALE", True) hlt.createIndex("hlt_runnum", ("RUNNUM")) db.createTable(hlt, True) # trghlt map table trghlt = coral.TableDescription() trghlt.setName(nameDealer.trghltMapTableName()) # trghlt.insertColumn( 'RUNNUM','unsigned int' ) trghlt.insertColumn("HLTKEY", "string") trghlt.insertColumn("HLTPATHNAME", "string") trghlt.insertColumn("L1SEED", "string") trghlt.setNotNullConstraint("HLTKEY", True) trghlt.setNotNullConstraint("HLTPATHNAME", True) trghlt.setNotNullConstraint("L1SEED", True) db.createTable(trghlt, False) # lumiresult table lumiresult = coral.TableDescription() lumiresult.setName(nameDealer.lumiresultTableName()) lumiresult.insertColumn("RUNNUM", "unsigned int") lumiresult.insertColumn("LUMIVERSION", "string") lumiresult.insertColumn("DELIVEREDLUMI", "float") lumiresult.insertColumn("RECORDEDLUMI", "float") db.createTable(lumiresult, False) # lumihltresult table lumihltresult = coral.TableDescription() lumihltresult.setName(nameDealer.lumihltresultTableName()) lumihltresult.insertColumn("RUNNUM", "unsigned int") lumihltresult.insertColumn("LUMIVERSION", "string") lumihltresult.insertColumn("HLTPATH", "float") lumihltresult.insertColumn("RECORDEDLUMI", "float") db.createTable(lumihltresult, False) # lumivalidation table lumivalidation = coral.TableDescription() lumivalidation.setName(nameDealer.lumivalidationTableName()) lumivalidation.insertColumn("RUNNUM", "unsigned int") lumivalidation.insertColumn("CMSLSNUM", "unsigned int") lumivalidation.insertColumn("FLAG", "string") lumivalidation.insertColumn("COMMENT", "string") lumivalidation.setPrimaryKey(("RUNNUM", "CMSLSNUM")) lumivalidation.setNotNullConstraint("FLAG", True) db.createTable(lumivalidation, False) dbsession.transaction().commit()