11 template <
typename propagator_t,
typename propagator_options_t>
19 const std::shared_ptr<PerigeeSurface> perigeeSurface =
20 Surface::makeShared<PerigeeSurface>(linPointPos);
24 propagator_options_t pOptions(gctx, mctx,
LoggerWrapper{*logger});
29 auto result = m_cfg.propagator->propagate(params, *perigeeSurface, pOptions);
31 endParams = (*result).endParameters.
get();
34 return result.error();
38 Vector4D positionAtPCA = Vector4D::Zero();
48 if (endParams->
covariance()->determinant() == 0) {
60 double sinPhiV = std::sin(phiV);
65 const double sinTh = std::sin(th);
66 const double tanTh = std::tan(th);
70 double sgnH = (qOvP < 0.) ? -1 : 1;
72 Vector3D momentumAtPCA(phiV, th, qOvP);
79 if (Bz == 0. ||
std::abs(qOvP) < m_cfg.minQoP) {
82 rho = sinTh * (1. / qOvP) / Bz;
86 double X = positionAtPCA(0) - linPointPos.x() + rho * sinPhiV;
87 double Y = positionAtPCA(1) - linPointPos.y() - rho * cosPhiV;
88 const double S2 = (X * X + Y * Y);
89 const double S = std::sqrt(S2);
96 int sgnX = (X < 0.) ? -1 : 1;
97 int sgnY = (Y < 0.) ? -1 : 1;
101 phiAtPCA = sgnH * sgnX * std::acos(-sgnH * Y / S);
103 phiAtPCA = std::asin(sgnH * X / S);
104 if ((sgnH * sgnY) > 0) {
105 phiAtPCA = sgnH * sgnX *
M_PI - phiAtPCA;
110 predParamsAtPCA[0] = rho - sgnH * S;
112 positionAtPCA[
eZ] - linPointPos.z() + rho * (phiV - phiAtPCA) / tanTh;
113 predParamsAtPCA[2] = phiAtPCA;
114 predParamsAtPCA[3] = th;
115 predParamsAtPCA[4] = qOvP;
116 predParamsAtPCA[5] = 0.;
120 positionJacobian.setZero();
122 positionJacobian(0, 0) = -sgnH * X / S;
123 positionJacobian(0, 1) = -sgnH * Y / S;
125 const double S2tanTh = S2 * tanTh;
128 positionJacobian(1, 0) = rho * Y / S2tanTh;
129 positionJacobian(1, 1) = -rho * X / S2tanTh;
130 positionJacobian(1, 2) = 1.;
133 positionJacobian(2, 0) = -Y / S2;
134 positionJacobian(2, 1) = X / S2;
138 positionJacobian(5, 3) = 1;
142 momentumJacobian.setZero();
144 double R = X * cosPhiV + Y * sinPhiV;
145 double Q = X * sinPhiV - Y * cosPhiV;
146 double dPhi = phiAtPCA - phiV;
149 momentumJacobian(0, 0) = -sgnH * rho * R / S;
151 double qOvSred = 1 - sgnH * Q / S;
153 momentumJacobian(0, 1) = qOvSred * rho / tanTh;
154 momentumJacobian(0, 2) = -qOvSred * rho / qOvP;
156 const double rhoOverS2 = rho / S2;
159 momentumJacobian(1, 0) = (1 - rhoOverS2 * Q) * rho / tanTh;
160 momentumJacobian(1, 1) = (dPhi + rho * R / (S2tanTh * tanTh)) * rho;
161 momentumJacobian(1, 2) = (dPhi - rhoOverS2 *
R) * rho / (qOvP * tanTh);
164 momentumJacobian(2, 0) = rhoOverS2 * Q;
165 momentumJacobian(2, 1) = -rho * R / S2tanTh;
166 momentumJacobian(2, 2) = rhoOverS2 * R / qOvP;
169 momentumJacobian(3, 1) = 1.;
170 momentumJacobian(4, 2) = 1.;
173 BoundVector constTerm = predParamsAtPCA - positionJacobian * positionAtPCA -
174 momentumJacobian * momentumAtPCA;
178 (parCovarianceAtPCA.block<5, 5>(0, 0)).inverse();
181 weightAtPCA.block<5, 5>(0, 0) = parWeight;
183 return LinearizedTrack(paramsAtPCA, parCovarianceAtPCA, weightAtPCA, linPoint,
184 positionJacobian, momentumJacobian, positionAtPCA,
185 momentumAtPCA, constTerm);