ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
python.AnaAlgorithmConfig.PrivateToolConfig Class Reference
Inheritance diagram for python.AnaAlgorithmConfig.PrivateToolConfig:
Collaboration diagram for python.AnaAlgorithmConfig.PrivateToolConfig:

Public Member Functions

def __init__ (self, algorithm, prefix, type)
 
def __getattr__ (self, name)
 
def __setattr__ (self, key, value)
 
def __str__ (self)
 

Private Attributes

 _algorithm
 
 _prefix
 
 _type
 
 _props
 

Detailed Description

Standalone Private Tool Configuration

This class is used to mimic the behaviour of Athena tool configurable
classes. To be able to set the properties of private tools used by
dual-use algorithms in a way that's valid for both Athena and EventLoop.

Definition at line 298 of file AnaAlgorithmConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.AnaAlgorithmConfig.PrivateToolConfig.__init__ (   self,
  algorithm,
  prefix,
  type 
)
Constructor for an private tool configuration object

Definition at line 306 of file AnaAlgorithmConfig.py.

306  def __init__( self, algorithm, prefix, type ):
307  """Constructor for an private tool configuration object
308  """
309 
310  self._algorithm = algorithm
311  self._prefix = prefix
312  self._type = type
313  self._props = {}
314 
315  pass
316 

Member Function Documentation

◆ __getattr__()

def python.AnaAlgorithmConfig.PrivateToolConfig.__getattr__ (   self,
  name 
)
Get a previously set property value from the configuration

This function allows us to retrieve the value of a tool property that
was already set for an algorithm's private tool, to possibly use it in
some configuration decisions in the Python code itself.

Keyword arguments:
  name -- The name of the property

Definition at line 317 of file AnaAlgorithmConfig.py.

317  def __getattr__( self, name ):
318  """Get a previously set property value from the configuration
319 
320  This function allows us to retrieve the value of a tool property that
321  was already set for an algorithm's private tool, to possibly use it in
322  some configuration decisions in the Python code itself.
323 
324  Keyword arguments:
325  name -- The name of the property
326  """
327 
328  # Fail if the property was not (yet) set:
329  if not name in self._props:
330  raise AttributeError( 'Property "%s" was not set on "%s/%s.%s"' %
331  ( name, self._algorithm.type(),
332  self._algorithm.name(), self._prefix ) )
333 
334  # Return the property value:
335  return self._props[ name ]
336 

◆ __setattr__()

def python.AnaAlgorithmConfig.PrivateToolConfig.__setattr__ (   self,
  key,
  value 
)
Set a tool property on an existing configuration object

This function allows us to set/override properties on a private tool
of an algorithm configuration object. Allowing for the following syntax:

   alg = ...
   alg.Tool.IntProperty = 66
   alg.Tool.FloatProperty = 3.141592
   alg.Tool.StringProperty = "Foo"

Keyword arguments:
  key   -- The key/name of the property
  value -- The value to set for the property

Definition at line 337 of file AnaAlgorithmConfig.py.

337  def __setattr__( self, key, value ):
338  """Set a tool property on an existing configuration object
339 
340  This function allows us to set/override properties on a private tool
341  of an algorithm configuration object. Allowing for the following syntax:
342 
343  alg = ...
344  alg.Tool.IntProperty = 66
345  alg.Tool.FloatProperty = 3.141592
346  alg.Tool.StringProperty = "Foo"
347 
348  Keyword arguments:
349  key -- The key/name of the property
350  value -- The value to set for the property
351  """
352 
353  # Private variables should be set directly:
354  if key[ 0 ] == '_':
355  return super( PrivateToolConfig, self ).__setattr__( key, value )
356 
357  # Construct the full name, used in the C++ code:
358  fullName = self._prefix + "." + key
359 
360  # Set the property, and remember its value:
361  self._algorithm.setPropertyFromString( fullName,
362  stringPropValue( value ) )
363  self._props[ key ] = copy.deepcopy( value )
364  pass
365 

◆ __str__()

def python.AnaAlgorithmConfig.PrivateToolConfig.__str__ (   self)
Print the private tool configuration in a user friendly way

This is just to help with debugging configurations, allowing
the user to get a nice printout of their job configuration.

Definition at line 366 of file AnaAlgorithmConfig.py.

366  def __str__( self ):
367  """Print the private tool configuration in a user friendly way
368 
369  This is just to help with debugging configurations, allowing
370  the user to get a nice printout of their job configuration.
371  """
372 
373  name = 'Private Tool %s/%s' % ( self._type, self._prefix )
374  result = ' \n'
375  result += AnaAlgorithmConfig._printHeader( name )
376  result += '\n'
377  for key, value in sorted( self._props.items() ):
378  if isinstance( value, str ):
379  printedValue = "'%s'" % value
380  else:
381  printedValue = value
382  pass
383  result += "|- %s: %s\n" % ( key, indentBy( printedValue, "| " ) )
384  pass
385  result += AnaAlgorithmConfig._printFooter( name )
386  return result
387 

Member Data Documentation

◆ _algorithm

python.AnaAlgorithmConfig.PrivateToolConfig._algorithm
private

Definition at line 310 of file AnaAlgorithmConfig.py.

◆ _prefix

python.AnaAlgorithmConfig.PrivateToolConfig._prefix
private

Definition at line 311 of file AnaAlgorithmConfig.py.

◆ _props

python.AnaAlgorithmConfig.PrivateToolConfig._props
private

Definition at line 313 of file AnaAlgorithmConfig.py.

◆ _type

python.AnaAlgorithmConfig.PrivateToolConfig._type
private

Definition at line 312 of file AnaAlgorithmConfig.py.


The documentation for this class was generated from the following file:
python.AnaAlgorithmConfig.indentBy
def indentBy(propValue, indent)
Definition: AnaAlgorithmConfig.py:401
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.AnaAlgorithmConfig.stringPropValue
def stringPropValue(value)
Definition: AnaAlgorithmConfig.py:391
python.PyAthenaComps.__setattr__
__setattr__
Definition: PyAthenaComps.py:41