Classes | |
class | constants |
Functions | |
def | bitzeroForRun |
def | deadcountForRun |
def | main |
Variables | |
string | VERSION = '1.02' |
def dumpTrg::bitzeroForRun | ( | dbsession, | |
c, | |||
runnum | |||
) |
select lsnr,counts,prescale from CMS_GT_MON.GT_MON_TRIG_ALGO_VIEW where runnr=:runnumber and algobit=:bitnum order by lsnr
Definition at line 18 of file dumpTrg.py.
00019 : 00020 ''' 00021 select lsnr,counts,prescale from CMS_GT_MON.GT_MON_TRIG_ALGO_VIEW where runnr=:runnumber and algobit=:bitnum order by lsnr 00022 ''' 00023 result={} 00024 try: 00025 dbsession.transaction().start(True) 00026 schema=dbsession.schema(c.gtmonschema) 00027 if not schema: 00028 raise 'cannot connect to schema',c.gtmonschema 00029 if not schema.existsView(c.algoviewname): 00030 raise 'non-existing view',c.algoviewname 00031 00032 bitOutput=coral.AttributeList() 00033 bitOutput.extend("lsnr","unsigned int") 00034 bitOutput.extend("algocount","unsigned int") 00035 bitBindVarList=coral.AttributeList() 00036 bitBindVarList.extend("runnumber","unsigned int") 00037 bitBindVarList.extend("bitnum","unsigned int") 00038 bitBindVarList["runnumber"].setData(int(runnum)) 00039 bitBindVarList["bitnum"].setData(0) 00040 00041 query=schema.newQuery() 00042 query.addToTableList(c.algoviewname) 00043 query.addToOutputList('LSNR','lsnr') 00044 query.addToOutputList('COUNTS','algocount') 00045 query.setCondition('RUNNR=:runnumber AND ALGOBIT=:bitnum',bitBindVarList) 00046 query.addToOrderList('lsnr') 00047 query.defineOutput(bitOutput) 00048 00049 cursor=query.execute() 00050 while cursor.next(): 00051 cmslsnum=cursor.currentRow()['lsnr'].data() 00052 algocount=cursor.currentRow()['algocount'].data() 00053 result[cmslsnum]=algocount 00054 del query 00055 dbsession.transaction().commit() 00056 #print result 00057 return result 00058 except Exception,e: 00059 print str(e) 00060 dbsession.transaction().rollback() 00061 del dbsession
def dumpTrg::deadcountForRun | ( | dbsession, | |
c, | |||
runnum | |||
) |
select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr;
Definition at line 62 of file dumpTrg.py.
00063 : 00064 ''' 00065 select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr; 00066 ''' 00067 result={} 00068 try: 00069 dbsession.transaction().start(True) 00070 schema=dbsession.schema(c.gtmonschema) 00071 if not schema: 00072 raise 'cannot connect to schema',c.gtmonschema 00073 if not schema.existsView(c.deadviewname): 00074 raise 'non-existing view',c.deadviewname 00075 00076 deadOutput=coral.AttributeList() 00077 deadOutput.extend("lsnr","unsigned int") 00078 deadOutput.extend("deadcount","unsigned long long") 00079 00080 deadBindVarList=coral.AttributeList() 00081 deadBindVarList.extend("runnumber","unsigned int") 00082 deadBindVarList.extend("countername","string") 00083 deadBindVarList["runnumber"].setData(int(runnum)) 00084 deadBindVarList["countername"].setData('DeadtimeBeamActive') 00085 00086 query=schema.newQuery() 00087 query.addToTableList(c.deadviewname) 00088 query.addToOutputList('LSNR','lsnr') 00089 query.addToOutputList('COUNTS','deadcount') 00090 query.setCondition('RUNNR=:runnumber AND DEADCOUNTER=:countername',deadBindVarList) 00091 query.addToOrderList('lsnr') 00092 query.defineOutput(deadOutput) 00093 00094 cursor=query.execute() 00095 while cursor.next(): 00096 cmslsnum=cursor.currentRow()['lsnr'].data() 00097 deadcount=cursor.currentRow()['deadcount'].data() 00098 result[cmslsnum]=deadcount 00099 del query 00100 dbsession.transaction().commit() 00101 return result 00102 except Exception,e: 00103 print str(e) 00104 dbsession.transaction().rollback() 00105 del dbsession
def dumpTrg::main | ( | ) |
Definition at line 106 of file dumpTrg.py.
00107 : 00108 c=constants() 00109 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Dump GT info") 00110 parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to trigger DB(required)') 00111 parser.add_argument('-P',dest='authpath',action='store',required=True,help='path to authentication file') 00112 parser.add_argument('-r',dest='runnumber',action='store',required=True,help='run number') 00113 parser.add_argument('action',choices=['deadtime','deadfraction'],help='dump deadtime beamacrive count') 00114 parser.add_argument('--debug',dest='debug',action='store_true',help='debug') 00115 args=parser.parse_args() 00116 runnumber=args.runnumber 00117 c.gtmondb=args.connect 00118 if args.authpath and len(args.authpath)!=0: 00119 os.environ['CORAL_AUTH_PATH']=args.authpath 00120 svc=coral.ConnectionService() 00121 session=svc.connect(c.gtmondb,accessMode=coral.access_ReadOnly) 00122 session.typeConverter().setCppTypeForSqlType("unsigned int","NUMBER(10)") 00123 session.typeConverter().setCppTypeForSqlType("unsigned long long","NUMBER(20)") 00124 if args.debug: 00125 msg=coral.MessageStream('') 00126 msg.setMsgVerbosity(coral.message_Level_Debug) 00127 00128 if args.action == 'deadtime': 00129 deadresult=deadcountForRun(session,c,runnumber) 00130 if deadresult and len(deadresult)!=0: 00131 print 'run',runnumber 00132 print 'ls deadcount' 00133 for cmsls,deadcount in deadresult.items(): 00134 print cmsls,deadcount 00135 else: 00136 print 'no deadtime found for run ',runnumber 00137 00138 if args.action == 'deadfraction': 00139 deadresult=deadcountForRun(session,c,runnumber) 00140 bitzeroresult=bitzeroForRun(session,c,runnumber) 00141 if deadresult and len(deadresult)!=0: 00142 print 'run',runnumber 00143 print 'ls deadfraction' 00144 for cmsls,deadcount in deadresult.items(): 00145 bitzero_count=bitzeroresult[cmsls] 00146 bitzero_prescale=1.0 00147 if int(runnumber)>=146315: 00148 bitzero_prescale=17.0 00149 if bitzero_count==0: 00150 print cmsls,'no beam' 00151 else: 00152 print cmsls,'%.5f'%float(float(deadcount)/(float(bitzero_count)*bitzero_prescale)) 00153 else: 00154 print 'no deadtime found for run ',runnumber 00155 00156 del session 00157 del svc
string dumpTrg::VERSION = '1.02' |
Definition at line 2 of file dumpTrg.py.