27 using namespace Acts::UnitLiterals;
30 template <
typename bfield_t>
35 using BoundState = std::tuple<BoundParameters, Jacobian, double>;
55 template <
typename Parameters>
56 State(std::reference_wrapper<const GeometryContext>
gctx,
57 std::reference_wrapper<const MagneticFieldContext> mctx,
70 stepSize(ndir * std::
abs(ssize)),
71 tolerance(stolerance),
79 const auto Vp = pars.parameters();
81 double Sf, Cf, Ce, Se;
90 pVector[3] = pars.time();
97 if (
std::abs(pVector[7]) < .000000000000001) {
98 pVector[7] < 0. ? pVector[7] = -.000000000000001
99 : pVector[7] = .000000000000001;
103 if (pars.covariance()) {
109 const auto transform = pars.referenceSurface().referenceFrame(
142 pVector[28] = -Sf * Se;
143 pVector[36] = Cf * Ce;
149 pVector[29] = Cf * Se;
150 pVector[37] = Sf * Ce;
174 const auto&
surface = pars.referenceSurface();
177 double lCf = cos(Vp[1]);
178 double lSf = sin(Vp[1]);
181 double d0 = lCf * Ax[0] + lSf * Ay[0];
182 double d1 = lCf * Ax[1] + lSf * Ay[1];
183 double d2 = lCf * Ax[2] + lSf * Ay[2];
187 pVector[16] = Vp[0] * (lCf * Ay[0] - lSf * Ax[0]);
188 pVector[17] = Vp[0] * (lCf * Ay[1] - lSf * Ax[1]);
189 pVector[18] = Vp[0] * (lCf * Ay[2] - lSf * Ax[2]);
204 double PC = pVector[4] * C[0] + pVector[5] * C[1] + pVector[6] * C[2];
207 double Bx2 = -A[2] * pVector[29];
208 double Bx3 = A[1] * pVector[38] - A[2] * pVector[37];
210 double By2 = A[2] * pVector[28];
211 double By3 = A[2] * pVector[36] - A[0] * pVector[38];
213 double Bz2 = A[0] * pVector[29] - A[1] * pVector[28];
214 double Bz3 = A[0] * pVector[37] - A[1] * pVector[36];
216 double B2 = B[0] * Bx2 + B[1] * By2 + B[2] * Bz2;
217 double B3 = B[0] * Bx3 + B[1] * By3 + B[2] * Bz3;
219 Bx2 = (Bx2 - B[0] * B2) * Bn;
220 Bx3 = (Bx3 - B[0] * B3) * Bn;
221 By2 = (By2 - B[1] * B2) * Bn;
222 By3 = (By3 - B[1] * B3) * Bn;
223 Bz2 = (Bz2 - B[2] * B2) * Bn;
224 Bz3 = (Bz3 - B[2] * B3) * Bn;
227 pVector[24] = Bx2 * Vp[0];
228 pVector[32] = Bx3 * Vp[0];
229 pVector[25] = By2 * Vp[0];
230 pVector[33] = By3 * Vp[0];
231 pVector[26] = Bz2 * Vp[0];
232 pVector[34] = Bz3 * Vp[0];
240 bool state_ready =
false;
269 bool covTransport =
false;
273 double pathAccumulated = 0.;
279 double previousStepSize = 0.;
294 std::string debugString =
"";
296 size_t debugPfxWidth = 30;
297 size_t debugMsgWidth = 50;
311 state.field = m_bField.getField(pos, state.fieldCache);
316 return Vector3D(state.pVector[0], state.pVector[1], state.pVector[2]);
320 return Vector3D(state.pVector[4], state.pVector[5], state.pVector[6]);
324 return 1. /
std::abs(state.pVector[7]);
329 return state.pVector[7] > 0. ? 1. : -1.;
338 double time(
const State& state)
const {
return state.pVector[3]; }
352 return detail::updateSingleSurfaceStatus<AtlasStepper>(*
this, state,
364 template <
typename object_
intersection_t>
365 void updateStepSize(
State& state,
const object_intersection_t& oIntersection,
366 bool release =
true)
const {
367 detail::updateSingleStepSize<AtlasStepper>(state, oIntersection, release);
375 void setStepSize(
State& state,
double stepSize,
377 state.previousStepSize = state.stepSize;
378 state.stepSize.update(stepSize, stype,
true);
392 return state.stepSize.toString();
407 state.state_ready =
false;
410 Acts::Vector3D gp(state.pVector[0], state.pVector[1], state.pVector[2]);
415 std::unique_ptr<const Covariance> cov =
nullptr;
416 std::optional<Covariance> covOpt = std::nullopt;
417 if (state.covTransport) {
424 charge(state), state.pVector[3],
428 state.pathAccumulated);
442 state.state_ready =
false;
444 Acts::Vector3D gp(state.pVector[0], state.pVector[1], state.pVector[2]);
448 std::optional<Covariance> covOpt = std::nullopt;
449 if (state.covTransport) {
458 state.pathAccumulated);
467 if (state.state_ready) {
474 double Sf, Cf, Ce, Se;
480 state.pVector[0] =
pos(0);
481 state.pVector[1] =
pos(1);
482 state.pVector[2] =
pos(2);
483 state.pVector[3] = pars.
time();
484 state.pVector[4] = Cf * Se;
485 state.pVector[5] = Sf * Se;
486 state.pVector[6] = Ce;
487 state.pVector[7] = Vp[4];
490 if (
std::abs(state.pVector[7]) < .000000000000001) {
491 state.pVector[7] < 0. ? state.pVector[7] = -.000000000000001
492 : state.pVector[7] = .000000000000001;
500 state.covTransport =
true;
501 state.useJacobian =
true;
506 state.pVector[24] = 0.;
507 state.pVector[32] = 0.;
508 state.pVector[40] = 0.;
509 state.pVector[48] = 0.;
513 state.pVector[25] = 0.;
514 state.pVector[33] = 0.;
515 state.pVector[41] = 0.;
516 state.pVector[49] = 0.;
520 state.pVector[26] = 0.;
521 state.pVector[34] = 0.;
522 state.pVector[42] = 0.;
523 state.pVector[50] = 0.;
525 state.pVector[11] = 0.;
526 state.pVector[19] = 0.;
527 state.pVector[27] = 0.;
528 state.pVector[35] = 0.;
529 state.pVector[43] = 0.;
530 state.pVector[51] = 1.;
532 state.pVector[12] = 0.;
533 state.pVector[20] = 0.;
534 state.pVector[28] = -Sf * Se;
535 state.pVector[36] = Cf * Ce;
536 state.pVector[44] = 0.;
537 state.pVector[52] = 0.;
539 state.pVector[13] = 0.;
540 state.pVector[21] = 0.;
541 state.pVector[29] = Cf * Se;
542 state.pVector[37] = Sf * Ce;
543 state.pVector[45] = 0.;
544 state.pVector[53] = 0.;
546 state.pVector[14] = 0.;
547 state.pVector[22] = 0.;
548 state.pVector[30] = 0.;
549 state.pVector[38] = -Se;
550 state.pVector[46] = 0.;
551 state.pVector[54] = 0.;
553 state.pVector[15] = 0.;
554 state.pVector[23] = 0.;
555 state.pVector[31] = 0.;
556 state.pVector[39] = 0.;
557 state.pVector[47] = 1.;
558 state.pVector[55] = 0.;
560 state.pVector[56] = 0.;
561 state.pVector[57] = 0.;
562 state.pVector[58] = 0.;
563 state.pVector[59] = 0.;
569 double lCf = cos(Vp[1]);
570 double lSf = sin(Vp[1]);
573 double d0 = lCf * Ax[0] + lSf * Ay[0];
574 double d1 = lCf * Ax[1] + lSf * Ay[1];
575 double d2 = lCf * Ax[2] + lSf * Ay[2];
576 state.pVector[8] = d0;
577 state.pVector[9] =
d1;
578 state.pVector[10] =
d2;
579 state.pVector[16] = Vp[0] * (lCf * Ay[0] - lSf * Ax[0]);
580 state.pVector[17] = Vp[0] * (lCf * Ay[1] - lSf * Ax[1]);
581 state.pVector[18] = Vp[0] * (lCf * Ay[2] - lSf * Ax[2]);
596 double PC = state.pVector[4] * C[0] + state.pVector[5] * C[1] +
597 state.pVector[6] * C[2];
600 double Bx2 = -A[2] * state.pVector[29];
601 double Bx3 = A[1] * state.pVector[38] - A[2] * state.pVector[37];
603 double By2 = A[2] * state.pVector[28];
604 double By3 = A[2] * state.pVector[36] - A[0] * state.pVector[38];
606 double Bz2 = A[0] * state.pVector[29] - A[1] * state.pVector[28];
607 double Bz3 = A[0] * state.pVector[37] - A[1] * state.pVector[36];
609 double B2 = B[0] * Bx2 + B[1] * By2 + B[2] * Bz2;
610 double B3 = B[0] * Bx3 + B[1] * By3 + B[2] * Bz3;
612 Bx2 = (Bx2 - B[0] * B2) * Bn;
613 Bx3 = (Bx3 - B[0] * B3) * Bn;
614 By2 = (By2 - B[1] * B2) * Bn;
615 By3 = (By3 - B[1] * B3) * Bn;
616 Bz2 = (Bz2 - B[2] * B2) * Bn;
617 Bz3 = (Bz3 - B[2] * B3) * Bn;
620 state.pVector[24] = Bx2 * Vp[0];
621 state.pVector[32] = Bx3 * Vp[0];
622 state.pVector[25] = By2 * Vp[0];
623 state.pVector[33] = By3 * Vp[0];
624 state.pVector[26] = Bz2 * Vp[0];
625 state.pVector[34] = Bz3 * Vp[0];
629 state.state_ready =
true;
638 const Vector3D& udirection,
double up,
double time)
const {
640 state.pVector[0] = uposition[0];
641 state.pVector[1] = uposition[1];
642 state.pVector[2] = uposition[2];
643 state.pVector[3] =
time;
644 state.pVector[4] = udirection[0];
645 state.pVector[5] = udirection[1];
646 state.pVector[6] = udirection[2];
647 state.pVector[7] =
charge(state) / up;
659 for (
unsigned int i = 0; i < 60; ++i) {
660 P[i] = state.pVector[i];
663 double p = 1. / P[7];
671 double An = sqrt(P[4] * P[4] + P[5] * P[5]);
683 double Ay[3] = {-Ax[1] * P[6], Ax[0] * P[6], An};
684 double S[3] = {P[4], P[5], P[6]};
686 double A = P[4] * S[0] + P[5] * S[1] + P[6] * S[2];
694 double s0 = P[8] * S[0] + P[9] * S[1] + P[10] * S[2];
695 double s1 = P[16] * S[0] + P[17] * S[1] + P[18] * S[2];
696 double s2 = P[24] * S[0] + P[25] * S[1] + P[26] * S[2];
697 double s3 = P[32] * S[0] + P[33] * S[1] + P[34] * S[2];
698 double s4 = P[40] * S[0] + P[41] * S[1] + P[42] * S[2];
702 P[10] -= (s0 * P[6]);
703 P[11] -= (s0 * P[59]);
704 P[12] -= (s0 * P[56]);
705 P[13] -= (s0 * P[57]);
706 P[14] -= (s0 * P[58]);
707 P[16] -= (s1 * P[4]);
708 P[17] -= (s1 * P[5]);
709 P[18] -= (s1 * P[6]);
710 P[19] -= (s1 * P[59]);
711 P[20] -= (s1 * P[56]);
712 P[21] -= (s1 * P[57]);
713 P[22] -= (s1 * P[58]);
714 P[24] -= (s2 * P[4]);
715 P[25] -= (s2 * P[5]);
716 P[26] -= (s2 * P[6]);
717 P[27] -= (s2 * P[59]);
718 P[28] -= (s2 * P[56]);
719 P[29] -= (s2 * P[57]);
720 P[30] -= (s2 * P[58]);
721 P[32] -= (s3 * P[4]);
722 P[33] -= (s3 * P[5]);
723 P[34] -= (s3 * P[6]);
724 P[35] -= (s3 * P[59]);
725 P[36] -= (s3 * P[56]);
726 P[37] -= (s3 * P[57]);
727 P[38] -= (s3 * P[58]);
728 P[40] -= (s4 * P[4]);
729 P[41] -= (s4 * P[5]);
730 P[42] -= (s4 * P[6]);
731 P[43] -= (s4 * P[59]);
732 P[44] -= (s4 * P[56]);
733 P[45] -= (s4 * P[57]);
734 P[46] -= (s4 * P[58]);
736 double P3, P4,
C = P[4] * P[4] + P[5] * P[5];
750 state.jacobian[0] = Ax[0] * P[8] + Ax[1] * P[9];
751 state.jacobian[1] = Ax[0] * P[16] + Ax[1] * P[17];
752 state.jacobian[2] = Ax[0] * P[24] + Ax[1] * P[25];
753 state.jacobian[3] = Ax[0] * P[32] + Ax[1] * P[33];
754 state.jacobian[4] = Ax[0] * P[40] + Ax[1] * P[41];
755 state.jacobian[5] = 0.;
757 state.jacobian[6] = Ay[0] * P[8] + Ay[1] * P[9] + Ay[2] * P[10];
759 Ay[0] * P[16] + Ay[1] * P[17] + Ay[2] * P[18];
761 Ay[0] * P[24] + Ay[1] * P[25] + Ay[2] * P[26];
763 Ay[0] * P[32] + Ay[1] * P[33] + Ay[2] * P[34];
765 Ay[0] * P[40] + Ay[1] * P[41] + Ay[2] * P[42];
766 state.jacobian[11] = 0.;
768 state.jacobian[12] = P3 * P[13] - P4 * P[12];
769 state.jacobian[13] = P3 * P[21] - P4 * P[20];
770 state.jacobian[14] = P3 * P[29] - P4 * P[28];
771 state.jacobian[15] = P3 * P[37] - P4 * P[36];
772 state.jacobian[16] = P3 * P[45] - P4 * P[44];
773 state.jacobian[17] = 0.;
775 state.jacobian[18] = C * P[14];
776 state.jacobian[19] = C * P[22];
777 state.jacobian[20] = C * P[30];
778 state.jacobian[21] = C * P[38];
779 state.jacobian[22] = C * P[46];
780 state.jacobian[23] = 0.;
782 state.jacobian[24] = 0.;
783 state.jacobian[25] = 0.;
784 state.jacobian[26] = 0.;
785 state.jacobian[27] = 0.;
786 state.jacobian[28] = P[47];
787 state.jacobian[29] = 0.;
789 state.jacobian[30] = P[11];
790 state.jacobian[31] = P[19];
791 state.jacobian[32] = P[27];
792 state.jacobian[33] = P[35];
793 state.jacobian[34] = P[43];
794 state.jacobian[35] = P[51];
799 state.cov = J * (*state.covariance) * J.transpose();
809 Acts::Vector3D gp(state.pVector[0], state.pVector[1], state.pVector[2]);
813 double p = 1. / state.pVector[7];
814 state.pVector[40] *=
p;
815 state.pVector[41] *=
p;
816 state.pVector[42] *=
p;
817 state.pVector[44] *=
p;
818 state.pVector[45] *=
p;
819 state.pVector[46] *=
p;
821 const auto fFrame = surface.
referenceFrame(state.geoContext, gp, mom);
823 double Ax[3] = {fFrame(0, 0), fFrame(1, 0), fFrame(2, 0)};
824 double Ay[3] = {fFrame(0, 1), fFrame(1, 1), fFrame(2, 1)};
825 double S[3] = {fFrame(0, 2), fFrame(1, 2), fFrame(2, 2)};
828 double A = state.pVector[4] * S[0] + state.pVector[5] * S[1] +
829 state.pVector[6] * S[2];
839 double s0 = state.pVector[8] * S[0] + state.pVector[9] * S[1] +
840 state.pVector[10] * S[2];
841 double s1 = state.pVector[16] * S[0] + state.pVector[17] * S[1] +
842 state.pVector[18] * S[2];
843 double s2 = state.pVector[24] * S[0] + state.pVector[25] * S[1] +
844 state.pVector[26] * S[2];
845 double s3 = state.pVector[32] * S[0] + state.pVector[33] * S[1] +
846 state.pVector[34] * S[2];
847 double s4 = state.pVector[40] * S[0] + state.pVector[41] * S[1] +
848 state.pVector[42] * S[2];
856 double x = state.pVector[0] - surface.
center(state.geoContext).x();
857 double y = state.pVector[1] - surface.
center(state.geoContext).y();
858 double z = state.pVector[2] - surface.
center(state.geoContext).z();
861 double d = state.pVector[4] * Ay[0] + state.pVector[5] * Ay[1] +
862 state.pVector[6] * Ay[2];
865 double a = (1. -
d) * (1. + d);
871 double X = d * Ay[0] - state.pVector[4];
872 double Y = d * Ay[1] - state.pVector[5];
873 double Z = d * Ay[2] - state.pVector[6];
876 double d0 = state.pVector[12] * Ay[0] + state.pVector[13] * Ay[1] +
877 state.pVector[14] * Ay[2];
878 double d1 = state.pVector[20] * Ay[0] + state.pVector[21] * Ay[1] +
879 state.pVector[22] * Ay[2];
880 double d2 = state.pVector[28] * Ay[0] + state.pVector[29] * Ay[1] +
881 state.pVector[30] * Ay[2];
882 double d3 = state.pVector[36] * Ay[0] + state.pVector[37] * Ay[1] +
883 state.pVector[38] * Ay[2];
884 double d4 = state.pVector[44] * Ay[0] + state.pVector[45] * Ay[1] +
885 state.pVector[46] * Ay[2];
887 s0 = (((state.pVector[8] * X + state.pVector[9] * Y +
888 state.pVector[10] *
Z) +
889 x * (d0 * Ay[0] - state.pVector[12])) +
890 (y * (d0 * Ay[1] - state.pVector[13]) +
891 z * (d0 * Ay[2] - state.pVector[14]))) *
894 s1 = (((state.pVector[16] * X + state.pVector[17] * Y +
895 state.pVector[18] *
Z) +
896 x * (d1 * Ay[0] - state.pVector[20])) +
897 (y * (d1 * Ay[1] - state.pVector[21]) +
898 z * (d1 * Ay[2] - state.pVector[22]))) *
900 s2 = (((state.pVector[24] * X + state.pVector[25] * Y +
901 state.pVector[26] *
Z) +
902 x * (d2 * Ay[0] - state.pVector[28])) +
903 (y * (d2 * Ay[1] - state.pVector[29]) +
904 z * (d2 * Ay[2] - state.pVector[30]))) *
906 s3 = (((state.pVector[32] * X + state.pVector[33] * Y +
907 state.pVector[34] *
Z) +
908 x * (d3 * Ay[0] - state.pVector[36])) +
909 (y * (d3 * Ay[1] - state.pVector[37]) +
910 z * (d3 * Ay[2] - state.pVector[38]))) *
912 s4 = (((state.pVector[40] * X + state.pVector[41] * Y +
913 state.pVector[42] *
Z) +
914 x * (d4 * Ay[0] - state.pVector[44])) +
915 (y * (d4 * Ay[1] - state.pVector[45]) +
916 z * (d4 * Ay[2] - state.pVector[46]))) *
920 state.pVector[8] -= (s0 * state.pVector[4]);
921 state.pVector[9] -= (s0 * state.pVector[5]);
922 state.pVector[10] -= (s0 * state.pVector[6]);
923 state.pVector[11] -= (s0 * state.pVector[59]);
924 state.pVector[12] -= (s0 * state.pVector[56]);
925 state.pVector[13] -= (s0 * state.pVector[57]);
926 state.pVector[14] -= (s0 * state.pVector[58]);
928 state.pVector[16] -= (s1 * state.pVector[4]);
929 state.pVector[17] -= (s1 * state.pVector[5]);
930 state.pVector[18] -= (s1 * state.pVector[6]);
931 state.pVector[19] -= (s1 * state.pVector[59]);
932 state.pVector[20] -= (s1 * state.pVector[56]);
933 state.pVector[21] -= (s1 * state.pVector[57]);
934 state.pVector[22] -= (s1 * state.pVector[58]);
936 state.pVector[24] -= (s2 * state.pVector[4]);
937 state.pVector[25] -= (s2 * state.pVector[5]);
938 state.pVector[26] -= (s2 * state.pVector[6]);
939 state.pVector[27] -= (s2 * state.pVector[59]);
940 state.pVector[28] -= (s2 * state.pVector[56]);
941 state.pVector[29] -= (s2 * state.pVector[57]);
942 state.pVector[30] -= (s2 * state.pVector[58]);
944 state.pVector[32] -= (s3 * state.pVector[4]);
945 state.pVector[33] -= (s3 * state.pVector[5]);
946 state.pVector[34] -= (s3 * state.pVector[6]);
947 state.pVector[35] -= (s3 * state.pVector[59]);
948 state.pVector[36] -= (s3 * state.pVector[56]);
949 state.pVector[37] -= (s3 * state.pVector[57]);
950 state.pVector[38] -= (s3 * state.pVector[58]);
952 state.pVector[40] -= (s4 * state.pVector[4]);
953 state.pVector[41] -= (s4 * state.pVector[5]);
954 state.pVector[42] -= (s4 * state.pVector[6]);
955 state.pVector[43] -= (s4 * state.pVector[59]);
956 state.pVector[44] -= (s4 * state.pVector[56]);
957 state.pVector[45] -= (s4 * state.pVector[57]);
958 state.pVector[46] -= (s4 * state.pVector[58]);
961 C = state.pVector[4] * state.pVector[4] +
962 state.pVector[5] * state.pVector[5];
965 P3 = state.pVector[4] *
C;
966 P4 = state.pVector[5] *
C;
974 double MA[3] = {Ax[0], Ax[1], Ax[2]};
975 double MB[3] = {Ay[0], Ay[1], Ay[2]};
979 const auto& sfc = surface.
center(state.geoContext);
980 double d[3] = {state.pVector[0] - sfc(0), state.pVector[1] - sfc(1),
981 state.pVector[2] - sfc(2)};
983 double RC = d[0] * Ax[0] + d[1] * Ax[1] + d[2] * Ax[2];
984 double RS = d[0] * Ay[0] + d[1] * Ay[1] + d[2] * Ay[2];
985 double R2 = RC * RC + RS * RS;
988 double Ri = 1. / sqrt(R2);
989 MA[0] = (RC * Ax[0] + RS * Ay[0]) * Ri;
990 MA[1] = (RC * Ax[1] + RS * Ay[1]) * Ri;
991 MA[2] = (RC * Ax[2] + RS * Ay[2]) * Ri;
992 MB[0] = (RC * Ay[0] - RS * Ax[0]) * (Ri = 1. / R2);
993 MB[1] = (RC * Ay[1] - RS * Ax[1]) * Ri;
994 MB[2] = (RC * Ay[2] - RS * Ax[2]) * Ri;
997 state.jacobian[0] = MA[0] * state.pVector[8] + MA[1] * state.pVector[9] +
998 MA[2] * state.pVector[10];
999 state.jacobian[1] = MA[0] * state.pVector[16] + MA[1] * state.pVector[17] +
1000 MA[2] * state.pVector[18];
1001 state.jacobian[2] = MA[0] * state.pVector[24] + MA[1] * state.pVector[25] +
1002 MA[2] * state.pVector[26];
1003 state.jacobian[3] = MA[0] * state.pVector[32] + MA[1] * state.pVector[33] +
1004 MA[2] * state.pVector[34];
1005 state.jacobian[4] = MA[0] * state.pVector[40] + MA[1] * state.pVector[41] +
1006 MA[2] * state.pVector[42];
1007 state.jacobian[5] = 0.;
1009 state.jacobian[6] = MB[0] * state.pVector[8] + MB[1] * state.pVector[9] +
1010 MB[2] * state.pVector[10];
1011 state.jacobian[7] = MB[0] * state.pVector[16] + MB[1] * state.pVector[17] +
1012 MB[2] * state.pVector[18];
1013 state.jacobian[8] = MB[0] * state.pVector[24] + MB[1] * state.pVector[25] +
1014 MB[2] * state.pVector[26];
1015 state.jacobian[9] = MB[0] * state.pVector[32] + MB[1] * state.pVector[33] +
1016 MB[2] * state.pVector[34];
1017 state.jacobian[10] = MB[0] * state.pVector[40] + MB[1] * state.pVector[41] +
1018 MB[2] * state.pVector[42];
1019 state.jacobian[11] = 0.;
1021 state.jacobian[12] =
1022 P3 * state.pVector[13] - P4 * state.pVector[12];
1023 state.jacobian[13] =
1024 P3 * state.pVector[21] - P4 * state.pVector[20];
1025 state.jacobian[14] =
1026 P3 * state.pVector[29] - P4 * state.pVector[28];
1027 state.jacobian[15] =
1028 P3 * state.pVector[37] - P4 * state.pVector[36];
1029 state.jacobian[16] =
1030 P3 * state.pVector[45] - P4 * state.pVector[44];
1031 state.jacobian[17] = 0.;
1033 state.jacobian[18] = C * state.pVector[14];
1034 state.jacobian[19] = C * state.pVector[22];
1035 state.jacobian[20] = C * state.pVector[30];
1036 state.jacobian[21] = C * state.pVector[38];
1037 state.jacobian[22] = C * state.pVector[46];
1038 state.jacobian[23] = 0.;
1040 state.jacobian[24] = 0.;
1041 state.jacobian[25] = 0.;
1042 state.jacobian[26] = 0.;
1043 state.jacobian[27] = 0.;
1044 state.jacobian[28] = state.pVector[47];
1045 state.jacobian[29] = 0.;
1047 state.jacobian[30] = state.pVector[11];
1048 state.jacobian[31] = state.pVector[19];
1049 state.jacobian[32] = state.pVector[27];
1050 state.jacobian[33] = state.pVector[35];
1051 state.jacobian[34] = state.pVector[43];
1052 state.jacobian[35] = state.pVector[51];
1057 state.cov = J * (*state.covariance) * J.transpose();
1063 template <
typename propagator_state_t>
1066 auto&
h = state.stepping.stepSize;
1067 bool Jac = state.stepping.useJacobian;
1069 double*
R = &(state.stepping.pVector[0]);
1070 double*
A = &(state.stepping.pVector[4]);
1071 double* sA = &(state.stepping.pVector[56]);
1073 double Pi = 0.5 * state.stepping.pVector[7];
1078 if (state.stepping.newfield) {
1081 f0 = getField(state.stepping, pos);
1083 f0 = state.stepping.field;
1091 double S3 = (1. / 3.) *
h, S4 = .25 *
h, PS2 = Pi *
h;
1096 double H0[3] = {f0[0] * PS2, f0[1] * PS2, f0[2] * PS2};
1098 double A0 = A[1] * H0[2] - A[2] * H0[1];
1099 double B0 = A[2] * H0[0] - A[0] * H0[2];
1100 double C0 = A[0] * H0[1] - A[1] * H0[0];
1102 double A2 = A0 + A[0];
1103 double B2 = B0 + A[1];
1104 double C2 = C0 + A[2];
1106 double A1 = A2 + A[0];
1107 double B1 = B2 + A[1];
1108 double C1 = C2 + A[2];
1114 const Vector3D pos(R[0] + A1 * S4, R[1] + B1 * S4, R[2] + C1 * S4);
1116 f = getField(state.stepping, pos);
1122 double H1[3] = {f[0] * PS2, f[1] * PS2, f[2] * PS2};
1124 double A3 = (A[0] + B2 * H1[2]) - C2 * H1[1];
1125 double B3 = (A[1] + C2 * H1[0]) - A2 * H1[2];
1126 double C3 = (A[2] + A2 * H1[1]) - B2 * H1[0];
1128 double A4 = (A[0] + B3 * H1[2]) - C3 * H1[1];
1129 double B4 = (A[1] + C3 * H1[0]) - A3 * H1[2];
1130 double C4 = (A[2] + A3 * H1[1]) - B3 * H1[0];
1132 double A5 = 2. * A4 - A[0];
1133 double B5 = 2. * B4 - A[1];
1134 double C5 = 2. * C4 - A[2];
1140 const Vector3D pos(R[0] + h * A4, R[1] + h * B4, R[2] + h * C4);
1142 f = getField(state.stepping, pos);
1148 double H2[3] = {f[0] * PS2, f[1] * PS2, f[2] * PS2};
1150 double A6 = B5 * H2[2] - C5 * H2[1];
1151 double B6 = C5 * H2[0] - A5 * H2[2];
1152 double C6 = A5 * H2[1] - B5 * H2[0];
1162 if (EST > state.options.tolerance) {
1172 double A00 = A[0],
A11 = A[1],
A22 = A[2];
1174 A[0] = 2. * A3 + (A0 + A5 + A6);
1175 A[1] = 2. * B3 + (B0 + B5 + B6);
1176 A[2] = 2. * C3 + (C0 + C5 + C6);
1178 double D = (A[0] * A[0] + A[1] * A[1]) + (A[2] * A[2] - 9.);
1180 D = (1. / 3.) - ((1. / 648.) *
D) * (12. - D);
1182 R[0] += (A2 + A3 + A4) * S3;
1183 R[1] += (B2 + B3 + B4) * S3;
1184 R[2] += (C2 + C3 + C4) * S3;
1193 state.stepping.pVector[3] +=
1194 h * std::hypot(1, state.options.mass /
momentum(state.stepping));
1195 state.stepping.pVector[59] =
1196 std::hypot(1, state.options.mass /
momentum(state.stepping));
1197 state.stepping.field =
f;
1198 state.stepping.newfield =
false;
1202 h * state.options.mass * state.options.mass *
1205 std::hypot(1., state.options.mass /
momentum(state.stepping)));
1206 state.stepping.pVector[43] += dtdl;
1210 double* d2A = &state.stepping.pVector[28];
1211 double* d3A = &state.stepping.pVector[36];
1212 double* d4A = &state.stepping.pVector[44];
1213 double d2A0 = H0[2] * d2A[1] - H0[1] * d2A[2];
1214 double d2B0 = H0[0] * d2A[2] - H0[2] * d2A[0];
1215 double d2C0 = H0[1] * d2A[0] - H0[0] * d2A[1];
1216 double d3A0 = H0[2] * d3A[1] - H0[1] * d3A[2];
1217 double d3B0 = H0[0] * d3A[2] - H0[2] * d3A[0];
1218 double d3C0 = H0[1] * d3A[0] - H0[0] * d3A[1];
1219 double d4A0 = (A0 + H0[2] * d4A[1]) - H0[1] * d4A[2];
1220 double d4B0 = (B0 + H0[0] * d4A[2]) - H0[2] * d4A[0];
1221 double d4C0 = (C0 + H0[1] * d4A[0]) - H0[0] * d4A[1];
1222 double d2A2 = d2A0 + d2A[0];
1223 double d2B2 = d2B0 + d2A[1];
1224 double d2C2 = d2C0 + d2A[2];
1225 double d3A2 = d3A0 + d3A[0];
1226 double d3B2 = d3B0 + d3A[1];
1227 double d3C2 = d3C0 + d3A[2];
1228 double d4A2 = d4A0 + d4A[0];
1229 double d4B2 = d4B0 + d4A[1];
1230 double d4C2 = d4C0 + d4A[2];
1231 double d0 = d4A[0] -
A00;
1232 double d1 = d4A[1] -
A11;
1233 double d2 = d4A[2] -
A22;
1234 double d2A3 = (d2A[0] + d2B2 * H1[2]) - d2C2 * H1[1];
1235 double d2B3 = (d2A[1] + d2C2 * H1[0]) - d2A2 * H1[2];
1236 double d2C3 = (d2A[2] + d2A2 * H1[1]) - d2B2 * H1[0];
1237 double d3A3 = (d3A[0] + d3B2 * H1[2]) - d3C2 * H1[1];
1238 double d3B3 = (d3A[1] + d3C2 * H1[0]) - d3A2 * H1[2];
1239 double d3C3 = (d3A[2] + d3A2 * H1[1]) - d3B2 * H1[0];
1240 double d4A3 = ((A3 + d0) + d4B2 * H1[2]) - d4C2 * H1[1];
1241 double d4B3 = ((B3 +
d1) + d4C2 * H1[0]) - d4A2 * H1[2];
1242 double d4C3 = ((C3 +
d2) + d4A2 * H1[1]) - d4B2 * H1[0];
1243 double d2A4 = (d2A[0] + d2B3 * H1[2]) - d2C3 * H1[1];
1244 double d2B4 = (d2A[1] + d2C3 * H1[0]) - d2A3 * H1[2];
1245 double d2C4 = (d2A[2] + d2A3 * H1[1]) - d2B3 * H1[0];
1246 double d3A4 = (d3A[0] + d3B3 * H1[2]) - d3C3 * H1[1];
1247 double d3B4 = (d3A[1] + d3C3 * H1[0]) - d3A3 * H1[2];
1248 double d3C4 = (d3A[2] + d3A3 * H1[1]) - d3B3 * H1[0];
1249 double d4A4 = ((A4 + d0) + d4B3 * H1[2]) - d4C3 * H1[1];
1250 double d4B4 = ((B4 +
d1) + d4C3 * H1[0]) - d4A3 * H1[2];
1251 double d4C4 = ((C4 +
d2) + d4A3 * H1[1]) - d4B3 * H1[0];
1252 double d2A5 = 2. * d2A4 - d2A[0];
1253 double d2B5 = 2. * d2B4 - d2A[1];
1254 double d2C5 = 2. * d2C4 - d2A[2];
1255 double d3A5 = 2. * d3A4 - d3A[0];
1256 double d3B5 = 2. * d3B4 - d3A[1];
1257 double d3C5 = 2. * d3C4 - d3A[2];
1258 double d4A5 = 2. * d4A4 - d4A[0];
1259 double d4B5 = 2. * d4B4 - d4A[1];
1260 double d4C5 = 2. * d4C4 - d4A[2];
1261 double d2A6 = d2B5 * H2[2] - d2C5 * H2[1];
1262 double d2B6 = d2C5 * H2[0] - d2A5 * H2[2];
1263 double d2C6 = d2A5 * H2[1] - d2B5 * H2[0];
1264 double d3A6 = d3B5 * H2[2] - d3C5 * H2[1];
1265 double d3B6 = d3C5 * H2[0] - d3A5 * H2[2];
1266 double d3C6 = d3A5 * H2[1] - d3B5 * H2[0];
1267 double d4A6 = d4B5 * H2[2] - d4C5 * H2[1];
1268 double d4B6 = d4C5 * H2[0] - d4A5 * H2[2];
1269 double d4C6 = d4A5 * H2[1] - d4B5 * H2[0];
1271 double* dR = &state.stepping.pVector[24];
1272 dR[0] += (d2A2 + d2A3 + d2A4) * S3;
1273 dR[1] += (d2B2 + d2B3 + d2B4) * S3;
1274 dR[2] += (d2C2 + d2C3 + d2C4) * S3;
1275 d2A[0] = ((d2A0 + 2. * d2A3) + (d2A5 + d2A6)) * (1. / 3.);
1276 d2A[1] = ((d2B0 + 2. * d2B3) + (d2B5 + d2B6)) * (1. / 3.);
1277 d2A[2] = ((d2C0 + 2. * d2C3) + (d2C5 + d2C6)) * (1. / 3.);
1279 dR = &state.stepping.pVector[32];
1280 dR[0] += (d3A2 + d3A3 + d3A4) * S3;
1281 dR[1] += (d3B2 + d3B3 + d3B4) * S3;
1282 dR[2] += (d3C2 + d3C3 + d3C4) * S3;
1283 d3A[0] = ((d3A0 + 2. * d3A3) + (d3A5 + d3A6)) * (1. / 3.);
1284 d3A[1] = ((d3B0 + 2. * d3B3) + (d3B5 + d3B6)) * (1. / 3.);
1285 d3A[2] = ((d3C0 + 2. * d3C3) + (d3C5 + d3C6)) * (1. / 3.);
1287 dR = &state.stepping.pVector[40];
1288 dR[0] += (d4A2 + d4A3 + d4A4) * S3;
1289 dR[1] += (d4B2 + d4B3 + d4B4) * S3;
1290 dR[2] += (d4C2 + d4C3 + d4C4) * S3;
1291 d4A[0] = ((d4A0 + 2. * d4A3) + (d4A5 + d4A6 + A6)) * (1. / 3.);
1292 d4A[1] = ((d4B0 + 2. * d4B3) + (d4B5 + d4B6 + B6)) * (1. / 3.);
1293 d4A[2] = ((d4C0 + 2. * d4C3) + (d4C5 + d4C6 + C6)) * (1. / 3.);
1296 state.stepping.pathAccumulated +=
h;
1301 state.stepping.pathAccumulated +=
h;
1309 double m_overstepLimit = -50
_um;