File InterpolatedBFieldMap.hpp¶
-
namespace Acts
Note
This file is foreseen for the
Geometry
module to replaceExtent
-
template<typename grid_t>
class InterpolatedBFieldMap : public Acts::InterpolatedMagneticField - #include <Acts/MagneticField/InterpolatedBFieldMap.hpp>
interpolate magnetic field value from field values on a given grid
This class implements a magnetic field service which is initialized by a field map defined by:
a list of field values on a regular grid in some n-Dimensional space,
a transformation of global 3D coordinates onto this n-Dimensional space.
a transformation of local n-Dimensional magnetic field coordinates into global (cartesian) 3D coordinates
The magnetic field value for a given global position is then determined by:
mapping the position onto the grid,
looking up the magnetic field values on the closest grid points,
doing a linear interpolation of these magnetic field values.
- Template Parameters
grid_t – The Grid type which provides the field storage and interpolation
Public Functions
-
inline InterpolatedBFieldMap(Config cfg)
default constructor
-
inline Result<Vector3> getField(const Vector3 &position) const
retrieve field at given position
- Parameters
position – [in] global 3D position
- Returns
magnetic field value at the given position
- Pre
The given
position
must lie within the range of the underlying magnetic field map.
-
inline virtual Result<Vector3> getField(const Vector3 &position, MagneticFieldProvider::Cache &cache) const final
Retrieve magnetic field value at a given location.
Requires a cache object created through makeCache().
- Parameters
position – [in] global 3D position for the lookup
cache – [inout] Field provider specific cache object
- Returns
magnetic field vector at given position
-
inline Result<FieldCell> getFieldCell(const Vector3 &position) const
retrieve field cell for given position
- Parameters
position – [in] global 3D position
- Returns
field cell containing the given global position
- Pre
The given
position
must lie within the range of the underlying magnetic field map.
-
inline virtual Result<Vector3> getFieldGradient(const Vector3 &position, ActsMatrix<3, 3> &derivative, MagneticFieldProvider::Cache &cache) const final
Retrieve magnetic field value its its gradient.
Requires a cache object created through makeCache().
Note
currently the derivative is not calculated
Note
Cache is not used currently
- Parameters
position – [in] global 3D position
derivative – [out] gradient of magnetic field vector as (3x3) matrix
cache – [inout] Field provider specific cache object
- Returns
magnetic field vector
-
inline virtual Vector3 getFieldUnchecked(const Vector3 &position) const final
Get a field value without checking if the lookup position is within the interpolation domain.
- Parameters
position – The lookup position in 3D
- Returns
The field value at
position
-
inline const Grid &getGrid() const
Get a const reference on the underlying grid structure.
- Returns
grid reference
-
inline virtual std::vector<double> getMax() const final
get the maximum value of all axes of the field map
- Returns
vector returning the maxima of all field map axes
-
inline virtual std::vector<double> getMin() const final
get the minimum value of all axes of the field map
- Returns
vector returning the minima of all field map axes
-
inline virtual std::vector<size_t> getNBins() const final
get the number of bins for all axes of the field map
- Returns
vector returning number of bins for all field map axes
-
inline virtual bool isInside(const Vector3 &position) const final
check whether given 3D position is inside look-up domain
- Parameters
position – [in] global 3D position
- Returns
true
if position is inside the defined look-up grid, otherwisefalse
-
inline bool isInsideLocal(const ActsVector<DIM_POS> &gridPosition) const
check whether given 3D position is inside look-up domain
- Parameters
gridPosition – [in] local N-D position
- Returns
true
if position is inside the defined look-up grid, otherwisefalse
-
inline virtual MagneticFieldProvider::Cache makeCache(const MagneticFieldContext &mctx) const final
Make an opaque cache for the magnetic field.
Instructs the specific implementation to generate a
Cache
instance for magnetic field lookup.- Parameters
mctx – The magnetic field context to generate cache for
- Returns
Cache The opaque cache object
Public Static Attributes
-
static constexpr size_t DIM_POS = Grid::DIM
-
struct Cache
- #include <Acts/MagneticField/InterpolatedBFieldMap.hpp>
Public Functions
-
inline Cache(const MagneticFieldContext &mctx)
Constructor with magnetic field context.
- Parameters
mctx – the magnetic field context
-
inline Cache(const MagneticFieldContext &mctx)
-
struct Config
- #include <Acts/MagneticField/InterpolatedBFieldMap.hpp>
Config structure for the interpolated B field map.
Public Members
-
Grid grid
grid storing magnetic field values
-
double scale = 1.
global B-field scaling factor
Note
Negative values for
scale
are accepted and will invert the direction of the magnetic field.
-
std::function<Vector3(const FieldType&, const Vector3&)> transformBField
calculating the global 3D coordinates (cartesian) of the magnetic field with the local n dimensional field and the global 3D position as input
- std::function< ActsVector< DIM_POS >const Vector3 &)> transformPos
mapping of global 3D coordinates (cartesian) onto grid space
-
Grid grid
-
struct FieldCell
- #include <Acts/MagneticField/InterpolatedBFieldMap.hpp>
struct representing smallest grid unit in magnetic field grid
This type encapsulate all required information to perform linear interpolation of magnetic field values within a confined 3D volume.
Public Functions
-
inline FieldCell(std::array<double, DIM_POS> lowerLeft, std::array<double, DIM_POS> upperRight, std::array<Vector3, N> fieldValues)
default constructor
- Parameters
lowerLeft – [in] generalized lower-left corner of hyper box (containing the minima of the hyper box along each Dimension)
upperRight – [in] generalized upper-right corner of hyper box (containing the maxima of the hyper box along each Dimension)
fieldValues – [in] field values at the hyper box corners sorted in the canonical order defined in Acts::interpolate
-
inline Vector3 getField(const ActsVector<DIM_POS> &position) const
retrieve field at given position
- Parameters
position – [in] global 3D position
- Returns
magnetic field value at the given position
- Pre
The given
position
must lie within the current field cell.
-
inline bool isInside(const ActsVector<DIM_POS> &position) const
check whether given 3D position is inside this field cell
- Parameters
position – [in] global 3D position
- Returns
true
if position is inside the current field cell, otherwisefalse
Public Static Attributes
-
static constexpr unsigned int N = 1 << DIM_POS
number of corner points defining the confining hyper-box
-
inline FieldCell(std::array<double, DIM_POS> lowerLeft, std::array<double, DIM_POS> upperRight, std::array<Vector3, N> fieldValues)
-
class InterpolatedMagneticField : public Acts::MagneticFieldProvider
- #include <Acts/MagneticField/InterpolatedBFieldMap.hpp>
Subclassed by Acts::InterpolatedBFieldMap< grid_t >
Public Functions
-
virtual Vector3 getFieldUnchecked(const Vector3 &position) const = 0
Get a field value without checking if the lookup position is within the interpolation domain.
- Parameters
position – The lookup position in 3D
- Returns
The field value at
position
-
virtual std::vector<double> getMax() const = 0
get the maximum value of all axes of the field map
- Returns
vector returning the maxima of all field map axes
-
virtual std::vector<double> getMin() const = 0
get the minimum value of all axes of the field map
- Returns
vector returning the minima of all field map axes
-
virtual std::vector<size_t> getNBins() const = 0
get the number of bins for all axes of the field map
- Returns
vector returning number of bins for all field map axes
-
virtual bool isInside(const Vector3 &position) const = 0
check whether given 3D position is inside look-up domain
- Parameters
position – [in] global 3D position
- Returns
true
if position is inside the defined look-up grid, otherwisefalse
-
virtual Vector3 getFieldUnchecked(const Vector3 &position) const = 0
-
template<typename grid_t>