File InterpolatedBFieldMap.hpp

namespace Acts

Note

This file is foreseen for the Geometry module to replace Extent

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 Types

using FieldType = typename Grid::value_type
using Grid = grid_t

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 override

retrieve magnetic field value

Parameters
  • position[in] global 3D position

  • 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 override

retrieve magnetic field value & its gradient

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 override
inline const Grid &getGrid() const

Get a const reference on the underlying grid structure.

Returns

grid reference

inline virtual std::vector<double> getMax() const override

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 override

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 override

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 override

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, otherwise false

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, otherwise false

inline virtual MagneticFieldProvider::Cache makeCache(const MagneticFieldContext &mctx) const override

Make an opaque cache for the magnetic field.

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

Private Members

Config m_cfg
Grid::point_t m_lowerLeft
Grid::point_t m_upperRight
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

Public Members

std::optional<FieldCell> fieldCell
bool initialized = false
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

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, otherwise false

Public Static Attributes

static constexpr unsigned int N = 1 << DIM_POS

number of corner points defining the confining hyper-box

Private Members

std::array<Vector3, N> m_fieldValues

magnetic field vectors at the hyper-box corners

Note

These values must be order according to the prescription detailed in Acts::interpolate.

std::array<double, DIM_POS> m_lowerLeft

generalized lower-left corner of the confining hyper-box

std::array<double, DIM_POS> m_upperRight

generalized upper-right corner of the confining hyper-box

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
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, otherwise false