CMS 3D CMS Logo

Classes | Functions | Variables

dumpWBM Namespace Reference

Classes

class  constants

Functions

def bitzeroForRun
def deadcountForRun
def main

Variables

string VERSION = '1.02'

Function Documentation

def dumpWBM::bitzeroForRun (   dbsession,
  c,
  runnum 
)
  select LUMISEGMENTNR,GTALGOCOUNTS from CMS_WBM.LEVEL1_TRIGGER_ALGO_CONDITIONS where RUNNUMBER=:runnumber and BIT=0 order by LUMISEGMENTNR

Definition at line 17 of file dumpWBM.py.

00018                                      :
00019     '''
00020       select LUMISEGMENTNR,GTALGOCOUNTS from CMS_WBM.LEVEL1_TRIGGER_ALGO_CONDITIONS where RUNNUMBER=:runnumber and BIT=0 order by LUMISEGMENTNR
00021     '''
00022     result={}
00023     try:
00024         dbsession.transaction().start(True)
00025         schema=dbsession.schema(c.wbmschema)
00026         if not schema:
00027             raise Exception,'cannot connect to schema'+c.wbmschema
00028         if not schema.existsTable(c.algotable):
00029             raise Exception,'non-existing view'+c.algotable
00030         
00031         query=schema.newQuery()
00032         algoBindVarList=coral.AttributeList()
00033         algoBindVarList.extend("runnumber","unsigned int")
00034         algoBindVarList.extend("bitnumber","unsigned int")
00035         algoBindVarList["runnumber"].setData(int(runnum))
00036         algoBindVarList["bitnumber"].setData(int(0))
00037         query.addToTableList(c.algotable)
00038         query.addToOutputList("LUMISEGMENTNR","lsnr")
00039         query.addToOutputList('GTALGOCOUNTS','bitcount')
00040         query.setCondition('RUNNUMBER=:runnumber AND BIT=:bitnumber',algoBindVarList)
00041         query.addToOrderList('LUMISEGMENTNR')
00042 
00043         bitzeroOutput=coral.AttributeList()
00044         bitzeroOutput.extend("lsnr","unsigned int")
00045         bitzeroOutput.extend('bitcount','unsigned int')
00046         
00047         query.defineOutput(bitzeroOutput)
00048         cursor=query.execute()
00049         while cursor.next():
00050             cmslsnum=cursor.currentRow()['lsnr'].data()
00051             bitcount=cursor.currentRow()['bitcount'].data()
00052             result[cmslsnum]=bitcount
00053         del query
00054         dbsession.transaction().commit()
00055         return result
00056     except Exception,e:
00057         print str(e)
00058         dbsession.transaction().rollback()
00059         del dbsession

def dumpWBM::deadcountForRun (   dbsession,
  c,
  runnum 
)
select DEADTIMEBEAMACTIVE from cms_wbm.LEVEL1_TRIGGER_CONDITIONS where RUNNUMBER=133881 order by LUMISEGMENTNR

Definition at line 60 of file dumpWBM.py.

00061                                        :
00062     '''
00063     select DEADTIMEBEAMACTIVE from cms_wbm.LEVEL1_TRIGGER_CONDITIONS where RUNNUMBER=133881 order by LUMISEGMENTNR
00064     '''
00065     result={}
00066     try:   
00067         dbsession.transaction().start(True)
00068         schema=dbsession.schema(c.wbmschema)
00069         if not schema:
00070             raise Exception,'cannot connect to schema '+c.wbmschema
00071         if not schema.existsTable(c.deadtable):
00072             raise Exception,'non-existing table '+c.deadtable
00073 
00074         deadOutput=coral.AttributeList()
00075         deadOutput.extend("lsnr","unsigned int")
00076         deadOutput.extend("deadcount","unsigned long long")
00077         
00078         deadBindVarList=coral.AttributeList()
00079         deadBindVarList.extend("RUNNUMBER","unsigned int")
00080         deadBindVarList["RUNNUMBER"].setData(int(runnum))
00081         
00082         query=schema.newQuery()
00083         query.addToTableList(c.deadtable)
00084         query.addToOutputList('LUMISEGMENTNR','lsnr')
00085         query.addToOutputList('DEADTIMEBEAMACTIVE','deadcount')
00086         query.setCondition('RUNNUMBER=:runnumber',deadBindVarList)
00087         query.addToOrderList('LUMISEGMENTNR')
00088         query.defineOutput(deadOutput)
00089         
00090         cursor=query.execute()
00091         while cursor.next():
00092             cmslsnum=cursor.currentRow()['lsnr'].data()
00093             deadcount=cursor.currentRow()['deadcount'].data()
00094             result[cmslsnum]=deadcount
00095             #print 'deadcount',deadcount
00096         del query
00097         dbsession.transaction().commit()
00098         return result
00099     except Exception,e:
00100         print str(e)
00101         dbsession.transaction().rollback()
00102         del dbsession
        
def dumpWBM::main ( )

Definition at line 103 of file dumpWBM.py.

00104           :
00105     c=constants()
00106     parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Dump trigger info in wbm")
00107     parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to trigger DB(required)')
00108     parser.add_argument('-P',dest='authpath',action='store',required=True,help='path to authentication file')
00109     parser.add_argument('-r',dest='runnumber',action='store',required=True,help='run number')
00110     parser.add_argument('action',choices=['deadtime','deadfraction'],help='dump deadfraction')
00111     parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
00112     args=parser.parse_args()
00113     runnumber=args.runnumber
00114     c.wbmdb=args.connect
00115     if args.authpath and len(args.authpath)!=0:
00116         os.environ['CORAL_AUTH_PATH']=args.authpath
00117     #print 'authpath ',args.authpath
00118     svc=coral.ConnectionService()
00119     #print 'about to access ',c.wbmdb
00120     session=svc.connect(c.wbmdb,accessMode=coral.access_ReadOnly)
00121     session.typeConverter().setCppTypeForSqlType("unsigned int","NUMBER(10)")
00122     session.typeConverter().setCppTypeForSqlType("unsigned long long","NUMBER(20)")
00123     if args.debug:
00124         msg=coral.MessageStream('')
00125         msg.setMsgVerbosity(coral.message_Level_Debug)
00126         
00127     if args.action == 'deadtime':
00128         deadresult=deadcountForRun(session,c,runnumber)
00129         if deadresult and len(deadresult)!=0:
00130             print 'run',runnumber
00131             print 'ls deadcount'
00132             for cmsls,deadcount in deadresult.items():
00133                 print cmsls,deadcount
00134         else:
00135             print 'no deadtime found for run ',runnumber
00136             
00137     if args.action == 'deadfraction':
00138         deadresult=deadcountForRun(session,c,runnumber)
00139         bitzeroresult=bitzeroForRun(session,c,runnumber)
00140         print 'run',runnumber
00141         print 'ls deadfraction'
00142         if deadresult and len(deadresult)!=0:
00143             #print 'run',runnumber
00144             #print 'ls deadfraction'
00145             for cmsls,deadcount in deadresult.items():
00146                 bitzero=bitzeroresult[cmsls]
00147                 bitzero_prescale=1.0
00148                 if int(runnumber)>=146315:
00149                     bitzero_prescale=17.0
00150                 if bitzero==0:
00151                     print cmsls,'no beam'
00152                 else:
00153                     print cmsls,'%.5f'%float(float(deadcount)/(float(bitzero)*bitzero_prescale))
00154         else:
00155             print 'no deadtime found for run ',runnumber
00156     del session
00157     del svc
        

Variable Documentation

string dumpWBM::VERSION = '1.02'

Definition at line 2 of file dumpWBM.py.