6 from RecoLuminosity.LumiDB
import argparse
18 '''select string_value from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.SCAL:FILLN' and rownum<=1;
23 dbsession.transaction().
start(
True)
24 schema=dbsession.schema(c.runinfoschema)
26 raise Exception(
'cannot connect to schema '+c.runinfoschema)
27 if not schema.existsTable(c.runsessionparameterTable):
28 raise Exception(
'non-existing table '+c.runsessionparameterTable)
30 fillOutput=coral.AttributeList()
31 fillOutput.extend(
"fillnum",
"string")
33 bindVarList=coral.AttributeList()
34 bindVarList.extend(
"name",
"string")
35 bindVarList.extend(
"runnumber",
"unsigned int")
37 bindVarList[
"name"].setData(c.fillnumname)
38 bindVarList[
"runnumber"].setData(int(runnum))
40 query=schema.newQuery()
41 query.addToTableList(c.runsessionparameterTable)
42 query.addToOutputList(
'STRING_VALUE',
'value')
43 query.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',bindVarList)
44 query.limitReturnedRows(1)
45 query.defineOutput(fillOutput)
47 cursor=query.execute()
49 result=cursor.currentRow()[
'fillnum'].
data()
51 dbsession.transaction().commit()
54 except Exception
as e:
56 dbsession.transaction().rollback()
61 select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum
65 dbsession.transaction().
start(
True)
66 schema=dbsession.schema(c.runinfoschema)
68 raise Exception(
'cannot connect to schema '+c.runinfoschema)
69 if not schema.existsTable(c.runsessionparameterTable):
70 raise Exception(
'non-existing table '+c.runsessionparameterTable)
72 hltkeyOutput=coral.AttributeList()
73 hltkeyOutput.extend(
"runnum",
"unsigned int")
74 hltkeyOutput.extend(
"hltkey",
"string")
76 bindVarList=coral.AttributeList()
77 bindVarList.extend(
"name",
"string")
78 bindVarList.extend(
"runnumber",
"unsigned int")
80 bindVarList[
"name"].setData(c.hltconfname)
81 bindVarList[
"runnumber"].setData(int(runnum))
83 query=schema.newQuery()
84 query.addToTableList(c.runsessionparameterTable)
85 query.addToOutputList(
'RUNNUMBER',
'runnumber')
86 query.addToOutputList(
'STRING_VALUE',
'value')
87 query.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',bindVarList)
88 query.defineOutput(hltkeyOutput)
90 cursor=query.execute()
92 runnum=cursor.currentRow()[
'runnum'].
data()
93 hltkey=cursor.currentRow()[
'hltkey'].
data()
96 dbsession.transaction().commit()
99 except Exception
as e:
101 dbsession.transaction().rollback()
106 select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum
110 dbsession.transaction().
start(
True)
111 schema=dbsession.schema(c.runinfoschema)
113 raise Exception(
'cannot connect to schema '+c.runinfoschema)
114 if not schema.existsTable(c.runsessionparameterTable):
115 raise Exception(
'non-existing table '+c.runsessionparameterTable)
117 l1keyOutput=coral.AttributeList()
118 l1keyOutput.extend(
"runnum",
"unsigned int")
119 l1keyOutput.extend(
"l1key",
"string")
121 bindVarList=coral.AttributeList()
122 bindVarList.extend(
"name",
"string")
123 bindVarList.extend(
"runnumber",
"unsigned int")
125 bindVarList[
"name"].setData(c.tsckeyname)
126 bindVarList[
"runnumber"].setData(int(runnum))
128 query=schema.newQuery()
129 query.addToTableList(c.runsessionparameterTable)
130 query.addToOutputList(
'RUNNUMBER',
'runnumber')
131 query.addToOutputList(
'STRING_VALUE',
'value')
132 query.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',bindVarList)
133 query.defineOutput(l1keyOutput)
135 cursor=query.execute()
137 runnum=cursor.currentRow()[
'runnum'].
data()
138 l1key=cursor.currentRow()[
'l1key'].
data()
141 dbsession.transaction().commit()
144 except Exception
as e:
146 dbsession.transaction().rollback()
152 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to trigger DB(required)')
153 parser.add_argument(
'-P',dest=
'authpath',action=
'store',required=
True,help=
'path to authentication file')
154 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',required=
True,help=
'run number')
155 parser.add_argument(
'action',choices=[
'hltkey',
'l1key',
'fill'],help=
'information to show')
156 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug')
157 parser.add_argument(
'--collision-only',dest=
'collisiononly',action=
'store_true',help=
'return only collision runs')
158 args=parser.parse_args()
159 runnumber=args.runnumber
160 c.runinfodb=args.connect
161 if args.authpath
and len(args.authpath)!=0:
162 os.environ[
'CORAL_AUTH_PATH']=args.authpath
163 svc=coral.ConnectionService()
164 session=svc.connect(c.runinfodb,accessMode=coral.access_ReadOnly)
165 session.typeConverter().setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)")
166 session.typeConverter().setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)")
168 msg=coral.MessageStream(
'')
169 msg.setMsgVerbosity(coral.message_Level_Debug)
171 if args.action ==
'hltkey':
172 p=re.compile(
r'^/cdaq/physics/.+')
174 print 'runnumber hltkey'
175 for runnum,hltkey
in result.items():
176 if not args.collisiononly:
178 if args.collisiononly
and re.match(p,hltkey):
182 if args.action ==
'l1key':
183 p=re.compile(
r'^TSC_.+_collisions_.+')
185 print 'runnumber tsc_key'
186 for runnum,l1key
in result.items():
187 if not args.collisiononly:
189 if args.collisiononly
and re.match(p,l1key):
193 if args.action ==
'fill':
195 print 'runnumber fill'
196 if not args.collisiononly:
197 print runnumber,result
200 print runnumber,result
204 if __name__==
'__main__':
char data[epos_bytes_allocation]