ATLAS Offline Software
Classes | Functions | Variables
python.AthHLT Namespace Reference

Classes

class  CondDB
 

Functions

def get_sor_params (run_number)
 
def get_trigconf_keys (run_number, lb_number)
 
def getCACfg (jopath)
 
def reload_from_json (filename, suppress_args=[])
 

Variables

 log = logging.getLogger('athenaHLT')
 
def d = get_sor_params(327265)
 

Function Documentation

◆ get_sor_params()

def python.AthHLT.get_sor_params (   run_number)

Definition at line 28 of file AthHLT.py.

28 def get_sor_params(run_number):
29  from CoolConvUtilities import AtlCoolLib
30 
31  log.info('Reading SOR record for run %s from COOL', run_number)
32 
33  cdb = CondDB(run_number)
34  dbcon = AtlCoolLib.readOpen('COOLONL_TDAQ/%s' % cdb.db_instance())
35  folder = dbcon.getFolder(cdb.sor_folder())
36 
37  # need to keep sor variable while using payload (cannot do the following in
38  # one single line nor overwrite sor). Otherwise: 1) GC comes into play;
39  # 2) the object is deleted; 3) since it's a shared_ptr, the internal
40  # cool::IObject also gets deleted; 4) payload is not valid any longer
41  try:
42  sor = folder.findObject(run_number << 32, 0)
43  except Exception:
44  return None # This can happen for unknown run numbers
45 
46  payload = sor.payload()
47  d = {k: payload[k] for k in payload}
48  return d
49 
50 
51 @cache

◆ get_trigconf_keys()

def python.AthHLT.get_trigconf_keys (   run_number,
  lb_number 
)
Read Trigger keys from COOL

Definition at line 52 of file AthHLT.py.

52 def get_trigconf_keys(run_number, lb_number):
53  """Read Trigger keys from COOL"""
54 
55  from TrigConfStorage.TriggerCoolUtil import TriggerCoolUtil
56 
57  cdb = CondDB(run_number)
58  db = TriggerCoolUtil.GetConnection(cdb.db_instance())
59  run_range = [[run_number,run_number]]
60  d = {}
61  d['SMK'] = TriggerCoolUtil.getHLTConfigKeys(db, run_range)[run_number]['SMK']
62 
63  def findKey(keys):
64  for (key, firstLB, lastLB) in keys:
65  if lb_number>=firstLB and lb_number<=lastLB:
66  return key
67  return None
68 
69  # Find L1/HLT prescale key
70  d['LVL1PSK'] = findKey(TriggerCoolUtil.getL1ConfigKeys(db, run_range)[run_number]['LVL1PSK'])
71  d['HLTPSK'] = findKey(TriggerCoolUtil.getHLTPrescaleKeys(db, run_range)[run_number]['HLTPSK2'])
72 
73  return d
74 
75 

◆ getCACfg()

def python.AthHLT.getCACfg (   jopath)
Return the CA Cfg function based on joboptions path.
The format is MODULE[.FNC]. If no FNC is given, 'main' will be tried.

Definition at line 76 of file AthHLT.py.

76 def getCACfg(jopath):
77  """Return the CA Cfg function based on joboptions path.
78  The format is MODULE[.FNC]. If no FNC is given, 'main' will be tried."""
79 
80  import importlib
81 
82  sys.path.append('.') # temporarily add local directory to search path
83 
84  # try to import module as given:
85  try:
86  module = importlib.import_module(jopath)
87  except ModuleNotFoundError:
88  if '.' not in jopath:
89  raise
90  # or interpret as module.fnc:
91  mod_name, fnc_name = jopath.rsplit('.', maxsplit=1)
92  module = importlib.import_module(mod_name)
93  else:
94  # if the first import worked we are using the 'main(flags)' function:
95  fnc_name = 'main'
96 
97  sys.path.pop()
98 
99  log.info("Loading %s.%s", module.__name__, fnc_name)
100  return getattr(module, fnc_name)
101 
102 

◆ reload_from_json()

def python.AthHLT.reload_from_json (   filename,
  suppress_args = [] 
)
Re-launch athenaHLT from the given json file. Optionally suppress
the list of command line args (e.g. flags).

Definition at line 103 of file AthHLT.py.

103 def reload_from_json(filename, suppress_args=[]):
104  """Re-launch athenaHLT from the given json file. Optionally suppress
105  the list of command line args (e.g. flags)."""
106 
107  # Remove all command line args that are not compatible with running from JSON:
108  argv = []
109  for arg_index, arg in enumerate(sys.argv):
110  if arg == '--dump-config-reload':
111  continue
112  if arg in ['--precommand', '-c', '--postcommand', '-C']:
113  continue
114  if arg_index > 0 and sys.argv[arg_index-1] in ['--precommand', '-c', '--postcommand', '-C']:
115  continue
116  if arg.startswith('--precommand') or arg.startswith('--postcommand'):
117  continue
118  if arg in suppress_args:
119  continue
120  argv.append(arg)
121 
122  argv[-1] = filename
123  log.info('Restarting %s from %s ...', argv[0], argv[-1])
124  sys.stdout.flush()
125  sys.stderr.flush()
126  os.execvp(argv[0], argv)
127 
128 
129 #
130 # Testing (used as ctest)
131 #

Variable Documentation

◆ d

def python.AthHLT.d = get_sor_params(327265)

Definition at line 139 of file AthHLT.py.

◆ log

python.AthHLT.log = logging.getLogger('athenaHLT')

Definition at line 6 of file AthHLT.py.

python.AthHLT.get_sor_params
def get_sor_params(run_number)
Definition: AthHLT.py:28
python.AthHLT.reload_from_json
def reload_from_json(filename, suppress_args=[])
Definition: AthHLT.py:103
python.AthHLT.get_trigconf_keys
def get_trigconf_keys(run_number, lb_number)
Definition: AthHLT.py:52
python.AthHLT.getCACfg
def getCACfg(jopath)
Definition: AthHLT.py:76