ATLAS Offline Software
Trigger/TrigTools/TrigInDetConfig/python/utils.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 #
3 # Helper methods for configuration
4 
5 from AthenaConfiguration.AthConfigFlags import AthConfigFlags
6 import logging
7 
8 
10  flags: AthConfigFlags, config_name: str, log: logging.Logger) -> AthConfigFlags:
11 
12  """Get the flags for the named config, ensure that they are set to be active
13 
14  Parameters
15  ----------
16  flags : AthConfigFlags
17  The instance of the flags to check
18  config_name : str
19  The name of the desired tracking config
20  log : logging.Logger
21  Logger to print related messages
22 
23  Returns
24  -------
25  Either the current flags instance if all the ActiveConfig is correct or a new
26  version with cloned flags
27  """
28  if flags.hasFlag("Tracking.ActiveConfig.input_name"):
29  if flags.Tracking.ActiveConfig.input_name == config_name:
30  log.debug(
31  "flags.Tracking.ActiveConfig is for %s",
32  flags.Tracking.ActiveConfig.input_name,
33  )
34  return flags
35  else:
36  log.warning(
37  "flags.Tracking.ActiveConfig is not for %s but %s",
38  config_name,
39  flags.Tracking.ActiveConfig.input_name,
40  )
41  else:
42 
43  log.warning(
44  "Menu code invoked ID config without flags.Tracking.ActiveConfig for %s",
45  config_name,
46  )
47 
48  if flags.Trigger.useActsTracking:
49  return flags.cloneAndReplace("Tracking.ActiveConfig", "Trigger.ActsTracking."+config_name)
50 
51  return cloneFlagsToActiveConfig(flags, config_name)
52 
53 
54 
56  flags: AthConfigFlags, config_name: str) -> AthConfigFlags:
57  """
58  do InDet/ITk specific clone and replace of ActiveConfig without checking flags vs config_name
59 
60  """
61  return flags.cloneAndReplace(
62  "Tracking.ActiveConfig",
63  ("Trigger.ITkTracking." if flags.Detector.GeometryITk else "Trigger.InDetTracking.") + config_name,
64  keepOriginal = True
65  )
python.utils.cloneFlagsToActiveConfig
AthConfigFlags cloneFlagsToActiveConfig(AthConfigFlags flags, str config_name)
Definition: Trigger/TrigTools/TrigInDetConfig/python/utils.py:55
python.utils.getFlagsForActiveConfig
AthConfigFlags getFlagsForActiveConfig(AthConfigFlags flags, str config_name, logging.Logger log)
Definition: Trigger/TrigTools/TrigInDetConfig/python/utils.py:9