367 FairField* MagneticField
371 const Double_t c_light = 0.000299792458;
373 Double_t
x = T[0],
y = T[1], tx = T[2], ty = T[3], qp0 = T[4], z = T[5],
379 txtx = tx * tx, tyty = ty * ty, txty = tx * ty;
381 Double_t Ax = txty, Ay = -txtx - 1, Az = ty, Ayy = tx * (txtx * 3 + 3), Ayz = -2 * txty, Azy = Ayz,
382 Ayyy = -(15 * txtx * txtx + 18 * txtx + 3),
384 Bx = tyty + 1, By = -txty, Bz = -tx, Byy = ty * (txtx * 3 + 1), Byz = 2 * txtx + 1, Bzy = txtx - tyty,
385 Byyy = -txty * (txtx * 15 + 9);
387 Double_t t = c_light *
sqrt(1. + txtx + tyty),
h = t * qp0;
391 Double_t Sx = 0, Sy = 0, Sz = 0, Syy = 0, Syz = 0, Szy = 0, Syyy = 0;
394 Double_t sx = 0, sy = 0, sz = 0, syy = 0, syz = 0, szy = 0, syyy = 0;
396 Double_t r[3] = {
x,
y, z};
399 Int_t n = int(fabs(vz - z) / 5.);
403 Double_t dz = (vz - z) / n;
406 MagneticField->GetFieldValue(r, B[0]);
410 MagneticField->GetFieldValue(r, B[1]);
414 MagneticField->GetFieldValue(r, B[2]);
416 sx = (B[0][0] + 4 * B[1][0] + B[2][0]) * dz * 2 / 6.;
417 sy = (B[0][1] + 4 * B[1][1] + B[2][1]) * dz * 2 / 6.;
418 sz = (B[0][2] + 4 * B[1][2] + B[2][2]) * dz * 2 / 6.;
420 Sx = (B[0][0] + 2 * B[1][0]) * dz * dz * 4 / 6.;
421 Sy = (B[0][1] + 2 * B[1][1]) * dz * dz * 4 / 6.;
422 Sz = (B[0][2] + 2 * B[1][2]) * dz * dz * 4 / 6.;
424 Double_t c2[3][3] = {{5, -4, -1}, {44, 80, -4}, {11, 44, 5}};
425 Double_t C2[3][3] = {{38, 8, -4}, {148, 208, -20}, {3, 36, 3}};
426 for (Int_t k = 0; k < 3; k++) {
427 for (Int_t m = 0; m < 3; m++) {
428 syz += c2[k][m] * B[k][1] * B[m][2];
429 Syz += C2[k][m] * B[k][1] * B[m][2];
430 szy += c2[k][m] * B[k][2] * B[m][1];
431 Szy += C2[k][m] * B[k][2] * B[m][1];
435 syz *= dz * dz * 4 / 360.;
436 Syz *= dz * dz * dz * 8 / 2520.;
438 szy *= dz * dz * 4 / 360.;
439 Szy *= dz * dz * dz * 8 / 2520.;
441 syy = (B[0][1] + 4 * B[1][1] + B[2][1]) * dz * 2;
442 syyy = syy * syy * syy / 1296;
443 syy = syy * syy / 72;
445 Syy = (B[0][1] * (38 * B[0][1] + 156 * B[1][1] - B[2][1]) + B[1][1] * (208 * B[1][1] + 16 * B[2][1])
446 + B[2][1] * (3 * B[2][1]))
447 * dz * dz * dz * 8 / 2520.;
449 * (B[0][1] * (85 * B[0][1] + 526 * B[1][1] - 7 * B[2][1]) + B[1][1] * (1376 * B[1][1] + 84 * B[2][1])
450 + B[2][1] * (19 * B[2][1]))
451 + B[1][1] * (B[1][1] * (1376 * B[1][1] + 256 * B[2][1]) + B[2][1] * (62 * B[2][1]))
452 + B[2][1] * B[2][1] * (3 * B[2][1]))
453 * dz * dz * dz * dz * 16 / 90720.;
455 x += tx * 2 * dz +
h * (Sx * Ax + Sy * Ay + Sz * Az) +
h *
h * (Syy * Ayy + Syz * Ayz + Szy * Azy)
456 +
h *
h *
h * Syyy * Ayyy;
457 y += ty * 2 * dz +
h * (Sx * Bx + Sy * By + Sz * Bz) +
h *
h * (Syy * Byy + Syz * Byz + Szy * Bzy)
458 +
h *
h *
h * Syyy * Byyy;
459 tx +=
h * (sx * Ax + sy * Ay + sz * Az) +
h *
h * (syy * Ayy + syz * Ayz + szy * Azy) +
h *
h *
h * syyy * Ayyy;
460 ty +=
h * (sx * Bx + sy * By + sz * Bz) +
h *
h * (syy * Byy + syz * Byz + szy * Bzy) +
h *
h *
h * syyy * Byyy;
469 Ayy = tx * (txtx * 3 + 3);
472 Ayyy = -(15 * txtx * txtx + 18 * txtx + 3);
477 Byy = ty * (txtx * 3 + 1);
480 Byyy = -txty * (txtx * 15 + 9);
482 t = c_light *
sqrt(1. + txtx + tyty);
486 for (Int_t i = 2; i < n; i++) {
488 Double_t B0[3] = {B[0][0], B[0][1], B[0][2]};
500 B[2][0] = B0[0] - 3 * B[0][0] + 3 * B[1][0];
501 B[2][1] = B0[1] - 3 * B[0][1] + 3 * B[1][1];
502 B[2][2] = B0[2] - 3 * B[0][2] + 3 * B[1][2];
504 Double_t Sx_, Sy_, Sz_, Syy_, Syz_, Szy_, Syyy_;
506 Sx_ = (-B[0][0] + 10 * B[1][0] + 3 * B[2][0]) * dz * dz * 4 / 96.;
507 Sy_ = (-B[0][1] + 10 * B[1][1] + 3 * B[2][1]) * dz * dz * 4 / 96.;
508 Sz_ = (-B[0][2] + 10 * B[1][2] + 3 * B[2][2]) * dz * dz * 4 / 96.;
512 Double_t c2[3][3] = {{5, -52, -13}, {-28, 320, 68}, {-37, 332, 125}};
513 Double_t C2[3][3] = {{13, -152, -29}, {-82, 1088, 170}, {-57, 576, 153}};
515 for (Int_t k = 0; k < 3; k++) {
516 for (Int_t m = 0; m < 3; m++) {
517 Syz_ += C2[k][m] * B[k][1] * B[m][2];
518 Szy_ += C2[k][m] * B[k][2] * B[m][1];
522 Syz_ *= dz * dz * dz * 8 / 80640.;
523 Szy_ *= dz * dz * dz * 8 / 80640.;
525 Syy_ = (B[0][1] * (13 * B[0][1] - 234 * B[1][1] - 86 * B[2][1]) + B[1][1] * (1088 * B[1][1] + 746 * B[2][1])
526 + B[2][1] * (153 * B[2][1]))
527 * dz * dz * dz * 8 / 80640.;
530 * (B[0][1] * (-43 * B[0][1] + 1118 * B[1][1] + 451 * B[2][1])
531 + B[1][1] * (-9824 * B[1][1] - 7644 * B[2][1]) + B[2][1] * (-1669 * B[2][1]))
532 + B[1][1] * (B[1][1] * (29344 * B[1][1] + 32672 * B[2][1]) + B[2][1] * (13918 * B[2][1]))
533 + B[2][1] * B[2][1] * (2157 * B[2][1]))
534 * dz * dz * dz * dz * 16 / 23224320.;
537 r[0] =
x + tx * dz +
h * (Sx_ * Ax + Sy_ * Ay + Sz_ * Az) +
h *
h * (Syy_ * Ayy + Syz_ * Ayz + Szy_ * Azy)
538 +
h *
h *
h * Syyy_ * Ayyy;
539 r[1] =
y + ty * dz +
h * (Sx_ * Bx + Sy_ * By + Sz_ * Bz) +
h *
h * (Syy_ * Byy + Syz_ * Byz + Szy_ * Bzy)
540 +
h *
h *
h * Syyy_ * Byyy;
561 MagneticField->GetFieldValue(r, B[2]);
563 Double_t sx_, sy_, sz_, syy_, syz_, szy_, syyy_;
565 sx_ = (-B[0][0] + 8 * B[1][0] + 5 * B[2][0]) * dz * 2 / 24.;
566 sy_ = (-B[0][1] + 8 * B[1][1] + 5 * B[2][1]) * dz * 2 / 24.;
567 sz_ = (-B[0][2] + 8 * B[1][2] + 5 * B[2][2]) * dz * 2 / 24.;
569 Sx_ = (-B[0][0] + 10 * B[1][0] + 3 * B[2][0]) * dz * dz * 4 / 96.;
570 Sy_ = (-B[0][1] + 10 * B[1][1] + 3 * B[2][1]) * dz * dz * 4 / 96.;
571 Sz_ = (-B[0][2] + 10 * B[1][2] + 3 * B[2][2]) * dz * dz * 4 / 96.;
573 syz_ = Syz_ = szy_ = Szy_ = 0;
575 for (Int_t k = 0; k < 3; k++) {
576 for (Int_t m = 0; m < 3; m++) {
577 syz_ += c2[k][m] * B[k][1] * B[m][2];
578 Syz_ += C2[k][m] * B[k][1] * B[m][2];
579 szy_ += c2[k][m] * B[k][2] * B[m][1];
580 Szy_ += C2[k][m] * B[k][2] * B[m][1];
584 syz_ *= dz * dz * 4 / 5760.;
585 Syz_ *= dz * dz * dz * 8 / 80640.;
587 szy_ *= dz * dz * 4 / 5760.;
588 Szy_ *= dz * dz * dz * 8 / 80640.;
590 syy_ = (B[0][1] - 8 * B[1][1] - 5 * B[2][1]) * dz * 2;
591 syyy_ = -syy_ * syy_ * syy_ / 82944;
592 syy_ = syy_ * syy_ / 1152;
594 Syy_ = (B[0][1] * (13 * B[0][1] - 234 * B[1][1] - 86 * B[2][1]) + B[1][1] * (1088 * B[1][1] + 746 * B[2][1])
595 + B[2][1] * (153 * B[2][1]))
596 * dz * dz * dz * 8 / 80640.;
599 * (B[0][1] * (-43 * B[0][1] + 1118 * B[1][1] + 451 * B[2][1])
600 + B[1][1] * (-9824 * B[1][1] - 7644 * B[2][1]) + B[2][1] * (-1669 * B[2][1]))
601 + B[1][1] * (B[1][1] * (29344 * B[1][1] + 32672 * B[2][1]) + B[2][1] * (13918 * B[2][1]))
602 + B[2][1] * B[2][1] * (2157 * B[2][1]))
603 * dz * dz * dz * dz * 16 / 23224320.;
605 x += tx * dz +
h * (Sx_ * Ax + Sy_ * Ay + Sz_ * Az) +
h *
h * (Syy_ * Ayy + Syz_ * Ayz + Szy_ * Azy)
606 +
h *
h *
h * Syyy_ * Ayyy;
607 y += ty * dz +
h * (Sx_ * Bx + Sy_ * By + Sz_ * Bz) +
h *
h * (Syy_ * Byy + Syz_ * Byz + Szy_ * Bzy)
608 +
h *
h *
h * Syyy_ * Byyy;
609 tx +=
h * (sx_ * Ax + sy_ * Ay + sz_ * Az) +
h *
h * (syy_ * Ayy + syz_ * Ayz + szy_ * Azy)
610 +
h *
h *
h * syyy_ * Ayyy;
611 ty +=
h * (sx_ * Bx + sy_ * By + sz_ * Bz) +
h *
h * (syy_ * Byy + syz_ * Byz + szy_ * Bzy)
612 +
h *
h *
h * syyy_ * Byyy;
621 Ayy = tx * (txtx * 3 + 3);
624 Ayyy = -(15 * txtx * txtx + 18 * txtx + 3);
629 Byy = ty * (txtx * 3 + 1);
632 Byyy = -txty * (txtx * 15 + 9);
634 t = c_light *
sqrt(1. + txtx + tyty);
638 Syyy += dz * syyy + Sy_ * syy + Syy_ * sy + Syyy_;
639 Syy += dz * syy + sy * Sy_ + Syy_;
640 Syz += dz * syz + sz * Sy_ + Syz_;
641 Szy += dz * szy + sy * Sz_ + Szy_;
646 syyy += sy_ * syy + syy_ * sy + syyy_;
647 syy += sy * sy_ + syy_;
648 syz += sz * sy_ + syz_;
649 szy += sz * sz_ + szy_;
669 Ayy = tx * (txtx * 3 + 3);
672 Ayyy = -(15 * txtx * txtx + 18 * txtx + 3);
677 Byy = ty * (txtx * 3 + 1);
680 Byyy = -txty * (txtx * 15 + 9);
682 t = c_light *
sqrt(1. + txtx + tyty);
687 c = (
x - vx) + tx * (vz - z),
688 b = t * (Sx * Ax + Sy * Ay + Sz * Az), a = t * t * (Syy * Ayy + Syz * Ayz + Szy * Azy),
689 d = t * t * t * (Syyy * Ayyy);
691 Double_t C = d * qp0 * qp0 * qp0 + a * qp0 * qp0 + b * qp0 + c, B = 3 * d * qp0 * qp0 + 2 * a * qp0 + b,
694 Double_t D = B * B - 4 * A * C;
700 Double_t dqp1 = (-B + D) / 2 / A;
701 Double_t dqp2 = (-B - D) / 2 / A;
702 Double_t dqp = (fabs(dqp1) < fabs(dqp2)) ? dqp1 : dqp2;