31 using namespace Eigen;
41 GblPoint::GblPoint(
const Matrix5d &aJacobian) :
42 theLabel(0), theOffset(0), p2pJacobian(aJacobian), measDim(0),
43 measPrecMin(0.), transFlag(
false), measTransformation(), scatFlag(
false),
44 localDerivatives(), globalLabels(), globalDerivatives()
48 #ifdef GBL_EIGEN_SUPPORT_ROOT 60 for (
unsigned int i = 0;
i < 5; ++
i) {
61 for (
unsigned int j = 0; j < 5; ++j) {
71 #ifdef GBL_EIGEN_SUPPORT_ROOT 82 const TVectorD &aResiduals,
const TVectorD &aPrecision,
83 double minPrecision) {
84 measDim = aResiduals.GetNrows();
86 unsigned int iOff = 5 -
measDim;
90 for (
unsigned int j = 0; j <
measDim; ++j) {
107 const TVectorD &aResiduals,
const TMatrixDSym &aPrecision,
108 double minPrecision) {
109 measDim = aResiduals.GetNrows();
111 TMatrixDSymEigen measEigen(aPrecision);
113 tmpTransformation = measEigen.GetEigenVectors();
114 tmpTransformation.T();
116 TVectorD transResiduals = tmpTransformation * aResiduals;
117 TVectorD transPrecision = measEigen.GetEigenValues();
118 TMatrixD transProjection = tmpTransformation * aProjection;
120 unsigned int iOff = 5 -
measDim;
124 for (
unsigned int j = 0; j <
measDim; ++j) {
140 const TVectorD &aPrecision,
double minPrecision) {
141 measDim = aResiduals.GetNrows();
143 unsigned int iOff = 5 -
measDim;
161 const TMatrixDSym &aPrecision,
double minPrecision) {
162 measDim = aResiduals.GetNrows();
164 TMatrixDSymEigen measEigen(aPrecision);
166 tmpTransformation = measEigen.GetEigenVectors();
167 tmpTransformation.T();
169 TVectorD transResiduals = tmpTransformation * aResiduals;
170 TVectorD transPrecision = measEigen.GetEigenValues();
172 unsigned int iOff = 5 -
measDim;
176 for (
unsigned int j = 0; j <
measDim; ++j) {
224 aTransformation.setIdentity();
228 #ifdef GBL_EIGEN_SUPPORT_ROOT 238 const TVectorD &aPrecision) {
264 const TMatrixDSym &aPrecision) {
266 TMatrixDSymEigen scatEigen(aPrecision);
267 TMatrixD aTransformation = scatEigen.GetEigenVectors();
269 TVectorD transResiduals = aTransformation * aResiduals;
270 TVectorD transPrecision = scatEigen.GetEigenValues();
272 for (
unsigned int i = 0;
i < 2; ++
i) {
275 for (
unsigned int j = 0; j < 2; ++j) {
299 const Vector2d& aPrecision) {
318 Vector2d &aPrecision)
const {
332 aTransformation.setIdentity();
336 #ifdef GBL_EIGEN_SUPPORT_ROOT 344 unsigned int numDer = aDerivatives.GetNcols();
347 MatrixXd tmpDerivatives(
measDim, numDer);
349 for (
unsigned int j = 0; j < numDer; ++j)
350 tmpDerivatives(
i, j) = aDerivatives(
i, j);
371 #ifdef GBL_EIGEN_SUPPORT_ROOT 379 const TMatrixD &aDerivatives) {
382 unsigned int numDer = aDerivatives.GetNcols();
385 MatrixXd tmpDerivatives(
measDim, numDer);
387 for (
unsigned int j = 0; j < numDer; ++j)
388 tmpDerivatives(
i, j) = aDerivatives(
i, j);
428 std::vector<int> &aLabels, std::vector<double> &aDerivatives)
const {
476 Matrix23d CA = aJac.block<2, 3>(3, 0) * aJac.block<3, 3>(0, 0).inverse();
477 Matrix2d DCAB = aJac.block<2, 2>(3, 3) - CA * aJac.block<3, 2>(0, 3);
478 Matrix2d DCABInv = DCAB.inverse();
502 Vector2d &vecWd)
const {
506 if (aDirection < 1) {
516 if (!matW.determinant()) {
517 std::cout <<
" GblPoint::getDerivatives failed to invert matrix " 520 <<
" Possible reason for singular matrix: multiple GblPoints at same arc-length" 522 throw std::overflow_error(
"Singular matrix inversion exception");
524 matW = matW.inverse().eval();
558 IOFormat CleanFmt(4, 0,
", ",
"\n",
"[",
"]");
560 std::cout <<
" Measurement" << std::endl;
561 std::cout <<
" Projection: " << std::endl
576 std::cout <<
" Local Derivatives:" << std::endl
589 std::cout <<
" Point-to-point " << std::endl
592 std::cout <<
" To previous offset " << std::endl
594 std::cout <<
" To next offset " << std::endl
const Eigen::MatrixXd & getLocalDerivatives() const
Retrieve local derivatives from a point.
void addNextJacobian(const Matrix5d &aJac)
Define jacobian to next scatterer (by GBLTrajectory constructor)
void getGlobalDerivatives(Eigen::MatrixXd &aDerivatives) const
Retrieve global derivatives from a point.
Vector5d measResiduals
Measurement residuals.
void setLabel(unsigned int aLabel)
Define label of point (by GBLTrajectory constructor)
bool transFlag
Transformation exists?
bool scatFlag
Scatterer present?
void setOffset(int anOffset)
Define offset for point (by GBLTrajectory constructor)
int theOffset
Offset number at point if not negative (else interpolation needed)
GblPoint(const Matrix5d &aJacobian)
Create a point.
Eigen::Vector2d scatPrecision
Scattering precision (diagonal of inverse covariance matrix)
bool hasScatterer() const
Check for scatterer at a point.
unsigned int getLabel() const
Retrieve label of point.
double measPrecMin
Minimal measurement precision (for usage)
void addGlobals(const std::vector< int > &aLabels, const Eigen::MatrixBase< Derivative > &aDerivatives)
Add global derivatives to a point.
void addLocals(const Eigen::MatrixBase< Derivative > &aDerivatives)
Add local derivatives to a point.
double getMeasPrecMin() const
get precision cutoff.
unsigned int measDim
Dimension of measurement (1-5), 0 indicates absence of measurement.
void getMeasurement(Matrix5d &aProjection, Vector5d &aResiduals, Vector5d &aPrecision) const
Retrieve measurement of a point.
int getOffset() const
Retrieve offset for point.
unsigned int hasMeasurement() const
Check for measurement at a point.
Eigen::MatrixXd globalDerivatives
Derivatives of measurement vs additional global (MP-II) parameters.
Eigen::MatrixXd localDerivatives
Derivatives of measurement vs additional local (fit) parameters.
void getGlobalLabels(std::vector< int > &aLabels) const
Retrieve global derivatives labels from a point.
void getGlobalLabelsAndDerivatives(unsigned int aRow, std::vector< int > &aLabels, std::vector< double > &aDerivatives) const
Retrieve global derivatives from a point for a single row.
void printPoint(unsigned int level=0) const
Print GblPoint.
std::vector< int > globalLabels
Labels of global (MP-II) derivatives.
void addScatterer(const Eigen::Vector2d &aResiduals, const Eigen::MatrixBase< Precision > &aPrecision)
Add a (thin) scatterer to a point.
Namespace for the general broken lines package.
unsigned int getNumLocals() const
Retrieve number of local derivatives from a point.
Matrix5d nextJacobian
Jacobian to next scatterer (or last measurement)
void getMeasTransformation(Eigen::MatrixXd &aTransformation) const
Get measurement transformation (from diagonalization).
Eigen::Matrix2d scatTransformation
Transformation of diagonalization (of scat. precision matrix)
Eigen::Matrix< double, 5, 1 > Vector5d
Eigen::Matrix< double, 2, 3 > Matrix23d
Vector5d measPrecision
Measurement precision (diagonal of inverse covariance matrix)
void getDerivatives(int aDirection, Eigen::Matrix2d &matW, Eigen::Matrix2d &matWJ, Eigen::Vector2d &vecWd) const
Retrieve derivatives of local track model.
Eigen::Vector2d scatResiduals
Scattering residuals (initial kinks if iterating)
Matrix5d measProjection
Projection from measurement to local system.
void getScatTransformation(Eigen::Matrix2d &aTransformation) const
Get scatterer transformation (from diagonalization).
void addMeasurement(const Eigen::MatrixBase< Projection > &aProjection, const Eigen::MatrixBase< Residuals > &aResiduals, const Eigen::MatrixBase< Precision > &aPrecision, double minPrecision=0.)
Add a measurement to a point.
Matrix5d prevJacobian
Jacobian to previous scatterer (or first measurement)
unsigned int theLabel
Label identifying point.
void addPrevJacobian(const Matrix5d &aJac)
Define jacobian to previous scatterer (by GBLTrajectory constructor)
void getScatterer(Eigen::Matrix2d &aTransformation, Eigen::Vector2d &aResiduals, Eigen::Vector2d &aPrecision) const
Retrieve scatterer of a point.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor, 5, 5 > measTransformation
Transformation of diagonalization (of meas. precision matrix)
const Matrix5d & getP2pJacobian() const
Retrieve point-to-(previous)point jacobian.
unsigned int getNumGlobals() const
Retrieve number of global derivatives from a point.
Matrix5d p2pJacobian
Point-to-point jacobian from previous point.
Eigen::Matrix< double, 5, 5 > Matrix5d