ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MagField::AtlasFieldCache Class Reference

Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h) More...

#include <AtlasFieldCache.h>

Collaboration diagram for MagField::AtlasFieldCache:

Public Member Functions

 AtlasFieldCache ()=default
 
 AtlasFieldCache (double solFieldScale, double torFieldScale, const AtlasFieldMap *fieldMap)
 constructor to setup with field scale and magnetic field map for first access to field More...
 
AtlasFieldCacheoperator= (AtlasFieldCache &&other)=default
 Move-able and copy-able. More...
 
 AtlasFieldCache (AtlasFieldCache &&other)=default
 
 AtlasFieldCache (const AtlasFieldCache &other)=default
 
AtlasFieldCacheoperator= (const AtlasFieldCache &other)=default
 
 ~AtlasFieldCache ()=default
 
void getField (const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
 get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given, field derivatives are returned in kT/mm More...
 
void getFieldZR (const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
 get B field valaue on the z-r plane at given position works only inside the solenoid. More...
 
bool solenoidOn () const
 status of the magnets More...
 
bool toroidOn () const
 

Private Member Functions

bool fillFieldCache (double z, double r, double phi)
 fill given magnetic field zone *‍/ More...
 
bool fillFieldCacheZR (double z, double r)
 fill Z-R cache for solenoid *‍/ More...
 

Private Attributes

double m_solScale { 1 }
 magnetic field scales from currents More...
 
double m_torScale { 1 }
 
double m_scaleToUse { 1 }
 
int m_solZoneId { -1 }
 
const AtlasFieldMapm_fieldMap { nullptr }
 handle to the magnetic field map - not owned More...
 
const BFieldZonem_zone3d { nullptr }
 A zone of the full 3d field. More...
 
BFieldCache m_cache3d
 Full 3d field cell/cache This will be a cell inside a 3d field zone. More...
 
const std::vector< BFieldCond > * m_cond { nullptr }
 Pointer to the conductors in the current field zone (to compute Biot-Savart component) Owned by AtlasFieldMap. More...
 
const BFieldMeshZRm_meshZR { nullptr }
 fast 2d map made of one zone assuming phi/roatational symmetry Owned by AtlasFieldMap. More...
 
BFieldCacheZR m_cacheZR {}
 Fast 2d field cell/cache. More...
 

Detailed Description

Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)

We keep track of the

Author
R.D.Schaffer -at- cern.ch

Definition at line 42 of file AtlasFieldCache.h.

Constructor & Destructor Documentation

◆ AtlasFieldCache() [1/4]

MagField::AtlasFieldCache::AtlasFieldCache ( )
default

◆ AtlasFieldCache() [2/4]

MagField::AtlasFieldCache::AtlasFieldCache ( double  solFieldScale,
double  torFieldScale,
const AtlasFieldMap fieldMap 
)

constructor to setup with field scale and magnetic field map for first access to field

◆ AtlasFieldCache() [3/4]

MagField::AtlasFieldCache::AtlasFieldCache ( AtlasFieldCache &&  other)
default

◆ AtlasFieldCache() [4/4]

MagField::AtlasFieldCache::AtlasFieldCache ( const AtlasFieldCache other)
default

◆ ~AtlasFieldCache()

MagField::AtlasFieldCache::~AtlasFieldCache ( )
default

Member Function Documentation

◆ fillFieldCache()

bool MagField::AtlasFieldCache::fillFieldCache ( double  z,
double  r,
double  phi 
)
private

fill given magnetic field zone *‍/

◆ fillFieldCacheZR()

bool MagField::AtlasFieldCache::fillFieldCacheZR ( double  z,
double  r 
)
private

fill Z-R cache for solenoid *‍/

◆ getField()

void MagField::AtlasFieldCache::getField ( const double *ATH_RESTRICT  xyz,
double *ATH_RESTRICT  bxyz,
double *ATH_RESTRICT  deriv = nullptr 
)

get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given, field derivatives are returned in kT/mm

Definition at line 42 of file AtlasFieldCache.cxx.

45 {
46  // Allow for the case of no map for testing
47  if (m_fieldMap == nullptr) {
48  defaultField(bxyz, deriv);
49  return;
50  }
51 
52  const double x = xyz[0];
53  const double y = xyz[1];
54  const double z = xyz[2];
55  const double r = std::sqrt(x * x + y * y);
56  const double phi = std::atan2(y, x);
57 
58  // Check that the cached z,r, phi cell is valid
59  // and if we are still inside it
60  if (!m_cache3d.inside(z, r, phi)) {
61  // if not we need to find and cache a new cell
62  if (!fillFieldCache(z, r, phi)) {
63  // caching failed
64  // outside the valid map volume
65  defaultField(bxyz, deriv);
66  return;
67  }
68  }
69 
70  // do interpolation (cache3d has correct scale factor)
71  m_cache3d.getB(xyz, r, phi, bxyz, deriv);
72 
73  if (!m_cond) {
74  return;
75  }
76  // add biot savart component - must add in scale factor to avoid changing
77  // conductor SF since the conductor is part of the static magnetic field model
78  const size_t condSize = m_cond->size();
79  for (size_t i = 0; i < condSize; i++) {
80  //Heavy Eigen use from here
81  (*m_cond)[i].addBiotSavart(m_scaleToUse, xyz, bxyz, deriv);
82  }
83 }

◆ getFieldZR()

void MagField::AtlasFieldCache::getFieldZR ( const double *ATH_RESTRICT  xyz,
double *ATH_RESTRICT  bxyz,
double *ATH_RESTRICT  deriv = nullptr 
)

get B field valaue on the z-r plane at given position works only inside the solenoid.

Otherwise call getField above. xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given, field derivatives are returned in kT/mm

Definition at line 86 of file AtlasFieldCache.cxx.

89 {
90 
91  // Allow for the case of no map for testing
92  if (m_fieldMap == nullptr) {
93  defaultField(bxyz, deriv);
94  return;
95  }
96 
97  const double x = xyz[0];
98  const double y = xyz[1];
99  const double z = xyz[2];
100  const double r = std::sqrt(x * x + y * y);
101 
102  // Check that the cached z,r, cell is valid
103  // and if we are still inside it
104  if (!m_cacheZR.inside(z, r)) {
105  // cached cell is invalid -> refresh cached cell
106  if (!fillFieldCacheZR(z, r)) {
107  // No cell found -> outside the valid z-r map volume
108  // fallback to calling
109  // the full version of getField()
110  getField(xyz, bxyz, deriv);
111  return;
112  }
113  }
114  // do interpolation
115  m_cacheZR.getB(xyz, r, bxyz, deriv);
116 }

◆ operator=() [1/2]

AtlasFieldCache& MagField::AtlasFieldCache::operator= ( AtlasFieldCache &&  other)
default

Move-able and copy-able.

◆ operator=() [2/2]

AtlasFieldCache& MagField::AtlasFieldCache::operator= ( const AtlasFieldCache other)
default

◆ solenoidOn()

bool MagField::AtlasFieldCache::solenoidOn ( ) const

status of the magnets

◆ toroidOn()

bool MagField::AtlasFieldCache::toroidOn ( ) const

Member Data Documentation

◆ m_cache3d

BFieldCache MagField::AtlasFieldCache::m_cache3d
private

Full 3d field cell/cache This will be a cell inside a 3d field zone.

Definition at line 113 of file AtlasFieldCache.h.

◆ m_cacheZR

BFieldCacheZR MagField::AtlasFieldCache::m_cacheZR {}
private

Fast 2d field cell/cache.

Definition at line 125 of file AtlasFieldCache.h.

◆ m_cond

const std::vector<BFieldCond>* MagField::AtlasFieldCache::m_cond { nullptr }
private

Pointer to the conductors in the current field zone (to compute Biot-Savart component) Owned by AtlasFieldMap.

Definition at line 117 of file AtlasFieldCache.h.

◆ m_fieldMap

const AtlasFieldMap* MagField::AtlasFieldCache::m_fieldMap { nullptr }
private

handle to the magnetic field map - not owned

Definition at line 102 of file AtlasFieldCache.h.

◆ m_meshZR

const BFieldMeshZR* MagField::AtlasFieldCache::m_meshZR { nullptr }
private

fast 2d map made of one zone assuming phi/roatational symmetry Owned by AtlasFieldMap.

Definition at line 122 of file AtlasFieldCache.h.

◆ m_scaleToUse

double MagField::AtlasFieldCache::m_scaleToUse { 1 }
private

Definition at line 95 of file AtlasFieldCache.h.

◆ m_solScale

double MagField::AtlasFieldCache::m_solScale { 1 }
private

magnetic field scales from currents

Definition at line 93 of file AtlasFieldCache.h.

◆ m_solZoneId

int MagField::AtlasFieldCache::m_solZoneId { -1 }
private

Definition at line 99 of file AtlasFieldCache.h.

◆ m_torScale

double MagField::AtlasFieldCache::m_torScale { 1 }
private

Definition at line 94 of file AtlasFieldCache.h.

◆ m_zone3d

const BFieldZone* MagField::AtlasFieldCache::m_zone3d { nullptr }
private

A zone of the full 3d field.

This can be solenoid or one of the toroid etc zones Owned by AtlasFieldMap

Definition at line 108 of file AtlasFieldCache.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
MagField::AtlasFieldCache::m_scaleToUse
double m_scaleToUse
Definition: AtlasFieldCache.h:95
MagField::AtlasFieldCache::m_cond
const std::vector< BFieldCond > * m_cond
Pointer to the conductors in the current field zone (to compute Biot-Savart component) Owned by Atlas...
Definition: AtlasFieldCache.h:117
MagField::AtlasFieldCache::m_cacheZR
BFieldCacheZR m_cacheZR
Fast 2d field cell/cache.
Definition: AtlasFieldCache.h:125
MagField::AtlasFieldCache::fillFieldCacheZR
bool fillFieldCacheZR(double z, double r)
fill Z-R cache for solenoid *‍/
xyz
#define xyz
BFieldCache::getB
void getB(const double *ATH_RESTRICT xyz, double r, double phi, double *ATH_RESTRICT B, double *ATH_RESTRICT deriv=nullptr) const
Definition: BFieldCache.cxx:99
x
#define x
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
BFieldCacheZR::getB
void getB(const double *ATH_RESTRICT xyz, double r, double *ATH_RESTRICT B, double *ATH_RESTRICT deriv=nullptr) const
Definition: BFieldCacheZR.cxx:9
MagField::AtlasFieldCache::m_fieldMap
const AtlasFieldMap * m_fieldMap
handle to the magnetic field map - not owned
Definition: AtlasFieldCache.h:102
MagField::AtlasFieldCache::m_cache3d
BFieldCache m_cache3d
Full 3d field cell/cache This will be a cell inside a 3d field zone.
Definition: AtlasFieldCache.h:113
BFieldCacheZR::inside
bool inside(double z, double r) const
BFieldCache::inside
bool inside(double z, double r, double phi) const
y
#define y
MagField::AtlasFieldCache::fillFieldCache
bool fillFieldCache(double z, double r, double phi)
fill given magnetic field zone *‍/
MagField::AtlasFieldCache::getField
void getField(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given,...
Definition: AtlasFieldCache.cxx:42