CMS 3D CMS Logo

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

#include <MultipleKinematicConstraint.h>

Inheritance diagram for MultipleKinematicConstraint:
KinematicConstraint

Public Member Functions

void addConstraint (KinematicConstraint *newConst) const
 
MultipleKinematicConstraintclone () 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
 
bool isEmpty () const
 
 MultipleKinematicConstraint ()
 
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

std::vector< KinematicConstraint * > cts
 
bool em
 

Detailed Description

Class implementing constraint multiplication for single or multiple track refit. Multiple track refit does not include vertexing constraint: only refit of tarjectory parameters is usually done.

Definition at line 15 of file MultipleKinematicConstraint.h.

Constructor & Destructor Documentation

◆ MultipleKinematicConstraint()

MultipleKinematicConstraint::MultipleKinematicConstraint ( )
inline

Definition at line 17 of file MultipleKinematicConstraint.h.

References em.

Referenced by clone().

Member Function Documentation

◆ addConstraint()

void MultipleKinematicConstraint::addConstraint ( KinematicConstraint newConst) const

Method adding new constraint to the list of existing ones.

Definition at line 3 of file MultipleKinematicConstraint.cc.

References cts, and em.

3  {
4  if (newConst == nullptr)
5  throw VertexException("MultipleKinematicConstraint::zero constraint pointer passed");
6  cts.push_back(newConst);
7  em = false;
8 }
Common base class.
std::vector< KinematicConstraint * > cts

◆ clone()

MultipleKinematicConstraint* MultipleKinematicConstraint::clone ( ) const
inlineoverridevirtual

Clone method

Implements KinematicConstraint.

Definition at line 49 of file MultipleKinematicConstraint.h.

References MultipleKinematicConstraint().

◆ derivative() [1/2]

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

Implements KinematicConstraint.

Definition at line 42 of file MultipleKinematicConstraint.cc.

References cts, flavorHistoryFilter_cfi::dr, mps_fire::i, and dqmMemoryStats::total.

43  {
44  if (cts.empty())
45  throw VertexException("MultipleKinematicConstraint::derivative requested for empty constraint");
46  if (exPoint.num_row() == 0)
47  throw VertexException("MultipleKinematicConstraint::value requested for zero Linearization point");
48 
49  //security check for extended cartesian parametrization
50  int inSize = exPoint.num_row();
51  if ((inSize % 7) != 0)
52  throw VertexException("MultipleKinematicConstraint::linearization point has a wrong dimension");
53 
54  AlgebraicVector par = exPoint;
55  int total = 0;
56  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
57  total += (*i)->numberOfEquations();
58  }
59 
60  //Full derivative matrix: (numberOfConstraints x 7*numberOfStates)
61  AlgebraicMatrix dr(total, inSize);
62 
63  int cr_size = 0;
64  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
65  //matrix should be (nx7*NumberOfStates)
66  AlgebraicMatrix lConst = (*i)->derivative(par).first;
67  dr.sub(cr_size + 1, 1, lConst);
68  cr_size += (*i)->numberOfEquations();
69  }
70  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, par);
71 }
Common base class.
std::vector< KinematicConstraint * > cts
CLHEP::HepMatrix AlgebraicMatrix
CLHEP::HepVector AlgebraicVector

◆ derivative() [2/2]

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

Implements KinematicConstraint.

Definition at line 116 of file MultipleKinematicConstraint.cc.

References submitPVResolutionJobs::count, cts, flavorHistoryFilter_cfi::dr, mps_fire::i, dqmiolumiharvest::j, and dqmMemoryStats::total.

117  {
118  if (cts.empty())
119  throw VertexException("MultipleKinematicConstraint::derivative requested for empty constraint");
120  int nStates = par.size();
121  AlgebraicVector param(7 * nStates, 0);
122 
123  int count = 1;
124  for (std::vector<RefCountedKinematicParticle>::const_iterator i = par.begin(); i != par.end(); i++) {
125  for (int j = 1; j < 8; j++) {
126  param((count - 1) * 7 + j) = (*i)->currentState().kinematicParameters().vector()(j - 1);
127  }
128  count++;
129  }
130  int total = 0;
131  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
132  total += (*i)->numberOfEquations();
133  }
134  AlgebraicMatrix dr(total, 7 * nStates);
135 
136  int cr_size = 0;
137  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
138  //matrix should be (TotalNumberOfEquations x 7* TotalNumberOfStates)
139  //Derivative matrix for given constraint
140  AlgebraicMatrix lConst = (*i)->derivative(param).first;
141 
142  //putting it into the appropriate line
143  dr.sub(cr_size + 1, 1, lConst);
144  cr_size += (*i)->numberOfEquations();
145  }
146  return std::pair<AlgebraicMatrix, AlgebraicVector>(dr, param);
147 }
Common base class.
std::vector< KinematicConstraint * > cts
CLHEP::HepMatrix AlgebraicMatrix
CLHEP::HepVector AlgebraicVector

◆ deviations()

AlgebraicVector MultipleKinematicConstraint::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 149 of file MultipleKinematicConstraint.cc.

References cts, mps_fire::i, and dqmiolumiharvest::j.

149  {
150  AlgebraicVector dev(nStates * 7, 0);
151  if (cts.empty())
152  throw VertexException("MultipleKinematicConstraint::deviations requested for empty constraint");
153  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
154  AlgebraicVector dev_loc = (*i)->deviations(nStates);
155  for (int j = 1; j < nStates * 7 + 1; j++) {
156  dev(j) = dev(j) + dev_loc(j);
157  }
158  }
159  return dev;
160 }
Common base class.
std::vector< KinematicConstraint * > cts
CLHEP::HepVector AlgebraicVector

◆ isEmpty()

bool MultipleKinematicConstraint::isEmpty ( void  ) const
inline

Definition at line 47 of file MultipleKinematicConstraint.h.

References em.

Referenced by plotting.Plot::clone().

◆ numberOfEquations()

int MultipleKinematicConstraint::numberOfEquations ( ) const
overridevirtual

Returns an actual number of equations in particular constraint (corresponds to the number of strings in constraint derivative matrix, for example)

Implements KinematicConstraint.

Definition at line 73 of file MultipleKinematicConstraint.cc.

References cts, mps_fire::i, and compareTotals::ne.

73  {
74  int ne = 0;
75  if (cts.empty())
76  throw VertexException("MultipleKinematicConstraint::number of equations requested for empty constraint");
77  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
78  ne += (*i)->numberOfEquations();
79  }
80  return ne;
81 }
Common base class.
std::vector< KinematicConstraint * > cts

◆ value() [1/2]

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

Vector of values and matrix of derivatives calculated at given 7xNumberOfStates linearization point

Implements KinematicConstraint.

Definition at line 10 of file MultipleKinematicConstraint.cc.

References cts, mps_fire::i, dqmiolumiharvest::j, and dqmMemoryStats::total.

10  {
11  if (cts.empty())
12  throw VertexException("MultipleKinematicConstraint::value requested for empty constraint");
13  if (exPoint.num_row() == 0)
14  throw VertexException("MultipleKinematicConstraint::value requested for zero Linearization point");
15 
16  //looking for total number of states, represented by this point.
17  //Since this version only works with extended cartesian parametrization,
18  //we check whether the dimensionof he point is n*7
19  AlgebraicVector expansion = exPoint;
20  int inSize = exPoint.num_row();
21  if ((inSize % 7) != 0)
22  throw VertexException("MultipleKinematicConstraint::linearization point has a wrong dimension");
23 
24  int total = 0;
25  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
26  total += (*i)->numberOfEquations();
27  }
28  AlgebraicVector vl(total, 0);
29 
30  int cr_size = 0;
31  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
32  AlgebraicVector vlc = (*i)->value(expansion).first;
33  int sz = vlc.num_row();
34  for (int j = 1; j < sz + 1; j++) {
35  vl(cr_size + j) = vlc(j);
36  }
37  cr_size += sz;
38  }
39  return std::pair<AlgebraicVector, AlgebraicVector>(vl, expansion);
40 }
Common base class.
std::vector< KinematicConstraint * > cts
CLHEP::HepVector AlgebraicVector

◆ value() [2/2]

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

Vector of values and matrix of derivatives, calu=culated at linearization point of current particle states

Implements KinematicConstraint.

Definition at line 83 of file MultipleKinematicConstraint.cc.

References submitPVResolutionJobs::count, cts, mps_fire::i, dqmiolumiharvest::j, and dqmMemoryStats::total.

84  {
85  if (cts.empty())
86  throw VertexException("MultipleKinematicConstraint::derivative requested for empty constraint");
87  int nStates = par.size();
88  AlgebraicVector param(7 * nStates, 0);
89  int count = 1;
90  for (std::vector<RefCountedKinematicParticle>::const_iterator i = par.begin(); i != par.end(); i++) {
91  for (int j = 1; j < 8; j++) {
92  param((count - 1) * 7 + j) = (*i)->currentState().kinematicParameters().vector()(j - 1);
93  }
94  count++;
95  }
96 
97  //looking for total number of equations
98  int total = 0;
99  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
100  total += (*i)->numberOfEquations();
101  }
102  AlgebraicVector vl(total, 0);
103 
104  int cr_size = 0;
105  for (std::vector<KinematicConstraint *>::const_iterator i = cts.begin(); i != cts.end(); i++) {
106  AlgebraicVector vlc = (*i)->value(par).first;
107  int sz = vlc.num_row();
108  for (int j = 1; j <= sz; j++) {
109  vl(cr_size + j) = vlc(j);
110  }
111  cr_size += sz;
112  }
113  return std::pair<AlgebraicVector, AlgebraicVector>(vl, param);
114 }
Common base class.
std::vector< KinematicConstraint * > cts
CLHEP::HepVector AlgebraicVector

Member Data Documentation

◆ cts

std::vector<KinematicConstraint *> MultipleKinematicConstraint::cts
mutableprivate

◆ em

bool MultipleKinematicConstraint::em
mutableprivate