ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
BFieldCache Class Reference

BFieldCache.h. More...

#include <BFieldCache.h>

Collaboration diagram for BFieldCache:

Public Member Functions

 BFieldCache ()=default
 
void invalidate ()
 
void setRange (double zmin, double zmax, double rmin, double rmax, double phimin, double phimax)
 
void setField (const CxxUtils::vec< double, 8 > &field1, const CxxUtils::vec< double, 8 > &field2, const CxxUtils::vec< double, 8 > &field3)
 
void setBscale (double bscale)
 
float bscale () const
 
bool inside (double z, double r, double phi) const
 
void getB (const double *ATH_RESTRICT xyz, double r, double phi, double *ATH_RESTRICT B, double *ATH_RESTRICT deriv=nullptr) const
 

Private Attributes

double m_zmin = 0.0
 
double m_zmax = 0.0
 
double m_rmin = 0.0
 
double m_rmax = 0.0
 
double m_phimin = 0.0
 
double m_phimax = -1.0
 
double m_invz
 
double m_invr
 
double m_invphi
 
double m_scale
 
double m_field [3][8]
 

Detailed Description

BFieldCache.h.

Cache of one bin of the magnetic field map. Defined by ranges in z, r, phi, and the B vectors at the 8 corners of the "bin".

Masahiro Morii, Harvard University

AthenaMT : RD Schaffer , Christos Anastopoulos

Definition at line 24 of file BFieldCache.h.

Constructor & Destructor Documentation

◆ BFieldCache()

BFieldCache::BFieldCache ( )
default

Member Function Documentation

◆ bscale()

float BFieldCache::bscale ( ) const

◆ getB()

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

Definition at line 99 of file BFieldCache.cxx.

103  {
104 
105  const double x = xyz[0];
106  const double y = xyz[1];
107  const double z = xyz[2];
108 
109  // make sure phi is inside [m_phimin,m_phimax]
110  if (phi < m_phimin) {
111  phi += 2 * M_PI;
112  }
113  // fractional position inside this bin
114  const double fz = (z - m_zmin) * m_invz;
115  const double gz = 1.0 - fz;
116  const double fr = (r - m_rmin) * m_invr;
117  const double gr = 1.0 - fr;
118  const double fphi = (phi - m_phimin) * m_invphi;
119  const double gphi = 1.0 - fphi;
120 
121  // get B in Z,r,phi
122  double Bzrphi[4];
123  getBzrphi(Bzrphi, m_field, fz, gz, fr, gr, fphi, gphi, m_scale);
124  // convert (Bz,Br,Bphi) to (Bx,By,Bz)
125  double invr;
126  double c;
127  double s;
128  if (r > 0.0) {
129  invr = 1.0 / r;
130  c = x * invr;
131  s = y * invr;
132  } else {
133  invr = 0.0;
134  c = cos(m_phimin);
135  s = sin(m_phimin);
136  }
137  B[0] = Bzrphi[1] * c - Bzrphi[2] * s;
138  B[1] = Bzrphi[1] * s + Bzrphi[2] * c;
139  B[2] = Bzrphi[0];
140 
141  // compute field derivatives if requested
142  if (deriv) {
143  const double sz = m_scale * m_invz;
144  const double sr = m_scale * m_invr;
145  const double sphi = m_scale * m_invphi;
146 
147  std::array<double, 3> dBdz{};
148  std::array<double, 3> dBdr{};
149  std::array<double, 3> dBdphi{};
150 
151  for (int j = 0; j < 3; ++j) { // Bz, Br, Bphi components
152  const double* field = m_field[j];
153  dBdz[j] =
154  sz *
155  (gr * (gphi * (field[2] - field[0]) + fphi * (field[6] - field[4])) +
156  fr * (gphi * (field[3] - field[1]) + fphi * (field[7] - field[5])));
157  dBdr[j] =
158  sr *
159  (gz * (gphi * (field[1] - field[0]) + fphi * (field[5] - field[4])) +
160  fz * (gphi * (field[3] - field[2]) + fphi * (field[7] - field[6])));
161  dBdphi[j] =
162  sphi * (gz * (gr * (field[4] - field[0]) + fr * (field[5] - field[1])) +
163  fz * (gr * (field[6] - field[2]) + fr * (field[7] - field[3])));
164  }
165 
166  // convert to cartesian coordinates
167  const double cc = c * c;
168  const double cs = c * s;
169  const double ss = s * s;
170  const double ccinvr = cc * invr;
171  const double csinvr = cs * invr;
172  const double ssinvr = ss * invr;
173  const double sinvr = s * invr;
174  const double cinvr = c * invr;
175  deriv[0] = cc * dBdr[1] - cs * dBdr[2] - csinvr * dBdphi[1] +
176  ssinvr * dBdphi[2] + sinvr * B[1];
177  deriv[1] = cs * dBdr[1] - ss * dBdr[2] + ccinvr * dBdphi[1] -
178  csinvr * dBdphi[2] - cinvr * B[1];
179  deriv[2] = c * dBdz[1] - s * dBdz[2];
180  deriv[3] = cs * dBdr[1] + cc * dBdr[2] - ssinvr * dBdphi[1] -
181  csinvr * dBdphi[2] - sinvr * B[0];
182  deriv[4] = ss * dBdr[1] + cs * dBdr[2] + csinvr * dBdphi[1] +
183  ccinvr * dBdphi[2] + cinvr * B[0];
184  deriv[5] = s * dBdz[1] + c * dBdz[2];
185  deriv[6] = c * dBdr[0] - sinvr * dBdphi[0];
186  deriv[7] = s * dBdr[0] + cinvr * dBdphi[0];
187  deriv[8] = dBdz[0];
188  }
189 }

◆ inside()

bool BFieldCache::inside ( double  z,
double  r,
double  phi 
) const

◆ invalidate()

void BFieldCache::invalidate ( )

◆ setBscale()

void BFieldCache::setBscale ( double  bscale)

◆ setField()

void BFieldCache::setField ( const CxxUtils::vec< double, 8 > &  field1,
const CxxUtils::vec< double, 8 > &  field2,
const CxxUtils::vec< double, 8 > &  field3 
)

◆ setRange()

void BFieldCache::setRange ( double  zmin,
double  zmax,
double  rmin,
double  rmax,
double  phimin,
double  phimax 
)

Member Data Documentation

◆ m_field

double BFieldCache::m_field[3][8]
private

Definition at line 74 of file BFieldCache.h.

◆ m_invphi

double BFieldCache::m_invphi
private

Definition at line 72 of file BFieldCache.h.

◆ m_invr

double BFieldCache::m_invr
private

Definition at line 71 of file BFieldCache.h.

◆ m_invz

double BFieldCache::m_invz
private

Definition at line 70 of file BFieldCache.h.

◆ m_phimax

double BFieldCache::m_phimax = -1.0
private

Definition at line 68 of file BFieldCache.h.

◆ m_phimin

double BFieldCache::m_phimin = 0.0
private

Definition at line 67 of file BFieldCache.h.

◆ m_rmax

double BFieldCache::m_rmax = 0.0
private

Definition at line 65 of file BFieldCache.h.

◆ m_rmin

double BFieldCache::m_rmin = 0.0
private

Definition at line 64 of file BFieldCache.h.

◆ m_scale

double BFieldCache::m_scale
private

Definition at line 73 of file BFieldCache.h.

◆ m_zmax

double BFieldCache::m_zmax = 0.0
private

Definition at line 62 of file BFieldCache.h.

◆ m_zmin

double BFieldCache::m_zmin = 0.0
private

Definition at line 61 of file BFieldCache.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
BFieldCache::m_phimin
double m_phimin
Definition: BFieldCache.h:67
BFieldCache::m_invphi
double m_invphi
Definition: BFieldCache.h:72
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
fitman.sz
sz
Definition: fitman.py:527
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xyz
#define xyz
gr
#define gr
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
BFieldCache::m_invr
double m_invr
Definition: BFieldCache.h:71
x
#define x
BFieldCache::m_scale
double m_scale
Definition: BFieldCache.h:73
BFieldCache::m_zmin
double m_zmin
Definition: BFieldCache.h:61
python.SystemOfUnits.sr
int sr
Definition: SystemOfUnits.py:113
z
#define z
BFieldCache::m_rmin
double m_rmin
Definition: BFieldCache.h:64
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
BFieldCache::m_invz
double m_invz
Definition: BFieldCache.h:70
y
#define y
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
grepfile.fr
fr
Definition: grepfile.py:32
python.compressB64.c
def c
Definition: compressB64.py:93
python.handimod.cc
int cc
Definition: handimod.py:523
BFieldCache::m_field
double m_field[3][8]
Definition: BFieldCache.h:74