CMS 3D CMS Logo

ColinearityKinematicConstraintT.h
Go to the documentation of this file.
1 #ifndef ColinearityKinematicConstraintT_H
2 #define ColinearityKinematicConstraintT_H
3 
7 
9 
19  enum ConstraintDim { Phi = 1, PhiTheta = 2 };
20 }
21 
22 template <enum colinearityKinematic::ConstraintDim Dim>
24 private:
25  double a_1;
26  double a_2;
27 
30 
32 
33 public:
35 
37 
38  // initialize the constraint so it can precompute common qualtities to the three next call
39  void init(const std::vector<KinematicState>& states,
40  const GlobalPoint& ipoint,
41  const GlobalVector& fieldValue) override {
42  if (states.size() != 2)
43  throw VertexException("ColinearityKinematicConstraint::<2 states passed");
44 
45  point = ipoint;
46 
47  a_1 = -states[0].particleCharge() * fieldValue.z();
48  a_2 = -states[1].particleCharge() * fieldValue.z();
49 
50  p1 = states[0].kinematicParameters().vector();
51  p2 = states[1].kinematicParameters().vector();
52  }
53 
57  int numberOfEquations() const override { return Dim == colinearityKinematic::Phi ? 1 : 2; }
58 
60  return new ColinearityKinematicConstraintT<Dim>(*this);
61  }
62 
63 private:
69  void fillValue() const override;
70 
76  void fillParametersDerivative() const override;
77 
83  void fillPositionDerivative() const override;
84 };
85 
86 template <enum colinearityKinematic::ConstraintDim Dim>
88  typename super::valueType& vl = super::vl();
89 
90  double p1vx = p1(3) - a_1 * (point.y() - p1(1));
91  double p1vy = p1(4) + a_1 * (point.x() - p1(0));
92 
93  double p2vx = p2(3) - a_2 * (point.y() - p2(1));
94  double p2vy = p2(4) + a_2 * (point.x() - p2(0));
95 
96  // H_phi:
97  vl(0) = atan2(p1vy, p1vx) - atan2(p2vy, p2vx);
98  if (vl(0) > M_PI)
99  vl(0) -= 2.0 * M_PI;
100  if (vl(0) <= -M_PI)
101  vl(0) += 2.0 * M_PI;
102  // H_theta:
103  if (Dim == colinearityKinematic::PhiTheta) {
104  double pt1 = sqrt(p1(3) * p1(3) + p1(4) * p1(4));
105  double pt2 = sqrt(p2(3) * p2(3) + p2(4) * p2(4));
106  vl(1) = atan2(pt1, p1(5)) - atan2(pt2, p2(5));
107  if (vl(1) > M_PI)
108  vl(1) -= 2.0 * M_PI;
109  if (vl(1) <= -M_PI)
110  vl(1) += 2.0 * M_PI;
111  }
112 }
113 
114 template <enum colinearityKinematic::ConstraintDim Dim>
116  typename super::parametersDerivativeType& jac_d = super::jac_d();
117 
118  double p1vx = p1(3) - a_1 * (point.y() - p1(1));
119  double p1vy = p1(4) + a_1 * (point.x() - p1(0));
120  double k1 = 1.0 / (p1vx * p1vx + p1vy * p1vy);
121 
122  double p2vx = p2(3) - a_2 * (point.y() - p2(1));
123  double p2vy = p2(4) + a_2 * (point.x() - p2(0));
124  double k2 = 1.0 / (p2vx * p2vx + p2vy * p2vy);
125 
126  // H_phi:
127 
128  //x1 and x2 derivatives: 1st and 8th elements
129  jac_d(0, 0) = -k1 * a_1 * p1vx;
130  jac_d(0, 7) = k2 * a_2 * p2vx;
131 
132  //y1 and y2 derivatives: 2nd and 9th elements:
133  jac_d(0, 1) = -k1 * a_1 * p1vy;
134  jac_d(0, 8) = k2 * a_2 * p2vy;
135 
136  //z1 and z2 components: 3d and 10th elmnets stay 0:
137  jac_d(0, 2) = 0.;
138  jac_d(0, 9) = 0.;
139 
140  //px1 and px2 components: 4th and 11th elements:
141  jac_d(0, 3) = -k1 * p1vy;
142  jac_d(0, 10) = k2 * p2vy;
143 
144  //py1 and py2 components: 5th and 12 elements:
145  jac_d(0, 4) = k1 * p1vx;
146  jac_d(0, 11) = -k2 * p2vx;
147 
148  //pz1 and pz2 components: 6th and 13 elements:
149  jac_d(0, 5) = 0.;
150  jac_d(0, 12) = 0.;
151  //mass components: 7th and 14th elements:
152  jac_d(0, 6) = 0.;
153  jac_d(0, 13) = 0.;
154 
155  if (Dim == colinearityKinematic::PhiTheta) {
156  double pt1 = sqrt(p1(3) * p1(3) + p1(4) * p1(4));
157  double pTot1 = p1(3) * p1(3) + p1(4) * p1(4) + p1(5) * p1(5);
158  double pt2 = sqrt(p2(3) * p2(3) + p2(4) * p2(4));
159  double pTot2 = p2(3) * p2(3) + p2(4) * p2(4) + p2(5) * p2(5);
160 
161  // H_theta:
162  //x1 and x2 derivatives: 1st and 8th elements
163  jac_d(1, 0) = 0.;
164  jac_d(1, 7) = 0.;
165 
166  //y1 and y2 derivatives: 2nd and 9th elements:
167  jac_d(1, 1) = 0.;
168  jac_d(1, 8) = 0.;
169 
170  //z1 and z2 components: 3d and 10th elmnets stay 0:
171  jac_d(1, 2) = 0.;
172  jac_d(1, 9) = 0.;
173 
174  jac_d(1, 3) = p1(3) * (p1(5) / (pTot1 * pt1));
175  jac_d(1, 10) = p2(3) * (-p2(5) / (pTot2 * pt2));
176 
177  //py1 and py2 components: 5th and 12 elements:
178  jac_d(1, 4) = p1(4) * (p1(5) / (pTot1 * pt1));
179  jac_d(1, 11) = p2(4) * (-p2(5) / (pTot2 * pt2));
180 
181  //pz1 and pz2 components: 6th and 13 elements:
182  jac_d(1, 5) = -pt1 / pTot1;
183  jac_d(1, 12) = pt2 / pTot2;
184 
185  //mass components: 7th and 14th elements:
186  jac_d(1, 6) = 0.;
187  jac_d(1, 13) = 0.;
188  }
189 }
190 
191 template <enum colinearityKinematic::ConstraintDim Dim>
193  typename super::positionDerivativeType& jac_e = super::jac_e();
194 
195  double p1vx = p1(3) - a_1 * (point.y() - p1(1));
196  double p1vy = p1(4) + a_1 * (point.x() - p1(0));
197  double k1 = 1.0 / (p1vx * p1vx + p1vy * p1vy);
198 
199  double p2vx = p2(3) - a_2 * (point.y() - p2(1));
200  double p2vy = p2(4) + a_2 * (point.x() - p2(0));
201  double k2 = 1.0 / (p2vx * p2vx + p2vy * p2vy);
202 
203  // H_phi:
204 
205  // xv component
206  jac_e(0, 0) = k1 * a_1 * p1vx - k2 * a_2 * p2vx;
207 
208  //yv component
209  jac_e(0, 1) = k1 * a_1 * p1vy - k2 * a_2 * p2vy;
210 
211  //zv component
212  jac_e(0, 2) = 0.;
213 
214  // H_theta: no correlation with vertex position
215  if (Dim == colinearityKinematic::PhiTheta) {
216  jac_e(1, 0) = 0.;
217  jac_e(1, 1) = 0.;
218  jac_e(1, 2) = 0.;
219  }
220 }
221 
222 #endif
T z() const
Definition: PV3DBase.h:61
Common base class.
ROOT::Math::SVector< double, 7 > AlgebraicVector7
Definition: Matrices.h:8
ROOT::Math::SMatrix< double, DIM, 3 > positionDerivativeType
void init(const std::vector< KinematicState > &states, const GlobalPoint &ipoint, const GlobalVector &fieldValue) override
T sqrt(T t)
Definition: SSEVec.h:19
#define M_PI
ColinearityKinematicConstraintT< Dim > * clone() const override
ROOT::Math::SMatrix< double, DIM, 7 *NTRK > parametersDerivativeType
MultiTrackKinematicConstraintT< 2, int(Dim)> super
*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