CMS 3D CMS Logo

PerigeeLinearizedTrackState.cc
Go to the documentation of this file.
8 
10  GlobalPoint paramPt(theLinPoint);
11 
12  thePredState = builder(theTSOS, paramPt);
14  return;
15 
16  double field = theTrack.field()->inInverseGeV(thePredState.theState().position()).z();
17 
18  if ((std::abs(theCharge) < 1e-5) || (fabs(field) < 1.e-10)) {
19  //neutral track
21  } else {
22  //charged track
24  }
25 
26  jacobiansAvailable = true;
27 }
28 
30  const PerigeeLinearizedTrackState* otherP = dynamic_cast<const PerigeeLinearizedTrackState*>(&other);
31  if (otherP == nullptr) {
32  throw VertexException("PerigeeLinearizedTrackState: don't know how to compare myself to non-perigee track state");
33  }
34  return (otherP->track() == theTrack);
35 }
36 
38  const PerigeeLinearizedTrackState* otherP = dynamic_cast<const PerigeeLinearizedTrackState*>(other.get());
39  if (otherP == nullptr) {
40  throw VertexException("PerigeeLinearizedTrackState: don't know how to compare myself to non-perigee track state");
41  }
42  return (otherP->track() == theTrack);
43 }
44 
46  const GlobalPoint& newLP) const {
48 }
49 
51  const GlobalPoint& vertexPosition,
52  const AlgebraicVector3& vectorParameters,
53  const AlgebraicSymMatrix66& covarianceMatrix) const {
55  vectorParameters, vertexPosition, charge(), covarianceMatrix, theTrack.field());
56  return RefCountedRefittedTrackState(new PerigeeRefittedTrackState(refittedTSCP, vectorParameters));
57 }
58 
59 std::vector<PerigeeLinearizedTrackState::RefCountedLinearizedTrackState> PerigeeLinearizedTrackState::components()
60  const {
61  std::vector<RefCountedLinearizedTrackState> result;
62  result.reserve(1);
63  result.push_back(RefCountedLinearizedTrackState(const_cast<PerigeeLinearizedTrackState*>(this)));
64  return result;
65 }
66 
68  const RefCountedRefittedTrackState& theRefittedState) const {
69  auto p = theRefittedState->position();
70  AlgebraicVector3 vertexPosition(p.x(), p.y(), p.z());
71  AlgebraicVector3 momentum = theRefittedState->momentumVector();
72  if ((momentum(2) * predictedStateMomentumParameters()(2) < 0) && (fabs(momentum(2)) > M_PI / 2)) {
74  momentum(2) -= 2 * M_PI;
76  momentum(2) += 2 * M_PI;
77  }
78  AlgebraicVectorN param = constantTerm() + positionJacobian() * vertexPosition + momentumJacobian() * momentum;
79  if (param(2) > M_PI)
80  param(2) -= 2 * M_PI;
81  if (param(2) < -M_PI)
82  param(2) += 2 * M_PI;
83 
84  return param;
85 }
86 
88  if (parameters(2) > M_PI)
89  parameters(2) -= 2 * M_PI;
90  if (parameters(2) < -M_PI)
91  parameters(2) += 2 * M_PI;
92 }
93 
95  GlobalPoint paramPt(theLinPoint);
96  //tarjectory parameters
97  double field = theTrack.field()->inInverseGeV(thePredState.theState().position()).z();
98  double signTC = -theCharge;
99 
100  double thetaAtEP = thePredState.perigeeParameters().theta();
101  double phiAtEP = thePredState.perigeeParameters().phi();
102  double ptAtEP = thePredState.pt();
103  double transverseCurvatureAtEP = field / ptAtEP * signTC;
104 
105  double x_v = thePredState.theState().position().x();
106  double y_v = thePredState.theState().position().y();
107  double z_v = thePredState.theState().position().z();
108  double X = x_v - paramPt.x() - sin(phiAtEP) / transverseCurvatureAtEP;
109  double Y = y_v - paramPt.y() + cos(phiAtEP) / transverseCurvatureAtEP;
110  double SS = X * X + Y * Y;
111  double S = sqrt(SS);
112 
113  // The track parameters at the expansion point
114 
115  theExpandedParams[0] = transverseCurvatureAtEP;
116  theExpandedParams[1] = thetaAtEP;
117  theExpandedParams[3] = 1 / transverseCurvatureAtEP - signTC * S;
118  double phiFEP;
119  if (std::abs(X) > std::abs(Y)) {
120  double signX = (X > 0.0 ? +1.0 : -1.0);
121  phiFEP = -signTC * signX * acos(signTC * Y / S);
122  } else {
123  phiFEP = asin(-signTC * X / S);
124  if ((signTC * Y) < 0.0)
125  phiFEP = M_PI - phiFEP;
126  }
127  if (phiFEP > M_PI)
128  phiFEP -= 2 * M_PI;
129  theExpandedParams[2] = phiFEP;
130  theExpandedParams[4] =
131  z_v - paramPt.z() - (phiAtEP - theExpandedParams[2]) / tan(thetaAtEP) / transverseCurvatureAtEP;
132 
133  // The Jacobian: (all at the expansion point)
134  // [i,j]
135  // i = 0: rho , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
136  // j = 0: x_v, 1: y_v, 2: z_v
137 
138  thePositionJacobian(2, 0) = -Y / (SS);
139  thePositionJacobian(2, 1) = X / (SS);
140  thePositionJacobian(3, 0) = -signTC * X / S;
141  thePositionJacobian(3, 1) = -signTC * Y / S;
142  thePositionJacobian(4, 0) = thePositionJacobian(2, 0) / tan(thetaAtEP) / transverseCurvatureAtEP;
143  thePositionJacobian(4, 1) = thePositionJacobian(2, 1) / tan(thetaAtEP) / transverseCurvatureAtEP;
144  thePositionJacobian(4, 2) = 1;
145 
146  // [i,j]
147  // i = 0: rho , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
148  // j = 0: rho, 1: theta, 2: phi_v
149  theMomentumJacobian(0, 0) = 1;
150  theMomentumJacobian(1, 1) = 1;
151 
152  theMomentumJacobian(2, 0) =
153  -(X * cos(phiAtEP) + Y * sin(phiAtEP)) / (SS * transverseCurvatureAtEP * transverseCurvatureAtEP);
154 
155  theMomentumJacobian(2, 2) = (Y * cos(phiAtEP) - X * sin(phiAtEP)) / (SS * transverseCurvatureAtEP);
156 
157  theMomentumJacobian(3, 0) =
158  (signTC * (Y * cos(phiAtEP) - X * sin(phiAtEP)) / S - 1) / (transverseCurvatureAtEP * transverseCurvatureAtEP);
159 
160  theMomentumJacobian(3, 2) = signTC * (X * cos(phiAtEP) + Y * sin(phiAtEP)) / (S * transverseCurvatureAtEP);
161 
162  theMomentumJacobian(4, 0) =
163  (phiAtEP - theExpandedParams[2]) / tan(thetaAtEP) / (transverseCurvatureAtEP * transverseCurvatureAtEP) +
164  theMomentumJacobian(2, 0) / tan(thetaAtEP) / transverseCurvatureAtEP;
165 
166  theMomentumJacobian(4, 1) =
167  (phiAtEP - theExpandedParams[2]) * (1 + 1 / (tan(thetaAtEP) * tan(thetaAtEP))) / transverseCurvatureAtEP;
168 
169  theMomentumJacobian(4, 2) = (theMomentumJacobian(2, 2) - 1) / tan(thetaAtEP) / transverseCurvatureAtEP;
170 
171  // And finally the residuals:
172 
173  auto p = thePredState.theState().position();
174  AlgebraicVector3 expansionPoint(p.x(), p.y(), p.z());
175  AlgebraicVector3 momentumAtExpansionPoint(transverseCurvatureAtEP, thetaAtEP, phiAtEP);
176 
178  theMomentumJacobian * momentumAtExpansionPoint);
179 }
180 
182  GlobalPoint paramPt(theLinPoint);
183 
184  //tarjectory parameters
185  double thetaAtEP = thePredState.theState().momentum().theta();
186  double phiAtEP = thePredState.theState().momentum().phi();
187  double ptAtEP = thePredState.theState().momentum().perp();
188 
189  double x_v = thePredState.theState().position().x();
190  double y_v = thePredState.theState().position().y();
191  double z_v = thePredState.theState().position().z();
192  double X = x_v - paramPt.x();
193  double Y = y_v - paramPt.y();
194 
195  // The track parameters at the expansion point
196 
197  theExpandedParams(0) = 1 / ptAtEP;
198  theExpandedParams(1) = thetaAtEP;
199  theExpandedParams(2) = phiAtEP;
200  theExpandedParams(3) = X * sin(phiAtEP) - Y * cos(phiAtEP);
201  theExpandedParams(4) = z_v - paramPt.z() - (X * cos(phiAtEP) + Y * sin(phiAtEP)) / tan(thetaAtEP);
202 
203  // The Jacobian: (all at the expansion point)
204  // [i,j]
205  // i = 0: rho = 1/pt , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
206  // j = 0: x_v, 1: y_v, 2: z_v
207 
208  thePositionJacobian(3, 0) = sin(phiAtEP);
209  thePositionJacobian(3, 1) = -cos(phiAtEP);
210  thePositionJacobian(4, 0) = -cos(phiAtEP) / tan(thetaAtEP);
211  thePositionJacobian(4, 1) = -sin(phiAtEP) / tan(thetaAtEP);
212  thePositionJacobian(4, 2) = 1;
213 
214  // [i,j]
215  // i = 0: rho = 1/pt , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
216  // j = 0: rho = 1/pt , 1: theta, 2: phi_v
217 
218  theMomentumJacobian(0, 0) = 1;
219  theMomentumJacobian(1, 1) = 1;
220  theMomentumJacobian(2, 2) = 1;
221 
222  theMomentumJacobian(3, 2) = X * cos(phiAtEP) + Y * sin(phiAtEP);
223 
224  theMomentumJacobian(4, 1) = theMomentumJacobian(3, 2) * (1 + 1 / (tan(thetaAtEP) * tan(thetaAtEP)));
225 
226  theMomentumJacobian(4, 2) = (X * sin(phiAtEP) - Y * cos(phiAtEP)) / tan(thetaAtEP);
227 
228  // And finally the residuals:
229 
230  auto p = thePredState.theState().position();
231  AlgebraicVector3 expansionPoint(p.x(), p.y(), p.z());
232  AlgebraicVector3 momentumAtExpansionPoint(1. / ptAtEP, thetaAtEP, phiAtEP);
233 
235  theMomentumJacobian * momentumAtExpansionPoint);
236 }
std::vector< ReferenceCountingPointer< LinearizedTrackState< 5 > > > components() const override
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const AlgebraicVector3 &momentum, const GlobalPoint &referencePoint, const TrackCharge &charge, const AlgebraicSymMatrix66 &theCovarianceMatrix, const MagneticField *field)
TrackCharge charge() const override
T perp() const
Definition: PV3DBase.h:69
void checkParameters(AlgebraicVector5 &parameters) const override
ROOT::Math::SVector< double, N > AlgebraicVectorN
T z() const
Definition: PV3DBase.h:61
Common base class.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
AlgebraicVector3 predictedStateMomentumParameters() const override
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:36
#define X(str)
Definition: MuonsGrabber.cc:38
RefCountedLinearizedTrackState stateWithNewLinearizationPoint(const GlobalPoint &newLP) const override
const AlgebraicVector5 & constantTerm() const override
ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
GlobalPoint position() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
TrajectoryStateClosestToPoint thePredState
bool operator==(LinearizedTrackState< 5 > &other) const override
T sqrt(T t)
Definition: SSEVec.h:19
const TrajectoryStateOnSurface theTSOS
const MagneticField * field() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
GlobalVector momentum() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ROOT::Math::SVector< double, 5 > AlgebraicVector5
ReferenceCountingPointer< RefittedTrackState< N > > RefCountedRefittedTrackState
const PerigeeTrajectoryParameters & perigeeParameters() const
#define M_PI
PerigeeLinearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track, const TrajectoryStateOnSurface &tsos)
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
const AlgebraicMatrix53 & positionJacobian() const override
const AlgebraicMatrix53 & momentumJacobian() const override
const FreeTrajectoryState & theState() const
reco::TransientTrack track() const override
AlgebraicVector5 refittedParamFromEquation(const RefCountedRefittedTrackState &theRefittedState) const override
ROOT::Math::SVector< double, 3 > AlgebraicVector3
#define UNLIKELY(x)
Definition: Likely.h:21
RefCountedRefittedTrackState createRefittedTrackState(const GlobalPoint &vertexPosition, const AlgebraicVector3 &vectorParameters, const AlgebraicSymMatrix66 &covarianceMatrix) const override
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72