CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
gbl::GblTrajectory Class Reference

GBL trajectory. More...

#include <GblTrajectory.h>

Public Member Functions

unsigned int fit (double &Chi2, int &Ndf, double &lostWeight, const std::string &optionList="", unsigned int aLabel=0)
 Perform fit of (valid) trajectory. More...
 
 GblTrajectory (const std::vector< GblPoint > &aPointList, bool flagCurv=true, bool flagU1dir=true, bool flagU2dir=true)
 Create new (simple) trajectory from list of points. More...
 
template<typename Seed >
 GblTrajectory (const std::vector< GblPoint > &aPointList, unsigned int aLabel, const Eigen::MatrixBase< Seed > &aSeed, bool flagCurv=true, bool flagU1dir=true, bool flagU2dir=true)
 Create new (simple) trajectory from list of points with external seed. More...
 
 GblTrajectory (const std::vector< std::pair< std::vector< GblPoint >, Eigen::MatrixXd > > &aPointsAndTransList)
 
template<typename Derivatives , typename Measurements , typename Precision , typename std::enable_if<(Measurements::ColsAtCompileTime==1)>::type * = nullptr, typename std::enable_if<(Precision::ColsAtCompileTime!=1)>::type * = nullptr>
 GblTrajectory (const std::vector< std::pair< std::vector< GblPoint >, Eigen::MatrixXd > > &aPointsAndTransList, const Eigen::MatrixBase< Derivatives > &extDerivatives, const Eigen::MatrixBase< Measurements > &extMeasurements, const Eigen::MatrixBase< Precision > &extPrecisions)
 Create new composed trajectory from list of points and transformations with (independent or correlated) external measurements. More...
 
template<typename Derivatives , typename Measurements , typename Precision , typename std::enable_if<(Measurements::ColsAtCompileTime==1)>::type * = nullptr, typename std::enable_if<(Precision::ColsAtCompileTime==1)>::type * = nullptr>
 GblTrajectory (const std::vector< std::pair< std::vector< GblPoint >, Eigen::MatrixXd > > &aPointsAndTransList, const Eigen::MatrixBase< Derivatives > &extDerivatives, const Eigen::MatrixBase< Measurements > &extMeasurements, const Eigen::MatrixBase< Precision > &extPrecisions)
 
unsigned int getLabels (std::vector< unsigned int > &aLabelList)
 Get (list of) labels of points on (simple) valid trajectory. More...
 
unsigned int getLabels (std::vector< std::vector< unsigned int > > &aLabelList)
 Get (list of lists of) labels of points on (composed) valid trajectory. More...
 
unsigned int getMeasResults (unsigned int aLabel, unsigned int &numRes, Eigen::VectorXd &aResiduals, Eigen::VectorXd &aMeasErrors, Eigen::VectorXd &aResErrors, Eigen::VectorXd &aDownWeights)
 Get residuals from fit at point for measurement. More...
 
unsigned int getNumPoints () const
 Retrieve number of point from trajectory. More...
 
unsigned int getResults (int aSignedLabel, Eigen::VectorXd &localPar, Eigen::MatrixXd &localCov) const
 Get fit results at point. More...
 
unsigned int getScatResults (unsigned int aLabel, unsigned int &numRes, Eigen::VectorXd &aResiduals, Eigen::VectorXd &aMeasErrors, Eigen::VectorXd &aResErrors, Eigen::VectorXd &aDownWeights)
 Get (kink) residuals from fit at point for scatterer. More...
 
bool isValid () const
 Retrieve validity of trajectory. More...
 
void milleOut (MilleBinary &aMille)
 Write valid trajectory to Millepede-II binary file. More...
 
void printData ()
 Print GblData blocks for trajectory. More...
 
void printPoints (unsigned int level=0)
 Print GblPoints on trajectory. More...
 
void printTrajectory (unsigned int level=0)
 Print GblTrajectory. More...
 
virtual ~GblTrajectory ()
 

Private Member Functions

void buildLinearEquationSystem ()
 Build linear equation system from data (blocks). More...
 
void calcJacobians ()
 Calculate Jacobians to previous/next scatterer from point to point ones. More...
 
void construct ()
 Construct trajectory from list of points. More...
 
void defineOffsets ()
 Define offsets from list of points. More...
 
double downWeight (unsigned int aMethod)
 Down-weight all points. More...
 
void getFitToKinkJacobian (std::array< unsigned int, 7 > &anIndex, Matrix27d &aJacobian, const GblPoint &aPoint) const
 Get jacobian for transformation from (trajectory) fit to kink parameters at point. More...
 
void getFitToLocalJacobian (std::array< unsigned int, 5 > &anIndex, Matrix5d &aJacobian, const GblPoint &aPoint, unsigned int measDim, unsigned int nJacobian=1) const
 Get (part of) jacobian for transformation from (trajectory) fit to track parameters at point. More...
 
std::pair< std::vector< unsigned int >, Eigen::MatrixXd > getJacobian (int aSignedLabel) const
 Get jacobian for transformation from fit to track parameters at point. More...
 
void getResAndErr (unsigned int aData, bool used, double &aResidual, double &aMeadsError, double &aResError, double &aDownWeight)
 Get residual and errors from data block. More...
 
void predict ()
 Calculate predictions for all points. More...
 
void prepare ()
 Prepare fit for simple or composed trajectory. More...
 

Private Attributes

bool constructOK
 Trajectory has been successfully constructed (ready for fit/output) More...
 
Eigen::MatrixXd externalDerivatives
 
Eigen::VectorXd externalMeasurements
 
unsigned int externalPoint
 Label of external point (or 0) More...
 
Eigen::VectorXd externalPrecisions
 
Eigen::MatrixXd externalSeed
 Precision (inverse covariance matrix) of external seed. More...
 
bool fitOK
 Trajectory has been successfully fitted (results are valid) More...
 
std::vector< Eigen::MatrixXd > innerTransformations
 Transformations at innermost points of. More...
 
unsigned int maxNumGlobals
 Max. number of global labels/derivatives per point. More...
 
std::vector< unsigned int > measDataIndex
 mapping points to data blocks from measurements More...
 
unsigned int numAllPoints
 Number of all points on trajectory. More...
 
unsigned int numCurvature
 Number of curvature parameters (0 or 1) or external parameters. More...
 
unsigned int numInnerTrans
 Number of inner transformations to external parameters. More...
 
unsigned int numLocals
 Total number of (additional) local parameters. More...
 
unsigned int numMeasurements
 Total number of measurements. More...
 
unsigned int numOffsets
 Number of (points with) offsets on trajectory. More...
 
unsigned int numParameters
 Number of fit parameters. More...
 
std::vector< unsigned int > numPoints
 Number of points on (sub)trajectory. More...
 
unsigned int numTrajectories
 Number of trajectories (in composed trajectory) More...
 
std::vector< unsigned int > scatDataIndex
 mapping points to data blocks from scatterers More...
 
unsigned int skippedMeasLabel
 Label of point with measurements skipped in fit (for unbiased residuals) (or 0) More...
 
std::vector< GblDatatheData
 List of data blocks. More...
 
std::vector< unsigned int > theDimension
 List of active dimensions (0=u1, 1=u2) in fit. More...
 
BorderedBandMatrix theMatrix
 (Bordered band) matrix of linear equation system More...
 
std::vector< std::vector< GblPoint > > thePoints
 (list of) List of points on trajectory More...
 
VVector theVector
 Vector of linear equation system. More...
 

Detailed Description

GBL trajectory.

List of GblPoints ordered by arc length. Can be fitted and optionally written to MP-II binary file.

Definition at line 47 of file GblTrajectory.h.

Constructor & Destructor Documentation

gbl::GblTrajectory::GblTrajectory ( const std::vector< GblPoint > &  aPointList,
bool  flagCurv = true,
bool  flagU1dir = true,
bool  flagU2dir = true 
)

Create new (simple) trajectory from list of points.

Curved trajectory in space (default) or without curvature (q/p) or in one plane (u-direction) only.

Parameters
[in]aPointListList of points
[in]flagCurvUse q/p
[in]flagU1dirUse in u1 direction
[in]flagU2dirUse in u2 direction

Definition at line 153 of file GblTrajectory.cc.

References construct(), externalDerivatives, externalMeasurements, externalPoint, externalPrecisions, externalSeed, plotBeamSpotDB::first, mps_fire::i, innerTransformations, maxNumGlobals, measDataIndex, eostools::move(), numAllPoints, numCurvature, numInnerTrans, numLocals, numMeasurements, numOffsets, numParameters, numPoints, scatDataIndex, edm::second(), skippedMeasLabel, theData, theDimension, and thePoints.

Referenced by GblTrajectory().

154  :
155  numAllPoints(aPointList.size()), numPoints(), numOffsets(0),
156  numInnerTrans(0), numCurvature(flagCurv ? 1 : 0), numParameters(0),
161  {
162 
163  if (flagU1dir)
164  theDimension.push_back(0);
165  if (flagU2dir)
166  theDimension.push_back(1);
167  // simple (single) trajectory
168  thePoints.emplace_back(std::move(aPointList));
169  numPoints.push_back(numAllPoints);
170  construct(); // construct trajectory
171  }
std::vector< unsigned int > scatDataIndex
mapping points to data blocks from scatterers
void construct()
Construct trajectory from list of points.
unsigned int numParameters
Number of fit parameters.
std::vector< unsigned int > measDataIndex
mapping points to data blocks from measurements
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int numOffsets
Number of (points with) offsets on trajectory.
Eigen::VectorXd externalMeasurements
unsigned int externalPoint
Label of external point (or 0)
unsigned int numInnerTrans
Number of inner transformations to external parameters.
unsigned int numMeasurements
Total number of measurements.
Eigen::MatrixXd externalSeed
Precision (inverse covariance matrix) of external seed.
std::vector< unsigned int > numPoints
Number of points on (sub)trajectory.
std::vector< GblData > theData
List of data blocks.
unsigned int maxNumGlobals
Max. number of global labels/derivatives per point.
std::vector< Eigen::MatrixXd > innerTransformations
Transformations at innermost points of.
Eigen::MatrixXd externalDerivatives
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numAllPoints
Number of all points on trajectory.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
def move(src, dest)
Definition: eostools.py:510
unsigned int skippedMeasLabel
Label of point with measurements skipped in fit (for unbiased residuals) (or 0)
Eigen::VectorXd externalPrecisions
template<typename Seed >
gbl::GblTrajectory::GblTrajectory ( const std::vector< GblPoint > &  aPointList,
unsigned int  aLabel,
const Eigen::MatrixBase< Seed > &  aSeed,
bool  flagCurv = true,
bool  flagU1dir = true,
bool  flagU2dir = true 
)

Create new (simple) trajectory from list of points with external seed.

Curved trajectory in space (default) or without curvature (q/p) or in one plane (u-direction) only.

Parameters
[in]aPointListList of points
[in]aLabel(Signed) label of point for external seed (<0: in front, >0: after point, slope changes at scatterer!)
[in]aSeedPrecision matrix of external seed
[in]flagCurvUse q/p
[in]flagU1dirUse in u1 direction
[in]flagU2dirUse in u2 direction

Definition at line 175 of file GblTrajectory.h.

References construct(), numAllPoints, numPoints, theDimension, and thePoints.

179  :
180  numAllPoints(aPointList.size()), numPoints(), numOffsets(0),
181  numInnerTrans(0), numCurvature(flagCurv ? 1 : 0), numParameters(0),
182  numLocals(0), numMeasurements(0), externalPoint(aLabel),
187  {
188 
189  if (flagU1dir)
190  theDimension.push_back(0);
191  if (flagU2dir)
192  theDimension.push_back(1);
193  // simple (single) trajectory
194  thePoints.push_back(aPointList);
195  numPoints.push_back(numAllPoints);
196  construct(); // construct trajectory
197  }
std::vector< unsigned int > scatDataIndex
mapping points to data blocks from scatterers
void construct()
Construct trajectory from list of points.
unsigned int numParameters
Number of fit parameters.
std::vector< unsigned int > measDataIndex
mapping points to data blocks from measurements
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int numOffsets
Number of (points with) offsets on trajectory.
Eigen::VectorXd externalMeasurements
unsigned int externalPoint
Label of external point (or 0)
unsigned int numInnerTrans
Number of inner transformations to external parameters.
unsigned int numMeasurements
Total number of measurements.
Eigen::MatrixXd externalSeed
Precision (inverse covariance matrix) of external seed.
std::vector< unsigned int > numPoints
Number of points on (sub)trajectory.
std::vector< GblData > theData
List of data blocks.
unsigned int maxNumGlobals
Max. number of global labels/derivatives per point.
std::vector< Eigen::MatrixXd > innerTransformations
Transformations at innermost points of.
Eigen::MatrixXd externalDerivatives
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numAllPoints
Number of all points on trajectory.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
unsigned int skippedMeasLabel
Label of point with measurements skipped in fit (for unbiased residuals) (or 0)
Eigen::VectorXd externalPrecisions
gbl::GblTrajectory::GblTrajectory ( const std::vector< std::pair< std::vector< GblPoint >, Eigen::MatrixXd > > &  aPointsAndTransList)
template<typename Derivatives , typename Measurements , typename Precision , typename std::enable_if<(Measurements::ColsAtCompileTime==1)>::type * , typename std::enable_if<(Precision::ColsAtCompileTime==1)>::type * >
gbl::GblTrajectory::GblTrajectory ( const std::vector< std::pair< std::vector< GblPoint >, Eigen::MatrixXd > > &  aPointsAndTransList,
const Eigen::MatrixBase< Derivatives > &  extDerivatives,
const Eigen::MatrixBase< Measurements > &  extMeasurements,
const Eigen::MatrixBase< Precision > &  extPrecisions 
)

Create new composed trajectory from list of points and transformations with (independent or correlated) external measurements.

Composed of curved trajectories in space. The precision matrix for the external measurements can specified as a vector for independent measurements or as arbitrary matrix which will be diagonalized.

Parameters
[in]aPointsAndTransListList containing pairs with list of points and transformation (at inner (first) point)
[in]extDerivativesDerivatives of external measurements vs external parameters
[in]extMeasurementsExternal measurements (residuals)
[in]extPrecisionsPrecision of external measurements (matrix)

Composed of curved trajectories in space. The precision matrix for the external measurements can specified as a vector for independent measurements or as arbitrary matrix which will be diagonalized.

Parameters
[in]aPointsAndTransListList containing pairs with list of points and transformation (at inner (first) point)
[in]extDerivativesDerivatives of external measurements vs external parameters
[in]extMeasurementsExternal measurements (residuals)
[in]extPrecisionsPrecision of external measurements (diagonal)

Definition at line 212 of file GblTrajectory.h.

References construct(), externalDerivatives, externalMeasurements, externalPoint, externalPrecisions, externalSeed, plotBeamSpotDB::first, GblTrajectory(), innerTransformations, maxNumGlobals, measDataIndex, numAllPoints, numCurvature, numInnerTrans, numLocals, numMeasurements, numOffsets, numParameters, numPoints, scatDataIndex, edm::second(), skippedMeasLabel, theData, theDimension, and thePoints.

215  :
217  numInnerTrans(aPointsAndTransList.size()), numParameters(0), numLocals(0),
221  {
222  // diagonalize external measurement
223  Eigen::SelfAdjointEigenSolver<typename Precision::PlainObject> extEigen{extPrecisions};
224  // @TODO if (extEigen.info() != Success) abort();
225  auto extTransformation = extEigen.eigenvectors().transpose();
226  externalDerivatives.resize(extDerivatives.rows(),
227  extDerivatives.cols());
228  externalDerivatives = extTransformation * extDerivatives;
229  externalMeasurements.resize(extMeasurements.size());
230  externalMeasurements = extTransformation * extMeasurements;
231  externalPrecisions.resize(extMeasurements.size());
232  externalPrecisions = extEigen.eigenvalues();
233 
234  for (unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) {
235  thePoints.push_back(aPointsAndTransList[iTraj].first);
236  numPoints.push_back(thePoints.back().size());
237  numAllPoints += numPoints.back();
238  innerTransformations.push_back(aPointsAndTransList[iTraj].second);
239  }
240  theDimension.push_back(0);
241  theDimension.push_back(1);
243  construct(); // construct (composed) trajectory
244  }
std::vector< unsigned int > scatDataIndex
mapping points to data blocks from scatterers
void construct()
Construct trajectory from list of points.
unsigned int numParameters
Number of fit parameters.
std::vector< unsigned int > measDataIndex
mapping points to data blocks from measurements
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int numOffsets
Number of (points with) offsets on trajectory.
Eigen::VectorXd externalMeasurements
U second(std::pair< T, U > const &p)
unsigned int externalPoint
Label of external point (or 0)
unsigned int numInnerTrans
Number of inner transformations to external parameters.
unsigned int numMeasurements
Total number of measurements.
Eigen::MatrixXd externalSeed
Precision (inverse covariance matrix) of external seed.
std::vector< unsigned int > numPoints
Number of points on (sub)trajectory.
std::vector< GblData > theData
List of data blocks.
unsigned int maxNumGlobals
Max. number of global labels/derivatives per point.
std::vector< Eigen::MatrixXd > innerTransformations
Transformations at innermost points of.
Eigen::MatrixXd externalDerivatives
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numAllPoints
Number of all points on trajectory.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
unsigned int skippedMeasLabel
Label of point with measurements skipped in fit (for unbiased residuals) (or 0)
Eigen::VectorXd externalPrecisions
template<typename Derivatives , typename Measurements , typename Precision , typename std::enable_if<(Measurements::ColsAtCompileTime==1)>::type * = nullptr, typename std::enable_if<(Precision::ColsAtCompileTime==1)>::type * = nullptr>
gbl::GblTrajectory::GblTrajectory ( const std::vector< std::pair< std::vector< GblPoint >, Eigen::MatrixXd > > &  aPointsAndTransList,
const Eigen::MatrixBase< Derivatives > &  extDerivatives,
const Eigen::MatrixBase< Measurements > &  extMeasurements,
const Eigen::MatrixBase< Precision > &  extPrecisions 
)
gbl::GblTrajectory::~GblTrajectory ( )
virtual

Definition at line 392 of file GblTrajectory.cc.

392  {
393  }

Member Function Documentation

void gbl::GblTrajectory::buildLinearEquationSystem ( )
private

Build linear equation system from data (blocks).

Definition at line 994 of file GblTrajectory.cc.

References gbl::BorderedBandMatrix::addBlockMatrix(), gbl::InternalMeasurement, numCurvature, numLocals, numParameters, gbl::VVector::resize(), gbl::BorderedBandMatrix::resize(), skippedMeasLabel, theData, theMatrix, and theVector.

Referenced by fit().

994  {
995  unsigned int nBorder = numCurvature + numLocals;
997  theMatrix.resize(numParameters, nBorder);
998  double aValue, aWeight;
999  unsigned int* indLocal;
1000  double* derLocal;
1001  unsigned int numLocal;
1002 
1003  std::vector<GblData>::iterator itData;
1004  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1005  // skipped (internal) measurement ?
1006  if (itData->getLabel() == skippedMeasLabel
1007  && itData->getType() == InternalMeasurement)
1008  continue;
1009  itData->getLocalData(aValue, aWeight, numLocal, indLocal, derLocal);
1010  for (unsigned int j = 0; j < numLocal; ++j) {
1011  theVector(indLocal[j] - 1) += derLocal[j] * aWeight * aValue;
1012  }
1013  theMatrix.addBlockMatrix(aWeight, numLocal, indLocal, derLocal);
1014  }
1015  }
void addBlockMatrix(double aWeight, const std::vector< unsigned int > *anIndex, const std::vector< double > *aVector)
Add symmetric block matrix.
unsigned int numParameters
Number of fit parameters.
void resize(const unsigned int nRows)
Resize vector.
Definition: VMatrix.cc:262
std::vector< GblData > theData
List of data blocks.
void resize(unsigned int nSize, unsigned int nBorder=1, unsigned int nBand=5)
Resize bordered band matrix.
BorderedBandMatrix theMatrix
(Bordered band) matrix of linear equation system
VVector theVector
Vector of linear equation system.
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
unsigned int skippedMeasLabel
Label of point with measurements skipped in fit (for unbiased residuals) (or 0)
void gbl::GblTrajectory::calcJacobians ( )
private

Calculate Jacobians to previous/next scatterer from point to point ones.

Definition at line 474 of file GblTrajectory.cc.

References gbl::GblPoint::addNextJacobian(), begin, end, gbl::GblPoint::getP2pJacobian(), numTrajectories, and thePoints.

Referenced by construct().

474  {
475 
476  Matrix5d scatJacobian;
477  // loop over trajectories
478  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
479  // forward propagation (all)
480  GblPoint* previousPoint = &thePoints[iTraj].front();
481  unsigned int numStep = 0;
482  std::vector<GblPoint>::iterator itPoint;
483  for (itPoint = thePoints[iTraj].begin() + 1;
484  itPoint < thePoints[iTraj].end(); ++itPoint) {
485  if (numStep == 0) {
486  scatJacobian = itPoint->getP2pJacobian();
487  } else {
488  scatJacobian = itPoint->getP2pJacobian() * scatJacobian;
489  }
490  numStep++;
491  itPoint->addPrevJacobian(scatJacobian); // iPoint -> previous scatterer
492  if (itPoint->getOffset() >= 0) {
493  previousPoint->addNextJacobian(scatJacobian); // lastPoint -> next scatterer
494  numStep = 0;
495  previousPoint = &(*itPoint);
496  }
497  }
498  // backward propagation (without scatterers)
499  for (itPoint = thePoints[iTraj].end() - 1;
500  itPoint > thePoints[iTraj].begin(); --itPoint) {
501  if (itPoint->getOffset() >= 0) {
502  scatJacobian = itPoint->getP2pJacobian();
503  continue; // skip offsets
504  }
505  itPoint->addNextJacobian(scatJacobian); // iPoint -> next scatterer
506  scatJacobian = scatJacobian * itPoint->getP2pJacobian();
507  }
508  }
509  }
#define end
Definition: vmac.h:37
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
#define begin
Definition: vmac.h:30
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: GblData.h:43
void gbl::GblTrajectory::construct ( )
private

Construct trajectory from list of points.

Trajectory is prepared for fit or output to binary file, may consists of sub-trajectories.

Definition at line 409 of file GblTrajectory.cc.

References begin, calcJacobians(), constructOK, gather_cfg::cout, defineOffsets(), MillePedeFileConverter_cfg::e, fitOK, hpstanc_transforms::max, numAllPoints, numCurvature, numInnerTrans, numLocals, numMeasurements, numOffsets, numParameters, numTrajectories, prepare(), theDimension, and thePoints.

Referenced by GblTrajectory().

409  {
410 
411  constructOK = false;
412  fitOK = false;
413  unsigned int aLabel = 0;
414  if (numAllPoints < 2) {
415  std::cout << " GblTrajectory construction failed: too few GblPoints "
416  << std::endl;
417  return;
418  }
419  // loop over trajectories
420  numTrajectories = thePoints.size();
421  //std::cout << " numTrajectories: " << numTrajectories << ", " << innerTransformations.size() << std::endl;
422  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
423  std::vector<GblPoint>::iterator itPoint;
424  for (itPoint = thePoints[iTraj].begin();
425  itPoint < thePoints[iTraj].end(); ++itPoint) {
426  numLocals = std::max(numLocals, itPoint->getNumLocals());
427  numMeasurements += itPoint->hasMeasurement();
428  itPoint->setLabel(++aLabel);
429  }
430  }
431  defineOffsets();
432  calcJacobians();
433  try {
434  prepare();
435  } catch (std::overflow_error &e) {
436  std::cout << " GblTrajectory construction failed: " << e.what()
437  << std::endl;
438  return;
439  }
440 
441  constructOK = true;
442  // number of fit parameters
445  }
unsigned int numParameters
Number of fit parameters.
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
bool fitOK
Trajectory has been successfully fitted (results are valid)
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int numOffsets
Number of (points with) offsets on trajectory.
unsigned int numInnerTrans
Number of inner transformations to external parameters.
void calcJacobians()
Calculate Jacobians to previous/next scatterer from point to point ones.
unsigned int numMeasurements
Total number of measurements.
void defineOffsets()
Define offsets from list of points.
void prepare()
Prepare fit for simple or composed trajectory.
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
#define begin
Definition: vmac.h:30
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numAllPoints
Number of all points on trajectory.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
void gbl::GblTrajectory::defineOffsets ( )
private

Define offsets from list of points.

Define offsets at points with scatterers and first and last point. All other points need interpolation from adjacent points with offsets.

Definition at line 452 of file GblTrajectory.cc.

References begin, numOffsets, numTrajectories, and thePoints.

Referenced by construct().

452  {
453 
454  // loop over trajectories
455  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
456  // first point is offset
457  thePoints[iTraj].front().setOffset(numOffsets++);
458  // intermediate scatterers are offsets
459  std::vector<GblPoint>::iterator itPoint;
460  for (itPoint = thePoints[iTraj].begin() + 1;
461  itPoint < thePoints[iTraj].end() - 1; ++itPoint) {
462  if (itPoint->hasScatterer()) {
463  itPoint->setOffset(numOffsets++);
464  } else {
465  itPoint->setOffset(-numOffsets);
466  }
467  }
468  // last point is offset
469  thePoints[iTraj].back().setOffset(numOffsets++);
470  }
471  }
unsigned int numOffsets
Number of (points with) offsets on trajectory.
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
#define begin
Definition: vmac.h:30
double gbl::GblTrajectory::downWeight ( unsigned int  aMethod)
private

Down-weight all points.

Parameters
[in]aMethodM-estimator (1: Tukey, 2:Huber, 3:Cauchy)

Definition at line 1253 of file GblTrajectory.cc.

References theData.

Referenced by fit().

1253  {
1254  double aLoss = 0.;
1255  std::vector<GblData>::iterator itData;
1256  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1257  aLoss += (1. - itData->setDownWeighting(aMethod));
1258  }
1259  return aLoss;
1260  }
std::vector< GblData > theData
List of data blocks.
unsigned int gbl::GblTrajectory::fit ( double &  Chi2,
int &  Ndf,
double &  lostWeight,
const std::string &  optionList = "",
unsigned int  aLabel = 0 
)

Perform fit of (valid) trajectory.

Optionally iterate for outlier down-weighting. Fit may fail due to singular or not positive definite matrices (internal exceptions 1-3).

Parameters
[out]Chi2Chi2 sum (corrected for down-weighting)
[out]NdfNumber of degrees of freedom
[out]lostWeightSum of weights lost due to down-weighting
[in]optionListIterations for down-weighting (One character per iteration: t,h,c (or T,H,C) for Tukey, Huber or Cauchy function)
[in]aLabelLabel of point where to skip measurements (for unbiased residuals)
Returns
Error code (non zero value indicates failure of fit)

Definition at line 1275 of file GblTrajectory.cc.

References buildLinearEquationSystem(), constructOK, gather_cfg::cout, downWeight(), MillePedeFileConverter_cfg::e, fitOK, mps_fire::i, gbl::InternalMeasurement, numParameters, predict(), skippedMeasLabel, gbl::BorderedBandMatrix::solveAndInvertBorderedBand(), AlCaHLTBitMon_QueryRunRegistry::string, theData, theMatrix, and theVector.

Referenced by trackingPlots.Iteration::modules().

1276  {
1277  const double normChi2[4] = { 1.0, 0.8737, 0.9326, 0.8228 };
1278  const std::string methodList = "TtHhCc";
1279 
1280  Chi2 = 0.;
1281  Ndf = -1;
1282  lostWeight = 0.;
1283  if (not constructOK)
1284  return 10;
1285 
1286  unsigned int aMethod = 0;
1287  skippedMeasLabel = aLabel;
1288 
1290  lostWeight = 0.;
1291  unsigned int ierr = 0;
1292  try {
1293 
1295  predict();
1296 
1297  for (unsigned int i = 0; i < optionList.size(); ++i) // down weighting iterations
1298  {
1299  size_t aPosition = methodList.find(optionList[i]);
1300  if (aPosition != std::string::npos) {
1301  aMethod = aPosition / 2 + 1;
1302  lostWeight = downWeight(aMethod);
1305  predict();
1306  }
1307  }
1308  Ndf = -numParameters;
1309  Chi2 = 0.;
1310  for (unsigned int i = 0; i < theData.size(); ++i) {
1311  // skipped (internal) measurement ?
1312  if (theData[i].getLabel() == skippedMeasLabel
1313  && theData[i].getType() == InternalMeasurement)
1314  continue;
1315  Chi2 += theData[i].getChi2();
1316  Ndf++;
1317  }
1318  Chi2 /= normChi2[aMethod];
1319  fitOK = true;
1320 
1321  } catch (int e) {
1322  std::cout << " GblTrajectory::fit exception " << e << std::endl;
1323  ierr = e;
1324  }
1325  return ierr;
1326  }
void buildLinearEquationSystem()
Build linear equation system from data (blocks).
unsigned int numParameters
Number of fit parameters.
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
bool fitOK
Trajectory has been successfully fitted (results are valid)
void predict()
Calculate predictions for all points.
double downWeight(unsigned int aMethod)
Down-weight all points.
std::vector< GblData > theData
List of data blocks.
BorderedBandMatrix theMatrix
(Bordered band) matrix of linear equation system
VVector theVector
Vector of linear equation system.
void solveAndInvertBorderedBand(const VVector &aRightHandSide, VVector &aSolution)
Solve linear equation system, partially calculate inverse.
Definition: Chi2.h:17
unsigned int skippedMeasLabel
Label of point with measurements skipped in fit (for unbiased residuals) (or 0)
void gbl::GblTrajectory::getFitToKinkJacobian ( std::array< unsigned int, 7 > &  anIndex,
Matrix27d aJacobian,
const GblPoint aPoint 
) const
private

Get jacobian for transformation from (trajectory) fit to kink parameters at point.

Jacobian broken lines (q/p,..,u_i-1,u_i,u_i+1..) to kink (du') parameters.

Parameters
[out]anIndexList of fit parameters with non zero derivatives
[out]aJacobianCorresponding transformation matrix
[in]aPointPoint to use

Definition at line 691 of file GblTrajectory.cc.

References gbl::GblPoint::getDerivatives(), gbl::GblPoint::getOffset(), mps_fire::i, numCurvature, numLocals, and theDimension.

Referenced by prepare().

692  {
693 
694  unsigned int nDim = theDimension.size();
695  unsigned int nCurv = numCurvature;
696  unsigned int nLocals = numLocals;
697 
698  int nOffset = aPoint.getOffset();
699 
700  aJacobian.setZero();
701 
702  Matrix2d prevW, prevWJ, nextW, nextWJ;
703  Vector2d prevWd, nextWd;
704  aPoint.getDerivatives(0, prevW, prevWJ, prevWd); // W-, W- * J-, W- * d-
705  aPoint.getDerivatives(1, nextW, nextWJ, nextWd); // W-, W- * J-, W- * d-
706  const Matrix2d sumWJ(prevWJ + nextWJ); // W- * J- + W+ * J+
707  const Vector2d sumWd(prevWd + nextWd); // W+ * d+ + W- * d-
708 
709  unsigned int iOff = (nOffset - 1) * nDim + nCurv + nLocals + 1; // first offset ('i' in u_i)
710 
711  // local offset
712  if (nCurv > 0) {
713  aJacobian.block<2, 1>(0, 0) = -sumWd; // from curvature
714  anIndex[0] = nLocals + 1;
715  }
716  aJacobian.block<2, 2>(0, 1) = prevW; // from 1st Offset
717  aJacobian.block<2, 2>(0, 3) = -sumWJ; // from 2nd Offset
718  aJacobian.block<2, 2>(0, 5) = nextW; // from 1st Offset
719  for (unsigned int i = 0; i < nDim; ++i) {
720  anIndex[1 + theDimension[i]] = iOff + i;
721  anIndex[3 + theDimension[i]] = iOff + nDim + i;
722  anIndex[5 + theDimension[i]] = iOff + nDim * 2 + i;
723  }
724  }
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
void gbl::GblTrajectory::getFitToLocalJacobian ( std::array< unsigned int, 5 > &  anIndex,
Matrix5d aJacobian,
const GblPoint aPoint,
unsigned int  measDim,
unsigned int  nJacobian = 1 
) const
private

Get (part of) jacobian for transformation from (trajectory) fit to track parameters at point.

Jacobian broken lines (q/p,..,u_i,u_i+1..) to local (q/p,u',u) parameters.

Parameters
[out]anIndexList of fit parameters with non zero derivatives
[out]aJacobianCorresponding transformation matrix
[in]aPointPoint to use
[in]measDimDimension of 'measurement' (<=2: calculate only offset part, >2: complete matrix)
[in]nJacobianDirection (0: to previous offset, 1: to next offset)

Definition at line 596 of file GblTrajectory.cc.

References gbl::GblPoint::getDerivatives(), gbl::GblPoint::getOffset(), mps_fire::i, numCurvature, numLocals, Validation_hcalonly_cfi::sign, and theDimension.

Referenced by getJacobian(), and prepare().

598  {
599 
600  unsigned int nDim = theDimension.size();
601  unsigned int nCurv = numCurvature;
602  unsigned int nLocals = numLocals;
603 
604  int nOffset = aPoint.getOffset();
605 
606  aJacobian.setZero();
607  if (nOffset < 0) // need interpolation
608  {
609  Matrix2d prevW, prevWJ, nextW, nextWJ, matN;
610  Vector2d prevWd, nextWd;
611  aPoint.getDerivatives(0, prevW, prevWJ, prevWd); // W-, W- * J-, W- * d-
612  aPoint.getDerivatives(1, nextW, nextWJ, nextWd); // W+, W+ * J+, W+ * d+
613  const Matrix2d sumWJ(prevWJ + nextWJ);
614  matN = sumWJ.inverse(); // N = (W- * J- + W+ * J+)^-1
615  // derivatives for u_int
616  const Matrix2d prevNW(matN * prevW); // N * W-
617  const Matrix2d nextNW(matN * nextW); // N * W+
618  const Vector2d prevNd(matN * prevWd); // N * W- * d-
619  const Vector2d nextNd(matN * nextWd); // N * W+ * d+
620 
621  unsigned int iOff = nDim * (-nOffset - 1) + nLocals + nCurv + 1; // first offset ('i' in u_i)
622 
623  // local offset
624  if (nCurv > 0) {
625  aJacobian.block<2, 1>(3, 0) = -prevNd - nextNd; // from curvature
626  anIndex[0] = nLocals + 1;
627  }
628  aJacobian.block<2, 2>(3, 1) = prevNW; // from 1st Offset
629  aJacobian.block<2, 2>(3, 3) = nextNW; // from 2nd Offset
630  for (unsigned int i = 0; i < nDim; ++i) {
631  anIndex[1 + theDimension[i]] = iOff + i;
632  anIndex[3 + theDimension[i]] = iOff + nDim + i;
633  }
634 
635  // local slope and curvature
636  if (measDim > 2) {
637  // derivatives for u'_int
638  const Matrix2d prevWPN(nextWJ * prevNW); // W+ * J+ * N * W-
639  const Matrix2d nextWPN(prevWJ * nextNW); // W- * J- * N * W+
640  const Vector2d prevWNd(nextWJ * prevNd); // W+ * J+ * N * W- * d-
641  const Vector2d nextWNd(prevWJ * nextNd); // W- * J- * N * W+ * d+
642  if (nCurv > 0) {
643  aJacobian(0, 0) = 1.0;
644  aJacobian.block<2, 1>(1, 0) = prevWNd - nextWNd; // from curvature
645  }
646  aJacobian.block<2, 2>(1, 1) = -prevWPN; // from 1st Offset
647  aJacobian.block<2, 2>(1, 3) = nextWPN; // from 2nd Offset
648  }
649  } else { // at point
650  // anIndex must be sorted
651  // forward : iOff2 = iOff1 + nDim, index1 = 1, index2 = 3
652  // backward: iOff2 = iOff1 - nDim, index1 = 3, index2 = 1
653  unsigned int iOff1 = nDim * nOffset + nCurv + nLocals + 1; // first offset ('i' in u_i)
654  unsigned int index1 = 3 - 2 * nJacobian; // index of first offset
655  unsigned int iOff2 = iOff1 + nDim * (nJacobian * 2 - 1); // second offset ('i' in u_i)
656  unsigned int index2 = 1 + 2 * nJacobian; // index of second offset
657  // local offset
658  aJacobian(3, index1) = 1.0; // from 1st Offset
659  aJacobian(4, index1 + 1) = 1.0;
660  for (unsigned int i = 0; i < nDim; ++i) {
661  anIndex[index1 + theDimension[i]] = iOff1 + i;
662  }
663 
664  // local slope and curvature
665  if (measDim > 2) {
666  Matrix2d matW, matWJ;
667  Vector2d vecWd;
668  aPoint.getDerivatives(nJacobian, matW, matWJ, vecWd); // W, W * J, W * d
669  double sign = (nJacobian > 0) ? 1. : -1.;
670  if (nCurv > 0) {
671  aJacobian(0, 0) = 1.0;
672  aJacobian.block<2, 1>(1, 0) = -sign * vecWd; // from curvature
673  anIndex[0] = nLocals + 1;
674  }
675  aJacobian.block<2, 2>(1, index1) = -sign * matWJ; // from 1st Offset
676  aJacobian.block<2, 2>(1, index2) = sign * matW; // from 2nd Offset
677  for (unsigned int i = 0; i < nDim; ++i) {
678  anIndex[index2 + theDimension[i]] = iOff2 + i;
679  }
680  }
681  }
682  }
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
std::pair< std::vector< unsigned int >, MatrixXd > gbl::GblTrajectory::getJacobian ( int  aSignedLabel) const
private

Get jacobian for transformation from fit to track parameters at point.

Jacobian broken lines (q/p,..,u_i,u_i+1..) to track (q/p,u',u) parameters including additional local parameters.

Parameters
[in]aSignedLabel(Signed) label of point for external seed (<0: in front, >0: after point, slope changes at scatterer!)
Returns
List of fit parameters with non zero derivatives and corresponding transformation matrix

Definition at line 520 of file GblTrajectory.cc.

References funct::abs(), getFitToLocalJacobian(), mps_fire::i, numCurvature, numLocals, numPoints, numTrajectories, theDimension, and thePoints.

Referenced by getResults(), getScatResults(), and prepare().

521  {
522 
523  unsigned int nDim = theDimension.size();
524  unsigned int nCurv = numCurvature;
525  unsigned int nLocals = numLocals;
526  unsigned int nBorder = nCurv + nLocals;
527  unsigned int nParBRL = nBorder + 2 * nDim;
528  unsigned int nParLoc = nLocals + 5;
529  std::vector<unsigned int> anIndex;
530  anIndex.reserve(nParBRL);
531  MatrixXd aJacobian(nParLoc, nParBRL);
532  aJacobian.setZero();
533 
534  unsigned int aLabel = abs(aSignedLabel);
535  unsigned int firstLabel = 1;
536  unsigned int lastLabel = 0;
537  unsigned int aTrajectory = 0;
538  // loop over trajectories
539  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
540  aTrajectory = iTraj;
541  lastLabel += numPoints[iTraj];
542  if (aLabel <= lastLabel)
543  break;
544  if (iTraj < numTrajectories - 1)
545  firstLabel += numPoints[iTraj];
546  }
547  int nJacobian; // 0: prev, 1: next
548  // check consistency of (index, direction)
549  if (aSignedLabel > 0) {
550  nJacobian = 1;
551  if (aLabel >= lastLabel) {
552  aLabel = lastLabel;
553  nJacobian = 0;
554  }
555  } else {
556  nJacobian = 0;
557  if (aLabel <= firstLabel) {
558  aLabel = firstLabel;
559  nJacobian = 1;
560  }
561  }
562  const GblPoint aPoint = thePoints[aTrajectory][aLabel - firstLabel];
563  std::array<unsigned int, 5> labDer;
564  Matrix5d matDer;
565  getFitToLocalJacobian(labDer, matDer, aPoint, 5, nJacobian);
566 
567  // from local parameters
568  for (unsigned int i = 0; i < nLocals; ++i) {
569  aJacobian(i + 5, i) = 1.0;
570  anIndex.push_back(i + 1);
571  }
572  // from trajectory parameters
573  unsigned int iCol = nLocals;
574  for (unsigned int i = 0; i < 5; ++i) {
575  if (labDer[i] > 0) {
576  anIndex.push_back(labDer[i]);
577  for (unsigned int j = 0; j < 5; ++j) {
578  aJacobian(j, iCol) = matDer(j, i);
579  }
580  ++iCol;
581  }
582  }
583  return std::make_pair(anIndex, aJacobian);
584  }
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< unsigned int > numPoints
Number of points on (sub)trajectory.
void getFitToLocalJacobian(std::array< unsigned int, 5 > &anIndex, Matrix5d &aJacobian, const GblPoint &aPoint, unsigned int measDim, unsigned int nJacobian=1) const
Get (part of) jacobian for transformation from (trajectory) fit to track parameters at point...
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: GblData.h:43
unsigned int gbl::GblTrajectory::getLabels ( std::vector< unsigned int > &  aLabelList)

Get (list of) labels of points on (simple) valid trajectory.

Parameters
[out]aLabelListList of labels (aLabelList[i] = i+1)
Returns
error code (non-zero if trajectory not valid (constructed successfully))

Definition at line 924 of file GblTrajectory.cc.

References constructOK, mps_fire::i, and thePoints.

924  {
925  if (not constructOK)
926  return 1;
927 
928  unsigned int aLabel = 0;
929  unsigned int nPoint = thePoints[0].size();
930  aLabelList.resize(nPoint);
931  for (unsigned i = 0; i < nPoint; ++i) {
932  aLabelList[i] = ++aLabel;
933  }
934  return 0;
935  }
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int gbl::GblTrajectory::getLabels ( std::vector< std::vector< unsigned int > > &  aLabelList)

Get (list of lists of) labels of points on (composed) valid trajectory.

Parameters
[out]aLabelListList of of lists of labels
Returns
error code (non-zero if trajectory not valid (constructed successfully))

Definition at line 942 of file GblTrajectory.cc.

References constructOK, mps_fire::i, numTrajectories, and thePoints.

943  {
944  if (not constructOK)
945  return 1;
946 
947  unsigned int aLabel = 0;
948  aLabelList.resize(numTrajectories);
949  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
950  unsigned int nPoint = thePoints[iTraj].size();
951  aLabelList[iTraj].resize(nPoint);
952  for (unsigned i = 0; i < nPoint; ++i) {
953  aLabelList[iTraj][i] = ++aLabel;
954  }
955  }
956  return 0;
957  }
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
unsigned int gbl::GblTrajectory::getMeasResults ( unsigned int  aLabel,
unsigned int &  numRes,
Eigen::VectorXd &  aResiduals,
Eigen::VectorXd &  aMeasErrors,
Eigen::VectorXd &  aResErrors,
Eigen::VectorXd &  aDownWeights 
)

Get residuals from fit at point for measurement.

Get (diagonalized) residual, error of measurement and residual and down-weighting factor for measurement at point

Parameters
[in]aLabelLabel of point on trajectory
[out]numDataNumber of data blocks from measurement at point
[out]aResidualsMeasurements-Predictions
[out]aMeasErrorsErrors of Measurements
[out]aResErrorsErrors of Residuals (including correlations from track fit)
[out]aDownWeightsDown-Weighting factors
Returns
error code (non-zero if trajectory not fitted successfully)

Definition at line 772 of file GblTrajectory.cc.

References fitOK, getResAndErr(), mps_fire::i, measDataIndex, and skippedMeasLabel.

Referenced by getScatResults().

774  {
775  numData = 0;
776  if (not fitOK)
777  return 1;
778 
779  unsigned int firstData = measDataIndex[aLabel - 1]; // first data block with measurement
780  numData = measDataIndex[aLabel] - firstData; // number of data blocks
781  for (unsigned int i = 0; i < numData; ++i) {
782  getResAndErr(firstData + i, (aLabel != skippedMeasLabel), aResiduals(i),
783  aMeasErrors(i), aResErrors(i), aDownWeights(i));
784  }
785  return 0;
786  }
std::vector< unsigned int > measDataIndex
mapping points to data blocks from measurements
bool fitOK
Trajectory has been successfully fitted (results are valid)
void getResAndErr(unsigned int aData, bool used, double &aResidual, double &aMeadsError, double &aResError, double &aDownWeight)
Get residual and errors from data block.
unsigned int skippedMeasLabel
Label of point with measurements skipped in fit (for unbiased residuals) (or 0)
unsigned int gbl::GblTrajectory::getNumPoints ( ) const

Retrieve number of point from trajectory.

Definition at line 401 of file GblTrajectory.cc.

References numAllPoints.

401  {
402  return numAllPoints;
403  }
unsigned int numAllPoints
Number of all points on trajectory.
void gbl::GblTrajectory::getResAndErr ( unsigned int  aData,
bool  used,
double &  aResidual,
double &  aMeasError,
double &  aResError,
double &  aDownWeight 
)
private

Get residual and errors from data block.

Get residual, error of measurement and residual and down-weighting factor for (single) data block

Parameters
[in]aDataLabel of data block
[in]usedFlag for usage of data block in fit
[out]aResidualMeasurement-Prediction
[out]aMeasErrorError of Measurement
[out]aResErrorError of Residual (including correlations from track fit)
[out]aDownWeightDown-Weighting factor

Definition at line 970 of file GblTrajectory.cc.

References gbl::BorderedBandMatrix::getBlockMatrix(), mathSSE::sqrt(), theData, and theMatrix.

Referenced by getMeasResults(), and getScatResults().

972  {
973 
974  double aMeasVar;
975  unsigned int numLocal;
976  unsigned int* indLocal;
977  double* derLocal;
978  theData[aData].getResidual(aResidual, aMeasVar, aDownWeight, numLocal,
979  indLocal, derLocal);
980  VectorXd aVec(numLocal); // compressed vector of derivatives
981  for (unsigned int j = 0; j < numLocal; ++j) {
982  aVec[j] = derLocal[j];
983  }
984  MatrixXd aMat = theMatrix.getBlockMatrix(numLocal, indLocal); // compressed (covariance) matrix
985  double aFitVar = aVec.transpose() * aMat * aVec; // variance from track fit
986  aMeasError = sqrt(aMeasVar); // error of measurement
987  if (used)
988  aResError = (aFitVar < aMeasVar ? sqrt(aMeasVar - aFitVar) : 0.); // error of (biased) residual
989  else
990  aResError = sqrt(aMeasVar + aFitVar); // error of (unbiased) residual
991  }
Eigen::MatrixXd getBlockMatrix(const std::vector< unsigned int > anIndex) const
Retrieve symmetric block matrix.
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< GblData > theData
List of data blocks.
BorderedBandMatrix theMatrix
(Bordered band) matrix of linear equation system
unsigned int gbl::GblTrajectory::getResults ( int  aSignedLabel,
Eigen::VectorXd &  localPar,
Eigen::MatrixXd &  localCov 
) const

Get fit results at point.

Get corrections and covariance matrix for local track and additional parameters in forward or backward direction.

The point is identified by its label (1..number(points)), the sign distinguishes the backward (facing previous point) and forward 'side' (facing next point). For scatterers the track direction may change in between.

Parameters
[in]aSignedLabel(Signed) label of point on trajectory (<0: in front, >0: after point, slope changes at scatterer!)
[out]localParCorrections for local parameters
[out]localCovCovariance for local parameters
Returns
error code (non-zero if trajectory not fitted successfully)

Definition at line 741 of file GblTrajectory.cc.

References fitOK, gbl::BorderedBandMatrix::getBlockMatrix(), getJacobian(), mps_fire::i, theMatrix, and theVector.

Referenced by getScatResults().

742  {
743  if (not fitOK)
744  return 1;
745  std::pair<std::vector<unsigned int>, MatrixXd> indexAndJacobian =
746  getJacobian(aSignedLabel);
747  unsigned int nParBrl = indexAndJacobian.first.size();
748  VectorXd aVec(nParBrl); // compressed vector
749  for (unsigned int i = 0; i < nParBrl; ++i) {
750  aVec[i] = theVector(indexAndJacobian.first[i] - 1);
751  }
752  MatrixXd aMat = theMatrix.getBlockMatrix(indexAndJacobian.first); // compressed matrix
753  localPar = indexAndJacobian.second * aVec;
754  localCov = indexAndJacobian.second * aMat
755  * indexAndJacobian.second.adjoint();
756  return 0;
757  }
Eigen::MatrixXd getBlockMatrix(const std::vector< unsigned int > anIndex) const
Retrieve symmetric block matrix.
bool fitOK
Trajectory has been successfully fitted (results are valid)
std::pair< std::vector< unsigned int >, Eigen::MatrixXd > getJacobian(int aSignedLabel) const
Get jacobian for transformation from fit to track parameters at point.
BorderedBandMatrix theMatrix
(Bordered band) matrix of linear equation system
VVector theVector
Vector of linear equation system.
unsigned int gbl::GblTrajectory::getScatResults ( unsigned int  aLabel,
unsigned int &  numRes,
Eigen::VectorXd &  aResiduals,
Eigen::VectorXd &  aMeasErrors,
Eigen::VectorXd &  aResErrors,
Eigen::VectorXd &  aDownWeights 
)

Get (kink) residuals from fit at point for scatterer.

Get (diagonalized) residual, error of measurement and residual and down-weighting factor for scatterering kinks at point

Parameters
[in]aLabelLabel of point on trajectory
[out]numDataNumber of data blocks from scatterer at point
[out]aResiduals(kink)Measurements-(kink)Predictions
[out]aMeasErrorsErrors of (kink)Measurements
[out]aResErrorsErrors of Residuals (including correlations from track fit)
[out]aDownWeightsDown-Weighting factors
Returns
error code (non-zero if trajectory not fitted successfully)

Definition at line 801 of file GblTrajectory.cc.

References fitOK, gbl::BorderedBandMatrix::getBlockMatrix(), getJacobian(), getMeasResults(), getResAndErr(), getResults(), mps_fire::i, measDataIndex, scatDataIndex, skippedMeasLabel, theMatrix, and theVector.

803  {
804  numData = 0;
805  if (not fitOK)
806  return 1;
807 
808  unsigned int firstData = scatDataIndex[aLabel - 1]; // first data block with scatterer
809  numData = scatDataIndex[aLabel] - firstData; // number of data blocks
810  for (unsigned int i = 0; i < numData; ++i) {
811  getResAndErr(firstData + i, true, aResiduals(i), aMeasErrors(i),
812  aResErrors(i), aDownWeights(i));
813  }
814  return 0;
815  }
std::vector< unsigned int > scatDataIndex
mapping points to data blocks from scatterers
bool fitOK
Trajectory has been successfully fitted (results are valid)
void getResAndErr(unsigned int aData, bool used, double &aResidual, double &aMeadsError, double &aResError, double &aDownWeight)
Get residual and errors from data block.
bool gbl::GblTrajectory::isValid ( void  ) const

Retrieve validity of trajectory.

Definition at line 396 of file GblTrajectory.cc.

References constructOK.

Referenced by ntupleDataFormat._Object::_checkIsValid(), and core.AutoHandle.AutoHandle::ReallyLoad().

396  {
397  return constructOK;
398  }
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
void gbl::GblTrajectory::milleOut ( MilleBinary aMille)

Write valid trajectory to Millepede-II binary file.

Definition at line 1329 of file GblTrajectory.cc.

References gbl::MilleBinary::addData(), constructOK, gbl::InternalMeasurement, maxNumGlobals, theData, thePoints, and gbl::MilleBinary::writeRecord().

Referenced by MillePedeAlignmentAlgorithm::addReferenceTrajectory().

1329  {
1330  double aValue;
1331  double aErr;
1332  unsigned int aTraj;
1333  unsigned int aPoint;
1334  unsigned int aRow;
1335  unsigned int numLocal;
1336  unsigned int* labLocal;
1337  double* derLocal;
1338  std::vector<int> labGlobal;
1339  std::vector<double> derGlobal;
1340 
1341  if (not constructOK)
1342  return;
1343 
1344  // data: measurements, kinks and external seed
1345  labGlobal.reserve(maxNumGlobals);
1346  derGlobal.reserve(maxNumGlobals);
1347  std::vector<GblData>::iterator itData;
1348  for (itData = theData.begin(); itData != theData.end(); ++itData) {
1349  itData->getAllData(aValue, aErr, numLocal, labLocal, derLocal, aTraj,
1350  aPoint, aRow);
1351  if (itData->getType() == InternalMeasurement)
1352  thePoints[aTraj][aPoint].getGlobalLabelsAndDerivatives(aRow,
1353  labGlobal, derGlobal);
1354  else
1355  labGlobal.resize(0);
1356  aMille.addData(aValue, aErr, numLocal, labLocal, derLocal, labGlobal,
1357  derGlobal);
1358  }
1359  aMille.writeRecord();
1360  }
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
std::vector< GblData > theData
List of data blocks.
unsigned int maxNumGlobals
Max. number of global labels/derivatives per point.
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
void gbl::GblTrajectory::predict ( )
private

Calculate predictions for all points.

Definition at line 1242 of file GblTrajectory.cc.

References theData, and theVector.

Referenced by fit().

1242  {
1243  std::vector<GblData>::iterator itData;
1244  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1245  itData->setPrediction(theVector);
1246  }
1247  }
std::vector< GblData > theData
List of data blocks.
VVector theVector
Vector of linear equation system.
void gbl::GblTrajectory::prepare ( )
private

Prepare fit for simple or composed trajectory.

Generate data (blocks) from measurements, kinks, external seed and measurements.

Definition at line 1021 of file GblTrajectory.cc.

References gbl::GblData::addDerivatives(), begin, externalDerivatives, gbl::ExternalMeasurement, externalMeasurements, externalPoint, externalPrecisions, gbl::ExternalSeed, externalSeed, getFitToKinkJacobian(), getFitToLocalJacobian(), getJacobian(), mps_fire::i, diffTreeTool::index, innerTransformations, gbl::InternalKink, gbl::InternalMeasurement, gen::k, hpstanc_transforms::max, maxNumGlobals, measDataIndex, eostools::move(), numAllPoints, numCurvature, numInnerTrans, numLocals, numMeasurements, numOffsets, numTrajectories, scatDataIndex, theData, theDimension, thePoints, and mitigatedMETSequence_cff::U.

Referenced by construct().

1021  {
1022  unsigned int nDim = theDimension.size();
1023  // upper limit
1024  unsigned int maxData = numMeasurements + nDim * (numOffsets - 2)
1025  + externalSeed.rows();
1026  theData.reserve(maxData);
1027  measDataIndex.resize(numAllPoints + 3); // include external seed and measurements
1028  scatDataIndex.resize(numAllPoints + 1);
1029  unsigned int nData = 0;
1030  std::vector<MatrixXd> innerTransDer;
1031  std::vector<std::array<unsigned int, 5> > innerTransLab;
1032  // composed trajectory ?
1033  if (numInnerTrans > 0) {
1034  //std::cout << "composed trajectory" << std::endl;
1035  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
1036  // innermost point
1037  GblPoint* innerPoint = &thePoints[iTraj].front();
1038  // transformation fit to local track parameters
1039  std::array<unsigned int, 5> firstLabels;
1040  Matrix5d matFitToLocal, matLocalToFit;
1041  getFitToLocalJacobian(firstLabels, matFitToLocal, *innerPoint, 5);
1042  // transformation local track to fit parameters
1043  matLocalToFit = matFitToLocal.inverse();
1044  // transformation external to fit parameters at inner (first) point
1045  innerTransDer.emplace_back(matLocalToFit * innerTransformations[iTraj]);
1046  innerTransLab.push_back(firstLabels);
1047  }
1048  }
1049  Matrix5d matP; // measurements
1050  std::vector<GblPoint>::iterator itPoint;
1051  // limit the scope of proDer:
1052  {
1053  // transform for external parameters
1054  Eigen::Matrix<double, Eigen::Dynamic, 5,
1055  Eigen::ColMajor /* default */, 5, 5> proDer;
1056  // loop over trajectories
1057  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
1058  for (itPoint = thePoints[iTraj].begin();
1059  itPoint < thePoints[iTraj].end(); ++itPoint) {
1060  Vector5d aMeas, aPrec;
1061  unsigned int nLabel = itPoint->getLabel();
1062  unsigned int measDim = itPoint->hasMeasurement();
1063  if (measDim) {
1064  const MatrixXd localDer = itPoint->getLocalDerivatives();
1066  itPoint->getNumGlobals());
1067  MatrixXd transDer;
1068  itPoint->getMeasurement(matP, aMeas, aPrec);
1069  double minPrecision = itPoint->getMeasPrecMin();
1070  unsigned int iOff = 5 - measDim; // first active component
1071  std::array<unsigned int, 5> labDer;
1072  Matrix5d matDer, matPDer;
1073  unsigned int nJacobian =
1074  (itPoint < thePoints[iTraj].end() - 1) ? 1 : 0; // last point needs backward propagation
1075  getFitToLocalJacobian(labDer, matDer, *itPoint, measDim,
1076  nJacobian);
1077  if (measDim > 2) {
1078  matPDer = matP * matDer;
1079  } else { // 'shortcut' for position measurements
1080  matPDer.block<2, 5>(3, 0) = matP.block<2, 2>(3, 3)
1081  * matDer.block<2, 5>(3, 0);
1082  }
1083 
1084  if (numInnerTrans > 0) {
1085  // transform for external parameters
1086  proDer.resize(measDim, Eigen::NoChange);
1087  // match parameters
1088  unsigned int ifirst = 0;
1089  unsigned int ilabel = 0;
1090  while (ilabel < 5) {
1091  if (labDer[ilabel] > 0) {
1092  while (innerTransLab[iTraj][ifirst]
1093  != labDer[ilabel] and ifirst < 5) {
1094  ++ifirst;
1095  }
1096  if (ifirst >= 5) {
1097  labDer[ilabel] -= 2 * nDim * (iTraj + 1); // adjust label
1098  } else {
1099  // match
1100  labDer[ilabel] = 0; // mark as related to external parameters
1101  for (unsigned int k = iOff; k < 5; ++k) {
1102  proDer(k - iOff, ifirst) = matPDer(k,
1103  ilabel);
1104  }
1105  }
1106  }
1107  ++ilabel;
1108  }
1109  transDer.resize(measDim, numCurvature);
1110  transDer = proDer * innerTransDer[iTraj];
1111  }
1112  for (unsigned int i = iOff; i < 5; ++i) {
1113  if (aPrec(i) > minPrecision) {
1114  GblData aData(nLabel, InternalMeasurement, aMeas(i),
1115  aPrec(i), iTraj,
1116  itPoint - thePoints[iTraj].begin());
1117  aData.addDerivatives(i, labDer, matPDer, iOff, localDer,
1118  numLocals, transDer);
1119  theData.emplace_back(aData);
1120  nData++;
1121  }
1122  }
1123 
1124  }
1125  measDataIndex[nLabel] = nData;
1126  }
1127  }
1128  } // end of scope for proDer
1129 
1130  Matrix2d matT; // measurements
1131  // limit the scope of proDer:
1132  {
1133  // transform for external parameters
1134  Eigen::Matrix<double, Eigen::Dynamic, 5,
1135  Eigen::ColMajor /* default */, 5, 5> proDer;
1136  scatDataIndex[0] = nData;
1137  scatDataIndex[1] = nData;
1138  // loop over trajectories
1139  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
1140  for (itPoint = thePoints[iTraj].begin() + 1;
1141  itPoint < thePoints[iTraj].end() - 1; ++itPoint) {
1142  Vector2d aMeas, aPrec;
1143  unsigned int nLabel = itPoint->getLabel();
1144  if (itPoint->hasScatterer()) {
1145  itPoint->getScatterer(matT, aMeas, aPrec);
1146  MatrixXd transDer;
1147  std::array<unsigned int, 7> labDer;
1148  Matrix27d matDer, matTDer;
1149  getFitToKinkJacobian(labDer, matDer, *itPoint);
1150  matTDer = matT * matDer;
1151  if (numInnerTrans > 0) {
1152  // transform for external parameters
1153  proDer.resize(nDim, Eigen::NoChange);
1154  // match parameters
1155  unsigned int ifirst = 0;
1156  unsigned int ilabel = 0;
1157  while (ilabel < 7) {
1158  if (labDer[ilabel] > 0) {
1159  while (innerTransLab[iTraj][ifirst]
1160  != labDer[ilabel] and ifirst < 5) {
1161  ++ifirst;
1162  }
1163  if (ifirst >= 5) {
1164  labDer[ilabel] -= 2 * nDim * (iTraj + 1); // adjust label
1165  } else {
1166  // match
1167  labDer[ilabel] = 0; // mark as related to external parameters
1168  for (unsigned int k = 0; k < nDim; ++k) {
1169  proDer(k, ifirst) = matTDer(k, ilabel);
1170  }
1171  }
1172  }
1173  ++ilabel;
1174  }
1175  transDer.resize(nDim, numCurvature);
1176  transDer = proDer * innerTransDer[iTraj];
1177  }
1178  for (unsigned int i = 0; i < nDim; ++i) {
1179  unsigned int iDim = theDimension[i];
1180  if (aPrec(iDim) > 0.) {
1181  GblData aData(nLabel, InternalKink, aMeas(iDim),
1182  aPrec(iDim), iTraj,
1183  itPoint - thePoints[iTraj].begin());
1184  aData.addDerivatives(iDim, labDer, matTDer, numLocals,
1185  transDer);
1186  theData.emplace_back(aData);
1187  nData++;
1188  }
1189  }
1190  }
1191  scatDataIndex[nLabel] = nData;
1192  }
1193  scatDataIndex[thePoints[iTraj].back().getLabel()] = nData;
1194  }
1195  }
1196 
1197  // external seed
1198  if (externalPoint > 0) {
1199  std::pair<std::vector<unsigned int>, MatrixXd> indexAndJacobian =
1201  std::vector<unsigned int> externalSeedIndex = indexAndJacobian.first;
1202  std::vector<double> externalSeedDerivatives(externalSeedIndex.size());
1203  SelfAdjointEigenSolver<MatrixXd> externalSeedEigen(externalSeed);
1204  VectorXd valEigen = externalSeedEigen.eigenvalues();
1205  MatrixXd vecEigen = externalSeedEigen.eigenvectors();
1206  vecEigen = vecEigen.transpose() * indexAndJacobian.second;
1207  for (int i = 0; i < externalSeed.rows(); ++i) {
1208  if (valEigen(i) > 0.) {
1209  for (int j = 0; j < externalSeed.cols(); ++j) {
1210  externalSeedDerivatives[j] = vecEigen(i, j);
1211  }
1212  GblData aData(externalPoint, ExternalSeed, 0., valEigen(i));
1213  aData.addDerivatives(externalSeedIndex,
1214  externalSeedDerivatives);
1215  theData.emplace_back(std::move(aData));
1216  nData++;
1217  }
1218  }
1219  }
1220  measDataIndex[numAllPoints + 1] = nData;
1221  // external measurements
1222  unsigned int nExt = externalMeasurements.rows();
1223  if (nExt > 0) {
1224  std::vector<unsigned int> index(numCurvature);
1225  std::vector<double> derivatives(numCurvature);
1226  for (unsigned int iExt = 0; iExt < nExt; ++iExt) {
1227  for (unsigned int iCol = 0; iCol < numCurvature; ++iCol) {
1228  index[iCol] = iCol + 1;
1229  derivatives[iCol] = externalDerivatives(iExt, iCol);
1230  }
1231  GblData aData(1U, ExternalMeasurement, externalMeasurements(iExt),
1232  externalPrecisions(iExt));
1233  aData.addDerivatives(index, derivatives);
1234  theData.emplace_back(std::move(aData));
1235  nData++;
1236  }
1237  }
1238  measDataIndex[numAllPoints + 2] = nData;
1239  }
std::vector< unsigned int > scatDataIndex
mapping points to data blocks from scatterers
std::vector< unsigned int > measDataIndex
mapping points to data blocks from measurements
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int numOffsets
Number of (points with) offsets on trajectory.
Eigen::VectorXd externalMeasurements
CLHEP::HepMatrix Matrix
Definition: matutil.h:65
unsigned int externalPoint
Label of external point (or 0)
unsigned int numInnerTrans
Number of inner transformations to external parameters.
unsigned int numMeasurements
Total number of measurements.
void getFitToKinkJacobian(std::array< unsigned int, 7 > &anIndex, Matrix27d &aJacobian, const GblPoint &aPoint) const
Get jacobian for transformation from (trajectory) fit to kink parameters at point.
Eigen::MatrixXd externalSeed
Precision (inverse covariance matrix) of external seed.
int k[5][pyjets_maxn]
std::pair< std::vector< unsigned int >, Eigen::MatrixXd > getJacobian(int aSignedLabel) const
Get jacobian for transformation from fit to track parameters at point.
void getFitToLocalJacobian(std::array< unsigned int, 5 > &anIndex, Matrix5d &aJacobian, const GblPoint &aPoint, unsigned int measDim, unsigned int nJacobian=1) const
Get (part of) jacobian for transformation from (trajectory) fit to track parameters at point...
std::vector< GblData > theData
List of data blocks.
Eigen::Matrix< double, 5, 1 > Vector5d
Definition: GblPoint.h:47
Eigen::Matrix< double, 2, 7 > Matrix27d
Definition: GblData.h:44
unsigned int maxNumGlobals
Max. number of global labels/derivatives per point.
std::vector< Eigen::MatrixXd > innerTransformations
Transformations at innermost points of.
Eigen::MatrixXd externalDerivatives
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
#define begin
Definition: vmac.h:30
unsigned int numLocals
Total number of (additional) local parameters.
unsigned int numAllPoints
Number of all points on trajectory.
unsigned int numCurvature
Number of curvature parameters (0 or 1) or external parameters.
def move(src, dest)
Definition: eostools.py:510
Eigen::VectorXd externalPrecisions
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: GblData.h:43
void gbl::GblTrajectory::printData ( )

Print GblData blocks for trajectory.

Definition at line 1446 of file GblTrajectory.cc.

References gather_cfg::cout, and theData.

1446  {
1447  std::cout << "GblData blocks " << std::endl;
1448  std::vector<GblData>::iterator itData;
1449  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1450  itData->printData();
1451  }
1452  }
std::vector< GblData > theData
List of data blocks.
void gbl::GblTrajectory::printPoints ( unsigned int  level = 0)

Print GblPoints on trajectory.

Parameters
[in]levelprint level (0: minimum, >0: more)

Definition at line 1434 of file GblTrajectory.cc.

References begin, gather_cfg::cout, numTrajectories, and thePoints.

1434  {
1435  std::cout << "GblPoints " << std::endl;
1436  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
1437  std::vector<GblPoint>::iterator itPoint;
1438  for (itPoint = thePoints[iTraj].begin();
1439  itPoint < thePoints[iTraj].end(); ++itPoint) {
1440  itPoint->printPoint(level);
1441  }
1442  }
1443  }
std::vector< std::vector< GblPoint > > thePoints
(list of) List of points on trajectory
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
#define begin
Definition: vmac.h:30
void gbl::GblTrajectory::printTrajectory ( unsigned int  level = 0)

Print GblTrajectory.

Parameters
[in]levelprint level (0: minimum, >0: more)

Definition at line 1366 of file GblTrajectory.cc.

References constructOK, gather_cfg::cout, externalDerivatives, externalMeasurements, externalPoint, externalPrecisions, externalSeed, fitOK, mps_fire::i, innerTransformations, numAllPoints, numInnerTrans, numMeasurements, numOffsets, numParameters, gbl::VVector::print(), gbl::BorderedBandMatrix::printMatrix(), theDimension, theMatrix, and theVector.

1366  {
1367  if (numInnerTrans) {
1368  std::cout << "Composed GblTrajectory, " << numInnerTrans
1369  << " subtrajectories" << std::endl;
1370  } else {
1371  std::cout << "Simple GblTrajectory" << std::endl;
1372  }
1373  if (theDimension.size() < 2) {
1374  std::cout << " 2D-trajectory" << std::endl;
1375  }
1376  std::cout << " Number of GblPoints : " << numAllPoints
1377  << std::endl;
1378  std::cout << " Number of points with offsets: " << numOffsets << std::endl;
1379  std::cout << " Number of fit parameters : " << numParameters
1380  << std::endl;
1381  std::cout << " Number of measurements : " << numMeasurements
1382  << std::endl;
1383  if (externalMeasurements.rows()) {
1384  std::cout << " Number of ext. measurements : "
1385  << externalMeasurements.rows() << std::endl;
1386  }
1387  if (externalPoint) {
1388  std::cout << " Label of point with ext. seed: " << externalPoint
1389  << std::endl;
1390  }
1391  if (constructOK) {
1392  std::cout << " Constructed OK " << std::endl;
1393  }
1394  if (fitOK) {
1395  std::cout << " Fitted OK " << std::endl;
1396  }
1397  if (level > 0) {
1398  IOFormat CleanFmt(4, 0, ", ", "\n", "[", "]");
1399  if (numInnerTrans) {
1400  std::cout << " Inner transformations" << std::endl;
1401  for (unsigned int i = 0; i < numInnerTrans; ++i) {
1402  std::cout << innerTransformations[i].format(CleanFmt)
1403  << std::endl;
1404  }
1405  }
1406  if (externalMeasurements.rows()) {
1407  std::cout << " External measurements" << std::endl;
1408  std::cout << " Measurements:" << std::endl;
1409  std::cout << externalMeasurements.format(CleanFmt) << std::endl;
1410  std::cout << " Precisions:" << std::endl;
1411  std::cout << externalPrecisions.format(CleanFmt) << std::endl;
1412  std::cout << " Derivatives:" << std::endl;
1413  std::cout << externalDerivatives.format(CleanFmt) << std::endl;
1414  }
1415  if (externalPoint) {
1416  std::cout << " External seed:" << std::endl;
1417  std::cout << externalSeed.format(CleanFmt) << std::endl;
1418  }
1419  if (fitOK) {
1420  std::cout << " Fit results" << std::endl;
1421  std::cout << " Parameters:" << std::endl;
1422  theVector.print();
1423  std::cout << " Covariance matrix (bordered band part):"
1424  << std::endl;
1426  }
1427  }
1428  }
void printMatrix() const
Print bordered band matrix.
unsigned int numParameters
Number of fit parameters.
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
bool fitOK
Trajectory has been successfully fitted (results are valid)
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
void print() const
Print vector.
Definition: VMatrix.cc:298
unsigned int numOffsets
Number of (points with) offsets on trajectory.
Eigen::VectorXd externalMeasurements
unsigned int externalPoint
Label of external point (or 0)
unsigned int numInnerTrans
Number of inner transformations to external parameters.
unsigned int numMeasurements
Total number of measurements.
Eigen::MatrixXd externalSeed
Precision (inverse covariance matrix) of external seed.
std::vector< Eigen::MatrixXd > innerTransformations
Transformations at innermost points of.
Eigen::MatrixXd externalDerivatives
BorderedBandMatrix theMatrix
(Bordered band) matrix of linear equation system
VVector theVector
Vector of linear equation system.
unsigned int numAllPoints
Number of all points on trajectory.
Eigen::VectorXd externalPrecisions

Member Data Documentation

bool gbl::GblTrajectory::constructOK
private

Trajectory has been successfully constructed (ready for fit/output)

Definition at line 127 of file GblTrajectory.h.

Referenced by construct(), fit(), getLabels(), isValid(), milleOut(), and printTrajectory().

Eigen::MatrixXd gbl::GblTrajectory::externalDerivatives
private

Definition at line 137 of file GblTrajectory.h.

Referenced by GblTrajectory(), prepare(), and printTrajectory().

Eigen::VectorXd gbl::GblTrajectory::externalMeasurements
private

Definition at line 138 of file GblTrajectory.h.

Referenced by GblTrajectory(), prepare(), and printTrajectory().

unsigned int gbl::GblTrajectory::externalPoint
private

Label of external point (or 0)

Definition at line 124 of file GblTrajectory.h.

Referenced by GblTrajectory(), prepare(), and printTrajectory().

Eigen::VectorXd gbl::GblTrajectory::externalPrecisions
private

Definition at line 139 of file GblTrajectory.h.

Referenced by GblTrajectory(), prepare(), and printTrajectory().

Eigen::MatrixXd gbl::GblTrajectory::externalSeed
private

Precision (inverse covariance matrix) of external seed.

Definition at line 134 of file GblTrajectory.h.

Referenced by GblTrajectory(), prepare(), and printTrajectory().

bool gbl::GblTrajectory::fitOK
private

Trajectory has been successfully fitted (results are valid)

Definition at line 128 of file GblTrajectory.h.

Referenced by construct(), fit(), getMeasResults(), getResults(), getScatResults(), and printTrajectory().

std::vector<Eigen::MatrixXd> gbl::GblTrajectory::innerTransformations
private

Transformations at innermost points of.

Definition at line 135 of file GblTrajectory.h.

Referenced by GblTrajectory(), prepare(), and printTrajectory().

unsigned int gbl::GblTrajectory::maxNumGlobals
private

Max. number of global labels/derivatives per point.

Definition at line 126 of file GblTrajectory.h.

Referenced by GblTrajectory(), milleOut(), and prepare().

std::vector<unsigned int> gbl::GblTrajectory::measDataIndex
private

mapping points to data blocks from measurements

Definition at line 132 of file GblTrajectory.h.

Referenced by GblTrajectory(), getMeasResults(), getScatResults(), and prepare().

unsigned int gbl::GblTrajectory::numAllPoints
private

Number of all points on trajectory.

Definition at line 115 of file GblTrajectory.h.

Referenced by construct(), GblTrajectory(), getNumPoints(), prepare(), and printTrajectory().

unsigned int gbl::GblTrajectory::numCurvature
private

Number of curvature parameters (0 or 1) or external parameters.

Definition at line 120 of file GblTrajectory.h.

Referenced by buildLinearEquationSystem(), construct(), GblTrajectory(), getFitToKinkJacobian(), getFitToLocalJacobian(), getJacobian(), and prepare().

unsigned int gbl::GblTrajectory::numInnerTrans
private

Number of inner transformations to external parameters.

Definition at line 119 of file GblTrajectory.h.

Referenced by construct(), GblTrajectory(), prepare(), and printTrajectory().

unsigned int gbl::GblTrajectory::numLocals
private

Total number of (additional) local parameters.

Definition at line 122 of file GblTrajectory.h.

Referenced by buildLinearEquationSystem(), construct(), GblTrajectory(), getFitToKinkJacobian(), getFitToLocalJacobian(), getJacobian(), and prepare().

unsigned int gbl::GblTrajectory::numMeasurements
private

Total number of measurements.

Definition at line 123 of file GblTrajectory.h.

Referenced by construct(), GblTrajectory(), prepare(), and printTrajectory().

unsigned int gbl::GblTrajectory::numOffsets
private

Number of (points with) offsets on trajectory.

Definition at line 118 of file GblTrajectory.h.

Referenced by construct(), defineOffsets(), GblTrajectory(), prepare(), and printTrajectory().

unsigned int gbl::GblTrajectory::numParameters
private

Number of fit parameters.

Definition at line 121 of file GblTrajectory.h.

Referenced by buildLinearEquationSystem(), construct(), fit(), GblTrajectory(), and printTrajectory().

std::vector<unsigned int> gbl::GblTrajectory::numPoints
private

Number of points on (sub)trajectory.

Definition at line 116 of file GblTrajectory.h.

Referenced by GblTrajectory(), and getJacobian().

unsigned int gbl::GblTrajectory::numTrajectories
private

Number of trajectories (in composed trajectory)

Definition at line 117 of file GblTrajectory.h.

Referenced by calcJacobians(), construct(), defineOffsets(), getJacobian(), getLabels(), prepare(), and printPoints().

std::vector<unsigned int> gbl::GblTrajectory::scatDataIndex
private

mapping points to data blocks from scatterers

Definition at line 133 of file GblTrajectory.h.

Referenced by GblTrajectory(), getScatResults(), and prepare().

unsigned int gbl::GblTrajectory::skippedMeasLabel
private

Label of point with measurements skipped in fit (for unbiased residuals) (or 0)

Definition at line 125 of file GblTrajectory.h.

Referenced by buildLinearEquationSystem(), fit(), GblTrajectory(), getMeasResults(), and getScatResults().

std::vector<GblData> gbl::GblTrajectory::theData
private

List of data blocks.

Definition at line 131 of file GblTrajectory.h.

Referenced by buildLinearEquationSystem(), downWeight(), fit(), GblTrajectory(), getResAndErr(), milleOut(), predict(), prepare(), and printData().

std::vector<unsigned int> gbl::GblTrajectory::theDimension
private

List of active dimensions (0=u1, 1=u2) in fit.

Definition at line 129 of file GblTrajectory.h.

Referenced by construct(), GblTrajectory(), getFitToKinkJacobian(), getFitToLocalJacobian(), getJacobian(), prepare(), and printTrajectory().

BorderedBandMatrix gbl::GblTrajectory::theMatrix
private

(Bordered band) matrix of linear equation system

Definition at line 141 of file GblTrajectory.h.

Referenced by buildLinearEquationSystem(), fit(), getResAndErr(), getResults(), getScatResults(), and printTrajectory().

std::vector<std::vector<GblPoint> > gbl::GblTrajectory::thePoints
private

(list of) List of points on trajectory

Definition at line 130 of file GblTrajectory.h.

Referenced by calcJacobians(), construct(), defineOffsets(), GblTrajectory(), getJacobian(), getLabels(), milleOut(), prepare(), and printPoints().

VVector gbl::GblTrajectory::theVector
private

Vector of linear equation system.

Definition at line 140 of file GblTrajectory.h.

Referenced by buildLinearEquationSystem(), fit(), getResults(), getScatResults(), predict(), and printTrajectory().