1 #ifndef RecoPixelVertexing_PixelTrackFitting_interface_FitUtils_h
2 #define RecoPixelVertexing_PixelTrackFitting_interface_FitUtils_h
19 using ArrayNd = Eigen::Array<double, N, N>;
21 using Matrix2Nd = Eigen::Matrix<double, 2 * N, 2 * N>;
23 using Matrix3Nd = Eigen::Matrix<double, 3 * N, 3 * N>;
55 for (
uint r = 0;
r <
m->rows(); ++
r) {
56 for (
uint c = 0;
c <
m->cols(); ++
c) {
57 printf(
"%s Matrix(%d,%d) = %g\n",
prefix,
r,
c, (*
m)(
r,
c));
80 return a.x() *
b.y() -
a.y() *
b.x();
87 template <
typename M6xNf,
typename M2Nd>
101 constexpr uint32_t hits_in_fit = M6xNf::ColsAtCompileTime;
102 for (uint32_t
i = 0;
i < hits_in_fit; ++
i) {
104 constexpr uint32_t ge_idx = 0,
j = 0,
l = 0;
105 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
108 constexpr uint32_t ge_idx = 2,
j = 1,
l = 1;
109 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
112 constexpr uint32_t ge_idx = 1,
j = 1,
l = 0;
113 hits_cov(
i +
l * hits_in_fit,
i +
j * hits_in_fit) = hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) =
119 template <
typename M6xNf,
typename M3xNd>
133 constexpr uint32_t hits_in_fit = M6xNf::ColsAtCompileTime;
134 for (uint32_t
i = 0;
i < hits_in_fit; ++
i) {
136 constexpr uint32_t ge_idx = 0,
j = 0,
l = 0;
137 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
140 constexpr uint32_t ge_idx = 2,
j = 1,
l = 1;
141 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
144 constexpr uint32_t ge_idx = 5,
j = 2,
l = 2;
145 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
148 constexpr uint32_t ge_idx = 1,
j = 1,
l = 0;
149 hits_cov(
i +
l * hits_in_fit,
i +
j * hits_in_fit) = hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) =
153 constexpr uint32_t ge_idx = 3,
j = 2,
l = 0;
154 hits_cov(
i +
l * hits_in_fit,
i +
j * hits_in_fit) = hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) =
158 constexpr uint32_t ge_idx = 4,
j = 2,
l = 1;
159 hits_cov(
i +
l * hits_in_fit,
i +
j * hits_in_fit) = hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) =
175 const double temp0 = circle.
par.head(2).squaredNorm();
176 const double temp1 =
sqrt(temp0);
180 const double temp2 =
sqr(circle.
par(0)) * 1. / temp0;
181 const double temp3 = 1. / temp1 * circle.
qCharge;
183 j4Mat << -circle.
par(1) * temp2 * 1. /
sqr(circle.
par(0)), temp2 * 1. / circle.
par(0), 0., circle.
par(0) * temp3,
185 circle.
cov = j4Mat * circle.
cov * j4Mat.transpose();
187 circle.
par = par_pak;
198 const double temp0 = circle.
par.head(2).squaredNorm();
199 const double temp1 =
sqrt(temp0);
203 const double temp2 =
sqr(circle.
par(0)) * 1. / temp0;
204 const double temp3 = 1. / temp1 * circle.
qCharge;
206 j4Mat << -circle.
par(1) * temp2 * 1. /
sqr(circle.
par(0)), temp2 * 1. / circle.
par(0), 0., circle.
par(0) * temp3,
208 circle.
cov = j4Mat * circle.
cov * j4Mat.transpose();
210 circle.
par = par_pak;
217 template <
typename VI5,
typename MI5,
typename VO5,
typename MO5>
219 auto sinTheta2 = 1. / (1. + ip(3) * ip(3));
221 auto cosTheta = ip(3) * sinTheta;
223 op(0) = sinTheta * ip(2);
231 jMat(0, 2) = sinTheta;
232 jMat(0, 3) = -sinTheta2 * cosTheta * ip(2);
238 ocov = jMat * icov * jMat.transpose();
243 #endif // RecoPixelVertexing_PixelTrackFitting_interface_FitUtils_h