139 using namespace Eigen;
153 GblTrajectory::GblTrajectory(
const std::vector<GblPoint> &aPointList,
154 bool flagCurv,
bool flagU1dir,
bool flagU2dir) :
155 numAllPoints(aPointList.
size()), numPoints(), numOffsets(0),
156 numInnerTrans(0), numCurvature(flagCurv ? 1 : 0), numParameters(0),
157 numLocals(0), numMeasurements(0), externalPoint(0), skippedMeasLabel(0),
158 maxNumGlobals(0), theDimension(0), thePoints(), theData(), measDataIndex(),
159 scatDataIndex(), externalSeed(), innerTransformations(),
160 externalDerivatives(), externalMeasurements(), externalPrecisions()
187 for (
unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) {
199 #ifdef GBL_EIGEN_SUPPORT_ROOT 213 unsigned int aLabel,
const TMatrixDSym &aSeed,
214 bool flagCurv,
bool flagU1dir,
bool flagU2dir) :
229 unsigned int nParSeed = aSeed.GetNrows();
231 for (
unsigned int i = 0;
i < nParSeed; ++
i) {
232 for (
unsigned int j = 0; j < nParSeed; ++j) {
256 for (
unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) {
261 unsigned int nRowTrans = aPointsAndTransList[iTraj].second.GetNrows();
262 unsigned int nColTrans = aPointsAndTransList[iTraj].second.GetNcols();
263 MatrixXd aTrans(nRowTrans, nColTrans);
264 for (
unsigned int i = 0;
i < nRowTrans; ++
i) {
265 for (
unsigned int j = 0; j < nColTrans; ++j) {
266 aTrans(
i, j) = aPointsAndTransList[iTraj].second(
i, j);
286 const TMatrixD &extDerivatives,
287 const TVectorD &extMeasurements,
288 const TVectorD &extPrecisions) :
298 unsigned int nExtMeas = extDerivatives.GetNrows();
299 unsigned int nExtPar = extDerivatives.GetNcols();
303 for (
unsigned int i = 0;
i < nExtMeas; ++
i) {
306 for (
unsigned int j = 0; j < nExtPar; ++j) {
310 for (
unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) {
315 unsigned int nRowTrans = aPointsAndTransList[iTraj].second.GetNrows();
316 unsigned int nColTrans = aPointsAndTransList[iTraj].second.GetNcols();
317 MatrixXd aTrans(nRowTrans, nColTrans);
318 for (
unsigned int i = 0;
i < nRowTrans; ++
i) {
319 for (
unsigned int j = 0; j < nColTrans; ++j) {
320 aTrans(
i, j) = aPointsAndTransList[iTraj].second(
i, j);
340 const TMatrixD &extDerivatives,
341 const TVectorD &extMeasurements,
342 const TMatrixDSym &extPrecisions) :
351 TMatrixDSymEigen extEigen(extPrecisions);
352 TMatrixD extTransformation = extEigen.GetEigenVectors();
353 extTransformation.T();
354 TMatrixD aDerivatives = extTransformation * extDerivatives;
355 TVectorD aMeasurements = extTransformation * extMeasurements;
356 TVectorD aPrecisions = extEigen.GetEigenValues();
358 unsigned int nExtMeas = aDerivatives.GetNrows();
359 unsigned int nExtPar = aDerivatives.GetNcols();
363 for (
unsigned int i = 0;
i < nExtMeas; ++
i) {
366 for (
unsigned int j = 0; j < nExtPar; ++j) {
370 for (
unsigned int iTraj = 0; iTraj < aPointsAndTransList.size(); ++iTraj) {
375 unsigned int nRowTrans = aPointsAndTransList[iTraj].second.GetNrows();
376 unsigned int nColTrans = aPointsAndTransList[iTraj].second.GetNcols();
377 MatrixXd aTrans(nRowTrans, nColTrans);
378 for (
unsigned int i = 0;
i < nRowTrans; ++
i) {
379 for (
unsigned int j = 0; j < nColTrans; ++j) {
380 aTrans(
i, j) = aPointsAndTransList[iTraj].second(
i, j);
413 unsigned int aLabel = 0;
415 std::cout <<
" GblTrajectory construction failed: too few GblPoints " 423 std::vector<GblPoint>::iterator itPoint;
425 itPoint <
thePoints[iTraj].end(); ++itPoint) {
428 itPoint->setLabel(++aLabel);
435 }
catch (std::overflow_error &
e) {
436 std::cout <<
" GblTrajectory construction failed: " << e.what()
459 std::vector<GblPoint>::iterator itPoint;
461 itPoint <
thePoints[iTraj].end() - 1; ++itPoint) {
462 if (itPoint->hasScatterer()) {
481 unsigned int numStep = 0;
482 std::vector<GblPoint>::iterator itPoint;
484 itPoint <
thePoints[iTraj].end(); ++itPoint) {
486 scatJacobian = itPoint->getP2pJacobian();
488 scatJacobian = itPoint->getP2pJacobian() * scatJacobian;
491 itPoint->addPrevJacobian(scatJacobian);
492 if (itPoint->getOffset() >= 0) {
495 previousPoint = &(*itPoint);
500 itPoint >
thePoints[iTraj].begin(); --itPoint) {
501 if (itPoint->getOffset() >= 0) {
505 itPoint->addNextJacobian(scatJacobian);
506 scatJacobian = scatJacobian * itPoint->getP2pJacobian();
521 int aSignedLabel)
const {
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);
534 unsigned int aLabel =
abs(aSignedLabel);
535 unsigned int firstLabel = 1;
536 unsigned int lastLabel = 0;
537 unsigned int aTrajectory = 0;
542 if (aLabel <= lastLabel)
544 if (iTraj < numTrajectories - 1)
549 if (aSignedLabel > 0) {
551 if (aLabel >= lastLabel) {
557 if (aLabel <= firstLabel) {
563 std::array<unsigned int, 5> labDer;
568 for (
unsigned int i = 0;
i < nLocals; ++
i) {
569 aJacobian(
i + 5,
i) = 1.0;
570 anIndex.push_back(
i + 1);
573 unsigned int iCol = nLocals;
574 for (
unsigned int i = 0;
i < 5; ++
i) {
576 anIndex.push_back(labDer[
i]);
577 for (
unsigned int j = 0; j < 5; ++j) {
578 aJacobian(j, iCol) = matDer(j, i);
583 return std::make_pair(anIndex, aJacobian);
598 unsigned int nJacobian)
const {
609 Matrix2d prevW, prevWJ, nextW, nextWJ, matN;
610 Vector2d prevWd, nextWd;
613 const Matrix2d sumWJ(prevWJ + nextWJ);
614 matN = sumWJ.inverse();
616 const Matrix2d prevNW(matN * prevW);
617 const Matrix2d nextNW(matN * nextW);
618 const Vector2d prevNd(matN * prevWd);
619 const Vector2d nextNd(matN * nextWd);
621 unsigned int iOff = nDim * (-nOffset - 1) + nLocals + nCurv + 1;
625 aJacobian.block<2, 1>(3, 0) = -prevNd - nextNd;
626 anIndex[0] = nLocals + 1;
628 aJacobian.block<2, 2>(3, 1) = prevNW;
629 aJacobian.block<2, 2>(3, 3) = nextNW;
630 for (
unsigned int i = 0;
i < nDim; ++
i) {
632 anIndex[3 + theDimension[
i]] = iOff + nDim +
i;
638 const Matrix2d prevWPN(nextWJ * prevNW);
639 const Matrix2d nextWPN(prevWJ * nextNW);
640 const Vector2d prevWNd(nextWJ * prevNd);
641 const Vector2d nextWNd(prevWJ * nextNd);
643 aJacobian(0, 0) = 1.0;
644 aJacobian.block<2, 1>(1, 0) = prevWNd - nextWNd;
646 aJacobian.block<2, 2>(1, 1) = -prevWPN;
647 aJacobian.block<2, 2>(1, 3) = nextWPN;
653 unsigned int iOff1 = nDim * nOffset + nCurv + nLocals + 1;
654 unsigned int index1 = 3 - 2 * nJacobian;
655 unsigned int iOff2 = iOff1 + nDim * (nJacobian * 2 - 1);
656 unsigned int index2 = 1 + 2 * nJacobian;
658 aJacobian(3, index1) = 1.0;
659 aJacobian(4, index1 + 1) = 1.0;
660 for (
unsigned int i = 0;
i < nDim; ++
i) {
666 Matrix2d matW, matWJ;
669 double sign = (nJacobian > 0) ? 1. : -1.;
671 aJacobian(0, 0) = 1.0;
672 aJacobian.block<2, 1>(1, 0) = -sign * vecWd;
673 anIndex[0] = nLocals + 1;
675 aJacobian.block<2, 2>(1, index1) = -sign * matWJ;
676 aJacobian.block<2, 2>(1, index2) = sign * matW;
677 for (
unsigned int i = 0;
i < nDim; ++
i) {
702 Matrix2d prevW, prevWJ, nextW, nextWJ;
703 Vector2d prevWd, nextWd;
706 const Matrix2d sumWJ(prevWJ + nextWJ);
707 const Vector2d sumWd(prevWd + nextWd);
709 unsigned int iOff = (nOffset - 1) * nDim + nCurv + nLocals + 1;
713 aJacobian.block<2, 1>(0, 0) = -sumWd;
714 anIndex[0] = nLocals + 1;
716 aJacobian.block<2, 2>(0, 1) = prevW;
717 aJacobian.block<2, 2>(0, 3) = -sumWJ;
718 aJacobian.block<2, 2>(0, 5) = nextW;
719 for (
unsigned int i = 0;
i < nDim; ++
i) {
721 anIndex[3 + theDimension[
i]] = iOff + nDim +
i;
722 anIndex[5 + theDimension[
i]] = iOff + nDim * 2 +
i;
742 MatrixXd &localCov)
const {
745 std::pair<std::vector<unsigned int>, MatrixXd> indexAndJacobian =
747 unsigned int nParBrl = indexAndJacobian.first.size();
748 VectorXd aVec(nParBrl);
749 for (
unsigned int i = 0;
i < nParBrl; ++
i) {
750 aVec[
i] =
theVector(indexAndJacobian.first[
i] - 1);
753 localPar = indexAndJacobian.second * aVec;
754 localCov = indexAndJacobian.second * aMat
755 * indexAndJacobian.second.adjoint();
773 unsigned int &numData, VectorXd &aResiduals, VectorXd &aMeasErrors,
774 VectorXd &aResErrors, VectorXd &aDownWeights) {
781 for (
unsigned int i = 0;
i < numData; ++
i) {
783 aMeasErrors(
i), aResErrors(
i), aDownWeights(
i));
802 unsigned int &numData, VectorXd &aResiduals, VectorXd &aMeasErrors,
803 VectorXd &aResErrors, VectorXd &aDownWeights) {
810 for (
unsigned int i = 0;
i < numData; ++
i) {
812 aResErrors(
i), aDownWeights(
i));
817 #ifdef GBL_EIGEN_SUPPORT_ROOT 834 TMatrixDSym &localCov)
const {
837 std::pair<std::vector<unsigned int>, MatrixXd> indexAndJacobian =
839 unsigned int nParBrl = indexAndJacobian.first.size();
840 VectorXd aVec(nParBrl);
841 for (
unsigned int i = 0;
i < nParBrl; ++
i) {
842 aVec[
i] =
theVector(indexAndJacobian.first[
i] - 1);
845 VectorXd aLocalPar = indexAndJacobian.second * aVec;
846 MatrixXd aLocalCov = indexAndJacobian.second * aMat
847 * indexAndJacobian.second.adjoint();
849 unsigned int nParOut = localPar.GetNrows();
850 for (
unsigned int i = 0;
i < nParOut; ++
i) {
851 localPar[
i] = aLocalPar(
i);
852 for (
unsigned int j = 0; j < nParOut; ++j) {
853 localCov(
i, j) = aLocalCov(
i, j);
873 unsigned int &numData, TVectorD &aResiduals, TVectorD &aMeasErrors,
874 TVectorD &aResErrors, TVectorD &aDownWeights) {
881 for (
unsigned int i = 0;
i < numData; ++
i) {
883 aMeasErrors[i], aResErrors[i], aDownWeights[i]);
902 unsigned int &numData, TVectorD &aResiduals, TVectorD &aMeasErrors,
903 TVectorD &aResErrors, TVectorD &aDownWeights) {
910 for (
unsigned int i = 0;
i < numData; ++
i) {
912 aResErrors[i], aDownWeights[i]);
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;
943 std::vector<std::vector<unsigned int> > &aLabelList) {
947 unsigned int aLabel = 0;
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;
971 double &aResidual,
double &aMeasError,
double &aResError,
972 double &aDownWeight) {
975 unsigned int numLocal;
976 unsigned int* indLocal;
978 theData[aData].getResidual(aResidual, aMeasVar, aDownWeight, numLocal,
980 VectorXd aVec(numLocal);
981 for (
unsigned int j = 0; j < numLocal; ++j) {
982 aVec[j] = derLocal[j];
985 double aFitVar = aVec.transpose() * aMat * aVec;
986 aMeasError =
sqrt(aMeasVar);
988 aResError = (aFitVar < aMeasVar ?
sqrt(aMeasVar - aFitVar) : 0.);
990 aResError =
sqrt(aMeasVar + aFitVar);
998 double aValue, aWeight;
999 unsigned int* indLocal;
1001 unsigned int numLocal;
1003 std::vector<GblData>::iterator itData;
1004 for (itData =
theData.begin(); itData <
theData.end(); ++itData) {
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;
1029 unsigned int nData = 0;
1030 std::vector<MatrixXd> innerTransDer;
1031 std::vector<std::array<unsigned int, 5> > innerTransLab;
1039 std::array<unsigned int, 5> firstLabels;
1040 Matrix5d matFitToLocal, matLocalToFit;
1043 matLocalToFit = matFitToLocal.inverse();
1046 innerTransLab.push_back(firstLabels);
1050 std::vector<GblPoint>::iterator itPoint;
1055 Eigen::ColMajor , 5, 5> proDer;
1059 itPoint <
thePoints[iTraj].end(); ++itPoint) {
1061 unsigned int nLabel = itPoint->getLabel();
1062 unsigned int measDim = itPoint->hasMeasurement();
1064 const MatrixXd localDer = itPoint->getLocalDerivatives();
1066 itPoint->getNumGlobals());
1068 itPoint->getMeasurement(matP, aMeas, aPrec);
1069 double minPrecision = itPoint->getMeasPrecMin();
1070 unsigned int iOff = 5 - measDim;
1071 std::array<unsigned int, 5> labDer;
1073 unsigned int nJacobian =
1074 (itPoint <
thePoints[iTraj].end() - 1) ? 1 : 0;
1078 matPDer = matP * matDer;
1080 matPDer.block<2, 5>(3, 0) = matP.block<2, 2>(3, 3)
1081 * matDer.block<2, 5>(3, 0);
1086 proDer.resize(measDim, Eigen::NoChange);
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) {
1097 labDer[ilabel] -= 2 * nDim * (iTraj + 1);
1101 for (
unsigned int k = iOff;
k < 5; ++
k) {
1102 proDer(
k - iOff, ifirst) = matPDer(
k,
1110 transDer = proDer * innerTransDer[iTraj];
1112 for (
unsigned int i = iOff;
i < 5; ++
i) {
1113 if (aPrec(
i) > minPrecision) {
1135 Eigen::ColMajor , 5, 5> proDer;
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);
1147 std::array<unsigned int, 7> labDer;
1150 matTDer = matT * matDer;
1153 proDer.resize(nDim, Eigen::NoChange);
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) {
1164 labDer[ilabel] -= 2 * nDim * (iTraj + 1);
1168 for (
unsigned int k = 0;
k < nDim; ++
k) {
1169 proDer(
k, ifirst) = matTDer(
k, ilabel);
1176 transDer = proDer * innerTransDer[iTraj];
1178 for (
unsigned int i = 0;
i < nDim; ++
i) {
1180 if (aPrec(iDim) > 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;
1208 if (valEigen(
i) > 0.) {
1210 externalSeedDerivatives[j] = vecEigen(
i, j);
1214 externalSeedDerivatives);
1226 for (
unsigned int iExt = 0; iExt < nExt; ++iExt) {
1227 for (
unsigned int iCol = 0; iCol <
numCurvature; ++iCol) {
1228 index[iCol] = iCol + 1;
1243 std::vector<GblData>::iterator itData;
1244 for (itData =
theData.begin(); itData <
theData.end(); ++itData) {
1255 std::vector<GblData>::iterator itData;
1256 for (itData =
theData.begin(); itData <
theData.end(); ++itData) {
1257 aLoss += (1. - itData->setDownWeighting(aMethod));
1276 const std::string& optionList,
unsigned int aLabel) {
1277 const double normChi2[4] = { 1.0, 0.8737, 0.9326, 0.8228 };
1286 unsigned int aMethod = 0;
1291 unsigned int ierr = 0;
1297 for (
unsigned int i = 0;
i < optionList.size(); ++
i)
1299 size_t aPosition = methodList.find(optionList[
i]);
1300 if (aPosition != std::string::npos) {
1301 aMethod = aPosition / 2 + 1;
1310 for (
unsigned int i = 0;
i <
theData.size(); ++
i) {
1318 Chi2 /= normChi2[aMethod];
1322 std::cout <<
" GblTrajectory::fit exception " << e << std::endl;
1333 unsigned int aPoint;
1335 unsigned int numLocal;
1336 unsigned int* labLocal;
1338 std::vector<int> labGlobal;
1339 std::vector<double> derGlobal;
1347 std::vector<GblData>::iterator itData;
1348 for (itData =
theData.begin(); itData !=
theData.end(); ++itData) {
1349 itData->getAllData(aValue, aErr, numLocal, labLocal, derLocal, aTraj,
1352 thePoints[aTraj][aPoint].getGlobalLabelsAndDerivatives(aRow,
1353 labGlobal, derGlobal);
1355 labGlobal.resize(0);
1356 aMille.
addData(aValue, aErr, numLocal, labLocal, derLocal, labGlobal,
1369 <<
" subtrajectories" << std::endl;
1371 std::cout <<
"Simple GblTrajectory" << std::endl;
1374 std::cout <<
" 2D-trajectory" << std::endl;
1384 std::cout <<
" Number of ext. measurements : " 1392 std::cout <<
" Constructed OK " << std::endl;
1395 std::cout <<
" Fitted OK " << std::endl;
1398 IOFormat CleanFmt(4, 0,
", ",
"\n",
"[",
"]");
1400 std::cout <<
" Inner transformations" << std::endl;
1407 std::cout <<
" External measurements" << std::endl;
1408 std::cout <<
" Measurements:" << std::endl;
1410 std::cout <<
" Precisions:" << std::endl;
1412 std::cout <<
" Derivatives:" << std::endl;
1416 std::cout <<
" External seed:" << std::endl;
1420 std::cout <<
" Fit results" << std::endl;
1421 std::cout <<
" Parameters:" << std::endl;
1423 std::cout <<
" Covariance matrix (bordered band part):" 1437 std::vector<GblPoint>::iterator itPoint;
1439 itPoint <
thePoints[iTraj].end(); ++itPoint) {
1440 itPoint->printPoint(level);
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();
void printMatrix() const
Print bordered band matrix.
std::vector< unsigned int > scatDataIndex
mapping points to data blocks from scatterers
void addBlockMatrix(double aWeight, const std::vector< unsigned int > *anIndex, const std::vector< double > *aVector)
Add symmetric block matrix.
void construct()
Construct trajectory from list of points.
void addNextJacobian(const Matrix5d &aJac)
Define jacobian to next scatterer (by GBLTrajectory constructor)
Data (block) for independent scalar measurement.
void buildLinearEquationSystem()
Build linear equation system from data (blocks).
void printTrajectory(unsigned int level=0)
Print GblTrajectory.
unsigned int numParameters
Number of fit parameters.
void writeRecord()
Write record to file.
bool constructOK
Trajectory has been successfully constructed (ready for fit/output)
std::vector< unsigned int > measDataIndex
mapping points to data blocks from measurements
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::vector< unsigned int > theDimension
List of active dimensions (0=u1, 1=u2) in fit.
void addDerivatives(unsigned int iRow, const std::array< unsigned int, 5 > &labDer, const Matrix5d &matDer, unsigned int iOff, const Eigen::MatrixBase< LocalDerivative > &derLocal, unsigned int nLocal, const Eigen::MatrixBase< TrafoDerivative > &derTrans)
Add derivatives from measurement.
unsigned int getLabels(std::vector< unsigned int > &aLabelList)
Get (list of) labels of points on (simple) valid trajectory.
void print() const
Print vector.
void predict()
Calculate predictions for all points.
int getOffset() const
Retrieve offset for point.
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.
void resize(const unsigned int nRows)
Resize vector.
Eigen::MatrixXd externalSeed
Precision (inverse covariance matrix) of external seed.
void defineOffsets()
Define offsets from list of points.
void addData(double aMeas, double aErr, unsigned int numLocal, unsigned int *indLocal, double *derLocal, const std::vector< int > &labGlobal, const std::vector< double > &derGlobal)
Add data block to (end of) record.
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.
Abs< T >::type abs(const T &t)
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, 5, 1 > Vector5d
Eigen::Matrix< double, 2, 7 > Matrix27d
unsigned int maxNumGlobals
Max. number of global labels/derivatives per point.
void resize(unsigned int nSize, unsigned int nBorder=1, unsigned int nBand=5)
Resize bordered band matrix.
std::vector< Eigen::MatrixXd > innerTransformations
Transformations at innermost points of.
Eigen::MatrixXd externalDerivatives
void getDerivatives(int aDirection, Eigen::Matrix2d &matW, Eigen::Matrix2d &matWJ, Eigen::Vector2d &vecWd) const
Retrieve derivatives of local track model.
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.
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.
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.
void solveAndInvertBorderedBand(const VVector &aRightHandSide, VVector &aSolution)
Solve linear equation system, partially calculate inverse.
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)
const Matrix5d & getP2pJacobian() const
Retrieve point-to-(previous)point jacobian.
Eigen::VectorXd externalPrecisions
Eigen::Matrix< double, 5, 5 > Matrix5d