CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
FourMomentumKinematicConstraint Class Reference

#include <FourMomentumKinematicConstraint.h>

Inheritance diagram for FourMomentumKinematicConstraint:
KinematicConstraint

Public Member Functions

FourMomentumKinematicConstraintclone () const override
 
std::pair< AlgebraicMatrix, AlgebraicVectorderivative (const AlgebraicVector &exPoint) const override
 
std::pair< AlgebraicMatrix, AlgebraicVectorderivative (const std::vector< RefCountedKinematicParticle > &par) const override
 
AlgebraicVector deviations (int nStates) const override
 
 FourMomentumKinematicConstraint (const AlgebraicVector &momentum, const AlgebraicVector &deviation)
 
int numberOfEquations () const override
 
std::pair< AlgebraicVector, AlgebraicVectorvalue (const AlgebraicVector &exPoint) const override
 
std::pair< AlgebraicVector, AlgebraicVectorvalue (const std::vector< RefCountedKinematicParticle > &par) const override
 
- Public Member Functions inherited from KinematicConstraint
 KinematicConstraint ()
 
virtual ~KinematicConstraint ()
 

Private Attributes

AlgebraicVector dd
 
AlgebraicVector mm
 

Detailed Description

4-Momentum track constraint class provides a way to compute the matrix of derivatives and the vector of values for 4-Momentum constraint on for given KinematicParticle. Current version does not allow working with multiple tracks

Kirill Prokofiev March 2003 MultiState version: July 2004

Definition at line 17 of file FourMomentumKinematicConstraint.h.

Constructor & Destructor Documentation

◆ FourMomentumKinematicConstraint()

FourMomentumKinematicConstraint::FourMomentumKinematicConstraint ( const AlgebraicVector momentum,
const AlgebraicVector deviation 
)

Constructor with desired 4-momentum vector and vector of deviations to be used forcovariance matrix as arguments

Definition at line 4 of file FourMomentumKinematicConstraint.cc.

References dd, and mm.

Referenced by clone().

5  {
6  if ((momentum.num_row() != 4) || (deviation.num_row() != 4))
7  throw VertexException("FourMomentumKinematicConstraint::vector of wrong size passed as 4-Momentum or Deviations");
8  mm = momentum;
9  AlgebraicVector deviation_l(7, 0);
10  deviation_l(6) = momentum(3);
11  deviation_l(5) = momentum(2);
12  deviation_l(4) = momentum(1);
13 
14  double mass_sq =
15  momentum(4) * momentum(4) - momentum(3) * momentum(3) - momentum(2) * momentum(2) - momentum(1) * momentum(1);
16 
17  if (mass_sq == 0.)
18  throw VertexException("FourMomentumKinematicConstraint::the constraint vector passed corresponds to 0 mass");
19  //deviation for mass calculated from deviations
20  //of momentum
21  deviation_l(7) =
22  momentum(4) * momentum(4) * deviation(4) / mass_sq + momentum(3) * momentum(3) * deviation(3) / mass_sq +
23  momentum(2) * momentum(2) * deviation(2) / mass_sq + momentum(1) * momentum(1) * deviation(1) / mass_sq;
24  //mass sigma because of the energy
25 
26  dd = deviation_l;
27 }
Common base class.
CLHEP::HepVector AlgebraicVector

Member Function Documentation

◆ clone()

FourMomentumKinematicConstraint* FourMomentumKinematicConstraint::clone ( ) const
inlineoverridevirtual

Clone method

Implements KinematicConstraint.

Definition at line 51 of file FourMomentumKinematicConstraint.h.

References FourMomentumKinematicConstraint().

51 { return new FourMomentumKinematicConstraint(*this); }
FourMomentumKinematicConstraint(const AlgebraicVector &momentum, const AlgebraicVector &deviation)

◆ derivative() [1/2]

std::pair< AlgebraicMatrix, AlgebraicVector > FourMomentumKinematicConstraint::derivative ( const AlgebraicVector exPoint) const
overridevirtual

Implements KinematicConstraint.

Definition at line 51 of file FourMomentumKinematicConstraint.cc.

References l1ctLayer1_cff::dr, and mathSSE::sqrt().

52  {
53  if (exPoint.num_row() == 0)
54  throw VertexException("FourMomentumKinematicConstraint::value requested for zero Linearization point");
55 
56  //security check for extended cartesian parametrization
57  int inSize = exPoint.num_row();
58  if ((inSize % 7) != 0)
59  throw VertexException("FourMomentumKinematicConstraint::linearization point has a wrong dimension");
60  int nStates = inSize / 7;
61  if (nStates != 1)
62  throw VertexException("FourMomentumKinematicConstraint::Multi particle refit is not supported in this version");
63  AlgebraicVector pr = exPoint;
64  AlgebraicMatrix dr(4, 7, 0);
65 
66  dr(1, 4) = 1.;
67  dr(2, 5) = 1.;
68  dr(3, 6) = 1.;
69  dr(4, 7) = pr(7) / sqrt(pr(4) * pr(4) + pr(5) * pr(5) + pr(6) * pr(6) + pr(7) * pr(7));
70 
71  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, pr);
72 }
Common base class.
CLHEP::HepMatrix AlgebraicMatrix
T sqrt(T t)
Definition: SSEVec.h:23
CLHEP::HepVector AlgebraicVector

◆ derivative() [2/2]

std::pair< AlgebraicMatrix, AlgebraicVector > FourMomentumKinematicConstraint::derivative ( const std::vector< RefCountedKinematicParticle > &  par) const
overridevirtual

Vector of values and matrix of derivatives calculated using current state as an expansion point

Implements KinematicConstraint.

Definition at line 92 of file FourMomentumKinematicConstraint.cc.

References l1ctLayer1_cff::dr, and mathSSE::sqrt().

93  {
94  int nStates = par.size();
95  if (nStates == 0)
96  throw VertexException("FourMomentumKinematicConstraint::Empty vector of particles passed");
97  if (nStates != 1)
98  throw VertexException("FourMomentumKinematicConstraint::Multi particle refit is not supported in this version");
99  AlgebraicMatrix dr(4, 7, 0);
100 
101  AlgebraicVector pr = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
102  dr(1, 4) = 1.;
103  dr(2, 5) = 1.;
104  dr(3, 6) = 1.;
105  dr(4, 7) = -pr(7) / sqrt(pr(4) * pr(4) + pr(5) * pr(5) + pr(6) * pr(6) + pr(7) * pr(7));
106 
107  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, pr);
108 }
Common base class.
CLHEP::HepMatrix AlgebraicMatrix
T sqrt(T t)
Definition: SSEVec.h:23
CLHEP::HepVector AlgebraicVector

◆ deviations()

AlgebraicVector FourMomentumKinematicConstraint::deviations ( int  nStates) const
overridevirtual

Returns vector of sigma squared associated to the KinematicParameters of refitted particles Initial deviations are given by user for the constraining parameters (mass, momentum components etc). In case of multiple states exactly the same values are added to every particle parameters

Implements KinematicConstraint.

Definition at line 110 of file FourMomentumKinematicConstraint.cc.

References dd.

110  {
111  if (nStates == 0)
112  throw VertexException("FourMomentumKinematicConstraint::Empty vector of particles passed");
113  if (nStates != 1)
114  throw VertexException("FourMomentumKinematicConstraint::Multi particle refit is not supported in this version");
116  return res;
117 }
Common base class.
Definition: Electron.h:6
CLHEP::HepVector AlgebraicVector

◆ numberOfEquations()

int FourMomentumKinematicConstraint::numberOfEquations ( ) const
overridevirtual

Returns number of constraint equations used for fitting. Method is relevant for proper NDF calculations.

Implements KinematicConstraint.

Definition at line 119 of file FourMomentumKinematicConstraint.cc.

119 { return 4; }

◆ value() [1/2]

std::pair< AlgebraicVector, AlgebraicVector > FourMomentumKinematicConstraint::value ( const AlgebraicVector exPoint) const
overridevirtual

Vector of values and matrix of derivatives calculated at given 7*NumberOfStates expansion point

Implements KinematicConstraint.

Definition at line 29 of file FourMomentumKinematicConstraint.cc.

References mm, and mathSSE::sqrt().

30  {
31  if (exPoint.num_row() == 0)
32  throw VertexException("FourMomentumKinematicConstraint::value requested for zero Linearization point");
33 
34  //security check for extended cartesian parametrization
35  int inSize = exPoint.num_row();
36  if ((inSize % 7) != 0)
37  throw VertexException("FourMomentumKinematicConstraint::linearization point has a wrong dimension");
38  int nStates = inSize / 7;
39  if (nStates != 1)
40  throw VertexException("FourMomentumKinematicConstraint::Multi particle refit is not supported in this version");
41  AlgebraicVector pr = exPoint;
42  AlgebraicVector vl(4, 0);
43  vl(1) += (pr(4) - mm(1));
44  vl(2) += (pr(5) - mm(2));
45  vl(3) += (pr(6) - mm(3));
46  vl(7) += (sqrt(pr(4) * pr(4) + pr(5) * pr(5) + pr(6) * pr(6) + pr(7) * pr(7)) - mm(4));
47 
48  return std::pair<AlgebraicVector, AlgebraicVector>(vl, pr);
49 }
Common base class.
T sqrt(T t)
Definition: SSEVec.h:23
CLHEP::HepVector AlgebraicVector

◆ value() [2/2]

std::pair< AlgebraicVector, AlgebraicVector > FourMomentumKinematicConstraint::value ( const std::vector< RefCountedKinematicParticle > &  par) const
overridevirtual

Methods making value and derivative matrix using current state parameters as expansion 7-point. Constraint can be made equaly for single and multiple states

Implements KinematicConstraint.

Definition at line 74 of file FourMomentumKinematicConstraint.cc.

References mm, and mathSSE::sqrt().

75  {
76  int nStates = par.size();
77  if (nStates == 0)
78  throw VertexException("FourMomentumKinematicConstraint::Empty vector of particles passed");
79  if (nStates != 1)
80  throw VertexException("FourMomentumKinematicConstraint::Multi particle refit is not supported in this version");
81  AlgebraicVector pr = asHepVector<7>(par.front()->currentState().kinematicParameters().vector());
82  AlgebraicVector vl(4, 0);
83 
84  vl(1) = pr(4) - mm(1);
85  vl(2) = pr(5) - mm(2);
86  vl(3) = pr(6) - mm(3);
87  vl(7) = sqrt(pr(4) * pr(4) + pr(5) * pr(5) + pr(6) * pr(6) + pr(7) * pr(7)) - mm(4);
88 
89  return std::pair<AlgebraicVector, AlgebraicVector>(vl, pr);
90 }
Common base class.
T sqrt(T t)
Definition: SSEVec.h:23
CLHEP::HepVector AlgebraicVector

Member Data Documentation

◆ dd

AlgebraicVector FourMomentumKinematicConstraint::dd
private

◆ mm

AlgebraicVector FourMomentumKinematicConstraint::mm
private

Definition at line 54 of file FourMomentumKinematicConstraint.h.

Referenced by FourMomentumKinematicConstraint(), and value().