10#include <tracking/trackFindingCDC/numerics/JacobianMatrixUtil.h>
12#include <tracking/trackFindingCDC/numerics/PrecisionMatrix.h>
13#include <tracking/trackFindingCDC/numerics/JacobianMatrix.h>
14#include <tracking/trackFindingCDC/numerics/ParameterVector.h>
16#include <tracking/trackFindingCDC/numerics/EigenView.h>
27 namespace TrackFindingCDC {
43 mapToEigen(precision) =
44 mapToEigen(ambiguity).transpose() * mapToEigen(precision) * mapToEigen(ambiguity);
49 template <
int M,
int N>
53 return mapToEigen(ambiguity).transpose() * mapToEigen(precision) * mapToEigen(ambiguity);
73 template <
int N1,
int N2>
77 PrecisionMatrix < N1 + N2 > result;
78 mapToEigen(result) << mapToEigen(block1), Eigen::Matrix<double, N1, N2>::Zero(),
79 Eigen::Matrix<double, N2, N1>::Zero(), mapToEigen(block2);
84 template <
class APrecisionMatrix,
int I = 0,
int N = 0>
87 constexpr const int M =
88 std::remove_reference_t<
decltype(mapToEigen(APrecisionMatrix()))>::RowsAtCompileTime;
89 return precision.template block<M, M>(I, I);
111 const auto& ePrecision1 = mapToEigen(precision1);
112 const auto& ePrecision2 = mapToEigen(precision2);
113 auto&& ePrecision = mapToEigen(precision);
115 const auto& eParameter1 = mapToEigen(parameter1);
116 const auto& eParameter2 = mapToEigen(parameter2);
117 auto&& eParameter = mapToEigen(parameter);
119 ePrecision = ePrecision1 + ePrecision2;
120 eParameter = ePrecision.colPivHouseholderQr().solve(ePrecision1 * eParameter1 +
121 ePrecision2 * eParameter2);
123 auto eResidual1 = eParameter1 - eParameter;
124 auto eResidual2 = eParameter2 - eParameter;
126 Eigen::Matrix<double, 1, 1> chi2 = (eResidual1.transpose() * ePrecision1 * eResidual1 +
127 eResidual2.transpose() * ePrecision2 * eResidual2);
145 template <
int M,
int N1,
int N2>
155 const auto& eParameter1 = mapToEigen(parameter1);
156 const auto& ePrecision1 = mapToEigen(precision1);
157 const auto& eAmbiguity1 = mapToEigen(ambiguity1);
159 const auto& eParameter2 = mapToEigen(parameter2);
160 const auto& ePrecision2 = mapToEigen(precision2);
161 const auto& eAmbiguity2 = mapToEigen(ambiguity2);
163 auto&& ePrecision = mapToEigen(precision);
164 auto&& eParameter = mapToEigen(parameter);
166 ePrecision = (eAmbiguity1.transpose() * ePrecision1 * eAmbiguity1 +
167 eAmbiguity2.transpose() * ePrecision2 * eAmbiguity2);
169 eParameter = ePrecision.colPivHouseholderQr().solve(
170 eAmbiguity1.transpose() * ePrecision1 * eParameter1 +
171 eAmbiguity2.transpose() * ePrecision2 * eParameter2);
173 auto eResidual1 = eParameter1 - eAmbiguity1 * eParameter;
174 auto eResidual2 = eParameter2 - eAmbiguity2 * eParameter;
176 Eigen::Matrix<double, 1, 1> chi2 = (eResidual1.transpose() * ePrecision1 * eResidual1 +
177 eResidual2.transpose() * ePrecision2 * eResidual2);
A matrix implementation to be used as an interface typ through out the track finder.
static PlainMatrix< T, M, N > Identity()
Construct an identity matrix.
Abstract base class for different kinds of events.
static JacobianMatrix< N > scale(const ParameterVector< N > &scales)
Calculates the jacobian matrix for a scaling in each parameter.
Collection of functions related to precision matrices.
static double average(const ParameterVector< N > ¶meter1, const PrecisionMatrix< N > &precision1, const ParameterVector< N > ¶meter2, const PrecisionMatrix< N > &precision2, ParameterVector< N > ¶meter, PrecisionMatrix< N > &precision)
Averages two parameter vectors taking into account their respective precision.
static PrecisionMatrix< N1+N2 > stackBlocks(const PrecisionMatrix< N1 > &block1, const PrecisionMatrix< N2 > &block2)
Combines two precision matrices by putting them in two blocks on the diagonal of a larger matrix.
static APrecisionMatrix getSub(const PrecisionMatrix< N > &precision)
Gets a subprecision from a precision matrix.
static void transport(const JacobianMatrix< N, N > &ambiguity, PrecisionMatrix< N > &precision)
Transport the precision matrix inplace with the given jacobian matrix.
static PrecisionMatrix< M > transported(const JacobianMatrix< N, M > &ambiguity, const PrecisionMatrix< N > &precision)
Return a copy of the precision matrix transported with the given back projection jacobian matrix.
static PrecisionMatrix< N > scale(const ParameterVector< N > &scales, const PrecisionMatrix< N > &precision)
Return a copy of the precision scaled by the given factors in each parameter.
static double average(const ParameterVector< N1 > ¶meter1, const PrecisionMatrix< N1 > &precision1, const JacobianMatrix< N1, M > &ambiguity1, const ParameterVector< N2 > ¶meter2, const PrecisionMatrix< N2 > &precision2, const JacobianMatrix< N2, M > &ambiguity2, ParameterVector< M > ¶meter, PrecisionMatrix< M > &precision)
Averages two parameter vectors from a projected space taking into account their respective precisions...
static PrecisionMatrix< N > identity()
Constructs an identity matrix.
static void scale(const ParameterVector< N > &scales, PrecisionMatrix< N > &precision)
Scale the precision inplace by the given factors in each parameter.