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
35 from AthenaConfiguration.ComponentFactory
import CompFactory
36 componentClass = CompFactory.getComp(typeName)
39 return componentClass( instanceName )
45 from AnaAlgorithm.PythonConfig
import PythonConfig
46 component = PythonConfig(
'%s/%s' % ( typeName, instanceName ) )
47 component.setComponentType( componentType )
54 """Create an algorithm configurable
56 This function is used to create an algorithm "configurable" in a dual-use
57 way, either returning an actual Athena configurable, or an appropriately
58 configured EL::AnaAlgorithmConfig instance.
61 typeName -- The C++ type name of the algorithm
62 instanceName -- The instance name of the algorithm to create
68 """Create a reentrant algorithm configurable
70 This function is used to create an algorithm "configurable" in a dual-use
71 way, either returning an actual Athena configurable, or an appropriately
72 configured EL::AnaAlgorithmConfig instance.
75 typeName -- The C++ type name of the algorithm
76 instanceName -- The instance name of the algorithm to create
78 return createComponent( typeName, instanceName,
'AnaReentrantAlgorithm' )
82 """Helper function for setting up a public tool for a dual-use algorithm
84 This function is meant to be used in the analysis algorithm sequence
85 configurations for setting up public tools on the analysis algorithms.
86 Public tools that could then be configured with a syntax shared between
90 typeName -- The C++ type name of the private tool
91 toolName -- The property name with which the tool handle was declared on
92 the algorithm. Also the instance name of the tool.
97 from AthenaConfiguration.ComponentFactory
import CompFactory
98 toolClass = CompFactory.getComp( typeName )
100 if useComponentAccumulator:
104 return toolClass( toolName )
107 from AthenaCommon.AppMgr
import ToolSvc
108 if not hasattr( ToolSvc, toolName ):
109 ToolSvc += toolClass( toolName )
113 return getattr( ToolSvc, toolName )
122 """Helper function for setting up a service for a dual-use algorithm
124 This function is meant to be used to set up services in a dual-use
125 manner, particularly for the common CP algorithms. This allows to
126 use the same syntax in EventLoop and Athena, hiding the
127 differences internally. Since in EventLoop the service gets added
128 to a sequence (but in Athena does not), that sequence needs to be
129 passed into this function.
132 typeName -- The C++ type name of the service
133 serviceName -- The name with which the service handle was configured on
134 the algorithm. Also the instance name of the service.
135 sequence -- an optional argument of an algorithm sequence to add it to
136 in EventLoop (ignored in Athena)
143 from AthenaConfiguration.ComponentFactory
import CompFactory
144 serviceClass = CompFactory.getComp( typeName )
146 if useComponentAccumulator:
150 return serviceClass( serviceName )
153 from AthenaCommon.AppMgr
import ServiceMgr
154 if not hasattr( ServiceMgr, serviceName ):
155 ServiceMgr += serviceClass( serviceName )
159 return getattr( ServiceMgr, serviceName )
165 if sequence
is not None :
172 """Helper function for declaring a private tool for a dual-use algorithm
174 This function is meant to be used in the analysis algorithm sequence
175 configurations for setting up private tools on the analysis algorithms.
176 Private tools that could then be configured with a syntax shared between
177 Athena and EventLoop.
180 alg -- The algorithm to set up the private tool on
181 toolName -- The property name with which the tool handle was declared on
182 the algorithm. Also the instance name of the tool.
183 typeName -- The C++ type name of the private tool
192 toolNames = toolName.split(
'.' )
196 for tname
in toolNames[ 0 : -1 ]:
197 component = getattr( component, tname )
201 from AthenaConfiguration.ComponentFactory
import CompFactory
202 toolClass = CompFactory.getComp(typeName)
205 setattr( component, toolNames[ -1 ], toolClass( toolNames[ -1 ] ) )
212 alg.addPrivateTool( toolName, typeName )
219 """Helper function for declaring a private tool in an array for a
222 This function is meant to be used in the analysis algorithm
223 sequence configurations for setting up private tools in arrays on
224 the analysis algorithms. Private tools that could then be
225 configured with a syntax shared between Athena and EventLoop.
228 alg -- The algorithm to set up the private tool on
229 toolName -- The property name with which the tool handle was declared on
230 the algorithm. Also the instance name of the tool.
231 typeName -- The C++ type name of the private tool
241 toolNames = toolName.split(
'.' )
245 for tname
in toolNames[ 0 : -1 ]:
246 component = getattr( component, tname )
250 from AthenaConfiguration.ComponentFactory
import CompFactory
251 toolClass = CompFactory.getComp(typeName)
254 getattr( component, toolNames[ -1 ] ).append (toolClass( toolNames[ -1 ] ) )
255 return getattr( component, toolNames[ -1 ] )
262 return alg.addPrivateToolInArray( toolName, typeName )