ATLAS Offline Software
Functions | Variables
python.TrigConfigSvcUtils Namespace Reference

Functions

def _getFileLocalOrPath (filename, pathenv)
 
def _getConnectionServicesForAlias (alias)
 
def _readAuthentication ()
 
def _getConnectionParameters (connection)
 
def interpretConnection (connection, debug=False, resolveAlias=True)
 
def getTriggerDBCursor (connection)
 
def _get_sqlite_cursor (filename)
 
def _get_oracle_cursor (tns, user, passwd="")
 
def _get_mysql_cursor (host, db, user, passwd="")
 
def getUsedTables (output, condition, schemaname, tables)
 
def isRun2 (cursor, schemaname)
 
def executeQuery (cursor, output, condition, schemaname, tables, bindvars=())
 
def getAlgorithmsForMenu (connection, smk)
 
def getAlgorithmsForMenuRun2 (connection, smk)
 
def getPropertyFromDB (connection, smk, component, parameter)
 
def getMenuNameFromDB (connection, hltprescalekey)
 
def getKeysFromName (connection, name, MCOnly=False)
 
def getKeysFromNameRelease (connection, name, release, l1only)
 
def getChainsAndStreams (connection, smk)
 
def getChains (connection, smk)
 
def getChainsWithLowerChainNames (connection, smk)
 
def getStreams (connection, smk)
 
def getL1Items (connection, smk)
 
def getBunchGroupContent (connection, bgsk)
 
def getL1Prescales (connection, l1prescalekey)
 
def getPrescaleFromCut (cut)
 
def queryHLTPrescaleTable (connection, psk)
 
def getHLTPrescales (connection, psk)
 
def getExpressStreamPrescales (connection, psk)
 
def getHLTPrescalesRun2 (connection, psk, smk)
 
def getExpressStreamPrescalesRun2 (connection, psk, smk)
 
def getReRunPrescalesRun2 (connection, psk, smk)
 
def queryHLTPrescaleTableRun2 (connection, psk, smk)
 
def getHLTPrescalesFromSMK (connection, smk)
 
def test ()
 
def test1 ()
 
def test2 ()
 

Variables

 log
 
 authDict
 

Function Documentation

◆ _get_mysql_cursor()

def python.TrigConfigSvcUtils._get_mysql_cursor (   host,
  db,
  user,
  passwd = "" 
)
private

Definition at line 271 of file TrigConfigSvcUtils.py.

271 def _get_mysql_cursor (host, db, user, passwd=""):
272  if passwd=="":
273  from getpass import getpass
274  passwd = getpass("[MySQL] `%s' database password for %s@%s: " % (db, user, host))
275 
276  from MySQLdb import connect
277  connection = connect(host=host, user=user, passwd=passwd, db=db, connect_timeout=10)
278  return connection.cursor()
279 

◆ _get_oracle_cursor()

def python.TrigConfigSvcUtils._get_oracle_cursor (   tns,
  user,
  passwd = "" 
)
private

Definition at line 261 of file TrigConfigSvcUtils.py.

261 def _get_oracle_cursor (tns, user, passwd=""):
262  if passwd=="":
263  from getpass import getpass
264  passwd = getpass("[Oracle] database password for %s@%s: " % (user, tns))
265 
266  from cx_Oracle import connect
267  connection = connect (user, passwd, tns, threaded=True)
268  return connection.cursor()
269 
270 

◆ _get_sqlite_cursor()

def python.TrigConfigSvcUtils._get_sqlite_cursor (   filename)
private

Definition at line 255 of file TrigConfigSvcUtils.py.

255 def _get_sqlite_cursor (filename):
256  import sqlite3
257  os.lstat(filename)
258  connection = sqlite3.connect(filename)
259  return connection.cursor()
260 

◆ _getConnectionParameters()

def python.TrigConfigSvcUtils._getConnectionParameters (   connection)
private

Definition at line 81 of file TrigConfigSvcUtils.py.

81 def _getConnectionParameters(connection):
82  connection = str(connection)
83  connectionParameters = {}
84 
85  if connection.startswith("sqlite_file:"):
86  filename = connection[connection.find(':')+1:]
87  connectionParameters["techno"] = "sqlite"
88  connectionParameters["filename"] = filename if os.path.exists(filename) else None
89 
90  elif connection.startswith("oracle://"):
91  if connection.count(';') == 2:
92  pattern = "(.*)://(.*)/(.*);username=(.*);password=(.*)"
93  m = re.match(pattern,connection)
94  #print 'Groups ', m
95  if not m:
96  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern))
97  (techno, server, schema, user, passwd) = m.groups()
98  #print (techno, server, schema, user, passwd)
99  else:
100  global authDict
101  if not authDict: authDict = _readAuthentication()
102  pattern = "oracle://(.*)/(.*)"
103  m = re.match(pattern,connection)
104  if not m:
105  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern))
106  (server, schema) = m.groups()
107  (user,passwd) = authDict[connection]
108  #info from auth file also unicode
109  connectionParameters["techno"] = 'oracle'
110  connectionParameters["server"] = str(server)
111  connectionParameters["schema"] = str(schema)
112  connectionParameters["user" ] = str(user)
113  connectionParameters["passwd"] = str(passwd)
114 
115  elif connection.startswith("mysql://"):
116  pattern = "mysql://(.*);dbname=(.*);user=(.*);passwd=(.*);"
117  m = re.match(pattern,connection)
118  if not m:
119  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern) )
120  (server, dbname, user, passwd) = m.groups()
121  connectionParameters["techno"] = 'mysql'
122  connectionParameters["server"] = server
123  connectionParameters["dbname"] = dbname
124  connectionParameters["user" ] = user
125  connectionParameters["passwd"] = passwd
126 
127  elif connection.startswith("frontier://"):
128  pattern = r"frontier://ATLF/\‍(\‍)/(.*)"
129  m = re.match(pattern,connection)
130  if not m:
131  log.fatal("connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern) )
132  (schema, ) = m.groups()
133  connectionParameters["techno"] = 'frontier'
134  connectionParameters["schema"] = schema
135 
136  return connectionParameters
137 
138 

◆ _getConnectionServicesForAlias()

def python.TrigConfigSvcUtils._getConnectionServicesForAlias (   alias)
private

Definition at line 36 of file TrigConfigSvcUtils.py.

37 
38  connectionServices = None # list of services
39 
40  dblookupfilename = _getFileLocalOrPath('dblookup.xml','CORAL_DBLOOKUP_PATH')
41  if dblookupfilename is None: return None
42 
43  doc = minidom.parse(dblookupfilename)
44  for ls in doc.getElementsByTagName('logicalservice'):
45  if ls.attributes['name'].value != alias: continue
46  connectionServices = [str(s.attributes['name'].value) for s in ls.getElementsByTagName('service')]
47  doc.unlink()
48 
49  log.info( "For alias '%s' found list of connections %r", alias,connectionServices )
50  if connectionServices is None:
51  log.fatal("Trigger connection alias '%s' is not defined in %s" % (alias,dblookupfilename))
52  return connectionServices
53 
54 

◆ _getFileLocalOrPath()

def python.TrigConfigSvcUtils._getFileLocalOrPath (   filename,
  pathenv 
)
private
looks for filename in local directory and then in all paths specified in environment variable 'pathenv'
returns path/filename if existing, otherwise None

Definition at line 19 of file TrigConfigSvcUtils.py.

19 def _getFileLocalOrPath(filename, pathenv):
20  """looks for filename in local directory and then in all paths specified in environment variable 'pathenv'
21  returns path/filename if existing, otherwise None
22  """
23  if os.path.exists(filename):
24  log.info( "Using local file %s", filename)
25  return filename
26 
27  pathlist = os.getenv(pathenv,'').split(os.pathsep)
28  resolvedfilename = FindFile(filename, pathlist, os.R_OK)
29  if resolvedfilename:
30  return resolvedfilename
31 
32  log.fatal("No file %s found locally nor in %s" % (filename, os.getenv('CORAL_DBLOOKUP_PATH')) )
33  return None
34 
35 

◆ _readAuthentication()

def python.TrigConfigSvcUtils._readAuthentication ( )
private
read authentication.xml, first from local directory, then from all paths specified in CORAL_AUTH_PATH

returns dictionary d with d[connection] -> (user,pw)

Definition at line 55 of file TrigConfigSvcUtils.py.

56  """ read authentication.xml, first from local directory, then from all paths specified in CORAL_AUTH_PATH
57 
58  returns dictionary d with d[connection] -> (user,pw)
59  """
60 
61  authDict = {}
62 
63  dbauthfilename = _getFileLocalOrPath('authentication.xml','CORAL_AUTH_PATH')
64  if dbauthfilename is None: return authDict
65 
66  doc = minidom.parse(dbauthfilename)
67  for cn in doc.getElementsByTagName('connection'):
68  user = ""
69  pw = ""
70  for p in cn.getElementsByTagName('parameter'):
71  if p.attributes['name'].value == 'user': user = p.attributes['value'].value
72  if p.attributes['name'].value == 'password': pw = p.attributes['value'].value
73  authDict[cn.attributes['name'].value] = (user,pw)
74  doc.unlink()
75  return authDict
76 
77 
78 

◆ executeQuery()

def python.TrigConfigSvcUtils.executeQuery (   cursor,
  output,
  condition,
  schemaname,
  tables,
  bindvars = () 
)

Definition at line 301 of file TrigConfigSvcUtils.py.

301 def executeQuery(cursor, output, condition, schemaname, tables, bindvars=()):
302  query = 'select distinct %s from %s' % \
303  (', '.join(output),
304  ', '.join(getUsedTables(output, condition, schemaname, tables)))
305 
306  if condition:
307  query += ' where ' + ' and '.join(condition)
308 
309  if len(bindvars)==0:
310  log.debug("Executing query %s", query)
311  cursor.execute(str(query))
312  else:
313  log.debug("Executing query %s with bound variables %r", query, bindvars)
314  cursor.execute(str(query),bindvars)
315  return cursor.fetchall()
316 
317 
318 

◆ getAlgorithmsForMenu()

def python.TrigConfigSvcUtils.getAlgorithmsForMenu (   connection,
  smk 
)

Definition at line 319 of file TrigConfigSvcUtils.py.

319 def getAlgorithmsForMenu(connection, smk):
320  cursor,schemaname = getTriggerDBCursor(connection)
321 
322  output = ['TC.HTC_L2_OR_EF', 'C.HCP_NAME', 'C.HCP_ALIAS' ]
323 
324  tables = {}
325  tables['SM'] = 'SUPER_MASTER_TABLE'
326  tables['HM'] = 'HLT_MASTER_TABLE'
327  tables['TM'] = 'HLT_TRIGGER_MENU'
328  tables['M2C'] = 'HLT_TM_TO_TC'
329  tables['TC'] = 'HLT_TRIGGER_CHAIN'
330  tables['C2S'] = 'HLT_TC_TO_TS'
331  tables['S2TE'] = 'HLT_TS_TO_TE'
332  tables['TE2C'] = 'HLT_TE_TO_CP'
333  tables['TE2TE'] = 'HLT_TE_TO_TE'
334  tables['C'] = 'HLT_COMPONENT'
335 
336  condition = [ "SM.SMT_ID = '%i'" % smk,
337  'SM.SMT_HLT_MASTER_TABLE_ID = HM.HMT_ID',
338  'HM.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
339  'M2C.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID',
340  'M2C.HTM2TC_TRIGGER_CHAIN_ID = C2S.HTC2TS_TRIGGER_CHAIN_ID',
341  'C2S.HTC2TS_TRIGGER_SIGNATURE_ID = S2TE.HTS2TE_TRIGGER_SIGNATURE_ID',
342  'S2TE.HTS2TE_TRIGGER_ELEMENT_ID = TE2C.HTE2CP_TRIGGER_ELEMENT_ID',
343  'TE2C.HTE2CP_COMPONENT_ID = C.HCP_ID' ]
344 
345  res = executeQuery(cursor, output, condition, schemaname, tables)
346 
347  l2algs=[]
348  efalgs=[]
349  for x in res:
350  if x[0]=='L2':
351  l2algs += ["%s/%s" % (x[1],x[2])]
352  else:
353  efalgs += ["%s/%s" % (x[1],x[2])]
354 
355  return l2algs, efalgs
356 
357 
358 
359 

◆ getAlgorithmsForMenuRun2()

def python.TrigConfigSvcUtils.getAlgorithmsForMenuRun2 (   connection,
  smk 
)

Definition at line 360 of file TrigConfigSvcUtils.py.

360 def getAlgorithmsForMenuRun2(connection, smk):
361  cursor,schemaname = getTriggerDBCursor(connection)
362 
363  output = [ 'C.HCP_NAME', 'C.HCP_ALIAS' ]
364 
365  tables = {}
366  tables['SM'] = 'SUPER_MASTER_TABLE'
367  tables['HM'] = 'HLT_MASTER_TABLE'
368  tables['TM'] = 'HLT_TRIGGER_MENU'
369  tables['M2C'] = 'HLT_TM_TO_TC'
370  tables['TC'] = 'HLT_TRIGGER_CHAIN'
371  tables['C2S'] = 'HLT_TC_TO_TS'
372  tables['S2TE'] = 'HLT_TS_TO_TE'
373  tables['TE2C'] = 'HLT_TE_TO_CP'
374  tables['TE2TE'] = 'HLT_TE_TO_TE'
375  tables['C'] = 'HLT_COMPONENT'
376 
377  condition = [ "SM.SMT_ID = '%i'" % smk,
378  'SM.SMT_HLT_MASTER_TABLE_ID = HM.HMT_ID',
379  'HM.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
380  'M2C.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID',
381  'M2C.HTM2TC_TRIGGER_CHAIN_ID = C2S.HTC2TS_TRIGGER_CHAIN_ID',
382  'C2S.HTC2TS_TRIGGER_SIGNATURE_ID = S2TE.HTS2TE_TRIGGER_SIGNATURE_ID',
383  'S2TE.HTS2TE_TRIGGER_ELEMENT_ID = TE2C.HTE2CP_TRIGGER_ELEMENT_ID',
384  'TE2C.HTE2CP_COMPONENT_ID = C.HCP_ID' ]
385 
386  res = executeQuery(cursor, output, condition, schemaname, tables)
387 
388  allalgs=[]
389  for x in res:
390  allalgs += ["%s/%s" % (x[0],x[1])]
391 
392  return allalgs
393 
394 
395 

◆ getBunchGroupContent()

def python.TrigConfigSvcUtils.getBunchGroupContent (   connection,
  bgsk 
)

Definition at line 717 of file TrigConfigSvcUtils.py.

717 def getBunchGroupContent(connection, bgsk):
718 
719  cursor,schemaname = getTriggerDBCursor(connection)
720 
721  output = [ "BGS.L1BGS2BG_INTERNAL_NUMBER","BG.L1BG2B_BUNCH_NUMBER" ]
722 
723  tables = { 'BGS' : 'L1_BGS_TO_BG',
724  'BG' : 'L1_BG_TO_B'}
725 
726  condition = [ "BGS.L1BGS2BG_BUNCH_GROUP_SET_ID = :bgsk",
727  "BGS.L1BGS2BG_BUNCH_GROUP_ID=BG.L1BG2B_BUNCH_GROUP_ID" ]
728 
729 
730  bindvars = { "bgsk": bgsk }
731 
732  res = executeQuery(cursor, output, condition, schemaname, tables, bindvars)
733 
734  bg = dict( enumerate( [[] for x in range(16)] ) )
735 
736  for e in res:
737  bg[e[0]] += [e[1]]
738 
739  return bg
740 
741 

◆ getChains()

def python.TrigConfigSvcUtils.getChains (   connection,
  smk 
)

Definition at line 592 of file TrigConfigSvcUtils.py.

592 def getChains(connection, smk):
593  cursor,schemaname = getTriggerDBCursor(connection)
594 
595  isrun2 = isRun2(cursor,schemaname)
596 
597  output = []
598 
599  if isrun2:
600  output = ['TC.HTC_ID', 'TC.HTC_CHAIN_COUNTER', 'TC.HTC_NAME']
601  else:
602  output = ['TC.HTC_ID', 'TC.HTC_CHAIN_COUNTER', 'TC.HTC_NAME', 'TC.HTC_L2_OR_EF']
603  tables = {}
604  tables['SM'] = 'SUPER_MASTER_TABLE'
605  tables['M2C'] = 'HLT_TM_TO_TC'
606  tables['TC'] = 'HLT_TRIGGER_CHAIN'
607  tables['MT'] = 'HLT_MASTER_TABLE'
608 
609  condition = [ "SM.SMT_ID = :smk",
610  'SM.SMT_HLT_MASTER_TABLE_ID = MT.HMT_ID',
611  'MT.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
612  'M2C.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID' ]
613 
614  bindvars = { "smk": smk }
615 
616  res = executeQuery(cursor, output, condition, schemaname, tables, bindvars)
617 
618  chainsl2 = {}
619  chainsef = {}
620  for x in res:
621  if isrun2:
622  chainsef[x[1]] = x[2]
623  else:
624  if x[3]=='L2': chainsl2[x[1]] = x[2]
625  else: chainsef[x[1]] = x[2]
626 
627  return chainsl2, chainsef
628 
629 

◆ getChainsAndStreams()

def python.TrigConfigSvcUtils.getChainsAndStreams (   connection,
  smk 
)

Definition at line 586 of file TrigConfigSvcUtils.py.

586 def getChainsAndStreams(connection, smk):
587  l2, ef = getChains(connection, smk)
588  strm = getStreams(connection, smk)
589  return l2, ef, strm
590 
591 

◆ getChainsWithLowerChainNames()

def python.TrigConfigSvcUtils.getChainsWithLowerChainNames (   connection,
  smk 
)

Definition at line 630 of file TrigConfigSvcUtils.py.

630 def getChainsWithLowerChainNames(connection, smk):
631  cursor,schemaname = getTriggerDBCursor(connection)
632 
633  isrun2 = isRun2(cursor,schemaname)
634 
635  output = []
636  chainshlt = {}
637 
638  if isrun2:
639  output = ['TC.HTC_ID', 'TC.HTC_CHAIN_COUNTER', 'TC.HTC_NAME', 'TC.HTC_LOWER_CHAIN_NAME']
640  else:
641  log.error("This method is compatibly with Run2 only")
642  return chainshlt
643 
644  tables = {}
645  tables['SM'] = 'SUPER_MASTER_TABLE'
646  tables['M2C'] = 'HLT_TM_TO_TC'
647  tables['TC'] = 'HLT_TRIGGER_CHAIN'
648  tables['MT'] = 'HLT_MASTER_TABLE'
649 
650  condition = [ "SM.SMT_ID = :smk",
651  'SM.SMT_HLT_MASTER_TABLE_ID = MT.HMT_ID',
652  'MT.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
653  'M2C.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID' ]
654 
655  bindvars = { "smk": smk }
656 
657  res = executeQuery(cursor, output, condition, schemaname, tables, bindvars)
658 
659 
660  for x in res:
661  chainshlt[x[1]] = (x[2],x[3])
662 
663  return chainshlt
664 
665 

◆ getExpressStreamPrescales()

def python.TrigConfigSvcUtils.getExpressStreamPrescales (   connection,
  psk 
)
returns the express stream prescales for a
given HLT prescale key
@connection - connection string, e.g. TRIGGERDB
@psk - HLT prescale key

@return (ps name, [chainId,prescale),...])

Definition at line 818 of file TrigConfigSvcUtils.py.

818 def getExpressStreamPrescales(connection,psk):
819  """returns the express stream prescales for a
820  given HLT prescale key
821  @connection - connection string, e.g. TRIGGERDB
822  @psk - HLT prescale key
823 
824  @return (ps name, [chainId,prescale),...])
825  """
826 
827  name, res = queryHLTPrescaleTable(connection,psk)
828 
829  return name, [(r[1],r[3]) for r in res if r[0]=='express']
830 
831 

◆ getExpressStreamPrescalesRun2()

def python.TrigConfigSvcUtils.getExpressStreamPrescalesRun2 (   connection,
  psk,
  smk 
)
returns the express stream prescales for a given HLT prescale key
@connection - connection string, e.g. TRIGGERDB
@psk - HLT prescale key
@smk - Supermaster key
@return (ps name, [chainId,prescale),...])

Definition at line 848 of file TrigConfigSvcUtils.py.

848 def getExpressStreamPrescalesRun2(connection,psk,smk):
849  """returns the express stream prescales for a given HLT prescale key
850  @connection - connection string, e.g. TRIGGERDB
851  @psk - HLT prescale key
852  @smk - Supermaster key
853  @return (ps name, [chainId,prescale),...])
854  """
855 
856  res = queryHLTPrescaleTableRun2(connection,psk, smk)
857 
858  if res == 0:
859  return res
860 
861  return [(r) for r in res if r[3]=='express']
862 
863 
864 

◆ getHLTPrescales()

def python.TrigConfigSvcUtils.getHLTPrescales (   connection,
  psk 
)
returns set name, prescale and passthrough values for a
given HLT prescale key
@connection - connection string, e.g. TRIGGERDB
@psk - HLT prescale key

@return (ps name, [('L2/EF',chainId,prescale,pass-through),...])

Definition at line 804 of file TrigConfigSvcUtils.py.

804 def getHLTPrescales(connection,psk):
805  """returns set name, prescale and passthrough values for a
806  given HLT prescale key
807  @connection - connection string, e.g. TRIGGERDB
808  @psk - HLT prescale key
809 
810  @return (ps name, [('L2/EF',chainId,prescale,pass-through),...])
811  """
812 
813  name, res = queryHLTPrescaleTable(connection,psk)
814 
815  return name, [r for r in res if r[0]!='express']
816 
817 

◆ getHLTPrescalesFromSMK()

def python.TrigConfigSvcUtils.getHLTPrescalesFromSMK (   connection,
  smk 
)

Definition at line 922 of file TrigConfigSvcUtils.py.

922 def getHLTPrescalesFromSMK(connection, smk):
923 
924  cursor,schemaname = getTriggerDBCursor(connection)
925 
926  tables = {}
927  tables['HPS'] = 'HLT_PRESCALE_SET'
928  tables['TM2PS'] = 'HLT_TM_TO_PS'
929  tables['HTM'] = 'HLT_TRIGGER_MENU'
930  tables['HMT'] = 'HLT_MASTER_TABLE'
931  tables['SM'] = 'SUPER_MASTER_TABLE'
932 
933  output = ['TM2PS.HTM2PS_PRESCALE_SET_ID']
934  condition = [ "TM2PS.HTM2PS_TRIGGER_MENU_ID = HTM.HTM_ID",
935  "HTM.HTM_ID = HMT.HMT_TRIGGER_MENU_ID",
936  "HMT.HMT_ID = SM.SMT_HLT_MASTER_TABLE_ID",
937  "SM.SMT_ID = %s" % smk ]
938 
939  hltpsk = executeQuery(cursor, output, condition, schemaname, tables)
940 
941  return hltpsk
942 
943 

◆ getHLTPrescalesRun2()

def python.TrigConfigSvcUtils.getHLTPrescalesRun2 (   connection,
  psk,
  smk 
)
returns set name, prescale and passthrough 
values for a given HLT prescale key 
@connection - connection string, e.g. TRIGGERDB
@psk - HLT prescale key
@smk - Supermaster key
@return (ps name, [('L2/EF',chainId,prescale,pass-through),...])

Definition at line 832 of file TrigConfigSvcUtils.py.

832 def getHLTPrescalesRun2(connection,psk,smk):
833  """returns set name, prescale and passthrough
834  values for a given HLT prescale key
835  @connection - connection string, e.g. TRIGGERDB
836  @psk - HLT prescale key
837  @smk - Supermaster key
838  @return (ps name, [('L2/EF',chainId,prescale,pass-through),...])
839  """
840 
841  res = queryHLTPrescaleTableRun2(connection,psk,smk)
842 
843  if res == 0:
844  return res
845 
846  return [(r) for r in res if r[3]!='express']
847 

◆ getKeysFromName()

def python.TrigConfigSvcUtils.getKeysFromName (   connection,
  name,
  MCOnly = False 
)

Definition at line 461 of file TrigConfigSvcUtils.py.

461 def getKeysFromName(connection, name, MCOnly=False):
462  cursor,schemaname = getTriggerDBCursor(connection)
463 
464  output = ['SM.SMT_ID', 'SM.SMT_NAME']
465 
466  tables = {}
467  tables['SM'] = 'SUPER_MASTER_TABLE'
468 
469  condition = [ "SM.SMT_NAME like '%s'" % name ]
470 
471  res = executeQuery(cursor, output, condition, schemaname, tables)
472  return res
473 

◆ getKeysFromNameRelease()

def python.TrigConfigSvcUtils.getKeysFromNameRelease (   connection,
  name,
  release,
  l1only 
)

Definition at line 474 of file TrigConfigSvcUtils.py.

474 def getKeysFromNameRelease(connection, name, release, l1only):
475 
476  cursor,schemaname = getTriggerDBCursor(connection)
477 
478  smname = name.split('__')[0]
479  print('SM name %s' % smname)
480  print('PS name %s' % name)
481  print('release %s' % release)
482  keys = []
483 
484  #Find the Release id
485  tables = {}
486  tables['RE'] = 'HLT_RELEASE'
487 
488  output = ['RE.HRE_ID']
489  condition = [ "RE.HRE_NAME like '%s'" %release ]
490 
491  rel = executeQuery(cursor, output, condition, schemaname, tables)
492  relid = (str(rel[-1])).lstrip('(').rstrip(')').split(',')[0]
493 
494  #Find the supermaster key
495  tables = {}
496  tables['SM'] = 'SUPER_MASTER_TABLE'
497  tables['SM2RE'] = 'HLT_SMT_TO_HRE'
498 
499  output = ['SM.SMT_ID']
500  condition = [ "SM.SMT_NAME like '%s'" % smname,
501  "SM.SMT_ID = SM2RE.SMT2RE_SUPER_MASTER_TABLE_ID",
502  "SM2RE.SMT2RE_RELEASE_ID = '%s'" % relid]
503 
504  smk = executeQuery(cursor, output, condition, schemaname, tables)
505  smid = (str(smk[-1])).lstrip('(').rstrip(')').split(',')[0]
506  #NB no check if we return more than one smk! (take the first here with the split!)
507 
508  #Find the L1 prescale key with the name and linked to this L1 master
509  tables = {}
510  tables['LPS'] = 'L1_PRESCALE_SET'
511  tables['PS2RE'] = 'L1_HRE_TO_PS'
512  tables['RE'] = 'HLT_RELEASE'
513 
514  output = ['LPS.L1PS_ID']
515  condition = [ "PS2RE.L1RE2PS_RELEASE_ID = '%s'" % relid,
516  "PS2RE.L1RE2PS_PRESCALE_ID = LPS.L1PS_ID",
517  "LPS.L1PS_NAME like '%s'" % name]
518 
519  l1k = executeQuery(cursor, output, condition, schemaname, tables)
520  l1id = (str(l1k[-1])).lstrip('(').rstrip(')').split(',')[0]
521 
522  #Check the PSkey returned matches the SMK
523  tables = {}
524  tables['LPS'] = 'L1_PRESCALE_SET'
525  tables['TM2PS'] = 'L1_TM_TO_PS'
526  tables['LTM'] = 'L1_TRIGGER_MENU'
527  tables['LMT'] = 'L1_MASTER_TABLE'
528  tables['SM'] = 'SUPER_MASTER_TABLE'
529 
530  output = ['SM.SMT_ID']
531  condition = [ "LPS.L1PS_ID = '%s'" % l1id,
532  "TM2PS.L1TM2PS_PRESCALE_SET_ID = '%s'" % l1id,
533  "TM2PS.L1TM2PS_TRIGGER_MENU_ID = LTM.L1TM_ID",
534  "LTM.L1TM_ID = LMT.L1MT_TRIGGER_MENU_ID",
535  "LMT.L1MT_ID = SM.SMT_ID"]
536 
537  l1chk = executeQuery(cursor, output, condition, schemaname, tables)
538  smk_chk = (str(l1chk[-1])).lstrip('(').rstrip(')').split(',')[0]
539  if smk_chk != smid:
540  log.fatal("SMK returned by release, SMK '%s', does not match the one returned by L1PS key, SMK '%s' " %(smid,smk_chk) )
541 
542  if not l1only:
543  #Find the HLT prescale key with the name and linked to this HLT master
544  tables = {}
545  tables['HPS'] = 'HLT_PRESCALE_SET'
546  tables['PS2RE'] = 'HLT_HRE_TO_PS'
547  tables['RE'] = 'HLT_RELEASE'
548 
549  output = ['HPS.HPS_ID']
550  condition = [ "PS2RE.HLTRE2PS_RELEASE_ID = '%s'" % relid,
551  "PS2RE.HLTRE2PS_PRESCALE_ID = HPS.HPS_ID",
552  "HPS.HPS_NAME like '%s'" % name]
553 
554  hltk = executeQuery(cursor, output, condition, schemaname, tables)
555  hltid = (str(hltk[-1])).lstrip('(').rstrip(')').split(',')[0]
556  print('HLT PS gotten %s' % hltid)
557 
558  keys = [int(smid), int(l1id), int(hltid)]
559 
560  #Check the PSkey returned matches the SMK
561  tables = {}
562  tables['HPS'] = 'HLT_PRESCALE_SET'
563  tables['TM2PS'] = 'HLT_TM_TO_PS'
564  tables['HTM'] = 'HLT_TRIGGER_MENU'
565  tables['HMT'] = 'HLT_MASTER_TABLE'
566  tables['SM'] = 'SUPER_MASTER_TABLE'
567 
568  output = ['SM.SMT_ID']
569  condition = [ "HPS.HPS_ID = '%s'" % hltid,
570  "TM2PS.HTM2PS_PRESCALE_SET_ID = '%s'" % hltid,
571  "TM2PS.HTM2PS_TRIGGER_MENU_ID = HTM.HTM_ID",
572  "HTM.HTM_ID = HMT.HMT_TRIGGER_MENU_ID",
573  "HMT.HMT_ID = SM.SMT_ID"]
574 
575  hltchk = executeQuery(cursor, output, condition, schemaname, tables)
576  smk_chk = (str(hltchk[-1])).lstrip('(').rstrip(')').split(',')[0]
577  if smk_chk != smid:
578  log.fatal("SMK returned by release, SMK '%s', does not match the one returned by L1PS key, SMK '%s' " %(smid,smk_chk) )
579 
580 
581  else:
582  keys = [int(smid), int(l1id)]
583 
584  return keys
585 

◆ getL1Items()

def python.TrigConfigSvcUtils.getL1Items (   connection,
  smk 
)

Definition at line 694 of file TrigConfigSvcUtils.py.

694 def getL1Items(connection, smk):
695 
696  cursor,schemaname = getTriggerDBCursor(connection)
697 
698  output = ['TI.L1TI_NAME', 'TI.L1TI_CTP_ID' ]
699  tables = { 'SM' : 'SUPER_MASTER_TABLE',
700  'M' : 'L1_MASTER_TABLE',
701  'M2I' : 'L1_TM_TO_TI',
702  'TI' : 'L1_TRIGGER_ITEM'
703  }
704  condition = [ "SM.SMT_ID = :smk",
705  'SM.SMT_L1_MASTER_TABLE_ID = M.L1MT_ID',
706  'M.L1MT_TRIGGER_MENU_ID = M2I.L1TM2TI_TRIGGER_MENU_ID',
707  'M2I.L1TM2TI_TRIGGER_ITEM_ID = TI.L1TI_ID' ]
708  bindvars = { "smk": smk }
709 
710  res = executeQuery( cursor, output, condition, schemaname, tables, bindvars)
711 
712  items = {}
713  for r in res:
714  items[r[0]] = r[1]
715  return items
716 

◆ getL1Prescales()

def python.TrigConfigSvcUtils.getL1Prescales (   connection,
  l1prescalekey 
)

Definition at line 742 of file TrigConfigSvcUtils.py.

742 def getL1Prescales(connection, l1prescalekey):
743 
744  cursor,schemaname = getTriggerDBCursor(connection)
745  isrun2 = isRun2(cursor,schemaname)
746 
747  maxitems = 512 if isrun2 else 256
748  tables = { 'L' : 'L1_PRESCALE_SET' }
749 
750  output = ['L.L1PS_NAME'] + ['L.L1PS_VAL%i' % i for i in range(1,maxitems+1)]
751 
752  condition = [ "L.L1PS_ID = '%i'" % l1prescalekey ]
753 
754  res = executeQuery(cursor, output, condition, schemaname, tables)
755 
756  name,prescales = res[0][0], res[0][1:maxitems+1]
757  if isrun2: prescales = map(getPrescaleFromCut, prescales)
758 
759  return (name,prescales)
760 

◆ getMenuNameFromDB()

def python.TrigConfigSvcUtils.getMenuNameFromDB (   connection,
  hltprescalekey 
)

Definition at line 435 of file TrigConfigSvcUtils.py.

435 def getMenuNameFromDB(connection, hltprescalekey):
436 
437  cursor,schemaname = getTriggerDBCursor(connection)
438 
439  tables = { 'HPS' : 'HLT_PRESCALE_SET' }
440 
441  output = ['HPS.HPS_NAME']
442 
443  condition = [ "HPS.HPS_ID = '%i'" % hltprescalekey ]
444 
445  res = executeQuery(cursor, output, condition, schemaname, tables)
446 
447  # now we need to do some logic, related to the
448 
449  print(res)
450 
451  hltpsName = str(res[0][0])
452 
453  # temporarily here, but should use the function from TMP
454  m = re.match( "(.*)_default_prescale", hltpsName)
455  menuName = m.group(1) if m else hltpsName
456 
457  log.info("Interpreting menu name from HLT prescale key %i: %s", hltprescalekey, menuName)
458 
459  return menuName
460 

◆ getPrescaleFromCut()

def python.TrigConfigSvcUtils.getPrescaleFromCut (   cut)
Convert (run-2) prescale cuts into prescale value

Definition at line 761 of file TrigConfigSvcUtils.py.

761 def getPrescaleFromCut(cut):
762  """Convert (run-2) prescale cuts into prescale value"""
763  sign = -1 if cut<0 else 1
764  ucut = abs(cut)
765  return (sign*0xFFFFFF ) / float( 0x1000000 - ucut )
766 

◆ getPropertyFromDB()

def python.TrigConfigSvcUtils.getPropertyFromDB (   connection,
  smk,
  component,
  parameter 
)
Get property value from DB. smk can be a single SMK or a list/tuple of SMKs.
SQL wildcards (%) can be used in both component and parameter names.
Return [(SMK,Component,Parameter,Value,Level)]

Definition at line 396 of file TrigConfigSvcUtils.py.

396 def getPropertyFromDB(connection, smk, component, parameter):
397  """Get property value from DB. smk can be a single SMK or a list/tuple of SMKs.
398  SQL wildcards (%) can be used in both component and parameter names.
399  Return [(SMK,Component,Parameter,Value,Level)]
400  """
401 
402  cursor,schemaname = getTriggerDBCursor(connection)
403 
404  isrun2 = isRun2(cursor,schemaname)
405  output = ['SM.SMT_ID', 'HCP.HCP_NAME', 'PAR.HPA_NAME', 'PAR.HPA_VALUE', 'HS.HST_ID']
406  output += ['HM.HMT_SETUP_ID' if isrun2 else 'HM.HMT_L2_SETUP_ID']
407 
408  tables = {'SM' : 'SUPER_MASTER_TABLE',
409  'HM' : 'HLT_MASTER_TABLE',
410  'HCP': 'HLT_COMPONENT',
411  'HS' : 'HLT_SETUP',
412  'HST2CP' : 'HLT_ST_TO_CP',
413  'HCP2PA' : 'HLT_CP_TO_PA',
414  'PAR' : 'HLT_PARAMETER'
415  }
416 
417  if type(smk)!=list and type(smk)!=tuple:
418  smk = [smk]
419 
420  condition = ["SM.SMT_ID IN (%s)" % ",".join([str(i) for i in smk]),
421  'SM.SMT_HLT_MASTER_TABLE_ID = HM.HMT_ID',
422  ('HM.HMT_SETUP_ID = HS.HST_ID' if isrun2 else '(HM.HMT_L2_SETUP_ID = HS.HST_ID or HM.HMT_EF_SETUP_ID = HS.HST_ID)'),
423  'HST2CP.HST2CP_SETUP_ID = HS.HST_ID',
424  'HST2CP.HST2CP_COMPONENT_ID = HCP2PA.HCP2PA_COMPONENT_ID',
425  'HST2CP.HST2CP_COMPONENT_ID = HCP.HCP_ID',
426  'HCP2PA.HCP2PA_PARAMETER_ID = PAR.HPA_ID',
427  "HCP.HCP_NAME like '%s'" % component,
428  "PAR.HPA_NAME like '%s'" % parameter]
429 
430  res = executeQuery(cursor, output, condition, schemaname, tables)
431 
432  if isrun2: return [ tuple(x[:4]+("HLT",) ) for x in res ]
433  else: return [ tuple(x[:4]+("L2" if x[4]==x[5] else "EF",) ) for x in res ]
434 

◆ getReRunPrescalesRun2()

def python.TrigConfigSvcUtils.getReRunPrescalesRun2 (   connection,
  psk,
  smk 
)
returns the express stream prescales for a given HLT prescale key
@connection - connection string, e.g. TRIGGERDB
@psk - HLT prescale key
@smk - Supermaster key
@return (ps name, [chainId,prescale),...])

Definition at line 865 of file TrigConfigSvcUtils.py.

865 def getReRunPrescalesRun2(connection,psk,smk):
866  """returns the express stream prescales for a given HLT prescale key
867  @connection - connection string, e.g. TRIGGERDB
868  @psk - HLT prescale key
869  @smk - Supermaster key
870  @return (ps name, [chainId,prescale),...])
871  """
872 
873  res = queryHLTPrescaleTableRun2(connection,psk, smk)
874 
875  if res == 0:
876  return res
877 
878  return [(r) for r in res if r[2]=='ReRun']
879 
880 
881 

◆ getStreams()

def python.TrigConfigSvcUtils.getStreams (   connection,
  smk 
)

Definition at line 666 of file TrigConfigSvcUtils.py.

666 def getStreams(connection, smk):
667  cursor,schemaname = getTriggerDBCursor(connection)
668 
669  # now the streams
670  output = ['TS.HTR_NAME']
671  tables = {}
672  tables['SM'] = 'SUPER_MASTER_TABLE'
673  tables['M2C'] = 'HLT_TM_TO_TC'
674  tables['TC'] = 'HLT_TRIGGER_CHAIN'
675  tables['MT'] = 'HLT_MASTER_TABLE'
676  tables['TS'] = 'HLT_TRIGGER_STREAM'
677  tables['C2S'] = 'HLT_TC_TO_TR'
678 
679 
680  condition = [ "SM.SMT_ID = :smk",
681  'SM.SMT_HLT_MASTER_TABLE_ID = MT.HMT_ID',
682  'MT.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
683  'M2C.HTM2TC_TRIGGER_CHAIN_ID = C2S.HTC2TR_TRIGGER_CHAIN_ID',
684  'C2S.HTC2TR_TRIGGER_STREAM_ID = TS.HTR_ID' ]
685 
686  bindvars = { "smk": smk }
687 
688  res = executeQuery(cursor, output, condition, schemaname, tables, bindvars)
689  streams = [x[0] for x in res]
690 
691 
692  return streams
693 

◆ getTriggerDBCursor()

def python.TrigConfigSvcUtils.getTriggerDBCursor (   connection)

Definition at line 229 of file TrigConfigSvcUtils.py.

229 def getTriggerDBCursor(connection):
230 
231  connectionParameters = interpretConnection(connection)
232 
233  technology = connectionParameters["techno"]
234 
235  if technology == 'sqlite':
236  cursor = _get_sqlite_cursor(connectionParameters["filename"])
237  schema = ''
238 
239  elif technology == 'oracle':
240  cursor = _get_oracle_cursor(connectionParameters["server"], connectionParameters["user"], connectionParameters["passwd"])
241  schema = connectionParameters["schema"].rstrip('.') + '.'
242 
243  elif technology == 'frontier':
244  from TrigConfigSvc.TrigConfFrontier import getFrontierCursor
245  schema = connectionParameters["schema"].rstrip('.')
246  cursor = getFrontierCursor( urls = connectionParameters['url'], schema = schema, loglevel = logging.getLogger("TrigConfigSvcUtils.py").level)
247  schema = schema + '.'
248 
249  elif technology == 'mysql':
250  cursor = _get_mysql_cursor(connectionParameters["server"], connectionParameters["dbname"], connectionParameters["user"], connectionParameters["passwd"]),''
251  schema = ''
252 
253  return cursor,schema
254 

◆ getUsedTables()

def python.TrigConfigSvcUtils.getUsedTables (   output,
  condition,
  schemaname,
  tables 
)

Definition at line 280 of file TrigConfigSvcUtils.py.

280 def getUsedTables(output, condition, schemaname, tables):
281  usedtables = set()
282  for o in output:
283  usedtables.add(o.split('.')[0])
284  for c in condition:
285  for p in c.split():
286  if '.' in p and '\'' not in p: usedtables.add(p.split('.')[0].lstrip('('))
287  return ["%s%s %s" % (schemaname,tables[t],t) for t in usedtables]
288 
289 

◆ interpretConnection()

def python.TrigConfigSvcUtils.interpretConnection (   connection,
  debug = False,
  resolveAlias = True 
)
connection needs to be of the following format (this is also the order of checking)
 <ALIAS>                              -- any string without a colon ':' will be checked for in the dblookup.xml file
 type:<detail>                        -- no dblookup will be used, type has to be oracle, mysql, or sqlite_file
 sqlite_file:filename.db              -- an sqlite file, no authentication needed, will be opened in read-only mode
 oracle://ATLR/ATLAS_CONF_TRIGGER_V2  -- a service description without user and password, requires lookup in authentication.xml
 oracle://ATLR/ATLAS_CONF_TRIGGER_V2;username=ATLAS_CONF_TRIGGER_V2_R;password=<...>  -- a service description with user and password

Definition at line 139 of file TrigConfigSvcUtils.py.

139 def interpretConnection(connection, debug=False, resolveAlias=True):
140  """connection needs to be of the following format (this is also the order of checking)
141  <ALIAS> -- any string without a colon ':' will be checked for in the dblookup.xml file
142  type:<detail> -- no dblookup will be used, type has to be oracle, mysql, or sqlite_file
143  sqlite_file:filename.db -- an sqlite file, no authentication needed, will be opened in read-only mode
144  oracle://ATLR/ATLAS_CONF_TRIGGER_V2 -- a service description without user and password, requires lookup in authentication.xml
145  oracle://ATLR/ATLAS_CONF_TRIGGER_V2;username=ATLAS_CONF_TRIGGER_V2_R;password=<...> -- a service description with user and password
146  """
147 
148  log.info("Specified connection string '%s'", connection)
149 
150  # not needed any longer
151  # connection = connection.lstrip("dblookup://")
152  # connection = connection.lstrip("dblookup:")
153  # connection = connection.rstrip(";")
154  #print connection
155 
156  # what to return
157  connectionParameters = {}
158  connection = str(connection)
159 
160  # connection explicitly specified (no DB alias)
161  if ':' in connection:
162  connectionParameters = _getConnectionParameters( connection )
163  return connectionParameters
164 
165 
166  # connection is a DB alias
167  connectionParameters["alias"] = connection
168  if not resolveAlias:
169  return connectionParameters
170 
171  connectionServices = _getConnectionServicesForAlias( connection ) # alias resolution via dblookup
172  if connectionServices is None:
173  return connectionParameters
174 
175  # SQLite
176  sqliteconnections = [conn for conn in connectionServices if conn.startswith("sqlite_file")]
177  if len(sqliteconnections)>0:
178  for conn in sqliteconnections:
179  connectionParameters = _getConnectionParameters( conn )
180  if connectionParameters["filename"] is not None:
181  break # stop at the first sqlite file that exists
182  if connectionParameters["filename"] is not None:
183  log.info("Using sqlite connection %s", connectionParameters)
184  return connectionParameters
185  else:
186  if 'ATLAS_TRIGGERDB_FORCESQLITE' in os.environ:
187  log.fatal("environment ATLAS_TRIGGERDB_FORCESQLITE is defined but non of the sqlite files defined in dblookup.xml exists" )
188  else:
189  if 'ATLAS_TRIGGERDB_FORCESQLITE' in os.environ:
190  log.fatal("environment ATLAS_TRIGGERDB_FORCESQLITE is defined but no sqlite connection defined in dblookup.xml" )
191 
192  # replicaList
193  from CoolConvUtilities.AtlCoolLib import replicaList
194  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
195  #serverlist=['ATLF']
196  log.info("Trying these servers in order %r", serverlist)
197  for server in serverlist:
198  log.info("Trying server %s", server)
199 
200  if server=='ATLF':
201  frontierconnections = [conn for conn in connectionServices if conn.startswith("frontier")]
202  if len(frontierconnections) == 0:
203  log.debug("FroNTier connection not defined for alias %s in dblookup", connection )
204  continue
205  log.info("Environment FRONTIER_SERVER: %s", os.getenv('FRONTIER_SERVER','not defined'))
206  frontierServer = os.getenv('FRONTIER_SERVER',None)
207  if not frontierServer:
208  log.debug("No environment variable FRONTIER_SERVER" )
209  continue
210  connectionParameters = _getConnectionParameters( frontierconnections[0] )
211  connectionParameters['url'] = frontierServer
212  log.info("Using frontier connection %s", frontierconnections[0])
213  #connstr='frontier://ATLF/%s;schema=%s;dbname=TRIGCONF' % (connectionParameters['url'],connectionParameters["schema"])
214  break
215  elif server=='atlas_dd': continue
216  else:
217  oracleconnections = [conn for conn in connectionServices if conn.lower().startswith("oracle://%s/" % server.lower())]
218  if len(oracleconnections) == 0:
219  log.debug("Oracle connection not defined for server %s in dblookup", server )
220  continue
221  connectionParameters = _getConnectionParameters( oracleconnections[0] )
222  log.info("Using oracle connection %s", oracleconnections[0])
223  #connstr='oracle://%s;schema=ATLAS_%s;dbname=TRIGCONF' % (connectionParameters["server"],connectionParameters["schema"])
224  break
225 
226  return connectionParameters
227 
228 

◆ isRun2()

def python.TrigConfigSvcUtils.isRun2 (   cursor,
  schemaname 
)

Definition at line 290 of file TrigConfigSvcUtils.py.

290 def isRun2(cursor,schemaname):
291  import cx_Oracle
292  if not hasattr(cursor,'connection') or type(cursor.connection)!=cx_Oracle.Connection:
293  log.warning('Detection of DB schema only supported for Oracle. Will assume run-2')
294  return True
295 
296  owner = schemaname.rstrip('.')
297  query = "select table_name from all_tables where table_name='ACTIVE_MASTERS' and owner='%s'" % owner
298  cursor.execute(query)
299  return (len(cursor.fetchall())>0)
300 

◆ queryHLTPrescaleTable()

def python.TrigConfigSvcUtils.queryHLTPrescaleTable (   connection,
  psk 
)
returns content of prescale set table and prescale table for a
given HLT prescale key
@connection - connection string, e.g. TRIGGERDB
@psk - HLT prescale key

@return (ps name, [('L2/EF/express',chainId,prescale,pass-through),...])
In case of 'express', the express stream prescale is returned in the position of the pass-through

Definition at line 767 of file TrigConfigSvcUtils.py.

767 def queryHLTPrescaleTable(connection,psk):
768  """returns content of prescale set table and prescale table for a
769  given HLT prescale key
770  @connection - connection string, e.g. TRIGGERDB
771  @psk - HLT prescale key
772 
773  @return (ps name, [('L2/EF/express',chainId,prescale,pass-through),...])
774  In case of 'express', the express stream prescale is returned in the position of the pass-through
775  """
776 
777  cursor,schemaname = getTriggerDBCursor(connection)
778 
779  tables = { 'S' : 'HLT_PRESCALE_SET'
780  }
781  output = [ 'S.HPS_NAME' ]
782 
783  condition = [
784  "S.HPS_ID = '%i'" % psk
785  ]
786 
787  res = executeQuery(cursor, output, condition, schemaname, tables)
788 
789  name = res[0][0]
790 
791  tables = { 'PS': 'HLT_PRESCALE'
792  }
793  output = ['PS.HPR_L2_OR_EF', 'PS.HPR_CHAIN_COUNTER', 'PS.HPR_PRESCALE', 'PS.HPR_PASS_THROUGH_RATE']
794 
795  condition = [
796  "PS.HPR_PRESCALE_SET_ID = '%i'" % psk
797  ]
798 
799  res = executeQuery(cursor, output, condition, schemaname, tables)
800 
801  return name, res
802 
803 

◆ queryHLTPrescaleTableRun2()

def python.TrigConfigSvcUtils.queryHLTPrescaleTableRun2 (   connection,
  psk,
  smk 
)

Definition at line 882 of file TrigConfigSvcUtils.py.

882 def queryHLTPrescaleTableRun2(connection,psk,smk):
883 
884  prescales = getHLTPrescalesFromSMK(connection, smk)
885 
886  valid = False
887  for entry in prescales:
888  if psk in entry:
889  valid = True
890 
891  if not valid:
892  log.warning("Selected HLT Prescale Key not associated with Supermaster key")
893  return 0
894 
895  cursor,schemaname = getTriggerDBCursor(connection)
896 
897  output = [ "HTC.HTC_NAME", "PS.HPR_CHAIN_COUNTER", "PS.HPR_TYPE", "PS.HPR_CONDITION" , "PS.HPR_VALUE"]
898 
899  tables = {}
900  tables['PS'] = 'HLT_PRESCALE'
901  tables['HTC'] = 'HLT_TRIGGER_CHAIN'
902  tables['TM2TC'] = 'HLT_TM_TO_TC'
903  tables['HTM'] = 'HLT_TRIGGER_MENU'
904  tables['HMT'] = 'HLT_MASTER_TABLE'
905  tables['SM'] = 'SUPER_MASTER_TABLE'
906 
907  condition = [ "PS.HPR_PRESCALE_SET_ID = :psk",
908  "HTC.HTC_CHAIN_COUNTER = PS.HPR_CHAIN_COUNTER",
909  "TM2TC.HTM2TC_TRIGGER_CHAIN_ID = HTC.HTC_ID",
910  "TM2TC.HTM2TC_TRIGGER_MENU_ID = HTM.HTM_ID",
911  "HTM.HTM_ID = HMT.HMT_TRIGGER_MENU_ID",
912  "HMT.HMT_ID = SM.SMT_HLT_MASTER_TABLE_ID",
913  "SM.SMT_ID = %s" % smk
914  ]
915 
916  bindvars = { "psk": psk }
917 
918  res = executeQuery(cursor, output, condition, schemaname, tables, bindvars)
919 
920  return res
921 

◆ test()

def python.TrigConfigSvcUtils.test ( )

Definition at line 944 of file TrigConfigSvcUtils.py.

944 def test():
945  log.setLevel(logging.DEBUG)
946 
947 
948  print("""####################################
949 ##
950 ## Testing ORACLE
951 ##
952 ####################################""")
953  l2, ef = getChains("TRIGGERDBREPR", 539)
954  strm_oracle = getStreams("TRIGGERDBREPR", 539)
955  print("\nList of Streams in SMK 539 %s\n" % strm_oracle)
956 
957 
958  print("""####################################
959 ##
960 ## Testing FRONTIER
961 ##
962 ####################################""")
963  strm_frontier = getStreams("TRIGGERDBREPR", 539)
964  print("\nList of Streams in SMK 539 %s\n" % strm_frontier)
965 
966  if strm_oracle == strm_frontier:
967  print("""####################################
968 ##
969 ## ORACLE and FRONTIER give IDENTICAL results
970 ##
971 ####################################""")
972  else:
973  print("""####################################
974 ##
975 ## ERROR: ORACLE and FRONTIER give DIFFERENT results
976 ##
977 ####################################""")
978 
979 

◆ test1()

def python.TrigConfigSvcUtils.test1 ( )

Definition at line 980 of file TrigConfigSvcUtils.py.

980 def test1():
981  getMenuNameFromDB("TRIGGERDBMC",321)
982 

◆ test2()

def python.TrigConfigSvcUtils.test2 ( )

Definition at line 983 of file TrigConfigSvcUtils.py.

983 def test2():
984  log.setLevel(logging.WARNING)
985 
986  connections = [ "TRIGGERDB",
987  "TRIGGERDB_RUN1",
988  "TRIGGERDBV1",
989  "TRIGGERDBMC_RUN1",
990  "TRIGGERDBMC",
991  "TRIGGERDBDEV1",
992  "TRIGGERDBDEV2",
993  "TRIGGERDBATN",
994  "TRIGGERDBREPR",
995  "TRIGGERDB_JOERG"
996  ]
997 
998 
999  for c in connections:
1000  print("\nConnecting to alias %s" % c)
1001  cursor, schema = getTriggerDBCursor(c)
1002  if cursor:
1003  print("SUCCESS : %s" % schema)
1004  else:
1005  print("FAILURE")
1006 
1007 
1008 

Variable Documentation

◆ authDict

python.TrigConfigSvcUtils.authDict

Definition at line 79 of file TrigConfigSvcUtils.py.

◆ log

python.TrigConfigSvcUtils.log

Definition at line 11 of file TrigConfigSvcUtils.py.

python.AtlCoolLib.replicaList
def replicaList()
Definition: AtlCoolLib.py:189
python.TrigConfigSvcUtils.getMenuNameFromDB
def getMenuNameFromDB(connection, hltprescalekey)
Definition: TrigConfigSvcUtils.py:435
python.TrigConfigSvcUtils.getReRunPrescalesRun2
def getReRunPrescalesRun2(connection, psk, smk)
Definition: TrigConfigSvcUtils.py:865
python.TrigConfigSvcUtils.executeQuery
def executeQuery(cursor, output, condition, schemaname, tables, bindvars=())
Definition: TrigConfigSvcUtils.py:301
python.TrigConfigSvcUtils._getFileLocalOrPath
def _getFileLocalOrPath(filename, pathenv)
Definition: TrigConfigSvcUtils.py:19
python.TrigConfigSvcUtils.getL1Items
def getL1Items(connection, smk)
Definition: TrigConfigSvcUtils.py:694
python.TrigConfigSvcUtils.getAlgorithmsForMenu
def getAlgorithmsForMenu(connection, smk)
Definition: TrigConfigSvcUtils.py:319
python.TrigConfigSvcUtils.getKeysFromNameRelease
def getKeysFromNameRelease(connection, name, release, l1only)
Definition: TrigConfigSvcUtils.py:474
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.TrigConfigSvcUtils.getKeysFromName
def getKeysFromName(connection, name, MCOnly=False)
Definition: TrigConfigSvcUtils.py:461
python.TrigConfigSvcUtils.getStreams
def getStreams(connection, smk)
Definition: TrigConfigSvcUtils.py:666
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
python.TrigConfFrontier.getFrontierCursor
def getFrontierCursor(urls, schema, loglevel=logging.INFO)
Definition: TrigConfFrontier.py:33
python.TrigConfigSvcUtils.test
def test()
Definition: TrigConfigSvcUtils.py:944
python.TrigConfigSvcUtils.test2
def test2()
Definition: TrigConfigSvcUtils.py:983
python.TrigConfigSvcUtils.getChains
def getChains(connection, smk)
Definition: TrigConfigSvcUtils.py:592
python.TrigConfigSvcUtils.getPrescaleFromCut
def getPrescaleFromCut(cut)
Definition: TrigConfigSvcUtils.py:761
python.TrigConfigSvcUtils.getHLTPrescalesFromSMK
def getHLTPrescalesFromSMK(connection, smk)
Definition: TrigConfigSvcUtils.py:922
python.TrigConfigSvcUtils._getConnectionServicesForAlias
def _getConnectionServicesForAlias(alias)
Definition: TrigConfigSvcUtils.py:36
python.TrigConfigSvcUtils.getExpressStreamPrescales
def getExpressStreamPrescales(connection, psk)
Definition: TrigConfigSvcUtils.py:818
python.TrigConfigSvcUtils._get_sqlite_cursor
def _get_sqlite_cursor(filename)
Definition: TrigConfigSvcUtils.py:255
python.TrigConfigSvcUtils.getExpressStreamPrescalesRun2
def getExpressStreamPrescalesRun2(connection, psk, smk)
Definition: TrigConfigSvcUtils.py:848
python.TrigConfigSvcUtils.getAlgorithmsForMenuRun2
def getAlgorithmsForMenuRun2(connection, smk)
Definition: TrigConfigSvcUtils.py:360
python.TrigConfigSvcUtils.queryHLTPrescaleTable
def queryHLTPrescaleTable(connection, psk)
Definition: TrigConfigSvcUtils.py:767
python.Utils.unixtools.FindFile
def FindFile(filename, pathlist, access)
helper -------------------------------------------------------------------—
Definition: unixtools.py:20
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.TrigConfigSvcUtils.getTriggerDBCursor
def getTriggerDBCursor(connection)
Definition: TrigConfigSvcUtils.py:229
python.TrigConfigSvcUtils.getPropertyFromDB
def getPropertyFromDB(connection, smk, component, parameter)
Definition: TrigConfigSvcUtils.py:396
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:224
python.TrigConfigSvcUtils.getChainsWithLowerChainNames
def getChainsWithLowerChainNames(connection, smk)
Definition: TrigConfigSvcUtils.py:630
python.TrigConfigSvcUtils.isRun2
def isRun2(cursor, schemaname)
Definition: TrigConfigSvcUtils.py:290
python.TrigConfigSvcUtils.getUsedTables
def getUsedTables(output, condition, schemaname, tables)
Definition: TrigConfigSvcUtils.py:280
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.TrigConfigSvcUtils.queryHLTPrescaleTableRun2
def queryHLTPrescaleTableRun2(connection, psk, smk)
Definition: TrigConfigSvcUtils.py:882
python.TrigConfigSvcUtils._readAuthentication
def _readAuthentication()
Definition: TrigConfigSvcUtils.py:55
python.TrigConfigSvcUtils._getConnectionParameters
def _getConnectionParameters(connection)
Definition: TrigConfigSvcUtils.py:81
python.TrigConfigSvcUtils.getBunchGroupContent
def getBunchGroupContent(connection, bgsk)
Definition: TrigConfigSvcUtils.py:717
python.TrigConfigSvcUtils.interpretConnection
def interpretConnection(connection, debug=False, resolveAlias=True)
Definition: TrigConfigSvcUtils.py:139
python.TrigConfigSvcUtils.getHLTPrescales
def getHLTPrescales(connection, psk)
Definition: TrigConfigSvcUtils.py:804
python.TrigConfigSvcUtils.getChainsAndStreams
def getChainsAndStreams(connection, smk)
Definition: TrigConfigSvcUtils.py:586
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.TrigConfigSvcUtils.test1
def test1()
Definition: TrigConfigSvcUtils.py:980
python.TrigConfigSvcUtils._get_mysql_cursor
def _get_mysql_cursor(host, db, user, passwd="")
Definition: TrigConfigSvcUtils.py:271
str
Definition: BTagTrackIpAccessor.cxx:11
python.TrigConfigSvcUtils.getL1Prescales
def getL1Prescales(connection, l1prescalekey)
Definition: TrigConfigSvcUtils.py:742
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.TrigConfigSvcUtils._get_oracle_cursor
def _get_oracle_cursor(tns, user, passwd="")
Definition: TrigConfigSvcUtils.py:261
python.TrigConfigSvcUtils.getHLTPrescalesRun2
def getHLTPrescalesRun2(connection, psk, smk)
Definition: TrigConfigSvcUtils.py:832