2 from __future__
import print_function
6 from RecoLuminosity.LumiDB
import argparse
20 select LUMISEGMENTNR,GTALGOCOUNTS from CMS_WBM.LEVEL1_TRIGGER_ALGO_CONDITIONS where RUNNUMBER=:runnumber and BIT=0 order by LUMISEGMENTNR 24 dbsession.transaction().
start(
True)
25 schema=dbsession.schema(c.wbmschema)
27 raise Exception(
'cannot connect to schema'+c.wbmschema)
28 if not schema.existsTable(c.algotable):
29 raise Exception(
'non-existing view'+c.algotable)
31 query=schema.newQuery()
32 algoBindVarList=coral.AttributeList()
33 algoBindVarList.extend(
"runnumber",
"unsigned int")
34 algoBindVarList.extend(
"bitnumber",
"unsigned int")
35 algoBindVarList[
"runnumber"].setData(
int(runnum))
36 algoBindVarList[
"bitnumber"].setData(
int(0))
37 query.addToTableList(c.algotable)
38 query.addToOutputList(
"LUMISEGMENTNR",
"lsnr")
39 query.addToOutputList(
'GTALGOCOUNTS',
'bitcount')
40 query.setCondition(
'RUNNUMBER=:runnumber AND BIT=:bitnumber',algoBindVarList)
41 query.addToOrderList(
'LUMISEGMENTNR')
43 bitzeroOutput=coral.AttributeList()
44 bitzeroOutput.extend(
"lsnr",
"unsigned int")
45 bitzeroOutput.extend(
'bitcount',
'unsigned int')
47 query.defineOutput(bitzeroOutput)
48 cursor=query.execute()
50 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
51 bitcount=cursor.currentRow()[
'bitcount'].
data()
52 result[cmslsnum]=bitcount
54 dbsession.transaction().commit()
56 except Exception
as e:
58 dbsession.transaction().rollback()
63 select DEADTIMEBEAMACTIVE from cms_wbm.LEVEL1_TRIGGER_CONDITIONS where RUNNUMBER=133881 order by LUMISEGMENTNR 67 dbsession.transaction().
start(
True)
68 schema=dbsession.schema(c.wbmschema)
70 raise Exception(
'cannot connect to schema '+c.wbmschema)
71 if not schema.existsTable(c.deadtable):
72 raise Exception(
'non-existing table '+c.deadtable)
74 deadOutput=coral.AttributeList()
75 deadOutput.extend(
"lsnr",
"unsigned int")
76 deadOutput.extend(
"deadcount",
"unsigned long long")
78 deadBindVarList=coral.AttributeList()
79 deadBindVarList.extend(
"RUNNUMBER",
"unsigned int")
80 deadBindVarList[
"RUNNUMBER"].setData(
int(runnum))
82 query=schema.newQuery()
83 query.addToTableList(c.deadtable)
84 query.addToOutputList(
'LUMISEGMENTNR',
'lsnr')
85 query.addToOutputList(
'DEADTIMEBEAMACTIVE',
'deadcount')
86 query.setCondition(
'RUNNUMBER=:runnumber',deadBindVarList)
87 query.addToOrderList(
'LUMISEGMENTNR')
88 query.defineOutput(deadOutput)
90 cursor=query.execute()
92 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
93 deadcount=cursor.currentRow()[
'deadcount'].
data()
94 result[cmslsnum]=deadcount
97 dbsession.transaction().commit()
99 except Exception
as e:
101 dbsession.transaction().rollback()
106 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description=
"Dump trigger info in wbm")
107 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to trigger DB(required)')
108 parser.add_argument(
'-P',dest=
'authpath',action=
'store',required=
True,help=
'path to authentication file')
109 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',required=
True,help=
'run number')
110 parser.add_argument(
'action',choices=[
'deadtime',
'deadfraction'],help=
'dump deadfraction')
111 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug')
112 args=parser.parse_args()
113 runnumber=args.runnumber
115 if args.authpath
and len(args.authpath)!=0:
116 os.environ[
'CORAL_AUTH_PATH']=args.authpath
118 svc=coral.ConnectionService()
120 session=svc.connect(c.wbmdb,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)
131 print(
'ls deadcount')
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 print(
'run',runnumber)
141 print(
'ls deadfraction')
142 if deadresult
and len(deadresult)!=0:
145 for cmsls,deadcount
in deadresult.items():
146 bitzero=bitzeroresult[cmsls]
148 if int(runnumber)>=146315:
149 bitzero_prescale=17.0
151 print(cmsls,
'no beam')
155 print(
'no deadtime found for run ',runnumber)
159 if __name__==
'__main__':
S & print(S &os, JobReport::InputFile const &f)
def bitzeroForRun(dbsession, c, runnum)
def deadcountForRun(dbsession, c, runnum)
char data[epos_bytes_allocation]