30 static Double_t gTempD[100];
44 Double_t qp0 = (QP0) ? *QP0 :
GetTrack()[4];
46 Bool_t downstream_direction = (z_out > z_in);
48 if (downstream_direction) {
56 vector<CbmKFMaterial*>::iterator
i, ibeg, iend;
62 && (*iend)->ZReference - (*iend)->ZThickness / 2 < Z)
64 if (downstream_direction) {
73 for (
i = ibeg;
i != iend; downstream_direction ? ++
i : --
i) {
74 Double_t zthick = (*i)->ZThickness, zcross = (*i)->ZReference;
79 (downstream_direction) ? zcross - zthick / 2. : zcross + zthick / 2.;
80 double d = (downstream_direction) ? 1 : -1;
81 double dz = 1.E-1 * (*i)->RadLength;
83 while (z_ + dz < zthick) {
86 z0 +
d * (z_ + dz / 2.), dz, *
this, downstream_direction, qp0);
92 z0 +
d * (z_ + dz / 2.), dz, *
this, downstream_direction, qp0);
108 if (NHits == 0)
return 1;
115 const Double_t INF = 10000.;
142 err =
h->Filter(*
this, downstream, qp0);
143 Int_t istold =
h->MaterialIndex;
144 for (Int_t
i = 1;
i < NHits;
i++) {
146 Int_t ist =
h->MaterialIndex;
147 for (Int_t j = istold + 1; j < ist; j++)
148 err = err || KF->
vMaterial[j]->Pass(*
this, downstream, qp0);
149 err = err ||
h->Filter(*
this, downstream, qp0);
154 err =
h->Filter(*
this, downstream, qp0);
155 Int_t istold =
h->MaterialIndex;
156 for (Int_t
i = NHits - 2;
i >= 0;
i--) {
158 Int_t ist =
h->MaterialIndex;
159 for (Int_t j = istold - 1; j > ist; j--)
160 err = err || KF->
vMaterial[j]->Pass(*
this, downstream, qp0);
161 err = err ||
h->Filter(*
this, downstream, qp0);
187 T[0] = T[1] = T[2] = T[3] = T[4] = T[5] = 0;
208 T[0] = T[1] = T[2] = T[3] = T[4] = T[5] = 0;
221 if (NHits == 0)
return;
228 const Double_t INF = 100.;
254 if (KF->
vMaterial[
h->MaterialIndex]->ZReference <= Z) {
255 h->Filter(*
this, 1, qp0);
256 Int_t istold =
h->MaterialIndex;
257 for (Int_t
i = 1;
i < NHits;
i++) {
259 Int_t ist =
h->MaterialIndex;
260 Int_t j = istold + 1;
261 for (; j < ist; j++) {
262 if (KF->
vMaterial[j]->ZReference > Z)
break;
265 if (j < ist || KF->vMaterial[
h->MaterialIndex]->ZReference > Z)
break;
266 h->Filter(*
this, 1, qp0);
273 double Ts[6], Cs[15];
274 for (
int k = 0; k < 6; k++)
276 for (
int k = 0; k < 15; k++)
296 if (KF->
vMaterial[
h->MaterialIndex]->ZReference > Z) {
297 h->Filter(*
this, 0, qp0);
298 Int_t istold =
h->MaterialIndex;
299 for (Int_t
i = NHits - 2;
i >= 0;
i--) {
301 Int_t ist =
h->MaterialIndex;
302 Int_t j = istold - 1;
303 for (; j > ist; j--) {
304 if (KF->
vMaterial[j]->ZReference <= Z)
break;
307 if (j > ist || KF->
vMaterial[
h->MaterialIndex]->ZReference <= Z)
break;
308 h->Filter(*
this, 0, qp0);
318 for (
int k = 0; k < 15; k++)
324 for (
int k = 0; k < 5; k++)
326 for (
int k = 0; k < 5; k++)
327 for (
int l = 0; l < 5; l++)
328 T[k] -= K[k * 5 + l] * r[l];
332 for (
int l = 0; l < 5; l++)
334 for (
int l = 0; l < 5; ++l)
335 for (
int j = 0; j <= l; ++j) {
338 for (
int k = 0; k < 5; ++k)
341 for (
int l = 0; l < 15; l++)
363 Double_t a = T[2], b = T[3];
368 Double_t zeta[2] = {
x - T[0],
y - T[1]};
370 Double_t CHt[5][2] = {
371 {C[0], C[1]}, {C[1], C[2]}, {C[3], C[4]}, {C[6], C[7]}, {C[10], C[11]}};
373 for (Int_t iter = 0; iter < MaxIter; iter++) {
375 Double_t Cv0 = Cv[0] - a * (2 * Cv[3] - a * Cv[5]);
376 Double_t Cv1 = Cv[1] - b * Cv[3] - a * (Cv[4] - b * Cv[5]);
377 Double_t Cv2 = Cv[2] - b * (2 * Cv[4] - b * Cv[5]);
379 Double_t S[3] = {C[0] + Cv0, C[1] + Cv1, C[2] + Cv2};
383 Double_t s = S[0] * S[2] - S[1] * S[1];
384 if (s < 1.E-20)
return;
396 if (iter < MaxIter - 1) {
398 for (Int_t
i = 2;
i < 4; ++
i) {
399 K[
i][0] = CHt[
i][0] * S[0] + CHt[
i][1] * S[1];
400 K[
i][1] = CHt[
i][0] * S[1] + CHt[
i][1] * S[2];
405 a = T[2] + K[2][0] * zeta[0] + K[2][1] * zeta[1];
406 b = T[3] + K[3][0] * zeta[0] + K[3][1] * zeta[1];
411 for (Int_t
i = 0;
i < 5; ++
i) {
412 K[
i][0] = CHt[
i][0] * S[0] + CHt[
i][1] * S[1];
413 K[
i][1] = CHt[
i][0] * S[1] + CHt[
i][1] * S[2];
420 T[2] += K[2][0] * zeta[0] + K[2][1] * zeta[1];
421 T[3] += K[3][0] * zeta[0] + K[3][1] * zeta[1];
422 T[4] += K[4][0] * zeta[0] + K[4][1] * zeta[1];
426 GetRefChi2() += zeta[0] * zeta[0] * S[0] + 2 * zeta[0] * zeta[1] * S[1]
427 + zeta[1] * zeta[1] * S[2];
431 C[0] -= K[0][0] * CHt[0][0] + K[0][1] * CHt[0][1];
432 C[1] -= K[1][0] * CHt[0][0] + K[1][1] * CHt[0][1];
433 C[2] -= K[1][0] * CHt[1][0] + K[1][1] * CHt[1][1];
434 C[3] -= K[2][0] * CHt[0][0] + K[2][1] * CHt[0][1];
435 C[4] -= K[2][0] * CHt[1][0] + K[2][1] * CHt[1][1];
436 C[5] -= K[2][0] * CHt[2][0] + K[2][1] * CHt[2][1];
437 C[6] -= K[3][0] * CHt[0][0] + K[3][1] * CHt[0][1];
438 C[7] -= K[3][0] * CHt[1][0] + K[3][1] * CHt[1][1];
439 C[8] -= K[3][0] * CHt[2][0] + K[3][1] * CHt[2][1];
440 C[9] -= K[3][0] * CHt[3][0] + K[3][1] * CHt[3][1];
441 C[10] -= K[4][0] * CHt[0][0] + K[4][1] * CHt[0][1];
442 C[11] -= K[4][0] * CHt[1][0] + K[4][1] * CHt[1][1];
443 C[12] -= K[4][0] * CHt[2][0] + K[4][1] * CHt[2][1];
444 C[13] -= K[4][0] * CHt[3][0] + K[4][1] * CHt[3][1];
445 C[14] -= K[4][0] * CHt[4][0] + K[4][1] * CHt[4][1];