Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef MultiTrackKinematicConstraintT_H
0002 #define MultiTrackKinematicConstraintT_H
0003 
0004 #include "RecoVertex/KinematicFitPrimitives/interface/RefCountedKinematicParticle.h"
0005 #include "RecoVertex/KinematicFitPrimitives/interface/RefCountedKinematicVertex.h"
0006 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0007 
0008 /**
0009  * Pure abstract class implementing constraint application 
0010  * on multiple tracks (back to back, collinearity etc.)
0011  * To be used by KinematicConstraindeVertexFitter only
0012  * Class caches the information about calculation of
0013  * of constraint equation derivatives and values at given
0014  * linearization point. Point should be of 7*n+3 dimensions
0015  * Where n - number of particles. 7 - parametrization for 
0016  * particles is (x,y,z,p_x,p_y,p_z,m), for vertex (x_v,y_v,z_v)
0017  * Fitter usually takes current parameters as the first step point
0018  * and the change it to the result of the first iteration.
0019  *
0020  * Kirill Prokofiev, October 2003
0021  *
0022  * New version: make use of SMatrix: optimize filling of matrices
0023  * Vincenzo Innocente, October 2010
0024  */
0025 
0026 class MultiTrackKinematicConstraintBaseT {
0027 public:
0028   virtual ~MultiTrackKinematicConstraintBaseT() {}
0029 
0030   // initialize the constraint so it can precompute common qualtities to the three next call
0031   virtual void init(const std::vector<KinematicState>& states, const GlobalPoint& point, const GlobalVector& mf) = 0;
0032 
0033   virtual int numberOfEquations() const = 0;
0034 
0035   virtual MultiTrackKinematicConstraintBaseT* clone() const = 0;
0036 };
0037 
0038 template <int NTRK, int DIM>
0039 class MultiTrackKinematicConstraintT : public MultiTrackKinematicConstraintBaseT {
0040 public:
0041   enum { nTrk = NTRK, nDim = DIM };
0042 
0043   typedef MultiTrackKinematicConstraintT<NTRK, DIM> self;
0044 
0045   typedef ROOT::Math::SVector<double, DIM> valueType;
0046 
0047   typedef ROOT::Math::SMatrix<double, DIM, 7 * NTRK> parametersDerivativeType;
0048 
0049   typedef ROOT::Math::SMatrix<double, DIM, 3> positionDerivativeType;
0050 
0051   ~MultiTrackKinematicConstraintT() override {}
0052 
0053   /**
0054    * Methods returning vector of values
0055    * and derivative matrices with
0056    * respect to vertex position and
0057    * particle parameters.
0058    * Input paramters are put into one vector: 
0059    * (Vertex position, particle_parameters_1,..., particle_parameters_n)
0060    */
0061   valueType const& value() const {
0062     fillValue();
0063     return m_vl;
0064   }
0065 
0066   parametersDerivativeType const& parametersDerivative() const {
0067     fillParametersDerivative();
0068     return m_jac_d;
0069   };
0070 
0071   positionDerivativeType const& positionDerivative() const {
0072     fillPositionDerivative();
0073     return m_jac_e;
0074   }
0075 
0076 private:
0077   /**
0078    * Methods making vector of values
0079    * and derivative matrices with
0080    * respect to vertex position and
0081    * particle parameters.
0082    * Input paramters are put into one vector: 
0083    * (Vertex position, particle_parameters_1,..., particle_parameters_n)
0084    */
0085   virtual void fillValue() const = 0;
0086 
0087   virtual void fillParametersDerivative() const = 0;
0088 
0089   virtual void fillPositionDerivative() const = 0;
0090 
0091 protected:
0092   valueType& vl() const { return m_vl; }
0093   parametersDerivativeType& jac_d() const { return m_jac_d; }
0094   positionDerivativeType& jac_e() const { return m_jac_e; }
0095 
0096   // self & me() const { return *const_cast<self*>(this); }
0097 
0098   double& vl(size_t i) const { return m_vl(i); }
0099   double& jac_d(size_t i, size_t j) const { return m_jac_d(i, j); }
0100   double& jac_e(size_t i, size_t j) const { return m_jac_e(i, j); }
0101 
0102 private:
0103   mutable valueType m_vl;
0104   mutable parametersDerivativeType m_jac_d;
0105   mutable positionDerivativeType m_jac_e;
0106 };
0107 
0108 #endif