CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoVertex/KinematicFit/src/MassKinematicConstraint.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFit/interface/MassKinematicConstraint.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003 
00004 MassKinematicConstraint::MassKinematicConstraint(const ParticleMass& m, const float sigma)
00005 {
00006  mass = m;
00007  AlgebraicVector deviation_l(7,0);
00008  deviation_l(7) = sigma * sigma; 
00009  dd = deviation_l;
00010 }
00011 
00012 std::pair<AlgebraicVector, AlgebraicVector> MassKinematicConstraint::value(const AlgebraicVector& exPoint) const
00013 {
00014 
00015 //we have only one equation and only one track, means the constraint value 
00016 //for track parameters is just a single number
00017  if(exPoint.num_row() ==0 ) throw VertexException("MomentumKinematicConstraint::value requested for zero Linearization point");
00018 
00019 //security check for extended cartesian parametrization 
00020  int inSize = exPoint.num_row(); 
00021  if((inSize%7) !=0) throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
00022  int nStates = inSize/7;
00023  if(nStates !=1) throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
00024  AlgebraicVector vl(1,0);
00025  AlgebraicVector point = exPoint;
00026  vl(1) = point(7) - mass; 
00027  return std::pair<AlgebraicVector,AlgebraicVector>(vl,point);
00028 }
00029 
00030 std::pair<AlgebraicMatrix, AlgebraicVector> MassKinematicConstraint::derivative(const AlgebraicVector& exPoint) const
00031 {
00032  if(exPoint.num_row() == 0) throw VertexException("MomentumKinematicConstraint::deriavtive requested for zero Linearization point");
00033 
00034 //security check for extended cartesian parametrization 
00035  int inSize = exPoint.num_row(); 
00036  if((inSize%7) !=0) throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
00037  int nStates = inSize/7;
00038  if(nStates !=1) throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
00039  AlgebraicMatrix dr(1,7,0);
00040  dr(1,7) = 1; 
00041  AlgebraicVector point = exPoint;
00042  return std::pair<AlgebraicMatrix,AlgebraicVector>(dr,point); 
00043 }
00044 
00045 std::pair<AlgebraicVector, AlgebraicVector> MassKinematicConstraint::value(const std::vector<RefCountedKinematicParticle> par) const
00046 {
00047  int nStates = par.size();
00048  if(nStates == 0) throw VertexException("MassKinematicConstraint::empty vector of particles passed");
00049  if(nStates !=1) throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
00050  
00051  AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
00052  AlgebraicVector vl(1,0);
00053  vl(1) = point(7) - mass;
00054  return std::pair<AlgebraicVector,AlgebraicVector>(vl,point);
00055 } 
00056 
00057 std::pair<AlgebraicMatrix, AlgebraicVector> MassKinematicConstraint::derivative(const std::vector<RefCountedKinematicParticle> par) const
00058 {
00059  int nStates = par.size();
00060  if(nStates == 0) throw VertexException("MassKinematicConstraint::empty vector of particles passed");
00061  if(nStates !=1) throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
00062 
00063  AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
00064  AlgebraicMatrix dr(1,7,0);
00065  dr(1,7) = 1;
00066  return std::pair<AlgebraicMatrix,AlgebraicVector>(dr,point);
00067 }
00068 
00069 AlgebraicVector MassKinematicConstraint::deviations(int nStates) const
00070 {
00071  if(nStates == 0) throw VertexException("MassKinematicConstraint::empty vector of particles passed");
00072  if(nStates !=1) throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
00073  AlgebraicVector res = dd;
00074  return res;
00075 }
00076 
00077 int MassKinematicConstraint::numberOfEquations() const 
00078 {return 1;}
00079 
00080 
00081 
00082 
00083 
00084 
00085