Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CachingVertex_H
0002 #define CachingVertex_H
0003 
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
0006 #include "DataFormats/GeometryCommonDetAlgo/interface/GlobalWeight.h"
0007 
0008 #include "RecoVertex/VertexPrimitives/interface/VertexState.h"
0009 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
0010 
0011 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h"
0012 #include "RecoVertex/VertexPrimitives/interface/VertexTrack.h"
0013 
0014 #include <vector>
0015 #include <map>
0016 
0017 /** Class for vertices fitted with Kalman and linear fit algorithms. 
0018  *  Provides access to temporary data to speed up the vertex update. 
0019  */
0020 
0021 template <unsigned int N>
0022 class CachingVertex {
0023 public:
0024   typedef ReferenceCountingPointer<VertexTrack<N> > RefCountedVertexTrack;
0025   typedef ROOT::Math::SMatrix<double, N, N, ROOT::Math::MatRepSym<double, N> > AlgebraicSymMatrixNN;
0026   typedef ROOT::Math::SMatrix<double, N - 2, N - 2, ROOT::Math::MatRepStd<double, N - 2, N - 2> > AlgebraicMatrixMM;
0027   typedef std::map<RefCountedVertexTrack, AlgebraicMatrixMM> TrackMap;
0028   typedef std::map<RefCountedVertexTrack, TrackMap> TrackToTrackMap;
0029 
0030   /** Constructors
0031    */
0032   // no time
0033   CachingVertex(const GlobalPoint &pos,
0034                 const GlobalError &posErr,
0035                 const std::vector<RefCountedVertexTrack> &tks,
0036                 float totalChiSq);
0037 
0038   CachingVertex(const GlobalPoint &pos,
0039                 const GlobalWeight &posWeight,
0040                 const std::vector<RefCountedVertexTrack> &tks,
0041                 float totalChiSq);
0042 
0043   CachingVertex(const AlgebraicVector3 &weightTimesPosition,
0044                 const GlobalWeight &posWeight,
0045                 const std::vector<RefCountedVertexTrack> &tks,
0046                 float totalChiSq);
0047 
0048   CachingVertex(const GlobalPoint &priorPos,
0049                 const GlobalError &priorErr,
0050                 const AlgebraicVector3 &weightTimesPosition,
0051                 const GlobalWeight &posWeight,
0052                 const std::vector<RefCountedVertexTrack> &tks,
0053                 float totalChiSq);
0054 
0055   // with time (tracks must have time as well)
0056   CachingVertex(const GlobalPoint &pos,
0057                 const double time,
0058                 const GlobalError &posTimeErr,
0059                 const std::vector<RefCountedVertexTrack> &tks,
0060                 float totalChiSq);
0061 
0062   CachingVertex(const GlobalPoint &pos,
0063                 const double time,
0064                 const GlobalWeight &posTimeWeight,
0065                 const std::vector<RefCountedVertexTrack> &tks,
0066                 float totalChiSq);
0067 
0068   CachingVertex(const AlgebraicVector4 &weightTimesPosition,
0069                 const GlobalWeight &posTimeWeight,
0070                 const std::vector<RefCountedVertexTrack> &tks,
0071                 float totalChiSq);
0072 
0073   CachingVertex(const GlobalPoint &priorPos,
0074                 const GlobalError &priorErr,
0075                 const AlgebraicVector4 &weightTimesPosition,
0076                 const GlobalWeight &posWeight,
0077                 const std::vector<RefCountedVertexTrack> &tks,
0078                 float totalChiSq);
0079 
0080   // either time or no time (depends on if the tracks/vertex states have times)
0081   CachingVertex(const GlobalPoint &priorPos,
0082                 const GlobalError &priorErr,
0083                 const GlobalPoint &pos,
0084                 const GlobalError &posErr,
0085                 const std::vector<RefCountedVertexTrack> &tks,
0086                 float totalChiSq);
0087 
0088   CachingVertex(const GlobalPoint &priorPos,
0089                 const double priorTime,
0090                 const GlobalError &priorErr,
0091                 const GlobalPoint &pos,
0092                 const double time,
0093                 const GlobalError &posErr,
0094                 const std::vector<RefCountedVertexTrack> &tks,
0095                 float totalChiSq);
0096 
0097   CachingVertex(const GlobalPoint &priorPos,
0098                 const GlobalError &priorErr,
0099                 const GlobalPoint &pos,
0100                 const GlobalWeight &posWeight,
0101                 const std::vector<RefCountedVertexTrack> &tks,
0102                 float totalChiSq);
0103 
0104   CachingVertex(const GlobalPoint &priorPos,
0105                 const double priorTime,
0106                 const GlobalError &priorErr,
0107                 const GlobalPoint &pos,
0108                 const double time,
0109                 const GlobalWeight &posWeight,
0110                 const std::vector<RefCountedVertexTrack> &tks,
0111                 float totalChiSq);
0112 
0113   CachingVertex(const VertexState &aVertexState, const std::vector<RefCountedVertexTrack> &tks, float totalChiSq);
0114 
0115   CachingVertex(const VertexState &priorVertexState,
0116                 const VertexState &aVertexState,
0117                 const std::vector<RefCountedVertexTrack> &tks,
0118                 float totalChiSq);
0119 
0120   CachingVertex(const VertexState &aVertexState,
0121                 const std::vector<RefCountedVertexTrack> &tks,
0122                 float totalChiSq,
0123                 const TrackToTrackMap &covMap);
0124 
0125   CachingVertex(const VertexState &priorVertexState,
0126                 const VertexState &aVertexState,
0127                 const std::vector<RefCountedVertexTrack> &tks,
0128                 float totalChiSq,
0129                 const TrackToTrackMap &covMap);
0130 
0131   /** Constructor for invalid CachingVertex
0132    */
0133   CachingVertex();
0134 
0135   /** Access methods
0136    */
0137   VertexState const &vertexState() const { return theVertexState; }
0138   VertexState const &priorVertexState() const { return thePriorVertexState; }
0139   GlobalPoint position() const;
0140   double time() const;
0141   GlobalError error() const;
0142   GlobalError error4D() const;
0143   GlobalWeight weight() const;
0144   GlobalWeight weight4D() const;
0145   AlgebraicVector3 weightTimesPosition() const;
0146   AlgebraicVector4 weightTimesPosition4D() const;
0147   std::vector<RefCountedVertexTrack> tracks() const { return theTracks; }
0148   const std::vector<RefCountedVertexTrack> &tracksRef() const { return theTracks; }
0149   GlobalPoint priorPosition() const { return priorVertexState().position(); }
0150   double priorTime() const { return priorVertexState().time(); }
0151   GlobalError priorError() const { return priorVertexState().error(); }
0152   GlobalError priorError4D() const { return priorVertexState().error4D(); }
0153   bool hasPrior() const { return withPrior; }
0154   bool isValid() const { return theValid; }
0155   bool is4D() const { return vertexIs4D; }
0156 
0157   /** Chi2, degrees of freedom. The latter may not be integer. 
0158    */
0159   float totalChiSquared() const { return theChiSquared; }
0160   float degreesOfFreedom() const;
0161 
0162   /** Track to track covariance
0163    */
0164   AlgebraicMatrixMM tkToTkCovariance(const RefCountedVertexTrack t1, const RefCountedVertexTrack t2) const;
0165   bool tkToTkCovarianceIsAvailable() const { return theCovMapAvailable; }
0166 
0167   operator TransientVertex() const;
0168 
0169 private:
0170   void computeNDF() const;
0171 
0172   mutable VertexState theVertexState;
0173   float theChiSquared;
0174   mutable float theNDF;
0175   mutable bool theNDFAvailable;
0176   std::vector<RefCountedVertexTrack> theTracks;
0177   TrackToTrackMap theCovMap;
0178   bool theCovMapAvailable;
0179   mutable VertexState thePriorVertexState;
0180   bool withPrior;
0181 
0182   bool theValid;
0183   bool vertexIs4D;
0184 };
0185 
0186 #endif