CMS 3D CMS Logo

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