ATLAS Offline Software
Loading...
Searching...
No Matches
BFieldCacheZR Class Reference

#include <BFieldCacheZR.h>

Collaboration diagram for BFieldCacheZR:

Public Member Functions

void invalidate ()
void setRange (double zmin, double zmax, double rmin, double rmax)
void setField (int i, const BFieldVectorZR &field, double scaleFactor=1.0)
bool inside (double z, double r) const
void getB (const double *ATH_RESTRICT xyz, double r, double *ATH_RESTRICT B, double *ATH_RESTRICT deriv=nullptr) const

Private Attributes

double m_zmin {0}
double m_zmax {-1}
double m_rmin {0}
double m_rmax {-1}
double m_invz {-1}
double m_invr {-1}
double m_field [2][4]

Detailed Description

Definition at line 21 of file BFieldCacheZR.h.

Member Function Documentation

◆ getB()

void BFieldCacheZR::getB ( const double *ATH_RESTRICT xyz,
double r,
double *ATH_RESTRICT B,
double *ATH_RESTRICT deriv = nullptr ) const

Definition at line 9 of file BFieldCacheZR.cxx.

13{
14 const double x = xyz[0];
15 const double y = xyz[1];
16 const double z = xyz[2];
17 // fractional position inside this bin
18 const double fz = (z - m_zmin) * m_invz;
19 const double gz = 1.0 - fz;
20 const double fr = (r - m_rmin) * m_invr;
21 const double gr = 1.0 - fr;
22 // interpolate field values in z, r
23 double Bzr[2];
24 for (int i = 0; i < 2; ++i) { // z, r components
25 const double* field = m_field[i];
26 Bzr[i] = gz * (gr * field[0] + fr * field[1]) +
27 fz * (gr * field[2] + fr * field[3]);
28 }
29 // convert (Bz,Br) to (Bx,By,Bz)
30 double invr;
31 if (r > 0.0) {
32 invr = 1.0 / r;
33 } else {
34 invr = 0.0;
35 }
36 const double c(x * invr);
37 const double s(y * invr);
38 B[0] = Bzr[1] * c;
39 B[1] = Bzr[1] * s;
40 B[2] = Bzr[0];
41
42 // compute field derivatives if requested
43 if (deriv) {
44 std::array<double, 2> dBdz{};
45 std::array<double, 2> dBdr{};
46 for (int j = 0; j < 2; ++j) { // Bz, Br components
47 const double* field = m_field[j];
48 dBdz[j] =
49 m_invz * (gr * (field[2] - field[0]) + fr * (field[3] - field[1]));
50 dBdr[j] =
51 m_invr * (gz * (field[1] - field[0]) + fz * (field[3] - field[2]));
52 }
53 // convert to cartesian coordinates
54 const double cc = c * c;
55 const double cs = c * s;
56 const double ss = s * s;
57 const double sinvr = s * invr;
58 const double cinvr = c * invr;
59 deriv[0] = cc * dBdr[1] + sinvr * B[1];
60 deriv[1] = cs * dBdr[1] - cinvr * B[1];
61 deriv[2] = c * dBdz[1];
62 deriv[3] = cs * dBdr[1] - sinvr * B[0];
63 deriv[4] = ss * dBdr[1] + cinvr * B[0];
64 deriv[5] = s * dBdz[1];
65 deriv[6] = c * dBdr[0];
66 deriv[7] = s * dBdr[0];
67 deriv[8] = dBdz[0];
68 }
69}
#define gr
static Double_t ss
#define y
#define xyz
#define x
#define z
double m_field[2][4]
int r
Definition globals.cxx:22

◆ inside()

bool BFieldCacheZR::inside ( double z,
double r ) const

◆ invalidate()

void BFieldCacheZR::invalidate ( )

◆ setField()

void BFieldCacheZR::setField ( int i,
const BFieldVectorZR & field,
double scaleFactor = 1.0 )

◆ setRange()

void BFieldCacheZR::setRange ( double zmin,
double zmax,
double rmin,
double rmax )

Member Data Documentation

◆ m_field

double BFieldCacheZR::m_field[2][4]
private

Definition at line 45 of file BFieldCacheZR.h.

◆ m_invr

double BFieldCacheZR::m_invr {-1}
private

Definition at line 44 of file BFieldCacheZR.h.

44{-1}, m_invr{-1}; // 1/(bin size) in z, r

◆ m_invz

double BFieldCacheZR::m_invz {-1}
private

Definition at line 44 of file BFieldCacheZR.h.

44{-1}, m_invr{-1}; // 1/(bin size) in z, r

◆ m_rmax

double BFieldCacheZR::m_rmax {-1}
private

Definition at line 43 of file BFieldCacheZR.h.

43{0}, m_rmax{-1}; // bin range in r

◆ m_rmin

double BFieldCacheZR::m_rmin {0}
private

Definition at line 43 of file BFieldCacheZR.h.

43{0}, m_rmax{-1}; // bin range in r

◆ m_zmax

double BFieldCacheZR::m_zmax {-1}
private

Definition at line 42 of file BFieldCacheZR.h.

42{0}, m_zmax{-1}; // bin range in z

◆ m_zmin

double BFieldCacheZR::m_zmin {0}
private

Definition at line 42 of file BFieldCacheZR.h.

42{0}, m_zmax{-1}; // bin range in z

The documentation for this class was generated from the following files: