CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Attributes
ColinearityKinematicConstraint Class Reference

#include <ColinearityKinematicConstraint.h>

Inheritance diagram for ColinearityKinematicConstraint:
MultiTrackKinematicConstraint

Public Types

enum  ConstraintDim { Phi, PhiTheta }
 

Public Member Functions

ColinearityKinematicConstraintclone () const override
 
 ColinearityKinematicConstraint (ConstraintDim dim=Phi)
 
int numberOfEquations () const override
 
AlgebraicMatrix parametersDerivative (const std::vector< KinematicState > &states, const GlobalPoint &point) const override
 
AlgebraicMatrix positionDerivative (const std::vector< KinematicState > &states, const GlobalPoint &point) const override
 
AlgebraicVector value (const std::vector< KinematicState > &states, const GlobalPoint &point) const override
 
- Public Member Functions inherited from MultiTrackKinematicConstraint
 MultiTrackKinematicConstraint ()
 
virtual ~MultiTrackKinematicConstraint ()
 

Private Attributes

ConstraintDim dimension
 
unsigned int size
 

Detailed Description

Consstraint to force the two tracks to be colinear (parallel), in 2D (phi) or 3D (phi-theta).

Warning: Since this constraint makes only sense with two tracks, two and only two tracks should be used in the fit.

Definition at line 16 of file ColinearityKinematicConstraint.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

ColinearityKinematicConstraint::ColinearityKinematicConstraint ( ConstraintDim  dim = Phi)

Definition at line 4 of file ColinearityKinematicConstraint.cc.

References dimension, Phi, and size.

Referenced by clone().

Member Function Documentation

ColinearityKinematicConstraint* ColinearityKinematicConstraint::clone ( void  ) const
inlineoverridevirtual

Implements MultiTrackKinematicConstraint.

Definition at line 50 of file ColinearityKinematicConstraint.h.

References ColinearityKinematicConstraint().

50 { return new ColinearityKinematicConstraint(*this); }
ColinearityKinematicConstraint(ConstraintDim dim=Phi)
int ColinearityKinematicConstraint::numberOfEquations ( ) const
inlineoverridevirtual

Number of equations per track used for the fit

Implements MultiTrackKinematicConstraint.

Definition at line 48 of file ColinearityKinematicConstraint.h.

References size.

AlgebraicMatrix ColinearityKinematicConstraint::parametersDerivative ( const std::vector< KinematicState > &  states,
const GlobalPoint point 
) const
overridevirtual

Returns a matrix of derivatives of constraint equations w.r.t. particle parameters

Implements MultiTrackKinematicConstraint.

Definition at line 52 of file ColinearityKinematicConstraint.cc.

References dimension, relval_steps::k2, fireworks::p1, fireworks::p2, PhiTheta, size, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

53  {
54  int n_st = states.size();
55  if (n_st < 2)
56  throw VertexException("ColinearityKinematicConstraint::<2 states passed");
57  AlgebraicMatrix res(size, n_st * 7, 0);
58 
59  double a_1 = -states[0].particleCharge() * states[0].magneticField()->inInverseGeV(states[0].globalPosition()).z();
60  double a_2 = -states[1].particleCharge() * states[1].magneticField()->inInverseGeV(states[1].globalPosition()).z();
61 
62  AlgebraicVector7 p1 = states[0].kinematicParameters().vector();
63  AlgebraicVector7 p2 = states[1].kinematicParameters().vector();
64 
65  double p1vx = p1(3) - a_1 * (point.y() - p1(1));
66  double p1vy = p1(4) + a_1 * (point.x() - p1(0));
67  double k1 = 1.0 / (p1vx * p1vx + p1vy * p1vy);
68  double pt1 = sqrt(p1(3) * p1(3) + p1(4) * p1(4));
69  double pTot1 = sqrt(p1(3) * p1(3) + p1(4) * p1(4) + p1(5) * p1(5));
70 
71  double p2vx = p2(3) - a_2 * (point.y() - p2(1));
72  double p2vy = p2(4) + a_2 * (point.x() - p2(0));
73  double k2 = 1.0 / (p2vx * p2vx + p2vy * p2vy);
74  double pt2 = sqrt(p2(3) * p2(3) + p2(4) * p2(4));
75  double pTot2 = sqrt(p2(3) * p2(3) + p2(4) * p2(4) + p2(5) * p2(5));
76 
77  // H_phi:
78 
79  //x1 and x2 derivatives: 1st and 8th elements
80  res(1, 1) = -k1 * a_1 * p1vx;
81  res(1, 8) = k2 * a_2 * p2vx;
82 
83  //y1 and y2 derivatives: 2nd and 9th elements:
84  res(1, 2) = -k1 * a_1 * p1vy;
85  res(1, 9) = k2 * a_2 * p2vy;
86 
87  //z1 and z2 components: 3d and 10th elmnets stay 0:
88  res(1, 3) = 0.;
89  res(1, 10) = 0.;
90 
91  //px1 and px2 components: 4th and 11th elements:
92  res(1, 4) = -k1 * p1vy;
93  res(1, 11) = k2 * p2vy;
94 
95  //py1 and py2 components: 5th and 12 elements:
96  res(1, 5) = k1 * p1vx;
97  res(1, 12) = -k2 * p2vx;
98 
99  //pz1 and pz2 components: 6th and 13 elements:
100  res(1, 6) = 0.;
101  res(1, 13) = 0.;
102  //mass components: 7th and 14th elements:
103  res(1, 7) = 0.;
104  res(1, 14) = 0.;
105 
106  if (dimension == PhiTheta) {
107  // H_theta:
108  //x1 and x2 derivatives: 1st and 8th elements
109  res(2, 1) = 0.;
110  res(2, 8) = 0.;
111 
112  //y1 and y2 derivatives: 2nd and 9th elements:
113  res(2, 2) = 0.;
114  res(2, 9) = 0.;
115 
116  //z1 and z2 components: 3d and 10th elmnets stay 0:
117  res(2, 3) = 0.;
118  res(2, 10) = 0.;
119 
120  res(2, 4) = p1(5) * p1(3) / (pTot1 * pTot1 * pt1);
121  res(2, 11) = -p2(5) * p2(3) / (pTot2 * pTot2 * pt2);
122 
123  //py1 and py2 components: 5th and 12 elements:
124  res(2, 5) = p1(5) * p1(4) / (pTot1 * pTot1 * pt1);
125  res(2, 12) = -p2(5) * p2(4) / (pTot2 * pTot2 * pt2);
126 
127  //pz1 and pz2 components: 6th and 13 elements:
128  res(2, 6) = -pt1 / (pTot1 * pTot1);
129  res(2, 13) = pt2 / (pTot2 * pTot2);
130  //mass components: 7th and 14th elements:
131  res(2, 7) = 0.;
132  res(2, 14) = 0.;
133  }
134 
135  return res;
136 }
const TString p2
Definition: fwPaths.cc:13
Common base class.
ROOT::Math::SVector< double, 7 > AlgebraicVector7
Definition: Matrices.h:8
T y() const
Definition: PV3DBase.h:60
CLHEP::HepMatrix AlgebraicMatrix
T sqrt(T t)
Definition: SSEVec.h:19
const TString p1
Definition: fwPaths.cc:12
T x() const
Definition: PV3DBase.h:59
AlgebraicMatrix ColinearityKinematicConstraint::positionDerivative ( const std::vector< KinematicState > &  states,
const GlobalPoint point 
) const
overridevirtual

Returns a matrix of derivatives of constraint equations w.r.t. vertex position

Implements MultiTrackKinematicConstraint.

Definition at line 138 of file ColinearityKinematicConstraint.cc.

References dimension, relval_steps::k2, fireworks::p1, fireworks::p2, PhiTheta, size, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

139  {
140  AlgebraicMatrix res(size, 3, 0);
141  if (states.size() < 2)
142  throw VertexException("ColinearityKinematicConstraint::<2 states passed");
143 
144  double a_1 = -states[0].particleCharge() * states[0].magneticField()->inInverseGeV(states[0].globalPosition()).z();
145  double a_2 = -states[1].particleCharge() * states[1].magneticField()->inInverseGeV(states[1].globalPosition()).z();
146 
147  AlgebraicVector7 p1 = states[0].kinematicParameters().vector();
148  AlgebraicVector7 p2 = states[1].kinematicParameters().vector();
149 
150  double p1vx = p1(3) - a_1 * (point.y() - p1(1));
151  double p1vy = p1(4) + a_1 * (point.x() - p1(0));
152  double k1 = 1.0 / (p1vx * p1vx + p1vy * p1vy);
153  //double pt1 = sqrt(p1(3)*p1(3)+p1(4)*p1(4));
154 
155  double p2vx = p2(3) - a_2 * (point.y() - p2(1));
156  double p2vy = p2(4) + a_2 * (point.x() - p2(0));
157  double k2 = 1.0 / (p2vx * p2vx + p2vy * p2vy);
158  //double pt2 = sqrt(p2(3)*p2(3)+p2(4)*p2(4));
159 
160  // H_phi:
161 
162  // xv component
163  res(1, 1) = k1 * a_1 * p1vx - k2 * a_2 * p2vx;
164 
165  //yv component
166  res(1, 2) = k1 * a_1 * p1vy - k2 * a_2 * p2vy;
167 
168  //zv component
169  res(1, 3) = 0.;
170 
171  // H_theta: no correlation with vertex position
172  if (dimension == PhiTheta) {
173  res(2, 1) = 0.;
174  res(2, 2) = 0.;
175  res(2, 3) = 0.;
176  }
177 
178  return res;
179 }
const TString p2
Definition: fwPaths.cc:13
Common base class.
ROOT::Math::SVector< double, 7 > AlgebraicVector7
Definition: Matrices.h:8
T y() const
Definition: PV3DBase.h:60
CLHEP::HepMatrix AlgebraicMatrix
const TString p1
Definition: fwPaths.cc:12
T x() const
Definition: PV3DBase.h:59
AlgebraicVector ColinearityKinematicConstraint::value ( const std::vector< KinematicState > &  states,
const GlobalPoint point 
) const
overridevirtual

Returns a vector of values of constraint equations at the point where the input particles are defined.

Implements MultiTrackKinematicConstraint.

Definition at line 12 of file ColinearityKinematicConstraint.cc.

References dimension, M_PI, fireworks::p1, fireworks::p2, PhiTheta, size, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by Types.int32::__nonzero__(), Types.uint32::__nonzero__(), Types.int64::__nonzero__(), Types.uint64::__nonzero__(), Types.double::__nonzero__(), Types.bool::__nonzero__(), Types.string::__nonzero__(), Types.string::configValue(), Types.FileInPath::configValue(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Types.double::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.FileInPath::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), and Types.vstring::insertInto().

13  {
14  if (states.size() < 2)
15  throw VertexException("ColinearityKinematicConstraint::<2 states passed");
16  AlgebraicVector res(size, 0);
17 
18  double a_1 = -states[0].particleCharge() * states[0].magneticField()->inInverseGeV(states[0].globalPosition()).z();
19  double a_2 = -states[1].particleCharge() * states[1].magneticField()->inInverseGeV(states[1].globalPosition()).z();
20 
21  AlgebraicVector7 p1 = states[0].kinematicParameters().vector();
22  AlgebraicVector7 p2 = states[1].kinematicParameters().vector();
23 
24  double p1vx = p1(3) - a_1 * (point.y() - p1(1));
25  double p1vy = p1(4) + a_1 * (point.x() - p1(0));
26  double pt1 = sqrt(p1(3) * p1(3) + p1(4) * p1(4));
27 
28  double p2vx = p2(3) - a_2 * (point.y() - p2(1));
29  double p2vy = p2(4) + a_2 * (point.x() - p2(0));
30  double pt2 = sqrt(p2(3) * p2(3) + p2(4) * p2(4));
31 
32  // H_phi:
33  res(1) = atan2(p1vy, p1vx) - atan2(p2vy, p2vx);
34  if (res(1) > M_PI)
35  res(1) -= 2.0 * M_PI;
36  if (res(1) <= -M_PI)
37  res(1) += 2.0 * M_PI;
38  // H_theta:
39  if (dimension == PhiTheta) {
40  res(2) = atan2(pt1, p1(5)) - atan2(pt2, p2(5));
41  if (res(2) > M_PI)
42  res(2) -= 2.0 * M_PI;
43  if (res(2) <= -M_PI)
44  res(2) += 2.0 * M_PI;
45  }
46 
47  // cout << res(1) << " "<<res(2) << "\n ";// res(2)
48 
49  return res;
50 }
const TString p2
Definition: fwPaths.cc:13
Common base class.
ROOT::Math::SVector< double, 7 > AlgebraicVector7
Definition: Matrices.h:8
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
const TString p1
Definition: fwPaths.cc:12
#define M_PI
CLHEP::HepVector AlgebraicVector
T x() const
Definition: PV3DBase.h:59

Member Data Documentation

ConstraintDim ColinearityKinematicConstraint::dimension
private
unsigned int ColinearityKinematicConstraint::size
private