ATLAS Offline Software
ComponentFactory.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 import sys
4 import AthenaConfiguration.AtlasSemantics # noqa: F401 (load ATLAS-specific semantics)
5 from AthenaCommon.Configurable import Configurable
6 from AthenaCommon.ConfigurableDb import getConfigurable
7 from GaudiConfig2 import Configurables as _cfgs
8 
9 
11  """Returns true if the python fragment is ComponentAccumulator-based"""
12 
13  if ("AthenaCommon.Include" not in sys.modules
14  or not Configurable._useGlobalInstances):
15  return True
16  else:
17  return False
18 
19 
20 class _compFactory1():
21  """Factory providing legacy Configurables with global namespace"""
22 
23  def __getattr__(self,cfgName):
24  if not cfgName.startswith("__"):
25  return getConfigurable(cfgName.replace("::","__"),assumeCxxClass=False)
26 
27  def getComp(self, cfgName):
28  return getConfigurable(cfgName.replace("::","__"),assumeCxxClass=False)
29 
30  def getComps(self, *manyNames):
31  return [getConfigurable(cfgName.replace("::","__"),assumeCxxClass=False) for cfgName in manyNames]
32 
33 
34 class _compFactory2():
35  """Factory providing GaudiConfig2 Configurable without global namespace"""
36 
37  def __getattr__(self,cfgName):
38  if not cfgName.startswith("__"):
39  return getattr(_cfgs,cfgName)
40 
41  def getComp(self, oneName):
42  return _cfgs.getByType(oneName)
43 
44  def getComps(self, *manyNames):
45  return [_cfgs.getByType(cfgName) for cfgName in manyNames]
46 
47 
48 class _compFactory():
49  """Return Configurable factory for legacy/CA jobs"""
50 
51  def _getFactory(self):
53 
54  def __getattr__(self,cfgName):
55  return getattr(self._getFactory(),cfgName)
56 
57  def getComp(self, oneName):
58  return self._getFactory().getComp(oneName)
59 
60  def getComps(self, *manyNames):
61  return self._getFactory().getComps(*manyNames)
62 
63 
64 CompFactory=_compFactory()
python.ComponentFactory._compFactory2
Definition: ComponentFactory.py:34
python.ComponentFactory._compFactory2.getComp
def getComp(self, oneName)
Definition: ComponentFactory.py:41
python.ComponentFactory._compFactory._getFactory
def _getFactory(self)
Definition: ComponentFactory.py:51
python.ConfigurableDb.getConfigurable
def getConfigurable(className, requester='', assumeCxxClass=True)
Definition: ConfigurableDb.py:208
python.ComponentFactory._compFactory.getComps
def getComps(self, *manyNames)
Definition: ComponentFactory.py:60
python.ComponentFactory._compFactory2.__getattr__
def __getattr__(self, cfgName)
Definition: ComponentFactory.py:37
python.ComponentFactory._compFactory1
Definition: ComponentFactory.py:20
python.ComponentFactory._compFactory.__getattr__
def __getattr__(self, cfgName)
Definition: ComponentFactory.py:54
Configurable
athena/gaudi ----------------------------------------------------------—
python.ComponentFactory._compFactory1.__getattr__
def __getattr__(self, cfgName)
Definition: ComponentFactory.py:23
python.ComponentFactory._compFactory2.getComps
def getComps(self, *manyNames)
Definition: ComponentFactory.py:44
python.ComponentFactory._compFactory1.getComp
def getComp(self, cfgName)
Definition: ComponentFactory.py:27
python.JetAnalysisCommon.isComponentAccumulatorCfg
isComponentAccumulatorCfg
Definition: JetAnalysisCommon.py:263
python.ComponentFactory._compFactory
Definition: ComponentFactory.py:48
python.ComponentFactory._compFactory.getComp
def getComp(self, oneName)
Definition: ComponentFactory.py:57
python.ComponentFactory._compFactory1.getComps
def getComps(self, *manyNames)
Definition: ComponentFactory.py:30