2 from __future__
import print_function
7 from RecoLuminosity.LumiDB
import argparse
19 '''select string_value from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.SCAL:FILLN' and rownum<=1; 24 dbsession.transaction().
start(
True)
25 schema=dbsession.schema(c.runinfoschema)
27 raise Exception(
'cannot connect to schema '+c.runinfoschema)
28 if not schema.existsTable(c.runsessionparameterTable):
29 raise Exception(
'non-existing table '+c.runsessionparameterTable)
31 fillOutput=coral.AttributeList()
32 fillOutput.extend(
"fillnum",
"string")
34 bindVarList=coral.AttributeList()
35 bindVarList.extend(
"name",
"string")
36 bindVarList.extend(
"runnumber",
"unsigned int")
38 bindVarList[
"name"].setData(c.fillnumname)
39 bindVarList[
"runnumber"].setData(
int(runnum))
41 query=schema.newQuery()
42 query.addToTableList(c.runsessionparameterTable)
43 query.addToOutputList(
'STRING_VALUE',
'value')
44 query.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',bindVarList)
45 query.limitReturnedRows(1)
46 query.defineOutput(fillOutput)
48 cursor=query.execute()
50 result=cursor.currentRow()[
'fillnum'].
data()
52 dbsession.transaction().commit()
55 except Exception
as e:
57 dbsession.transaction().rollback()
62 select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum 66 dbsession.transaction().
start(
True)
67 schema=dbsession.schema(c.runinfoschema)
69 raise Exception(
'cannot connect to schema '+c.runinfoschema)
70 if not schema.existsTable(c.runsessionparameterTable):
71 raise Exception(
'non-existing table '+c.runsessionparameterTable)
73 hltkeyOutput=coral.AttributeList()
74 hltkeyOutput.extend(
"runnum",
"unsigned int")
75 hltkeyOutput.extend(
"hltkey",
"string")
77 bindVarList=coral.AttributeList()
78 bindVarList.extend(
"name",
"string")
79 bindVarList.extend(
"runnumber",
"unsigned int")
81 bindVarList[
"name"].setData(c.hltconfname)
82 bindVarList[
"runnumber"].setData(
int(runnum))
84 query=schema.newQuery()
85 query.addToTableList(c.runsessionparameterTable)
86 query.addToOutputList(
'RUNNUMBER',
'runnumber')
87 query.addToOutputList(
'STRING_VALUE',
'value')
88 query.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',bindVarList)
89 query.defineOutput(hltkeyOutput)
91 cursor=query.execute()
93 runnum=cursor.currentRow()[
'runnum'].
data()
94 hltkey=cursor.currentRow()[
'hltkey'].
data()
97 dbsession.transaction().commit()
100 except Exception
as e:
102 dbsession.transaction().rollback()
107 select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum 111 dbsession.transaction().
start(
True)
112 schema=dbsession.schema(c.runinfoschema)
114 raise Exception(
'cannot connect to schema '+c.runinfoschema)
115 if not schema.existsTable(c.runsessionparameterTable):
116 raise Exception(
'non-existing table '+c.runsessionparameterTable)
118 l1keyOutput=coral.AttributeList()
119 l1keyOutput.extend(
"runnum",
"unsigned int")
120 l1keyOutput.extend(
"l1key",
"string")
122 bindVarList=coral.AttributeList()
123 bindVarList.extend(
"name",
"string")
124 bindVarList.extend(
"runnumber",
"unsigned int")
126 bindVarList[
"name"].setData(c.tsckeyname)
127 bindVarList[
"runnumber"].setData(
int(runnum))
129 query=schema.newQuery()
130 query.addToTableList(c.runsessionparameterTable)
131 query.addToOutputList(
'RUNNUMBER',
'runnumber')
132 query.addToOutputList(
'STRING_VALUE',
'value')
133 query.setCondition(
'NAME=:name AND RUNNUMBER=:runnumber',bindVarList)
134 query.defineOutput(l1keyOutput)
136 cursor=query.execute()
138 runnum=cursor.currentRow()[
'runnum'].
data()
139 l1key=cursor.currentRow()[
'l1key'].
data()
142 dbsession.transaction().commit()
145 except Exception
as e:
147 dbsession.transaction().rollback()
152 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description=
"Dump Run info")
153 parser.add_argument(
'-c',dest=
'connect',action=
'store',required=
True,help=
'connect string to trigger DB(required)')
154 parser.add_argument(
'-P',dest=
'authpath',action=
'store',required=
True,help=
'path to authentication file')
155 parser.add_argument(
'-r',dest=
'runnumber',action=
'store',required=
True,help=
'run number')
156 parser.add_argument(
'action',choices=[
'hltkey',
'l1key',
'fill'],help=
'information to show')
157 parser.add_argument(
'--debug',dest=
'debug',action=
'store_true',help=
'debug')
158 parser.add_argument(
'--collision-only',dest=
'collisiononly',action=
'store_true',help=
'return only collision runs')
159 args=parser.parse_args()
160 runnumber=args.runnumber
161 c.runinfodb=args.connect
162 if args.authpath
and len(args.authpath)!=0:
163 os.environ[
'CORAL_AUTH_PATH']=args.authpath
164 svc=coral.ConnectionService()
165 session=svc.connect(c.runinfodb,accessMode=coral.access_ReadOnly)
166 session.typeConverter().setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)")
167 session.typeConverter().setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)")
169 msg=coral.MessageStream(
'')
170 msg.setMsgVerbosity(coral.message_Level_Debug)
172 if args.action ==
'hltkey':
173 p=re.compile(
r'^/cdaq/physics/.+')
175 print(
'runnumber hltkey')
176 for runnum,hltkey
in result.items():
177 if not args.collisiononly:
179 if args.collisiononly
and re.match(p,hltkey):
183 if args.action ==
'l1key':
184 p=re.compile(
r'^TSC_.+_collisions_.+')
186 print(
'runnumber tsc_key')
187 for runnum,l1key
in result.items():
188 if not args.collisiononly:
190 if args.collisiononly
and re.match(p,l1key):
194 if args.action ==
'fill':
196 print(
'runnumber fill')
197 if not args.collisiononly:
198 print(runnumber,result)
201 print(runnumber,result)
205 if __name__==
'__main__':
def l1keyForRun(dbsession, c, runnum)
S & print(S &os, JobReport::InputFile const &f)
def hltkeyForRun(dbsession, c, runnum)
char data[epos_bytes_allocation]
def fillnumForRun(dbsession, c, runnum)