43 theLabel(0), theOffset(0), theType(0), p2pJacobian(aJacobian), scatDim(
48#ifdef GBL_EIGEN_SUPPORT_ROOT
55 theLabel(0), theOffset(0), theType(0), scatDim(0) {
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) {
96 const TVectorD &aResiduals,
const TMatrixDSym &aPrecision,
97 double minPrecision) {
111 const TVectorD &aPrecision,
double minPrecision) {
125 const TMatrixDSym &aPrecision,
double minPrecision) {
160 const Eigen::Matrix2d &aPrecision) {
163 Eigen::SelfAdjointEigenSolver<Eigen::Matrix2d> scatEigen { aPrecision };
195 const Eigen::Vector2d &aPrecision) {
233 const Eigen::Matrix4d &aPrecision) {
236 Eigen::SelfAdjointEigenSolver<Eigen::Matrix4d> scatEigen { aPrecision };
243#ifdef GBL_EIGEN_SUPPORT_ROOT
267 const TVectorD &aPrecision) {
296 const TMatrixDSym &aPrecision) {
298 TMatrixDSymEigen scatEigen(aPrecision);
299 TMatrixD aTransformation = scatEigen.GetEigenVectors();
301 TVectorD transResiduals = aTransformation * aResiduals;
302 TVectorD transPrecision = scatEigen.GetEigenValues();
303 for (
unsigned int i = 0; i < 2; ++i) {
306 for (
unsigned int j = 0; j < 2; ++j) {
343 const TMatrixDSym &aPrecision) {
345 TMatrixDSymEigen scatEigen(aPrecision);
346 TMatrixD aTransformation = scatEigen.GetEigenVectors();
348 TVectorD transResiduals = aTransformation * aResiduals;
349 TVectorD transPrecision = scatEigen.GetEigenValues();
350 for (
unsigned int i = 0; i < 4; ++i) {
353 for (
unsigned int j = 0; j < 4; ++j) {
376 Vector4d &aPrecision)
const {
392 Vector4d &aResiduals, Vector4d &aPrecision)
const {
398 Matrix2d posPrec = scatPrec.bottomRightCorner<2, 2>()
399 - scatPrec.bottomLeftCorner<2, 2>()
400 * scatPrec.topLeftCorner<2, 2>().inverse()
401 * scatPrec.topRightCorner<2, 2>();
404 scatPrec.bottomRightCorner<2, 2>() = posPrec;
406 Eigen::SelfAdjointEigenSolver<Eigen::Matrix4d> scatEigen { scatPrec };
408 aTransformation = scatEigen.eigenvectors().transpose();
409 aResiduals = aTransformation * scatRes;
410 aPrecision = scatEigen.eigenvalues();
422 aTransformation.setIdentity();
426#ifdef GBL_EIGEN_SUPPORT_ROOT
444 const TMatrixD &aDerivatives) {
497 Matrix23d CA = aJac.block<2, 3>(3, 0) * aJac.block<3, 3>(0, 0).inverse();
498 Matrix2d DCAB = aJac.block<2, 2>(3, 3) - CA * aJac.block<3, 2>(0, 3);
499 Matrix2d DCABInv = DCAB.inverse();
523 Vector2d &vecWd)
const {
527 if (aDirection < 1) {
537 if (!matW.determinant()) {
538 std::cout <<
" GblPoint::getDerivatives failed to invert matrix "
541 <<
" Possible reason for singular matrix: multiple GblPoints at same arc-length"
543 throw std::overflow_error(
"Singular matrix inversion exception");
545 matW = matW.inverse().eval();
555 std::cout <<
" GblPoint";
557 std::cout <<
", label " <<
theLabel;
565 std::vector<GblMeasurement>::const_iterator itMeas;
568 itMeas->printMeasurement(0);
571 std::cout <<
", thin scatterer";
574 std::cout <<
", thick scatterer";
577 std::cout << std::endl;
581 itMeas->printMeasurement(level);
583 IOFormat CleanFmt(4, 0,
", ",
"\n",
"[",
"]");
585 std::cout <<
" Scatterer" << std::endl;
586 std::cout <<
" Residuals: "
589 std::cout <<
" Precision: "
593 std::cout <<
" Jacobian " << std::endl;
594 std::cout <<
" Point-to-point " << std::endl
598 std::cout <<
" To previous offset (last 2 rows)" << std::endl
602 std::cout <<
" To next offset " << std::endl
626 unsigned int aRow, std::vector<int> &aLabels,
627 std::vector<double> &aDerivatives)
const {
Matrix5d nextJacobian
Jacobian to next scatterer (or last measurement)
void getScatterer(Eigen::Matrix4d &aTransformation, Eigen::Vector4d &aResiduals, Eigen::Vector4d &aPrecision) const
Retrieve scatterer of a point.
Eigen::Matrix4d scatTransformation
Transformation of diagonalization (of scat. precision matrix)
void addThickScatterer(const Eigen::Vector4d &aResiduals, const Eigen::Matrix4d &aPrecision)
Add a thick scatterer to a point.
void getScatTransformation(Eigen::MatrixXd &aTransformation) const
Get scatterer transformation (from diagonalization).
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.
void getGlobalLabelsAndDerivatives(unsigned int aMeas, unsigned int aRow, std::vector< int > &aLabels, std::vector< double > &aDerivatives) const
Retrieve global derivatives from a measurement at a point for a single row.
void setType(int aType)
Define type for point (by GBLTrajectory constructor)
void printPoint(unsigned int level=0) const
Print GblPoint.
void addPrevJacobian(const Matrix5d &aJac)
Define jacobian to previous scatterer (by GBLTrajectory constructor)
int theType
Type (-1: first, 0: inner, 1: last)
std::vector< GblMeasurement > theMeasurements
List of measurements at point.
Eigen::Vector4d scatPrecision
Scattering precision (diagonal of inverse covariance matrix)
unsigned int numMeasurements() const
Check for measurements at a point.
void getReducedScatterer(Eigen::Matrix4d &aTransformation, Eigen::Vector4d &aResiduals, Eigen::Vector4d &aPrecision) const
Retrieve (reduced) scatterer of a point.
unsigned int theLabel
Label identifying point.
std::vector< GblMeasurement >::iterator getMeasBegin()
Get GblMeasurement iterator for begin.
unsigned int scatDim
Dimension of scatterer (0: none, 2: thin, 4:thick)
int theOffset
Offset number at point if not negative (else interpolation needed)
bool isLast() const
Is last point on (sub)trajectory?
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.
void addNextJacobian(const Matrix5d &aJac)
Define jacobian to next scatterer (by GBLTrajectory constructor)
unsigned int getScatDim() const
Get scatterer dimension.
unsigned int getLabel() const
Retrieve label of point.
GblPoint(const Matrix5d &aJacobian, unsigned int numMeasReserve=0)
Create a point.
Eigen::Vector4d scatResiduals
Scattering residuals (initial kinks if iterating)
Matrix5d prevJacobian
Jacobian to previous scatterer (or first measurement)
std::vector< GblMeasurement >::iterator getMeasEnd()
Get GblMeasurement iterator for end.
const Matrix5d & getP2pJacobian() const
Retrieve point-to-(previous)point jacobian.
void addScatterer(const Eigen::Vector2d &aResiduals, const Eigen::Matrix2d &aPrecision)
Add a thin scatterer to a point.
void setOffset(int anOffset)
Define offset for point (by GBLTrajectory constructor)
bool isFirst() const
Is first point on (sub)trajectory?
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, 5 > Matrix5d