51 const Int_t MaxIter = 3;
59 r[0] =
r[1] =
r[2] = 0.;
73 for (Int_t iteration = 0; iteration < MaxIter; ++iteration) {
75 for (
int i = 0;
i < 8;
i++)
83 for (Int_t
i = 0;
i < 36; ++
i)
86 C[0] =
C[2] =
C[5] = 100.0;
91 for (vector<CbmKFTrackInterface*>::iterator tr =
vTracks.begin();
103 Double_t a =
m[2], b =
m[3], qp =
m[4];
105 Double_t s = V[0] * V[2] - V[1] * V[1];
106 s = (s > 1.E-20) ? 1. / s : 0;
107 Double_t zetas[2] = {(
r0[0] -
m[0]) * s, (
r0[1] -
m[1]) * s};
108 a += (V[3] * V[2] - V[4] * V[1]) * zetas[0]
109 + (-V[3] * V[1] + V[4] * V[0]) * zetas[1];
110 b += (V[6] * V[2] - V[7] * V[1]) * zetas[0]
111 + (-V[6] * V[1] + V[7] * V[0]) * zetas[1];
112 qp += (V[10] * V[2] - V[11] * V[1]) * zetas[0]
113 + (-V[10] * V[1] + V[11] * V[0]) * zetas[1];
117 double mm[6], VV[21];
119 double c2 = 1. / (1. + a * a + b * b);
122 double pz =
sqrt(p2 * c2);
127 double da = (
m[2] - a);
128 double db = (
m[3] - b);
129 double dq = (
m[4] - qp);
131 double H[3] = {-px * c2, -py * c2, -pz * p};
132 double HE = -p * p2 / E;
134 double dpz = H[0] * da + H[1] * db + H[2] * dq;
138 mm[2] = px + da + a * dpz;
139 mm[3] = py + db + b * dpz;
143 double cxpz = H[0] * V[3] + H[1] * V[6] + H[2] * V[10];
144 double cypz = H[0] * V[4] + H[1] * V[7] + H[2] * V[11];
145 double capz = H[0] * V[5] + H[1] * V[8] + H[2] * V[12];
146 double cbpz = H[0] * V[8] + H[1] * V[9] + H[2] * V[13];
147 double cqpz = H[0] * V[12] + H[1] * V[13] + H[2] * V[14];
148 double cpzpz = H[0] * H[0] * V[5] + H[1] * H[1] * V[9]
149 + H[2] * H[2] * V[14]
151 * (H[0] * H[1] * V[8] + H[0] * H[2] * V[12]
152 + H[1] * H[2] * V[13]);
157 VV[3] = V[3] * pz + a * cxpz;
158 VV[4] = V[4] * pz + a * cypz;
159 VV[5] = V[5] * pz * pz + 2 * a * pz * capz + a * a * cpzpz;
160 VV[6] = V[6] * pz + b * cxpz;
161 VV[7] = V[7] * pz + b * cypz;
162 VV[8] = V[8] * pz * pz + a * pz * cbpz + b * pz * capz + a * b * cpzpz;
163 VV[9] = V[9] * pz * pz + 2 * b * pz * cbpz + b * b * cpzpz;
166 VV[12] = capz * pz + a * cpzpz;
167 VV[13] = cbpz * pz + b * cpzpz;
171 VV[17] = HE * (V[12] * pz + a * cqpz);
172 VV[18] = HE * (V[13] * pz + b * cqpz);
174 VV[20] = HE * HE * V[14];
208 Double_t zeta[2] = {mm[0] - (
r[0] - a * (
r[2] -
r0[2])),
209 mm[1] - (
r[1] - b * (
r[2] -
r0[2]))};
215 Double_t S[3] = {VV[0] +
C[0] - 2 * a *
C[3] + a * a *
C[5],
216 VV[1] +
C[1] - b *
C[3] - a *
C[4] + a * b *
C[5],
217 VV[2] +
C[2] - 2 * b *
C[4] + b * b *
C[5]};
221 Double_t s = S[0] * S[2] - S[1] * S[1];
223 if (s < 1.E-20)
continue;
233 Double_t CHt0[7], CHt1[7];
235 CHt0[0] =
C[0] - a *
C[3];
236 CHt1[0] =
C[1] - b *
C[3];
237 CHt0[1] =
C[1] - a *
C[4];
238 CHt1[1] =
C[2] - b *
C[4];
239 CHt0[2] =
C[3] - a *
C[5];
240 CHt1[2] =
C[4] - b *
C[5];
241 CHt0[3] =
C[6] - a *
C[8] - VV[3];
242 CHt1[3] =
C[7] - b *
C[8] - VV[4];
243 CHt0[4] =
C[10] - a *
C[12] - VV[6];
244 CHt1[4] =
C[11] - b *
C[12] - VV[7];
245 CHt0[5] =
C[15] - a *
C[17] - VV[10];
246 CHt1[5] =
C[16] - b *
C[17] - VV[11];
247 CHt0[6] =
C[21] - a *
C[23] - VV[15];
248 CHt1[6] =
C[22] - b *
C[23] - VV[16];
252 Double_t K0[7], K1[7];
254 for (Int_t
i = 0;
i < 7; ++
i) {
255 K0[
i] = CHt0[
i] * S[0] + CHt1[
i] * S[1];
256 K1[
i] = CHt0[
i] * S[1] + CHt1[
i] * S[2];
261 for (Int_t
i = 0;
i < 7; ++
i)
262 r[
i] += K0[
i] * zeta[0] + K1[
i] * zeta[1];
266 for (Int_t
i = 0, k = 0;
i < 7; ++
i) {
267 for (Int_t j = 0; j <=
i; ++j, ++k)
268 C[k] -= K0[
i] * CHt0[j] + K1[
i] * CHt1[j];
274 Chi2 += zeta[0] * zeta[0] * S[0] + 2 * zeta[0] * zeta[1] * S[1]
275 + zeta[1] * zeta[1] * S[2];
292 for (
int i = 0;
i < 6;
i++)
310 Double_t px =
r[3], py =
r[4], pz =
r[5];
312 Double_t p =
sqrt(px * px + py * py + pz * pz);
324 double qp3 = qp * qp * qp;
327 for (Int_t
i = 0;
i < 5;
i++)
328 for (Int_t j = 0; j < 6; ++j)
337 J[2][5] = -Par[2] * pzi;
339 J[3][5] = -Par[3] * pzi;
346 for (Int_t
i = 0;
i < 5;
i++)
347 for (Int_t j = 0; j < 6; j++) {
349 for (Int_t k = 0; k < 6; k++)
350 JC[
i][j] += J[
i][k] *
Cij(k, j);
354 for (Int_t
i = 0;
i < 5;
i++)
355 for (Int_t j =
i; j < 5; j++, ii++) {
357 for (Int_t k = 0; k < 6; k++)
358 Cov[ii] += JC[
i][k] * J[j][k];
367 (
r[3] *
r[3] *
C[9] +
r[4] *
r[4] *
C[14] +
r[5] *
r[5] *
C[20]
368 +
r[6] *
r[6] *
C[27]
370 * (+
r[3] *
r[4] *
C[13] +
r[5] * (
r[3] *
C[18] +
r[4] *
C[19])
371 -
r[6] * (
r[3] *
C[24] +
r[4] *
C[25] +
r[5] *
C[26])));
372 Double_t m2 =
r[6] *
r[6] -
r[3] *
r[3] -
r[4] *
r[4] -
r[5] *
r[5];
374 if (M) *M = (m2 > 1.e-20) ?
sqrt(m2) : 0.;
375 if (Error_) *Error_ = (S >= 0 && m2 > 1.e-20) ?
sqrt(S / m2) : 1.e4;
382 H[0] = H[1] = H[2] = 0.;
391 for (Int_t
i = 0;
i < 8; ++
i)
392 zeta -= H[
i] * (
r[
i] -
r0[
i]);
396 for (Int_t
i = 0;
i < 8; ++
i) {
398 for (Int_t j = 0; j < 8; ++j)
399 CHt[
i] +=
Cij(
i, j) * H[j];
403 if (S < 1.e-20)
return;
405 Chi2 += zeta * zeta * S;
407 for (Int_t
i = 0, ii = 0;
i < 8; ++
i) {
408 Double_t Ki = CHt[
i] * S;
410 for (Int_t j = 0; j <=
i; ++j)
411 C[ii++] -= Ki * CHt[j];
426 double C30 =
C[6] + T *
C[9];
427 double C41 =
C[11] + T *
C[14];
428 double C52 =
C[17] + T *
C[20];
429 double T54 = T *
C[19];
431 C[0] += T * (
C[6] + C30);
432 C[1] += T * (
C[7] +
C[10]);
433 C[2] += T * (
C[11] + C41);
440 C[3] += T * (
C[8] +
C[15]);
441 C[4] += T * (
C[12] +
C[16]);
442 C[5] += T * (
C[17] + C52);
472 double xinf =
r0[0] * inf;
473 double yinf =
r0[1] * inf;
474 double zinf =
r0[2] * inf;
475 C[0] +=
r0[0] * xinf;
476 C[1] +=
r0[0] * yinf;
477 C[2] +=
r0[1] * yinf;
478 C[3] +=
r0[0] * zinf;
479 C[4] +=
r0[1] * zinf;
480 C[5] +=
r0[2] * zinf;
493 Ai[0] =
C[4] *
C[4] -
C[2] *
C[5];
494 Ai[1] =
C[1] *
C[5] -
C[3] *
C[4];
495 Ai[3] =
C[2] *
C[3] -
C[1] *
C[4];
496 double det = (
C[0] * Ai[0] +
C[1] * Ai[1] +
C[3] * Ai[3]);
497 det = (det > 1.e-8) ? 1. / det : 0;
501 Ai[2] = (
C[3] *
C[3] -
C[0] *
C[5]) * det;
502 Ai[4] = (
C[0] *
C[4] -
C[1] *
C[3]) * det;
503 Ai[5] = (
C[1] *
C[1] -
C[0] *
C[2]) * det;
506 B[0][0] =
C[6] * Ai[0] +
C[7] * Ai[1] +
C[8] * Ai[3];
507 B[0][1] =
C[6] * Ai[1] +
C[7] * Ai[2] +
C[8] * Ai[4];
508 B[0][2] =
C[6] * Ai[3] +
C[7] * Ai[4] +
C[8] * Ai[5];
510 B[1][0] =
C[10] * Ai[0] +
C[11] * Ai[1] +
C[12] * Ai[3];
511 B[1][1] =
C[10] * Ai[1] +
C[11] * Ai[2] +
C[12] * Ai[4];
512 B[1][2] =
C[10] * Ai[3] +
C[11] * Ai[4] +
C[12] * Ai[5];
514 B[2][0] =
C[15] * Ai[0] +
C[16] * Ai[1] +
C[17] * Ai[3];
515 B[2][1] =
C[15] * Ai[1] +
C[16] * Ai[2] +
C[17] * Ai[4];
516 B[2][2] =
C[15] * Ai[3] +
C[16] * Ai[4] +
C[17] * Ai[5];
518 B[3][0] =
C[21] * Ai[0] +
C[22] * Ai[1] +
C[23] * Ai[3];
519 B[3][1] =
C[21] * Ai[1] +
C[22] * Ai[2] +
C[23] * Ai[4];
520 B[3][2] =
C[21] * Ai[3] +
C[22] * Ai[4] +
C[23] * Ai[5];
522 B[4][0] =
C[28] * Ai[0] +
C[29] * Ai[1] +
C[30] * Ai[3];
523 B[4][1] =
C[28] * Ai[1] +
C[29] * Ai[2] +
C[30] * Ai[4];
524 B[4][2] =
C[28] * Ai[3] +
C[29] * Ai[4] +
C[30] * Ai[5];
526 double z[3] = {
m[0] -
r[0],
m[1] -
r[1],
m[2] -
r[2]};
530 r[3] += B[0][0] * z[0] + B[0][1] * z[1] + B[0][2] * z[2];
531 r[4] += B[1][0] * z[0] + B[1][1] * z[1] + B[1][2] * z[2];
532 r[5] += B[2][0] * z[0] + B[2][1] * z[1] + B[2][2] * z[2];
533 r[6] += B[3][0] * z[0] + B[3][1] * z[1] + B[3][2] * z[2];
534 r[7] += B[4][0] * z[0] + B[4][1] * z[1] + B[4][2] * z[2];
537 double AV[6] = {
C[0] - V[0],
544 AVi[0] = AV[4] * AV[4] - AV[2] * AV[5];
545 AVi[1] = AV[1] * AV[5] - AV[3] * AV[4];
546 AVi[2] = AV[3] * AV[3] - AV[0] * AV[5];
547 AVi[3] = AV[2] * AV[3] - AV[1] * AV[4];
548 AVi[4] = AV[0] * AV[4] - AV[1] * AV[3];
550 det = (AV[0] * AVi[0] + AV[1] * AVi[1] + AV[3] * AVi[3]);
551 det = (det > 1.e-8) ? 1. / det : 0;
553 Chi2 += (+(AVi[0] * z[0] + AVi[1] * z[1] + AVi[3] * z[2]) * z[0]
554 + (AVi[1] * z[0] + AVi[2] * z[1] + AVi[4] * z[2]) * z[1]
555 + (AVi[3] * z[0] + AVi[4] * z[1] + AVi[5] * z[2]) * z[2])
567 d0 = B[0][0] * V[0] + B[0][1] * V[1] + B[0][2] * V[3] -
C[6];
568 d1 = B[0][0] * V[1] + B[0][1] * V[2] + B[0][2] * V[4] -
C[7];
569 d2 = B[0][0] * V[3] + B[0][1] * V[4] + B[0][2] * V[5] -
C[8];
574 C[9] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
576 d0 = B[1][0] * V[0] + B[1][1] * V[1] + B[1][2] * V[3] -
C[10];
577 d1 = B[1][0] * V[1] + B[1][1] * V[2] + B[1][2] * V[4] -
C[11];
578 d2 = B[1][0] * V[3] + B[1][1] * V[4] + B[1][2] * V[5] -
C[12];
583 C[13] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
584 C[14] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
586 d0 = B[2][0] * V[0] + B[2][1] * V[1] + B[2][2] * V[3] -
C[15];
587 d1 = B[2][0] * V[1] + B[2][1] * V[2] + B[2][2] * V[4] -
C[16];
588 d2 = B[2][0] * V[3] + B[2][1] * V[4] + B[2][2] * V[5] -
C[17];
593 C[18] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
594 C[19] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
595 C[20] += d0 * B[2][0] + d1 * B[2][1] + d2 * B[2][2];
597 d0 = B[3][0] * V[0] + B[3][1] * V[1] + B[3][2] * V[3] -
C[21];
598 d1 = B[3][0] * V[1] + B[3][1] * V[2] + B[3][2] * V[4] -
C[22];
599 d2 = B[3][0] * V[3] + B[3][1] * V[4] + B[3][2] * V[5] -
C[23];
604 C[24] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
605 C[25] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
606 C[26] += d0 * B[2][0] + d1 * B[2][1] + d2 * B[2][2];
607 C[27] += d0 * B[3][0] + d1 * B[3][1] + d2 * B[3][2];
609 d0 = B[4][0] * V[0] + B[4][1] * V[1] + B[4][2] * V[3] -
C[28];
610 d1 = B[4][0] * V[1] + B[4][1] * V[2] + B[4][2] * V[4] -
C[29];
611 d2 = B[4][0] * V[3] + B[4][1] * V[4] + B[4][2] * V[5] -
C[30];
616 C[31] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
617 C[32] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
618 C[33] += d0 * B[2][0] + d1 * B[2][1] + d2 * B[2][2];
619 C[34] += d0 * B[3][0] + d1 * B[3][1] + d2 * B[3][2];
620 C[35] += d0 * B[4][0] + d1 * B[4][1] + d2 * B[4][2];
625 double CH00 =
C[0] +
r0[0] *
C[28];
626 double CH10 =
C[1] +
r0[0] *
C[29];
627 double CH11 =
C[2] +
r0[1] *
C[29];
628 double CH20 =
C[3] +
r0[0] *
C[30];
629 double CH21 =
C[4] +
r0[1] *
C[30];
630 double CH22 =
C[5] +
r0[2] *
C[30];
632 C[28] +=
r0[0] *
C[35];
633 C[29] +=
r0[1] *
C[35];
634 C[30] +=
r0[2] *
C[35];
636 C[0] = CH00 +
r0[0] *
C[28];
637 C[1] = CH10 +
r0[1] *
C[28];
638 C[2] = CH11 +
r0[1] *
C[29];
639 C[3] = CH20 +
r0[2] *
C[28];
640 C[4] = CH21 +
r0[2] *
C[29];
641 C[5] = CH22 +
r0[2] *
C[30];
643 C[6] +=
r0[0] *
C[31];
644 C[7] +=
r0[1] *
C[31];
645 C[8] +=
r0[2] *
C[31];
646 C[10] +=
r0[0] *
C[32];
647 C[11] +=
r0[1] *
C[32];
648 C[12] +=
r0[2] *
C[32];
649 C[15] +=
r0[0] *
C[33];
650 C[16] +=
r0[1] *
C[33];
651 C[17] +=
r0[2] *
C[33];
652 C[21] +=
r0[0] *
C[34];
653 C[22] +=
r0[1] *
C[34];
654 C[23] +=
r0[2] *
C[34];