Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
|
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 () |
|
◆ _get_mysql_cursor()
def python.TrigConfigSvcUtils._get_mysql_cursor |
( |
|
host, |
|
|
|
db, |
|
|
|
user, |
|
|
|
passwd = "" |
|
) |
| |
|
private |
Definition at line 271 of file TrigConfigSvcUtils.py.
273 from getpass
import getpass
274 passwd = getpass(
"[MySQL] `%s' database password for %s@%s: " % (db, user, host))
276 from MySQLdb
import connect
277 connection =
connect(host=host, user=user, passwd=passwd, db=db, connect_timeout=10)
278 return connection.cursor()
◆ _get_oracle_cursor()
def python.TrigConfigSvcUtils._get_oracle_cursor |
( |
|
tns, |
|
|
|
user, |
|
|
|
passwd = "" |
|
) |
| |
|
private |
Definition at line 261 of file TrigConfigSvcUtils.py.
263 from getpass
import getpass
264 passwd = getpass(
"[Oracle] database password for %s@%s: " % (user, tns))
266 from cx_Oracle
import connect
267 connection = connect (user, passwd, tns, threaded=
True)
268 return connection.cursor()
◆ _get_sqlite_cursor()
def python.TrigConfigSvcUtils._get_sqlite_cursor |
( |
|
filename | ) |
|
|
private |
Definition at line 255 of file TrigConfigSvcUtils.py.
258 connection = sqlite3.connect(filename)
259 return connection.cursor()
◆ _getConnectionParameters()
def python.TrigConfigSvcUtils._getConnectionParameters |
( |
|
connection | ) |
|
|
private |
Definition at line 81 of file TrigConfigSvcUtils.py.
82 connection =
str(connection)
83 connectionParameters = {}
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
90 elif connection.startswith(
"oracle://"):
91 if connection.count(
';') == 2:
92 pattern =
"(.*)://(.*)/(.*);username=(.*);password=(.*)"
93 m = re.match(pattern,connection)
96 log.fatal(
"connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern))
97 (techno, server, schema, user, passwd) = m.groups()
102 pattern =
"oracle://(.*)/(.*)"
103 m = re.match(pattern,connection)
105 log.fatal(
"connection string '%s' doesn't match the pattern '%s'?" % (connection,pattern))
106 (server, schema) = m.groups()
107 (user,passwd) = authDict[connection]
109 connectionParameters[
"techno"] =
'oracle'
110 connectionParameters[
"server"] =
str(server)
111 connectionParameters[
"schema"] =
str(schema)
112 connectionParameters[
"user" ] =
str(user)
113 connectionParameters[
"passwd"] =
str(passwd)
115 elif connection.startswith(
"mysql://"):
116 pattern =
"mysql://(.*);dbname=(.*);user=(.*);passwd=(.*);"
117 m = re.match(pattern,connection)
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
127 elif connection.startswith(
"frontier://"):
128 pattern =
r"frontier://ATLF/\(\)/(.*)"
129 m = re.match(pattern,connection)
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
136 return connectionParameters
◆ _getConnectionServicesForAlias()
def python.TrigConfigSvcUtils._getConnectionServicesForAlias |
( |
|
alias | ) |
|
|
private |
Definition at line 36 of file TrigConfigSvcUtils.py.
38 connectionServices =
None
41 if dblookupfilename
is None:
return None
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')]
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
◆ _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.
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
23 if os.path.exists(filename):
24 log.info(
"Using local file %s", filename)
27 pathlist = os.getenv(pathenv,
'').
split(os.pathsep)
28 resolvedfilename =
FindFile(filename, pathlist, os.R_OK)
30 return resolvedfilename
32 log.fatal(
"No file %s found locally nor in %s" % (filename, os.getenv(
'CORAL_DBLOOKUP_PATH')) )
◆ _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
58 returns dictionary d with d[connection] -> (user,pw)
64 if dbauthfilename
is None:
return authDict
66 doc = minidom.parse(dbauthfilename)
67 for cn
in doc.getElementsByTagName(
'connection'):
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)
◆ 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' % \
307 query +=
' where ' +
' and '.
join(condition)
310 log.debug(
"Executing query %s", query)
311 cursor.execute(
str(query))
313 log.debug(
"Executing query %s with bound variables %r", query, bindvars)
314 cursor.execute(
str(query),bindvars)
315 return cursor.fetchall()
◆ getAlgorithmsForMenu()
def python.TrigConfigSvcUtils.getAlgorithmsForMenu |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 319 of file TrigConfigSvcUtils.py.
322 output = [
'TC.HTC_L2_OR_EF',
'C.HCP_NAME',
'C.HCP_ALIAS' ]
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'
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' ]
345 res =
executeQuery(cursor, output, condition, schemaname, tables)
351 l2algs += [
"%s/%s" % (x[1],x[2])]
353 efalgs += [
"%s/%s" % (x[1],x[2])]
355 return l2algs, efalgs
◆ getAlgorithmsForMenuRun2()
def python.TrigConfigSvcUtils.getAlgorithmsForMenuRun2 |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 360 of file TrigConfigSvcUtils.py.
363 output = [
'C.HCP_NAME',
'C.HCP_ALIAS' ]
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'
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' ]
386 res =
executeQuery(cursor, output, condition, schemaname, tables)
390 allalgs += [
"%s/%s" % (x[0],x[1])]
◆ getBunchGroupContent()
def python.TrigConfigSvcUtils.getBunchGroupContent |
( |
|
connection, |
|
|
|
bgsk |
|
) |
| |
Definition at line 719 of file TrigConfigSvcUtils.py.
723 output = [
"BGS.L1BGS2BG_INTERNAL_NUMBER",
"BG.L1BG2B_BUNCH_NUMBER" ]
725 tables = {
'BGS' :
'L1_BGS_TO_BG',
728 condition = [
"BGS.L1BGS2BG_BUNCH_GROUP_SET_ID = :bgsk",
729 "BGS.L1BGS2BG_BUNCH_GROUP_ID=BG.L1BG2B_BUNCH_GROUP_ID" ]
732 bindvars = {
"bgsk": bgsk }
734 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
736 bg = dict( enumerate( [[]
for x
in range(16)] ) )
◆ getChains()
def python.TrigConfigSvcUtils.getChains |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 592 of file TrigConfigSvcUtils.py.
595 isrun2 =
isRun2(cursor,schemaname)
600 output = [
'TC.HTC_ID',
'TC.HTC_CHAIN_COUNTER',
'TC.HTC_NAME']
602 output = [
'TC.HTC_ID',
'TC.HTC_CHAIN_COUNTER',
'TC.HTC_NAME',
'TC.HTC_L2_OR_EF']
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'
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' ]
614 bindvars = {
"smk": smk }
616 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
622 chainsef[x[1]] = x[2]
624 if x[3]==
'L2': chainsl2[x[1]] = x[2]
625 else: chainsef[x[1]] = x[2]
627 return chainsl2, chainsef
◆ getChainsAndStreams()
def python.TrigConfigSvcUtils.getChainsAndStreams |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
◆ getChainsWithLowerChainNames()
def python.TrigConfigSvcUtils.getChainsWithLowerChainNames |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 630 of file TrigConfigSvcUtils.py.
633 isrun2 =
isRun2(cursor,schemaname)
639 output = [
'TC.HTC_ID',
'TC.HTC_CHAIN_COUNTER',
'TC.HTC_NAME',
'TC.HTC_LOWER_CHAIN_NAME']
641 log.error(
"This method is compatibly with Run2 only")
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'
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' ]
655 bindvars = {
"smk": smk }
657 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
663 chainshlt[x[1]] = (x[2],x[3])
◆ 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 820 of file TrigConfigSvcUtils.py.
821 """returns the express stream prescales for a
822 given HLT prescale key
823 @connection - connection string, e.g. TRIGGERDB
824 @psk - HLT prescale key
826 @return (ps name, [chainId,prescale),...])
831 return name, [(r[1],r[3])
for r
in res
if r[0]==
'express']
◆ 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 850 of file TrigConfigSvcUtils.py.
851 """returns the express stream prescales for a given HLT prescale key
852 @connection - connection string, e.g. TRIGGERDB
853 @psk - HLT prescale key
854 @smk - Supermaster key
855 @return (ps name, [chainId,prescale),...])
863 return [(r)
for r
in res
if r[3]==
'express']
◆ 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 806 of file TrigConfigSvcUtils.py.
807 """returns set name, prescale and passthrough values for a
808 given HLT prescale key
809 @connection - connection string, e.g. TRIGGERDB
810 @psk - HLT prescale key
812 @return (ps name, [('L2/EF',chainId,prescale,pass-through),...])
817 return name, [r
for r
in res
if r[0]!=
'express']
◆ getHLTPrescalesFromSMK()
def python.TrigConfigSvcUtils.getHLTPrescalesFromSMK |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 924 of file TrigConfigSvcUtils.py.
929 tables[
'HPS'] =
'HLT_PRESCALE_SET'
930 tables[
'TM2PS'] =
'HLT_TM_TO_PS'
931 tables[
'HTM'] =
'HLT_TRIGGER_MENU'
932 tables[
'HMT'] =
'HLT_MASTER_TABLE'
933 tables[
'SM'] =
'SUPER_MASTER_TABLE'
935 output = [
'TM2PS.HTM2PS_PRESCALE_SET_ID']
936 condition = [
"TM2PS.HTM2PS_TRIGGER_MENU_ID = HTM.HTM_ID",
937 "HTM.HTM_ID = HMT.HMT_TRIGGER_MENU_ID",
938 "HMT.HMT_ID = SM.SMT_HLT_MASTER_TABLE_ID",
939 "SM.SMT_ID = %s" % smk ]
941 hltpsk =
executeQuery(cursor, output, condition, schemaname, tables)
◆ 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 834 of file TrigConfigSvcUtils.py.
835 """returns set name, prescale and passthrough
836 values for a given HLT prescale key
837 @connection - connection string, e.g. TRIGGERDB
838 @psk - HLT prescale key
839 @smk - Supermaster key
840 @return (ps name, [('L2/EF',chainId,prescale,pass-through),...])
848 return [(r)
for r
in res
if r[3]!=
'express']
◆ getKeysFromName()
def python.TrigConfigSvcUtils.getKeysFromName |
( |
|
connection, |
|
|
|
name, |
|
|
|
MCOnly = False |
|
) |
| |
Definition at line 461 of file TrigConfigSvcUtils.py.
464 output = [
'SM.SMT_ID',
'SM.SMT_NAME']
467 tables[
'SM'] =
'SUPER_MASTER_TABLE'
469 condition = [
"SM.SMT_NAME like '%s'" % name ]
471 res =
executeQuery(cursor, output, condition, schemaname, tables)
◆ getKeysFromNameRelease()
def python.TrigConfigSvcUtils.getKeysFromNameRelease |
( |
|
connection, |
|
|
|
name, |
|
|
|
release, |
|
|
|
l1only |
|
) |
| |
Definition at line 474 of file TrigConfigSvcUtils.py.
478 smname = name.split(
'__')[0]
479 print(
'SM name %s' % smname)
480 print(
'PS name %s' % name)
481 print(
'release %s' % release)
486 tables[
'RE'] =
'HLT_RELEASE'
488 output = [
'RE.HRE_ID']
489 condition = [
"RE.HRE_NAME like '%s'" %release ]
491 rel =
executeQuery(cursor, output, condition, schemaname, tables)
492 relid = (
str(rel[-1])).lstrip(
'(').rstrip(
')').
split(
',')[0]
496 tables[
'SM'] =
'SUPER_MASTER_TABLE'
497 tables[
'SM2RE'] =
'HLT_SMT_TO_HRE'
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]
504 smk =
executeQuery(cursor, output, condition, schemaname, tables)
505 smid = (
str(smk[-1])).lstrip(
'(').rstrip(
')').
split(
',')[0]
510 tables[
'LPS'] =
'L1_PRESCALE_SET'
511 tables[
'PS2RE'] =
'L1_HRE_TO_PS'
512 tables[
'RE'] =
'HLT_RELEASE'
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]
519 l1k =
executeQuery(cursor, output, condition, schemaname, tables)
520 l1id = (
str(l1k[-1])).lstrip(
'(').rstrip(
')').
split(
',')[0]
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'
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"]
537 l1chk =
executeQuery(cursor, output, condition, schemaname, tables)
538 smk_chk = (
str(l1chk[-1])).lstrip(
'(').rstrip(
')').
split(
',')[0]
540 log.fatal(
"SMK returned by release, SMK '%s', does not match the one returned by L1PS key, SMK '%s' " %(smid,smk_chk) )
545 tables[
'HPS'] =
'HLT_PRESCALE_SET'
546 tables[
'PS2RE'] =
'HLT_HRE_TO_PS'
547 tables[
'RE'] =
'HLT_RELEASE'
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]
554 hltk =
executeQuery(cursor, output, condition, schemaname, tables)
555 hltid = (
str(hltk[-1])).lstrip(
'(').rstrip(
')').
split(
',')[0]
556 print(
'HLT PS gotten %s' % hltid)
558 keys = [
int(smid),
int(l1id),
int(hltid)]
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'
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"]
575 hltchk =
executeQuery(cursor, output, condition, schemaname, tables)
576 smk_chk = (
str(hltchk[-1])).lstrip(
'(').rstrip(
')').
split(
',')[0]
578 log.fatal(
"SMK returned by release, SMK '%s', does not match the one returned by L1PS key, SMK '%s' " %(smid,smk_chk) )
582 keys = [
int(smid),
int(l1id)]
◆ getL1Items()
def python.TrigConfigSvcUtils.getL1Items |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 696 of file TrigConfigSvcUtils.py.
700 output = [
'TI.L1TI_NAME',
'TI.L1TI_CTP_ID' ]
701 tables = {
'SM' :
'SUPER_MASTER_TABLE',
702 'M' :
'L1_MASTER_TABLE',
703 'M2I' :
'L1_TM_TO_TI',
704 'TI' :
'L1_TRIGGER_ITEM'
706 condition = [
"SM.SMT_ID = :smk",
707 'SM.SMT_L1_MASTER_TABLE_ID = M.L1MT_ID',
708 'M.L1MT_TRIGGER_MENU_ID = M2I.L1TM2TI_TRIGGER_MENU_ID',
709 'M2I.L1TM2TI_TRIGGER_ITEM_ID = TI.L1TI_ID' ]
710 bindvars = {
"smk": smk }
712 res =
executeQuery( cursor, output, condition, schemaname, tables, bindvars)
◆ getL1Prescales()
def python.TrigConfigSvcUtils.getL1Prescales |
( |
|
connection, |
|
|
|
l1prescalekey |
|
) |
| |
Definition at line 744 of file TrigConfigSvcUtils.py.
747 isrun2 =
isRun2(cursor,schemaname)
749 maxitems = 512
if isrun2
else 256
750 tables = {
'L' :
'L1_PRESCALE_SET' }
752 output = [
'L.L1PS_NAME'] + [
'L.L1PS_VAL%i' % i
for i
in range(1,maxitems+1)]
754 condition = [
"L.L1PS_ID = '%i'" % l1prescalekey ]
756 res =
executeQuery(cursor, output, condition, schemaname, tables)
758 name,prescales = res[0][0], res[0][1:maxitems+1]
759 if isrun2: prescales = map(getPrescaleFromCut, prescales)
761 return (name,prescales)
◆ getMenuNameFromDB()
def python.TrigConfigSvcUtils.getMenuNameFromDB |
( |
|
connection, |
|
|
|
hltprescalekey |
|
) |
| |
Definition at line 435 of file TrigConfigSvcUtils.py.
439 tables = {
'HPS' :
'HLT_PRESCALE_SET' }
441 output = [
'HPS.HPS_NAME']
443 condition = [
"HPS.HPS_ID = '%i'" % hltprescalekey ]
445 res =
executeQuery(cursor, output, condition, schemaname, tables)
451 hltpsName =
str(res[0][0])
454 m = re.match(
"(.*)_default_prescale", hltpsName)
455 menuName = m.group(1)
if m
else hltpsName
457 log.info(
"Interpreting menu name from HLT prescale key %i: %s", hltprescalekey, menuName)
◆ getPrescaleFromCut()
def python.TrigConfigSvcUtils.getPrescaleFromCut |
( |
|
cut | ) |
|
Convert (run-2) prescale cuts into prescale value
Definition at line 763 of file TrigConfigSvcUtils.py.
764 """Convert (run-2) prescale cuts into prescale value"""
765 sign = -1
if cut<0
else 1
767 return (sign*0xFFFFFF ) /
float( 0x1000000 - ucut )
◆ 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.
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)]
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']
408 tables = {
'SM' :
'SUPER_MASTER_TABLE',
409 'HM' :
'HLT_MASTER_TABLE',
410 'HCP':
'HLT_COMPONENT',
412 'HST2CP' :
'HLT_ST_TO_CP',
413 'HCP2PA' :
'HLT_CP_TO_PA',
414 'PAR' :
'HLT_PARAMETER'
417 if type(smk)!=list
and type(smk)!=tuple:
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]
430 res =
executeQuery(cursor, output, condition, schemaname, tables)
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 ]
◆ 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 867 of file TrigConfigSvcUtils.py.
868 """returns the express stream prescales for a given HLT prescale key
869 @connection - connection string, e.g. TRIGGERDB
870 @psk - HLT prescale key
871 @smk - Supermaster key
872 @return (ps name, [chainId,prescale),...])
880 return [(r)
for r
in res
if r[2]==
'ReRun']
◆ getStreams()
def python.TrigConfigSvcUtils.getStreams |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 668 of file TrigConfigSvcUtils.py.
672 output = [
'TS.HTR_NAME']
674 tables[
'SM'] =
'SUPER_MASTER_TABLE'
675 tables[
'M2C'] =
'HLT_TM_TO_TC'
676 tables[
'TC'] =
'HLT_TRIGGER_CHAIN'
677 tables[
'MT'] =
'HLT_MASTER_TABLE'
678 tables[
'TS'] =
'HLT_TRIGGER_STREAM'
679 tables[
'C2S'] =
'HLT_TC_TO_TR'
682 condition = [
"SM.SMT_ID = :smk",
683 'SM.SMT_HLT_MASTER_TABLE_ID = MT.HMT_ID',
684 'MT.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
685 'M2C.HTM2TC_TRIGGER_CHAIN_ID = C2S.HTC2TR_TRIGGER_CHAIN_ID',
686 'C2S.HTC2TR_TRIGGER_STREAM_ID = TS.HTR_ID' ]
688 bindvars = {
"smk": smk }
690 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
691 streams = [x[0]
for x
in res]
◆ getTriggerDBCursor()
def python.TrigConfigSvcUtils.getTriggerDBCursor |
( |
|
connection | ) |
|
Definition at line 229 of file TrigConfigSvcUtils.py.
233 technology = connectionParameters[
"techno"]
235 if technology ==
'sqlite':
239 elif technology ==
'oracle':
240 cursor =
_get_oracle_cursor(connectionParameters[
"server"], connectionParameters[
"user"], connectionParameters[
"passwd"])
241 schema = connectionParameters[
"schema"].rstrip(
'.') +
'.'
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 +
'.'
249 elif technology ==
'mysql':
250 cursor =
_get_mysql_cursor(connectionParameters[
"server"], connectionParameters[
"dbname"], connectionParameters[
"user"], connectionParameters[
"passwd"]),
''
◆ getUsedTables()
def python.TrigConfigSvcUtils.getUsedTables |
( |
|
output, |
|
|
|
condition, |
|
|
|
schemaname, |
|
|
|
tables |
|
) |
| |
Definition at line 280 of file TrigConfigSvcUtils.py.
283 usedtables.add(o.split(
'.')[0])
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]
◆ 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.
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
148 log.info(
"Specified connection string '%s'", connection)
157 connectionParameters = {}
158 connection =
str(connection)
161 if ':' in connection:
163 return connectionParameters
167 connectionParameters[
"alias"] = connection
169 return connectionParameters
172 if connectionServices
is None:
173 return connectionParameters
176 sqliteconnections = [conn
for conn
in connectionServices
if conn.startswith(
"sqlite_file")]
177 if len(sqliteconnections)>0:
178 for conn
in sqliteconnections:
180 if connectionParameters[
"filename"]
is not None:
182 if connectionParameters[
"filename"]
is not None:
183 log.info(
"Using sqlite connection %s", connectionParameters)
184 return connectionParameters
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" )
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" )
193 from CoolConvUtilities.AtlCoolLib
import replicaList
194 serverlist=[
'ATLAS_CONFIG' if s==
'ATLAS_COOLPROD' else s
for s
in replicaList()]
196 log.info(
"Trying these servers in order %r", serverlist)
197 for server
in serverlist:
198 log.info(
"Trying server %s", server)
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 )
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" )
211 connectionParameters[
'url'] = frontierServer
212 log.info(
"Using frontier connection %s", frontierconnections[0])
215 elif server==
'atlas_dd':
continue
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 )
222 log.info(
"Using oracle connection %s", oracleconnections[0])
226 return connectionParameters
◆ isRun2()
def python.TrigConfigSvcUtils.isRun2 |
( |
|
cursor, |
|
|
|
schemaname |
|
) |
| |
Definition at line 290 of file TrigConfigSvcUtils.py.
290 def isRun2(cursor,schemaname):
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')
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)
◆ 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 769 of file TrigConfigSvcUtils.py.
770 """returns content of prescale set table and prescale table for a
771 given HLT prescale key
772 @connection - connection string, e.g. TRIGGERDB
773 @psk - HLT prescale key
775 @return (ps name, [('L2/EF/express',chainId,prescale,pass-through),...])
776 In case of 'express', the express stream prescale is returned in the position of the pass-through
781 tables = {
'S' :
'HLT_PRESCALE_SET'
783 output = [
'S.HPS_NAME' ]
786 "S.HPS_ID = '%i'" % psk
789 res =
executeQuery(cursor, output, condition, schemaname, tables)
793 tables = {
'PS':
'HLT_PRESCALE'
795 output = [
'PS.HPR_L2_OR_EF',
'PS.HPR_CHAIN_COUNTER',
'PS.HPR_PRESCALE',
'PS.HPR_PASS_THROUGH_RATE']
798 "PS.HPR_PRESCALE_SET_ID = '%i'" % psk
801 res =
executeQuery(cursor, output, condition, schemaname, tables)
◆ queryHLTPrescaleTableRun2()
def python.TrigConfigSvcUtils.queryHLTPrescaleTableRun2 |
( |
|
connection, |
|
|
|
psk, |
|
|
|
smk |
|
) |
| |
Definition at line 884 of file TrigConfigSvcUtils.py.
889 for entry
in prescales:
894 log.warning(
"Selected HLT Prescale Key not associated with Supermaster key")
899 output = [
"HTC.HTC_NAME",
"PS.HPR_CHAIN_COUNTER",
"PS.HPR_TYPE",
"PS.HPR_CONDITION" ,
"PS.HPR_VALUE"]
902 tables[
'PS'] =
'HLT_PRESCALE'
903 tables[
'HTC'] =
'HLT_TRIGGER_CHAIN'
904 tables[
'TM2TC'] =
'HLT_TM_TO_TC'
905 tables[
'HTM'] =
'HLT_TRIGGER_MENU'
906 tables[
'HMT'] =
'HLT_MASTER_TABLE'
907 tables[
'SM'] =
'SUPER_MASTER_TABLE'
909 condition = [
"PS.HPR_PRESCALE_SET_ID = :psk",
910 "HTC.HTC_CHAIN_COUNTER = PS.HPR_CHAIN_COUNTER",
911 "TM2TC.HTM2TC_TRIGGER_CHAIN_ID = HTC.HTC_ID",
912 "TM2TC.HTM2TC_TRIGGER_MENU_ID = HTM.HTM_ID",
913 "HTM.HTM_ID = HMT.HMT_TRIGGER_MENU_ID",
914 "HMT.HMT_ID = SM.SMT_HLT_MASTER_TABLE_ID",
915 "SM.SMT_ID = %s" % smk
918 bindvars = {
"psk": psk }
920 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
◆ test()
def python.TrigConfigSvcUtils.test |
( |
| ) |
|
Definition at line 946 of file TrigConfigSvcUtils.py.
947 log.setLevel(logging.DEBUG)
950 print(
"""####################################
954 ####################################""")
956 strm_oracle =
getStreams(
"TRIGGERDBREPR", 539)
957 print(
"\nList of Streams in SMK 539 %s\n" % strm_oracle)
960 print(
"""####################################
964 ####################################""")
965 strm_frontier =
getStreams(
"TRIGGERDBREPR", 539)
966 print(
"\nList of Streams in SMK 539 %s\n" % strm_frontier)
968 if strm_oracle == strm_frontier:
969 print(
"""####################################
971 ## ORACLE and FRONTIER give IDENTICAL results
973 ####################################""")
975 print(
"""####################################
977 ## ERROR: ORACLE and FRONTIER give DIFFERENT results
979 ####################################""")
◆ test1()
def python.TrigConfigSvcUtils.test1 |
( |
| ) |
|
◆ test2()
def python.TrigConfigSvcUtils.test2 |
( |
| ) |
|
Definition at line 985 of file TrigConfigSvcUtils.py.
986 log.setLevel(logging.WARNING)
988 connections = [
"TRIGGERDB",
1001 for c
in connections:
1002 print(
"\nConnecting to alias %s" % c)
1005 print(
"SUCCESS : %s" % schema)
◆ authDict
python.TrigConfigSvcUtils.authDict |
◆ log
python.TrigConfigSvcUtils.log |
def getMenuNameFromDB(connection, hltprescalekey)
def getReRunPrescalesRun2(connection, psk, smk)
def executeQuery(cursor, output, condition, schemaname, tables, bindvars=())
def _getFileLocalOrPath(filename, pathenv)
def getL1Items(connection, smk)
def getAlgorithmsForMenu(connection, smk)
def getKeysFromNameRelease(connection, name, release, l1only)
def getKeysFromName(connection, name, MCOnly=False)
def getStreams(connection, smk)
def getFrontierCursor(urls, schema, loglevel=logging.INFO)
def getChains(connection, smk)
def getPrescaleFromCut(cut)
def getHLTPrescalesFromSMK(connection, smk)
def _getConnectionServicesForAlias(alias)
def getExpressStreamPrescales(connection, psk)
def _get_sqlite_cursor(filename)
def getExpressStreamPrescalesRun2(connection, psk, smk)
def getAlgorithmsForMenuRun2(connection, smk)
def queryHLTPrescaleTable(connection, psk)
def getTriggerDBCursor(connection)
def getPropertyFromDB(connection, smk, component, parameter)
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.
def getChainsWithLowerChainNames(connection, smk)
void print(char *figname, TCanvas *c1)
def isRun2(cursor, schemaname)
def getUsedTables(output, condition, schemaname, tables)
std::string join(const std::vector< std::string > &v, const char c=',')
def queryHLTPrescaleTableRun2(connection, psk, smk)
def _readAuthentication()
def _getConnectionParameters(connection)
def getBunchGroupContent(connection, bgsk)
def interpretConnection(connection, debug=False, resolveAlias=True)
def getHLTPrescales(connection, psk)
def getChainsAndStreams(connection, smk)
def _get_mysql_cursor(host, db, user, passwd="")
def getL1Prescales(connection, l1prescalekey)
def _get_oracle_cursor(tns, user, passwd="")
def getHLTPrescalesRun2(connection, psk, smk)