CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoVertex/KinematicFitPrimitives/interface/MultiTrackKinematicConstraintT.h

Go to the documentation of this file.
00001 #ifndef MultiTrackKinematicConstraintT_H
00002 #define MultiTrackKinematicConstraintT_H
00003 
00004 #include "RecoVertex/KinematicFitPrimitives/interface/RefCountedKinematicParticle.h"
00005 #include "RecoVertex/KinematicFitPrimitives/interface/RefCountedKinematicVertex.h"
00006 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00007 
00008 
00027 class MultiTrackKinematicConstraintBaseT
00028 {
00029 public:
00030   virtual ~MultiTrackKinematicConstraintBaseT() {}
00031 
00032  // initialize the constraint so it can precompute common qualtities to the three next call
00033   virtual void init(const std::vector<KinematicState>& states,
00034                     const GlobalPoint& point,  const GlobalVector& mf) =0;
00035 
00036   virtual int numberOfEquations() const = 0;
00037   
00038   virtual MultiTrackKinematicConstraintBaseT * clone() const = 0;
00039 
00040 
00041 };
00042 
00043 template<int NTRK, int DIM>
00044 class MultiTrackKinematicConstraintT : public MultiTrackKinematicConstraintBaseT
00045 {
00046 public:
00047   enum {nTrk=NTRK, nDim=DIM};
00048 
00049   typedef MultiTrackKinematicConstraintT<NTRK, DIM> self;
00050 
00051   typedef ROOT::Math::SVector<double, DIM>  valueType; 
00052   
00053   typedef ROOT::Math::SMatrix<double, DIM,7*NTRK> parametersDerivativeType;
00054   
00055 
00056   typedef ROOT::Math::SMatrix<double, DIM,3> positionDerivativeType;
00057 
00058 
00059   virtual ~MultiTrackKinematicConstraintT() {}
00060 
00061 
00070   valueType const & value() const {
00071     fillValue();
00072     return m_vl;
00073   } 
00074   
00075   parametersDerivativeType const & parametersDerivative() const {
00076     fillParametersDerivative();
00077     return m_jac_d;
00078   };
00079   
00080 
00081   positionDerivativeType const &  positionDerivative() const {
00082     fillPositionDerivative();
00083     return m_jac_e;
00084   }
00085  
00086 private:
00095   virtual  void fillValue() const = 0; 
00096   
00097   virtual  void fillParametersDerivative() const = 0;
00098   
00099 
00100   virtual void fillPositionDerivative() const = 0;
00101   
00102 protected:
00103 
00104   valueType & vl() const { return m_vl; }
00105   parametersDerivativeType & jac_d() const { return m_jac_d;}
00106   positionDerivativeType & jac_e() const { return m_jac_e;}
00107 
00108   // self & me() const { return *const_cast<self*>(this); }
00109 
00110   double & vl(size_t i) const { return m_vl(i);}
00111   double & jac_d(size_t i, size_t j) const { return m_jac_d(i,j);}
00112   double & jac_e(size_t i, size_t j) const { return m_jac_e(i,j);}
00113 
00114 private:
00115 
00116   mutable valueType m_vl;
00117   mutable parametersDerivativeType m_jac_d;
00118   mutable positionDerivativeType m_jac_e;
00119 
00120 };
00121 
00122 
00123 #endif