2 from __future__
import print_function
6 from RecoLuminosity.LumiDB
import argparse
21 select lsnr,counts,prescale from CMS_GT_MON.GT_MON_TRIG_ALGO_VIEW where runnr=:runnumber and algobit=:bitnum order by lsnr 25 dbsession.transaction().
start(
True)
26 schema=dbsession.schema(c.gtmonschema)
28 raise RuntimeError(
'cannot connect to schema '+c.gtmonschema)
29 if not schema.existsView(c.algoviewname):
30 raise RuntimeError(
'non-existing view '+c.algoviewname)
32 bitOutput=coral.AttributeList()
33 bitOutput.extend(
"lsnr",
"unsigned int")
34 bitOutput.extend(
"algocount",
"unsigned int")
35 bitBindVarList=coral.AttributeList()
36 bitBindVarList.extend(
"runnumber",
"unsigned int")
37 bitBindVarList.extend(
"bitnum",
"unsigned int")
38 bitBindVarList[
"runnumber"].setData(
int(runnum))
39 bitBindVarList[
"bitnum"].setData(0)
41 query=schema.newQuery()
42 query.addToTableList(c.algoviewname)
43 query.addToOutputList(
'LSNR',
'lsnr')
44 query.addToOutputList(
'COUNTS',
'algocount')
45 query.setCondition(
'RUNNR=:runnumber AND ALGOBIT=:bitnum',bitBindVarList)
46 query.addToOrderList(
'lsnr')
47 query.defineOutput(bitOutput)
49 cursor=query.execute()
51 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
52 algocount=cursor.currentRow()[
'algocount'].
data()
53 result[cmslsnum]=algocount
55 dbsession.transaction().commit()
58 except Exception
as e:
60 dbsession.transaction().rollback()
65 select counts,lsnr from cms_gt_mon.gt_mon_trig_dead_view where runnr=:runnumber and deadcounter=:countername order by lsnr; 69 dbsession.transaction().
start(
True)
70 schema=dbsession.schema(c.gtmonschema)
72 raise RuntimeError(
'cannot connect to schema '+c.gtmonschema)
73 if not schema.existsView(c.deadviewname):
74 raise RuntimeError(
'non-existing view '+c.deadviewname)
76 deadOutput=coral.AttributeList()
77 deadOutput.extend(
"lsnr",
"unsigned int")
78 deadOutput.extend(
"deadcount",
"unsigned long long")
80 deadBindVarList=coral.AttributeList()
81 deadBindVarList.extend(
"runnumber",
"unsigned int")
82 deadBindVarList.extend(
"countername",
"string")
83 deadBindVarList[
"runnumber"].setData(
int(runnum))
84 deadBindVarList[
"countername"].setData(
'DeadtimeBeamActive')
86 query=schema.newQuery()
87 query.addToTableList(c.deadviewname)
88 query.addToOutputList(
'LSNR',
'lsnr')
89 query.addToOutputList(
'COUNTS',
'deadcount')
90 query.setCondition(
'RUNNR=:runnumber AND DEADCOUNTER=:countername',deadBindVarList)
91 query.addToOrderList(
'lsnr')
92 query.defineOutput(deadOutput)
94 cursor=query.execute()
96 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
97 deadcount=cursor.currentRow()[
'deadcount'].
data()
98 result[cmslsnum]=deadcount
100 dbsession.transaction().commit()
102 except Exception
as e:
104 dbsession.transaction().rollback()
109 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description=
"Dump GT info")
110 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to trigger DB(required)')
111 parser.add_argument(
'-P',dest=
'authpath',action=
'store',required=
True,help=
'path to authentication file')
112 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',required=
True,help=
'run number')
113 parser.add_argument(
'action',choices=[
'deadtime',
'deadfraction'],help=
'dump deadtime beamacrive count')
114 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug')
115 args=parser.parse_args()
116 runnumber=args.runnumber
117 c.gtmondb=args.connect
118 if args.authpath
and len(args.authpath)!=0:
119 os.environ[
'CORAL_AUTH_PATH']=args.authpath
120 svc=coral.ConnectionService()
121 session=svc.connect(c.gtmondb,accessMode=coral.access_ReadOnly)
122 session.typeConverter().setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)")
123 session.typeConverter().setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)")
125 msg=coral.MessageStream(
'')
126 msg.setMsgVerbosity(coral.message_Level_Debug)
128 if args.action ==
'deadtime':
130 if deadresult
and len(deadresult)!=0:
131 print(
'run',runnumber)
132 print(
'ls deadcount')
133 for cmsls,deadcount
in deadresult.items():
134 print(cmsls,deadcount)
136 print(
'no deadtime found for run ',runnumber)
138 if args.action ==
'deadfraction':
141 if deadresult
and len(deadresult)!=0:
142 print(
'run',runnumber)
143 print(
'ls deadfraction')
144 for cmsls,deadcount
in deadresult.items():
145 bitzero_count=bitzeroresult[cmsls]
147 if int(runnumber)>=146315:
148 bitzero_prescale=17.0
150 print(cmsls,
'no beam')
154 print(
'no deadtime found for run ',runnumber)
159 if __name__==
'__main__':
def deadcountForRun(dbsession, c, runnum)
def bitzeroForRun(dbsession, c, runnum)
S & print(S &os, JobReport::InputFile const &f)
char data[epos_bytes_allocation]