ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::MultiRangeBField Class Referencefinal

Magnetic field provider modelling a magnetic field consisting of several (potentially overlapping) regions of constant values. More...

#include <Acts/MagneticField/MultiRangeBField.hpp>

Inheritance diagram for Acts::MultiRangeBField:
[legend]
Collaboration diagram for Acts::MultiRangeBField:
[legend]

Public Member Functions

 MultiRangeBField (const std::vector< BFieldRange > &ranges)
 Construct a magnetic field from a vector of ranges.
 MultiRangeBField (std::vector< BFieldRange > &&ranges)
 Construct from a vector of magnetic field ranges (move version).
Result< Vector3 > getField (const Vector3 &position, MagneticFieldProvider::Cache &cache) const override
 Request the value of the magnetic field at a given position.
Result< FieldAndGradient > getFieldAndGradient (const Vector3 &position, MagneticFieldProvider::Cache &cache) const override
 Retrieve the magnetic field and its spatial gradient at a given location.
MagneticFieldProvider::Cache makeCache (const MagneticFieldContext &mctx) const override
 Construct a cache object.
bool providesFieldGradient () const override
 Check if getFieldAndGradient is implemented by this provider.

Additional Inherited Members

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

Detailed Description

Magnetic field provider modelling a magnetic field consisting of several (potentially overlapping) regions of constant values.

The multi-range constant field allows modelling cases where a magnetic field can be described as multiple (potentially overlapping) regions, each of which has its own constant magnetic field. This provides more flexibility than the Acts::ConstantBField while providing higher performance than Acts::InterpolatedBFieldMap.

This magnetic field provider is configured using a list of pairs, where each pair defines a region in three-dimensional space as well as a field vector. Magnetic field lookup then proceeds by finding the last region in the user-provided list that contains the requested coordinate and returning the corresponding field vector.

The implementation uses a simple caching mechanism to store the last matched region, providing improved performance for consecutive lookups within the same region. This is thread-safe when each thread uses its own cache instance. The field configuration itself is immutable after construction.

Constructor & Destructor Documentation

◆ MultiRangeBField() [1/2]

Acts::MultiRangeBField::MultiRangeBField ( const std::vector< BFieldRange > & ranges)
explicit

Construct a magnetic field from a vector of ranges.

Parameters
rangesVector of magnetic field ranges to use
Warning
These ranges are listed in increasing order of precedence, i.e. ranges further along the vector have higher priority.

◆ MultiRangeBField() [2/2]

Acts::MultiRangeBField::MultiRangeBField ( std::vector< BFieldRange > && ranges)
explicit

Construct from a vector of magnetic field ranges (move version).

Parameters
rangesVector of magnetic field ranges to use (moved)
Warning
These ranges are listed in increasing order of precedence, i.e. ranges further along the vector have higher priority.

Member Function Documentation

◆ getField()

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

Request the value of the magnetic field at a given position.

Parameters
[in]positionGlobal 3D position for the lookup.
[in,out]cacheCache object.
Returns
A successful value containing a field vector if the given location is contained inside any of the regions, or a failure value otherwise.

Implements Acts::MagneticFieldProvider.

◆ getFieldAndGradient()

Result< FieldAndGradient > Acts::MultiRangeBField::getFieldAndGradient ( const Vector3 & position,
MagneticFieldProvider::Cache & cache ) const
overridevirtual

Retrieve the magnetic field and its spatial gradient at a given location.

Parameters
[in]positionglobal 3D position for the lookup
[in,out]cacheField provider specific cache object
Returns
field and gradient at the given position, or MagneticFieldError::NotImplemented if providesFieldGradient is false
Note
The field is the field vector of the region that getField selects. Each region has one constant field vector, so the gradient is zero at every position inside the regions. At the edge between two regions the field jumps. A jump has no finite gradient, so the gradient does not describe it.

Reimplemented from Acts::MagneticFieldProvider.

◆ makeCache()

MagneticFieldProvider::Cache Acts::MultiRangeBField::makeCache ( const MagneticFieldContext & mctx) const
overridevirtual

Construct a cache object.

Parameters
mctxMagnetic field context for cache creation
Returns
Cache object for magnetic field computations

Implements Acts::MagneticFieldProvider.

◆ providesFieldGradient()

bool Acts::MultiRangeBField::providesFieldGradient ( ) const
overridevirtual

Check if getFieldAndGradient is implemented by this provider.

If it is false, the caller has to compute the gradient in a different way, for example with finite differences of getField.

Returns
true if the provider implements the field gradient

Reimplemented from Acts::MagneticFieldProvider.