test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
dumpRunInfo Namespace Reference

Classes

class  constants
 

Functions

def fillnumForRun
 
def hltkeyForRun
 
def l1keyForRun
 
def main
 

Variables

string VERSION = '1.02'
 

Function Documentation

def dumpRunInfo.fillnumForRun (   dbsession,
  c,
  runnum 
)
select string_value from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.SCAL:FILLN' and rownum<=1;

Definition at line 17 of file dumpRunInfo.py.

References AlCaHLTBitMon_QueryRunRegistry.data, and GetRecoTauVFromDQM_MC_cff.next.

Referenced by main().

17 
18 def fillnumForRun(dbsession,c,runnum):
19  '''select string_value from cms_runinfo.runsession_parameter where runnumber=129265 and name='CMS.SCAL:FILLN' and rownum<=1;
20 
21  '''
22  result=''
23  try:
24  dbsession.transaction().start(True)
25  schema=dbsession.schema(c.runinfoschema)
26  if not schema:
27  raise Exception('cannot connect to schema '+c.runinfoschema)
28  if not schema.existsTable(c.runsessionparameterTable):
29  raise Exception('non-existing table '+c.runsessionparameterTable)
30 
31  fillOutput=coral.AttributeList()
32  fillOutput.extend("fillnum","string")
33 
34  bindVarList=coral.AttributeList()
35  bindVarList.extend("name","string")
36  bindVarList.extend("runnumber","unsigned int")
37 
38  bindVarList["name"].setData(c.fillnumname)
39  bindVarList["runnumber"].setData(int(runnum))
40 
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)
47 
48  cursor=query.execute()
49  while next(cursor):
50  result=cursor.currentRow()['fillnum'].data()
51  del query
52  dbsession.transaction().commit()
53  #print result
54  return result
55  except Exception as e:
56  print str(e)
57  dbsession.transaction().rollback()
58  del dbsession
Definition: start.py:1
def fillnumForRun
Definition: dumpRunInfo.py:17
def dumpRunInfo.hltkeyForRun (   dbsession,
  c,
  runnum 
)
select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum 

Definition at line 59 of file dumpRunInfo.py.

References AlCaHLTBitMon_QueryRunRegistry.data, and GetRecoTauVFromDQM_MC_cff.next.

Referenced by main().

59 
60 def hltkeyForRun(dbsession,c,runnum):
61  '''
62  select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum
63  '''
64  result={}
65  try:
66  dbsession.transaction().start(True)
67  schema=dbsession.schema(c.runinfoschema)
68  if not schema:
69  raise Exception('cannot connect to schema '+c.runinfoschema)
70  if not schema.existsTable(c.runsessionparameterTable):
71  raise Exception('non-existing table '+c.runsessionparameterTable)
72 
73  hltkeyOutput=coral.AttributeList()
74  hltkeyOutput.extend("runnum","unsigned int")
75  hltkeyOutput.extend("hltkey","string")
76 
77  bindVarList=coral.AttributeList()
78  bindVarList.extend("name","string")
79  bindVarList.extend("runnumber","unsigned int")
80 
81  bindVarList["name"].setData(c.hltconfname)
82  bindVarList["runnumber"].setData(int(runnum))
83 
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)
90 
91  cursor=query.execute()
92  while next(cursor):
93  runnum=cursor.currentRow()['runnum'].data()
94  hltkey=cursor.currentRow()['hltkey'].data()
95  result[runnum]=hltkey
96  del query
97  dbsession.transaction().commit()
98  #print result
99  return result
100  except Exception as e:
101  print str(e)
102  dbsession.transaction().rollback()
103  del dbsession
Definition: start.py:1
def hltkeyForRun
Definition: dumpRunInfo.py:59
def dumpRunInfo.l1keyForRun (   dbsession,
  c,
  runnum 
)
select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum 

Definition at line 104 of file dumpRunInfo.py.

References AlCaHLTBitMon_QueryRunRegistry.data, and GetRecoTauVFromDQM_MC_cff.next.

Referenced by main().

105 def l1keyForRun(dbsession,c,runnum):
106  '''
107  select runnumber,string_value from cms_runinfo.runsession_parameter where name=:runsessionparametername and runnumber=:runnum
108  '''
109  result={}
110  try:
111  dbsession.transaction().start(True)
112  schema=dbsession.schema(c.runinfoschema)
113  if not schema:
114  raise Exception('cannot connect to schema '+c.runinfoschema)
115  if not schema.existsTable(c.runsessionparameterTable):
116  raise Exception('non-existing table '+c.runsessionparameterTable)
117 
118  l1keyOutput=coral.AttributeList()
119  l1keyOutput.extend("runnum","unsigned int")
120  l1keyOutput.extend("l1key","string")
121 
122  bindVarList=coral.AttributeList()
123  bindVarList.extend("name","string")
124  bindVarList.extend("runnumber","unsigned int")
125 
126  bindVarList["name"].setData(c.tsckeyname)
127  bindVarList["runnumber"].setData(int(runnum))
128 
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)
135 
136  cursor=query.execute()
137  while next(cursor):
138  runnum=cursor.currentRow()['runnum'].data()
139  l1key=cursor.currentRow()['l1key'].data()
140  result[runnum]=l1key
141  del query
142  dbsession.transaction().commit()
143  #print result
144  return result
145  except Exception as e:
146  print str(e)
147  dbsession.transaction().rollback()
148  del dbsession
Definition: start.py:1
def dumpRunInfo.main ( )

Definition at line 149 of file dumpRunInfo.py.

References fillnumForRun(), hltkeyForRun(), and l1keyForRun().

150 def main():
151  c=constants()
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)")
168  if args.debug:
169  msg=coral.MessageStream('')
170  msg.setMsgVerbosity(coral.message_Level_Debug)
171 
172  if args.action == 'hltkey':
173  p=re.compile(r'^/cdaq/physics/.+')
174  result=hltkeyForRun(session,c,runnumber)
175  print 'runnumber hltkey'
176  for runnum,hltkey in result.items():
177  if not args.collisiononly:
178  print runnum,hltkey
179  if args.collisiononly and re.match(p,hltkey):
180  fillnum=fillnumForRun(session,c,runnumber)
181  if len(fillnum)!=0:
182  print runnum,hltkey
183  if args.action == 'l1key':
184  p=re.compile(r'^TSC_.+_collisions_.+')
185  result=l1keyForRun(session,c,runnumber)
186  print 'runnumber tsc_key'
187  for runnum,l1key in result.items():
188  if not args.collisiononly:
189  print runnum,l1key
190  if args.collisiononly and re.match(p,l1key):
191  fillnum=fillnumForRun(session,c,runnumber)
192  if len(fillnum)!=0:
193  print runnum,l1key
194  if args.action == 'fill':
195  result=fillnumForRun(session,c,runnumber)
196  print 'runnumber fill'
197  if not args.collisiononly:
198  print runnumber,result
199  else:
200  if len(result)!=0:
201  print runnumber,result
202  del session
203  del svc
def fillnumForRun
Definition: dumpRunInfo.py:17
def hltkeyForRun
Definition: dumpRunInfo.py:59

Variable Documentation

string dumpRunInfo.VERSION = '1.02'

Definition at line 2 of file dumpRunInfo.py.