12#ifndef LITFIELDSLICE_H_
13#define LITFIELDSLICE_H_
28#define LIT_POLYNOM_DEGREE 7
43#if LIT_POLYNOM_DEGREE == 3
44 static const unsigned int N = 10;
46#if LIT_POLYNOM_DEGREE == 5
47 static const unsigned int N = 21;
49#if LIT_POLYNOM_DEGREE == 7
50 static const unsigned int N = 36;
52#if LIT_POLYNOM_DEGREE == 9
53 static const unsigned int N = 55;
65 for (
unsigned int i = 0; i <
N; i++) {
66 cx[i] =
cy[i] =
cz[i] = 0.;
82#if LIT_POLYNOM_DEGREE == 3
91 +
cx[8] * xy2 +
cx[9] * y3;
94 +
cy[8] * xy2 +
cy[9] * y3;
97 +
cz[8] * xy2 +
cz[9] * y3;
99#if LIT_POLYNOM_DEGREE == 5
122 B.
Bx =
cx[0] +
cx[1] *
x +
cx[2] *
y +
cx[3] * x2 +
cx[4] * xy +
cx[5] * y2 +
cx[6] * x3 +
cx[7] * x2y
123 +
cx[8] * xy2 +
cx[9] * y3 +
cx[10] * x4 +
cx[11] * x3y +
cx[12] * x2y2 +
cx[13] * xy3 +
cx[14] * y4
124 +
cx[15] * x5 +
cx[16] * x4y +
cx[17] * x3y2 +
cx[18] * x2y3 +
cx[19] * xy4 +
cx[20] * y5;
126 B.
By =
cy[0] +
cy[1] *
x +
cy[2] *
y +
cy[3] * x2 +
cy[4] * xy +
cy[5] * y2 +
cy[6] * x3 +
cy[7] * x2y
127 +
cy[8] * xy2 +
cy[9] * y3 +
cy[10] * x4 +
cy[11] * x3y +
cy[12] * x2y2 +
cy[13] * xy3 +
cy[14] * y4
128 +
cy[15] * x5 +
cy[16] * x4y +
cy[17] * x3y2 +
cy[18] * x2y3 +
cy[19] * xy4 +
cy[20] * y5;
130 B.
Bz =
cz[0] +
cz[1] *
x +
cz[2] *
y +
cz[3] * x2 +
cz[4] * xy +
cz[5] * y2 +
cz[6] * x3 +
cz[7] * x2y
131 +
cz[8] * xy2 +
cz[9] * y3 +
cz[10] * x4 +
cz[11] * x3y +
cz[12] * x2y2 +
cz[13] * xy3 +
cz[14] * y4
132 +
cz[15] * x5 +
cz[16] * x4y +
cz[17] * x3y2 +
cz[18] * x2y3 +
cz[19] * xy4 +
cz[20] * y5;
135#if LIT_POLYNOM_DEGREE == 7
175 B.
Bx =
cx[0] +
cx[1] *
x +
cx[2] *
y +
cx[3] * x2 +
cx[4] * xy +
cx[5] * y2 +
cx[6] * x3 +
cx[7] * x2y
176 +
cx[8] * xy2 +
cx[9] * y3 +
cx[10] * x4 +
cx[11] * x3y +
cx[12] * x2y2 +
cx[13] * xy3 +
cx[14] * y4
177 +
cx[15] * x5 +
cx[16] * x4y +
cx[17] * x3y2 +
cx[18] * x2y3 +
cx[19] * xy4 +
cx[20] * y5 +
cx[21] * x6
178 +
cx[22] * x5y +
cx[23] * x4y2 +
cx[24] * x3y3 +
cx[25] * x2y4 +
cx[26] * xy5 +
cx[27] * y6 +
cx[28] * x7
179 +
cx[29] * x6y +
cx[30] * x5y2 +
cx[31] * x4y3 +
cx[32] * x3y4 +
cx[33] * x2y5 +
cx[34] * xy6
182 B.
By =
cy[0] +
cy[1] *
x +
cy[2] *
y +
cy[3] * x2 +
cy[4] * xy +
cy[5] * y2 +
cy[6] * x3 +
cy[7] * x2y
183 +
cy[8] * xy2 +
cy[9] * y3 +
cy[10] * x4 +
cy[11] * x3y +
cy[12] * x2y2 +
cy[13] * xy3 +
cy[14] * y4
184 +
cy[15] * x5 +
cy[16] * x4y +
cy[17] * x3y2 +
cy[18] * x2y3 +
cy[19] * xy4 +
cy[20] * y5 +
cy[21] * x6
185 +
cy[22] * x5y +
cy[23] * x4y2 +
cy[24] * x3y3 +
cy[25] * x2y4 +
cy[26] * xy5 +
cy[27] * y6 +
cy[28] * x7
186 +
cy[29] * x6y +
cy[30] * x5y2 +
cy[31] * x4y3 +
cy[32] * x3y4 +
cy[33] * x2y5 +
cy[34] * xy6
189 B.
Bz =
cz[0] +
cz[1] *
x +
cz[2] *
y +
cz[3] * x2 +
cz[4] * xy +
cz[5] * y2 +
cz[6] * x3 +
cz[7] * x2y
190 +
cz[8] * xy2 +
cz[9] * y3 +
cz[10] * x4 +
cz[11] * x3y +
cz[12] * x2y2 +
cz[13] * xy3 +
cz[14] * y4
191 +
cz[15] * x5 +
cz[16] * x4y +
cz[17] * x3y2 +
cz[18] * x2y3 +
cz[19] * xy4 +
cz[20] * y5 +
cz[21] * x6
192 +
cz[22] * x5y +
cz[23] * x4y2 +
cz[24] * x3y3 +
cz[25] * x2y4 +
cz[26] * xy5 +
cz[27] * y6 +
cz[28] * x7
193 +
cz[29] * x6y +
cz[30] * x5y2 +
cz[31] * x4y3 +
cz[32] * x3y4 +
cz[33] * x2y5 +
cz[34] * xy6
196#if LIT_POLYNOM_DEGREE == 9
257 B.
Bx =
cx[0] +
cx[1] *
x +
cx[2] *
y +
cx[3] * x2 +
cx[4] * xy +
cx[5] * y2 +
cx[6] * x3 +
cx[7] * x2y
258 +
cx[8] * xy2 +
cx[9] * y3 +
cx[10] * x4 +
cx[11] * x3y +
cx[12] * x2y2 +
cx[13] * xy3 +
cx[14] * y4
259 +
cx[15] * x5 +
cx[16] * x4y +
cx[17] * x3y2 +
cx[18] * x2y3 +
cx[19] * xy4 +
cx[20] * y5 +
cx[21] * x6
260 +
cx[22] * x5y +
cx[23] * x4y2 +
cx[24] * x3y3 +
cx[25] * x2y4 +
cx[26] * xy5 +
cx[27] * y6 +
cx[28] * x7
261 +
cx[29] * x6y +
cx[30] * x5y2 +
cx[31] * x4y3 +
cx[32] * x3y4 +
cx[33] * x2y5 +
cx[34] * xy6
263 +
cx[36] * x8 +
cx[37] * x7y +
cx[38] * x6y2 +
cx[39] * x5y3 +
cx[40] * x4y4 +
cx[41] * x3y5 +
cx[42] * x2y6
264 +
cx[43] * xy7 +
cx[44] * y8 +
cx[45] * x9 +
cx[46] * x8y +
cx[47] * x7y2 +
cx[48] * x6y3 +
cx[49] * x5y4
265 +
cx[50] * x4y5 +
cx[51] * x3y6 +
cx[52] * x2y7 +
cx[53] * xy8 +
cx[54] * y9;
267 B.
By =
cy[0] +
cy[1] *
x +
cy[2] *
y +
cy[3] * x2 +
cy[4] * xy +
cy[5] * y2 +
cy[6] * x3 +
cy[7] * x2y
268 +
cy[8] * xy2 +
cy[9] * y3 +
cy[10] * x4 +
cy[11] * x3y +
cy[12] * x2y2 +
cy[13] * xy3 +
cy[14] * y4
269 +
cy[15] * x5 +
cy[16] * x4y +
cy[17] * x3y2 +
cy[18] * x2y3 +
cy[19] * xy4 +
cy[20] * y5 +
cy[21] * x6
270 +
cy[22] * x5y +
cy[23] * x4y2 +
cy[24] * x3y3 +
cy[25] * x2y4 +
cy[26] * xy5 +
cy[27] * y6 +
cy[28] * x7
271 +
cy[29] * x6y +
cy[30] * x5y2 +
cy[31] * x4y3 +
cy[32] * x3y4 +
cy[33] * x2y5 +
cy[34] * xy6
273 +
cy[36] * x8 +
cy[37] * x7y +
cy[38] * x6y2 +
cy[39] * x5y3 +
cy[40] * x4y4 +
cy[41] * x3y5 +
cy[42] * x2y6
274 +
cy[43] * xy7 +
cy[44] * y8 +
cy[45] * x9 +
cy[46] * x8y +
cy[47] * x7y2 +
cy[48] * x6y3 +
cy[49] * x5y4
275 +
cy[50] * x4y5 +
cy[51] * x3y6 +
cy[52] * x2y7 +
cy[53] * xy8 +
cy[54] * y9;
277 B.
Bz =
cz[0] +
cz[1] *
x +
cz[2] *
y +
cz[3] * x2 +
cz[4] * xy +
cz[5] * y2 +
cz[6] * x3 +
cz[7] * x2y
278 +
cz[8] * xy2 +
cz[9] * y3 +
cz[10] * x4 +
cz[11] * x3y +
cz[12] * x2y2 +
cz[13] * xy3 +
cz[14] * y4
279 +
cz[15] * x5 +
cz[16] * x4y +
cz[17] * x3y2 +
cz[18] * x2y3 +
cz[19] * xy4 +
cz[20] * y5 +
cz[21] * x6
280 +
cz[22] * x5y +
cz[23] * x4y2 +
cz[24] * x3y3 +
cz[25] * x2y4 +
cz[26] * xy5 +
cz[27] * y6 +
cz[28] * x7
281 +
cz[29] * x6y +
cz[30] * x5y2 +
cz[31] * x4y3 +
cz[32] * x3y4 +
cz[33] * x2y5 +
cz[34] * xy6
283 +
cz[36] * x8 +
cz[37] * x7y +
cz[38] * x6y2 +
cz[39] * x5y3 +
cz[40] * x4y4 +
cz[41] * x3y5 +
cz[42] * x2y6
284 +
cz[43] * xy7 +
cz[44] * y8 +
cz[45] * x9 +
cz[46] * x8y +
cz[47] * x7y2 +
cz[48] * x6y3 +
cz[49] * x5y4
285 +
cz[50] * x4y5 +
cz[51] * x3y6 +
cz[52] * x2y7 +
cz[53] * xy8 +
cz[54] * y9;
301 for (
unsigned int i = 0; i <
N; i++) {
326 std::string str =
"";
328 for (
unsigned int i = 0; i <
N; i++) {
332 str +=
"LitFieldSlice: cy=";
333 for (
unsigned int i = 0; i <
N; i++) {
337 str +=
"LitFieldSlice: cz=";
338 for (
unsigned int i = 0; i <
N; i++) {
Magnetic field value at a certain point in the space.
Approximated magnetic field slice in XY plane perpendicular to Z.
void SetZ(const T &Z)
Sets Z position of the slice.
friend std::ostream & operator<<(std::ostream &strm, const LitFieldSlice &slice)
Operator << for convenient output to std::ostream.
const T & GetZ() const
Returns Z position of the slice.
static const unsigned int N
std::string ToString() const
Returns std::string representation of the class.
void GetFieldValue(const T &x, const T &y, LitFieldValue< T > &B) const
Returns field value at a certain (X, Y) position.
void SetCoefficients(const std::vector< T > &x, const std::vector< T > &y, const std::vector< T > &z)
Sets polynom coefficients.
LitFieldSlice()
Constructor.
Magnetic field value at a certain point in the space.
class lit::parallel::LitDetectorLayout _fvecalignment
std::string ToString(const T &value)
Function converts object into a std::string.
LitFieldSlice< fscal > LitFieldSliceScal
Scalar version of LitFieldSlice.
LitFieldSlice< fvec > LitFieldSliceVec
Vector version of LitFieldSlice.