ATLAS Offline Software
Public Member Functions | Static Private Attributes | List of all members
Trk::CollinearityConstraint Class Reference

#include <CollinearityConstraint.h>

Inheritance diagram for Trk::CollinearityConstraint:
Collaboration diagram for Trk::CollinearityConstraint:

Public Member Functions

 CollinearityConstraint ()=default
 
virtual ~CollinearityConstraint ()=default
 
virtual Amg::VectorX vectorOfValues (std::vector< Amg::VectorX > &cart_coordList, std::vector< int > &charges, Amg::Vector3D refPoint, double b_fieldTesla) const override final
 
virtual Amg::MatrixX matrixOfDerivatives (std::vector< Amg::VectorX > &cart_coordList, std::vector< int > &charges, Amg::Vector3D refPoint, double b_fieldTesla) const override final
 
virtual int numberOfEquations () const override final
 

Static Private Attributes

static constexpr int s_eqno = 2
 

Detailed Description

Definition at line 14 of file CollinearityConstraint.h.

Constructor & Destructor Documentation

◆ CollinearityConstraint()

Trk::CollinearityConstraint::CollinearityConstraint ( )
default

◆ ~CollinearityConstraint()

virtual Trk::CollinearityConstraint::~CollinearityConstraint ( )
virtualdefault

Member Function Documentation

◆ matrixOfDerivatives()

Amg::MatrixX Trk::CollinearityConstraint::matrixOfDerivatives ( std::vector< Amg::VectorX > &  cart_coordList,
std::vector< int > &  charges,
Amg::Vector3D  refPoint,
double  b_fieldTesla 
) const
finaloverridevirtual

Implements Trk::IKinematicConstraint.

Definition at line 60 of file CollinearityConstraint.cxx.

65 {
66 
67  const unsigned int ntrack = cart_coordList.size();
68 
69  Amg::MatrixX matrixDeriv2(2, ntrack * 7);
70 
71  if (ntrack != 2) {
72  return matrixDeriv2; // returning matrix with zero's
73  }
74 
75  const double bend_factor = -0.299792458 * b_fieldTesla;
76 
77  const double px1 = cart_coordList[0][0];
78  const double py1 = cart_coordList[0][1];
79  const double pz1 = cart_coordList[0][2];
80 
81  const double pt1 = sqrt(px1 * px1 + py1 * py1);
82 
83  const double px2 = cart_coordList[1][0];
84  const double py2 = cart_coordList[1][1];
85  const double pz2 = cart_coordList[1][2];
86 
87  const double pt2 = sqrt(px2 * px2 + py2 * py2);
88 
89  const double deltaX1 = refPoint[0] - cart_coordList[0][4];
90  const double deltaY1 = refPoint[1] - cart_coordList[0][5];
91  const double deltaX2 = refPoint[0] - cart_coordList[1][4];
92  const double deltaY2 = refPoint[1] - cart_coordList[1][5];
93 
94  const double a1 = charges[0] * bend_factor;
95  const double a2 = charges[1] * bend_factor;
96 
97  // derivatives to first constraint-equation:
98  matrixDeriv2(0, 0) = -(px2 - a2 * deltaY2) / (pt1 * pt2) +
99  px1 *
100  ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
101  (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
102  (pt1 * pt1 * pt1 * pt2); // vs px1
103  matrixDeriv2(0, 1) = -(py2 + a2 * deltaX2) / (pt1 * pt2) +
104  py1 *
105  ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
106  (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
107  (pt1 * pt1 * pt1 * pt2); // vs py1
108  matrixDeriv2(0, 2) = 0.; // vs pz1
109  matrixDeriv2(0, 3) = 0.; // vs E1
110 
111  matrixDeriv2(0, 4) = a1 * (py2 + a2 * deltaX2) / (pt1 * pt2); // vs x1
112  matrixDeriv2(0, 5) = -a1 * (px2 - a2 * deltaY2) / (pt1 * pt2); // vs y1
113  matrixDeriv2(0, 6) = 0.; // vs z1
114 
115  matrixDeriv2(0, 7) = -(px1 - a1 * deltaY1) / (pt1 * pt2) +
116  px2 *
117  ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
118  (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
119  (pt1 * pt2 * pt2 * pt2); // vs px2
120  matrixDeriv2(0, 8) = -(py1 + a1 * deltaX1) / (pt1 * pt2) +
121  py2 *
122  ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
123  (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
124  (pt1 * pt2 * pt2 * pt2); // vs py2
125  matrixDeriv2(0, 9) = 0.; // vs pz2
126  matrixDeriv2(0, 10) = 0.; // vs E2
127 
128  matrixDeriv2(0, 11) = a2 * (py1 + a1 * deltaX1) / (pt1 * pt2); // vs x2
129  matrixDeriv2(0, 12) = -a2 * (px1 - a1 * deltaY1) / (pt1 * pt2); // vs y2
130  matrixDeriv2(0, 13) = 0.; // vs z2
131 
132  // derivatives to second constraint-equation:
133  matrixDeriv2(1, 0) = -(px1 * pz2) / pt1; // vs px1
134  matrixDeriv2(1, 1) = -(py1 * pz2) / pt1; // vs py1
135  matrixDeriv2(1, 2) = pt2; // vs pz1
136  matrixDeriv2(1, 3) = 0.; // vs E1
137 
138  matrixDeriv2(1, 4) = 0.; // vs x1
139  matrixDeriv2(1, 5) = 0.; // vs y1
140  matrixDeriv2(1, 6) = 0.; // vs z1
141 
142  matrixDeriv2(1, 7) = (px2 * pz1) / pt2; // vs px2
143  matrixDeriv2(1, 8) = (py2 * pz1) / pt2; // vs py2
144  matrixDeriv2(1, 9) = -pt1; // vs pz2
145  matrixDeriv2(1, 10) = 0; // vs E2
146 
147  matrixDeriv2(1, 11) = 0.; // vs x2
148  matrixDeriv2(1, 12) = 0.; // vs y2
149  matrixDeriv2(1, 13) = 0.; // vs z2
150 
151  return matrixDeriv2;
152 }

◆ numberOfEquations()

virtual int Trk::CollinearityConstraint::numberOfEquations ( ) const
inlinefinaloverridevirtual

Implements Trk::IKinematicConstraint.

Definition at line 34 of file CollinearityConstraint.h.

34 { return s_eqno; }

◆ vectorOfValues()

Amg::VectorX Trk::CollinearityConstraint::vectorOfValues ( std::vector< Amg::VectorX > &  cart_coordList,
std::vector< int > &  charges,
Amg::Vector3D  refPoint,
double  b_fieldTesla 
) const
finaloverridevirtual

Implements Trk::IKinematicConstraint.

Definition at line 13 of file CollinearityConstraint.cxx.

18 {
19 
20  unsigned int ntrack = cart_coordList.size();
21 
22  Amg::VectorX vectorOfValues2(2, 0);
23 
24  if (ntrack != 2) {
25  return vectorOfValues2; // returning vector with zero's
26  }
27 
28  const double bend_factor = -0.299792458 * b_fieldTesla;
29 
30  const double px1 = cart_coordList[0][0];
31  const double py1 = cart_coordList[0][1];
32  const double pz1 = cart_coordList[0][2];
33 
34  const double pt1 = sqrt(px1 * px1 + py1 * py1);
35 
36  const double px2 = cart_coordList[1][0];
37  const double py2 = cart_coordList[1][1];
38  const double pz2 = cart_coordList[1][2];
39 
40  double pt2 = sqrt(px2 * px2 + py2 * py2);
41 
42  const double deltaX1 = refPoint[0] - cart_coordList[0][4];
43  const double deltaY1 = refPoint[1] - cart_coordList[0][5];
44  const double deltaX2 = refPoint[0] - cart_coordList[1][4];
45  const double deltaY2 = refPoint[1] - cart_coordList[1][5];
46 
47  const double a1 = charges[0] * bend_factor;
48  const double a2 = charges[1] * bend_factor;
49 
50  // constraint equations, using scalar product:
51  vectorOfValues2[0] = 1 - ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
52  (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
53  (pt1 * pt2);
54  vectorOfValues2[1] = pz1 * pt2 - pz2 * pt1;
55 
56  return vectorOfValues2;
57 }

Member Data Documentation

◆ s_eqno

constexpr int Trk::CollinearityConstraint::s_eqno = 2
staticconstexprprivate

Definition at line 37 of file CollinearityConstraint.h.


The documentation for this class was generated from the following files:
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:30
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
Trk::CollinearityConstraint::s_eqno
static constexpr int s_eqno
Definition: CollinearityConstraint.h:37