ATLAS Offline Software
AtlRunQueryTriggerUtils.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 #
5 # ----------------------------------------------------------------
6 # Script : AtlRunQueryTriggerUtils.py
7 # Project: AtlRunQuery
8 # Purpose: Trigger Utility functions for AtlRunQuery
9 # Authors: Andreas Hoecker (CERN), Joerg Stelzer (DESY)
10 # Created: Oct 27, 2010
11 # ----------------------------------------------------------------
12 
13 
14 from collections.abc import Iterable
15 
16 
17 __cursor_schema = {} # cache for cursor and schema by alias
18 
19 # returns True if run is RUN 2 (2015-2018)
20 def isTriggerRun2(run_number = None , smk = None , isRun2 = None ):
21  if run_number is None and smk is None and isRun2 is None:
22  raise RuntimeError("Cannot determine if trigger db is run 1 or 2")
23 
24  if smk is not None :
25  return smk >= 2000 and smk<3000
26  elif run_number is not None :
27  return run_number > 249000
28  else:
29  return isRun2
30 
31 
32 def triggerDBAlias(run_number = None , smk = None, lhcRun = None ):
33  if run_number is None and smk is None and lhcRun is None:
34  raise RuntimeError("Cannot determine the triggerDBAlias as no info is given")
35 
36  # lhcRun given
37  if lhcRun==1 or lhcRun==2:
38  return f"TRIGGERDB_RUN{lhcRun}"
39  if lhcRun==3:
40  return "TRIGGERDBDEV1_I8" if (smk is not None and smk<3000) else "TRIGGERDB_RUN3"
41 
42  # smk given
43  if smk is not None:
44  if smk<2000:
45  return "TRIGGERDB_RUN1"
46  elif smk<3000:
47  # note that this causes problems for the runs taken during the LS2 Pilot beam test
48  return "TRIGGERDB_RUN2"
49  else:
50  return "TRIGGERDB_RUN3"
51 
52  # run number given (should not be used, as the run should know the lhcRun)
53  # see AtlRunQueryRun.py
54  if run_number > 405800:
55  return "TRIGGERDB_RUN3"
56  if run_number > 378000:
57  return "TRIGGERDBDEV1_I8"
58  elif run_number > 249000:
59  return "TRIGGERDB_RUN2"
60  else:
61  return "TRIGGERDB_RUN1"
62 
63 
64 
65 from xml.dom import minidom
66 import os, re, logging
67 log = logging.getLogger( __name__ )
68 
70  def __init__(self, name, counter, lowername="", lowercounter=-1, forshow=False, forselect=False, level=0):
71  self.name = name
72  self.counter = counter
73  self.lowername = "" if lowername=="~" else lowername
74  self.lowercounter = lowercounter
75  self.forshow = forshow
76  self.forselect = forselect
77  self.multiseeded = (self.lowername=="") or (',' in self.lowername)
78  self.level = level
79  self.lower = None
80 
81  def __repr__(self):
82  return "TC:"+self.name
83 
84 
85 def FindFile( filename, pathlist, access ):
86  """Find <filename> with rights <access> through <pathlist>."""
87 
88  # special case for those filenames that already contain a path
89  if os.path.dirname( filename ):
90  if os.access( filename, access ):
91  return filename
92 
93  # test the file name in all possible paths until first found
94  for path in pathlist:
95  f = os.path.join( path, filename )
96  if os.access( f, access ):
97  return f
98 
99  # no such accessible file avalailable
100  return None
101 
102 
103 
104 def _getFileLocalOrPath(filename, pathenv):
105  """looks for filename in local directory and then in all paths specified in environment variable 'pathenv'
106  returns path/filename if existing, otherwise None
107  """
108  log = logging.getLogger( "TrigConfigSvcUtils.py" )
109  if os.path.exists(filename):
110  log.info( "Using local file %s", filename)
111  return filename
112 
113  pathlist = os.getenv(pathenv,'').split(os.pathsep)
114  resolvedfilename = FindFile(filename, pathlist, os.R_OK)
115  if resolvedfilename:
116  return resolvedfilename
117 
118  log.fatal("No file %s found locally nor in %s" % (filename, os.getenv('CORAL_DBLOOKUP_PATH')) )
119  return None
120 
121 
123  log = logging.getLogger( "TrigConfigSvcUtils.py" )
124 
125  connectionServices = None # list of services
126 
127  dblookupfilename = _getFileLocalOrPath('dblookup.xml','CORAL_DBLOOKUP_PATH')
128  if dblookupfilename is None:
129  return None
130 
131  doc = minidom.parse(dblookupfilename)
132  for ls in doc.getElementsByTagName('logicalservice'):
133  if ls.attributes['name'].value != alias:
134  continue
135  connectionServices = [str(s.attributes['name'].value) for s in ls.getElementsByTagName('service')]
136  doc.unlink()
137 
138  log.info( "For alias '%s' found list of connections %r", alias, connectionServices )
139  if connectionServices is None:
140  print("ERROR: Trigger connection alias '%s' is not defined in %s" % (alias,dblookupfilename))
141  return connectionServices
142 
143 
145  """ read authentication.xml, first from local directory, then from all paths specified in CORAL_AUTH_PATH
146  returns dictionary d with d[connection] -> (user,pw)
147  """
148 
149  authDict = {}
150  dbauthfilename = _getFileLocalOrPath('authentication.xml','CORAL_AUTH_PATH')
151  if dbauthfilename is None:
152  return authDict
153 
154  doc = minidom.parse(dbauthfilename)
155  for cn in doc.getElementsByTagName('connection'):
156  user = ""
157  pw = ""
158  svc = cn.attributes['name'].value
159  for p in cn.getElementsByTagName('parameter'):
160  if p.attributes['name'].value == 'user':
161  user = p.attributes['value'].value
162  elif p.attributes['name'].value == 'password':
163  pw = p.attributes['value'].value
164  authDict[svc] = (user,pw)
165  doc.unlink()
166  return authDict
167 
168 authDict = None
169 
170 def _getConnectionParameters(connection):
171  log = logging.getLogger( "TrigConfigSvcUtils.py" )
172  connection = str(connection)
173  connectionParameters = {}
174 
175  if connection.startswith("sqlite_file:"):
176  filename = connection[connection.find(':')+1:]
177  connectionParameters["techno"] = "sqlite"
178  connectionParameters["filename"] = filename if os.path.exists(filename) else None
179 
180  elif connection.startswith("oracle://"):
181  if connection.count(';') == 2:
182  pattern = "(.*)://(.*)/(.*);username=(.*);password=(.*)"
183  m = re.match(pattern,connection)
184  #print ('Groups ', m)
185  if not m:
186  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern))
187  (techno, server, schema, user, passwd) = m.groups()
188  #print ((techno, server, schema, user, passwd))
189  else:
190  global authDict
191  if not authDict:
192  authDict = _readAuthentication()
193  pattern = "oracle://(.*)/(.*)"
194  m = re.match(pattern,connection)
195  if not m:
196  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern))
197  (server, schema) = m.groups()
198  (user,passwd) = authDict[connection]
199  #info from auth file also unicode
200  connectionParameters["techno"] = 'oracle'
201  connectionParameters["server"] = str(server)
202  connectionParameters["schema"] = str(schema)
203  connectionParameters["user" ] = str(user)
204  connectionParameters["passwd"] = str(passwd)
205 
206  elif connection.startswith("mysql://"):
207  pattern = "mysql://(.*);dbname=(.*);user=(.*);passwd=(.*);"
208  m = re.match(pattern,connection)
209  if not m:
210  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern) )
211  (server, dbname, user, passwd) = m.groups()
212  connectionParameters["techno"] = 'mysql'
213  connectionParameters["server"] = server
214  connectionParameters["dbname"] = dbname
215  connectionParameters["user" ] = user
216  connectionParameters["passwd"] = passwd
217 
218  elif connection.startswith("frontier://"):
219  pattern = r"frontier://ATLF/\‍(\‍)/(.*)"
220  m = re.match(pattern,connection)
221  if not m:
222  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern) )
223  (schema, ) = m.groups()
224  connectionParameters["techno"] = 'frontier'
225  connectionParameters["schema"] = schema
226 
227  return connectionParameters
228 
229 def interpretConnection(connection, debug=False, resolveAlias=True):
230  # connection needs to be of the following format (this is also the order of checking)
231  # <ALIAS> -- any string without a colon ':' will be checked for in the dblookup.xml file
232  # sqlite_file:filename.db -- an sqlite file, no authentication needed, will be opened in read-only mode
233  # oracle://ATLR/ATLAS_CONF_TRIGGER_V2 -- a service description without user and password, requires lookup in authentication.xml
234  # oracle://ATLR/ATLAS_CONF_TRIGGER_V2;username=ATLAS_CONF_TRIGGER_V2_R;password=<...> -- a service description with user and password
235 
236  log.info("Specified connection string '%s'", connection)
237 
238  # not needed any longer
239  # connection = connection.lstrip("dblookup://")
240  # connection = connection.lstrip("dblookup:")
241  # connection = connection.rstrip(";")
242  #print (connection)
243 
244  # what to return
245  connectionParameters = {}
246  connection = str(connection)
247 
248  # connection explicitly specified (no DB alias)
249  if ':' in connection:
250  connectionParameters = _getConnectionParameters( connection )
251  return connectionParameters
252 
253  # connection is a DB alias
254  connectionParameters["alias"] = connection
255  if not resolveAlias:
256  return connectionParameters
257 
258  connectionServices = _getConnectionServicesForAlias( connection ) # alias resolution via dblookup
259  if connectionServices is None:
260  return connectionParameters
261 
262  # If ${TRIGGER_USE_FRONTIER} is True then we remove sqlite files
263  if os.getenv('TRIGGER_USE_FRONTIER',False):
264  connectionServices = filter(lambda conn: not conn.startswith("sqlite_file"), connectionServices)
265  if 'ATLAS_TRIGGERDB_FORCESQLITE' in os.environ:
266  log.fatal("Inconsistent setup: environment variable ATLAS_TRIGGERDB_FORCESQLITE is defined and use of Frontier is requested" )
267 
268  # SQLite
269  sqliteconnections = [conn for conn in connectionServices if conn.startswith("sqlite_file")]
270  if len(sqliteconnections)>0:
271  for conn in sqliteconnections:
272  connectionParameters = _getConnectionParameters( conn )
273  if connectionParameters["filename"] is not None:
274  break # stop at the first sqlite file that exists
275  if connectionParameters["filename"] is not None:
276  log.info("Using sqlite connection %s", connectionParameters)
277  return connectionParameters
278  else:
279  if 'ATLAS_TRIGGERDB_FORCESQLITE' in os.environ:
280  log.fatal("environment ATLAS_TRIGGERDB_FORCESQLITE is defined but non of the sqlite files defined in dblookup.xml exists" )
281  else:
282  if 'ATLAS_TRIGGERDB_FORCESQLITE' in os.environ:
283  log.fatal("environment ATLAS_TRIGGERDB_FORCESQLITE is defined but no sqlite connection defined in dblookup.xml" )
284 
285  from CoolConvUtilities.AtlCoolLib import replicaList
286  serverlist=['ATLAS_CONFIG' if s=='ATLAS_COOLPROD' else s for s in replicaList()] # replicaList is for COOL, I need ATLAS_CONFIG instead of ATLAS_COOLPROD
287  log.info("Trying these servers in order %r", serverlist)
288  for server in serverlist:
289  log.info("Trying server %s", server)
290 
291  if server=='ATLF':
292  if not os.getenv('TRIGGER_USE_FRONTIER',False):
293  continue
294  frontierconnections = [conn for conn in connectionServices if conn.startswith("frontier")]
295  if len(frontierconnections) == 0:
296  log.debug("FroNTier connection not defined for alias %s in dblookup", connection )
297  continue
298  log.info("Environment FRONTIER_SERVER: %s", os.getenv('FRONTIER_SERVER','not defined'))
299  frontierServer = os.getenv('FRONTIER_SERVER',None)
300  if not frontierServer:
301  log.debug("No environment variable FRONTIER_SERVER" )
302  continue
303  connectionParameters = _getConnectionParameters( frontierconnections[0] )
304  connectionParameters['url'] = frontierServer
305  log.info("Using frontier connection %s", frontierconnections[0])
306  #connstr='frontier://ATLF/%s;schema=%s;dbname=TRIGCONF' % (connectionParameters['url'],connectionParameters["schema"])
307  break
308  elif server=='atlas_dd':
309  continue
310  else:
311  oracleconnections = [conn for conn in connectionServices if conn.startswith("oracle://%s/" % server)]
312  if len(oracleconnections) == 0:
313  log.debug("Oracle connection not defined for server %s in dblookup", server )
314  continue
315  connectionParameters = _getConnectionParameters( oracleconnections[0] )
316  log.info("Using oracle connection %s", oracleconnections[0])
317  break
318 
319  return connectionParameters
320 
321 
322 def _get_sqlite_cursor (filename):
323  try:
324  import sqlite3
325  except ImportError:
326  raise RuntimeError ("ERROR: Can't import sqlite3?")
327  os.lstat(filename)
328  connection = sqlite3.connect(filename)
329  return connection.cursor()
330 
331 def _get_oracle_cursor (tns, user, passwd=""):
332  if passwd=="":
333  from getpass import getpass
334  passwd = getpass("[Oracle] database password for %s@%s: " % (user, tns))
335  try:
336  from cx_Oracle import connect
337  except ImportError:
338  raise RuntimeError ("ERROR: Can't import cx_Oracle?")
339  connection = connect (user, passwd, tns, threaded=True)
340  return connection.cursor()
341 
342 
343 def _get_mysql_cursor (host, db, user, passwd=""):
344  if passwd=="":
345  from getpass import getpass
346  passwd = getpass("[MySQL] `%s' database password for %s@%s: " % (db, user, host))
347  try:
348  from MySQLdb import connect
349  except ImportError:
350  raise RuntimeError ("ERROR: Can't import MySQLdb")
351  connection = connect(host=host, user=user, passwd=passwd, db=db, connect_timeout=10)
352  return connection.cursor()
353 
354 
356 
357  global __cursor_schema
358  if dbAlias in __cursor_schema:
359  return __cursor_schema[dbAlias] # return the correct cursor and schema name
360 
361  connectionParameters = interpretConnection(dbAlias)
362  technology = connectionParameters["techno"]
363 
364  if technology == 'sqlite':
365  cursor = _get_sqlite_cursor(connectionParameters["filename"])
366  schema = ''
367 
368  elif technology == 'oracle':
369  cursor = _get_oracle_cursor(connectionParameters["server"], connectionParameters["user"], connectionParameters["passwd"])
370  schema = connectionParameters["schema"].rstrip('.') + '.'
371 
372  elif technology == 'frontier':
373  from TrigConfigSvc.TrigConfFrontier import getFrontierCursor
374  cursor = getFrontierCursor(connectionParameters["url"], connectionParameters["schema"], logging.getLogger("TrigConfigSvcUtils.py").level)
375  schema = connectionParameters["schema"].rstrip('.') + '.'
376 
377  elif technology == 'mysql':
378  cursor = _get_mysql_cursor(connectionParameters["server"], connectionParameters["dbname"], connectionParameters["user"], connectionParameters["passwd"]),''
379  schema = ''
380 
381  __cursor_schema[dbAlias] = (cursor,schema)
382 
383  return __cursor_schema[dbAlias] # return the correct cursor and schema name
384 
385 
386 def getTriggerDBCursor(run_number = None, smk = None, lhcRun = None):
387 
388  dbAlias = triggerDBAlias(run_number = run_number, smk = smk, lhcRun = lhcRun)
389  return getTriggerDBCursorForAlias(dbAlias)
390 
391 
392 def getUsedTables(output, condition, schemaname, tables):
393  schemaname = schemaname.rstrip('.')+'.'
394  usedtables = set()
395  for o in output:
396  usedtables.add(o.split('.')[0])
397  for c in condition:
398  for p in c.split():
399  if '.' in p and '\'' not in p:
400  usedtables.add(p.split('.')[0])
401  return ["%s%s %s" % (schemaname,tables[t],t) for t in usedtables]
402 
403 
404 def executeQuery(cursor, output, condition, schemaname, tables, bindvars=()):
405  query = 'select distinct %s from %s where %s' % (
406  ', '.join(output),
407  ', '.join(getUsedTables(output, condition, schemaname, tables)),
408  ' and '.join(condition)
409  )
410  if len(bindvars)==0:
411  cursor.execute(str(query))
412  else:
413  cursor.execute(str(query),bindvars)
414 
415  return cursor.fetchall()
416 
417 
418 def getL1PskNames(psk, dbAlias = None, run_number = None , smk = None , lhcRun = None ):
419  if not isinstance(psk, Iterable):
420  psk = [psk]
421 
422  keyslist = ','.join([str(k) for k in psk if k])
423 
424  if keyslist=="":
425  return {}
426 
427  tables = { 'L' : 'L1_PRESCALE_SET' }
428  output = [ 'L.L1PS_ID', 'L.L1PS_NAME' ]
429  condition = [ "L.L1PS_ID in (%s)" % keyslist ]
430 
431  if dbAlias is not None:
432  cursor, schema = getTriggerDBCursorForAlias(dbAlias)
433  else:
434  cursor, schema = getTriggerDBCursor(run_number = run_number, smk = smk, lhcRun = lhcRun )
435 
436  res = executeQuery(cursor, output, condition, schema, tables)
437 
438  return dict(res)
439 
440 
441 
442 def getHLTPskNames(psk, dbAlias = None, run_number = None , smk = None , lhcRun = None ):
443  if not isinstance(psk, Iterable):
444  psk = [psk]
445 
446  keyslist = ','.join([str(k) for k in psk if k])
447  if keyslist=="":
448  return {}
449 
450  tables = { 'L' : 'HLT_PRESCALE_SET' }
451  output = ['L.HPS_ID', 'L.HPS_NAME']
452  condition = [ "L.HPS_ID in (%s)" % keyslist ]
453 
454  if dbAlias is not None:
455  cursor, schema = getTriggerDBCursorForAlias(dbAlias)
456  else:
457  cursor,schema = getTriggerDBCursor(run_number = run_number, smk = smk, lhcRun = lhcRun )
458 
459  res = executeQuery( cursor, output, condition, schema, tables)
460 
461  return dict(res)
462 
463 
464 def getSmkNames( smks, dbAlias ):
465  """
466  takes a single SMK or a list of SMKs
467  returns a map from SMK to (name,version,comment)
468  """
469  if not isinstance(smks, Iterable):
470  smks = [smks]
471 
472  keyslist = ','.join([str(k) for k in smks if k])
473  if keyslist=="":
474  return {}
475 
476  tables = { 'S' : 'SUPER_MASTER_TABLE' }
477  output = ['S.SMT_ID', 'S.SMT_NAME', 'S.SMT_VERSION', 'S.SMT_COMMENT']
478  condition = [ "S.SMT_ID in (%s)" % keyslist ]
479 
480  cursor, schema = getTriggerDBCursorForAlias(dbAlias)
481  res = executeQuery( cursor, output, condition, schema, tables)
482 
483  return dict([ (r[0],(r[1],r[2],r[3])) for r in res])
484 
485 
486 
487 
488 def getHLTMenu(smk):
489  if smk is None or smk==0:
490  return [],[]
491 
492  if isTriggerRun2(smk):
493  output = ['TC.HTC_NAME', 'TC.HTC_CHAIN_COUNTER', 'TC.HTC_LOWER_CHAIN_NAME' ]
494  else:
495  output = ['TC.HTC_NAME', 'TC.HTC_CHAIN_COUNTER', 'TC.HTC_LOWER_CHAIN_NAME', 'TC.HTC_L2_OR_EF' ]
496 
497  tables = {
498  'SM' : 'SUPER_MASTER_TABLE',
499  'HM' : 'HLT_MASTER_TABLE',
500  'M2C' : 'HLT_TM_TO_TC',
501  'TC' : 'HLT_TRIGGER_CHAIN'
502  }
503  condition = [
504  'SM.SMT_ID = :smk',
505  'SM.SMT_HLT_MASTER_TABLE_ID = HM.HMT_ID',
506  'HM.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
507  'M2C.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID'
508  ]
509  bindvars = { "smk": smk }
510 
511  cursor,schema = getTriggerDBCursor(smk)
512  res = executeQuery( cursor, output, condition, schema, tables, bindvars)
513 
514  l2chains = []
515  efchains = []
516 
517  for r in res:
518  if len(r)==4 and r[3]=='L2':
519  l2chains += [TriggerChain(r[0],r[1],r[2], level=2)]
520  else:
521  efchains += [TriggerChain(r[0],r[1],r[2], level=3)]
522 
523  return l2chains, efchains
524 
525 
526 
527 
528 def getL1Menu(smk):
529  if smk is None or smk==0:
530  return []
531  output = [
532  'TI.L1TI_NAME',
533  'TI.L1TI_CTP_ID'
534  ]
535  tables = {
536  'SM' : 'SUPER_MASTER_TABLE',
537  'M' : 'L1_MASTER_TABLE',
538  'M2I' : 'L1_TM_TO_TI',
539  'TI' : 'L1_TRIGGER_ITEM'
540  }
541  condition = [
542  "SM.SMT_ID = :smk",
543  'SM.SMT_L1_MASTER_TABLE_ID = M.L1MT_ID',
544  'M.L1MT_TRIGGER_MENU_ID = M2I.L1TM2TI_TRIGGER_MENU_ID',
545  'M2I.L1TM2TI_TRIGGER_ITEM_ID = TI.L1TI_ID'
546  ]
547  bindvars = { "smk": smk }
548 
549  cursor,schema = getTriggerDBCursor(smk = smk)
550  res = executeQuery( cursor, output, condition, schema, tables, bindvars)
551 
552  maxNumberItems = 512 if isTriggerRun2(smk=smk) else 256
553  items = maxNumberItems*[None]
554 
555  for r in res:
556  items[r[1]] = TriggerChain(r[0],r[1])
557  return items
558 
559 
560 
561 def getL1Prescales(l1prescalekey, run_number):
562 
563  maxNumberItems = 512 if isTriggerRun2( run_number = run_number ) else 256
564 
565  tables = { 'L' : 'L1_PRESCALE_SET' }
566  output = ['L.L1PS_VAL%i' % i for i in range( 1, maxNumberItems + 1)]
567  condition = [ "L.L1PS_ID = :psk" ]
568  bindvars = { "psk": l1prescalekey }
569 
570  cursor,schema = getTriggerDBCursor( run_number = run_number )
571  res = executeQuery(cursor, output, condition, schema, tables, bindvars)
572 
573  return res[0][0:maxNumberItems]
574 
575 
576 def getHLTPrescales(hltprescalekey, run_number):
577 
578  l2ps = {}
579  efps = {}
580 
581  if isTriggerRun2( run_number = run_number ):
582  return l2ps,efps
583 
584  tables = {
585  'H' : 'HLT_PRESCALE_SET',
586  'P' : 'HLT_PRESCALE'
587  }
588  output = [
589  'P.HPR_L2_OR_EF',
590  'P.HPR_CHAIN_COUNTER',
591  'P.HPR_PRESCALE',
592  'P.HPR_PASS_THROUGH_RATE'
593  ]
594  condition = [
595  "P.HPR_PRESCALE_SET_ID = :psk",
596  "P.HPR_L2_OR_EF not like 'express'"
597  ]
598  bindvars = { "psk": hltprescalekey }
599 
600  cursor,schema = getTriggerDBCursor(isRun2 = True)
601  res = executeQuery(cursor, output, condition, schema, tables, bindvars)
602 
603  for r in res:
604  if r[0]=='L2':
605  l2ps[r[1]] = ( float(r[2]), float(r[3]) )
606  elif (r[0]=='EF' or r[0]=='HLT' or r[0]=='HL'):
607  efps[r[1]] = ( float(r[2]), float(r[3]) )
608 
609  return l2ps, efps
610 
611 
612 def getRandom(smk, lhcRun):
613  # does not work for Run 3
614  if lhcRun >= 3:
615  return (1,1,1,1)
616 
617  if smk=='n.a.':
618  return ('n.a.','n.a.')
619 
620  tables = {
621  'S' : 'SUPER_MASTER_TABLE',
622  'M' : 'L1_MASTER_TABLE',
623  'R' : 'L1_RANDOM'
624  }
625  if lhcRun == 2:
626  output = [ 'R.L1R_CUT0', 'R.L1R_CUT1', 'R.L1R_CUT2', 'R.L1R_CUT3' ]
627  else:
628  output = [ 'R.L1R_RATE1', 'R.L1R_RATE2' ]
629 
630  condition = [ "S.SMT_ID=:smk", "S.SMT_L1_MASTER_TABLE_ID=M.L1MT_ID", "M.L1MT_RANDOM_ID=R.L1R_ID" ]
631 
632  bindvars = { "smk": smk }
633 
634  cursor,schema = getTriggerDBCursorForAlias(dbAlias = triggerDBAlias(lhcRun=lhcRun))
635  res = executeQuery(cursor, output, condition, schema, tables, bindvars)
636  if len(res) > 0:
637  return res[0]
638  else:
639  return [0,0,0,0]
640 
641 
642 if __name__=="__main__":
643  #print (getL1PskNames([2517, 2518, 2284, 2536]))
644 
645  #print (getHLTPskNames([2517, 2530, 2537, 2491]))
646 
647  #print (getSmkNames([931, 932, 933]))
648 
649  #print (getL1Menu(931))
650 
651  #print (getHLTMenu(931))
652 
653  #print (getL1Prescales(2517))
654 
655  #print (getHLTPrescales(2530))
656 
657  print (getRandom(1038))
python.utils.AtlRunQueryTriggerUtils.TriggerChain.name
name
Definition: AtlRunQueryTriggerUtils.py:71
python.utils.AtlRunQueryTriggerUtils.getL1Menu
def getL1Menu(smk)
Definition: AtlRunQueryTriggerUtils.py:528
python.AtlCoolLib.replicaList
def replicaList()
Definition: AtlCoolLib.py:188
python.utils.AtlRunQueryTriggerUtils.TriggerChain.__repr__
def __repr__(self)
Definition: AtlRunQueryTriggerUtils.py:81
python.utils.AtlRunQueryTriggerUtils.getTriggerDBCursor
def getTriggerDBCursor(run_number=None, smk=None, lhcRun=None)
Definition: AtlRunQueryTriggerUtils.py:386
python.utils.AtlRunQueryTriggerUtils.TriggerChain.lowername
lowername
Definition: AtlRunQueryTriggerUtils.py:73
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
python.utils.AtlRunQueryTriggerUtils.TriggerChain.lowercounter
lowercounter
Definition: AtlRunQueryTriggerUtils.py:74
python.TrigConfFrontier.getFrontierCursor
def getFrontierCursor(urls, schema, loglevel=logging.INFO)
Definition: TrigConfFrontier.py:33
python.utils.AtlRunQueryTriggerUtils.TriggerChain.level
level
Definition: AtlRunQueryTriggerUtils.py:78
python.utils.AtlRunQueryTriggerUtils.FindFile
def FindFile(filename, pathlist, access)
Definition: AtlRunQueryTriggerUtils.py:85
python.utils.AtlRunQueryTriggerUtils.getSmkNames
def getSmkNames(smks, dbAlias)
Definition: AtlRunQueryTriggerUtils.py:464
python.utils.AtlRunQueryTriggerUtils._getConnectionParameters
def _getConnectionParameters(connection)
Definition: AtlRunQueryTriggerUtils.py:170
python.utils.AtlRunQueryTriggerUtils.interpretConnection
def interpretConnection(connection, debug=False, resolveAlias=True)
Definition: AtlRunQueryTriggerUtils.py:229
python.utils.AtlRunQueryTriggerUtils.getHLTPskNames
def getHLTPskNames(psk, dbAlias=None, run_number=None, smk=None, lhcRun=None)
Definition: AtlRunQueryTriggerUtils.py:442
python.utils.AtlRunQueryTriggerUtils.TriggerChain
Definition: AtlRunQueryTriggerUtils.py:69
python.utils.AtlRunQueryTriggerUtils.TriggerChain.__init__
def __init__(self, name, counter, lowername="", lowercounter=-1, forshow=False, forselect=False, level=0)
Definition: AtlRunQueryTriggerUtils.py:70
python.utils.AtlRunQueryTriggerUtils.triggerDBAlias
def triggerDBAlias(run_number=None, smk=None, lhcRun=None)
Definition: AtlRunQueryTriggerUtils.py:32
covarianceTool.filter
filter
Definition: covarianceTool.py:514
python.utils.AtlRunQueryTriggerUtils.getHLTPrescales
def getHLTPrescales(hltprescalekey, run_number)
Definition: AtlRunQueryTriggerUtils.py:576
python.utils.AtlRunQueryTriggerUtils._getConnectionServicesForAlias
def _getConnectionServicesForAlias(alias)
Definition: AtlRunQueryTriggerUtils.py:122
python.utils.AtlRunQueryTriggerUtils.executeQuery
def executeQuery(cursor, output, condition, schemaname, tables, bindvars=())
Definition: AtlRunQueryTriggerUtils.py:404
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.utils.AtlRunQueryTriggerUtils.TriggerChain.lower
lower
Definition: AtlRunQueryTriggerUtils.py:79
python.utils.AtlRunQueryTriggerUtils._getFileLocalOrPath
def _getFileLocalOrPath(filename, pathenv)
Definition: AtlRunQueryTriggerUtils.py:104
python.utils.AtlRunQueryTriggerUtils.TriggerChain.forshow
forshow
Definition: AtlRunQueryTriggerUtils.py:75
python.utils.AtlRunQueryTriggerUtils._get_mysql_cursor
def _get_mysql_cursor(host, db, user, passwd="")
Definition: AtlRunQueryTriggerUtils.py:343
python.utils.AtlRunQueryTriggerUtils.TriggerChain.multiseeded
multiseeded
Definition: AtlRunQueryTriggerUtils.py:77
python.utils.AtlRunQueryTriggerUtils.getRandom
def getRandom(smk, lhcRun)
Definition: AtlRunQueryTriggerUtils.py:612
python.utils.AtlRunQueryTriggerUtils.getUsedTables
def getUsedTables(output, condition, schemaname, tables)
Definition: AtlRunQueryTriggerUtils.py:392
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.utils.AtlRunQueryTriggerUtils._get_sqlite_cursor
def _get_sqlite_cursor(filename)
Definition: AtlRunQueryTriggerUtils.py:322
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.utils.AtlRunQueryTriggerUtils.TriggerChain.forselect
forselect
Definition: AtlRunQueryTriggerUtils.py:76
python.utils.AtlRunQueryTriggerUtils.getTriggerDBCursorForAlias
def getTriggerDBCursorForAlias(dbAlias)
Definition: AtlRunQueryTriggerUtils.py:355
python.utils.AtlRunQueryTriggerUtils._get_oracle_cursor
def _get_oracle_cursor(tns, user, passwd="")
Definition: AtlRunQueryTriggerUtils.py:331
python.utils.AtlRunQueryTriggerUtils.isTriggerRun2
def isTriggerRun2(run_number=None, smk=None, isRun2=None)
Definition: AtlRunQueryTriggerUtils.py:20
python.utils.AtlRunQueryTriggerUtils.TriggerChain.counter
counter
Definition: AtlRunQueryTriggerUtils.py:72
python.utils.AtlRunQueryTriggerUtils.getL1PskNames
def getL1PskNames(psk, dbAlias=None, run_number=None, smk=None, lhcRun=None)
Definition: AtlRunQueryTriggerUtils.py:418
python.utils.AtlRunQueryTriggerUtils.getL1Prescales
def getL1Prescales(l1prescalekey, run_number)
Definition: AtlRunQueryTriggerUtils.py:561
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.utils.AtlRunQueryTriggerUtils.getHLTMenu
def getHLTMenu(smk)
Definition: AtlRunQueryTriggerUtils.py:488
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65
python.utils.AtlRunQueryTriggerUtils._readAuthentication
def _readAuthentication()
Definition: AtlRunQueryTriggerUtils.py:144