CbmRoot
L1Field.h
Go to the documentation of this file.
1 #ifndef L1Field_h
2 #define L1Field_h 1
3 
4 #include "CbmL1Def.h"
5 #include <iostream>
6 using std::cout;
7 using std::endl;
8 using std::ostream;
9 
10 
11 class L1FieldValue {
12 
13 
14 public:
15  L1FieldValue() : x(0), y(0), z(0) {};
16 
17  fvec x, y, z;
18 
19  void Combine(L1FieldValue& B, fvec w) {
20  x += w * (B.x - x);
21  y += w * (B.y - y);
22  z += w * (B.z - z);
23  }
24 
25  friend ostream& operator<<(ostream& out, L1FieldValue& B) {
26  return out << B.x[0] << " | " << B.y[0] << " | " << B.z[0];
27  };
29 
30 
31 class L1FieldSlice {
32 
33 public:
34  fvec cx[21], cy[21], cz[21]; // polinom coeff.
35 
37  for (int i = 0; i < 21; i++)
38  cx[i] = cy[i] = cz[i] = 0;
39  }
40 
41  void GetFieldValue(const fvec& x, const fvec& y, L1FieldValue& B) const {
42  fvec x2 = x * x;
43  fvec y2 = y * y;
44  fvec xy = x * y;
45 
46  fvec x3 = x2 * x;
47  fvec y3 = y2 * y;
48  fvec xy2 = x * y2;
49  fvec x2y = x2 * y;
50 
51  fvec x4 = x3 * x;
52  fvec y4 = y3 * y;
53  fvec xy3 = x * y3;
54  fvec x2y2 = x2 * y2;
55  fvec x3y = x3 * y;
56 
57  fvec x5 = x4 * x;
58  fvec y5 = y4 * y;
59  fvec xy4 = x * y4;
60  fvec x2y3 = x2 * y3;
61  fvec x3y2 = x3 * y2;
62  fvec x4y = x4 * y;
63 
64  B.x = cx[0] + cx[1] * x + cx[2] * y + cx[3] * x2 + cx[4] * xy + cx[5] * y2
65  + cx[6] * x3 + cx[7] * x2y + cx[8] * xy2 + cx[9] * y3 + cx[10] * x4
66  + cx[11] * x3y + cx[12] * x2y2 + cx[13] * xy3 + cx[14] * y4
67  + cx[15] * x5 + cx[16] * x4y + cx[17] * x3y2 + cx[18] * x2y3
68  + cx[19] * xy4 + cx[20] * y5;
69 
70  B.y = cy[0] + cy[1] * x + cy[2] * y + cy[3] * x2 + cy[4] * xy + cy[5] * y2
71  + cy[6] * x3 + cy[7] * x2y + cy[8] * xy2 + cy[9] * y3 + cy[10] * x4
72  + cy[11] * x3y + cy[12] * x2y2 + cy[13] * xy3 + cy[14] * y4
73  + cy[15] * x5 + cy[16] * x4y + cy[17] * x3y2 + cy[18] * x2y3
74  + cy[19] * xy4 + cy[20] * y5;
75 
76  B.z = cz[0] + cz[1] * x + cz[2] * y + cz[3] * x2 + cz[4] * xy + cz[5] * y2
77  + cz[6] * x3 + cz[7] * x2y + cz[8] * xy2 + cz[9] * y3 + cz[10] * x4
78  + cz[11] * x3y + cz[12] * x2y2 + cz[13] * xy3 + cz[14] * y4
79  + cz[15] * x5 + cz[16] * x4y + cz[17] * x3y2 + cz[18] * x2y3
80  + cz[19] * xy4 + cz[20] * y5;
81  }
83 
84 
86 
87 public:
89  : cx0(0)
90  , cx1(0)
91  , cx2(0)
92  , cy0(0)
93  , cy1(0)
94  , cy2(0)
95  , cz0(0)
96  , cz1(0)
97  , cz2(0)
98  , z0(0) {}
99 
100  L1FieldRegion(float reg[10])
101  : cx0(reg[0])
102  , cx1(reg[1])
103  , cx2(reg[2])
104  , cy0(reg[3])
105  , cy1(reg[4])
106  , cy2(reg[5])
107  , cz0(reg[6])
108  , cz1(reg[7])
109  , cz2(reg[8])
110  , z0(reg[9]) {}
111 
112  fvec cx0, cx1, cx2; // Bx(z) = cx0 + cx1*(z-z0) + cx2*(z-z0)^2
113  fvec cy0, cy1, cy2; // By(z) = cy0 + cy1*(z-z0) + cy2*(z-z0)^2
114  fvec cz0, cz1, cz2; // Bz(z) = cz0 + cz1*(z-z0) + cz2*(z-z0)^2
116 
117  L1FieldValue Get(const fvec z) {
118  fvec dz = (z - z0);
119  fvec dz2 = dz * dz;
120  L1FieldValue B;
121  B.x = cx0 + cx1 * dz + cx2 * dz2;
122  B.y = cy0 + cy1 * dz + cy2 * dz2;
123  B.z = cz0 + cz1 * dz + cz2 * dz2;
124  return B;
125  }
126 
127  void Get(const fvec z_, fvec* B) const {
128  fvec dz = (z_ - z0);
129  fvec dz2 = dz * dz;
130  B[0] = cx0 + cx1 * dz + cx2 * dz2;
131  B[1] = cy0 + cy1 * dz + cy2 * dz2;
132  B[2] = cz0 + cz1 * dz + cz2 * dz2;
133  }
134 
135  void Set(const L1FieldValue& B0,
136  const fvec B0z,
137  const L1FieldValue& B1,
138  const fvec B1z,
139  const L1FieldValue& B2,
140  const fvec B2z) {
141  z0 = B0z;
142  fvec dz1 = B1z - B0z, dz2 = B2z - B0z;
143  fvec det = rcp(fvec(dz1 * dz2 * (dz2 - dz1)));
144  fvec w21 = -dz2 * det;
145  fvec w22 = dz1 * det;
146  fvec w11 = -dz2 * w21;
147  fvec w12 = -dz1 * w22;
148 
149  fvec dB1 = B1.x - B0.x;
150  fvec dB2 = B2.x - B0.x;
151  cx0 = B0.x;
152  cx1 = dB1 * w11 + dB2 * w12;
153  cx2 = dB1 * w21 + dB2 * w22;
154 
155  dB1 = B1.y - B0.y;
156  dB2 = B2.y - B0.y;
157  cy0 = B0.y;
158  cy1 = dB1 * w11 + dB2 * w12;
159  cy2 = dB1 * w21 + dB2 * w22;
160 
161  dB1 = B1.z - B0.z;
162  dB2 = B2.z - B0.z;
163  cz0 = B0.z;
164  cz1 = dB1 * w11 + dB2 * w12;
165  cz2 = dB1 * w21 + dB2 * w22;
166  }
167 
168  void Set(const L1FieldValue& B0,
169  const fvec B0z,
170  const L1FieldValue& B1,
171  const fvec B1z) {
172  z0 = B0z[0];
173  fvec dzi = rcp(fvec(B1z - B0z));
174  cx0 = B0.x;
175  cy0 = B0.y;
176  cz0 = B0.z;
177  cx1 = (B1.x - B0.x) * dzi;
178  cy1 = (B1.y - B0.y) * dzi;
179  cz1 = (B1.z - B0.z) * dzi;
180  cx2 = cy2 = cz2 = 0;
181  }
182 
183  void Shift(fvec z) {
184  fvec dz = z - z0;
185  fvec cx2dz = cx2 * dz;
186  fvec cy2dz = cy2 * dz;
187  fvec cz2dz = cz2 * dz;
188  z0 = z[0];
189  cx0 += (cx1 + cx2dz) * dz;
190  cy0 += (cy1 + cy2dz) * dz;
191  cz0 += (cz1 + cz2dz) * dz;
192  cx1 += cx2dz + cx2dz;
193  cy1 += cy2dz + cy2dz;
194  cz1 += cz2dz + cz2dz;
195  }
196 
197  void SetOneEntry(const int i0, const L1FieldRegion& f1, const int i1) {
198  cx0[i0] = f1.cx0[i1];
199  cx1[i0] = f1.cx1[i1];
200  cx2[i0] = f1.cx2[i1];
201  cy0[i0] = f1.cy0[i1];
202  cy1[i0] = f1.cy1[i1];
203  cy2[i0] = f1.cy2[i1];
204  cz0[i0] = f1.cz0[i1];
205  cz1[i0] = f1.cz1[i1];
206  cz2[i0] = f1.cz2[i1];
207  z0[i0] = f1.z0[i1];
208  }
209 
210  void SetOneEntry(const L1FieldRegion& f1, const int i1) {
211  cx0 = f1.cx0[i1];
212  cx1 = f1.cx1[i1];
213  cx2 = f1.cx2[i1];
214  cy0 = f1.cy0[i1];
215  cy1 = f1.cy1[i1];
216  cy2 = f1.cy2[i1];
217  cz0 = f1.cz0[i1];
218  cz1 = f1.cz1[i1];
219  cz2 = f1.cz2[i1];
220  z0 = f1.z0[i1];
221  }
222 
223  void GetOneEntry(float reg[10], const int iVec) {
224  reg[0] = cx0[iVec];
225  reg[1] = cx1[iVec];
226  reg[2] = cx2[iVec];
227  reg[3] = cy0[iVec];
228  reg[4] = cy1[iVec];
229  reg[5] = cy2[iVec];
230  reg[6] = cz0[iVec];
231  reg[7] = cz1[iVec];
232  reg[8] = cz2[iVec];
233  reg[9] = z0[iVec];
234  }
236 
237 
238 #endif
L1FieldRegion::cx1
fvec cx1
Definition: L1Field.h:112
L1FieldRegion::GetOneEntry
void GetOneEntry(float reg[10], const int iVec)
Definition: L1Field.h:223
L1FieldValue::L1FieldValue
L1FieldValue()
Definition: L1Field.h:15
F32vec4
Definition: L1/vectors/P4_F32vec4.h:47
fvec
F32vec4 fvec
Definition: L1/vectors/P4_F32vec4.h:249
L1FieldValue::z
fvec z
Definition: L1Field.h:17
L1FieldSlice::L1FieldSlice
L1FieldSlice()
Definition: L1Field.h:36
rcp
friend F32vec4 rcp(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:52
L1FieldRegion::Get
void Get(const fvec z_, fvec *B) const
Definition: L1Field.h:127
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
L1FieldRegion::L1FieldRegion
L1FieldRegion(float reg[10])
Definition: L1Field.h:100
L1FieldRegion::Get
L1FieldValue Get(const fvec z)
Definition: L1Field.h:117
L1FieldRegion::cz0
fvec cz0
Definition: L1Field.h:114
L1FieldSlice::cz
fvec cz[21]
Definition: L1Field.h:34
L1FieldSlice::cy
fvec cy[21]
Definition: L1Field.h:34
L1FieldRegion::L1FieldRegion
L1FieldRegion()
Definition: L1Field.h:88
CbmL1Def.h
L1FieldRegion::Set
void Set(const L1FieldValue &B0, const fvec B0z, const L1FieldValue &B1, const fvec B1z)
Definition: L1Field.h:168
L1FieldRegion::SetOneEntry
void SetOneEntry(const L1FieldRegion &f1, const int i1)
Definition: L1Field.h:210
L1FieldValue::y
fvec y
Definition: L1Field.h:17
L1FieldSlice::cx
fvec cx[21]
Definition: L1Field.h:34
L1FieldRegion
Definition: L1Field.h:85
_fvecalignment
class L1FieldValue _fvecalignment
L1FieldRegion::cx2
fvec cx2
Definition: L1Field.h:112
L1FieldRegion::cz2
fvec cz2
Definition: L1Field.h:114
L1FieldRegion::Set
void Set(const L1FieldValue &B0, const fvec B0z, const L1FieldValue &B1, const fvec B1z, const L1FieldValue &B2, const fvec B2z)
Definition: L1Field.h:135
L1FieldRegion::cy0
fvec cy0
Definition: L1Field.h:113
L1FieldRegion::cy2
fvec cy2
Definition: L1Field.h:113
L1FieldSlice
Definition: L1Field.h:31
L1FieldSlice::GetFieldValue
void GetFieldValue(const fvec &x, const fvec &y, L1FieldValue &B) const
Definition: L1Field.h:41
L1FieldRegion::SetOneEntry
void SetOneEntry(const int i0, const L1FieldRegion &f1, const int i1)
Definition: L1Field.h:197
L1FieldRegion::z0
fvec z0
Definition: L1Field.h:115
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
L1FieldRegion::cy1
fvec cy1
Definition: L1Field.h:113
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
L1FieldRegion::Shift
void Shift(fvec z)
Definition: L1Field.h:183
L1FieldRegion::cx0
fvec cx0
Definition: L1Field.h:112
L1FieldRegion::cz1
fvec cz1
Definition: L1Field.h:114
L1FieldValue
Definition: L1Field.h:11
L1FieldValue::Combine
void Combine(L1FieldValue &B, fvec w)
Definition: L1Field.h:19
L1FieldValue::operator<<
friend ostream & operator<<(ostream &out, L1FieldValue &B)
Definition: L1Field.h:25
L1FieldValue::x
fvec x
Definition: L1Field.h:15