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()

python.DualUseConfig.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 133 of file DualUseConfig.py.

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

◆ addPrivateToolInArray()

python.DualUseConfig.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 179 of file DualUseConfig.py.

179def addPrivateToolInArray( alg, toolName, typeName ):
180 """Helper function for declaring a private tool in an array for a
181 dual-use algorithm
182
183 This function is meant to be used in the analysis algorithm
184 sequence configurations for setting up private tools in arrays on
185 the analysis algorithms. Private tools that could then be
186 configured with a syntax shared between Athena and EventLoop.
187
188 Keyword arguments:
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
193
194 """
195
196 if isAthena:
197
198 # First try to set up the private tool in an "Athena way".
199
200 # Tokenize the tool's name. In case it is a subtool of a tool, or
201 # something possibly even deeper.
202 toolNames = toolName.split( '.' )
203
204 # Look up the component that we need to set up the private tool on:
205 component = alg
206 for tname in toolNames[ 0 : -1 ]:
207 component = getattr( component, tname )
208 pass
209
210 # Now look up the Athena configurable describing this tool:
211 toolClass = CompFactory.getComp(typeName)
212
213 # Finally, set up the tool handle property:
214 getattr( component, toolNames[ -1 ] ).append (toolClass( toolNames[ -1 ] ) )
215 return getattr( component, toolNames[ -1 ] )
216
217 else:
218
219 # If that failed, then we should be in an EventLoop environment. So
220 # let's rely on the standalone specific formalism for setting up the
221 # private tool.
222 return alg.addPrivateToolInArray( toolName, typeName )
223
224 return

◆ createAlgorithm()

python.DualUseConfig.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 48 of file DualUseConfig.py.

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

◆ createComponent()

python.DualUseConfig.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( '%s/%s' % ( typeName, instanceName ) )
42 component.setComponentType( componentType )
43 return component
44
45 pass
46
47

◆ createPublicTool()

python.DualUseConfig.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 76 of file DualUseConfig.py.

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

◆ createReentrantAlgorithm()

python.DualUseConfig.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 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 62 of file DualUseConfig.py.

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

◆ createService()

python.DualUseConfig.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 100 of file DualUseConfig.py.

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

Variable Documentation

◆ isAthena

bool python.DualUseConfig.isAthena = False

Definition at line 3 of file DualUseConfig.py.