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 996 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().

996  {
997  unsigned int nBorder = numCurvature + numLocals;
999  theMatrix.resize(numParameters, nBorder);
1000  double aValue, aWeight;
1001  unsigned int* indLocal;
1002  double* derLocal;
1003  unsigned int numLocal;
1004 
1005  std::vector<GblData>::iterator itData;
1006  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1007  // skipped (internal) measurement ?
1008  if (itData->getLabel() == skippedMeasLabel
1009  && itData->getType() == InternalMeasurement)
1010  continue;
1011  itData->getLocalData(aValue, aWeight, numLocal, indLocal, derLocal);
1012  for (unsigned int j = 0; j < numLocal; ++j) {
1013  theVector(indLocal[j] - 1) += derLocal[j] * aWeight * aValue;
1014  }
1015  theMatrix.addBlockMatrix(aWeight, numLocal, indLocal, derLocal);
1016  }
1017  }
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 1258 of file GblTrajectory.cc.

References theData.

Referenced by fit().

1258  {
1259  double aLoss = 0.;
1260  std::vector<GblData>::iterator itData;
1261  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1262  aLoss += (1. - itData->setDownWeighting(aMethod));
1263  }
1264  return aLoss;
1265  }
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 1280 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().

1281  {
1282  const double normChi2[4] = { 1.0, 0.8737, 0.9326, 0.8228 };
1283  const std::string methodList = "TtHhCc";
1284 
1285  Chi2 = 0.;
1286  Ndf = -1;
1287  lostWeight = 0.;
1288  if (not constructOK)
1289  return 10;
1290 
1291  unsigned int aMethod = 0;
1292  skippedMeasLabel = aLabel;
1293 
1295  lostWeight = 0.;
1296  unsigned int ierr = 0;
1297  try {
1298 
1300  predict();
1301 
1302  for (unsigned int i = 0; i < optionList.size(); ++i) // down weighting iterations
1303  {
1304  size_t aPosition = methodList.find(optionList[i]);
1305  if (aPosition != std::string::npos) {
1306  aMethod = aPosition / 2 + 1;
1307  lostWeight = downWeight(aMethod);
1310  predict();
1311  }
1312  }
1313  Ndf = -numParameters;
1314  Chi2 = 0.;
1315  for (unsigned int i = 0; i < theData.size(); ++i) {
1316  // skipped (internal) measurement ?
1317  if (theData[i].getLabel() == skippedMeasLabel
1318  && theData[i].getType() == InternalMeasurement)
1319  continue;
1320  Chi2 += theData[i].getChi2();
1321  Ndf++;
1322  }
1323  Chi2 /= normChi2[aMethod];
1324  fitOK = true;
1325 
1326  } catch (int e) {
1327  std::cout << " GblTrajectory::fit exception " << e << std::endl;
1328  ierr = e;
1329  }
1330  return ierr;
1331  }
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 692 of file GblTrajectory.cc.

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

Referenced by prepare().

693  {
694 
695  unsigned int nDim = theDimension.size();
696  unsigned int nCurv = numCurvature;
697  unsigned int nLocals = numLocals;
698 
699  int nOffset = aPoint.getOffset();
700 
701  anIndex = {};
702  aJacobian.setZero();
703 
704  Matrix2d prevW, prevWJ, nextW, nextWJ;
705  Vector2d prevWd, nextWd;
706  aPoint.getDerivatives(0, prevW, prevWJ, prevWd); // W-, W- * J-, W- * d-
707  aPoint.getDerivatives(1, nextW, nextWJ, nextWd); // W-, W- * J-, W- * d-
708  const Matrix2d sumWJ(prevWJ + nextWJ); // W- * J- + W+ * J+
709  const Vector2d sumWd(prevWd + nextWd); // W+ * d+ + W- * d-
710 
711  unsigned int iOff = (nOffset - 1) * nDim + nCurv + nLocals + 1; // first offset ('i' in u_i)
712 
713  // local offset
714  if (nCurv > 0) {
715  aJacobian.block<2, 1>(0, 0) = -sumWd; // from curvature
716  anIndex[0] = nLocals + 1;
717  }
718  aJacobian.block<2, 2>(0, 1) = prevW; // from 1st Offset
719  aJacobian.block<2, 2>(0, 3) = -sumWJ; // from 2nd Offset
720  aJacobian.block<2, 2>(0, 5) = nextW; // from 1st Offset
721  for (unsigned int i = 0; i < nDim; ++i) {
722  anIndex[1 + theDimension[i]] = iOff + i;
723  anIndex[3 + theDimension[i]] = iOff + nDim + i;
724  anIndex[5 + theDimension[i]] = iOff + nDim * 2 + i;
725  }
726  }
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  anIndex = {};
607  aJacobian.setZero();
608  if (nOffset < 0) // need interpolation
609  {
610  Matrix2d prevW, prevWJ, nextW, nextWJ, matN;
611  Vector2d prevWd, nextWd;
612  aPoint.getDerivatives(0, prevW, prevWJ, prevWd); // W-, W- * J-, W- * d-
613  aPoint.getDerivatives(1, nextW, nextWJ, nextWd); // W+, W+ * J+, W+ * d+
614  const Matrix2d sumWJ(prevWJ + nextWJ);
615  matN = sumWJ.inverse(); // N = (W- * J- + W+ * J+)^-1
616  // derivatives for u_int
617  const Matrix2d prevNW(matN * prevW); // N * W-
618  const Matrix2d nextNW(matN * nextW); // N * W+
619  const Vector2d prevNd(matN * prevWd); // N * W- * d-
620  const Vector2d nextNd(matN * nextWd); // N * W+ * d+
621 
622  unsigned int iOff = nDim * (-nOffset - 1) + nLocals + nCurv + 1; // first offset ('i' in u_i)
623 
624  // local offset
625  if (nCurv > 0) {
626  aJacobian.block<2, 1>(3, 0) = -prevNd - nextNd; // from curvature
627  anIndex[0] = nLocals + 1;
628  }
629  aJacobian.block<2, 2>(3, 1) = prevNW; // from 1st Offset
630  aJacobian.block<2, 2>(3, 3) = nextNW; // from 2nd Offset
631  for (unsigned int i = 0; i < nDim; ++i) {
632  anIndex[1 + theDimension[i]] = iOff + i;
633  anIndex[3 + theDimension[i]] = iOff + nDim + i;
634  }
635 
636  // local slope and curvature
637  if (measDim > 2) {
638  // derivatives for u'_int
639  const Matrix2d prevWPN(nextWJ * prevNW); // W+ * J+ * N * W-
640  const Matrix2d nextWPN(prevWJ * nextNW); // W- * J- * N * W+
641  const Vector2d prevWNd(nextWJ * prevNd); // W+ * J+ * N * W- * d-
642  const Vector2d nextWNd(prevWJ * nextNd); // W- * J- * N * W+ * d+
643  if (nCurv > 0) {
644  aJacobian(0, 0) = 1.0;
645  aJacobian.block<2, 1>(1, 0) = prevWNd - nextWNd; // from curvature
646  }
647  aJacobian.block<2, 2>(1, 1) = -prevWPN; // from 1st Offset
648  aJacobian.block<2, 2>(1, 3) = nextWPN; // from 2nd Offset
649  }
650  } else { // at point
651  // anIndex must be sorted
652  // forward : iOff2 = iOff1 + nDim, index1 = 1, index2 = 3
653  // backward: iOff2 = iOff1 - nDim, index1 = 3, index2 = 1
654  unsigned int iOff1 = nDim * nOffset + nCurv + nLocals + 1; // first offset ('i' in u_i)
655  unsigned int index1 = 3 - 2 * nJacobian; // index of first offset
656  unsigned int iOff2 = iOff1 + nDim * (nJacobian * 2 - 1); // second offset ('i' in u_i)
657  unsigned int index2 = 1 + 2 * nJacobian; // index of second offset
658  // local offset
659  aJacobian(3, index1) = 1.0; // from 1st Offset
660  aJacobian(4, index1 + 1) = 1.0;
661  for (unsigned int i = 0; i < nDim; ++i) {
662  anIndex[index1 + theDimension[i]] = iOff1 + i;
663  }
664 
665  // local slope and curvature
666  if (measDim > 2) {
667  Matrix2d matW, matWJ;
668  Vector2d vecWd;
669  aPoint.getDerivatives(nJacobian, matW, matWJ, vecWd); // W, W * J, W * d
670  double sign = (nJacobian > 0) ? 1. : -1.;
671  if (nCurv > 0) {
672  aJacobian(0, 0) = 1.0;
673  aJacobian.block<2, 1>(1, 0) = -sign * vecWd; // from curvature
674  anIndex[0] = nLocals + 1;
675  }
676  aJacobian.block<2, 2>(1, index1) = -sign * matWJ; // from 1st Offset
677  aJacobian.block<2, 2>(1, index2) = sign * matW; // from 2nd Offset
678  for (unsigned int i = 0; i < nDim; ++i) {
679  anIndex[index2 + theDimension[i]] = iOff2 + i;
680  }
681  }
682  }
683  }
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 926 of file GblTrajectory.cc.

References constructOK, mps_fire::i, and thePoints.

926  {
927  if (not constructOK)
928  return 1;
929 
930  unsigned int aLabel = 0;
931  unsigned int nPoint = thePoints[0].size();
932  aLabelList.resize(nPoint);
933  for (unsigned i = 0; i < nPoint; ++i) {
934  aLabelList[i] = ++aLabel;
935  }
936  return 0;
937  }
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 944 of file GblTrajectory.cc.

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

945  {
946  if (not constructOK)
947  return 1;
948 
949  unsigned int aLabel = 0;
950  aLabelList.resize(numTrajectories);
951  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
952  unsigned int nPoint = thePoints[iTraj].size();
953  aLabelList[iTraj].resize(nPoint);
954  for (unsigned i = 0; i < nPoint; ++i) {
955  aLabelList[iTraj][i] = ++aLabel;
956  }
957  }
958  return 0;
959  }
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 774 of file GblTrajectory.cc.

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

Referenced by getScatResults().

776  {
777  numData = 0;
778  if (not fitOK)
779  return 1;
780 
781  unsigned int firstData = measDataIndex[aLabel - 1]; // first data block with measurement
782  numData = measDataIndex[aLabel] - firstData; // number of data blocks
783  for (unsigned int i = 0; i < numData; ++i) {
784  getResAndErr(firstData + i, (aLabel != skippedMeasLabel), aResiduals(i),
785  aMeasErrors(i), aResErrors(i), aDownWeights(i));
786  }
787  return 0;
788  }
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 972 of file GblTrajectory.cc.

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

Referenced by getMeasResults(), and getScatResults().

974  {
975 
976  double aMeasVar;
977  unsigned int numLocal;
978  unsigned int* indLocal;
979  double* derLocal;
980  theData[aData].getResidual(aResidual, aMeasVar, aDownWeight, numLocal,
981  indLocal, derLocal);
982  VectorXd aVec(numLocal); // compressed vector of derivatives
983  for (unsigned int j = 0; j < numLocal; ++j) {
984  aVec[j] = derLocal[j];
985  }
986  MatrixXd aMat = theMatrix.getBlockMatrix(numLocal, indLocal); // compressed (covariance) matrix
987  double aFitVar = aVec.transpose() * aMat * aVec; // variance from track fit
988  aMeasError = sqrt(aMeasVar); // error of measurement
989  if (used)
990  aResError = (aFitVar < aMeasVar ? sqrt(aMeasVar - aFitVar) : 0.); // error of (biased) residual
991  else
992  aResError = sqrt(aMeasVar + aFitVar); // error of (unbiased) residual
993  }
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 743 of file GblTrajectory.cc.

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

Referenced by getScatResults().

744  {
745  if (not fitOK)
746  return 1;
747  std::pair<std::vector<unsigned int>, MatrixXd> indexAndJacobian =
748  getJacobian(aSignedLabel);
749  unsigned int nParBrl = indexAndJacobian.first.size();
750  VectorXd aVec(nParBrl); // compressed vector
751  for (unsigned int i = 0; i < nParBrl; ++i) {
752  aVec[i] = theVector(indexAndJacobian.first[i] - 1);
753  }
754  MatrixXd aMat = theMatrix.getBlockMatrix(indexAndJacobian.first); // compressed matrix
755  localPar = indexAndJacobian.second * aVec;
756  localCov = indexAndJacobian.second * aMat
757  * indexAndJacobian.second.adjoint();
758  return 0;
759  }
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 803 of file GblTrajectory.cc.

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

805  {
806  numData = 0;
807  if (not fitOK)
808  return 1;
809 
810  unsigned int firstData = scatDataIndex[aLabel - 1]; // first data block with scatterer
811  numData = scatDataIndex[aLabel] - firstData; // number of data blocks
812  for (unsigned int i = 0; i < numData; ++i) {
813  getResAndErr(firstData + i, true, aResiduals(i), aMeasErrors(i),
814  aResErrors(i), aDownWeights(i));
815  }
816  return 0;
817  }
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 1334 of file GblTrajectory.cc.

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

Referenced by MillePedeAlignmentAlgorithm::addReferenceTrajectory().

1334  {
1335  double aValue;
1336  double aErr;
1337  unsigned int aTraj;
1338  unsigned int aPoint;
1339  unsigned int aRow;
1340  unsigned int numLocal;
1341  unsigned int* labLocal;
1342  double* derLocal;
1343  std::vector<int> labGlobal;
1344  std::vector<double> derGlobal;
1345 
1346  if (not constructOK)
1347  return;
1348 
1349  // data: measurements, kinks and external seed
1350  labGlobal.reserve(maxNumGlobals);
1351  derGlobal.reserve(maxNumGlobals);
1352  std::vector<GblData>::iterator itData;
1353  for (itData = theData.begin(); itData != theData.end(); ++itData) {
1354  itData->getAllData(aValue, aErr, numLocal, labLocal, derLocal, aTraj,
1355  aPoint, aRow);
1356  if (itData->getType() == InternalMeasurement)
1357  thePoints[aTraj][aPoint].getGlobalLabelsAndDerivatives(aRow,
1358  labGlobal, derGlobal);
1359  else
1360  labGlobal.resize(0);
1361  aMille.addData(aValue, aErr, numLocal, labLocal, derLocal, labGlobal,
1362  derGlobal);
1363  }
1364  aMille.writeRecord();
1365  }
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 1247 of file GblTrajectory.cc.

References theData, and theVector.

Referenced by fit().

1247  {
1248  std::vector<GblData>::iterator itData;
1249  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1250  itData->setPrediction(theVector);
1251  }
1252  }
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 1023 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().

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

References gather_cfg::cout, and theData.

1451  {
1452  std::cout << "GblData blocks " << std::endl;
1453  std::vector<GblData>::iterator itData;
1454  for (itData = theData.begin(); itData < theData.end(); ++itData) {
1455  itData->printData();
1456  }
1457  }
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 1439 of file GblTrajectory.cc.

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

1439  {
1440  std::cout << "GblPoints " << std::endl;
1441  for (unsigned int iTraj = 0; iTraj < numTrajectories; ++iTraj) {
1442  std::vector<GblPoint>::iterator itPoint;
1443  for (itPoint = thePoints[iTraj].begin();
1444  itPoint < thePoints[iTraj].end(); ++itPoint) {
1445  itPoint->printPoint(level);
1446  }
1447  }
1448  }
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 1371 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.

1371  {
1372  if (numInnerTrans) {
1373  std::cout << "Composed GblTrajectory, " << numInnerTrans
1374  << " subtrajectories" << std::endl;
1375  } else {
1376  std::cout << "Simple GblTrajectory" << std::endl;
1377  }
1378  if (theDimension.size() < 2) {
1379  std::cout << " 2D-trajectory" << std::endl;
1380  }
1381  std::cout << " Number of GblPoints : " << numAllPoints
1382  << std::endl;
1383  std::cout << " Number of points with offsets: " << numOffsets << std::endl;
1384  std::cout << " Number of fit parameters : " << numParameters
1385  << std::endl;
1386  std::cout << " Number of measurements : " << numMeasurements
1387  << std::endl;
1388  if (externalMeasurements.rows()) {
1389  std::cout << " Number of ext. measurements : "
1390  << externalMeasurements.rows() << std::endl;
1391  }
1392  if (externalPoint) {
1393  std::cout << " Label of point with ext. seed: " << externalPoint
1394  << std::endl;
1395  }
1396  if (constructOK) {
1397  std::cout << " Constructed OK " << std::endl;
1398  }
1399  if (fitOK) {
1400  std::cout << " Fitted OK " << std::endl;
1401  }
1402  if (level > 0) {
1403  IOFormat CleanFmt(4, 0, ", ", "\n", "[", "]");
1404  if (numInnerTrans) {
1405  std::cout << " Inner transformations" << std::endl;
1406  for (unsigned int i = 0; i < numInnerTrans; ++i) {
1407  std::cout << innerTransformations[i].format(CleanFmt)
1408  << std::endl;
1409  }
1410  }
1411  if (externalMeasurements.rows()) {
1412  std::cout << " External measurements" << std::endl;
1413  std::cout << " Measurements:" << std::endl;
1414  std::cout << externalMeasurements.format(CleanFmt) << std::endl;
1415  std::cout << " Precisions:" << std::endl;
1416  std::cout << externalPrecisions.format(CleanFmt) << std::endl;
1417  std::cout << " Derivatives:" << std::endl;
1418  std::cout << externalDerivatives.format(CleanFmt) << std::endl;
1419  }
1420  if (externalPoint) {
1421  std::cout << " External seed:" << std::endl;
1422  std::cout << externalSeed.format(CleanFmt) << std::endl;
1423  }
1424  if (fitOK) {
1425  std::cout << " Fit results" << std::endl;
1426  std::cout << " Parameters:" << std::endl;
1427  theVector.print();
1428  std::cout << " Covariance matrix (bordered band part):"
1429  << std::endl;
1431  }
1432  }
1433  }
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().