# File SolenoidBField.hpp¶

namespace Acts

Set the Geometry Context PLUGIN.

Set the Calibration Context PLUGIN.

Convenience functions to ease creation of and Acts::InterpolatedMaterialMap and to avoid code duplication.

Set the Mangetic Field Context PLUGIN.

Convenience functions to ease creation of and Acts::InterpolatedBFieldMap and to avoid code duplication.

Currently implemented for the two most common formats: rz and xyz.

class SolenoidBField : public Acts::MagneticFieldProvider
#include <Acts/MagneticField/SolenoidBField.hpp>

Implements a multi-coil solenoid magnetic field.

On every call, the field is evaluated at that exact position. The field has radially symmetry, the field vectors point in +z direction. The config exposes a target field value in the center. This value is used to empirically determine a scale factor which reproduces this field value in the center.

E_1(k^2) = complete elliptic integral of the 1st kind E_2(k^2) = complete elliptic integral of the 2nd kind

E_1(k^2) and E_2(k^2) are usually indicated as K(k^2) and E(k^2) in literature, respectively _ 2 / pi / 2 2 2 - 1 / 2 E (k ) = | ( 1 - k sin {theta} ) dtheta 1 _/ 0

```        _          ____________________
```
2 / pi / 2| / 2 2 E (k ) = | |/ 1 - k sin {theta} dtheta 2 _/ 0

k^2 = is a function of the point (r, z) and of the radius of the coil R

2 4Rr k = ————&#8212; 2 2 (R + r) + z Using these, you can evaluate the two components B_r and B_z of the magnetic field: _ _ mu I | / 2 \ | 0 kz | |2 - k | 2 2 | B (r, z) = –&#8212; —&#8212; | |—-&#8212;|E (k ) - E (k ) | r 4pi ___ | | 2| 2 1 | | / 3 |_ \2 - 2k / _| |/ Rr

``` _                                       _
```
mu I | / 2 \ | 0 k | | (R + r)k - 2r | 2 2 | B (r,z) = –&#8212; -&#8212; | | ———–&#8212; | E (k ) + E (k ) | z 4pi __ | | 2 | 2 1 | |/Rr |_ \ 2r(1 - k ) / _|

Public Functions

SolenoidBField(Config config)

the constructur with a shared pointer

Note

since it is a shared field, we enforce it to be const

Template Parameters

bField – is the shared BField to be stored

Vector2 getField(const Vector2 &position) const

Retrieve magnetic field value in local (r,z) coordinates.

Parameters

position[in] local 2D position

Vector3 getField(const Vector3 &position) const

Get the B field at a position.

Parameters

position – The position to query at

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

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

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

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

Private Functions

double B_r(const Vector2 &pos, double scale) const
double B_z(const Vector2 &pos, double scale) const
double k2(double r, double z) const
Vector2 multiCoilField(const Vector2 &pos, double scale) const
Vector2 singleCoilField(const Vector2 &pos, double scale) const

Private Members

Config m_cfg
double m_dz
double m_R2
double m_scale
struct Cache
#include <Acts/MagneticField/SolenoidBField.hpp>

Public Functions

inline Cache(const MagneticFieldContext &mctx)

Constructor with magnetic field context.

Parameters

mctx – the magnetic field context

struct Config
#include <Acts/MagneticField/SolenoidBField.hpp>

Config struct for the SolenoidBfield.

Public Members

double bMagCenter

The target magnetic field strength at the center.

This will be used to scale coefficients

double length

Extent of the solenoid in z.

It goes from -length/2 to +length/2 by convention

size_t nCoils

The number of coils that make up the solenoid.