18 #include "CbmKFParticleDatabase.h"
37 , AtProductionVertex(0) {
39 fDaughtersIds.push_back(Track->
Id());
50 Double_t a =
m[2], b =
m[3], qp =
m[4];
56 Mass = CbmKFParticleDatabase::Instance()->GetMass(*pdg);
61 double c2 = 1. / (1. + a * a + b * b);
63 if (qHypo) pq *= *qHypo;
65 double pz =
sqrt(p2 * c2);
68 double E =
sqrt(Mass * Mass + p2);
70 double H[3] = {-px * c2, -py * c2, -pz * pq};
71 double HE = -pq * p2 / E;
82 double cxpz = H[0] * V[3] + H[1] * V[6] + H[2] * V[10];
83 double cypz = H[0] * V[4] + H[1] * V[7] + H[2] * V[11];
84 double capz = H[0] * V[5] + H[1] * V[8] + H[2] * V[12];
85 double cbpz = H[0] * V[8] + H[1] * V[9] + H[2] * V[13];
86 double cqpz = H[0] * V[12] + H[1] * V[13] + H[2] * V[14];
88 H[0] * H[0] * V[5] + H[1] * H[1] * V[9] + H[2] * H[2] * V[14]
89 + 2 * (H[0] * H[1] * V[8] + H[0] * H[2] * V[12] + H[1] * H[2] * V[13]);
97 C[6] = V[3] * pz + a * cxpz;
98 C[7] = V[4] * pz + a * cypz;
100 C[9] = V[5] * pz * pz + 2 * a * pz * capz + a * a * cpzpz;
101 C[10] = V[6] * pz + b * cxpz;
102 C[11] = V[7] * pz + b * cypz;
104 C[13] = V[8] * pz * pz + a * pz * cbpz + b * pz * capz + a * b * cpzpz;
105 C[14] = V[9] * pz * pz + 2 * b * pz * cbpz + b * b * cpzpz;
109 C[18] = capz * pz + a * cpzpz;
110 C[19] = cbpz * pz + b * cpzpz;
115 C[24] = HE * (V[12] * pz + a * cqpz);
116 C[25] = HE * (V[13] * pz + b * cqpz);
118 C[27] = HE * HE * V[14];
119 C[28] = C[29] = C[30] = C[31] = C[32] = C[33] = C[34] = 0;
124 Q = (qp > 0.) ? 1 : ((qp < 0) ? -1 : 0);
125 if (qHypo) Q *= *qHypo;
126 AtProductionVertex = 1;
130 double s0 =
sqrt(C[0]);
131 double s1 =
sqrt(C[2]);
132 double s2 =
sqrt(C[5]);
133 double s3 =
sqrt(C[9]);
134 double s4 =
sqrt(C[14]);
136 cout << C[1] / s0 / s1 <<
" " << s1 <<
" ";
137 cout << C[3] / s0 / s2 <<
" " << C[4] / s1 / s2 <<
" " << s2 <<
" ";
138 cout << C[6] / s0 / s3 <<
" " << C[7] / s1 / s3 <<
" " << C[8] / s2 / s3
140 cout << C[10] / s0 / s4 <<
" " << C[11] / s1 / s4 <<
" " << C[12] / s2 / s4
141 <<
" " << C[13] / s3 / s4 <<
" " << s4 << endl;
148 const Int_t MaxIter = 3;
151 r[0] =
r[1] =
r[2] = 0.;
152 C[0] =
C[2] =
C[5] = 1.;
153 C[1] =
C[3] =
C[4] = 0;
158 C[0] =
C[2] = t.
R * t.
R / 9.;
160 C[1] =
C[3] =
C[4] = 0;
169 for (Int_t iteration = 0; iteration < MaxIter; ++iteration) {
171 Double_t r0[8], C0[6];
173 for (
int i = 0;
i < 8;
i++)
175 for (
int i = 0;
i < 6;
i++)
179 if (iteration == 0) {
180 Double_t VertexGuess[3];
182 Double_t fTDaughter[(int) vDaughters.size()][6];
183 Double_t fCDaughter[(int) vDaughters.size()][15];
185 vector<CbmKFTrack*> TrV;
188 for (vector<CbmKFTrackInterface*>::iterator tr = vDaughters.begin();
189 tr != vDaughters.end();
192 fTDaughter[nvect][0] = Tr->
GetTrack()[0];
193 fTDaughter[nvect][1] = Tr->
GetTrack()[1];
194 fTDaughter[nvect][2] = Tr->
GetTrack()[2];
195 fTDaughter[nvect][3] = Tr->
GetTrack()[3];
196 fTDaughter[nvect][4] = Tr->
GetTrack()[4];
197 fTDaughter[nvect][5] = Tr->
GetTrack()[5];
209 Double_t z = (fTDaughter[0][3] * fTDaughter[0][5]
210 - fTDaughter[1][3] * fTDaughter[1][5] + fTDaughter[1][1]
212 / (fTDaughter[0][3] - fTDaughter[1][3]);
225 r0[0] = VertexGuess[0];
226 r0[1] = VertexGuess[1];
227 r0[2] = VertexGuess[2];
235 for (Int_t
i = 0;
i < 36; ++
i)
238 C[0] =
C[2] =
C[5] = 100.;
244 MF->GetFieldValue(r0, B);
245 const Double_t
c_light = 0.000299792458;
255 for (vector<CbmKFTrackInterface*>::iterator tr = vDaughters.begin();
256 tr != vDaughters.end();
262 Double_t*
m = Daughter.
r;
263 Double_t* Cd = Daughter.
C;
265 Double_t
d[3] = {r0[0] -
m[0], r0[1] -
m[1], r0[2] -
m[2]};
268 *
sqrt((
d[0] *
d[0] +
d[1] *
d[1] +
d[2] *
d[2])
269 / (
m[3] *
m[3] +
m[4] *
m[4] +
m[5] *
m[5]));
273 h[0] =
m[3] * SigmaS;
274 h[1] =
m[4] * SigmaS;
275 h[2] =
m[5] * SigmaS;
276 h[3] = (
h[1] * B[2] -
h[2] * B[1]) * Daughter.
Q;
277 h[4] = (
h[2] * B[0] -
h[0] * B[2]) * Daughter.
Q;
278 h[5] = (
h[0] * B[1] -
h[1] * B[0]) * Daughter.
Q;
282 Double_t zeta[3] = {r0[0] -
m[0], r0[1] -
m[1], r0[2] -
m[2]};
284 Double_t Vv[6] = {Cd[0] +
h[0] *
h[0],
289 Cd[5] +
h[2] *
h[2]};
291 Double_t Vvp[9] = {Cd[6] +
h[0] *
h[3],
294 Cd[10] +
h[0] *
h[4],
295 Cd[11] +
h[1] *
h[4],
296 Cd[12] +
h[2] *
h[4],
297 Cd[15] +
h[0] *
h[5],
298 Cd[16] +
h[1] *
h[5],
299 Cd[17] +
h[2] *
h[5]};
303 Double_t Si[6] = {Vv[0] + C0[0],
309 Double_t S[6] = {Si[2] * Si[5] - Si[4] * Si[4],
310 Si[3] * Si[4] - Si[1] * Si[5],
311 Si[0] * Si[5] - Si[3] * Si[3],
312 Si[1] * Si[4] - Si[2] * Si[3],
313 Si[1] * Si[3] - Si[0] * Si[4],
314 Si[0] * Si[2] - Si[1] * Si[1]};
315 Double_t det = (Si[0] * S[0] + Si[1] * S[1] + Si[3] * S[3]);
317 (+(S[0] * zeta[0] + S[1] * zeta[1] + S[3] * zeta[2]) * zeta[0]
318 + (S[1] * zeta[0] + S[2] * zeta[1] + S[4] * zeta[2]) * zeta[1]
319 + (S[3] * zeta[0] + S[4] * zeta[1] + S[5] * zeta[2]) * zeta[2]);
320 if (chi2 > 2 * CutChi2 * det)
continue;
323 double S[6] = {Vv[2] * Vv[5] - Vv[4] * Vv[4],
324 Vv[3] * Vv[4] - Vv[1] * Vv[5],
325 Vv[0] * Vv[5] - Vv[3] * Vv[3],
326 Vv[1] * Vv[4] - Vv[2] * Vv[3],
327 Vv[1] * Vv[3] - Vv[0] * Vv[4],
328 Vv[0] * Vv[2] - Vv[1] * Vv[1]};
330 double s = (Vv[0] * S[0] + Vv[1] * S[1] + Vv[3] * S[3]);
331 s = (s > 1.E-20) ? 1. / s : 0;
340 Double_t Sz[3] = {(S[0] * zeta[0] + S[1] * zeta[1] + S[3] * zeta[2]),
341 (S[1] * zeta[0] + S[2] * zeta[1] + S[4] * zeta[2]),
342 (S[3] * zeta[0] + S[4] * zeta[1] + S[5] * zeta[2])};
344 Double_t
x =
m[3] + Vvp[0] * Sz[0] + Vvp[1] * Sz[1] + Vvp[2] * Sz[2];
345 Double_t
y =
m[4] + Vvp[3] * Sz[0] + Vvp[4] * Sz[1] + Vvp[5] * Sz[2];
346 Double_t z =
m[5] + Vvp[6] * Sz[0] + Vvp[7] * Sz[1] + Vvp[8] * Sz[2];
351 h[3] = (
h[1] * B[2] -
h[2] * B[1]) * Daughter.Q;
352 h[4] = (
h[2] * B[0] -
h[0] * B[2]) * Daughter.Q;
353 h[5] = (
h[0] * B[1] -
h[1] * B[0]) * Daughter.Q;
358 V[0] = Cd[0] +
h[0] *
h[0];
359 V[1] = Cd[1] +
h[1] *
h[0];
360 V[2] = Cd[2] +
h[1] *
h[1];
361 V[3] = Cd[3] +
h[2] *
h[0];
362 V[4] = Cd[4] +
h[2] *
h[1];
363 V[5] = Cd[5] +
h[2] *
h[2];
365 V[6] = Cd[6] +
h[3] *
h[0];
366 V[7] = Cd[7] +
h[3] *
h[1];
367 V[8] = Cd[8] +
h[3] *
h[2];
368 V[9] = Cd[9] +
h[3] *
h[3];
370 V[10] = Cd[10] +
h[4] *
h[0];
371 V[11] = Cd[11] +
h[4] *
h[1];
372 V[12] = Cd[12] +
h[4] *
h[2];
373 V[13] = Cd[13] +
h[4] *
h[3];
374 V[14] = Cd[14] +
h[4] *
h[4];
376 V[15] = Cd[15] +
h[5] *
h[0];
377 V[16] = Cd[16] +
h[5] *
h[1];
378 V[17] = Cd[17] +
h[5] *
h[2];
379 V[18] = Cd[18] +
h[5] *
h[3];
380 V[19] = Cd[19] +
h[5] *
h[4];
381 V[20] = Cd[20] +
h[5] *
h[5];
398 for (
int i = 0;
i < 7;
i++)
400 for (
int i = 0;
i < 28;
i++)
409 double Si[6] = {
C[0] + V[0],
416 S[0] = Si[2] * Si[5] - Si[4] * Si[4];
417 S[1] = Si[3] * Si[4] - Si[1] * Si[5];
418 S[2] = Si[0] * Si[5] - Si[3] * Si[3];
419 S[3] = Si[1] * Si[4] - Si[2] * Si[3];
420 S[4] = Si[1] * Si[3] - Si[0] * Si[4];
421 S[5] = Si[0] * Si[2] - Si[1] * Si[1];
423 double s = (Si[0] * S[0] + Si[1] * S[1] + Si[3] * S[3]);
424 s = (s > 1.E-20) ? 1. / s : 0;
435 Double_t zeta[3] = {
m[0] -
r[0],
m[1] -
r[1],
m[2] -
r[2]};
457 Double_t CHt0[7], CHt1[7], CHt2[7];
468 CHt0[3] =
C[6] - V[6];
469 CHt1[3] =
C[7] - V[7];
470 CHt2[3] =
C[8] - V[8];
471 CHt0[4] =
C[10] - V[10];
472 CHt1[4] =
C[11] - V[11];
473 CHt2[4] =
C[12] - V[12];
474 CHt0[5] =
C[15] - V[15];
475 CHt1[5] =
C[16] - V[16];
476 CHt2[5] =
C[17] - V[17];
477 CHt0[6] =
C[21] - V[21];
478 CHt1[6] =
C[22] - V[22];
479 CHt2[6] =
C[23] - V[23];
483 Double_t K0[7], K1[7], K2[7];
485 for (Int_t
i = 0;
i < 7; ++
i) {
486 K0[
i] = CHt0[
i] * S[0] + CHt1[
i] * S[1] + CHt2[
i] * S[3];
487 K1[
i] = CHt0[
i] * S[1] + CHt1[
i] * S[2] + CHt2[
i] * S[4];
488 K2[
i] = CHt0[
i] * S[3] + CHt1[
i] * S[4] + CHt2[
i] * S[5];
493 for (Int_t
i = 0;
i < 7; ++
i)
494 r[
i] += K0[
i] * zeta[0] + K1[
i] * zeta[1] + K2[
i] * zeta[2];
498 for (Int_t
i = 0, k = 0;
i < 7; ++
i) {
499 for (Int_t j = 0; j <=
i; ++j, ++k)
500 C[k] -= K0[
i] * CHt0[j] + K1[
i] * CHt1[j] + K2[
i] * CHt2[j];
505 Chi2 += (S[0] * zeta[0] + S[1] * zeta[1] + S[3] * zeta[2]) * zeta[0]
506 + (S[1] * zeta[0] + S[2] * zeta[1] + S[4] * zeta[2]) * zeta[1]
507 + (S[3] * zeta[0] + S[4] * zeta[1] + S[5] * zeta[2]) * zeta[2];
511 if (iteration == 0) {
517 double dx = Parent->GetRefX() - r[0];
518 double dy = Parent->GetRefY() - r[1];
519 double dz = Parent->GetRefZ() - r[2];
520 r0[7] = r[7] =
sqrt((dx * dx + dy * dy + dz * dz)
521 / (r[3] * r[3] + r[4] * r[4] + r[5] * r[5]));
525 if (Mass >= 0) MeasureMass(r0, Mass);
526 if (Parent) MeasureProductionVertex(r0, Parent);
530 AtProductionVertex = 0;
537 const Int_t MaxIter = 3;
540 r[0] =
r[1] =
r[2] = 0.;
541 C[0] =
C[2] =
C[5] = 1.;
542 C[1] =
C[3] =
C[4] = 0;
547 C[0] =
C[2] = t.
R * t.
R / 9.;
549 C[1] =
C[3] =
C[4] = 0;
558 for (Int_t iteration = 0; iteration < MaxIter; ++iteration) {
560 Double_t r0[8], C0[6];
562 for (
int i = 0;
i < 8;
i++)
564 for (
int i = 0;
i < 6;
i++)
567 if (iteration == 0) {
568 Double_t VertexGuess[3];
570 Double_t fTDaughter[(int) vDaughters.size()][6];
571 Double_t fCDaughter[(int) vDaughters.size()][15];
573 vector<CbmKFTrack*> TrV;
576 for (vector<CbmKFParticle*>::iterator tr = vDaughters.begin();
577 tr != vDaughters.end();
584 fTDaughter[nvect][0] = Tr->
GetTrack()[0];
585 fTDaughter[nvect][1] = Tr->
GetTrack()[1];
586 fTDaughter[nvect][2] = Tr->
GetTrack()[2];
587 fTDaughter[nvect][3] = Tr->
GetTrack()[3];
588 fTDaughter[nvect][4] = Tr->
GetTrack()[4];
589 fTDaughter[nvect][5] = Tr->
GetTrack()[5];
602 Double_t z = (fTDaughter[0][3] * fTDaughter[0][5]
603 - fTDaughter[1][3] * fTDaughter[1][5] + fTDaughter[1][1]
605 / (fTDaughter[0][3] - fTDaughter[1][3]);
618 r0[0] = VertexGuess[0];
619 r0[1] = VertexGuess[1];
620 r0[2] = VertexGuess[2];
628 for (Int_t
i = 0;
i < 36; ++
i)
631 C[0] =
C[2] =
C[5] = 100.;
637 MF->GetFieldValue(r0, B);
638 const Double_t
c_light = 0.000299792458;
648 for (vector<CbmKFParticle*>::iterator tr = vDaughters.begin();
649 tr != vDaughters.end();
653 Double_t dx_aprox = Daughter.
r[0] - r0[0];
654 Double_t dy_aprox = Daughter.
r[1] - r0[1];
655 Double_t dz_aprox = Daughter.
r[2] - r0[2];
657 sqrt((dx_aprox * dx_aprox + dy_aprox * dy_aprox + dz_aprox * dz_aprox)
658 / (Daughter.
r[3] * Daughter.
r[3] + Daughter.
r[4] * Daughter.
r[4]
659 + Daughter.
r[5] * Daughter.
r[5]));
663 Double_t*
m = Daughter.
r;
664 Double_t* Cd = Daughter.
C;
666 Double_t
d[3] = {r0[0] -
m[0], r0[1] -
m[1], r0[2] -
m[2]};
669 *
sqrt((
d[0] *
d[0] +
d[1] *
d[1] +
d[2] *
d[2])
670 / (
m[3] *
m[3] +
m[4] *
m[4] +
m[5] *
m[5]));
674 h[0] =
m[3] * SigmaS;
675 h[1] =
m[4] * SigmaS;
676 h[2] =
m[5] * SigmaS;
677 h[3] = (
h[1] * B[2] -
h[2] * B[1]) * Daughter.
Q;
678 h[4] = (
h[2] * B[0] -
h[0] * B[2]) * Daughter.
Q;
679 h[5] = (
h[0] * B[1] -
h[1] * B[0]) * Daughter.
Q;
683 Double_t zeta[3] = {r0[0] -
m[0], r0[1] -
m[1], r0[2] -
m[2]};
685 Double_t Vv[6] = {Cd[0] +
h[0] *
h[0],
690 Cd[5] +
h[2] *
h[2]};
692 Double_t Vvp[9] = {Cd[6] +
h[0] *
h[3],
695 Cd[10] +
h[0] *
h[4],
696 Cd[11] +
h[1] *
h[4],
697 Cd[12] +
h[2] *
h[4],
698 Cd[15] +
h[0] *
h[5],
699 Cd[16] +
h[1] *
h[5],
700 Cd[17] +
h[2] *
h[5]};
704 Double_t Si[6] = {Vv[0] + C0[0],
710 Double_t S[6] = {Si[2] * Si[5] - Si[4] * Si[4],
711 Si[3] * Si[4] - Si[1] * Si[5],
712 Si[0] * Si[5] - Si[3] * Si[3],
713 Si[1] * Si[4] - Si[2] * Si[3],
714 Si[1] * Si[3] - Si[0] * Si[4],
715 Si[0] * Si[2] - Si[1] * Si[1]};
716 Double_t det = (Si[0] * S[0] + Si[1] * S[1] + Si[3] * S[3]);
718 (+(S[0] * zeta[0] + S[1] * zeta[1] + S[3] * zeta[2]) * zeta[0]
719 + (S[1] * zeta[0] + S[2] * zeta[1] + S[4] * zeta[2]) * zeta[1]
720 + (S[3] * zeta[0] + S[4] * zeta[1] + S[5] * zeta[2]) * zeta[2]);
721 if (chi2 > 2 * CutChi2 * det)
continue;
724 double S[6] = {Vv[2] * Vv[5] - Vv[4] * Vv[4],
725 Vv[3] * Vv[4] - Vv[1] * Vv[5],
726 Vv[0] * Vv[5] - Vv[3] * Vv[3],
727 Vv[1] * Vv[4] - Vv[2] * Vv[3],
728 Vv[1] * Vv[3] - Vv[0] * Vv[4],
729 Vv[0] * Vv[2] - Vv[1] * Vv[1]};
731 double s = (Vv[0] * S[0] + Vv[1] * S[1] + Vv[3] * S[3]);
732 s = (s > 1.E-20) ? 1. / s : 0;
741 Double_t Sz[3] = {(S[0] * zeta[0] + S[1] * zeta[1] + S[3] * zeta[2]),
742 (S[1] * zeta[0] + S[2] * zeta[1] + S[4] * zeta[2]),
743 (S[3] * zeta[0] + S[4] * zeta[1] + S[5] * zeta[2])};
745 Double_t
x =
m[3] + Vvp[0] * Sz[0] + Vvp[1] * Sz[1] + Vvp[2] * Sz[2];
746 Double_t
y =
m[4] + Vvp[3] * Sz[0] + Vvp[4] * Sz[1] + Vvp[5] * Sz[2];
747 Double_t z =
m[5] + Vvp[6] * Sz[0] + Vvp[7] * Sz[1] + Vvp[8] * Sz[2];
752 h[3] = (
h[1] * B[2] -
h[2] * B[1]) * Daughter.Q;
753 h[4] = (
h[2] * B[0] -
h[0] * B[2]) * Daughter.Q;
754 h[5] = (
h[0] * B[1] -
h[1] * B[0]) * Daughter.Q;
759 V[0] = Cd[0] +
h[0] *
h[0];
760 V[1] = Cd[1] +
h[1] *
h[0];
761 V[2] = Cd[2] +
h[1] *
h[1];
762 V[3] = Cd[3] +
h[2] *
h[0];
763 V[4] = Cd[4] +
h[2] *
h[1];
764 V[5] = Cd[5] +
h[2] *
h[2];
766 V[6] = Cd[6] +
h[3] *
h[0];
767 V[7] = Cd[7] +
h[3] *
h[1];
768 V[8] = Cd[8] +
h[3] *
h[2];
769 V[9] = Cd[9] +
h[3] *
h[3];
771 V[10] = Cd[10] +
h[4] *
h[0];
772 V[11] = Cd[11] +
h[4] *
h[1];
773 V[12] = Cd[12] +
h[4] *
h[2];
774 V[13] = Cd[13] +
h[4] *
h[3];
775 V[14] = Cd[14] +
h[4] *
h[4];
777 V[15] = Cd[15] +
h[5] *
h[0];
778 V[16] = Cd[16] +
h[5] *
h[1];
779 V[17] = Cd[17] +
h[5] *
h[2];
780 V[18] = Cd[18] +
h[5] *
h[3];
781 V[19] = Cd[19] +
h[5] *
h[4];
782 V[20] = Cd[20] +
h[5] *
h[5];
799 for (
int i = 0;
i < 7;
i++)
801 for (
int i = 0;
i < 28;
i++)
810 double Si[6] = {
C[0] + V[0],
817 S[0] = Si[2] * Si[5] - Si[4] * Si[4];
818 S[1] = Si[3] * Si[4] - Si[1] * Si[5];
819 S[2] = Si[0] * Si[5] - Si[3] * Si[3];
820 S[3] = Si[1] * Si[4] - Si[2] * Si[3];
821 S[4] = Si[1] * Si[3] - Si[0] * Si[4];
822 S[5] = Si[0] * Si[2] - Si[1] * Si[1];
824 double s = (Si[0] * S[0] + Si[1] * S[1] + Si[3] * S[3]);
825 s = (s > 1.E-20) ? 1. / s : 0;
836 Double_t zeta[3] = {
m[0] -
r[0],
m[1] -
r[1],
m[2] -
r[2]};
858 Double_t CHt0[7], CHt1[7], CHt2[7];
869 CHt0[3] =
C[6] - V[6];
870 CHt1[3] =
C[7] - V[7];
871 CHt2[3] =
C[8] - V[8];
872 CHt0[4] =
C[10] - V[10];
873 CHt1[4] =
C[11] - V[11];
874 CHt2[4] =
C[12] - V[12];
875 CHt0[5] =
C[15] - V[15];
876 CHt1[5] =
C[16] - V[16];
877 CHt2[5] =
C[17] - V[17];
878 CHt0[6] =
C[21] - V[21];
879 CHt1[6] =
C[22] - V[22];
880 CHt2[6] =
C[23] - V[23];
884 Double_t K0[7], K1[7], K2[7];
886 for (Int_t
i = 0;
i < 7; ++
i) {
887 K0[
i] = CHt0[
i] * S[0] + CHt1[
i] * S[1] + CHt2[
i] * S[3];
888 K1[
i] = CHt0[
i] * S[1] + CHt1[
i] * S[2] + CHt2[
i] * S[4];
889 K2[
i] = CHt0[
i] * S[3] + CHt1[
i] * S[4] + CHt2[
i] * S[5];
894 for (Int_t
i = 0;
i < 7; ++
i)
895 r[
i] += K0[
i] * zeta[0] + K1[
i] * zeta[1] + K2[
i] * zeta[2];
899 for (Int_t
i = 0, k = 0;
i < 7; ++
i) {
900 for (Int_t j = 0; j <=
i; ++j, ++k)
901 C[k] -= K0[
i] * CHt0[j] + K1[
i] * CHt1[j] + K2[
i] * CHt2[j];
906 Chi2 += (S[0] * zeta[0] + S[1] * zeta[1] + S[3] * zeta[2]) * zeta[0]
907 + (S[1] * zeta[0] + S[2] * zeta[1] + S[4] * zeta[2]) * zeta[1]
908 + (S[3] * zeta[0] + S[4] * zeta[1] + S[5] * zeta[2]) * zeta[2];
912 if (iteration == 0) {
918 double dx = Parent->GetRefX() - r[0];
919 double dy = Parent->GetRefY() - r[1];
920 double dz = Parent->GetRefZ() - r[2];
921 r0[7] = r[7] =
sqrt((dx * dx + dy * dy + dz * dz)
922 / (r[3] * r[3] + r[4] * r[4] + r[5] * r[5]));
926 if (Mass >= 0) MeasureMass(r0, Mass);
927 if (Parent) MeasureProductionVertex(r0, Parent);
931 AtProductionVertex = 0;
936 H[0] = H[1] = H[2] = 0.;
942 double m2 = r0[6] * r0[6] - r0[3] * r0[3] - r0[4] * r0[4] - r0[5] * r0[5];
944 double zeta = Mass * Mass - m2;
945 for (Int_t
i = 0;
i < 8; ++
i)
946 zeta -= H[
i] * (
r[
i] - r0[
i]);
950 for (Int_t
i = 0;
i < 8; ++
i) {
952 for (Int_t j = 0; j < 8; ++j)
953 CHt[
i] +=
Cij(
i, j) * H[j];
957 if (S < 1.e-20)
return;
959 Chi2 += zeta * zeta * S;
961 for (Int_t
i = 0, ii = 0;
i < 8; ++
i) {
962 Double_t Ki = CHt[
i] * S;
964 for (Int_t j = 0; j <=
i; ++j)
965 C[ii++] -= Ki * CHt[j];
985 Ai[0] =
C[4] *
C[4] -
C[2] *
C[5];
986 Ai[1] =
C[1] *
C[5] -
C[3] *
C[4];
987 Ai[3] =
C[2] *
C[3] -
C[1] *
C[4];
988 double det = 1. / (
C[0] * Ai[0] +
C[1] * Ai[1] +
C[3] * Ai[3]);
992 Ai[2] = (
C[3] *
C[3] -
C[0] *
C[5]) * det;
993 Ai[4] = (
C[0] *
C[4] -
C[1] *
C[3]) * det;
994 Ai[5] = (
C[1] *
C[1] -
C[0] *
C[2]) * det;
998 B[0][0] =
C[6] * Ai[0] +
C[7] * Ai[1] +
C[8] * Ai[3];
999 B[0][1] =
C[6] * Ai[1] +
C[7] * Ai[2] +
C[8] * Ai[4];
1000 B[0][2] =
C[6] * Ai[3] +
C[7] * Ai[4] +
C[8] * Ai[5];
1002 B[1][0] =
C[10] * Ai[0] +
C[11] * Ai[1] +
C[12] * Ai[3];
1003 B[1][1] =
C[10] * Ai[1] +
C[11] * Ai[2] +
C[12] * Ai[4];
1004 B[1][2] =
C[10] * Ai[3] +
C[11] * Ai[4] +
C[12] * Ai[5];
1006 B[2][0] =
C[15] * Ai[0] +
C[16] * Ai[1] +
C[17] * Ai[3];
1007 B[2][1] =
C[15] * Ai[1] +
C[16] * Ai[2] +
C[17] * Ai[4];
1008 B[2][2] =
C[15] * Ai[3] +
C[16] * Ai[4] +
C[17] * Ai[5];
1010 B[3][0] =
C[21] * Ai[0] +
C[22] * Ai[1] +
C[23] * Ai[3];
1011 B[3][1] =
C[21] * Ai[1] +
C[22] * Ai[2] +
C[23] * Ai[4];
1012 B[3][2] =
C[21] * Ai[3] +
C[22] * Ai[4] +
C[23] * Ai[5];
1014 B[4][0] =
C[28] * Ai[0] +
C[29] * Ai[1] +
C[30] * Ai[3];
1015 B[4][1] =
C[28] * Ai[1] +
C[29] * Ai[2] +
C[30] * Ai[4];
1016 B[4][2] =
C[28] * Ai[3] +
C[29] * Ai[4] +
C[30] * Ai[5];
1018 double z[3] = {
m[0] -
r[0],
m[1] -
r[1],
m[2] -
r[2]};
1021 double AV[6] = {
C[0] - V[0],
1028 AVi[0] = AV[4] * AV[4] - AV[2] * AV[5];
1029 AVi[1] = AV[1] * AV[5] - AV[3] * AV[4];
1030 AVi[2] = AV[3] * AV[3] - AV[0] * AV[5];
1031 AVi[3] = AV[2] * AV[3] - AV[1] * AV[4];
1032 AVi[4] = AV[0] * AV[4] - AV[1] * AV[3];
1033 AVi[5] = AV[1] * AV[1] - AV[0] * AV[2];
1035 det = 1. / (AV[0] * AVi[0] + AV[1] * AVi[1] + AV[3] * AVi[3]);
1038 Chi2 += (+(AVi[0] * z[0] + AVi[1] * z[1] + AVi[3] * z[2]) * z[0]
1039 + (AVi[1] * z[0] + AVi[2] * z[1] + AVi[4] * z[2]) * z[1]
1040 + (AVi[3] * z[0] + AVi[4] * z[1] + AVi[5] * z[2]) * z[2])
1047 r[3] += B[0][0] * z[0] + B[0][1] * z[1] + B[0][2] * z[2];
1048 r[4] += B[1][0] * z[0] + B[1][1] * z[1] + B[1][2] * z[2];
1049 r[5] += B[2][0] * z[0] + B[2][1] * z[1] + B[2][2] * z[2];
1050 r[6] += B[3][0] * z[0] + B[3][1] * z[1] + B[3][2] * z[2];
1051 r[7] += B[4][0] * z[0] + B[4][1] * z[1] + B[4][2] * z[2];
1062 d0 = B[0][0] * V[0] + B[0][1] * V[1] + B[0][2] * V[3] -
C[6];
1063 d1 = B[0][0] * V[1] + B[0][1] * V[2] + B[0][2] * V[4] -
C[7];
1064 d2 = B[0][0] * V[3] + B[0][1] * V[4] + B[0][2] * V[5] -
C[8];
1069 C[9] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
1071 d0 = B[1][0] * V[0] + B[1][1] * V[1] + B[1][2] * V[3] -
C[10];
1072 d1 = B[1][0] * V[1] + B[1][1] * V[2] + B[1][2] * V[4] -
C[11];
1073 d2 = B[1][0] * V[3] + B[1][1] * V[4] + B[1][2] * V[5] -
C[12];
1078 C[13] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
1079 C[14] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
1081 d0 = B[2][0] * V[0] + B[2][1] * V[1] + B[2][2] * V[3] -
C[15];
1082 d1 = B[2][0] * V[1] + B[2][1] * V[2] + B[2][2] * V[4] -
C[16];
1083 d2 = B[2][0] * V[3] + B[2][1] * V[4] + B[2][2] * V[5] -
C[17];
1088 C[18] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
1089 C[19] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
1090 C[20] += d0 * B[2][0] + d1 * B[2][1] + d2 * B[2][2];
1092 d0 = B[3][0] * V[0] + B[3][1] * V[1] + B[3][2] * V[3] -
C[21];
1093 d1 = B[3][0] * V[1] + B[3][1] * V[2] + B[3][2] * V[4] -
C[22];
1094 d2 = B[3][0] * V[3] + B[3][1] * V[4] + B[3][2] * V[5] -
C[23];
1099 C[24] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
1100 C[25] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
1101 C[26] += d0 * B[2][0] + d1 * B[2][1] + d2 * B[2][2];
1102 C[27] += d0 * B[3][0] + d1 * B[3][1] + d2 * B[3][2];
1104 d0 = B[4][0] * V[0] + B[4][1] * V[1] + B[4][2] * V[3] -
C[28];
1105 d1 = B[4][0] * V[1] + B[4][1] * V[2] + B[4][2] * V[4] -
C[29];
1106 d2 = B[4][0] * V[3] + B[4][1] * V[4] + B[4][2] * V[5] -
C[30];
1111 C[31] += d0 * B[0][0] + d1 * B[0][1] + d2 * B[0][2];
1112 C[32] += d0 * B[1][0] + d1 * B[1][1] + d2 * B[1][2];
1113 C[33] += d0 * B[2][0] + d1 * B[2][1] + d2 * B[2][2];
1114 C[34] += d0 * B[3][0] + d1 * B[3][1] + d2 * B[3][2];
1115 C[35] += d0 * B[4][0] + d1 * B[4][1] + d2 * B[4][2];
1127 MF->GetFieldValue(r0, B);
1128 const Double_t
c_light =
Q * 0.000299792458;
1144 h[3] =
h[1] * B[2] -
h[2] * B[1];
1145 h[4] =
h[2] * B[0] -
h[0] * B[2];
1146 h[5] =
h[0] * B[1] -
h[1] * B[0];
1150 c =
C[28] +
h[0] *
C[35];
1151 C[0] +=
h[0] * (c +
C[28]);
1154 C[1] +=
h[1] *
C[28] +
h[0] *
C[29];
1155 c =
C[29] +
h[1] *
C[35];
1156 C[2] +=
h[1] * (c +
C[29]);
1159 C[3] +=
h[2] *
C[28] +
h[0] *
C[30];
1160 C[4] +=
h[2] *
C[29] +
h[1] *
C[30];
1161 c =
C[30] +
h[2] *
C[35];
1162 C[5] +=
h[2] * (c +
C[30]);
1165 C[6] +=
h[3] *
C[28] +
h[0] *
C[31];
1166 C[7] +=
h[3] *
C[29] +
h[1] *
C[31];
1167 C[8] +=
h[3] *
C[30] +
h[2] *
C[31];
1168 c =
C[31] +
h[3] *
C[35];
1169 C[9] +=
h[3] * (c +
C[31]);
1172 C[10] +=
h[4] *
C[28] +
h[0] *
C[32];
1173 C[11] +=
h[4] *
C[29] +
h[1] *
C[32];
1174 C[12] +=
h[4] *
C[30] +
h[2] *
C[32];
1175 C[13] +=
h[4] *
C[31] +
h[3] *
C[32];
1176 c =
C[32] +
h[4] *
C[35];
1177 C[14] +=
h[4] * (c +
C[32]);
1180 C[15] +=
h[5] *
C[28] +
h[0] *
C[33];
1181 C[16] +=
h[5] *
C[29] +
h[1] *
C[33];
1182 C[17] +=
h[5] *
C[30] +
h[2] *
C[33];
1183 C[18] +=
h[5] *
C[31] +
h[3] *
C[33];
1184 C[19] +=
h[5] *
C[32] +
h[4] *
C[33];
1185 c =
C[33] +
h[5] *
C[35];
1186 C[20] +=
h[5] * (c +
C[33]);
1189 C[21] +=
h[0] *
C[34];
1190 C[22] +=
h[1] *
C[34];
1191 C[23] +=
h[2] *
C[34];
1192 C[24] +=
h[3] *
C[34];
1193 C[25] +=
h[4] *
C[34];
1194 C[26] +=
h[5] *
C[34];
1198 if (r0 && r0 !=
r) {
1199 r0[0] += dS * r0[3];
1200 r0[1] += dS * r0[4];
1201 r0[2] += dS * r0[5];
1208 double C6 =
C[6] + dS *
C[9];
1209 double C11 =
C[11] + dS *
C[14];
1210 double C17 =
C[17] + dS *
C[20];
1211 double SC13 = dS *
C[13];
1212 double SC18 = dS *
C[18];
1213 double SC19 = dS *
C[19];
1215 C[0] += dS * (
C[6] + C6);
1216 C[2] += dS * (
C[11] + C11);
1217 C[5] += dS * (
C[17] + C17);
1223 C[1] += dS * (
C[10] +
C[7]);
1224 C[3] += dS * (
C[15] +
C[8]);
1225 C[4] += dS * (
C[16] +
C[12]);
1234 C[21] += dS *
C[24];
1235 C[22] += dS *
C[25];
1236 C[23] += dS *
C[26];
1237 C[28] += dS *
C[31];
1238 C[29] += dS *
C[32];
1239 C[30] += dS *
C[33];
1249 const Double_t
c_light = 0.000299792458;
1256 Double_t px =
r[3], py =
r[4], pz =
r[5];
1258 Double_t sx = 0, sy = 0, sz = 0, syy = 0, syz = 0, syyy = 0, Sx = 0, Sy = 0,
1259 Sz = 0, Syy = 0, Syz = 0, Syyy = 0;
1264 Double_t p0[3], p1[3], p2[3];
1272 p2[0] =
r[0] + px * dS;
1273 p2[1] =
r[1] + py * dS;
1274 p2[2] =
r[2] + pz * dS;
1276 p1[0] = 0.5 * (p0[0] + p2[0]);
1277 p1[1] = 0.5 * (p0[1] + p2[1]);
1278 p1[2] = 0.5 * (p0[2] + p2[2]);
1282 MF->GetFieldValue(p0, B[0]);
1283 MF->GetFieldValue(p1, B[1]);
1284 MF->GetFieldValue(p2, B[2]);
1286 Double_t Sy1 = (7 * B[0][1] + 6 * B[1][1] - B[2][1]) * c * dS * dS / 96.;
1287 Double_t Sy2 = (B[0][1] + 2 * B[1][1]) * c * dS * dS / 6.;
1295 MF->GetFieldValue(p0, B[0]);
1296 MF->GetFieldValue(p1, B[1]);
1297 MF->GetFieldValue(p2, B[2]);
1299 sx = c * (B[0][0] + 4 * B[1][0] + B[2][0]) * dS / 6.;
1300 sy = c * (B[0][1] + 4 * B[1][1] + B[2][1]) * dS / 6.;
1301 sz = c * (B[0][2] + 4 * B[1][2] + B[2][2]) * dS / 6.;
1303 Sx = c * (B[0][0] + 2 * B[1][0]) * dS * dS / 6.;
1304 Sy = c * (B[0][1] + 2 * B[1][1]) * dS * dS / 6.;
1305 Sz = c * (B[0][2] + 2 * B[1][2]) * dS * dS / 6.;
1307 Double_t c2[3][3] = {{5, -4, -1}, {44, 80, -4}, {11, 44, 5}};
1308 Double_t C2[3][3] = {{38, 8, -4}, {148, 208, -20}, {3, 36, 3}};
1309 for (Int_t n = 0; n < 3; n++)
1310 for (Int_t
m = 0;
m < 3;
m++) {
1311 syz += c2[n][
m] * B[n][1] * B[
m][2];
1312 Syz += C2[n][
m] * B[n][1] * B[
m][2];
1315 syz *= c * c * dS * dS / 360.;
1316 Syz *= c * c * dS * dS * dS / 2520.;
1318 syy = c * (B[0][1] + 4 * B[1][1] + B[2][1]) * dS;
1319 syyy = syy * syy * syy / 1296;
1320 syy = syy * syy / 72;
1322 Syy = (B[0][1] * (38 * B[0][1] + 156 * B[1][1] - B[2][1])
1323 + B[1][1] * (208 * B[1][1] + 16 * B[2][1]) + B[2][1] * (3 * B[2][1]))
1324 * dS * dS * dS * c * c / 2520.;
1326 * (B[0][1] * (85 * B[0][1] + 526 * B[1][1] - 7 * B[2][1])
1327 + B[1][1] * (1376 * B[1][1] + 84 * B[2][1])
1328 + B[2][1] * (19 * B[2][1]))
1330 * (B[1][1] * (1376 * B[1][1] + 256 * B[2][1])
1331 + B[2][1] * (62 * B[2][1]))
1332 + B[2][1] * B[2][1] * (3 * B[2][1]))
1333 * dS * dS * dS * dS * c * c * c / 90720.;
1337 for (
int i = 0;
i < 8;
i++)
1338 for (
int j = 0; j < 8; j++)
1346 J[0][5] = Syyy - Sy;
1356 J[2][3] = Sy - Syyy;
1365 J[3][5] = syyy - sy;
1375 J[5][3] = sy - syyy;
1378 J[6][6] = J[7][7] = 1;
1380 r[0] += J[0][3] * px + J[0][4] * py + J[0][5] * pz;
1381 r[1] += J[1][3] * px + J[1][4] * py + J[1][5] * pz;
1382 r[2] += J[2][3] * px + J[2][4] * py + J[2][5] * pz;
1383 r[3] = J[3][3] * px + J[3][4] * py + J[3][5] * pz;
1384 r[4] = J[4][3] * px + J[4][4] * py + J[4][5] * pz;
1385 r[5] = J[5][3] * px + J[5][4] * py + J[5][5] * pz;
1387 if (r0 && r0 !=
r) {
1392 r0[0] += J[0][3] * px + J[0][4] * py + J[0][5] * pz;
1393 r0[1] += J[1][3] * px + J[1][4] * py + J[1][5] * pz;
1394 r0[2] += J[2][3] * px + J[2][4] * py + J[2][5] * pz;
1395 r0[3] = J[3][3] * px + J[3][4] * py + J[3][5] * pz;
1396 r0[4] = J[4][3] * px + J[4][4] * py + J[4][5] * pz;
1397 r0[5] = J[5][3] * px + J[5][4] * py + J[5][5] * pz;
1407 for (
int i = 0;
i < 8;
i++)
1417 for (
int i = 0;
i < 8;
i++)
1432 Double_t px =
r[3], py =
r[4], pz =
r[5];
1433 Double_t p =
sqrt(px * px + py * py + pz * pz);
1434 Double_t pzi = 1 / pz;
1435 Double_t qp = 1 / p;
1437 if (
Q != 0) qp =
Q * qp;
1446 Double_t qp3 = qp * qp * qp;
1447 Double_t pzi2 = pzi * pzi;
1449 Double_t cXpz =
C[15] - T[2] *
C[17];
1450 Double_t cYpz =
C[16] - T[3] *
C[17];
1451 Double_t cqpx = -qp3 * (px *
C[9] + py *
C[13] + pz *
C[18]);
1452 Double_t cqpy = -qp3 * (px *
C[13] + py *
C[14] + pz *
C[19]);
1453 Double_t cqpz = -qp3 * (px *
C[18] + py *
C[19] + pz *
C[20]);
1455 Cov[0] =
C[0] + T[2] * (-2 *
C[3] + T[2] *
C[5]);
1456 Cov[1] =
C[1] - T[2] *
C[4] + T[3] * (-
C[3] + T[2] *
C[5]);
1457 Cov[2] =
C[2] + T[3] * (-2 *
C[4] + T[3] *
C[5]);
1458 Cov[3] = pzi * (
C[6] - T[2] * (
C[8] + cXpz));
1459 Cov[4] = pzi * (
C[7] - T[3] *
C[8] - T[2] * cYpz);
1460 Cov[5] = pzi2 * (
C[9] + T[2] * (-2 *
C[18] + T[2] *
C[20]));
1461 Cov[6] = pzi * (
C[10] - T[2] *
C[12] - T[3] * cXpz);
1462 Cov[7] = pzi * (
C[11] - T[3] * (
C[12] + cYpz));
1463 Cov[8] = pzi2 * (
C[13] - T[2] *
C[19] - T[3] *
C[18] + T[2] * T[3] *
C[20]);
1464 Cov[9] = pzi2 * (
C[14] + T[3] * (-2 *
C[19] + T[3] *
C[20]));
1465 Cov[10] = -qp3 * (px *
C[6] + py *
C[10] + pz *
C[15]) - T[2] * cqpz;
1466 Cov[11] = -qp3 * (px *
C[7] + py *
C[11] + pz *
C[16]) - T[3] * cqpz;
1467 Cov[12] = pzi * (cqpx - T[2] * cqpz);
1468 Cov[13] = pzi * (cqpy - T[3] * cqpz);
1469 Cov[14] = -qp3 * (px * cqpx + py * cqpy + pz * cqpz);
1476 for (
int i = 0;
i < 6;
i++)
1486 Double_t x2 =
x *
x;
1487 Double_t y2 =
y *
y;
1488 Double_t
z2 = z * z;
1489 Double_t p2 = x2 + y2 +
z2;
1491 Error_ =
sqrt((x2 *
C[9] + y2 *
C[14] +
z2 *
C[20]
1492 + 2 * (
x *
y *
C[13] +
x * z *
C[18] +
y * z *
C[19]))
1500 (
r[3] *
r[3] *
C[9] +
r[4] *
r[4] *
C[14] +
r[5] *
r[5] *
C[20]
1501 +
r[6] *
r[6] *
C[27]
1503 * (+
r[3] *
r[4] *
C[13] +
r[5] * (
r[3] *
C[18] +
r[4] *
C[19])
1504 -
r[6] * (
r[3] *
C[24] +
r[4] *
C[25] +
r[5] *
C[26])));
1505 Double_t m2 =
r[6] *
r[6] -
r[3] *
r[3] -
r[4] *
r[4] -
r[5] *
r[5];
1506 M = (m2 > 1.e-20) ?
sqrt(m2) : 0.;
1507 Error_ = (S >= 0 && m2 > 1.e-20) ?
sqrt(S / m2) : 1.e4;
1516 Double_t x2 =
x *
x;
1517 Double_t y2 =
y *
y;
1518 Double_t
z2 = z * z;
1519 Double_t p2 = x2 + y2 +
z2;
1521 Error_ =
sqrt(p2 *
C[35]
1523 * (x2 *
C[9] + y2 *
C[14] +
z2 *
C[20]
1524 + 2 * (
x *
y *
C[13] +
x * z *
C[18] +
y * z *
C[19]))
1525 + 2 * t * (
x *
C[31] +
y *
C[32] + z *
C[33]));
1531 Double_t cTM = (-
r[3] *
C[31] -
r[4] *
C[32] -
r[5] *
C[33] +
r[6] *
C[34]);
1533 Error_ =
sqrt(
m *
m *
C[35] + 2 *
r[7] * cTM +
r[7] *
r[7] * dm * dm);
1537 return 0.5 * TMath::Log((
r[6] +
r[5]) / (
r[6] -
r[5]));
1540 return TMath::Sqrt(
r[3] *
r[3] +
r[4] *
r[4]);
1548 Double_t dx = xyz[0] -
r[0];
1549 Double_t dy = xyz[1] -
r[1];
1550 Double_t dz = xyz[2] -
r[2];
1551 Double_t p2 =
r[3] *
r[3] +
r[4] *
r[4] +
r[5] *
r[5];
1553 if (
Q == 0 &&
r[2] < xyz[2])
return sqrt((dx * dx + dy * dy + dz * dz) / p2);
1554 if (
Q == 0 &&
r[2] >= xyz[2])
1555 return -
sqrt((dx * dx + dy * dy + dz * dz) / p2);
1557 const Double_t kCLight = 0.000299792458;
1560 MF->GetFieldValue(
r, B);
1562 Double_t bq1 = B[0] *
Q * kCLight;
1563 Double_t bq2 = B[1] *
Q * kCLight;
1564 Double_t bq3 = B[2] *
Q * kCLight;
1565 Double_t a = dx *
r[3] + dy *
r[4] + dz *
r[5];
1566 Double_t B2 = B[0] * B[0] + B[1] * B[1] + B[2] * B[2];
1567 Double_t bq =
Q * kCLight *
sqrt(B2);
1568 Double_t pB =
r[3] * B[0] +
r[4] * B[1] +
r[5] * B[2];
1569 Double_t rB = dx * B[0] + dy * B[1] + dz * B[2];
1570 Double_t pt2 = p2 - pB * pB / B2;
1571 a = a - pB * rB / B2;
1575 if (pt2 < 1.e-4)
return 0;
1577 if (TMath::Abs(bq) < 1.e-8)
1580 dS = TMath::ATan2(bq * a,
1581 pt2 + bq1 * (dz *
r[4] - dy *
r[5])
1582 - bq2 * (dz *
r[3] - dx *
r[5])
1583 + bq3 * (dy *
r[3] - dx *
r[4]))