ATLAS Offline Software
Loading...
Searching...
No Matches
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
AtlasFieldCacheoperator= (AtlasFieldCache &&other)=default
 Move-able and copy-able.
 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
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.
bool solenoidOn () const
 status of the magnets
bool toroidOn () const

Private Member Functions

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

Private Attributes

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

Detailed Description

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

We keep track of the

  • magnetic field map
  • solenoid/toroid scales from the currents
  • The current zone
  • The current/cached cell in the zone.
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}
Scalar phi() const
phi method
#define y
#define xyz
#define x
#define z
const AtlasFieldMap * m_fieldMap
handle to the magnetic field map - not owned
BFieldCache m_cache3d
Full 3d field cell/cache This will be a cell inside a 3d field zone.
bool fillFieldCache(double z, double r, double phi)
fill given magnetic field zone *‍/
const std::vector< BFieldCond > * m_cond
Pointer to the conductors in the current field zone (to compute Biot-Savart component) Owned by Atlas...
int r
Definition globals.cxx:22

◆ 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}
bool fillFieldCacheZR(double z, double r)
fill Z-R cache for solenoid *‍/
BFieldCacheZR m_cacheZR
Fast 2d field cell/cache.
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,...

◆ 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.

125{};

◆ 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.

117{ nullptr };

◆ 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.

102{ nullptr };

◆ 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.

122{ nullptr };

◆ m_scaleToUse

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

Definition at line 95 of file AtlasFieldCache.h.

95{ 1 };

◆ m_solScale

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

magnetic field scales from currents

Definition at line 93 of file AtlasFieldCache.h.

93{ 1 };

◆ m_solZoneId

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

Definition at line 99 of file AtlasFieldCache.h.

99{ -1 };

◆ m_torScale

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

Definition at line 94 of file AtlasFieldCache.h.

94{ 1 };

◆ 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.

108{ nullptr };

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