1 #ifndef RecoTracker_PixelTrackFitting_interface_alpaka_RiemannFit_h 2 #define RecoTracker_PixelTrackFitting_interface_alpaka_RiemannFit_h 4 #include <alpaka/alpaka.hpp> 7 #include <Eigen/Eigenvalues> 37 template <
typename TAcc,
typename VNd1,
typename VNd2>
39 const VNd1& length_values,
44 uint n = length_values.rows();
45 rad_lengths(0) = length_values(0) * xx_0_inv;
70 template <
typename TAcc,
typename V4,
typename VNd1,
typename VNd2,
int N>
84 double p_2 = p_t * p_t * (1. + 1. /
sqr(
fast_fit(3)));
85 VectorNd<N> rad_lengths_S;
89 VectorNd<N> s_values = s_arcs.array() * s_arcs.array() + z_values.array() * z_values.array();
90 s_values = s_values.array().sqrt();
93 sig2_S = .000225 / p_2 * (1. + 0.038 * rad_lengths_S.array().log()).abs2() * rad_lengths_S.array();
97 Matrix2Nd<N>
tmp = Matrix2Nd<N>::Zero();
99 tmp(
k,
k) = cov_sz[
k](0, 0);
100 tmp(
k +
n,
k +
n) = cov_sz[
k](1, 1);
133 template <
typename TAcc,
typename M2xN,
typename V4,
int N>
135 const TAcc& acc,
const M2xN& p2D,
const V4&
fast_fit, VectorNd<N>
const& rad,
double B) {
138 double p_2 = p_t * p_t * (1. + 1. /
sqr(
fast_fit(3)));
141 VectorNd<N> s_values;
142 VectorNd<N> rad_lengths;
147 Vector2d pVec = p2D.block(0,
i, 2, 1) - oVec;
149 const double dot = (-oVec).
dot(pVec);
150 const double tempAtan2 = atan2(
cross,
dot);
155 VectorNd<N> sig2 = (1. + 0.038 * rad_lengths.array().log()).abs2() * rad_lengths.array();
179 template <
typename TAcc,
typename M2xN,
int N>
182 const MatrixNd<N>& cov_rad,
183 const VectorNd<N>& rad) {
185 printf(
"Address of p2D: %p\n", &p2D);
187 printIt(&p2D,
"cov_radtocart - p2D:");
189 Matrix2Nd<N> cov_cart = Matrix2Nd<N>::Zero();
190 VectorNd<N> rad_inv = rad.cwiseInverse();
191 printIt(&rad_inv,
"cov_radtocart - rad_inv:");
194 cov_cart(
i,
j) = cov_rad(
i,
j) * p2D(1,
i) * rad_inv(
i) * p2D(1,
j) * rad_inv(
j);
195 cov_cart(
i +
n,
j +
n) = cov_rad(
i,
j) * p2D(0,
i) * rad_inv(
i) * p2D(0,
j) * rad_inv(
j);
196 cov_cart(
i,
j +
n) = -cov_rad(
i,
j) * p2D(1,
i) * rad_inv(
i) * p2D(0,
j) * rad_inv(
j);
197 cov_cart(
i +
n,
j) = -cov_rad(
i,
j) * p2D(0,
i) * rad_inv(
i) * p2D(1,
j) * rad_inv(
j);
198 cov_cart(
j,
i) = cov_cart(
i,
j);
199 cov_cart(
j +
n,
i +
n) = cov_cart(
i +
n,
j +
n);
200 cov_cart(
j +
n,
i) = cov_cart(
i,
j +
n);
201 cov_cart(
j,
i +
n) = cov_cart(
i +
n,
j);
217 template <
typename TAcc,
typename M2xN,
int N>
220 const Matrix2Nd<N>& cov_cart,
221 const VectorNd<N>& rad) {
224 const VectorNd<N> rad_inv2 = rad.cwiseInverse().array().square();
228 cov_rad(
i) = cov_cart(
i,
i);
230 cov_rad(
i) = rad_inv2(
i) * (cov_cart(
i,
i) *
sqr(p2D(1,
i)) + cov_cart(
i +
n,
i +
n) *
sqr(p2D(0,
i)) -
231 2. * cov_cart(
i,
i +
n) * p2D(0,
i) * p2D(1,
i));
249 template <
typename TAcc,
typename M2xN,
typename V4,
int N>
251 const TAcc& acc,
const M2xN& p2D,
const Matrix2Nd<N>& cov_cart, V4&
fast_fit,
const VectorNd<N>& rad) {
257 cov_rad(
i) = cov_cart(
i,
i);
261 const double x2 =
a.dot(
b);
263 const double tan_c = -
y2 / x2;
264 const double tan_c2 =
sqr(tan_c);
266 1. / (1. + tan_c2) * (cov_cart(
i,
i) + cov_cart(
i +
n,
i +
n) * tan_c2 + 2 * cov_cart(
i,
i +
n) * tan_c);
283 template <
typename TAcc,
int N>
284 ALPAKA_FN_ACC ALPAKA_FN_INLINE VectorNd<N>
weightCircle(
const TAcc& acc,
const MatrixNd<N>& cov_rad_inv) {
285 return cov_rad_inv.colwise().sum().transpose();
296 template <
typename TAcc,
typename M2xN>
297 ALPAKA_FN_ACC ALPAKA_FN_INLINE int32_t
charge(
const TAcc& acc,
const M2xN& p2D,
const Vector3d& par_uvr) {
298 return ((p2D(0, 1) - p2D(0, 0)) * (par_uvr.y() - p2D(1, 0)) - (p2D(1, 1) - p2D(1, 0)) * (par_uvr.x() - p2D(0, 0)) >
318 template <
typename TAcc>
321 printf(
"min_eigen3D - enter\n");
323 Eigen::SelfAdjointEigenSolver<Matrix3d> solver(3);
324 solver.computeDirect(
A);
326 chi2 = solver.eigenvalues().minCoeff(&min_index);
328 printf(
"min_eigen3D - exit\n");
330 return solver.eigenvectors().col(min_index);
344 template <
typename TAcc>
346 Eigen::SelfAdjointEigenSolver<Matrix3f> solver(3);
347 solver.computeDirect(
A.cast<
float>());
349 solver.eigenvalues().minCoeff(&min_index);
350 return solver.eigenvectors().col(min_index).cast<
double>();
362 template <
typename TAcc>
364 Eigen::SelfAdjointEigenSolver<Matrix2d> solver(2);
365 solver.computeDirect(aMat);
367 chi2 = solver.eigenvalues().minCoeff(&min_index);
368 return solver.eigenvectors().col(min_index);
384 template <
typename TAcc,
typename M3xN,
typename V4>
386 constexpr uint32_t
N = M3xN::ColsAtCompileTime;
394 printIt(&bVec,
"Fast_fit - b: ");
395 printIt(&cVec,
"Fast_fit - c: ");
397 auto b2 = bVec.squaredNorm();
398 auto c2 = cVec.squaredNorm();
406 auto bx =
flip ? bVec.y() : bVec.x();
407 auto by =
flip ? bVec.x() : bVec.y();
408 auto cx =
flip ? cVec.y() : cVec.x();
409 auto cy =
flip ? cVec.x() : cVec.y();
411 auto div = 2. * (cx * by -
bx * cy);
413 auto y0 = (cx *
b2 -
bx * c2) / div;
414 auto x0 = (0.5 *
b2 - y0 * by) /
bx;
464 template <
typename TAcc,
typename M2xN,
typename V4,
int N>
465 ALPAKA_FN_ACC ALPAKA_FN_INLINE CircleFit
circleFit(
const TAcc& acc,
467 const Matrix2Nd<N>& hits_cov2D,
469 const VectorNd<N>& rad,
473 printf(
"circle_fit - enter\n");
476 Matrix2Nd<N> vMat = hits_cov2D;
478 printIt(&hits2D,
"circle_fit - hits2D:");
479 printIt(&hits_cov2D,
"circle_fit - hits_cov2D:");
482 printf(
"circle_fit - WEIGHT COMPUTATION\n");
491 printIt(&scatterCovRadMat,
"circle_fit - scatter_cov_rad:");
492 printIt(&hits2D,
"circle_fit - hits2D bis:");
494 printf(
"Address of hits2D: a) %p\n", &hits2D);
497 printIt(&vMat,
"circle_fit - V:");
498 cov_rad += scatterCovRadMat;
499 printIt(&cov_rad,
"circle_fit - cov_rad:");
510 printf(
"circle_fit - SPACE TRANSFORMATION\n");
515 printf(
"Address of hits2D: b) %p\n", &hits2D);
517 const Vector2d hCentroid = hits2D.rowwise().mean();
518 printIt(&hCentroid,
"circle_fit - h_:");
520 p3D.block(0, 0, 2,
n) = hits2D.colwise() - hCentroid;
521 printIt(&p3D,
"circle_fit - p3D: a)");
523 mc << p3D.row(0).transpose(), p3D.row(1).transpose();
524 printIt(&
mc,
"circle_fit - mc(centered hits):");
527 const double tempQ =
mc.squaredNorm();
528 const double tempS =
sqrt(
n * 1. / tempQ);
529 p3D.block(0, 0, 2,
n) *= tempS;
532 p3D.row(2) = p3D.block(0, 0, 2,
n).colwise().squaredNorm();
533 printIt(&p3D,
"circle_fit - p3D: b)");
536 printf(
"circle_fit - COST FUNCTION\n");
542 r0.noalias() = p3D *
weight;
543 const Matrix3xNd<N> xMat = p3D.colwise() - r0;
544 Matrix3d aMat = xMat * gMat * xMat.transpose();
545 printIt(&aMat,
"circle_fit - A:");
548 printf(
"circle_fit - MINIMIZE\n");
554 printf(
"circle_fit - AFTER MIN_EIGEN\n");
556 printIt(&vVec,
"v BEFORE INVERSION");
557 vVec *= (vVec(2) > 0) ? 1 : -1;
558 printIt(&vVec,
"v AFTER INVERSION");
562 printf(
"circle_fit - AFTER MIN_EIGEN 1\n");
564 Eigen::Matrix<double, 1, 1> cm;
566 printf(
"circle_fit - AFTER MIN_EIGEN 2\n");
568 cm = -vVec.transpose() * r0;
570 printf(
"circle_fit - AFTER MIN_EIGEN 3\n");
572 const double tempC = cm(0, 0);
575 printf(
"circle_fit - COMPUTE CIRCLE PARAMETER\n");
580 const double tempH =
sqrt(1. -
sqr(vVec(2)) - 4. * tempC * vVec(2));
581 const double v2x2_inv = 1. / (2. * vVec(2));
582 const double s_inv = 1. / tempS;
584 par_uvr << -vVec(0) * v2x2_inv, -vVec(1) * v2x2_inv, tempH * v2x2_inv;
587 circle.par << par_uvr(0) * s_inv + hCentroid(0), par_uvr(1) * s_inv + hCentroid(1), par_uvr(2) * s_inv;
588 circle.qCharge =
charge(acc, hits2D, circle.par);
589 circle.chi2 =
abs(
chi2) * renorm /
sqr(2 * vVec(2) * par_uvr(2) * tempS);
590 printIt(&circle.par,
"circle_fit - CIRCLE PARAMETERS:");
591 printIt(&circle.cov,
"circle_fit - CIRCLE COVARIANCE:");
593 printf(
"circle_fit - CIRCLE CHARGE: %d\n", circle.qCharge);
597 printf(
"circle_fit - ERROR PROPAGATION\n");
602 printf(
"circle_fit - ERROR PRPAGATION ACTIVATED\n");
604 ArrayNd<N> vcsMat[2][2];
605 MatrixNd<N> cMat[3][3];
607 printf(
"circle_fit - ERROR PRPAGATION ACTIVATED 2\n");
610 Eigen::Matrix<double, 1, 1> cm;
611 Eigen::Matrix<double, 1, 1> cm2;
612 cm =
mc.transpose() * vMat *
mc;
613 const double tempC2 = cm(0, 0);
614 Matrix2Nd<N> tempVcsMat;
615 tempVcsMat.template triangularView<Eigen::Upper>() =
616 (
sqr(tempS) * vMat +
sqr(
sqr(tempS)) * 1. / (4. * tempQ *
n) *
617 (2. * vMat.squaredNorm() + 4. * tempC2) *
618 (
mc *
mc.transpose()));
620 printIt(&tempVcsMat,
"circle_fit - Vcs:");
621 cMat[0][0] = tempVcsMat.block(0, 0,
n,
n).template selfadjointView<Eigen::Upper>();
622 vcsMat[0][1] = tempVcsMat.block(0,
n,
n,
n);
623 cMat[1][1] = tempVcsMat.block(
n,
n,
n,
n).template selfadjointView<Eigen::Upper>();
624 vcsMat[1][0] = vcsMat[0][1].transpose();
625 printIt(&tempVcsMat,
"circle_fit - Vcs:");
631 const ArrayNd<N> t00 = p3D.row(0).transpose() * p3D.row(0);
632 const ArrayNd<N> t01 = p3D.row(0).transpose() * p3D.row(1);
633 const ArrayNd<N> t11 = p3D.row(1).transpose() * p3D.row(1);
634 const ArrayNd<N> t10 = t01.transpose();
635 vcsMat[0][0] = cMat[0][0];
636 cMat[0][1] = vcsMat[0][1];
637 cMat[0][2] = 2. * (vcsMat[0][0] *
t0 + vcsMat[0][1] *
t1);
638 vcsMat[1][1] = cMat[1][1];
639 cMat[1][2] = 2. * (vcsMat[1][0] *
t0 + vcsMat[1][1] *
t1);
641 tmp.template triangularView<Eigen::Upper>() =
642 (2. * (vcsMat[0][0] * vcsMat[0][0] + vcsMat[0][0] * vcsMat[0][1] + vcsMat[1][1] * vcsMat[1][0] +
643 vcsMat[1][1] * vcsMat[1][1]) +
644 4. * (vcsMat[0][0] * t00 + vcsMat[0][1] * t01 + vcsMat[1][0] * t10 + vcsMat[1][1] * t11))
646 cMat[2][2] =
tmp.template selfadjointView<Eigen::Upper>();
648 printIt(&cMat[0][0],
"circle_fit - C[0][0]:");
653 Eigen::Matrix<double, 1, 1>
tmp;
656 const double tempC =
tmp(0, 0);
658 c0Mat(
j,
i) = c0Mat(
i,
j);
661 printIt(&c0Mat,
"circle_fit - C0:");
664 const MatrixNd<N> hMat = MatrixNd<N>::Identity().rowwise() -
weight.transpose();
665 const MatrixNx3d<N> s_v = hMat * p3D.transpose();
666 printIt(&wMat,
"circle_fit - W:");
667 printIt(&hMat,
"circle_fit - H:");
668 printIt(&s_v,
"circle_fit - s_v:");
670 MatrixNd<N> dMat[3][3];
671 dMat[0][0] = (hMat * cMat[0][0] * hMat.transpose()).cwiseProduct(wMat);
672 dMat[0][1] = (hMat * cMat[0][1] * hMat.transpose()).cwiseProduct(wMat);
673 dMat[0][2] = (hMat * cMat[0][2] * hMat.transpose()).cwiseProduct(wMat);
674 dMat[1][1] = (hMat * cMat[1][1] * hMat.transpose()).cwiseProduct(wMat);
675 dMat[1][2] = (hMat * cMat[1][2] * hMat.transpose()).cwiseProduct(wMat);
676 dMat[2][2] = (hMat * cMat[2][2] * hMat.transpose()).cwiseProduct(wMat);
677 dMat[1][0] = dMat[0][1].transpose();
678 dMat[2][0] = dMat[0][2].transpose();
679 dMat[2][1] = dMat[1][2].transpose();
680 printIt(&dMat[0][0],
"circle_fit - D_[0][0]:");
682 constexpr uint nu[6][2] = {{0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 2}};
686 const uint i = nu[
a][0],
j = nu[
a][1];
688 const uint k = nu[
b][0],
l = nu[
b][1];
692 t0 = 2. * dMat[
j][
l] * s_v.col(
l);
696 t1 = 2. * dMat[
i][
l] * s_v.col(
l);
698 t0 = dMat[
j][
l] * s_v.col(
k) + dMat[
j][
k] * s_v.col(
l);
702 t1 = dMat[
i][
l] * s_v.col(
k) + dMat[
i][
k] * s_v.col(
l);
706 Eigen::Matrix<double, 1, 1> cm;
707 cm = s_v.col(
i).transpose() * (
t0 +
t1);
709 const double tempC = cm(0, 0);
710 eMat(
a,
b) = 0. + tempC;
712 Eigen::Matrix<double, 1, 1> cm;
713 cm = (s_v.col(
i).transpose() *
t0) + (s_v.col(
j).transpose() *
t1);
715 const double tempC = cm(0, 0);
716 eMat(
a,
b) = 0. + tempC;
719 eMat(
b,
a) = eMat(
a,
b);
722 printIt(&eMat,
"circle_fit - E:");
724 Eigen::Matrix<double, 3, 6> j2Mat;
726 const uint i = nu[
a][0],
j = nu[
a][1];
730 const int sign = (j2Mat.col(
a)(2) > 0) ? 1 : -1;
733 printIt(&j2Mat,
"circle_fit - J2:");
737 Matrix3d t0 = j2Mat * eMat * j2Mat.transpose();
739 cvcMat.block(0, 0, 3, 3) =
t0;
740 cvcMat.block(0, 3, 3, 1) =
t1;
741 cvcMat.block(3, 0, 1, 3) =
t1.transpose();
742 Eigen::Matrix<double, 1, 1> cm1;
743 Eigen::Matrix<double, 1, 1> cm3;
744 cm1 = (vVec.transpose() * c0Mat * vVec);
746 cm3 = (r0.transpose() *
t0 * r0);
748 const double tempC = cm1(0, 0) + (c0Mat.cwiseProduct(
t0)).sum() + cm3(0, 0);
749 cvcMat(3, 3) = tempC;
752 printIt(&cvcMat,
"circle_fit - Cvc:");
754 Eigen::Matrix<double, 3, 4> j3Mat;
756 const double t = 1. / tempH;
757 j3Mat << -v2x2_inv, 0, vVec(0) *
sqr(v2x2_inv) * 2., 0, 0, -v2x2_inv, vVec(1) *
sqr(v2x2_inv) * 2., 0,
758 vVec(0) * v2x2_inv *
t, vVec(1) * v2x2_inv *
t,
759 -tempH *
sqr(v2x2_inv) * 2. - (2. * tempC + vVec(2)) * v2x2_inv *
t, -
t;
761 printIt(&j3Mat,
"circle_fit - J3:");
763 const RowVector2Nd<N> Jq =
mc.transpose() * tempS * 1. /
n;
764 printIt(&Jq,
"circle_fit - Jq:");
766 Matrix3d cov_uvr = j3Mat * cvcMat * j3Mat.transpose() *
sqr(s_inv)
767 + (par_uvr * par_uvr.transpose()) * (Jq * vMat * Jq.transpose());
769 circle.cov = cov_uvr;
772 printIt(&circle.cov,
"Circle cov:");
774 printf(
"circle_fit - exit\n");
795 template <
typename TAcc,
typename M3xN,
typename M6xN,
typename V4>
796 ALPAKA_FN_ACC ALPAKA_FN_INLINE LineFit
lineFit(
const TAcc& acc,
799 const CircleFit& circle,
803 constexpr uint32_t
N = M3xN::ColsAtCompileTime;
809 Eigen::Matrix<double, 2, 2>
rot;
820 Matrix2xNd<N> p2D = Matrix2xNd<N>::Zero();
821 Eigen::Matrix<double, 2, 6> jxMat;
824 printf(
"Line_fit - B: %g\n",
bField);
826 printIt(&hits_ge,
"Line_fit covs: ");
834 const Vector2d oVec(circle.par(0), circle.par(1));
842 const double dot = (-oVec).
dot(pVec);
845 const double tempQAtan2 = -circle.qCharge * atan2(
cross,
dot);
847 p2D(0,
i) = tempQAtan2 * circle.par(2);
850 const double temp0 = -circle.qCharge * circle.par(2) * 1. / (
sqr(
dot) +
sqr(
cross));
851 double d_X0 = 0., d_Y0 = 0., d_R = 0.;
853 d_X0 = -temp0 * ((pVec(1) + oVec(1)) *
dot - (pVec(0) - oVec(0)) *
cross);
854 d_Y0 = temp0 * ((pVec(0) + oVec(0)) *
dot - (oVec(1) - pVec(1)) *
cross);
857 const double d_x = temp0 * (oVec(1) *
dot + oVec(0) *
cross);
858 const double d_y = temp0 * (-oVec(0) *
dot + oVec(1) *
cross);
859 jxMat << d_X0, d_Y0, d_R,
d_x,
d_y, 0., 0., 0., 0., 0., 0., 1.;
861 covMat.block(0, 0, 3, 3) = circle.cov;
862 covMat(3, 3) = hits_ge.col(
i)[0];
863 covMat(4, 4) = hits_ge.col(
i)[2];
864 covMat(5, 5) = hits_ge.col(
i)[5];
865 covMat(3, 4) = covMat(4, 3) = hits_ge.col(
i)[1];
866 covMat(3, 5) = covMat(5, 3) = hits_ge.col(
i)[3];
867 covMat(4, 5) = covMat(5, 4) = hits_ge.col(
i)[4];
869 cov_sz[
i].noalias() =
rot *
tmp *
rot.transpose();
872 p2D.row(1) =
hits.row(2);
876 MatrixNd<N> cov_with_ms;
879 printIt(cov_sz,
"line_fit - cov_sz:");
880 printIt(&cov_with_ms,
"line_fit - cov_with_ms: ");
884 Matrix2xNd<N> p2D_rot =
rot * p2D;
887 printf(
"Fast fit Tan(theta): %g\n",
fast_fit(3));
888 printf(
"Rotation angle: %g\n",
theta);
890 printIt(&p2D,
"Original Hits(s,z):");
891 printIt(&p2D_rot,
"Rotated hits(S3D, Z'):");
897 aMat << MatrixXd::Ones(1,
n), p2D_rot.row(0);
904 MatrixNd<N> vyInvMat;
907 Eigen::Matrix<double, 2, 2> covParamsMat = aMat * vyInvMat * aMat.transpose();
914 Eigen::Matrix<double, 2, 1>
sol = covParamsMat * aMat * vyInvMat * p2D_rot.row(1).transpose();
923 auto common_factor = 1. / (sinTheta -
sol(1, 0) * cosTheta);
924 Eigen::Matrix<double, 2, 2> jMat;
925 jMat << 0., common_factor * common_factor, common_factor,
sol(0, 0) * cosTheta * common_factor * common_factor;
927 double tempM = common_factor * (
sol(1, 0) * sinTheta + cosTheta);
928 double tempQ = common_factor *
sol(0, 0);
929 auto cov_mq = jMat * covParamsMat * jMat.transpose();
931 VectorNd<N>
res = p2D_rot.row(1).transpose() - aMat.transpose() *
sol;
932 double chi2 =
res.transpose() * vyInvMat *
res;
935 line.par << tempM, tempQ;
940 printf(
"Common_factor: %g\n", common_factor);
943 printIt(&covParamsMat,
"Cov_params:");
944 printIt(&cov_mq,
"Rotated Covariance Matrix:");
947 printf(
"Chi2: %g\n",
chi2);
992 template <
typename TAcc>
993 ALPAKA_FN_ACC ALPAKA_FN_INLINE
void operator()(
const TAcc& acc,
995 const Eigen::Matrix<float, 6, N>* hits_ge,
1016 helix->
cov = MatrixXd::Zero(5, 5);
1017 helix->
cov.block(0, 0, 3, 3) = circle.
cov;
1018 helix->
cov.block(3, 3, 2, 2) =
line.cov;
1028 #endif // RecoTracker_PixelTrackFitting_interface_alpaka_RiemannFit_h
Basic3DVector cross(const Basic3DVector &v) const
Vector product, or "cross" product, with a vector of same type.
ALPAKA_FN_ACC ALPAKA_FN_INLINE void computeRadLenUniformMaterial(const TAcc &acc, const VNd1 &length_values, VNd2 &rad_lengths)
int32_t qCharge
particle charge
ALPAKA_FN_ACC ALPAKA_FN_INLINE VectorNd< N > cov_carttorad_prefit(const TAcc &acc, const M2xN &p2D, const Matrix2Nd< N > &cov_cart, V4 &fast_fit, const VectorNd< N > &rad)
Transform covariance matrix from Cartesian coordinates (only transverse plane component) to coordinat...
ALPAKA_FN_ACC ALPAKA_FN_INLINE LineFit lineFit(const TAcc &acc, const M3xN &hits, const M6xN &hits_ge, const CircleFit &circle, const V4 &fast_fit, const double bField, const bool error)
Perform an ordinary least square fit in the s-z plane to compute the parameters cotTheta and Zip...
ALPAKA_FN_ACC void loadCovariance2D(const TAcc &acc, M6xNf const &ge, M2Nd &hits_cov)
ret
prodAgent to be discontinued
Vector5d par
(phi,Tip,pt,cotan(theta)),Zip)
Sin< T >::type sin(const T &t)
ALPAKA_FN_ACC ALPAKA_FN_INLINE double cross2D(const TAcc &acc, const Vector2d &a, const Vector2d &b)
Compute cross product of two 2D vector (assuming z component 0), returning z component of the result...
ALPAKA_FN_ACC ALPAKA_FN_INLINE void par_uvrtopak(const TAcc &acc, CircleFit &circle, const double B, const bool error)
Transform circle parameter from (X0,Y0,R) to (phi,Tip,p_t) and consequently covariance matrix...
Vector3d par
parameter: (X0,Y0,R)
constexpr T sqr(const T a)
raise to square.
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
ALPAKA_FN_ACC ALPAKA_FN_INLINE void fastFit(const TAcc &acc, const M3xN &hits, V4 &result)
A very fast helix fit: it fits a circle by three points (first, middle and last point) and a line by ...
Eigen::Matrix< double, 6, 6 > Matrix6d
ALPAKA_FN_ACC ALPAKA_FN_INLINE VectorNd< N > weightCircle(const TAcc &acc, const MatrixNd< N > &cov_rad_inv)
Compute the points' weights' vector for the circle fit when multiple scattering is managed...
Eigen::Matrix< double, N, 1 > VectorNd
int32_t qCharge
particle charge
ALPAKA_FN_ACC ALPAKA_FN_INLINE void operator()(const TAcc &acc, const Matrix3xNd< N > *hits, const Eigen::Matrix< float, 6, N > *hits_ge, const double bField, const bool error, HelixFit *helix) const
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
Eigen::Matrix< double, 3, N > Matrix3xNd
ALPAKA_FN_ACC ALPAKA_FN_INLINE MatrixNd< N > scatter_cov_rad(const TAcc &acc, const M2xN &p2D, const V4 &fast_fit, VectorNd< N > const &rad, double B)
Compute the covariance matrix (in radial coordinates) of points in the transverse plane due to multip...
ALPAKA_FN_ACC ALPAKA_FN_INLINE void const M3xN const V4 & fast_fit
Eigen::Matrix< double, 2 *N, 2 *N > Matrix2Nd
ALPAKA_FN_ACC ALPAKA_FN_INLINE int32_t charge(const TAcc &acc, const M2xN &p2D, const Vector3d &par_uvr)
Find particle q considering the sign of cross product between particles velocity (estimated by the fi...
ALPAKA_FN_ACC void printIt(const TAcc &acc, C *m, const char *prefix="")
Helix fit by three step: -fast pre-fit (see Fast_fit() for further info); -circle fit of hits proje...
riemannFit::Vector2d eVec
ALPAKA_FN_ACC ALPAKA_FN_INLINE auto scatterCovLine(const TAcc &acc, Matrix2d const *cov_sz, const V4 &fast_fit, VNd1 const &s_arcs, VNd2 const &z_values, const double theta, const double bField, MatrixNd< N > &ret)
Compute the covariance matrix along cartesian S-Z of points due to multiple Coulomb scattering to be ...
ALPAKA_FN_ACC ALPAKA_FN_INLINE Vector3d min_eigen3D(const TAcc &acc, const Matrix3d &A, double &chi2)
Compute the eigenvector associated to the minimum eigenvalue.
ALPAKA_FN_ACC ALPAKA_FN_INLINE CircleFit circleFit(const TAcc &acc, const M2xN &hits2D, const Matrix2Nd< N > &hits_cov2D, const V4 &fast_fit, const VectorNd< N > &rad, const double bField, const bool error)
Fit a generic number of 2D points with a circle using Riemann-Chernov algorithm. Covariance matrix of...
ALPAKA_FN_ACC ALPAKA_FN_INLINE VectorNd< N > cov_carttorad(const TAcc &acc, const M2xN &p2D, const Matrix2Nd< N > &cov_cart, const VectorNd< N > &rad)
Transform covariance matrix from Cartesian coordinates (only transverse plane component) to radial co...
ALPAKA_FN_ACC ALPAKA_FN_INLINE Matrix2Nd< N > cov_radtocart(const TAcc &acc, const M2xN &p2D, const MatrixNd< N > &cov_rad, const VectorNd< N > &rad)
Transform covariance matrix from radial (only tangential component) to Cartesian coordinates (only tr...
Geom::Theta< T > theta() const
ALPAKA_FN_ACC ALPAKA_FN_INLINE Vector2d min_eigen2D(const TAcc &acc, const Matrix2d &aMat, double &chi2)
2D version of min_eigen3D().
ALPAKA_FN_ACC ALPAKA_FN_INLINE Vector3d min_eigen3D_fast(const TAcc &acc, const Matrix3d &A)
A faster version of min_eigen3D() where double precision is not needed.