CbmRoot
Loading...
Searching...
No Matches
LitFieldRegion.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2012 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
12#ifndef LITFIELDREGION_H_
13#define LITFIELDREGION_H_
14
15#include "LitMath.h"
16
17namespace lit
18{
19 namespace parallel
20 {
21
31 template<class T>
33 public:
46 void Set(const LitFieldValue<T>& B0, const T B0z, const LitFieldValue<T>& B1, const T B1z,
47 const LitFieldValue<T>& B2, const T B2z)
48 {
49 z0 = B0z;
50 T dz1 = B1z - B0z, dz2 = B2z - B0z;
51 T det = rcp(T(dz1 * dz2 * (dz2 - dz1)));
52 T w21 = -dz2 * det;
53 T w22 = dz1 * det;
54 T w11 = -dz2 * w21;
55 T w12 = -dz1 * w22;
56
57 T dB1 = B1.Bx - B0.Bx;
58 T dB2 = B2.Bx - B0.Bx;
59 cx0 = B0.Bx;
60 cx1 = dB1 * w11 + dB2 * w12;
61 cx2 = dB1 * w21 + dB2 * w22;
62
63 dB1 = B1.By - B0.By;
64 dB2 = B2.By - B0.By;
65 cy0 = B0.By;
66 cy1 = dB1 * w11 + dB2 * w12;
67 cy2 = dB1 * w21 + dB2 * w22;
68
69 dB1 = B1.Bz - B0.Bz;
70 dB2 = B2.Bz - B0.Bz;
71 cz0 = B0.Bz;
72 cz1 = dB1 * w11 + dB2 * w12;
73 cz2 = dB1 * w21 + dB2 * w22;
74 }
75
86 void Set(const LitFieldValue<T>& B0, const T B0z, const LitFieldValue<T>& B1, const T B1z)
87 {
88 z0 = B0z;
89 T dzi = rcp(T(B1z - B0z));
90 cx0 = B0.Bx;
91 cy0 = B0.By;
92 cz0 = B0.Bz;
93 cx1 = (B1.Bx - B0.Bx) * dzi;
94 cy1 = (B1.By - B0.By) * dzi;
95 cz1 = (B1.Bz - B0.Bz) * dzi;
96 cx2 = cy2 = cz2 = 0;
97 }
98
102 void Shift(T z)
103 {
104 T dz = z - z0;
105 T cx2dz = cx2 * dz;
106 T cy2dz = cy2 * dz;
107 T cz2dz = cz2 * dz;
108 z0 = z[0];
109 cx0 += (cx1 + cx2dz) * dz;
110 cy0 += (cy1 + cy2dz) * dz;
111 cz0 += (cz1 + cz2dz) * dz;
112 cx1 += cx2dz + cx2dz;
113 cy1 += cy2dz + cy2dz;
114 cz1 += cz2dz + cz2dz;
115 }
116
123 void GetFieldValue(const T& z, LitFieldValue<T>& B) const
124 {
125 T dz = z - z0;
126 T dzdz = dz * dz;
127 B.Bx = cx0 + cx1 * dz + cx2 * dzdz;
128 B.By = cy0 + cy1 * dz + cy2 * dzdz;
129 B.Bz = cz0 + cz1 * dz + cz2 * dzdz;
130 }
131
132 private:
133 T cx0, cx1, cx2; // Bx(z) = cx0 + cx1*(z-z0) + cx2*(z-z0)^2
134 T cy0, cy1, cy2; // By(z) = cy0 + cy1*(z-z0) + cy2*(z-z0)^2
135 T cz0, cz1, cz2; // Bz(z) = cz0 + cz1*(z-z0) + cz2*(z-z0)^2
136 T z0;
138
139 } // namespace parallel
140} // namespace lit
141
142#endif /* LITFIELDREGION_H_ */
Useful math functions.
Storage for field approximation along Z.
void Set(const LitFieldValue< T > &B0, const T B0z, const LitFieldValue< T > &B1, const T B1z, const LitFieldValue< T > &B2, const T B2z)
Sets field region using three field values.
void GetFieldValue(const T &z, LitFieldValue< T > &B) const
Returns field value at a certain Z position.
void Set(const LitFieldValue< T > &B0, const T B0z, const LitFieldValue< T > &B1, const T B1z)
Sets field region using two field values.
Magnetic field value at a certain point in the space.
class lit::parallel::LitDetectorLayout _fvecalignment
fscal rcp(const fscal &a)
Returns reciprocal.
Definition LitMath.h:32