cpalgnodes.componentfacade module
Classes to collect together the configurations of algorithms, tools and services
Jobs in Athena and AnalysisBase are built out of components. Components are written in C++ but all expose values which can be configured called ‘properties’. The classes in this module model these through dictionary-like access. Components come in three main types:
- Algorithms:
Algorithms are the primary pieces of the job. They all have an execute method which is called once per event (unless the event has been rejected by an upstream algorithm).
- Tools:
Tools are more flexible components. Their methods can conform to any interface and must (ultimately) be called by algorithms to do their jobs. Tools can be either public or private. Public tools are globally available and accessible by name. This means that there is only one instance of any named public tool. Generally public tools are no longer recommended with a few exceptions (such as the TrigDecisionTool which must always be public). Private tools are owned by their parent components.
- Services:
Services are also global components. TODO: Properly describe the difference between public tools and services…
- class cpalgnodes.componentfacade.Algorithm(type: str, name: str, **properties)
Bases:
ComponentBase class representing an algorithm
- class cpalgnodes.componentfacade.AlgorithmList(algorithms: List[Algorithm] = [])
Bases:
ConfigFragment,ComponentArrayPiece of the configuration representing a list of algorithms
- copy() AlgorithmList
Create a copy of this component array
- create(sequence: AnaAlgorithm.AlgSequence.AlgSequence | str | None = None, accumulator=None, flags=None)
Creates the full configuration that it describes
- Parameters:
sequence (Union[AlgSequence, str]) – If running in AnalysisBase, the AlgSequence object must be provided as a hook for the public components. If running in athena in the ComponentAccumulator mode a sequence name can be provided and the algorithms will be placed in that sequence. In this case it must already exist in the accumulator.
accumulator (ComponentAccumulator, optional) – If running in athena, a ComponentAccumulator-based configuration can be used instead. To activate this mode pass the accumulator the fragment should be merged into here. When running in this mode the ConfigFlags should also be provided
flags (AthConfigFlags, optional) – The ConfigFlags instance when running in the ComponentAccumulator mode
- Return type:
The list of algorithms that have been created
- class cpalgnodes.componentfacade.Component(type: str, name: str, component_type: ComponentType, **properties)
Bases:
MutableMappingBase class for components
Dictionary-like access is used to set/retrieve properties.
Extra components (e.g. services) that this requires can be provided to the None key.
- class ComponentType(value)
Bases:
EnumAn enumeration.
- Algorithm = 1
- PrivateTool = 3
- PublicTool = 2
- Service = 4
- property is_public: bool
- appendToPrivateToolArray(key: str, type: str, name: str, **properties) PrivateTool
Append a new private tool to the named property
- Parameters:
key (str) – The property on the parent Component to set
type (str) – The type of the private tool
name (str) – The name of the new private tool (ignored in AnalysisBase)
**properties – Any other properties to be set on the private tool
- Return type:
The created private tool
- appendToPublicToolArray(key: str, type: str, name: str, **properties) PublicTool
Append a new public tool to the named property
- Parameters:
key (str) – The property on the parent Component to set
type (str) – The type of the public tool
name (str) – The name of the new public tool
**properties – Any other properties to be set on the public tool
- Return type:
The created public tool
- appendToServiceArray(key: str, type: str, name: str, **properties) Service
Append a new service to the named property
- Parameters:
key (str) – The property on the parent Component to set
type (str) – The type of the service
name (str) – The name of the new service
**properties – Any other properties to be set on the service
- Return type:
The created service
- property component_type: ComponentType
The component type (algorithm, public/private tool or service)
- property full_name: str
The full name of the component (including its parent)
- get(sequence: AnaAlgorithm.AlgSequence.AlgSequence | str | None = None, accumulator=None, flags=None)
Get the real underlying component, creating it if it hasn’t been already
The first time this is called will lock the component, preventing further modification
- Parameters:
sequence (Union[AlgSequence, str]) – If running in AnalysisBase, the AlgSequence object must be provided as a hook for the public components. If running in athena in the ComponentAccumulator mode a sequence name can be provided and the algorithms will be placed in that sequence. In this case it must already exist in the accumulator.
accumulator (ComponentAccumulator, optional) – If running in athena, a ComponentAccumulator-based configuration can be used instead. To activate this mode pass the accumulator the fragment should be merged into here. When running in this mode the ConfigFlags should also be provided
flags (AthConfigFlags, optional) – The ConfigFlags instance when running in the ComponentAccumulator mode
- property is_public: bool
Is this component public
- property locked: bool
Whether the component can still be modified
- merge(other: Component)
Merge this with another component definition with the same name
The default implementation will make sure that the type, name and component type are the same and then merges the properties. If a property is present in both it must be equal.
Note that this implementation is ignored when ComponentAccumulators are used
- Raises:
ValueError – The two components are not equal
- property name: str
The name of the component
- setPrivateTool(key: str, type: str, **properties) PrivateTool
Set the named property to a private tool
- Parameters:
key (str) – The property on the parent Component to set
type (str) – The type of the private tool
**properties – Any other properties to be set on the private tool
- Return type:
The created private tool
- setPublicTool(key: str, type: str, name: str, **properties) PublicTool
Set the named property to a public tool
- Parameters:
key (str) – The property on the parent Component to set
type (str) – The type of the public tool
name (str) – The name of the new public tool
**properties – Any other properties to be set on the public tool
- Return type:
The created public tool
- setService(key: str | None, type: str, name: str, **properties) Service
Set the named property to a service
- Parameters:
key (Optional[str]) – The property on the parent Component to set. If None add the service to the extra components list
type (str) – The type of the service
name (str) – The name of the new service
**properties – Any other properties to be set on the service
- Return type:
The created service
- subcomponents() Iterable[Component]
Iterate over all subcomponents
A subcomponent is any component that is a property (or a property of a property) of this component
- property type: str
The type of the component
- property type_and_full_name: str
The type/full_name string
- property type_and_name: str
The type/name string
- class cpalgnodes.componentfacade.ComponentArray(component_type: ComponentType)
Bases:
MutableSequenceArray of a specific component type
- property component_type: ComponentType
The component type in this array
- abstract copy() ComponentArray
Create a copy of this component array
- get(sequence: AnaAlgorithm.AlgSequence.AlgSequence | str | None = None, accumulator=None, flags=None)
Get the real underlying component, creating it if it hasn’t been already
The first time this is called will lock the component, preventing further modification
- Parameters:
sequence (Union[AlgSequence, str]) – If running in AnalysisBase, the AlgSequence object must be provided as a hook for the public components. If running in athena in the ComponentAccumulator mode a sequence name can be provided and the algorithms will be placed in that sequence. In this case it must already exist in the accumulator.
accumulator (ComponentAccumulator, optional) – If running in athena, a ComponentAccumulator-based configuration can be used instead. To activate this mode pass the accumulator the fragment should be merged into here. When running in this mode the ConfigFlags should also be provided
flags (AthConfigFlags, optional) – The ConfigFlags instance when running in the ComponentAccumulator mode
- property is_public: bool
Whether the components in this array are public
- class cpalgnodes.componentfacade.ConfigFragment
Bases:
ABCRepresents a piece of the configured job which can be converted to a series of algorithms
- abstract create(sequence: AnaAlgorithm.AlgSequence.AlgSequence | str | None = None, accumulator=None, flags=None)
Creates the full configuration that it describes
- Parameters:
sequence (Union[AlgSequence, str]) – If running in AnalysisBase, the AlgSequence object must be provided as a hook for the public components. If running in athena in the ComponentAccumulator mode a sequence name can be provided and the algorithms will be placed in that sequence. In this case it must already exist in the accumulator.
accumulator (ComponentAccumulator, optional) – If running in athena, a ComponentAccumulator-based configuration can be used instead. To activate this mode pass the accumulator the fragment should be merged into here. When running in this mode the ConfigFlags should also be provided
flags (AthConfigFlags, optional) – The ConfigFlags instance when running in the ComponentAccumulator mode
- Return type:
The list of algorithms that have been created
- class cpalgnodes.componentfacade.JobConfiguration
Bases:
ConfigFragment,MutableSequenceRepresents the whole configured job
Acts as a list of smaller configuration fragments
- create(sequence: AnaAlgorithm.AlgSequence.AlgSequence | str | None = None, accumulator=None, flags=None)
Creates the full configuration that it describes
- Parameters:
sequence (Union[AlgSequence, str]) – If running in AnalysisBase, the AlgSequence object must be provided as a hook for the public components. If running in athena in the ComponentAccumulator mode a sequence name can be provided and the algorithms will be placed in that sequence. In this case it must already exist in the accumulator.
accumulator (ComponentAccumulator, optional) – If running in athena, a ComponentAccumulator-based configuration can be used instead. To activate this mode pass the accumulator the fragment should be merged into here. When running in this mode the ConfigFlags should also be provided
flags (AthConfigFlags, optional) – The ConfigFlags instance when running in the ComponentAccumulator mode
- Return type:
The list of algorithms that have been created
- class cpalgnodes.componentfacade.PreconfiguredAlgList(algorithms)
Bases:
ConfigFragmentConfiguration fragment representing a list of already configured algorithms
- create(sequence: AnaAlgorithm.AlgSequence.AlgSequence | str | None = None, accumulator=None, flags=None)
Creates the full configuration that it describes
- Parameters:
sequence (Union[AlgSequence, str]) – If running in AnalysisBase, the AlgSequence object must be provided as a hook for the public components. If running in athena in the ComponentAccumulator mode a sequence name can be provided and the algorithms will be placed in that sequence. In this case it must already exist in the accumulator.
accumulator (ComponentAccumulator, optional) – If running in athena, a ComponentAccumulator-based configuration can be used instead. To activate this mode pass the accumulator the fragment should be merged into here. When running in this mode the ConfigFlags should also be provided
flags (AthConfigFlags, optional) – The ConfigFlags instance when running in the ComponentAccumulator mode
- Return type:
The list of algorithms that have been created
- class cpalgnodes.componentfacade.PreconfiguredComponentAccumulator(accumulator)
Bases:
ConfigFragmentConfiguration fragment representing an already configured CA
- create(sequence: AnaAlgorithm.AlgSequence.AlgSequence | str | None = None, accumulator=None, flags=None)
Creates the full configuration that it describes
- Parameters:
sequence (Union[AlgSequence, str]) – If running in AnalysisBase, the AlgSequence object must be provided as a hook for the public components. If running in athena in the ComponentAccumulator mode a sequence name can be provided and the algorithms will be placed in that sequence. In this case it must already exist in the accumulator.
accumulator (ComponentAccumulator, optional) – If running in athena, a ComponentAccumulator-based configuration can be used instead. To activate this mode pass the accumulator the fragment should be merged into here. When running in this mode the ConfigFlags should also be provided
flags (AthConfigFlags, optional) – The ConfigFlags instance when running in the ComponentAccumulator mode
- Return type:
The list of algorithms that have been created
- class cpalgnodes.componentfacade.PrivateTool(type: str, name: str, **properties)
Bases:
ComponentBase class representing a private tool
Note that the parent must be set before the actual tool object is created
- copy() PrivateTool
Create a copy of this component
- property full_name: str
The full name of the component (including its parent)
- class cpalgnodes.componentfacade.PrivateToolArray
Bases:
ComponentArrayFacade class representing an array of private tools
- copy() PrivateToolArray
Create a copy of this component array
- class cpalgnodes.componentfacade.PublicTool(type: str, name: str, **properties)
Bases:
ComponentBase class representing a public tool
- copy() PublicTool
Create a copy of this component
- property full_name: str
The full name of the component (including its parent)
- class cpalgnodes.componentfacade.PublicToolArray
Bases:
ComponentArrayFacade class representing an array of public tools
- copy() PublicToolArray
Create a copy of this component array
- class cpalgnodes.componentfacade.Service(type: str, name: str, **properties)
Bases:
ComponentBase class representing a service
- class cpalgnodes.componentfacade.ServiceArray
Bases:
ComponentArrayFacade class representing an array of services
- copy() ServiceArray
Create a copy of this component array