CMS 3D CMS Logo

MomentumKinematicConstraint.cc
Go to the documentation of this file.
3 
5  if ((momentum.num_row() != 3) || (dev.num_row() != 3))
6  throw VertexException("MomentumKinemticConstraint::Momentum or Deviation vector passed is not 3-dimensional");
7  mm = momentum;
8  AlgebraicVector dev_l(7, 0);
9  dev_l(4) = dev(1) * dev(1);
10  dev_l(5) = dev(2) * dev(2);
11  dev_l(6) = dev(3) * dev(3);
12  dd = dev_l;
13 }
14 
15 std::pair<AlgebraicVector, AlgebraicVector> MomentumKinematicConstraint::value(const AlgebraicVector& exPoint) const {
16  if (exPoint.num_row() == 0)
17  throw VertexException("MomentumKinematicConstraint::value requested for zero Linearization point");
18 
19  //security check for extended cartesian parametrization
20  int inSize = exPoint.num_row();
21  if ((inSize % 7) != 0)
22  throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
23  int nStates = inSize / 7;
24  if (nStates != 1)
25  throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");
26  AlgebraicVector pr = exPoint;
27  AlgebraicVector vl(3, 0);
28  vl(1) = pr(4) - mm(1);
29  vl(2) = pr(5) - mm(2);
30  vl(3) = pr(6) - mm(3);
31  return std::pair<AlgebraicVector, AlgebraicVector>(vl, pr);
32 }
33 
34 std::pair<AlgebraicMatrix, AlgebraicVector> MomentumKinematicConstraint::derivative(
35  const AlgebraicVector& exPoint) const {
36  if (exPoint.num_row() == 0)
37  throw VertexException("MomentumKinematicConstraint::derivative requested for zero Linearization point");
38 
39  //security check for extended cartesian parametrization
40  int inSize = exPoint.num_row();
41  if ((inSize % 7) != 0)
42  throw VertexException("MomentumKinematicConstraint::linearization point has a wrong dimension");
43  int nStates = inSize / 7;
44  if (nStates != 1)
45  throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");
46 
47  AlgebraicVector pr = exPoint;
48  AlgebraicMatrix dr(3, 7, 0);
49  dr(1, 4) = 1.;
50  dr(2, 5) = 1.;
51  dr(3, 6) = 1.;
52  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, pr);
53 }
54 
55 std::pair<AlgebraicVector, AlgebraicVector> MomentumKinematicConstraint::value(
56  const std::vector<RefCountedKinematicParticle>& par) const {
57  int nStates = par.size();
58  if (nStates == 0)
59  throw VertexException("MomentumKinematicConstraint::Empty vector of particles passed");
60  if (nStates != 1)
61  throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");
62  AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
63  AlgebraicVector vl(3, 0);
64  vl(1) = point(4) - mm(1);
65  vl(2) = point(5) - mm(2);
66  vl(3) = point(6) - mm(3);
67  return std::pair<AlgebraicVector, AlgebraicVector>(vl, point);
68 }
69 
70 std::pair<AlgebraicMatrix, AlgebraicVector> MomentumKinematicConstraint::derivative(
71  const std::vector<RefCountedKinematicParticle>& par) const {
72  int nStates = par.size();
73  if (nStates == 0)
74  throw VertexException("MomentumKinematicConstraint::Empty vector of particles passed");
75  if (nStates != 1)
76  throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");
77  AlgebraicVector point = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
78  AlgebraicMatrix dr(3, 7, 0);
79  dr(1, 4) = 1.;
80  dr(2, 5) = 1.;
81  dr(3, 6) = 1.;
82  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, point);
83 }
84 
86  if (nStates == 0)
87  throw VertexException("MomentumKinematicConstraint::Empty vector of particles passed");
88  if (nStates != 1)
89  throw VertexException("MomentumKinematicConstraint::Multistate refit is not foreseen for this constraint");
91  return res;
92 }
93 
MomentumKinematicConstraint::mm
AlgebraicVector mm
Definition: MomentumKinematicConstraint.h:51
VertexException
Common base class.
Definition: VertexException.h:12
MomentumKinematicConstraint::dd
AlgebraicVector dd
Definition: MomentumKinematicConstraint.h:52
MomentumKinematicConstraint::deviations
AlgebraicVector deviations(int nStates) const override
Definition: MomentumKinematicConstraint.cc:85
MomentumKinematicConstraint::numberOfEquations
int numberOfEquations() const override
Definition: MomentumKinematicConstraint.cc:94
MomentumKinematicConstraint.h
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
MomentumKinematicConstraint::value
std::pair< AlgebraicVector, AlgebraicVector > value(const AlgebraicVector &exPoint) const override
Definition: MomentumKinematicConstraint.cc:15
MomentumKinematicConstraint::MomentumKinematicConstraint
MomentumKinematicConstraint(const AlgebraicVector &momentum, const AlgebraicVector &dev)
Definition: MomentumKinematicConstraint.cc:4
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:32
res
Definition: Electron.h:6
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
MomentumKinematicConstraint::derivative
std::pair< AlgebraicMatrix, AlgebraicVector > derivative(const AlgebraicVector &exPoint) const override
Definition: MomentumKinematicConstraint.cc:34
VertexException.h
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5