ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::MagneticFieldProvider Class Referenceabstract

Base class for all magnetic field providers. More...

#include <Acts/MagneticField/MagneticFieldProvider.hpp>

Inheritance diagram for Acts::MagneticFieldProvider:
[legend]

Public Types

using Cache = Acts::AnyBase<sizeof(char) * 512>
 Opaque cache type that can store arbitrary implementation specific cache data.

Public Member Functions

virtual ~MagneticFieldProvider ()=default
virtual Result< Vector3getField (const Vector3 &position, Cache &cache) const =0
 Retrieve magnetic field value at a given location.
virtual Cache makeCache (const MagneticFieldContext &mctx) const =0
 Make an opaque cache for the magnetic field.

Detailed Description

Base class for all magnetic field providers.

All magnetic field implementations inherit and implement from this interface.

It provides a generic interface over different implementations. To speed up magnetic field lookup, each implementation can have a cache object. The cache object can for example be used to store a local interpolation domain, to speed up nearby field lookups. The client is expected to pass into lookup calls an instance of Acts::MagneticFieldProvider::Cache.

The implementation is then free to use and update this cache instance as needed. Before a client can issue field lookup calls, it needs to obtain an initialized instance of this cache object. This can be achieved generically for all implementations by using Acts::MagneticFieldProvider::makeCache. This function accepts an instance of Acts::MagneticFieldContext.

The main lookup method of Acts::MagneticFieldProvider is Acts::MagneticFieldProvider::getField

Aside from the lookup position as a global position vector, it accepts an instance of the opaque cache object mentioned before. The return value is a Acts::Result object. It either contains the field value at the requested location, or an Acts::MagneticFieldError in case of a lookup failure, like an out-of-bounds lookup position.

Below is an example of how a client can interact with an instance of Acts::MagneticFieldProvider.

// In event context
auto fieldContext = getExperimentFieldContext();
const Acts::MagneticFieldProvider& fieldProvider = getFieldProvider();
// Make an opaque cache for field lookups
auto cache = fieldProvider.makeCache(fieldContext);
auto lookupResult = fieldProvider.getField(Acts::Vector3{10, 10, 10},
cache);
if(!lookupResult.ok()) {
throw std::runtime_error{"Field lookup failure"};
}
Acts::Vector3 fieldValue = *lookupResult;
Base class for all magnetic field providers.
Definition MagneticFieldProvider.hpp:64
virtual Result< Vector3 > getField(const Vector3 &position, Cache &cache) const =0
Retrieve magnetic field value at a given location.
virtual Cache makeCache(const MagneticFieldContext &mctx) const =0
Make an opaque cache for the magnetic field.
ActsVector< 3 > Vector3
3-dimensional vector type for e.g. spatial coordinates and momenta
Definition Algebra.hpp:72

Member Typedef Documentation

◆ Cache

Opaque cache type that can store arbitrary implementation specific cache data.

Examples are an interpolation cell, or an experiment specific conditions data handle.

The cache is always creaded through makeCache.

Constructor & Destructor Documentation

◆ ~MagneticFieldProvider()

virtual Acts::MagneticFieldProvider::~MagneticFieldProvider ( )
virtualdefault

Member Function Documentation

◆ getField()

virtual Result< Vector3 > Acts::MagneticFieldProvider::getField ( const Vector3 & position,
Cache & cache ) const
pure virtual

Retrieve magnetic field value at a given location.

Requires an instance of Acts::MagneticFieldProvider::Cache created through makeCache.

Parameters
[in]positionglobal 3D position for the lookup
[in,out]cacheField provider specific cache object
Returns
magnetic field vector at given position

Implemented in Acts::ConstantBField, Acts::InterpolatedBFieldMap< grid_t >, Acts::MultiRangeBField, Acts::NullBField, Acts::SolenoidBField, Acts::ToroidField, and ActsPlugins::DD4hepFieldAdapter.

◆ makeCache()

virtual Cache Acts::MagneticFieldProvider::makeCache ( const MagneticFieldContext & mctx) const
pure virtual

Make an opaque cache for the magnetic field.

Instructs the specific implementation to generate a Acts::MagneticFieldProvider::Cache instance for magnetic field lookup.

Parameters
mctxThe magnetic field context to generate cache for
Returns
Cache The opaque cache object

Implemented in Acts::ConstantBField, Acts::InterpolatedBFieldMap< grid_t >, Acts::MultiRangeBField, Acts::NullBField, Acts::SolenoidBField, Acts::ToroidField, and ActsPlugins::DD4hepFieldAdapter.