31 using namespace Eigen;
41 GblPoint::GblPoint(
const Matrix5d &aJacobian) :
42 theLabel(0), theOffset(0), p2pJacobian(aJacobian), measDim(0), measPrecMin(
43 0.), transFlag(false), measTransformation(), scatFlag(false), localDerivatives(), globalLabels(), globalDerivatives() {
46 #ifdef GBL_EIGEN_SUPPORT_ROOT
53 theLabel(0), theOffset(0), measDim(0), measPrecMin(0.), transFlag(false),
54 measTransformation(), scatFlag(false), localDerivatives(), globalLabels(),
57 for (
unsigned int i = 0; i < 5; ++i) {
58 for (
unsigned int j = 0; j < 5; ++j) {
68 #ifdef GBL_EIGEN_SUPPORT_ROOT
79 const TVectorD &aResiduals,
const TVectorD &aPrecision,
80 double minPrecision) {
81 measDim = aResiduals.GetNrows();
83 unsigned int iOff = 5 -
measDim;
84 for (
unsigned int i = 0; i <
measDim; ++i) {
87 for (
unsigned int j = 0; j <
measDim; ++j) {
104 const TVectorD &aResiduals,
const TMatrixDSym &aPrecision,
105 double minPrecision) {
106 measDim = aResiduals.GetNrows();
108 TMatrixDSymEigen measEigen(aPrecision);
110 tmpTransformation = measEigen.GetEigenVectors();
111 tmpTransformation.T();
113 TVectorD transResiduals = tmpTransformation * aResiduals;
114 TVectorD transPrecision = measEigen.GetEigenValues();
115 TMatrixD transProjection = tmpTransformation * aProjection;
117 unsigned int iOff = 5 -
measDim;
118 for (
unsigned int i = 0; i <
measDim; ++i) {
121 for (
unsigned int j = 0; j <
measDim; ++j) {
137 const TVectorD &aPrecision,
double minPrecision) {
138 measDim = aResiduals.GetNrows();
140 unsigned int iOff = 5 -
measDim;
141 for (
unsigned int i = 0; i <
measDim; ++i) {
158 const TMatrixDSym &aPrecision,
double minPrecision) {
159 measDim = aResiduals.GetNrows();
161 TMatrixDSymEigen measEigen(aPrecision);
163 tmpTransformation = measEigen.GetEigenVectors();
164 tmpTransformation.T();
166 TVectorD transResiduals = tmpTransformation * aResiduals;
167 TVectorD transPrecision = measEigen.GetEigenValues();
169 unsigned int iOff = 5 -
measDim;
170 for (
unsigned int i = 0; i <
measDim; ++i) {
173 for (
unsigned int j = 0; j <
measDim; ++j) {
221 aTransformation.setIdentity();
225 #ifdef GBL_EIGEN_SUPPORT_ROOT
235 const TVectorD &aPrecision) {
261 const TMatrixDSym &aPrecision) {
263 TMatrixDSymEigen scatEigen(aPrecision);
264 TMatrixD aTransformation = scatEigen.GetEigenVectors();
266 TVectorD transResiduals = aTransformation * aResiduals;
267 TVectorD transPrecision = scatEigen.GetEigenValues();
269 for (
unsigned int i = 0; i < 2; ++i) {
272 for (
unsigned int j = 0; j < 2; ++j) {
291 Vector2d &aPrecision)
const {
305 aTransformation.setIdentity();
309 #ifdef GBL_EIGEN_SUPPORT_ROOT
317 unsigned int numDer = aDerivatives.GetNcols();
320 MatrixXd tmpDerivatives(
measDim, numDer);
321 for (
unsigned int i = 0; i <
measDim; ++i) {
322 for (
unsigned int j = 0; j < numDer; ++j)
323 tmpDerivatives(i, j) = aDerivatives(i, j);
344 #ifdef GBL_EIGEN_SUPPORT_ROOT
352 const TMatrixD &aDerivatives) {
355 unsigned int numDer = aDerivatives.GetNcols();
358 MatrixXd tmpDerivatives(
measDim, numDer);
359 for (
unsigned int i = 0; i <
measDim; ++i) {
360 for (
unsigned int j = 0; j < numDer; ++j)
361 tmpDerivatives(i, j) = aDerivatives(i, j);
401 std::vector<int> &aLabels, std::vector<double> &aDerivatives)
const {
449 Matrix23d CA = aJac.block<2, 3>(3, 0) * aJac.block<3, 3>(0, 0).inverse();
450 Matrix2d DCAB = aJac.block<2, 2>(3, 3) - CA * aJac.block<3, 2>(0, 3);
451 Matrix2d DCABInv = DCAB.inverse();
475 Vector2d &vecWd)
const {
479 if (aDirection < 1) {
489 if (!matW.determinant()) {
490 std::cout <<
" GblPoint::getDerivatives failed to invert matrix "
493 <<
" Possible reason for singular matrix: multiple GblPoints at same arc-length"
495 throw std::overflow_error(
"Singular matrix inversion exception");
497 matW = matW.inverse().eval();
507 std::cout <<
" GblPoint";
509 std::cout <<
", label " <<
theLabel;
515 std::cout <<
", " <<
measDim <<
" measurements";
518 std::cout <<
", scatterer";
521 std::cout <<
", diagonalized";
529 std::cout << std::endl;
531 IOFormat CleanFmt(4, 0,
", ",
"\n",
"[",
"]");
533 std::cout <<
" Measurement" << std::endl;
534 std::cout <<
" Projection: " << std::endl
536 std::cout <<
" Residuals: "
538 std::cout <<
" Precision (min.: " <<
measPrecMin <<
"): "
542 std::cout <<
" Scatterer" << std::endl;
543 std::cout <<
" Residuals: "
545 std::cout <<
" Precision: "
549 std::cout <<
" Local Derivatives:" << std::endl
553 std::cout <<
" Global Labels:";
554 for (
unsigned int i = 0; i <
globalLabels.size(); ++i) {
557 std::cout << std::endl;
558 std::cout <<
" Global Derivatives:"
561 std::cout <<
" Jacobian " << std::endl;
562 std::cout <<
" Point-to-point " << std::endl
565 std::cout <<
" To previous offset " << std::endl
567 std::cout <<
" To next offset " << std::endl
Matrix5d nextJacobian
Jacobian to next scatterer (or last measurement)
void getScatterer(Eigen::Matrix2d &aTransformation, Eigen::Vector2d &aResiduals, Eigen::Vector2d &aPrecision) const
Retrieve scatterer of a point.
std::vector< int > globalLabels
Labels of global (MP-II) derivatives.
void getDerivatives(int aDirection, Eigen::Matrix2d &matW, Eigen::Matrix2d &matWJ, Eigen::Vector2d &vecWd) const
Retrieve derivatives of local track model.
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.
const Eigen::MatrixXd & getLocalDerivatives() const
Retrieve local derivatives from a point.
Eigen::MatrixXd globalDerivatives
Derivatives of measurement vs additional global (MP-II) parameters.
void getScatTransformation(Eigen::Matrix2d &aTransformation) const
Get scatterer transformation (from diagonalization).
Eigen::Matrix2d scatTransformation
Transformation of diagonalization (of scat. precision matrix)
void printPoint(unsigned int level=0) const
Print GblPoint.
bool scatFlag
Scatterer present?
double getMeasPrecMin() const
get precision cutoff.
void addPrevJacobian(const Matrix5d &aJac)
Define jacobian to previous scatterer (by GBLTrajectory constructor)
GblPoint(const Matrix5d &aJacobian)
Create a point.
double measPrecMin
Minimal measurement precision (for usage)
Vector5d measResiduals
Measurement residuals.
unsigned int hasMeasurement() const
Check for measurement at a point.
unsigned int measDim
Dimension of measurement (1-5), 0 indicates absence of measurement.
bool transFlag
Transformation exists?
void getMeasurement(Matrix5d &aProjection, Vector5d &aResiduals, Vector5d &aPrecision) const
Retrieve measurement of a point.
bool hasScatterer() const
Check for scatterer at a point.
void addScatterer(const Eigen::Vector2d &aResiduals, const Eigen::MatrixBase< Precision > &aPrecision)
Add a (thin) scatterer to 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.
unsigned int theLabel
Label identifying point.
unsigned int getNumLocals() const
Retrieve number of local derivatives from a point.
int theOffset
Offset number at point if not negative (else interpolation needed)
void getGlobalDerivatives(Eigen::MatrixXd &aDerivatives) const
Retrieve global derivatives from a point.
void setLabel(unsigned int aLabel)
Define label of point (by GBLTrajectory constructor)
void addLocals(const Eigen::MatrixBase< Derivative > &aDerivatives)
Add local derivatives to a point.
void addGlobals(const std::vector< int > &aLabels, const Eigen::MatrixBase< Derivative > &aDerivatives)
Add global derivatives to a point.
Matrix5d measProjection
Projection from measurement to local system.
void getGlobalLabels(std::vector< int > &aLabels) const
Retrieve global derivatives labels from a point.
void addNextJacobian(const Matrix5d &aJac)
Define jacobian to next scatterer (by GBLTrajectory constructor)
unsigned int getLabel() const
Retrieve label of point.
void getMeasTransformation(Eigen::MatrixXd &aTransformation) const
Get measurement transformation (from diagonalization).
Eigen::Vector2d scatPrecision
Scattering precision (diagonal of inverse covariance matrix)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor, 5, 5 > measTransformation
Transformation of diagonalization (of meas. precision matrix)
Vector5d measPrecision
Measurement precision (diagonal of inverse covariance matrix)
Matrix5d prevJacobian
Jacobian to previous scatterer (or first measurement)
Eigen::MatrixXd localDerivatives
Derivatives of measurement vs additional local (fit) parameters.
const Matrix5d & getP2pJacobian() const
Retrieve point-to-(previous)point jacobian.
void setOffset(int anOffset)
Define offset for point (by GBLTrajectory constructor)
Eigen::Vector2d scatResiduals
Scattering residuals (initial kinks if iterating)
unsigned int getNumGlobals() const
Retrieve number of global derivatives from a point.
Matrix5d p2pJacobian
Point-to-point jacobian from previous point.
int getOffset() const
Retrieve offset for point.
Namespace for the general broken lines package.
Eigen::Matrix< double, 2, 3 > Matrix23d
Eigen::Matrix< double, 5, 1 > Vector5d
Eigen::Matrix< double, 5, 5 > Matrix5d