Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "RecoVertex/KinematicFit/interface/MassKinematicConstraint.h"
0002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
0003 
0004 MassKinematicConstraint::MassKinematicConstraint(const ParticleMass& m, const float sigma) {
0005   mass = m;
0006   AlgebraicVector deviation_l(7, 0);
0007   deviation_l(7) = sigma * sigma;
0008   dd = deviation_l;
0009 }
0010 
0011 std::pair<AlgebraicVector, AlgebraicVector> MassKinematicConstraint::value(const AlgebraicVector& exPoint) const {
0012   //we have only one equation and only one track, means the constraint value
0013   //for track parameters is just a single number
0014   if (exPoint.num_row() == 0)
0015     throw VertexException("MomentumKinematicConstraint::value requested for zero Linearization point");
0016 
0017   //security check for extended cartesian parametrization
0018   int inSize = exPoint.num_row();
0019   if ((inSize % 7) != 0)
0020     throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
0021   int nStates = inSize / 7;
0022   if (nStates != 1)
0023     throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
0024   AlgebraicVector vl(1, 0);
0025   AlgebraicVector point = exPoint;
0026   vl(1) = point(7) - mass;
0027   return std::pair<AlgebraicVector, AlgebraicVector>(vl, point);
0028 }
0029 
0030 std::pair<AlgebraicMatrix, AlgebraicVector> MassKinematicConstraint::derivative(const AlgebraicVector& exPoint) const {
0031   if (exPoint.num_row() == 0)
0032     throw VertexException("MomentumKinematicConstraint::deriavtive requested for zero Linearization point");
0033 
0034   //security check for extended cartesian parametrization
0035   int inSize = exPoint.num_row();
0036   if ((inSize % 7) != 0)
0037     throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
0038   int nStates = inSize / 7;
0039   if (nStates != 1)
0040     throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
0041   AlgebraicMatrix dr(1, 7, 0);
0042   dr(1, 7) = 1;
0043   AlgebraicVector point = exPoint;
0044   return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, point);
0045 }
0046 
0047 std::pair<AlgebraicVector, AlgebraicVector> MassKinematicConstraint::value(
0048     const std::vector<RefCountedKinematicParticle>& par) const {
0049   int nStates = par.size();
0050   if (nStates == 0)
0051     throw VertexException("MassKinematicConstraint::empty vector of particles passed");
0052   if (nStates != 1)
0053     throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
0054 
0055   AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
0056   AlgebraicVector vl(1, 0);
0057   vl(1) = point(7) - mass;
0058   return std::pair<AlgebraicVector, AlgebraicVector>(vl, point);
0059 }
0060 
0061 std::pair<AlgebraicMatrix, AlgebraicVector> MassKinematicConstraint::derivative(
0062     const std::vector<RefCountedKinematicParticle>& par) const {
0063   int nStates = par.size();
0064   if (nStates == 0)
0065     throw VertexException("MassKinematicConstraint::empty vector of particles passed");
0066   if (nStates != 1)
0067     throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
0068 
0069   AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
0070   AlgebraicMatrix dr(1, 7, 0);
0071   dr(1, 7) = 1;
0072   return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, point);
0073 }
0074 
0075 AlgebraicVector MassKinematicConstraint::deviations(int nStates) const {
0076   if (nStates == 0)
0077     throw VertexException("MassKinematicConstraint::empty vector of particles passed");
0078   if (nStates != 1)
0079     throw VertexException("MassKinematicConstraint::multiple state refit is not supported in this version");
0080   AlgebraicVector res = dd;
0081   return res;
0082 }
0083 
0084 int MassKinematicConstraint::numberOfEquations() const { return 1; }