5 from RecoLuminosity.LumiDB
import argparse
20 select lsnr,counts,prescale from CMS_GT_MON.GT_MON_TRIG_ALGO_VIEW where runnr=:runnumber and algobit=:bitnum order by lsnr
24 dbsession.transaction().
start(
True)
25 schema=dbsession.schema(c.gtmonschema)
27 raise 'cannot connect to schema',c.gtmonschema
28 if not schema.existsView(c.algoviewname):
29 raise 'non-existing view',c.algoviewname
31 bitOutput=coral.AttributeList()
32 bitOutput.extend(
"lsnr",
"unsigned int")
33 bitOutput.extend(
"algocount",
"unsigned int")
34 bitBindVarList=coral.AttributeList()
35 bitBindVarList.extend(
"runnumber",
"unsigned int")
36 bitBindVarList.extend(
"bitnum",
"unsigned int")
37 bitBindVarList[
"runnumber"].setData(int(runnum))
38 bitBindVarList[
"bitnum"].setData(0)
40 query=schema.newQuery()
41 query.addToTableList(c.algoviewname)
42 query.addToOutputList(
'LSNR',
'lsnr')
43 query.addToOutputList(
'COUNTS',
'algocount')
44 query.setCondition(
'RUNNR=:runnumber AND ALGOBIT=:bitnum',bitBindVarList)
45 query.addToOrderList(
'lsnr')
46 query.defineOutput(bitOutput)
48 cursor=query.execute()
50 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
51 algocount=cursor.currentRow()[
'algocount'].
data()
52 result[cmslsnum]=algocount
54 dbsession.transaction().commit()
57 except Exception
as e:
59 dbsession.transaction().rollback()
64 select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr;
68 dbsession.transaction().
start(
True)
69 schema=dbsession.schema(c.gtmonschema)
71 raise 'cannot connect to schema',c.gtmonschema
72 if not schema.existsView(c.deadviewname):
73 raise 'non-existing view',c.deadviewname
75 deadOutput=coral.AttributeList()
76 deadOutput.extend(
"lsnr",
"unsigned int")
77 deadOutput.extend(
"deadcount",
"unsigned long long")
79 deadBindVarList=coral.AttributeList()
80 deadBindVarList.extend(
"runnumber",
"unsigned int")
81 deadBindVarList.extend(
"countername",
"string")
82 deadBindVarList[
"runnumber"].setData(int(runnum))
83 deadBindVarList[
"countername"].setData(
'DeadtimeBeamActive')
85 query=schema.newQuery()
86 query.addToTableList(c.deadviewname)
87 query.addToOutputList(
'LSNR',
'lsnr')
88 query.addToOutputList(
'COUNTS',
'deadcount')
89 query.setCondition(
'RUNNR=:runnumber AND DEADCOUNTER=:countername',deadBindVarList)
90 query.addToOrderList(
'lsnr')
91 query.defineOutput(deadOutput)
93 cursor=query.execute()
95 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
96 deadcount=cursor.currentRow()[
'deadcount'].
data()
97 result[cmslsnum]=deadcount
99 dbsession.transaction().commit()
101 except Exception
as e:
103 dbsession.transaction().rollback()
109 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to trigger DB(required)')
110 parser.add_argument(
'-P',dest=
'authpath',action=
'store',required=
True,help=
'path to authentication file')
111 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',required=
True,help=
'run number')
112 parser.add_argument(
'action',choices=[
'deadtime',
'deadfraction'],help=
'dump deadtime beamacrive count')
113 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug')
114 args=parser.parse_args()
115 runnumber=args.runnumber
116 c.gtmondb=args.connect
117 if args.authpath
and len(args.authpath)!=0:
118 os.environ[
'CORAL_AUTH_PATH']=args.authpath
119 svc=coral.ConnectionService()
120 session=svc.connect(c.gtmondb,accessMode=coral.access_ReadOnly)
121 session.typeConverter().setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)")
122 session.typeConverter().setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)")
124 msg=coral.MessageStream(
'')
125 msg.setMsgVerbosity(coral.message_Level_Debug)
127 if args.action ==
'deadtime':
129 if deadresult
and len(deadresult)!=0:
130 print 'run',runnumber
132 for cmsls,deadcount
in deadresult.items():
133 print cmsls,deadcount
135 print 'no deadtime found for run ',runnumber
137 if args.action ==
'deadfraction':
140 if deadresult
and len(deadresult)!=0:
141 print 'run',runnumber
142 print 'ls deadfraction'
143 for cmsls,deadcount
in deadresult.items():
144 bitzero_count=bitzeroresult[cmsls]
146 if int(runnumber)>=146315:
147 bitzero_prescale=17.0
149 print cmsls,
'no beam'
151 print cmsls,
'%.5f'%float(float(deadcount)/(float(bitzero_count)*bitzero_prescale))
153 print 'no deadtime found for run ',runnumber
158 if __name__==
'__main__':
char data[epos_bytes_allocation]