1 #ifndef RecoTracker_PixelTrackFitting_FitUtils_h 2 #define RecoTracker_PixelTrackFitting_FitUtils_h 15 using MatrixNd = Eigen::Matrix<double, N, N>;
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>;
25 using Matrix2xNd = Eigen::Matrix<double, 2, N>;
27 using Array2xNd = Eigen::Array<double, 2, N>;
29 using MatrixNx3d = Eigen::Matrix<double, N, 3>;
31 using MatrixNx5d = Eigen::Matrix<double, N, 5>;
33 using VectorNd = Eigen::Matrix<double, N, 1>;
37 using Vector2Nd = Eigen::Matrix<double, 2 * N, 1>;
39 using Vector3Nd = Eigen::Matrix<double, 3 * N, 1>;
45 using Matrix2x3d = Eigen::Matrix<double, 2, 3>;
50 using Vector6f = Eigen::Matrix<double, 6, 1>;
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) {
105 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
109 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
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) {
137 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
141 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
145 hits_cov(
i +
j * hits_in_fit,
i +
l * hits_in_fit) = ge.col(
i)[ge_idx];
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) =
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) =
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 // RecoTracker_PixelTrackFitting_FitUtils_h Eigen::Matrix< double, 2, N > Matrix2xNd
Eigen::Matrix< double, 6, 1 > Vector6f
Eigen::Matrix< double, 3 *N, 1 > Vector3Nd
Eigen::Matrix< double, 5, 5 > Matrix5d
int32_t qCharge
particle charge
Eigen::Matrix< double, 1, 2 *N > RowVector2Nd
Eigen::Matrix< double, 2 *N, 1 > Vector2Nd
Eigen::Matrix< double, 2, 3 > Matrix2x3d
Eigen::Matrix< double, 3 *N, 3 *N > Matrix3Nd
Eigen::Array< double, N, N > ArrayNd
Eigen::Matrix< double, N+1, 1 > VectorNplusONEd
Vector3d par
parameter: (X0,Y0,R)
__host__ __device__ double cross2D(const Vector2d &a, const Vector2d &b)
Compute cross product of two 2D vector (assuming z component 0), returning z component of the result...
void transformToPerigeePlane(VI5 const &ip, MI5 const &icov, VO5 &op, MO5 &ocov)
__host__ __device__ void par_uvrtopak(CircleFit &circle, const double B, const bool error)
Transform circle parameter from (X0,Y0,R) to (phi,Tip,p_t) and consequently covariance matrix...
Eigen::Matrix< double, N, 1 > VectorNd
Eigen::Matrix< double, N, N > MatrixNd
constexpr T sqr(const T a)
raise to square.
constexpr double epsilon
used in numerical derivative (J2 in Circle_fit())
__host__ __device__ void loadCovariance(M6xNf const &ge, M3xNd &hits_cov)
Eigen::Matrix< double, N, 5 > MatrixNx5d
Eigen::Matrix< double, 2 *N, 2 *N > Matrix2Nd
Eigen::Array< double, 2, N > Array2xNd
Eigen::Matrix< double, N, 3 > MatrixNx3d
Eigen::Matrix< double, N+1, N+1 > MatrixNplusONEd
__host__ __device__ void fromCircleToPerigee(CircleFit &circle)
Transform circle parameter from (X0,Y0,R) to (phi,Tip,q/R) and consequently covariance matrix...
__host__ __device__ void loadCovariance2D(M6xNf const &ge, M2Nd &hits_cov)
Eigen::Matrix< double, 1, 1, N > RowVectorNd
__host__ __device__ void printIt(C *m, const char *prefix="")