ATLAS Offline Software
JacobianHelper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef JACOBIAN__HELPER__H
6 #define JACOBIAN__HELPER__H
7 
8 #include "CxxUtils/restrict.h"
10 #include "CxxUtils/vec.h"
11 
12 namespace Trk {
13 
28 
40 void
42  const double* ATH_RESTRICT H0,
43  const double* ATH_RESTRICT H1,
44  const double* ATH_RESTRICT H2,
45  const double* ATH_RESTRICT A,
46  const double* ATH_RESTRICT A0,
47  const double* ATH_RESTRICT A3,
48  const double* ATH_RESTRICT A4,
49  const double* ATH_RESTRICT A6,
50  const double S3)
51 {
52  using namespace CxxUtils;
54 
55  vec2 d23A_0{ P[24], P[31] };
56  vec2 d23A_1{ P[25], P[32] };
57  vec2 d23A_2{ P[26], P[33] };
58  const double d4A_0 = P[38];
59  const double d4A_1 = P[39];
60  const double d4A_2 = P[40];
61  // H
62  const double H0_0 = H0[0];
63  const double H0_1 = H0[1];
64  const double H0_2 = H0[2];
65  const double H1_0 = H1[0];
66  const double H1_1 = H1[1];
67  const double H1_2 = H1[2];
68  const double H2_0 = H2[0];
69  const double H2_1 = H2[1];
70  const double H2_2 = H2[2];
71  //
72  vec2 d23A0 = H0_2 * d23A_1 - H0_1 * d23A_2;
73  vec2 d23B0 = H0_0 * d23A_2 - H0_2 * d23A_0;
74  vec2 d23C0 = H0_1 * d23A_0 - H0_0 * d23A_1;
75  const double d4A0 = (A0[0] + H0_2 * d4A_1) - H0_1 * d4A_2;
76  const double d4B0 = (A0[1] + H0_0 * d4A_2) - H0_2 * d4A_0;
77  const double d4C0 = (A0[2] + H0_1 * d4A_0) - H0_0 * d4A_1;
78  //
79  vec2 d23A2 = d23A0 + d23A_0;
80  vec2 d23B2 = d23B0 + d23A_1;
81  vec2 d23C2 = d23C0 + d23A_2;
82  const double d4A2 = d4A0 + d4A_0;
83  const double d4B2 = d4B0 + d4A_1;
84  const double d4C2 = d4C0 + d4A_2;
85  const double d0 = d4A_0 - A[0];
86  const double d1 = d4A_1 - A[1];
87  const double d2 = d4A_2 - A[2];
88  //
89  vec2 d23A3 = (d23A_0 + d23B2 * H1_2) - d23C2 * H1_1;
90  vec2 d23B3 = (d23A_1 + d23C2 * H1_0) - d23A2 * H1_2;
91  vec2 d23C3 = (d23A_2 + d23A2 * H1_1) - d23B2 * H1_0;
92  const double d4A3 = ((A3[0] + d0) + d4B2 * H1_2) - d4C2 * H1_1;
93  const double d4B3 = ((A3[1] + d1) + d4C2 * H1_0) - d4A2 * H1_2;
94  const double d4C3 = ((A3[2] + d2) + d4A2 * H1_1) - d4B2 * H1_0;
95  //
96  vec2 d23A4 = (d23A_0 + d23B3 * H1_2) - d23C3 * H1_1;
97  vec2 d23B4 = (d23A_1 + d23C3 * H1_0) - d23A3 * H1_2;
98  vec2 d23C4 = (d23A_2 + d23A3 * H1_1) - d23B3 * H1_0;
99  const double d4A4 = ((A4[0] + d0) + d4B3 * H1_2) - d4C3 * H1_1;
100  const double d4B4 = ((A4[1] + d1) + d4C3 * H1_0) - d4A3 * H1_2;
101  const double d4C4 = ((A4[2] + d2) + d4A3 * H1_1) - d4B3 * H1_0;
102  //
103  vec2 d23A5 = 2. * d23A4 - d23A_0;
104  vec2 d23B5 = 2. * d23B4 - d23A_1;
105  vec2 d23C5 = 2. * d23C4 - d23A_2;
106  const double d4A5 = 2. * d4A4 - d4A_0;
107  const double d4B5 = 2. * d4B4 - d4A_1;
108  const double d4C5 = 2. * d4C4 - d4A_2;
109  //
110  vec2 d23A6 = d23B5 * H2_2 - d23C5 * H2_1;
111  vec2 d23B6 = d23C5 * H2_0 - d23A5 * H2_2;
112  vec2 d23C6 = d23A5 * H2_1 - d23B5 * H2_0;
113  double d4A6 = d4B5 * H2_2 - d4C5 * H2_1;
114  double d4B6 = d4C5 * H2_0 - d4A5 * H2_2;
115  double d4C6 = d4A5 * H2_1 - d4B5 * H2_0;
116 
117  vec2 dR23_A = (d23A2 + d23A3 + d23A4) * S3;
118  vec2 dR23_B = (d23B2 + d23B3 + d23B4) * S3;
119  vec2 dR23_C = (d23C2 + d23C3 + d23C4) * S3;
120 
121  vec2 res23_0 = ((d23A0 + 2. * d23A3) + (d23A5 + d23A6)) * (1. / 3.);
122  vec2 res23_1 = ((d23B0 + 2. * d23B3) + (d23B5 + d23B6)) * (1. / 3.);
123  vec2 res23_2 = ((d23C0 + 2. * d23C3) + (d23C5 + d23C6)) * (1. / 3.);
124 
126  P[21] += dR23_A[0];
127  P[22] += dR23_B[0];
128  P[23] += dR23_C[0];
129  P[24] = res23_0[0];
130  P[25] = res23_1[0];
131  P[26] = res23_2[0];
132 
133  P[28] += dR23_A[1];
134  P[29] += dR23_B[1];
135  P[30] += dR23_C[1];
136  P[31] = res23_0[1];
137  P[32] = res23_1[1];
138  P[33] = res23_2[1];
139 
140  P[35] += (d4A2 + d4A3 + d4A4) * S3;
141  P[36] += (d4B2 + d4B3 + d4B4) * S3;
142  P[37] += (d4C2 + d4C3 + d4C4) * S3;
143  P[38] = ((d4A0 + 2. * d4A3) + (d4A5 + d4A6 + A6[0])) * (1. / 3.);
144  P[39] = ((d4B0 + 2. * d4B3) + (d4B5 + d4B6 + A6[1])) * (1. / 3.);
145  P[40] = ((d4C0 + 2. * d4C3) + (d4C5 + d4C6 + A6[2])) * (1. / 3.);
146 }
147 }
148 
149 #endif // Jacobian__Helper__H
D3PDMakerTestInstan::vec2
std::vector< D3PDTest::MyVec2 > vec2
Definition: D3PDMakerTestDict.h:14
inline_hints.h
DMTest::P
P_v1 P
Definition: P.h:23
S3
struct TBPatternUnitContext S3
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
ATH_ALWAYS_INLINE
#define ATH_ALWAYS_INLINE
Definition: inline_hints.h:53
Trk::propJacobian
ATH_ALWAYS_INLINE void propJacobian(double *ATH_RESTRICT P, const double *ATH_RESTRICT H0, const double *ATH_RESTRICT H1, const double *ATH_RESTRICT H2, const double *ATH_RESTRICT A, const double *ATH_RESTRICT A0, const double *ATH_RESTRICT A3, const double *ATH_RESTRICT A4, const double *ATH_RESTRICT A6, const double S3)
This provides an inline helper function for updating the jacobian during Runge-Kutta propagation.
Definition: JacobianHelper.h:41
H2
#define H2(x, y, z)
Definition: MD5.cxx:115
ATH_RESTRICT
#define ATH_RESTRICT
Definition: restrict.h:31
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
A
CxxUtils
Definition: aligned_vector.h:29
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
restrict.h
Macro wrapping the nonstandard restrict keyword.
Trk::d0
@ d0
Definition: ParamDefs.h:63
vec.h
Vectorization helpers.
dq_defect_virtual_defect_validation.d2
d2
Definition: dq_defect_virtual_defect_validation.py:81