![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
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 717 of file TrigConfigSvcUtils.py.
721 output = [
"BGS.L1BGS2BG_INTERNAL_NUMBER",
"BG.L1BG2B_BUNCH_NUMBER" ]
723 tables = {
'BGS' :
'L1_BGS_TO_BG',
726 condition = [
"BGS.L1BGS2BG_BUNCH_GROUP_SET_ID = :bgsk",
727 "BGS.L1BGS2BG_BUNCH_GROUP_ID=BG.L1BG2B_BUNCH_GROUP_ID" ]
730 bindvars = {
"bgsk": bgsk }
732 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
734 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)
661 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 818 of file TrigConfigSvcUtils.py.
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
824 @return (ps name, [chainId,prescale),...])
829 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 848 of file TrigConfigSvcUtils.py.
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),...])
861 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 804 of file TrigConfigSvcUtils.py.
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
810 @return (ps name, [('L2/EF',chainId,prescale,pass-through),...])
815 return name, [r
for r
in res
if r[0]!=
'express']
◆ getHLTPrescalesFromSMK()
def python.TrigConfigSvcUtils.getHLTPrescalesFromSMK |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 922 of file TrigConfigSvcUtils.py.
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'
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 ]
939 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 832 of file TrigConfigSvcUtils.py.
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),...])
846 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 694 of file TrigConfigSvcUtils.py.
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'
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 }
710 res =
executeQuery( cursor, output, condition, schemaname, tables, bindvars)
◆ getL1Prescales()
def python.TrigConfigSvcUtils.getL1Prescales |
( |
|
connection, |
|
|
|
l1prescalekey |
|
) |
| |
Definition at line 742 of file TrigConfigSvcUtils.py.
745 isrun2 =
isRun2(cursor,schemaname)
747 maxitems = 512
if isrun2
else 256
748 tables = {
'L' :
'L1_PRESCALE_SET' }
750 output = [
'L.L1PS_NAME'] + [
'L.L1PS_VAL%i' % i
for i
in range(1,maxitems+1)]
752 condition = [
"L.L1PS_ID = '%i'" % l1prescalekey ]
754 res =
executeQuery(cursor, output, condition, schemaname, tables)
756 name,prescales = res[0][0], res[0][1:maxitems+1]
757 if isrun2: prescales = map(getPrescaleFromCut, prescales)
759 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 761 of file TrigConfigSvcUtils.py.
762 """Convert (run-2) prescale cuts into prescale value"""
763 sign = -1
if cut<0
else 1
765 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 865 of file TrigConfigSvcUtils.py.
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),...])
878 return [(r)
for r
in res
if r[2]==
'ReRun']
◆ getStreams()
def python.TrigConfigSvcUtils.getStreams |
( |
|
connection, |
|
|
|
smk |
|
) |
| |
Definition at line 666 of file TrigConfigSvcUtils.py.
670 output = [
'TS.HTR_NAME']
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'
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' ]
686 bindvars = {
"smk": smk }
688 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
689 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 767 of file TrigConfigSvcUtils.py.
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
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
779 tables = {
'S' :
'HLT_PRESCALE_SET'
781 output = [
'S.HPS_NAME' ]
784 "S.HPS_ID = '%i'" % psk
787 res =
executeQuery(cursor, output, condition, schemaname, tables)
791 tables = {
'PS':
'HLT_PRESCALE'
793 output = [
'PS.HPR_L2_OR_EF',
'PS.HPR_CHAIN_COUNTER',
'PS.HPR_PRESCALE',
'PS.HPR_PASS_THROUGH_RATE']
796 "PS.HPR_PRESCALE_SET_ID = '%i'" % psk
799 res =
executeQuery(cursor, output, condition, schemaname, tables)
◆ queryHLTPrescaleTableRun2()
def python.TrigConfigSvcUtils.queryHLTPrescaleTableRun2 |
( |
|
connection, |
|
|
|
psk, |
|
|
|
smk |
|
) |
| |
Definition at line 882 of file TrigConfigSvcUtils.py.
887 for entry
in prescales:
892 log.warning(
"Selected HLT Prescale Key not associated with Supermaster key")
897 output = [
"HTC.HTC_NAME",
"PS.HPR_CHAIN_COUNTER",
"PS.HPR_TYPE",
"PS.HPR_CONDITION" ,
"PS.HPR_VALUE"]
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'
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
916 bindvars = {
"psk": psk }
918 res =
executeQuery(cursor, output, condition, schemaname, tables, bindvars)
◆ test()
def python.TrigConfigSvcUtils.test |
( |
| ) |
|
Definition at line 944 of file TrigConfigSvcUtils.py.
945 log.setLevel(logging.DEBUG)
948 print(
"""####################################
952 ####################################""")
954 strm_oracle =
getStreams(
"TRIGGERDBREPR", 539)
955 print(
"\nList of Streams in SMK 539 %s\n" % strm_oracle)
958 print(
"""####################################
962 ####################################""")
963 strm_frontier =
getStreams(
"TRIGGERDBREPR", 539)
964 print(
"\nList of Streams in SMK 539 %s\n" % strm_frontier)
966 if strm_oracle == strm_frontier:
967 print(
"""####################################
969 ## ORACLE and FRONTIER give IDENTICAL results
971 ####################################""")
973 print(
"""####################################
975 ## ERROR: ORACLE and FRONTIER give DIFFERENT results
977 ####################################""")
◆ test1()
def python.TrigConfigSvcUtils.test1 |
( |
| ) |
|
◆ test2()
def python.TrigConfigSvcUtils.test2 |
( |
| ) |
|
Definition at line 983 of file TrigConfigSvcUtils.py.
984 log.setLevel(logging.WARNING)
986 connections = [
"TRIGGERDB",
999 for c
in connections:
1000 print(
"\nConnecting to alias %s" % c)
1003 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)
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)
std::string print(const MuPatSegment &)
def _get_mysql_cursor(host, db, user, passwd="")
def getL1Prescales(connection, l1prescalekey)
def _get_oracle_cursor(tns, user, passwd="")
def getHLTPrescalesRun2(connection, psk, smk)