30 #ifndef GBLTRAJECTORY_H_ 31 #define GBLTRAJECTORY_H_ 49 GblTrajectory(
const std::vector<GblPoint> &aPointList,
bool flagCurv =
true,
50 bool flagU1dir =
true,
bool flagU2dir =
true);
51 template <
typename Seed>
52 GblTrajectory(
const std::vector<GblPoint> &aPointList,
unsigned int aLabel,
53 const Eigen::MatrixBase<Seed>& aSeed,
54 bool flagCurv =
true,
bool flagU1dir =
true,
bool flagU2dir =
true);
55 GblTrajectory(
const std::vector<std::pair<std::vector<GblPoint>, Eigen::MatrixXd> >& aPointsAndTransList);
56 template <
typename Derivatives,
typename Measurements,
typename Precision,
59 GblTrajectory(
const std::vector<std::pair<std::vector<GblPoint>, Eigen::MatrixXd> >& aPointsAndTransList,
60 const Eigen::MatrixBase<Derivatives>& extDerivatives,
61 const Eigen::MatrixBase<Measurements>& extMeasurements,
62 const Eigen::MatrixBase<Precision>& extPrecisions);
63 template <
typename Derivatives,
typename Measurements,
typename Precision,
64 typename std::enable_if<(Measurements::ColsAtCompileTime == 1)>::type* =
nullptr,
66 GblTrajectory(
const std::vector<std::pair<std::vector<GblPoint>, Eigen::MatrixXd> >& aPointsAndTransList,
67 const Eigen::MatrixBase<Derivatives>& extDerivatives,
68 const Eigen::MatrixBase<Measurements>& extMeasurements,
69 const Eigen::MatrixBase<Precision>& extPrecisions);
70 #ifdef GBL_EIGEN_SUPPORT_ROOT 72 GblTrajectory(
const std::vector<GblPoint> &aPointList,
unsigned int aLabel,
73 const TMatrixDSym &aSeed,
bool flagCurv =
true,
bool flagU1dir =
74 true,
bool flagU2dir =
true);
75 GblTrajectory(
const std::vector<std::pair<std::vector<GblPoint>, TMatrixD> > &aPointsAndTransList);
76 GblTrajectory(
const std::vector<std::pair<std::vector<GblPoint>, TMatrixD> > &aPointsAndTransList,
77 const TMatrixD &extDerivatives,
const TVectorD &extMeasurements,
78 const TVectorD &extPrecisions);
79 GblTrajectory(
const std::vector<std::pair<std::vector<GblPoint>, TMatrixD> > &aPointsAndTransList,
80 const TMatrixD &extDerivatives,
const TVectorD &extMeasurements,
81 const TMatrixDSym &extPrecisions);
86 unsigned int getResults(
int aSignedLabel, Eigen::VectorXd &localPar,
87 Eigen::MatrixXd &localCov)
const;
88 unsigned int getMeasResults(
unsigned int aLabel,
unsigned int &numRes,
89 Eigen::VectorXd &aResiduals, Eigen::VectorXd &aMeasErrors,
90 Eigen::VectorXd &aResErrors, Eigen::VectorXd &aDownWeights);
91 unsigned int getScatResults(
unsigned int aLabel,
unsigned int &numRes,
92 Eigen::VectorXd &aResiduals, Eigen::VectorXd &aMeasErrors,
93 Eigen::VectorXd &aResErrors, Eigen::VectorXd &aDownWeights);
94 #ifdef GBL_EIGEN_SUPPORT_ROOT 96 unsigned int getResults(
int aSignedLabel, TVectorD &localPar,
97 TMatrixDSym &localCov)
const;
98 unsigned int getMeasResults(
unsigned int aLabel,
unsigned int &numRes,
99 TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors,
100 TVectorD &aDownWeights);
101 unsigned int getScatResults(
unsigned int aLabel,
unsigned int &numRes,
102 TVectorD &aResiduals, TVectorD &aMeasErrors, TVectorD &aResErrors,
103 TVectorD &aDownWeights);
105 unsigned int getLabels(std::vector<unsigned int> &aLabelList);
106 unsigned int getLabels(std::vector<std::vector<unsigned int> > &aLabelList);
107 unsigned int fit(
double &
Chi2,
int &Ndf,
double &lostWeight,
108 const std::string& optionList =
"",
unsigned int aLabel = 0);
143 std::pair<std::vector<unsigned int>, Eigen::MatrixXd>
getJacobian(
int aSignedLabel)
const;
146 unsigned int measDim,
147 unsigned int nJacobian = 1)
const;
157 void getResAndErr(
unsigned int aData,
bool used,
double &aResidual,
158 double &aMeadsError,
double &aResError,
double &aDownWeight);
174 template <
typename Seed>
177 const Eigen::MatrixBase<Seed>& aSeed,
179 bool flagU1dir,
bool flagU2dir) :
209 template <
typename Derivatives,
typename Measurements,
typename Precision,
213 const Eigen::MatrixBase<Derivatives>& extDerivatives,
214 const Eigen::MatrixBase<Measurements>& extMeasurements,
215 const Eigen::MatrixBase<Precision>& extPrecisions) :
223 Eigen::SelfAdjointEigenSolver<typename Precision::PlainObject> extEigen{extPrecisions};
225 auto extTransformation = extEigen.eigenvectors().transpose();
227 extDerivatives.cols());
234 for (
unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) {
256 template <
typename Derivatives,
typename Measurements,
typename Precision,
257 typename std::enable_if<(Measurements::ColsAtCompileTime == 1)>::type*,
260 const Eigen::MatrixBase<Derivatives>& extDerivatives,
261 const Eigen::MatrixBase<Measurements>& extMeasurements,
262 const Eigen::MatrixBase<Precision>& extPrecisions) :
273 for (
unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) {
std::vector< unsigned int > scatDataIndex
mapping points to data blocks from scatterers
void construct()
Construct trajectory from list of points.
void buildLinearEquationSystem()
Build linear equation system from data (blocks).
void printTrajectory(unsigned int level=0)
Print GblTrajectory.
unsigned int numParameters
Number of fit parameters.
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
std::vector< unsigned int > measDataIndex
mapping points to data blocks from measurements
bool fitOK
Trajectory has been successfully fitted (results are valid)
(Symmetric) Bordered Band Matrix.
std::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
unsigned int getLabels(std::vector< unsigned int > &aLabelList)
Get (list of) labels of points on (simple) valid trajectory.
void predict()
Calculate predictions for all points.
unsigned int numOffsets
Number of (points with) offsets on trajectory.
Eigen::VectorXd externalMeasurements
bool isValid() const
Retrieve validity of trajectory.
unsigned int getResults(int aSignedLabel, Eigen::VectorXd &localPar, Eigen::MatrixXd &localCov) const
Get fit results at point.
U second(std::pair< T, U > const &p)
unsigned int fit(double &Chi2, int &Ndf, double &lostWeight, const std::string &optionList="", unsigned int aLabel=0)
Perform fit of (valid) trajectory.
unsigned int externalPoint
Label of external point (or 0)
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 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.
void defineOffsets()
Define offsets from list of points.
void prepare()
Prepare fit for simple or composed trajectory.
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.
void printData()
Print GblData blocks for trajectory.
Namespace for the general broken lines package.
double downWeight(unsigned int aMethod)
Down-weight all points.
std::vector< unsigned int > numPoints
Number of points on (sub)trajectory.
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...
void milleOut(MilleBinary &aMille)
Write valid trajectory to Millepede-II binary file.
std::vector< GblData > theData
List of data blocks.
Eigen::Matrix< double, 2, 7 > Matrix27d
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
BorderedBandMatrix theMatrix
(Bordered band) matrix of linear equation system
VVector theVector
Vector of linear equation system.
unsigned int numTrajectories
Number of trajectories (in composed trajectory)
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.
Simple Vector based on std::vector<double>
GblTrajectory(const std::vector< GblPoint > &aPointList, bool flagCurv=true, bool flagU1dir=true, bool flagU2dir=true)
Create new (simple) trajectory from list of points.
unsigned int numLocals
Total number of (additional) local parameters.
Millepede-II (binary) record.
unsigned int getNumPoints() const
Retrieve number of point from trajectory.
AlgebraicMatrix Derivatives
unsigned int numAllPoints
Number of all points on trajectory.
void getResAndErr(unsigned int aData, bool used, double &aResidual, double &aMeadsError, double &aResError, double &aDownWeight)
Get residual and errors from data block.
void printPoints(unsigned int level=0)
Print GblPoints 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
Eigen::Matrix< double, 5, 5 > Matrix5d