# Project CMSSW displayed by LXR

File indexing completed on 2023-10-25 10:05:45

```0001 #ifndef _TRACKER_LOCALTRAJECTORYERROR_H_
0002 #define _TRACKER_LOCALTRAJECTORYERROR_H_
0003
0004 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0005 #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
0006 #include <memory>
0007
0008 /** Class providing access to the covariance matrix of a set of relevant parameters of a trajectory
0009  *  in a local, Cartesian frame. The errors provided are: <BR> <BR>
0010  *
0011  *  sigma^2(q/p) : charge (plus or minus one) divided by magnitude of momentum <BR>
0012  *  sigma^2(dxdz) : direction tangent in local xz-plane <BR>
0013  *  sigma^2(dydz) : direction tangent in local yz-plane <BR>
0014  *  sigma^2(x) : local x-coordinate <BR>
0015  *  sigma^2(y) : local y-coordinate <BR> <BR>
0016  *
0017  *  plus the relevant correlation terms.
0018  */
0019
0020 class LocalTrajectoryError {
0021 public:
0022   // construct
0023   LocalTrajectoryError() {}
0024
0025   LocalTrajectoryError(InvalidError) : theCovarianceMatrix(ROOT::Math::SMatrixNoInit()) {
0026     theCovarianceMatrix(0, 0) = -99999.e10;
0027   }
0028   // destruct
0029   ~LocalTrajectoryError() {}
0030
0031   bool invalid() const { return theCovarianceMatrix(0, 0) < -1.e10; }
0032   bool valid() const { return !invalid(); }
0033
0034   // not really full check of posdef
0035   bool posDef() const {
0036     return (theCovarianceMatrix(0, 0) >= 0) && (theCovarianceMatrix(1, 1) >= 0) && (theCovarianceMatrix(2, 2) >= 0) &&
0037            (theCovarianceMatrix(3, 3) >= 0) && (theCovarianceMatrix(4, 4) >= 0);
0038   }
0039
0040   /** Constructing class from a full covariance matrix. The sequence of the parameters is
0041    *  the same as the one described above.
0042    */
0043
0044   LocalTrajectoryError(const AlgebraicSymMatrix55 &aCovarianceMatrix)
0045       : theCovarianceMatrix(aCovarianceMatrix), theWeightMatrixPtr() {}
0046
0047   /** Constructing class from standard deviations of the individual parameters, making
0048    *  the covariance matrix diagonal. The sequence of the input parameters is sigma(x), sigma(y),
0049    *  sigma(dxdz), sigma(dydz), sigma(q/p), but the resulting covariance matrix has the
0050    *  same structure as the one described above.
0051    */
0052
0053   LocalTrajectoryError(float dx, float dy, float dxdir, float dydir, float dpinv);
0054
0055   // access
0056
0057   /** Returns the covariance matrix.
0058    */
0059
0060   const AlgebraicSymMatrix55 &matrix() const { return theCovarianceMatrix; }
0061
0062   /** Returns the inverse of covariance matrix.
0063    */
0064   const AlgebraicSymMatrix55 &weightMatrix() const;
0065
0066   /** Enables the multiplication of the covariance matrix with the scalar "factor".
0067    */
0068
0069   LocalTrajectoryError &operator*=(double factor) {
0070     theCovarianceMatrix *= factor;
0071     if ((theWeightMatrixPtr.get() != nullptr) && (factor != 0.0)) {
0072       (*theWeightMatrixPtr) /= factor;
0073     }
0074     return *this;
0075   }
0076
0077   /** Returns the two-by-two submatrix of the covariance matrix which yields the local
0078    *  position errors as well as the correlation between them.
0079    */
0080
0081   LocalError positionError() const {
0082     return LocalError(theCovarianceMatrix(3, 3), theCovarianceMatrix(3, 4), theCovarianceMatrix(4, 4));
0083   }
0084
0085 private:
0086   AlgebraicSymMatrix55 theCovarianceMatrix;
0087   mutable std::shared_ptr<AlgebraicSymMatrix55> theWeightMatrixPtr;
0088 };
0089
0090 #endif```