CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PerigeeLinearizedTrackState.cc
Go to the documentation of this file.
7 
8 // #include "CommonReco/PatternTools/interface/TransverseImpactPointExtrapolator.h"
9 // #include "CommonDet/DetUtilities/interface/FastTimeMe.h"
10 
15 {
17  return theConstantTerm;
18 }
19 
24 {
26  return thePositionJacobian;
27 }
28 
33 {
35  return theMomentumJacobian;
36 }
37 
41 {
43  return theExpandedParams;
44 }
45 
51 {
53  return thePredState;
54 }
55 
56 // /** Method returning the impact point measurement
57 // */
58 // ImpactPointMeasurement PerigeeLinearizedTrackState::impactPointMeasurement() const
59 // {
60 // if (!impactPointAvailable) compute3DImpactPoint();
61 // return the3DImpactPoint;
62 // }
63 //
65 {
66  GlobalPoint paramPt(theLinPoint);
67 
68 // std::cout << "Track "
69 // << "\n Param " << theTSOS.globalParameters ()
70 // << "\n Dir " << theTSOS.globalDirection ()
71 // << "\n";
72  thePredState = builder(theTSOS, paramPt);
73  if (!thePredState.isValid())
74  return;
75 // std::cout << "thePredState " << thePredState.theState().position()<<std::endl;
76 // edm::LogInfo("RecoVertex/PerigeeLTS")
77 // << "predstate built" << "\n";
78  double field = theTrack.field()->inInverseGeV(thePredState.theState().position()).z();
79 
80  if ((std::abs(theCharge)<1e-5)||(fabs(field)<1.e-10)){
81  //neutral track
83  } else {
84  //charged track
85 // edm::LogInfo("RecoVertex/PerigeeLTS")
86 // << "about to compute charged jac" << "\n";
88 // edm::LogInfo("RecoVertex/PerigeeLTS")
89 // << "charged jac computed" << "\n";
90  }
91 
92 
93 
94 
95  jacobiansAvailable = true;
96 }
97 
98 // void PerigeeLinearizedTrackState::compute3DImpactPoint() const
99 // {
100 // the3DImpactPoint = theIPMExtractor.impactPointMeasurement(theTrack, theLinPoint);
101 // impactPointAvailable = true;
102 // }
103 
105 {
107  return thePredState.hasError();
108 }
109 
111 {
114 }
115 
117 {
119  AlgebraicVector3 momentum;
120  momentum[0] = thePredState.perigeeParameters().vector()(0);
121  momentum[1] = thePredState.perigeeParameters().theta();
122  momentum[2] = thePredState.perigeeParameters().phi();
123  return momentum;
124 }
125 
127 {
129  if (!thePredState.isValid()) {
130  error = 1;
131  return AlgebraicSymMatrix55();
132  }
133  return thePredState.perigeeError().weightMatrix(error);
134 }
135 
137 {
140 }
141 
143 {
146 }
147 
149 {
150  const PerigeeLinearizedTrackState* otherP =
151  dynamic_cast<const PerigeeLinearizedTrackState*>(&other);
152  if (otherP == 0) {
153  throw VertexException("PerigeeLinearizedTrackState: don't know how to compare myself to non-perigee track state");
154  }
155  return (otherP->track() == theTrack);
156 }
157 
158 
160 {
161  const PerigeeLinearizedTrackState* otherP =
162  dynamic_cast<const PerigeeLinearizedTrackState*>(other.get());
163  if (otherP == 0) {
164  throw VertexException("PerigeeLinearizedTrackState: don't know how to compare myself to non-perigee track state");
165  }
166  return (otherP->track() == theTrack);
167 }
168 
169 
172  (const GlobalPoint & newLP) const
173 {
175  new PerigeeLinearizedTrackState(newLP, track(), theTSOS));
176 }
177 
180  const GlobalPoint & vertexPosition,
181  const AlgebraicVector3 & vectorParameters,
182  const AlgebraicSymMatrix66 & covarianceMatrix) const
183 {
184  PerigeeConversions perigeeConversions;
185  TrajectoryStateClosestToPoint refittedTSCP =
186  perigeeConversions.trajectoryStateClosestToPoint(
187  vectorParameters, vertexPosition, charge(), covarianceMatrix, theTrack.field());
188  return RefCountedRefittedTrackState(new PerigeeRefittedTrackState(refittedTSCP, vectorParameters));
189 }
190 
191 std::vector< PerigeeLinearizedTrackState::RefCountedLinearizedTrackState >
193 {
194  std::vector<RefCountedLinearizedTrackState> result; result.reserve(1);
195  result.push_back(RefCountedLinearizedTrackState(
196  const_cast<PerigeeLinearizedTrackState*>(this)));
197  return result;
198 }
199 
200 
202  const RefCountedRefittedTrackState & theRefittedState) const
203 {
204  AlgebraicVector3 vertexPosition;
205  vertexPosition(0) = theRefittedState->position().x();
206  vertexPosition(1) = theRefittedState->position().y();
207  vertexPosition(2) = theRefittedState->position().z();
208  AlgebraicVector3 momentum = theRefittedState->momentumVector();
209  if ((momentum(2)*predictedStateMomentumParameters()(2) < 0)&&(fabs(momentum(2))>M_PI/2) ) {
210  if (predictedStateMomentumParameters()(2) < 0.) momentum(2)-= 2*M_PI;
211  if (predictedStateMomentumParameters()(2) > 0.) momentum(2)+= 2*M_PI;
212  }
213  AlgebraicVectorN param = constantTerm() +
214  positionJacobian() * vertexPosition +
215  momentumJacobian() * momentum;
216  if (param(2) > M_PI) param(2)-= 2*M_PI;
217  if (param(2) < -M_PI) param(2)+= 2*M_PI;
218 
219  return param;
220 }
221 
222 
224 {
225  if (parameters(2) > M_PI) parameters(2)-= 2*M_PI;
226  if (parameters(2) < -M_PI) parameters(2)+= 2*M_PI;
227 }
228 
230 {
231  GlobalPoint paramPt(theLinPoint);
232  //tarjectory parameters
233  double field = theTrack.field()->inInverseGeV(thePredState.theState().position()).z();
234  double signTC = -theCharge;
235 
236  double thetaAtEP = thePredState.theState().momentum().theta();
237  double phiAtEP = thePredState.theState().momentum().phi();
238  double ptAtEP = thePredState.theState().momentum().perp();
239  double transverseCurvatureAtEP = field / ptAtEP*signTC;
240 
241  double x_v = thePredState.theState().position().x();
242  double y_v = thePredState.theState().position().y();
243  double z_v = thePredState.theState().position().z();
244  double X = x_v - paramPt.x() - sin(phiAtEP) / transverseCurvatureAtEP;
245  double Y = y_v - paramPt.y() + cos(phiAtEP) / transverseCurvatureAtEP;
246  double SS = X*X + Y*Y;
247  double S = sqrt(SS);
248 
249  // The track parameters at the expansion point
250 
251  theExpandedParams[0] = transverseCurvatureAtEP;
252  theExpandedParams[1] = thetaAtEP;
253  theExpandedParams[3] = 1/transverseCurvatureAtEP - signTC * S;
254  double phiFEP;
255  if (std::abs(X)>std::abs(Y)) {
256  double signX = (X>0.0? +1.0:-1.0);
257  phiFEP = -signTC * signX*acos(signTC*Y/S);
258  } else {
259  phiFEP = asin(-signTC*X/S);
260  if ((signTC*Y)<0.0)
261  phiFEP = M_PI - phiFEP;
262  }
263  if (phiFEP>M_PI) phiFEP-= 2*M_PI;
264  theExpandedParams[2] = phiFEP;
265  theExpandedParams[4] = z_v - paramPt.z() -
266  (phiAtEP - theExpandedParams[2]) / tan(thetaAtEP)/transverseCurvatureAtEP;
267 
268  // The Jacobian: (all at the expansion point)
269  // [i,j]
270  // i = 0: rho , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
271  // j = 0: x_v, 1: y_v, 2: z_v
272 
273  thePositionJacobian(2,0) = - Y / (SS);
274  thePositionJacobian(2,1) = X / (SS);
275  thePositionJacobian(3,0) = - signTC * X / S;
276  thePositionJacobian(3,1) = - signTC * Y / S;
277  thePositionJacobian(4,0) = thePositionJacobian(2,0)/tan(thetaAtEP)/transverseCurvatureAtEP;
278  thePositionJacobian(4,1) = thePositionJacobian(2,1)/tan(thetaAtEP)/transverseCurvatureAtEP;
279  thePositionJacobian(4,2) = 1;
280 
281  // [i,j]
282  // i = 0: rho , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
283  // j = 0: rho, 1: theta, 2: phi_v
284  theMomentumJacobian(0,0) = 1;
285  theMomentumJacobian(1,1) = 1;
286 
287  theMomentumJacobian(2,0) = -
288  (X*cos(phiAtEP) + Y*sin(phiAtEP))/
289  (SS*transverseCurvatureAtEP*transverseCurvatureAtEP);
290 
291  theMomentumJacobian(2,2) = (Y*cos(phiAtEP) - X*sin(phiAtEP)) /
292  (SS*transverseCurvatureAtEP);
293 
294  theMomentumJacobian(3,0) =
295  (signTC * (Y*cos(phiAtEP) - X*sin(phiAtEP)) / S - 1)/
296  (transverseCurvatureAtEP*transverseCurvatureAtEP);
297 
298  theMomentumJacobian(3,2) = signTC *(X*cos(phiAtEP) + Y*sin(phiAtEP))/
299  (S*transverseCurvatureAtEP);
300 
301  theMomentumJacobian(4,0) = (phiAtEP - theExpandedParams[2]) /
302  tan(thetaAtEP)/(transverseCurvatureAtEP*transverseCurvatureAtEP)+
303  theMomentumJacobian(2,0) / tan(thetaAtEP)/transverseCurvatureAtEP;
304 
305  theMomentumJacobian(4,1) = (phiAtEP - theExpandedParams[2]) *
306  (1 + 1/(tan(thetaAtEP)*tan(thetaAtEP)))/transverseCurvatureAtEP;
307 
308  theMomentumJacobian(4,2) = (theMomentumJacobian(2,2) - 1) /
309  tan(thetaAtEP)/transverseCurvatureAtEP;
310 
311  // And finally the residuals:
312 
313  AlgebraicVector3 expansionPoint;
314  expansionPoint(0) = thePredState.theState().position().x();
315  expansionPoint(1) = thePredState.theState().position().y();
316  expansionPoint(2) = thePredState.theState().position().z();
317  AlgebraicVector3 momentumAtExpansionPoint;
318  momentumAtExpansionPoint(0) = transverseCurvatureAtEP; // Transverse Curv
319  momentumAtExpansionPoint(1) = thetaAtEP;
320  momentumAtExpansionPoint(2) = phiAtEP;
321 
323  thePositionJacobian * expansionPoint -
324  theMomentumJacobian * momentumAtExpansionPoint );
325 
326 }
327 
328 
329 
330 
331 
333 {
334  GlobalPoint paramPt(theLinPoint);
335 
336  //tarjectory parameters
337  double thetaAtEP = thePredState.theState().momentum().theta();
338  double phiAtEP = thePredState.theState().momentum().phi();
339  double ptAtEP = thePredState.theState().momentum().perp();
340 
341  double x_v = thePredState.theState().position().x();
342  double y_v = thePredState.theState().position().y();
343  double z_v = thePredState.theState().position().z();
344  double X = x_v - paramPt.x();
345  double Y = y_v - paramPt.y();
346 
347  // The track parameters at the expansion point
348 
349  theExpandedParams(0) = 1 / ptAtEP;
350  theExpandedParams(1) = thetaAtEP;
351  theExpandedParams(2) = phiAtEP;
352  theExpandedParams(3) = X*sin(phiAtEP) - Y*cos(phiAtEP);
353  theExpandedParams(4) = z_v - paramPt.z() -
354  (X*cos(phiAtEP) + Y*sin(phiAtEP)) / tan(thetaAtEP);
355 
356  // The Jacobian: (all at the expansion point)
357  // [i,j]
358  // i = 0: rho = 1/pt , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
359  // j = 0: x_v, 1: y_v, 2: z_v
360 
361  thePositionJacobian(3,0) = sin(phiAtEP);
362  thePositionJacobian(3,1) = - cos(phiAtEP);
363  thePositionJacobian(4,0) = - cos(phiAtEP)/tan(thetaAtEP);
364  thePositionJacobian(4,1) = - sin(phiAtEP)/tan(thetaAtEP);
365  thePositionJacobian(4,2) = 1;
366 
367  // [i,j]
368  // i = 0: rho = 1/pt , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
369  // j = 0: rho = 1/pt , 1: theta, 2: phi_v
370 
371  theMomentumJacobian(0,0) = 1;
372  theMomentumJacobian(1,1) = 1;
373  theMomentumJacobian(2,2) = 1;
374 
375  theMomentumJacobian(3,2) = X*cos(phiAtEP) + Y*sin(phiAtEP);
376 
378  (1 + 1/(tan(thetaAtEP)*tan(thetaAtEP)));
379 
380  theMomentumJacobian(4,2) = (X*sin(phiAtEP) - Y*cos(phiAtEP))/tan(thetaAtEP);
381 
382  // And finally the residuals:
383 
384  AlgebraicVector3 expansionPoint;
385  expansionPoint(0) = thePredState.theState().position().x();
386  expansionPoint(1) = thePredState.theState().position().y();
387  expansionPoint(2) = thePredState.theState().position().z();
388  AlgebraicVector3 momentumAtExpansionPoint;
389  momentumAtExpansionPoint(0) = 1 / ptAtEP; //
390  momentumAtExpansionPoint(1) = thetaAtEP;
391  momentumAtExpansionPoint(2) = phiAtEP;
392 
394  thePositionJacobian * expansionPoint -
395  theMomentumJacobian * momentumAtExpansionPoint );
396 
397 }
398 
400 {
401  if (!theTSOS.isValid())
402  return false;
403 
404  if (!jacobiansAvailable)
406 
407  return jacobiansAvailable;
408 }
virtual AlgebraicVector3 predictedStateMomentumParameters() const
const AlgebraicVector5 & vector() const
dictionary parameters
Definition: Parameters.py:2
T perp() const
Definition: PV3DBase.h:71
const AlgebraicMatrix53 & momentumJacobian() const
virtual RefCountedLinearizedTrackState stateWithNewLinearizationPoint(const GlobalPoint &newLP) const
const PerigeeTrajectoryError & perigeeError() const
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const AlgebraicVector3 &momentum, const GlobalPoint &referencePoint, const TrackCharge &charge, const AlgebraicSymMatrix66 &theCovarianceMatrix, const MagneticField *field) const
ROOT::Math::SVector< double, N > AlgebraicVectorN
Common base class.
const FreeTrajectoryState & theState() const
virtual reco::TransientTrack track() const
virtual void checkParameters(AlgebraicVector5 &parameters) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
#define X(str)
Definition: MuonsGrabber.cc:49
#define abs(x)
Definition: mlp_lapack.h:159
const MagneticField * field() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
double double double z
bool operator==(LinearizedTrackState< 5 > &other) const
ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
Geom::Theta< T > theta() const
Definition: PV3DBase.h:74
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:40
TrajectoryStateClosestToPoint thePredState
ROOT::Math::SMatrix< double, 5, 3, ROOT::Math::MatRepStd< double, 5, 3 > > AlgebraicMatrix53
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
const PerigeeTrajectoryParameters & perigeeParameters() const
const TrajectoryStateClosestToPoint & predictedState() const
T sqrt(T t)
Definition: SSEVec.h:46
const TrajectoryStateOnSurface theTSOS
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const AlgebraicMatrix53 & positionJacobian() const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
AlgebraicSymMatrix55 predictedStateError() const
AlgebraicSymMatrix33 predictedStateMomentumError() const
ReferenceCountingPointer< RefittedTrackState< N > > RefCountedRefittedTrackState
GlobalVector momentum() const
const AlgebraicSymMatrix55 & covarianceMatrix() const
const AlgebraicSymMatrix55 & weightMatrix(int &error) const
GlobalPoint position() const
#define M_PI
Definition: BFit3D.cc:3
ROOT::Math::SVector< double, 5 > AlgebraicVector5
virtual AlgebraicVector5 refittedParamFromEquation(const RefCountedRefittedTrackState &theRefittedState) const
const AlgebraicVector5 & parametersFromExpansion() const
T x() const
Definition: PV3DBase.h:61
AlgebraicVector5 predictedStateParameters() const
virtual RefCountedRefittedTrackState createRefittedTrackState(const GlobalPoint &vertexPosition, const AlgebraicVector3 &vectorParameters, const AlgebraicSymMatrix66 &covarianceMatrix) const
virtual std::vector< ReferenceCountingPointer< LinearizedTrackState< 5 > > > components() const
AlgebraicSymMatrix55 predictedStateWeight(int &error) const
const AlgebraicVector5 & constantTerm() const