Skip to content
Snippets Groups Projects
Commit 56bde404 authored by R D Schaffer's avatar R D Schaffer Committed by Frank Winklmeier
Browse files

moving attributes back to float from double, and just doing calculations with...

moving attributes back to float from double, and just doing calculations with explicit casts to double
parent 13e227a5
No related branches found
No related tags found
No related merge requests found
...@@ -104,9 +104,9 @@ private: ...@@ -104,9 +104,9 @@ private:
double m_zmin, m_zmax; // bin range in z double m_zmin, m_zmax; // bin range in z
double m_rmin, m_rmax; // bin range in r double m_rmin, m_rmax; // bin range in r
double m_phimin, m_phimax; // bin range in phi double m_phimin, m_phimax; // bin range in phi
float m_invz, m_invr, m_invphi; // 1/(bin size) in z, r, phi double m_invz, m_invr, m_invphi; // 1/(bin size) in z, r, phi
float m_field[3][8]; // (Bz,Br,Bphi) at 8 corners of the bin double m_field[3][8]; // (Bz,Br,Bphi) at 8 corners of the bin
float m_scale; // unit of m_field in kT double m_scale; // unit of m_field in kT
}; };
#include "BFieldCache.icc" #include "BFieldCache.icc"
......
...@@ -19,26 +19,25 @@ BFieldCache::getB(const double* ATH_RESTRICT xyz, ...@@ -19,26 +19,25 @@ BFieldCache::getB(const double* ATH_RESTRICT xyz,
phi += 2 * M_PI; phi += 2 * M_PI;
} }
// fractional position inside this bin // fractional position inside this bin
const float fz = (z - m_zmin) * m_invz; const double fz = (z - m_zmin) * m_invz;
const float gz = 1.0 - fz; const double gz = 1.0 - fz;
const float fr = (r - m_rmin) * m_invr; const double fr = (r - m_rmin) * m_invr;
const float gr = 1.0 - fr; const double gr = 1.0 - fr;
const float fphi = (phi - m_phimin) * m_invphi; const double fphi = (phi - m_phimin) * m_invphi;
const float gphi = 1.0 - fphi; const double gphi = 1.0 - fphi;
// interpolate field values in z, r, phi // interpolate field values in z, r, phi
const float scale = m_scale; double Bzrphi[3];
float Bzrphi[3];
for (int i = 0; i < 3; i++) { // z, r, phi components for (int i = 0; i < 3; i++) { // z, r, phi components
const float* field = m_field[i]; const double* field = m_field[i];
Bzrphi[i] = scale * (gz * (gr * (gphi * field[0] + fphi * field[1]) + Bzrphi[i] = m_scale * (gz * (gr * (gphi * field[0] + fphi * field[1]) +
fr * (gphi * field[2] + fphi * field[3])) + fr * (gphi * field[2] + fphi * field[3])) +
fz * (gr * (gphi * field[4] + fphi * field[5]) + fz * (gr * (gphi * field[4] + fphi * field[5]) +
fr * (gphi * field[6] + fphi * field[7]))); fr * (gphi * field[6] + fphi * field[7])));
} }
// convert (Bz,Br,Bphi) to (Bx,By,Bz) // convert (Bz,Br,Bphi) to (Bx,By,Bz)
float invr; double invr;
float c; double c;
float s; double s;
if (r > 0.0) { if (r > 0.0) {
invr = 1.0 / r; invr = 1.0 / r;
c = x * invr; c = x * invr;
...@@ -54,37 +53,43 @@ BFieldCache::getB(const double* ATH_RESTRICT xyz, ...@@ -54,37 +53,43 @@ BFieldCache::getB(const double* ATH_RESTRICT xyz,
// compute field derivatives if requested // compute field derivatives if requested
if (deriv) { if (deriv) {
const float sz = m_scale * m_invz; const double sz = m_scale * m_invz;
const float sr = m_scale * m_invr; const double sr = m_scale * m_invr;
const float sphi = m_scale * m_invphi; const double sphi = m_scale * m_invphi;
float dBdz[3]; double dBdz[3];
float dBdr[3]; double dBdr[3];
float dBdphi[3]; double dBdphi[3];
for (int j = 0; j < 3; j++) { // Bz, Br, Bphi components for (int j = 0; j < 3; j++) { // Bz, Br, Bphi components
const float* field = m_field[j]; const double* field = m_field[j];
dBdz[j] = dBdz[j] =
sz * sz *
(gr * (gphi * (field[4] - field[0]) + fphi * (field[5] - field[1])) + (gr * (gphi * (field[4] - field[0]) +
fr * (gphi * (field[6] - field[2]) + fphi * (field[7] - field[3]))); fphi * (field[5] - field[1])) +
fr * (gphi * (field[6] - field[2]) +
fphi * (field[7] - field[3])));
dBdr[j] = dBdr[j] =
sr * sr *
(gz * (gphi * (field[2] - field[0]) + fphi * (field[3] - field[1])) + (gz * (gphi * (field[2] - field[0]) +
fz * (gphi * (field[6] - field[4]) + fphi * (field[7] - field[5]))); fphi * (field[3] - field[1])) +
fz * (gphi * (field[6] - field[4]) +
fphi * (field[7] - field[5])));
dBdphi[j] = dBdphi[j] =
sphi * (gz * (gr * (field[1] - field[0]) + fr * (field[3] - field[2])) + sphi * (gz * (gr * (field[1] - field[0]) +
fz * (gr * (field[5] - field[4]) + fr * (field[7] - field[6]))); fr * (field[3] - field[2])) +
fz * (gr * (field[5] - field[4]) +
fr * (field[7] - field[6])));
} }
// convert to cartesian coordinates // convert to cartesian coordinates
const float cc = c * c; const double cc = c * c;
const float cs = c * s; const double cs = c * s;
const float ss = s * s; const double ss = s * s;
const float ccinvr = cc * invr; const double ccinvr = cc * invr;
const float csinvr = cs * invr; const double csinvr = cs * invr;
const float ssinvr = ss * invr; const double ssinvr = ss * invr;
const float sinvr = s * invr; const double sinvr = s * invr;
const float cinvr = c * invr; const double cinvr = c * invr;
deriv[0] = cc * dBdr[1] - cs * dBdr[2] - csinvr * dBdphi[1] + deriv[0] = cc * dBdr[1] - cs * dBdr[2] - csinvr * dBdphi[1] +
ssinvr * dBdphi[2] + sinvr * B[1]; ssinvr * dBdphi[2] + sinvr * B[1];
deriv[1] = cs * dBdr[1] - ss * dBdr[2] + ccinvr * dBdphi[1] - deriv[1] = cs * dBdr[1] - ss * dBdr[2] + ccinvr * dBdphi[1] -
......
...@@ -66,8 +66,8 @@ public: ...@@ -66,8 +66,8 @@ public:
private: private:
double m_zmin, m_zmax; // bin range in z double m_zmin, m_zmax; // bin range in z
double m_rmin, m_rmax; // bin range in r double m_rmin, m_rmax; // bin range in r
float m_invz, m_invr; // 1/(bin size) in z, r double m_invz, m_invr; // 1/(bin size) in z, r
float m_field[2][4]; // (Bz,Br) at 4 corners of the bin double m_field[2][4]; // (Bz,Br) at 4 corners of the bin
}; };
#include "BFieldCacheZR.icc" #include "BFieldCacheZR.icc"
#endif #endif
...@@ -10,48 +10,50 @@ BFieldCacheZR::getB(const double* xyz, double r, double* B, double* deriv) const ...@@ -10,48 +10,50 @@ BFieldCacheZR::getB(const double* xyz, double r, double* B, double* deriv) const
const double& y(xyz[1]); const double& y(xyz[1]);
const double& z(xyz[2]); const double& z(xyz[2]);
// fractional position inside this bin // fractional position inside this bin
float fz = (z - m_zmin) * m_invz; double fz = (z - m_zmin) * m_invz;
float gz = 1.0 - fz; double gz = 1.0 - fz;
float fr = (r - m_rmin) * m_invr; double fr = (r - m_rmin) * m_invr;
float gr = 1.0 - fr; double gr = 1.0 - fr;
// interpolate field values in z, r // interpolate field values in z, r
float Bzr[2]; double Bzr[2];
for (int i = 0; i < 2; i++) { // z, r components for (int i = 0; i < 2; i++) { // z, r components
const float* field = m_field[i]; const double* field = m_field[i];
Bzr[i] = gz * (gr * field[0] + fr * field[1]) + Bzr[i] = gz * (gr * field[0] + fr * field[1]) +
fz * (gr * field[2] + fr * field[3]); fz * (gr * field[2] + fr * field[3]);
} }
// convert (Bz,Br) to (Bx,By,Bz) // convert (Bz,Br) to (Bx,By,Bz)
float invr; double invr;
if (r > 0.0) { if (r > 0.0) {
invr = 1.0 / r; invr = 1.0 / r;
} else { } else {
invr = 0.0; invr = 0.0;
} }
float c(x * invr); double c(x * invr);
float s(y * invr); double s(y * invr);
B[0] = Bzr[1] * c; B[0] = Bzr[1] * c;
B[1] = Bzr[1] * s; B[1] = Bzr[1] * s;
B[2] = Bzr[0]; B[2] = Bzr[0];
// compute field derivatives if requested // compute field derivatives if requested
if (deriv) { if (deriv) {
float dBdz[2]; double dBdz[2];
float dBdr[2]; double dBdr[2];
for (int j = 0; j < 2; j++) { // Bz, Br components for (int j = 0; j < 2; j++) { // Bz, Br components
const float* field = m_field[j]; const double* field = m_field[j];
dBdz[j] = dBdz[j] =
m_invz * (gr * (field[2] - field[0]) + fr * (field[3] - field[1])); m_invz * (gr * (field[2] - field[0]) +
fr * (field[3] - field[1]));
dBdr[j] = dBdr[j] =
m_invr * (gz * (field[1] - field[0]) + fz * (field[3] - field[2])); m_invr * (gz * (field[1] - field[0]) +
fz * (field[3] - field[2]));
} }
// convert to cartesian coordinates // convert to cartesian coordinates
float cc = c * c; double cc = c * c;
float cs = c * s; double cs = c * s;
float ss = s * s; double ss = s * s;
float sinvr = s * invr; double sinvr = s * invr;
float cinvr = c * invr; double cinvr = c * invr;
deriv[0] = cc * dBdr[1] + sinvr * B[1]; deriv[0] = cc * dBdr[1] + sinvr * B[1];
deriv[1] = cs * dBdr[1] - cinvr * B[1]; deriv[1] = cs * dBdr[1] - cinvr * B[1];
deriv[2] = c * dBdz[1]; deriv[2] = c * dBdz[1];
......
...@@ -26,19 +26,19 @@ public: ...@@ -26,19 +26,19 @@ public:
~BFieldVectorZR() = default; ~BFieldVectorZR() = default;
//constructor //constructor
BFieldVectorZR(float Bz, float Br) BFieldVectorZR(double Bz, double Br)
: m_B{ Bz, Br } : m_B{ Bz, Br }
{} {}
// setter // setter
void set(float Bz, float Br) { m_B = { Bz, Br }; } void set(double Bz, double Br) { m_B = { Bz, Br }; }
// accessors // accessors
float z() const { return m_B[0]; } double z() const { return m_B[0]; }
float r() const { return m_B[1]; } double r() const { return m_B[1]; }
// array-like accessor // array-like accessor
float operator[](size_t i) const { return m_B[i]; } double operator[](size_t i) const { return m_B[i]; }
private: private:
std::array<float, 2> m_B; std::array<double, 2> m_B;
}; };
#endif #endif
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
284500 87473063 62 76 5 2 6 2 4 6 4 2 284500 87473063 62 76 5 2 6 2 4 6 4 2
284500 87473068 26 35 1 1 0 0 0 0 0 0 284500 87473068 26 35 1 1 0 0 0 0 0 0
284500 87473075 72 84 6 0 5 0 5 5 4 1 284500 87473075 72 84 6 0 5 0 5 5 4 1
284500 87473084 83 86 7 2 14 1 13 10 5 5 284500 87473084 83 86 7 3 14 1 13 10 5 5
284500 87473091 43 49 3 0 2 1 1 5 2 3 284500 87473091 43 49 3 0 2 1 1 5 2 3
284500 87473096 72 75 3 2 2 0 2 3 2 1 284500 87473096 72 75 3 2 2 0 2 3 2 1
284500 87473104 61 63 6 0 6 1 5 5 4 1 284500 87473104 61 63 6 0 6 1 5 5 4 1
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
330470 1183733040 381 285 6 1 330470 1183733040 381 285 6 1
330470 1183734651 361 363 14 3 330470 1183734651 361 363 14 3
330470 1183735332 406 370 9 1 330470 1183735332 406 370 9 1
330470 1183736475 741 650 17 3 330470 1183736475 741 650 17 2
330470 1183738728 1 0 0 0 330470 1183738728 1 0 0 0
330470 1183738949 368 418 9 1 330470 1183738949 368 418 9 1
330470 1183742489 152 125 2 1 330470 1183742489 152 125 2 1
......
...@@ -25,7 +25,7 @@ ciRefFileMap = { ...@@ -25,7 +25,7 @@ ciRefFileMap = {
's3505-21.0' : 'v1', 's3505-21.0' : 'v1',
's3505-21.3' : 'v1', 's3505-21.3' : 'v1',
's3505-21.9' : 'v1', 's3505-21.9' : 'v1',
's3505-22.0' : 'v4', 's3505-22.0' : 'v5',
# OverlayTier0Test_required-test # OverlayTier0Test_required-test
'overlay-d1498-21.0' : 'v2', 'overlay-d1498-21.0' : 'v2',
'overlay-d1498-22.0' : 'v32', 'overlay-d1498-22.0' : 'v32',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment