CMS 3D CMS Logo

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