CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/RecoVertex/KinematicFit/src/MomentumKinematicConstraint.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFit/interface/MomentumKinematicConstraint.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003 
00004 
00005 MomentumKinematicConstraint::MomentumKinematicConstraint(const AlgebraicVector& momentum,
00006                                                          const AlgebraicVector& dev)
00007 {
00008  if((momentum.num_row() != 3) || (dev.num_row() != 3))
00009      throw VertexException("MomentumKinemticConstraint::Momentum or Deviation vector passed is not 3-dimensional");
00010  mm = momentum;
00011  AlgebraicVector dev_l(7,0);
00012  dev_l(4) = dev(1) * dev(1);
00013  dev_l(5) = dev(2) * dev(2);
00014  dev_l(6) = dev(3) * dev(3);
00015  dd = dev_l;
00016 }
00017 
00018 std::pair<AlgebraicVector,AlgebraicVector> MomentumKinematicConstraint::value(const AlgebraicVector& exPoint) const
00019 {
00020  if(exPoint.num_row() ==0 ) throw VertexException("MomentumKinematicConstraint::value requested for zero Linearization point");
00021 
00022 //security check for extended cartesian parametrization 
00023  int inSize = exPoint.num_row(); 
00024  if((inSize%7) !=0) throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
00025  int nStates = inSize/7;
00026  if(nStates != 1) throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint"); 
00027  AlgebraicVector pr = exPoint;
00028  AlgebraicVector vl(3,0);
00029  vl(1) = pr(4) - mm(1);
00030  vl(2) = pr(5) - mm(2);
00031  vl(3) = pr(6) - mm(3);
00032  return std::pair<AlgebraicVector,AlgebraicVector>(vl,pr); 
00033 }
00034 
00035 std::pair<AlgebraicMatrix, AlgebraicVector> MomentumKinematicConstraint::derivative(const AlgebraicVector& exPoint) const
00036 {
00037  if(exPoint.num_row() ==0 ) throw VertexException("MomentumKinematicConstraint::derivative requested for zero Linearization point");
00038 
00039 //security check for extended cartesian parametrization 
00040  int inSize = exPoint.num_row(); 
00041  if((inSize%7) !=0) throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
00042  int nStates = inSize/7;
00043  if(nStates != 1) throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint"); 
00044 
00045  AlgebraicVector pr = exPoint;
00046  AlgebraicMatrix dr(3,7,0);
00047  dr(1,4) = 1.;
00048  dr(2,5) = 1.;
00049  dr(3,6) = 1.;
00050  return std::pair<AlgebraicMatrix,AlgebraicVector>(dr,pr);
00051 }
00052 
00053 std::pair<AlgebraicVector, AlgebraicVector> MomentumKinematicConstraint::value(const std::vector<RefCountedKinematicParticle> par) const
00054 {
00055  int nStates = par.size(); 
00056  if(nStates == 0) throw VertexException("MomentumKinematicConstraint::Empty vector of particles passed");
00057  if(nStates != 1) throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");  
00058  AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
00059  AlgebraicVector vl(3,0);
00060  vl(1) = point(4) - mm(1);
00061  vl(2) = point(5) - mm(2);
00062  vl(3) = point(6) - mm(3);
00063  return std::pair<AlgebraicVector,AlgebraicVector>(vl,point);
00064 }
00065 
00066 std::pair<AlgebraicMatrix, AlgebraicVector> MomentumKinematicConstraint::derivative(const std::vector<RefCountedKinematicParticle> par) const
00067 {
00068  int nStates = par.size();
00069  if(nStates == 0) throw VertexException("MomentumKinematicConstraint::Empty vector of particles passed");
00070  if(nStates != 1) throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");
00071  AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
00072  AlgebraicMatrix dr(3,7,0);
00073  dr(1,4) = 1.;
00074  dr(2,5) = 1.;
00075  dr(3,6) = 1.;
00076  return std::pair<AlgebraicMatrix,AlgebraicVector>(dr,point);
00077 }
00078 
00079 AlgebraicVector MomentumKinematicConstraint::deviations(int nStates) const
00080 {
00081  if(nStates == 0) throw VertexException("MomentumKinematicConstraint::Empty vector of particles passed");
00082  if(nStates != 1) throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");
00083  AlgebraicVector res = dd;
00084  return res;
00085 }
00086 
00087 int MomentumKinematicConstraint::numberOfEquations() const
00088 {return 3;}
00089