ATLAS Offline Software
Loading...
Searching...
No Matches
python.DualUseConfig Namespace Reference

Functions

 createComponent (typeName, instanceName, componentType)
 createAlgorithm (typeName, instanceName)
 createReentrantAlgorithm (typeName, instanceName)
 createPublicTool (typeName, toolName)
 createService (typeName, serviceName, sequence=None)
 addPrivateTool (alg, toolName, typeName)
 addPrivateToolInArray (alg, toolName, typeName)

Variables

bool isAthena = False

Function Documentation

◆ addPrivateTool()

addPrivateTool ( alg,
toolName,
typeName )
Helper function for declaring a private tool for a dual-use algorithm

This function is meant to be used in the analysis algorithm sequence
configurations for setting up private tools on the analysis algorithms.
Private tools that could then be configured with a syntax shared between
Athena and EventLoop.

Keyword arguments:
  alg      -- The algorithm to set up the private tool on
  toolName -- The property name with which the tool handle was declared on
              the algorithm. Also the instance name of the tool.
  typeName -- The C++ type name of the private tool

Definition at line 131 of file DualUseConfig.py.

131def addPrivateTool( alg, toolName, typeName ):
132 """Helper function for declaring a private tool for a dual-use algorithm
133
134 This function is meant to be used in the analysis algorithm sequence
135 configurations for setting up private tools on the analysis algorithms.
136 Private tools that could then be configured with a syntax shared between
137 Athena and EventLoop.
138
139 Keyword arguments:
140 alg -- The algorithm to set up the private tool on
141 toolName -- The property name with which the tool handle was declared on
142 the algorithm. Also the instance name of the tool.
143 typeName -- The C++ type name of the private tool
144 """
145
146 if isAthena:
147
148 # First try to set up the private tool in an "Athena way".
149
150 # Tokenize the tool's name. In case it is a subtool of a tool, or
151 # something possibly even deeper.
152 toolNames = toolName.split( '.' )
153
154 # Look up the component that we need to set up the private tool on:
155 component = alg
156 for tname in toolNames[ 0 : -1 ]:
157 component = getattr( component, tname )
158
159 # Now look up the Athena configurable describing this tool:
160 toolClass = CompFactory.getComp(typeName)
161
162 # Finally, set up the tool handle property:
163 setattr( component, toolNames[ -1 ], toolClass( toolNames[ -1 ] ) )
164
165 else:
166
167 # If that failed, then we should be in an EventLoop environment. So
168 # let's rely on the standalone specific formalism for setting up the
169 # private tool.
170 alg.addPrivateTool( toolName, typeName )
171
172

◆ addPrivateToolInArray()

addPrivateToolInArray ( alg,
toolName,
typeName )
Helper function for declaring a private tool in an array for a
dual-use algorithm

This function is meant to be used in the analysis algorithm
sequence configurations for setting up private tools in arrays on
the analysis algorithms.  Private tools that could then be
configured with a syntax shared between Athena and EventLoop.

Keyword arguments:
  alg      -- The algorithm to set up the private tool on
  toolName -- The property name with which the tool handle was declared on
              the algorithm. Also the instance name of the tool.
  typeName -- The C++ type name of the private tool

Definition at line 173 of file DualUseConfig.py.

173def addPrivateToolInArray( alg, toolName, typeName ):
174 """Helper function for declaring a private tool in an array for a
175 dual-use algorithm
176
177 This function is meant to be used in the analysis algorithm
178 sequence configurations for setting up private tools in arrays on
179 the analysis algorithms. Private tools that could then be
180 configured with a syntax shared between Athena and EventLoop.
181
182 Keyword arguments:
183 alg -- The algorithm to set up the private tool on
184 toolName -- The property name with which the tool handle was declared on
185 the algorithm. Also the instance name of the tool.
186 typeName -- The C++ type name of the private tool
187
188 """
189
190 if isAthena:
191
192 # First try to set up the private tool in an "Athena way".
193
194 # Tokenize the tool's name. In case it is a subtool of a tool, or
195 # something possibly even deeper.
196 toolNames = toolName.split( '.' )
197
198 # Look up the component that we need to set up the private tool on:
199 component = alg
200 for tname in toolNames[ 0 : -1 ]:
201 component = getattr( component, tname )
202
203 # Now look up the Athena configurable describing this tool:
204 toolClass = CompFactory.getComp(typeName)
205
206 # Finally, set up the tool handle property, and return the tool that
207 # was just appended (not the whole tool-handle array), so that callers
208 # can configure it the same way they do in EventLoop.
209 theTool = toolClass( toolNames[ -1 ] )
210 getattr( component, toolNames[ -1 ] ).append( theTool )
211 return theTool
212
213 else:
214
215 # If that failed, then we should be in an EventLoop environment. So
216 # let's rely on the standalone specific formalism for setting up the
217 # private tool.
218 return alg.addPrivateToolInArray( toolName, typeName )

◆ createAlgorithm()

createAlgorithm ( typeName,
instanceName )
Create an algorithm configurable

This function is used to create an algorithm "configurable" in a dual-use
way, either returning an actual Athena configurable, or an appropriately
configured EL::AnaAlgorithmConfig instance.

Keyword arguments:
  typeName     -- The C++ type name of the algorithm
  instanceName -- The instance name of the algorithm to create

Definition at line 46 of file DualUseConfig.py.

46def createAlgorithm( typeName, instanceName ):
47 """Create an algorithm configurable
48
49 This function is used to create an algorithm "configurable" in a dual-use
50 way, either returning an actual Athena configurable, or an appropriately
51 configured EL::AnaAlgorithmConfig instance.
52
53 Keyword arguments:
54 typeName -- The C++ type name of the algorithm
55 instanceName -- The instance name of the algorithm to create
56 """
57 return createComponent( typeName, instanceName, 'AnaAlgorithm' )
58
59

◆ createComponent()

createComponent ( typeName,
instanceName,
componentType )
Create a generic configurable

This function is used to create an component "configurable" in a
dual-use way, either returning an actual Athena configurable, or
an appropriately configured PythonConfig instance.

Keyword arguments:
  typeName      -- The C++ type name of the component
  instanceName  -- The instance name of the component to create
  componentType -- The type of component in AnalysisBase

Definition at line 12 of file DualUseConfig.py.

12def createComponent( typeName, instanceName, componentType ):
13 """Create a generic configurable
14
15 This function is used to create an component "configurable" in a
16 dual-use way, either returning an actual Athena configurable, or
17 an appropriately configured PythonConfig instance.
18
19 Keyword arguments:
20 typeName -- The C++ type name of the component
21 instanceName -- The instance name of the component to create
22 componentType -- The type of component in AnalysisBase
23
24 """
25
26 if isAthena:
27 # Try to get a configurable for this C++ class "from Athena".
28 # If this succeeds, we're obviously in an Athena environment.
29
30 # Look up the Athena configurable of this component:
31 componentClass = CompFactory.getComp(typeName)
32
33 # Return the object:
34 return componentClass( instanceName )
35
36 else:
37 # If that didn't work, then apparently we're in an EventLoop
38 # environment, so we need to use PythonConfig as the base class
39 # for the user's class.
40 from AnaAlgorithm.PythonConfig import PythonConfig
41 component = PythonConfig( f'{typeName}/{instanceName}' )
42 component.setComponentType( componentType )
43 return component
44
45

◆ createPublicTool()

createPublicTool ( typeName,
toolName )
Helper function for setting up a public tool for a dual-use algorithm

This function is meant to be used in the analysis algorithm sequence
configurations for setting up public tools on the analysis algorithms.
Public tools that could then be configured with a syntax shared between
Athena and EventLoop.

Keyword arguments:
  typeName -- The C++ type name of the private tool
  toolName -- The property name with which the tool handle was declared on
              the algorithm. Also the instance name of the tool.

Definition at line 75 of file DualUseConfig.py.

75def createPublicTool( typeName, toolName ):
76 """Helper function for setting up a public tool for a dual-use algorithm
77
78 This function is meant to be used in the analysis algorithm sequence
79 configurations for setting up public tools on the analysis algorithms.
80 Public tools that could then be configured with a syntax shared between
81 Athena and EventLoop.
82
83 Keyword arguments:
84 typeName -- The C++ type name of the private tool
85 toolName -- The property name with which the tool handle was declared on
86 the algorithm. Also the instance name of the tool.
87 """
88
89 if isAthena:
90 # Look up the Athena configurable of this tool:
91 return CompFactory.getComp( typeName )( toolName )
92
93 else:
94 # If that didn't work, then apparently we're in an EventLoop
95 # environment, so let's use the EventLoop specific formalism.
96 return createComponent( typeName, toolName, 'AsgTool' )
97
98

◆ createReentrantAlgorithm()

createReentrantAlgorithm ( typeName,
instanceName )
Create a reentrant algorithm configurable

This function is used to create an algorithm "configurable" in a dual-use
way, either returning an actual Athena configurable, or an appropriately
configured PythonConfig instance (with component type
AnaReentrantAlgorithm).

Keyword arguments:
  typeName     -- The C++ type name of the algorithm
  instanceName -- The instance name of the algorithm to create

Definition at line 60 of file DualUseConfig.py.

60def createReentrantAlgorithm( typeName, instanceName ):
61 """Create a reentrant algorithm configurable
62
63 This function is used to create an algorithm "configurable" in a dual-use
64 way, either returning an actual Athena configurable, or an appropriately
65 configured PythonConfig instance (with component type
66 AnaReentrantAlgorithm).
67
68 Keyword arguments:
69 typeName -- The C++ type name of the algorithm
70 instanceName -- The instance name of the algorithm to create
71 """
72 return createComponent( typeName, instanceName, 'AnaReentrantAlgorithm' )
73
74

◆ createService()

createService ( typeName,
serviceName,
sequence = None )
Helper function for setting up a service for a dual-use algorithm

This function is meant to be used to set up services in a dual-use
manner, particularly for the common CP algorithms.  This allows to
use the same syntax in EventLoop and Athena, hiding the
differences internally.  Since in EventLoop the service gets added
to a sequence (but in Athena does not), that sequence needs to be
passed into this function.

Keyword arguments:
  typeName -- The C++ type name of the service
  serviceName -- The name with which the service handle was configured on
                the algorithm. Also the instance name of the service.
  sequence -- an optional argument of an algorithm sequence to add it to
              in EventLoop (ignored in Athena)

Definition at line 99 of file DualUseConfig.py.

99def createService( typeName, serviceName, sequence=None ):
100 """Helper function for setting up a service for a dual-use algorithm
101
102 This function is meant to be used to set up services in a dual-use
103 manner, particularly for the common CP algorithms. This allows to
104 use the same syntax in EventLoop and Athena, hiding the
105 differences internally. Since in EventLoop the service gets added
106 to a sequence (but in Athena does not), that sequence needs to be
107 passed into this function.
108
109 Keyword arguments:
110 typeName -- The C++ type name of the service
111 serviceName -- The name with which the service handle was configured on
112 the algorithm. Also the instance name of the service.
113 sequence -- an optional argument of an algorithm sequence to add it to
114 in EventLoop (ignored in Athena)
115
116 """
117
118 if isAthena:
119 # Look up the Athena configurable of this serivce:
120 return CompFactory.getComp( typeName )( serviceName )
121
122 else:
123 # If that didn't work, then apparently we're in an EventLoop
124 # environment, so let's use the EventLoop specific formalism.
125 service = createComponent( typeName, serviceName, 'AsgService' )
126 if sequence is not None :
127 sequence += service
128 return service
129
130

Variable Documentation

◆ isAthena

bool isAthena = False

Definition at line 3 of file DualUseConfig.py.