BmnRoot
Loading...
Searching...
No Matches
BmnKalmanFilter.cxx
Go to the documentation of this file.
1
2#include "BmnKalmanFilter.h"
3
4#include "BmnFieldMap.h"
5
6using namespace std;
7using namespace TMath;
8
10{
11 fMaterial = new BmnMaterialEffects();
12 fNavigator = new BmnGeoNavigator();
13 fField = nullptr;
14}
15
17{
18 delete fMaterial;
19 delete fNavigator;
20}
21
22BmnStatus BmnKalmanFilter::RK4TrackExtrapolate(FairTrackParam* par, Double_t zOut, vector<Double_t>* F)
23{
24 Double_t zIn = par->GetZ();
25 fField = FairRunAna::Instance()->GetField();
26
27 vector<Double_t> xIn;
28 xIn.resize(5);
29 xIn[0] = par->GetX();
30 xIn[1] = par->GetY();
31 xIn[2] = par->GetTx();
32 xIn[3] = par->GetTy();
33 xIn[4] = par->GetQp();
34 vector<Double_t> xOut(5, 0.);
35 vector<Double_t> F1(25, 0.);
36
37 RK4Order(xIn, zIn, xOut, zOut, F1);
38
39 vector<Double_t> cIn(15, 0.0);
40 Double_t cIn_tmp[15];
41 par->CovMatrix(cIn_tmp);
42 for (Int_t i = 0; i < 15; ++i) {
43 cIn[i] = cIn_tmp[i];
44 }
45 vector<Double_t> cOut(15, 0.0);
46 TransportC(cIn, F1, cOut);
47
48 par->SetX(xOut[0]);
49 par->SetY(xOut[1]);
50 par->SetTx(xOut[2]);
51 par->SetTy(xOut[3]);
52 par->SetQp(xOut[4]);
53 Double_t cOut_tmp[15];
54 for (Int_t i = 0; i < 15; ++i) {
55 cOut_tmp[i] = cOut[i];
56 }
57 par->SetCovMatrix(cOut_tmp);
58 par->SetZ(zOut);
59
60 if (F != NULL)
61 F->assign(F1.begin(), F1.end());
62
63 return kBMNSUCCESS;
64}
65
66void BmnKalmanFilter::RK4Order(const vector<Double_t>& xIn,
67 Double_t zIn,
68 vector<Double_t>& xOut,
69 Double_t zOut,
70 vector<Double_t>& derivs)
71{
72 const Double_t fC = 0.000299792458;
73
74 Double_t coef[4] = {0.0, 0.5, 0.5, 1.0};
75
76 Double_t Ax[4], Ay[4];
77 Double_t dAx_dtx[4], dAy_dtx[4], dAx_dty[4], dAy_dty[4];
78 Double_t k[4][4];
79
80 Double_t h = zOut - zIn;
81 Double_t hC = h * fC;
82 Double_t hCqp = h * fC * xIn[4];
83 Double_t x0[4];
84
85 Double_t x[4] = {xIn[0], xIn[1], xIn[2], xIn[3]};
86
87 for (UInt_t iStep = 0; iStep < 4; iStep++) { // 1
88 if (iStep > 0) {
89 for (UInt_t i = 0; i < 4; i++) {
90 x[i] = xIn[i] + coef[iStep] * k[i][iStep - 1];
91 }
92 }
93
94 Double_t Bx = fField->GetBx(x[0], x[1], zIn + coef[iStep] * h);
95 Double_t By = fField->GetBy(x[0], x[1], zIn + coef[iStep] * h);
96 Double_t Bz = fField->GetBz(x[0], x[1], zIn + coef[iStep] * h);
97
98 Double_t tx = x[2];
99 Double_t ty = x[3];
100 Double_t txtx = tx * tx;
101 Double_t tyty = ty * ty;
102 Double_t txty = tx * ty;
103 Double_t txtxtyty1 = 1.0 + txtx + tyty;
104 Double_t t1 = Sqrt(txtxtyty1);
105 Double_t t2 = 1.0 / txtxtyty1;
106
107 Ax[iStep] = (txty * Bx + ty * Bz - (1.0 + txtx) * By) * t1;
108 Ay[iStep] = (-txty * By - tx * Bz + (1.0 + tyty) * Bx) * t1;
109
110 dAx_dtx[iStep] = Ax[iStep] * tx * t2 + (ty * Bx - 2.0 * tx * By) * t1;
111 dAx_dty[iStep] = Ax[iStep] * ty * t2 + (tx * Bx + Bz) * t1;
112 dAy_dtx[iStep] = Ay[iStep] * tx * t2 + (-ty * By - Bz) * t1;
113 dAy_dty[iStep] = Ay[iStep] * ty * t2 + (-tx * By + 2.0 * ty * Bx) * t1;
114
115 k[0][iStep] = tx * h;
116 k[1][iStep] = ty * h;
117 k[2][iStep] = Ax[iStep] * hCqp;
118 k[3][iStep] = Ay[iStep] * hCqp;
119
120 } // 1
121
122 for (UInt_t i = 0; i < 4; i++) {
123 xOut[i] = CalcOut(xIn[i], k[i]);
124 }
125 xOut[4] = xIn[4];
126
127 // Calculation of the derivatives
128
129 // derivatives dx/dx and dx/dy
130 // dx/dx
131 derivs[0] = 1.;
132 derivs[5] = 0.;
133 derivs[10] = 0.;
134 derivs[15] = 0.;
135 derivs[20] = 0.;
136 // dx/dy
137 derivs[1] = 0.;
138 derivs[6] = 1.;
139 derivs[11] = 0.;
140 derivs[16] = 0.;
141 derivs[21] = 0.;
142 // end of derivatives dx/dx and dx/dy
143
144 // Derivatives dx/tx
145 x[0] = x0[0] = 0.0;
146 x[1] = x0[1] = 0.0;
147 x[2] = x0[2] = 1.0;
148 x[3] = x0[3] = 0.0;
149 for (UInt_t iStep = 0; iStep < 4; iStep++) { // 2
150 if (iStep > 0) {
151 for (UInt_t i = 0; i < 4; i++) {
152 if (i != 2) {
153 x[i] = x0[i] + coef[iStep] * k[i][iStep - 1];
154 }
155 }
156 }
157
158 k[0][iStep] = x[2] * h;
159 k[1][iStep] = x[3] * h;
160 // k[2][iStep] = (dAx_dtx[iStep] * x[2] + dAx_dty[iStep] * x[3]) * hCqp;
161 k[3][iStep] = (dAy_dtx[iStep] * x[2] + dAy_dty[iStep] * x[3]) * hCqp;
162 } // 2
163
164 derivs[2] = CalcOut(x0[0], k[0]);
165 derivs[7] = CalcOut(x0[1], k[1]);
166 derivs[12] = 1.0;
167 derivs[17] = CalcOut(x0[3], k[3]);
168 derivs[22] = 0.0;
169 // end of derivatives dx/dtx
170
171 // Derivatives dx/ty
172 x[0] = x0[0] = 0.0;
173 x[1] = x0[1] = 0.0;
174 x[2] = x0[2] = 0.0;
175 x[3] = x0[3] = 1.0;
176 for (UInt_t iStep = 0; iStep < 4; iStep++) { // 4
177 if (iStep > 0) {
178 for (UInt_t i = 0; i < 4; i++) {
179 if (i != 3) {
180 x[i] = x0[i] + coef[iStep] * k[i][iStep - 1];
181 }
182 }
183 }
184
185 k[0][iStep] = x[2] * h;
186 k[1][iStep] = x[3] * h;
187 k[2][iStep] = (dAx_dtx[iStep] * x[2] + dAx_dty[iStep] * x[3]) * hCqp;
188 // k[3][iStep] = (dAy_dtx[iStep] * x[2] + dAy_dty[iStep] * x[3]) * hCqp;
189 } // 4
190
191 derivs[3] = CalcOut(x0[0], k[0]);
192 derivs[8] = CalcOut(x0[1], k[1]);
193 derivs[13] = CalcOut(x0[2], k[2]);
194 derivs[18] = 1.;
195 derivs[23] = 0.;
196 // end of derivatives dx/dty
197
198 // Derivatives dx/dqp
199 x[0] = x0[0] = 0.0;
200 x[1] = x0[1] = 0.0;
201 x[2] = x0[2] = 0.0;
202 x[3] = x0[3] = 0.0;
203 for (UInt_t iStep = 0; iStep < 4; iStep++) { // 4
204 if (iStep > 0) {
205 for (UInt_t i = 0; i < 4; i++) {
206 x[i] = x0[i] + coef[iStep] * k[i][iStep - 1];
207 }
208 }
209
210 k[0][iStep] = x[2] * h;
211 k[1][iStep] = x[3] * h;
212 k[2][iStep] = Ax[iStep] * hC + hCqp * (dAx_dtx[iStep] * x[2] + dAx_dty[iStep] * x[3]);
213 k[3][iStep] = Ay[iStep] * hC + hCqp * (dAy_dtx[iStep] * x[2] + dAy_dty[iStep] * x[3]);
214 } // 4
215
216 derivs[4] = CalcOut(x0[0], k[0]);
217 derivs[9] = CalcOut(x0[1], k[1]);
218 derivs[14] = CalcOut(x0[2], k[2]);
219 derivs[19] = CalcOut(x0[3], k[3]);
220 derivs[24] = 1.;
221 // end of derivatives dx/dqp
222
223 // end calculation of the derivatives
224}
225
226void BmnKalmanFilter::TransportC(const vector<Double_t>& cIn, const vector<Double_t>& F, vector<Double_t>& cOut)
227{
228 // F*C*Ft
229 Double_t A = cIn[2] + F[2] * cIn[9] + F[3] * cIn[10] + F[4] * cIn[11];
230 Double_t B = cIn[3] + F[2] * cIn[10] + F[3] * cIn[12] + F[4] * cIn[13];
231 Double_t C = cIn[4] + F[2] * cIn[11] + F[3] * cIn[13] + F[4] * cIn[14];
232
233 Double_t D = cIn[6] + F[7] * cIn[9] + F[8] * cIn[10] + F[9] * cIn[11];
234 Double_t E = cIn[7] + F[7] * cIn[10] + F[8] * cIn[12] + F[9] * cIn[13];
235 Double_t G = cIn[8] + F[7] * cIn[11] + F[8] * cIn[13] + F[9] * cIn[14];
236
237 Double_t H = cIn[9] + F[13] * cIn[10] + F[14] * cIn[11];
238 Double_t I = cIn[10] + F[13] * cIn[12] + F[14] * cIn[13];
239 Double_t J = cIn[11] + F[13] * cIn[13] + F[14] * cIn[14];
240
241 Double_t K = cIn[13] + F[17] * cIn[11] + F[19] * cIn[14];
242
243 cOut[0] = cIn[0] + F[2] * cIn[2] + F[3] * cIn[3] + F[4] * cIn[4] + A * F[2] + B * F[3] + C * F[4];
244 cOut[1] = cIn[1] + F[2] * cIn[6] + F[3] * cIn[7] + F[4] * cIn[8] + A * F[7] + B * F[8] + C * F[9];
245 cOut[2] = A + B * F[13] + C * F[14];
246 cOut[3] = B + A * F[17] + C * F[19];
247 cOut[4] = C;
248
249 cOut[5] = cIn[5] + F[7] * cIn[6] + F[8] * cIn[7] + F[9] * cIn[8] + D * F[7] + E * F[8] + G * F[9];
250 cOut[6] = D + E * F[13] + G * F[14];
251 cOut[7] = E + D * F[17] + G * F[19];
252 cOut[8] = G;
253
254 cOut[9] = H + I * F[13] + J * F[14];
255 cOut[10] = I + H * F[17] + J * F[19];
256 cOut[11] = J;
257
258 cOut[12] =
259 cIn[12] + F[17] * cIn[10] + F[19] * cIn[13] + (F[17] * cIn[9] + cIn[10] + F[19] * cIn[11]) * F[17] + K * F[19];
260 cOut[13] = K;
261
262 cOut[14] = cIn[14];
263}
264
265Double_t BmnKalmanFilter::CalcOut(Double_t in, const Double_t k[4])
266{
267 return in + k[0] / 6. + k[1] / 3. + k[2] / 3. + k[3] / 6.;
268}
269
270BmnStatus BmnKalmanFilter::Update(FairTrackParam* par, const BmnHit* hit, Double_t& chiSq)
271{
272 // vector<Double_t> cIn = par->GetCovMatrix();
273 Double_t cIn[15];
274 par->CovMatrix(cIn);
275
276 static const Double_t ONE = 1., TWO = 2.;
277
278 Double_t dxx = hit->GetDx() * hit->GetDx();
279 Double_t dxy = 0.0;
280 Double_t dyy = hit->GetDy() * hit->GetDy();
281
282 // calculate residuals
283 Double_t dx = hit->GetX() - par->GetX();
284 Double_t dy = hit->GetY() - par->GetY();
285
286 // Calculate and inverse residual covariance matrix
287 Double_t t =
288 (dxx * dyy + dxx * cIn[5] + dyy * cIn[0] + cIn[0] * cIn[5] - dxy * dxy - TWO * dxy * cIn[1] - cIn[1] * cIn[1]);
289 if (t == 0.0)
290 return kBMNERROR;
291 else
292 t = ONE
293 / (dxx * dyy + dxx * cIn[5] + dyy * cIn[0] + cIn[0] * cIn[5] - dxy * dxy - TWO * dxy * cIn[1]
294 - cIn[1] * cIn[1]);
295
296 Double_t R00 = (dyy + cIn[5]) * t;
297 Double_t R01 = -(dxy + cIn[1]) * t;
298 Double_t R11 = (dxx + cIn[0]) * t;
299
300 // Calculate Kalman gain matrix
301 Double_t K00 = cIn[0] * R00 + cIn[1] * R01;
302 Double_t K01 = cIn[0] * R01 + cIn[1] * R11;
303 Double_t K10 = cIn[1] * R00 + cIn[5] * R01;
304 Double_t K11 = cIn[1] * R01 + cIn[5] * R11;
305 Double_t K20 = cIn[2] * R00 + cIn[6] * R01;
306 Double_t K21 = cIn[2] * R01 + cIn[6] * R11;
307 Double_t K30 = cIn[3] * R00 + cIn[7] * R01;
308 Double_t K31 = cIn[3] * R01 + cIn[7] * R11;
309 Double_t K40 = cIn[4] * R00 + cIn[8] * R01;
310 Double_t K41 = cIn[4] * R01 + cIn[8] * R11;
311
312 // Calculate filtered state vector
313 Double_t xOut[5] = {par->GetX(), par->GetY(), par->GetTx(), par->GetTy(), par->GetQp()};
314 xOut[0] += K00 * dx + K01 * dy;
315 // cout << "xOut[0] = " << xOut[0] << endl;
316 xOut[1] += K10 * dx + K11 * dy;
317 xOut[2] += K20 * dx + K21 * dy;
318 xOut[3] += K30 * dx + K31 * dy;
319 xOut[4] += K40 * dx + K41 * dy;
320
321 // Calculate filtered covariance matrix
322
323 Double_t cOut[15];
324 for (Int_t i = 0; i < 15; ++i)
325 cOut[i] = cIn[i];
326
327 cOut[0] += -K00 * cIn[0] - K01 * cIn[1];
328 cOut[1] += -K00 * cIn[1] - K01 * cIn[5];
329 cOut[2] += -K00 * cIn[2] - K01 * cIn[6];
330 cOut[3] += -K00 * cIn[3] - K01 * cIn[7];
331 cOut[4] += -K00 * cIn[4] - K01 * cIn[8];
332
333 cOut[5] += -K11 * cIn[5] - K10 * cIn[1];
334 cOut[6] += -K11 * cIn[6] - K10 * cIn[2];
335 cOut[7] += -K11 * cIn[7] - K10 * cIn[3];
336 cOut[8] += -K11 * cIn[8] - K10 * cIn[4];
337
338 cOut[9] += -K20 * cIn[2] - K21 * cIn[6];
339 cOut[10] += -K20 * cIn[3] - K21 * cIn[7];
340 cOut[11] += -K20 * cIn[4] - K21 * cIn[8];
341
342 cOut[12] += -K30 * cIn[3] - K31 * cIn[7];
343 cOut[13] += -K30 * cIn[4] - K31 * cIn[8];
344
345 cOut[14] += -K40 * cIn[4] - K41 * cIn[8];
346
347 // Copy filtered state to output
348 par->SetX(xOut[0]);
349 par->SetY(xOut[1]);
350 par->SetTx(xOut[2]);
351 par->SetTy(xOut[3]);
352 par->SetQp(xOut[4]);
353 par->SetCovMatrix(cOut);
354
355 // Calculate chi-square
356 Double_t xmx = hit->GetX() - par->GetX();
357 Double_t ymy = hit->GetY() - par->GetY();
358 Double_t C0 = cOut[0];
359 Double_t C1 = cOut[1];
360 Double_t C5 = cOut[5];
361
362 Double_t norm = dxx * dyy - dxx * C5 - dyy * C0 + C0 * C5 - dxy * dxy + 2 * dxy * C1 - C1 * C1;
363
364 chiSq = ((xmx * (dyy - C5) - ymy * (dxy - C1)) * xmx + (-xmx * (dxy - C1) + ymy * (dxx - C0)) * ymy) / norm;
365
366 return kBMNSUCCESS;
367}
368
369void BmnKalmanFilter::UpdateF(vector<Double_t>& F, const vector<Double_t>& newF)
370{
371 vector<Double_t> A(25);
372 Mult25(newF, F, A);
373 F.assign(A.begin(), A.end());
374}
375
376// We are going in the upstream direction
377// this Node (k) , prevNode (k+1)
378
380{
381 if (thisNode->GetPredictedParam()->GetQp() == 0.0)
382 return kBMNERROR;
383 if (prevNode->GetPredictedParam()->GetQp() == 0.0)
384 return kBMNERROR;
385
386 Double_t cov1[15];
387 prevNode->GetPredictedParam()->CovMatrix(cov1);
388 vector<Double_t> invPrevPredC;
389 for (Int_t i = 0; i < 15; ++i) {
390 invPrevPredC.push_back(cov1[i]);
391 }
392 if (!InvSym15(invPrevPredC))
393 return kBMNERROR;
394
395 vector<Double_t> Ft(prevNode->GetF());
396 Transpose25(Ft);
397
398 Double_t cov2[15];
399 thisNode->GetUpdatedParam()->CovMatrix(cov2);
400 vector<Double_t> thisUpdC;
401 for (Int_t i = 0; i < 15; ++i) {
402 thisUpdC.push_back(cov2[i]);
403 }
404
405 vector<Double_t> A(25);
406 vector<Double_t> temp1(25);
407 Mult15On25(thisUpdC, Ft, temp1);
408 Mult25On15(temp1, invPrevPredC, A);
409
410 vector<Double_t> thisUpdX;
411 thisUpdX.push_back(thisNode->GetUpdatedParam()->GetX());
412 thisUpdX.push_back(thisNode->GetUpdatedParam()->GetY());
413 thisUpdX.push_back(thisNode->GetUpdatedParam()->GetTx());
414 thisUpdX.push_back(thisNode->GetUpdatedParam()->GetTy());
415 thisUpdX.push_back(thisNode->GetUpdatedParam()->GetQp());
416
417 vector<Double_t> prevSmoothedX;
418 prevSmoothedX.push_back(prevNode->GetSmoothedParam()->GetX());
419 prevSmoothedX.push_back(prevNode->GetSmoothedParam()->GetY());
420 prevSmoothedX.push_back(prevNode->GetSmoothedParam()->GetTx());
421 prevSmoothedX.push_back(prevNode->GetSmoothedParam()->GetTy());
422 prevSmoothedX.push_back(prevNode->GetSmoothedParam()->GetQp());
423
424 vector<Double_t> prevPredX;
425 prevPredX.push_back(prevNode->GetPredictedParam()->GetX());
426 prevPredX.push_back(prevNode->GetPredictedParam()->GetY());
427 prevPredX.push_back(prevNode->GetPredictedParam()->GetTx());
428 prevPredX.push_back(prevNode->GetPredictedParam()->GetTy());
429 prevPredX.push_back(prevNode->GetPredictedParam()->GetQp());
430
431 vector<Double_t> temp2(5), temp3(5);
432 Subtract(prevSmoothedX, prevPredX, temp2);
433 Mult25On5(A, temp2, temp3);
434 vector<Double_t> thisSmoothedX(5);
435 Add(thisUpdX, temp3, thisSmoothedX);
436
437 Double_t cov3[15];
438 prevNode->GetSmoothedParam()->CovMatrix(cov3);
439 vector<Double_t> prevSmoothedC;
440 for (Int_t i = 0; i < 15; ++i) {
441 prevSmoothedC.push_back(cov3[i]);
442 }
443
444 Double_t cov4[15];
445 prevNode->GetPredictedParam()->CovMatrix(cov4);
446 vector<Double_t> prevPredC;
447 for (Int_t i = 0; i < 15; ++i) {
448 prevPredC.push_back(cov4[i]);
449 }
450
451 vector<Double_t> temp4(15);
452 Subtract(prevSmoothedC, prevPredC, temp4);
453
454 vector<Double_t> temp5(15);
455 Similarity(A, temp4, temp5);
456 vector<Double_t> thisSmoothedC(15);
457 Add(thisUpdC, temp5, thisSmoothedC);
458
459 FairTrackParam par;
460
461 par.SetX(thisSmoothedX[0]);
462 par.SetY(thisSmoothedX[1]);
463 par.SetTx(thisSmoothedX[2]);
464 par.SetTy(thisSmoothedX[3]);
465 par.SetQp(thisSmoothedX[4]);
466
467 Double_t cov5[15];
468 for (Int_t i = 0; i < 15; ++i) {
469 cov5[i] = thisSmoothedC[i];
470 }
471 par.SetCovMatrix(cov5);
472 par.SetZ(thisNode->GetUpdatedParam()->GetZ());
473
474 thisNode->SetSmoothedParam(&par);
475
476 return kBMNSUCCESS;
477}
478
479// propagate with flag isField is needed for backward compatibility
481 Double_t zOut,
482 Int_t pdg,
483 vector<Double_t>* F,
484 Double_t* length,
485 Bool_t isField)
486{
487 return TGeoTrackPropagate(par, zOut, pdg, F, length);
488}
489
491 Double_t zOut,
492 Int_t pdg,
493 vector<Double_t>* F,
494 Double_t* length)
495{
496
497 BmnFieldMap* field = (BmnFieldMap*)FairRunAna::Instance()->GetField();
498 Bool_t isField = !(field->IsFieldOff());
499
500 if (!IsParCorrect(par, isField))
501 return kBMNERROR;
502 Double_t zIn = par->GetZ();
503 Double_t dz = zOut - zIn;
504
505 Bool_t downstream = dz > 0;
506
507 if (isField) {
508 if (F != NULL) {
509 F->assign(25, 0.);
510 (*F)[0] = 1.;
511 (*F)[6] = 1.;
512 (*F)[12] = 1.;
513 (*F)[18] = 1.;
514 (*F)[24] = 1.;
515 }
516
517 Int_t nofSteps = Int_t(abs(dz) / 10);
518 Double_t stepSize;
519 if (nofSteps == 0) {
520 stepSize = abs(dz);
521 } else {
522 stepSize = 10.0;
523 }
524 Double_t z = zIn;
525
526 // cout << "Z = " << zIn << " Par q/p = " << par->GetQp() << endl;
527 // if (length) *length = 0;
528 // Loop over steps + additional step to propagate to virtual plane at zOut
529 for (Int_t iStep = 0; iStep < nofSteps + 1; iStep++) { // FIXME possible problems with geometry...
530 if (!IsParCorrect(par, isField))
531 return kBMNERROR;
532 // Check if already at exit position
533 if (z == zOut)
534 break;
535 // Update current z position
536 if (iStep != nofSteps)
537 z = (downstream) ? z + stepSize : z - stepSize;
538 else
539 z = zOut;
540
541 // Get intersections with materials for this step
542 vector<BmnMaterialInfo> inter;
543
544 if (fNavigator->FindIntersections(par, z, inter) == kBMNERROR)
545 return kBMNERROR;
546
547 // Loop over material layers
548 for (UInt_t iMat = 0; iMat < inter.size(); iMat++) {
549 BmnMaterialInfo mat = inter[iMat];
550 // Check if track parameters are correct
551 if (!IsParCorrect(par, isField))
552 return kBMNERROR;
553 vector<Double_t>* Fnew = NULL;
554 if (F != NULL)
555 Fnew = new vector<Double_t>(25, 0.);
556
557 // Extrapolate to the next boundary
558 if (RK4TrackExtrapolate(par, mat.GetZpos(), Fnew) == kBMNERROR)
559 { // Is it possible to return error from RK4 extrapolator???
560 return kBMNERROR;
561 }
562
563 // Update transport matrix
564 if (F != NULL)
565 UpdateF(*F, *Fnew);
566 if (Fnew != NULL)
567 delete Fnew;
568
569 fMaterial->Update(par, &mat, pdg, downstream);
570 if (length)
571 *length += mat.GetLength();
572 }
573 }
574 } else { // line extrapolation
575 Float_t x0 = par->GetX();
576 Float_t y0 = par->GetY();
577 Float_t z0 = par->GetZ();
578 Float_t ty = par->GetTy();
579 Float_t tx = par->GetTx();
580 Float_t xOut = tx * (zOut - z0) + x0;
581 Float_t yOut = ty * (zOut - z0) + y0;
582 par->SetX(xOut);
583 par->SetY(yOut);
584 par->SetZ(zOut);
585 if (length)
586 *length = Sqrt(Sq(xOut - x0) + Sq(yOut - y0) + Sq(zOut - z0));
587 }
588
589 if (!IsParCorrect(par, isField)) {
590 return kBMNERROR;
591 } else {
592 return kBMNSUCCESS;
593 }
594}
Bool_t IsParCorrect(const FairTrackParam *par, const Bool_t isField)
Definition BmnMath.cxx:59
Bool_t Similarity(const vector< Double_t > &a, const vector< Double_t > &b, vector< Double_t > &c)
Bool_t Mult25On5(const vector< Double_t > &a, const vector< Double_t > &b, vector< Double_t > &c)
Bool_t Subtract(const vector< Double_t > &a, const vector< Double_t > &b, vector< Double_t > &c)
Bool_t Mult25(const vector< Double_t > &a, const vector< Double_t > &b, vector< Double_t > &c)
Bool_t Mult15On25(const vector< Double_t > &a, const vector< Double_t > &b, vector< Double_t > &c)
Bool_t Transpose25(vector< Double_t > &a)
Bool_t InvSym15(vector< Double_t > &a)
Bool_t Add(const vector< Double_t > &a, const vector< Double_t > &b, vector< Double_t > &c)
Bool_t Mult25On15(const vector< Double_t > &a, const vector< Double_t > &b, vector< Double_t > &c)
const Float_t z0
Definition BmnMwpcHit.cxx:6
int i
Definition P4_F32vec4.h:22
BmnStatus
Definition BmnEnums.h:24
@ kBMNERROR
Definition BmnEnums.h:26
@ kBMNSUCCESS
Definition BmnEnums.h:25
Bool_t IsFieldOff() const
Definition BmnFieldMap.h:93
FairTrackParam * GetSmoothedParam()
Definition BmnFitNode.h:48
void SetSmoothedParam(const FairTrackParam *par)
Definition BmnFitNode.h:57
const vector< Double_t > & GetF() const
Definition BmnFitNode.h:44
const FairTrackParam * GetPredictedParam() const
Definition BmnFitNode.h:46
FairTrackParam * GetUpdatedParam()
Definition BmnFitNode.h:47
BmnStatus FindIntersections(const FairTrackParam *par, Float_t zOut, vector< BmnMaterialInfo > &inter)
void RK4Order(const vector< Double_t > &xIn, Double_t zIn, vector< Double_t > &xOut, Double_t zOut, vector< Double_t > &derivs)
BmnStatus RK4TrackExtrapolate(FairTrackParam *par, Double_t zOut, vector< Double_t > *F)
void TransportC(const vector< Double_t > &cIn, const vector< Double_t > &F, vector< Double_t > &cOut)
void UpdateF(vector< Double_t > &F, const vector< Double_t > &newF)
BmnStatus TGeoTrackPropagate(FairTrackParam *par, Double_t zOut, Int_t pdg, vector< Double_t > *F, Double_t *length, Bool_t isField)
BmnStatus Update(FairTrackParam *par, const BmnHit *hit, Double_t &chiSq)
BmnStatus Smooth(BmnFitNode *thisNode, BmnFitNode *prevNode)
virtual ~BmnKalmanFilter()
Double_t CalcOut(Double_t in, const Double_t k[4])
Interface for material effects calculation algorithm.
virtual BmnStatus Update(FairTrackParam *par, const BmnMaterialInfo *mat, Int_t pdg, Bool_t downstream)
Main function to be implemented for concrete material effects calculation algorithm.
Float_t GetZpos() const
Float_t GetLength() const
STL namespace.