3 useComponentAccumulator =
False
9 from AthenaConfiguration.ComponentFactory
import isComponentAccumulatorCfg
17 """Create a generic configurable
19 This function is used to create an component "configurable" in a
20 dual-use way, either returning an actual Athena configurable, or
21 an appropriately configured PythonConfig instance.
24 typeName -- The C++ type name of the component
25 instanceName -- The instance name of the component to create
26 componentType -- The type of component in AnalysisBase
31 global useComponentAccumulator
38 from AthenaConfiguration.ComponentFactory
import CompFactory
39 componentClass = CompFactory.getComp(typeName)
42 return componentClass( instanceName )
48 from AnaAlgorithm.PythonConfig
import PythonConfig
49 component = PythonConfig(
'%s/%s' % ( typeName, instanceName ) )
50 component.setComponentType( componentType )
57 """Create an algorithm configurable
59 This function is used to create an algorithm "configurable" in a dual-use
60 way, either returning an actual Athena configurable, or an appropriately
61 configured EL::AnaAlgorithmConfig instance.
64 typeName -- The C++ type name of the algorithm
65 instanceName -- The instance name of the algorithm to create
71 """Create a reentrant algorithm configurable
73 This function is used to create an algorithm "configurable" in a dual-use
74 way, either returning an actual Athena configurable, or an appropriately
75 configured EL::AnaAlgorithmConfig instance.
78 typeName -- The C++ type name of the algorithm
79 instanceName -- The instance name of the algorithm to create
81 return createComponent( typeName, instanceName,
'AnaReentrantAlgorithm' )
85 """Helper function for setting up a public tool for a dual-use algorithm
87 This function is meant to be used in the analysis algorithm sequence
88 configurations for setting up public tools on the analysis algorithms.
89 Public tools that could then be configured with a syntax shared between
93 typeName -- The C++ type name of the private tool
94 toolName -- The property name with which the tool handle was declared on
95 the algorithm. Also the instance name of the tool.
99 global useComponentAccumulator
103 from AthenaConfiguration.ComponentFactory
import CompFactory
104 toolClass = CompFactory.getComp( typeName )
106 if useComponentAccumulator:
110 return toolClass( toolName )
113 from AthenaCommon.AppMgr
import ToolSvc
114 if not hasattr( ToolSvc, toolName ):
115 ToolSvc += toolClass( toolName )
119 return getattr( ToolSvc, toolName )
128 """Helper function for setting up a service for a dual-use algorithm
130 This function is meant to be used to set up services in a dual-use
131 manner, particularly for the common CP algorithms. This allows to
132 use the same syntax in EventLoop and Athena, hiding the
133 differences internally. Since in EventLoop the service gets added
134 to a sequence (but in Athena does not), that sequence needs to be
135 passed into this function.
138 typeName -- The C++ type name of the service
139 serviceName -- The name with which the service handle was configured on
140 the algorithm. Also the instance name of the service.
141 sequence -- an optional argument of an algorithm sequence to add it to
142 in EventLoop (ignored in Athena)
147 global useComponentAccumulator
152 from AthenaConfiguration.ComponentFactory
import CompFactory
153 serviceClass = CompFactory.getComp( typeName )
155 if useComponentAccumulator:
159 return serviceClass( serviceName )
162 from AthenaCommon.AppMgr
import ServiceMgr
163 if not hasattr( ServiceMgr, serviceName ):
164 ServiceMgr += serviceClass( serviceName )
168 return getattr( ServiceMgr, serviceName )
174 if sequence
is not None :
181 """Helper function for declaring a private tool for a dual-use algorithm
183 This function is meant to be used in the analysis algorithm sequence
184 configurations for setting up private tools on the analysis algorithms.
185 Private tools that could then be configured with a syntax shared between
186 Athena and EventLoop.
189 alg -- The algorithm to set up the private tool on
190 toolName -- The property name with which the tool handle was declared on
191 the algorithm. Also the instance name of the tool.
192 typeName -- The C++ type name of the private tool
203 toolNames = toolName.split(
'.' )
207 for tname
in toolNames[ 0 : -1 ]:
208 component = getattr( component, tname )
212 from AthenaConfiguration.ComponentFactory
import CompFactory
213 toolClass = CompFactory.getComp(typeName)
216 setattr( component, toolNames[ -1 ], toolClass( toolNames[ -1 ] ) )
223 alg.addPrivateTool( toolName, typeName )
230 """Helper function for declaring a private tool in an array for a
233 This function is meant to be used in the analysis algorithm
234 sequence configurations for setting up private tools in arrays on
235 the analysis algorithms. Private tools that could then be
236 configured with a syntax shared between Athena and EventLoop.
239 alg -- The algorithm to set up the private tool on
240 toolName -- The property name with which the tool handle was declared on
241 the algorithm. Also the instance name of the tool.
242 typeName -- The C++ type name of the private tool
254 toolNames = toolName.split(
'.' )
258 for tname
in toolNames[ 0 : -1 ]:
259 component = getattr( component, tname )
263 from AthenaConfiguration.ComponentFactory
import CompFactory
264 toolClass = CompFactory.getComp(typeName)
267 getattr( component, toolNames[ -1 ] ).append (toolClass( toolNames[ -1 ] ) )
268 return getattr( component, toolNames[ -1 ] )
275 return alg.addPrivateToolInArray( toolName, typeName )