5 from RecoLuminosity.LumiDB
import argparse
19 select LUMISEGMENTNR,GTALGOCOUNTS from CMS_WBM.LEVEL1_TRIGGER_ALGO_CONDITIONS where RUNNUMBER=:runnumber and BIT=0 order by LUMISEGMENTNR 23 dbsession.transaction().
start(
True)
24 schema=dbsession.schema(c.wbmschema)
26 raise Exception(
'cannot connect to schema'+c.wbmschema)
27 if not schema.existsTable(c.algotable):
28 raise Exception(
'non-existing view'+c.algotable)
30 query=schema.newQuery()
31 algoBindVarList=coral.AttributeList()
32 algoBindVarList.extend(
"runnumber",
"unsigned int")
33 algoBindVarList.extend(
"bitnumber",
"unsigned int")
34 algoBindVarList[
"runnumber"].setData(
int(runnum))
35 algoBindVarList[
"bitnumber"].setData(
int(0))
36 query.addToTableList(c.algotable)
37 query.addToOutputList(
"LUMISEGMENTNR",
"lsnr")
38 query.addToOutputList(
'GTALGOCOUNTS',
'bitcount')
39 query.setCondition(
'RUNNUMBER=:runnumber AND BIT=:bitnumber',algoBindVarList)
40 query.addToOrderList(
'LUMISEGMENTNR')
42 bitzeroOutput=coral.AttributeList()
43 bitzeroOutput.extend(
"lsnr",
"unsigned int")
44 bitzeroOutput.extend(
'bitcount',
'unsigned int')
46 query.defineOutput(bitzeroOutput)
47 cursor=query.execute()
49 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
50 bitcount=cursor.currentRow()[
'bitcount'].
data()
51 result[cmslsnum]=bitcount
53 dbsession.transaction().commit()
55 except Exception
as e:
57 dbsession.transaction().rollback()
62 select DEADTIMEBEAMACTIVE from cms_wbm.LEVEL1_TRIGGER_CONDITIONS where RUNNUMBER=133881 order by LUMISEGMENTNR 66 dbsession.transaction().
start(
True)
67 schema=dbsession.schema(c.wbmschema)
69 raise Exception(
'cannot connect to schema '+c.wbmschema)
70 if not schema.existsTable(c.deadtable):
71 raise Exception(
'non-existing table '+c.deadtable)
73 deadOutput=coral.AttributeList()
74 deadOutput.extend(
"lsnr",
"unsigned int")
75 deadOutput.extend(
"deadcount",
"unsigned long long")
77 deadBindVarList=coral.AttributeList()
78 deadBindVarList.extend(
"RUNNUMBER",
"unsigned int")
79 deadBindVarList[
"RUNNUMBER"].setData(
int(runnum))
81 query=schema.newQuery()
82 query.addToTableList(c.deadtable)
83 query.addToOutputList(
'LUMISEGMENTNR',
'lsnr')
84 query.addToOutputList(
'DEADTIMEBEAMACTIVE',
'deadcount')
85 query.setCondition(
'RUNNUMBER=:runnumber',deadBindVarList)
86 query.addToOrderList(
'LUMISEGMENTNR')
87 query.defineOutput(deadOutput)
89 cursor=query.execute()
91 cmslsnum=cursor.currentRow()[
'lsnr'].
data()
92 deadcount=cursor.currentRow()[
'deadcount'].
data()
93 result[cmslsnum]=deadcount
96 dbsession.transaction().commit()
98 except Exception
as e:
100 dbsession.transaction().rollback()
106 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to trigger DB(required)')
107 parser.add_argument(
'-P',dest=
'authpath',action=
'store',required=
True,help=
'path to authentication file')
108 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',required=
True,help=
'run number')
109 parser.add_argument(
'action',choices=[
'deadtime',
'deadfraction'],help=
'dump deadfraction')
110 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug')
111 args=parser.parse_args()
112 runnumber=args.runnumber
114 if args.authpath
and len(args.authpath)!=0:
115 os.environ[
'CORAL_AUTH_PATH']=args.authpath
117 svc=coral.ConnectionService()
119 session=svc.connect(c.wbmdb,accessMode=coral.access_ReadOnly)
120 session.typeConverter().setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)")
121 session.typeConverter().setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)")
123 msg=coral.MessageStream(
'')
124 msg.setMsgVerbosity(coral.message_Level_Debug)
126 if args.action ==
'deadtime':
128 if deadresult
and len(deadresult)!=0:
129 print 'run',runnumber
131 for cmsls,deadcount
in deadresult.items():
132 print cmsls,deadcount
134 print 'no deadtime found for run ',runnumber
136 if args.action ==
'deadfraction':
139 print 'run',runnumber
140 print 'ls deadfraction' 141 if deadresult
and len(deadresult)!=0:
144 for cmsls,deadcount
in deadresult.items():
145 bitzero=bitzeroresult[cmsls]
147 if int(runnumber)>=146315:
148 bitzero_prescale=17.0
150 print cmsls,
'no beam' 152 print cmsls,
'%.5f'%
float(
float(deadcount)/(
float(bitzero)*bitzero_prescale))
154 print 'no deadtime found for run ',runnumber
158 if __name__==
'__main__':
def bitzeroForRun(dbsession, c, runnum)
def deadcountForRun(dbsession, c, runnum)
char data[epos_bytes_allocation]