Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:11

0001 #include "RecoVertex/KinematicFit/interface/BackToBackKinematicConstraint.h"
0002 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
0003 #include "DataFormats/CLHEP/interface/Migration.h"
0004 
0005 std::pair<AlgebraicVector, AlgebraicVector> BackToBackKinematicConstraint::value(const AlgebraicVector& exPoint) const {
0006   //security check for extended cartesian parametrization
0007   int inSize = exPoint.num_row();
0008   if (inSize != 14)
0009     throw VertexException("BackToBackKinematicConstraint::linearization point has a wrong dimension");
0010   AlgebraicVector pr = exPoint;
0011 
0012   //number of states should be always equal to 2 for such a constraint
0013   AlgebraicVector vl(3, 0);
0014   vl(1) = pr(4) + pr(11);
0015   vl(2) = pr(5) + pr(12);
0016   vl(3) = pr(6) + pr(13);
0017   return std::pair<AlgebraicVector, AlgebraicVector>(vl, pr);
0018 }
0019 
0020 std::pair<AlgebraicMatrix, AlgebraicVector> BackToBackKinematicConstraint::derivative(
0021     const AlgebraicVector& exPoint) const {
0022   //security check for extended cartesian parametrization
0023   int inSize = exPoint.num_row();
0024   if (inSize != 14)
0025     throw VertexException("BackToBackKinematicConstraint::linearization point has a wrong dimension");
0026   AlgebraicVector pr = exPoint;
0027 
0028   //number of states should be always equal to 2 for such a constraint
0029   AlgebraicMatrix dr(3, 14, 0);
0030   dr(1, 4) = 1.;
0031   dr(1, 11) = 1.;
0032   dr(2, 5) = 1;
0033   dr(2, 12) = 1;
0034   dr(3, 6) = 1;
0035   dr(3, 13) = 1;
0036   return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, pr);
0037 }
0038 
0039 std::pair<AlgebraicVector, AlgebraicVector> BackToBackKinematicConstraint::value(
0040     const std::vector<RefCountedKinematicParticle>& par) const {
0041   int nStates = par.size();
0042   if (nStates != 2)
0043     throw VertexException("BackToBackKinematicConstraint::number of tracks is not equal to 2");
0044   AlgebraicVector point(14, 0);
0045   int co = 0;
0046   for (std::vector<RefCountedKinematicParticle>::const_iterator i = par.begin(); i != par.end(); i++) {
0047     AlgebraicVector7 cPar = (*i)->currentState().kinematicParameters().vector();
0048     for (int j = 1; j < 8; j++) {
0049       point((co - 1) * 7 + j) = cPar(j - 1);
0050     }
0051     co++;
0052   }
0053   AlgebraicVector vl(3, 0);
0054   AlgebraicVector st1 = asHepVector<7>(par[0]->currentState().kinematicParameters().vector());
0055   AlgebraicVector st2 = asHepVector<7>(par[1]->currentState().kinematicParameters().vector());
0056   vl(1) = st1(4) + st2(4);
0057   vl(2) = st1(5) + st2(5);
0058   vl(3) = st1(6) + st2(6);
0059 
0060   return std::pair<AlgebraicVector, AlgebraicVector>(vl, point);
0061 }
0062 
0063 std::pair<AlgebraicMatrix, AlgebraicVector> BackToBackKinematicConstraint::derivative(
0064     const std::vector<RefCountedKinematicParticle>& par) const {
0065   int nStates = par.size();
0066   if (nStates != 2)
0067     throw VertexException("BackToBackKinematicConstraint::number of tracks is not equal to 2");
0068   AlgebraicVector point(14, 0);
0069   int co = 0;
0070   for (std::vector<RefCountedKinematicParticle>::const_iterator i = par.begin(); i != par.end(); i++) {
0071     AlgebraicVector7 cPar = (*i)->currentState().kinematicParameters().vector();
0072     for (int j = 1; j < 8; j++) {
0073       point((co - 1) * 7 + j) = cPar(j - 1);
0074     }
0075     co++;
0076   }
0077   AlgebraicMatrix dr(3, 14, 0);
0078 
0079   return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, point);
0080 }
0081 
0082 AlgebraicVector BackToBackKinematicConstraint::deviations(int nStates) const {
0083   AlgebraicVector dd(7 * nStates, 0);
0084   return dd;
0085 }
0086 
0087 int BackToBackKinematicConstraint::numberOfEquations() const { return 3; }
0088 
0089 KinematicConstraint* BackToBackKinematicConstraint::clone() const { return new BackToBackKinematicConstraint(*this); }