CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/RecoVertex/KinematicFit/src/BackToBackKinematicConstraint.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFit/interface/BackToBackKinematicConstraint.h"
00002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
00003 #include "DataFormats/CLHEP/interface/Migration.h"
00004 
00005 std::pair<AlgebraicVector, AlgebraicVector> BackToBackKinematicConstraint::value(const AlgebraicVector& exPoint) const
00006 {
00007 //security check for extended cartesian parametrization 
00008  int inSize = exPoint.num_row(); 
00009  if(inSize != 14) throw VertexException("BackToBackKinematicConstraint::linearization point has a wrong dimension");
00010  AlgebraicVector pr = exPoint;
00011  
00012 //number of states should be always equal to 2 for such a constraint
00013  AlgebraicVector vl(3,0);
00014  vl(1) = pr(4)+pr(11);
00015  vl(2) = pr(5)+pr(12);
00016  vl(3) = pr(6)+pr(13);
00017  return std::pair<AlgebraicVector, AlgebraicVector>(vl,pr); 
00018 }
00019 
00020 std::pair<AlgebraicMatrix, AlgebraicVector> BackToBackKinematicConstraint::derivative(const AlgebraicVector& exPoint) const
00021 {
00022 //security check for extended cartesian parametrization 
00023  int inSize = exPoint.num_row(); 
00024  if(inSize != 14) throw VertexException("BackToBackKinematicConstraint::linearization point has a wrong dimension");
00025  AlgebraicVector pr = exPoint;
00026  
00027 //number of states should be always equal to 2 for such a constraint 
00028  AlgebraicMatrix dr(3,14,0);
00029  dr(1,4) = 1.;
00030  dr(1,11) = 1.;
00031  dr(2,5) = 1;
00032  dr(2,12) = 1;
00033  dr(3,6) = 1;
00034  dr(3,13) = 1;
00035  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr,pr); 
00036 }
00037 
00038 std::pair<AlgebraicVector, AlgebraicVector> BackToBackKinematicConstraint::value(const std::vector<RefCountedKinematicParticle> par) const
00039 {
00040  int nStates = par.size();
00041  if(nStates != 2) throw VertexException("BackToBackKinematicConstraint::number of tracks is not equal to 2");
00042  AlgebraicVector point(14,0);
00043  int co = 0;
00044  for(std::vector<RefCountedKinematicParticle>::const_iterator i = par.begin(); i!=par.end(); i++)
00045  {
00046   AlgebraicVector7 cPar = (*i)->currentState().kinematicParameters().vector();
00047   for(int j = 1; j<8; j++){point((co-1)*7+j) = cPar(j-1);}
00048   co++;
00049  }
00050  AlgebraicVector vl(3,0);
00051  AlgebraicVector st1 = asHepVector<7>(par[0]->currentState().kinematicParameters().vector());
00052  AlgebraicVector st2 = asHepVector<7>(par[1]->currentState().kinematicParameters().vector());
00053  vl(1) = st1(4)+st2(4);
00054  vl(2) = st1(5)+st2(5);
00055  vl(3) = st1(6)+st2(6);
00056  
00057  return std::pair<AlgebraicVector, AlgebraicVector>(vl,point); 
00058 }
00059 
00060 std::pair<AlgebraicMatrix, AlgebraicVector> BackToBackKinematicConstraint::derivative(const std::vector<RefCountedKinematicParticle> par) const
00061 {
00062  int nStates = par.size();
00063  if(nStates != 2) throw VertexException("BackToBackKinematicConstraint::number of tracks is not equal to 2"); 
00064  AlgebraicVector point(14,0);
00065  int co = 0;
00066  for(std::vector<RefCountedKinematicParticle>::const_iterator i = par.begin(); i!=par.end(); i++)
00067  {
00068   AlgebraicVector7 cPar = (*i)->currentState().kinematicParameters().vector();
00069   for(int j = 1; j<8; j++){point((co-1)*7+j) = cPar(j-1);}
00070   co++;
00071  }
00072  AlgebraicMatrix dr(3,14,0);
00073 
00074  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr,point);
00075 }
00076 
00077 AlgebraicVector BackToBackKinematicConstraint::deviations(int nStates) const
00078 {
00079  AlgebraicVector dd(7*nStates,0);
00080  return dd;
00081 }
00082 
00083 int BackToBackKinematicConstraint::numberOfEquations() const
00084 {return 3;}
00085 
00086 KinematicConstraint * BackToBackKinematicConstraint::clone() const
00087 {return new BackToBackKinematicConstraint(*this);}