Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:23

0001 #ifndef VertexTrack_H
0002 #define VertexTrack_H
0003 
0004 #include "RecoVertex/VertexPrimitives/interface/LinearizedTrackState.h"
0005 #include "RecoVertex/VertexPrimitives/interface/VertexState.h"
0006 #include "RecoVertex/VertexPrimitives/interface/RefittedTrackState.h"
0007 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
0008 
0009 #define SMATRIX_USE_CONSTEXPR
0010 #include "Math/SMatrix.h"
0011 
0012 /** Track information relative to a track-to-vertex association. 
0013  *  The track weight corresponds to the distance 
0014  *  of the track to the seed position. 
0015  */
0016 
0017 template <unsigned int N>
0018 class VertexTrack final : public ReferenceCounted {
0019 public:
0020   typedef ROOT::Math::SVector<double, N> AlgebraicVectorN;
0021   typedef ROOT::Math::SMatrix<double, N - 2, N - 2, ROOT::Math::MatRepStd<double, N - 2, N - 2> > AlgebraicMatrixMM;
0022   typedef ROOT::Math::SMatrix<double, 3, N - 2, ROOT::Math::MatRepStd<double, 3, N - 2> > AlgebraicMatrix3M;
0023   typedef ROOT::Math::SMatrix<double, N + 1, N + 1, ROOT::Math::MatRepSym<double, N + 1> > AlgebraicSymMatrixOO;
0024 
0025   //typedef ReferenceCountingPointer<VertexTrack<N> > RefCountedVertexTrack;
0026   typedef ReferenceCountingPointer<LinearizedTrackState<N> > RefCountedLinearizedTrackState;
0027   typedef ReferenceCountingPointer<RefittedTrackState<N> > RefCountedRefittedTrackState;
0028 
0029   /** Constructor with the linearized track data, vertex seed and weight
0030    */
0031   VertexTrack(RefCountedLinearizedTrackState lt, VertexState v, float weight);
0032 
0033   /** Constructor with the linearized track data, vertex seed and weight
0034    *  and state at vertex, constrained by vertex
0035    */
0036   VertexTrack(RefCountedLinearizedTrackState lt,
0037               VertexState v,
0038               float weight,
0039               const RefCountedRefittedTrackState& refittedState,
0040               float smoothedChi2);
0041 
0042   /** Constructor with the linearized track data, vertex seed and weight
0043    *  and state and covariance at vertex, constrained by vertex
0044    */
0045   VertexTrack(RefCountedLinearizedTrackState lt,
0046               VertexState v,
0047               float weight,
0048               const RefCountedRefittedTrackState& refittedState,
0049               float smoothedChi2,
0050               const AlgebraicSymMatrixOO& fullCov);
0051 
0052   /** Access methods
0053    */
0054   RefCountedLinearizedTrackState linearizedTrack() const { return theLinTrack; }
0055   VertexState vertexState() const { return theVertexState; }
0056   float weight() const { return theWeight; }
0057   bool refittedStateAvailable() const { return stAvailable; }
0058   bool tkToVertexCovarianceAvailable() const { return covAvailable; }
0059   bool fullCovarianceAvailable() const { return covAvailable; }
0060 
0061   /**
0062    * The smoother track-chi2 (can be used to test the track-vertex compatibility).
0063    * Its value has a meaning only if the smoother has been run after the vertex
0064    * fit (track-refit) . Otherwise, the value returned is -1.
0065    */
0066 
0067   float smoothedChi2() const { return smoothedChi2_; }
0068 
0069   /** Track state with vertex constraint
0070    */
0071   RefCountedRefittedTrackState refittedState() const {
0072     if (!refittedStateAvailable()) {
0073       throw VertexException("VertexTrack::refitted state not available");
0074     }
0075     return theRefittedState;
0076   }
0077 
0078   //   /** Track to vertex covariance
0079   //    */
0080   //   AlgebraicMatrix3M tkToVtxCovariance() const;
0081 
0082   /** Track to vertex covariance 
0083    */
0084   AlgebraicSymMatrixOO fullCovariance() const {
0085     if (!tkToVertexCovarianceAvailable()) {
0086       throw VertexException("VertexTrack::track to vertex covariance not available");
0087     }
0088     return fullCovariance_;
0089   }
0090 
0091   /** Equality for finding a VertexTrack in a container
0092    *  Compares the RecTrack addresses
0093    */
0094   bool operator==(const VertexTrack<N>& data) const { return ((*data.linearizedTrack()) == (*linearizedTrack())); }
0095 
0096   /** Method helping Kalman vertex fit
0097    */
0098   AlgebraicVectorN refittedParamFromEquation() const;
0099 
0100 private:
0101   RefCountedLinearizedTrackState theLinTrack;
0102   VertexState theVertexState;
0103   float theWeight;
0104   bool stAvailable;
0105   bool covAvailable;
0106   RefCountedRefittedTrackState theRefittedState;
0107   AlgebraicSymMatrixOO fullCovariance_;
0108   ROOT::Math::SMatrix<double, 6, 6, ROOT::Math::MatRepSym<double, 6> > b6;
0109   ROOT::Math::SMatrix<double, 7, 7, ROOT::Math::MatRepSym<double, 7> > b7;
0110   float smoothedChi2_;
0111 };
0112 
0113 template <unsigned int N>
0114 class VertexTrackEqual {
0115 public:
0116   typedef ReferenceCountingPointer<VertexTrack<N> > RefCountedVertexTrack;
0117   VertexTrackEqual(const RefCountedVertexTrack& t) : track_(t) {}
0118   bool operator()(const RefCountedVertexTrack& t) const { return t->operator==(*track_); }
0119 
0120 private:
0121   const RefCountedVertexTrack& track_;
0122 };
0123 
0124 #endif