CMS 3D CMS Logo

ParticleKinematicLinearizedTrackState.cc
Go to the documentation of this file.
4 
8  return theConstantTerm;
9 }
10 
12  if (!jacobiansAvailable)
14  return thePositionJacobian;
15 }
16 
18  if (!jacobiansAvailable)
20  return theMomentumJacobian;
21 }
22 
24  if (!jacobiansAvailable)
26  return theExpandedParams;
27 }
28 
30  if (!jacobiansAvailable)
33 }
34 
36  if (!jacobiansAvailable)
38  int i = 0;
40  error = i;
41  return z;
42  // return thePredState.perigeeError().weightMatrix(error);
43 }
44 
46  if (!jacobiansAvailable)
49 }
50 
51 // ImpactPointMeasurement ParticleKinematicLinearizedTrackState::impactPointMeasurement() const
52 // { throw VertexException(" ParticleKinematicLinearizedTrackState::impact point measurement is not implemented for kinematic classes!");}
53 
54 TrackCharge ParticleKinematicLinearizedTrackState::charge() const { return part->initialState().particleCharge(); }
55 
57 
60  dynamic_cast<const ParticleKinematicLinearizedTrackState*>(&other);
61  if (otherP == nullptr) {
62  throw VertexException(
63  " ParticleKinematicLinearizedTrackState:: don't know how to compare myself to non-kinematic track state");
64  }
65  return (*(otherP->particle()) == *part);
66 }
67 
69  if (!jacobiansAvailable)
71  return thePredState.isValid();
72 }
73 
74 // here we make a and b matrices of
75 // our measurement function expansion.
76 // marices will be almost the same as for
77 // classical perigee, but bigger:
78 // (6x3) and (6x4) respectivelly.
80  GlobalPoint paramPt(theLinPoint);
81  thePredState = builder(part->currentState(), paramPt);
82  // bool valid = thePredState.isValid();
83  // if (!valid) std::cout <<"Help!!!!!!!!! State is invalid\n";
84  // if (!valid) return;
85  if (std::abs(theCharge) < 1e-5) {
86  //neutral track
88  } else {
89  //charged track
91  }
92  jacobiansAvailable = true;
93 }
94 
98  return new ParticleKinematicLinearizedTrackState(newLP, pr);
99 }
100 
103  const AlgebraicVector4& vectorParameters,
104  const AlgebraicSymMatrix77& covarianceMatrix) const {
106  KinematicState lst = conversions.kinematicState(
107  vectorParameters, vertexPosition, charge(), covarianceMatrix, part->currentState().magneticField());
109  RefCountedRefittedTrackState(new KinematicRefittedTrackState(lst, vectorParameters));
110  return rst;
111 }
112 
114  if (!jacobiansAvailable)
117  res[0] = thePredState.perigeeParameters().vector()(0);
118  res[1] = thePredState.perigeeParameters().vector()(1);
119  res[2] = thePredState.perigeeParameters().vector()(2);
120  res[3] = thePredState.perigeeParameters().vector()(5);
121  return res;
122 }
123 
125  int error;
126  if (!jacobiansAvailable)
130  res.Place_at(m3, 0, 0);
131  res(3, 0) = thePredState.perigeeError().weightMatrix(error)(5, 5);
132  res(3, 1) = thePredState.perigeeError().weightMatrix(error)(5, 0);
133  res(3, 2) = thePredState.perigeeError().weightMatrix(error)(5, 1);
134  res(3, 3) = thePredState.perigeeError().weightMatrix(error)(5, 2);
135  return res;
136 }
137 
139 
140 std::vector<ReferenceCountingPointer<LinearizedTrackState<6> > > ParticleKinematicLinearizedTrackState::components()
141  const {
142  std::vector<ReferenceCountingPointer<LinearizedTrackState<6> > > res;
143  res.reserve(1);
144  res.push_back(RefCountedLinearizedTrackState(const_cast<ParticleKinematicLinearizedTrackState*>(this)));
145  return res;
146 }
147 
149  const RefCountedRefittedTrackState& theRefittedState) const {
150  AlgebraicVectorM momentum = theRefittedState->momentumVector();
151  if ((momentum(2) * predictedStateMomentumParameters()(2) < 0) && (std::fabs(momentum(2)) > M_PI / 2)) {
152  if (predictedStateMomentumParameters()(2) < 0.)
153  momentum(2) -= 2 * M_PI;
154  if (predictedStateMomentumParameters()(2) > 0.)
155  momentum(2) += 2 * M_PI;
156  }
157 
158  AlgebraicVector3 vertexPosition;
159  vertexPosition(0) = theRefittedState->position().x();
160  vertexPosition(1) = theRefittedState->position().y();
161  vertexPosition(2) = theRefittedState->position().z();
162  AlgebraicVector6 param = constantTerm() + positionJacobian() * vertexPosition + momentumJacobian() * momentum;
163 
164  if (param(2) > M_PI)
165  param(2) -= 2 * M_PI;
166  if (param(2) < -M_PI)
167  param(2) += 2 * M_PI;
168 
169  return param;
170 }
171 
173  if (parameters(2) > M_PI)
174  parameters(2) -= 2 * M_PI;
175  if (parameters(2) < -M_PI)
176  parameters(2) += 2 * M_PI;
177 }
178 
180  GlobalPoint paramPt(theLinPoint);
181 
182  double field = part->currentState().magneticField()->inInverseGeV(thePredState.theState().globalPosition()).z();
183  double signTC = -part->currentState().particleCharge();
184 
185  double thetaAtEP = thePredState.theState().globalMomentum().theta();
186  double phiAtEP = thePredState.theState().globalMomentum().phi();
187  double ptAtEP = thePredState.theState().globalMomentum().perp();
188  double transverseCurvatureAtEP = field / ptAtEP * signTC;
189 
190  double x_v = thePredState.theState().globalPosition().x();
191  double y_v = thePredState.theState().globalPosition().y();
192  double z_v = thePredState.theState().globalPosition().z();
193  double X = x_v - paramPt.x() - sin(phiAtEP) / transverseCurvatureAtEP;
194  double Y = y_v - paramPt.y() + cos(phiAtEP) / transverseCurvatureAtEP;
195  double SS = X * X + Y * Y;
196  double S = sqrt(SS);
197 
198  // The track parameters at the expansion point
199  theExpandedParams[0] = transverseCurvatureAtEP;
200  theExpandedParams[1] = thetaAtEP;
201  theExpandedParams[3] = 1 / transverseCurvatureAtEP - signTC * S;
202 
203  theExpandedParams[5] = part->currentState().mass();
204 
205  double phiFEP;
206  if (std::abs(X) > std::abs(Y)) {
207  double signX = (X > 0.0 ? +1.0 : -1.0);
208  phiFEP = -signTC * signX * acos(signTC * Y / S);
209  } else {
210  phiFEP = asin(-signTC * X / S);
211  if ((signTC * Y) < 0.0)
212  phiFEP = M_PI - phiFEP;
213  }
214  if (phiFEP > M_PI)
215  phiFEP -= 2 * M_PI;
216  theExpandedParams[2] = phiFEP;
217  theExpandedParams[4] =
218  z_v - paramPt.z() - (phiAtEP - theExpandedParams[2]) / tan(thetaAtEP) / transverseCurvatureAtEP;
219 
220  thePositionJacobian(2, 0) = -Y / (SS);
221  thePositionJacobian(2, 1) = X / (SS);
222  thePositionJacobian(3, 0) = -signTC * X / S;
223  thePositionJacobian(3, 1) = -signTC * Y / S;
224  thePositionJacobian(4, 0) = thePositionJacobian(2, 0) / tan(thetaAtEP) / transverseCurvatureAtEP;
225  thePositionJacobian(4, 1) = thePositionJacobian(2, 1) / tan(thetaAtEP) / transverseCurvatureAtEP;
226  thePositionJacobian(4, 2) = 1;
227 
228  //debug code - to be removed later
229  // cout<<"parameters for momentum jacobian: X "<<X<<endl;
230  // cout<<"parameters for momentum jacobian: Y "<<Y<<endl;
231  // cout<<"parameters for momentum jacobian: SS "<<SS<<endl;
232  // cout<<"parameters for momentum jacobian: PhiAtEP "<<phiAtEP<<endl;
233  // cout<<"parameters for momentum jacobian: curv "<<transverseCurvatureAtEP<<endl;
234  // cout<<"sin phi Atep "<<sin(phiAtEP)<<endl;
235  // cout<<"cos phi at EP "<<cos(phiAtEP)<<endl;
236  // cout<<"upper part is "<<X*cos(phiAtEP) + Y*sin(phiAtEP) <<endl;
237  // cout<<"lower part is"<<SS*transverseCurvatureAtEP*transverseCurvatureAtEP<<endl;
238 
239  theMomentumJacobian(0, 0) = 1;
240  theMomentumJacobian(1, 1) = 1;
241 
242  theMomentumJacobian(2, 0) =
243  -(X * cos(phiAtEP) + Y * sin(phiAtEP)) / (SS * transverseCurvatureAtEP * transverseCurvatureAtEP);
244 
245  theMomentumJacobian(2, 2) = (Y * cos(phiAtEP) - X * sin(phiAtEP)) / (SS * transverseCurvatureAtEP);
246 
247  theMomentumJacobian(3, 0) =
248  (signTC * (Y * cos(phiAtEP) - X * sin(phiAtEP)) / S - 1) / (transverseCurvatureAtEP * transverseCurvatureAtEP);
249 
250  theMomentumJacobian(3, 2) = signTC * (X * cos(phiAtEP) + Y * sin(phiAtEP)) / (S * transverseCurvatureAtEP);
251 
252  theMomentumJacobian(4, 0) =
253  (phiAtEP - theExpandedParams(2)) / tan(thetaAtEP) / (transverseCurvatureAtEP * transverseCurvatureAtEP) +
254  theMomentumJacobian(2, 0) / tan(thetaAtEP) / transverseCurvatureAtEP;
255 
256  theMomentumJacobian(4, 1) =
257  (phiAtEP - theExpandedParams(2)) * (1 + 1 / (tan(thetaAtEP) * tan(thetaAtEP))) / transverseCurvatureAtEP;
258 
259  theMomentumJacobian(4, 2) = (theMomentumJacobian(2, 2) - 1) / tan(thetaAtEP) / transverseCurvatureAtEP;
260 
261  theMomentumJacobian(5, 3) = 1;
262 
263  // And finally the residuals:
264  AlgebraicVector3 expansionPoint;
265  expansionPoint[0] = thePredState.theState().globalPosition().x();
266  expansionPoint[1] = thePredState.theState().globalPosition().y();
267  expansionPoint[2] = thePredState.theState().globalPosition().z();
268  AlgebraicVector4 momentumAtExpansionPoint;
269  momentumAtExpansionPoint[0] = transverseCurvatureAtEP; // Transverse Curv
270  momentumAtExpansionPoint[1] = thetaAtEP;
271  momentumAtExpansionPoint[2] = phiAtEP;
272  momentumAtExpansionPoint[3] = theExpandedParams[5];
273 
275  theMomentumJacobian * momentumAtExpansionPoint);
276 }
277 
279  GlobalPoint paramPt(theLinPoint);
280  double thetaAtEP = thePredState.theState().globalMomentum().theta();
281  double phiAtEP = thePredState.theState().globalMomentum().phi();
282  double ptAtEP = thePredState.theState().globalMomentum().perp();
283 
284  double x_v = thePredState.theState().globalPosition().x();
285  double y_v = thePredState.theState().globalPosition().y();
286  double z_v = thePredState.theState().globalPosition().z();
287  double X = x_v - paramPt.x();
288  double Y = y_v - paramPt.y();
289 
290  // The track parameters at the expansion point
291  theExpandedParams[0] = 1 / ptAtEP;
292  theExpandedParams[1] = thetaAtEP;
293  theExpandedParams[2] = phiAtEP;
294  theExpandedParams[3] = X * sin(phiAtEP) - Y * cos(phiAtEP);
295  theExpandedParams[4] = z_v - paramPt.z() - (X * cos(phiAtEP) + Y * sin(phiAtEP)) / tan(thetaAtEP);
296  theExpandedParams[5] = part->currentState().mass();
297 
298  // The Jacobian: (all at the expansion point)
299  // [i,j]
300  // i = 0: rho = 1/pt , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
301  // j = 0: x_v, 1: y_v, 2: z_v
302  thePositionJacobian(3, 0) = sin(phiAtEP);
303  thePositionJacobian(3, 1) = -cos(phiAtEP);
304  thePositionJacobian(4, 0) = -cos(phiAtEP) / tan(thetaAtEP);
305  thePositionJacobian(4, 1) = -sin(phiAtEP) / tan(thetaAtEP);
306  thePositionJacobian(4, 2) = 1;
307 
308  // [i,j]
309  // i = 0: rho = 1/pt , 1: theta, 2: phi_p, 3: epsilon, 4: z_p
310  // j = 0: rho = 1/pt , 1: theta, 2: phi_v
311  theMomentumJacobian(0, 0) = 1;
312  theMomentumJacobian(1, 1) = 1;
313  theMomentumJacobian(2, 2) = 1;
314 
315  theMomentumJacobian(3, 2) = X * cos(phiAtEP) + Y * sin(phiAtEP);
316  theMomentumJacobian(4, 1) = theMomentumJacobian(3, 2) * (1 + 1 / (tan(thetaAtEP) * tan(thetaAtEP)));
317 
318  theMomentumJacobian(4, 2) = (X * sin(phiAtEP) - Y * cos(phiAtEP)) / tan(thetaAtEP);
319  theMomentumJacobian(5, 3) = 1;
320 
321  // And finally the residuals:
322  AlgebraicVector3 expansionPoint;
323  expansionPoint[0] = thePredState.theState().globalPosition().x();
324  expansionPoint[1] = thePredState.theState().globalPosition().y();
325  expansionPoint[2] = thePredState.theState().globalPosition().z();
326  AlgebraicVector4 momentumAtExpansionPoint;
327  momentumAtExpansionPoint[0] = 1 / ptAtEP;
328  momentumAtExpansionPoint[1] = thetaAtEP;
329  momentumAtExpansionPoint[2] = phiAtEP;
330  momentumAtExpansionPoint[3] = theExpandedParams[5];
331 
333  theMomentumJacobian * momentumAtExpansionPoint);
334 }
335 
337  throw VertexException(" ParticleKinematicLinearizedTrackState:: no TransientTrack to return");
338 }
AlgebraicSymMatrix66 predictedStateWeight(int &error) const override
AlgebraicVectorN refittedParamFromEquation(const RefCountedRefittedTrackState &theRefittedState) const override
RefCountedRefittedTrackState createRefittedTrackState(const GlobalPoint &vertexPosition, const AlgebraicVectorM &vectorParameters, const AlgebraicSymMatrix77 &covarianceMatrix) const override
T perp() const
Definition: PV3DBase.h:69
const AlgebraicSymMatrix66 & covarianceMatrix() const
Common base class.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
AlgebraicSymMatrix44 predictedStateMomentumError() const override
T y() const
Definition: PV3DBase.h:60
#define X(str)
Definition: MuonsGrabber.cc:38
bool operator==(LinearizedTrackState< 6 > &other) const override
GlobalVector globalMomentum() const
ROOT::Math::SVector< double, N-2 > AlgebraicVectorM
int lst[30]
ROOT::Math::SMatrix< double, 6, 4, ROOT::Math::MatRepStd< double, 6, 4 > > AlgebraicMatrix64
Definition: Electron.h:6
ROOT::Math::SMatrix< double, 6, 3, ROOT::Math::MatRepStd< double, 6, 3 > > AlgebraicMatrix63
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
int TrackCharge
Definition: TrackCharge.h:4
AlgebraicSymMatrix66 predictedStateError() const override
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
const AlgebraicVector6 & constantTerm() const override
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > AlgebraicSymMatrix44
ReferenceCountingPointer< RefittedTrackState< N > > RefCountedRefittedTrackState
KinematicState kinematicState(const AlgebraicVector4 &momentum, const GlobalPoint &referencePoint, const TrackCharge &charge, const AlgebraicSymMatrix77 &theCovarianceMatrix, const MagneticField *field) const
ROOT::Math::SVector< double, 4 > AlgebraicVector4
const AlgebraicSymMatrix66 & weightMatrix(int &error) const
ReferenceCountingPointer< LinearizedTrackState< 6 > > RefCountedLinearizedTrackState
#define M_PI
const ExtendedPerigeeTrajectoryError & perigeeError() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
const AlgebraicVector6 & parametersFromExpansion() const override
const AlgebraicMatrix63 & positionJacobian() const override
part
Definition: HCALResponse.h:20
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
Definition: Matrices.h:9
AlgebraicVectorM predictedStateMomentumParameters() const override
ROOT::Math::SVector< double, 3 > AlgebraicVector3
ROOT::Math::SVector< double, 6 > AlgebraicVector6
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
const KinematicState & theState() const
const AlgebraicMatrix64 & momentumJacobian() const override
const ExtendedPerigeeTrajectoryParameters & perigeeParameters() const
void checkParameters(AlgebraicVectorN &parameters) const override
ReferenceCountingPointer< LinearizedTrackState< 6 > > stateWithNewLinearizationPoint(const GlobalPoint &newLP) const override
T x() const
Definition: PV3DBase.h:59
GlobalPoint globalPosition() const
std::vector< ReferenceCountingPointer< LinearizedTrackState< 6 > > > components() const override