CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PerigeeConversions.cc
Go to the documentation of this file.
4 #include <cmath>
5 #include <vdt/vdtMath.h>
6 
8  (const FTS& originalFTS, const GlobalPoint& referencePoint, double & pt)
9 
10 {
11  GlobalVector impactDistance = originalFTS.position() - referencePoint;
12 
13  pt = originalFTS.momentum().perp();
14  if (pt==0.) throw cms::Exception("PerigeeConversions", "Track with pt=0");
15 
16  double theta = originalFTS.momentum().theta();
17  double phi = originalFTS.momentum().phi();
18  double field = originalFTS.parameters().magneticFieldInInverseGeV().z();
19 // if (field==0.) throw cms::Exception("PerigeeConversions", "Field is 0") << " at " << originalFTS.position() << "\n" ;
20 
21  double positiveMomentumPhi = ( (phi>0) ? phi : (2*M_PI+phi) );
22  double positionPhi = impactDistance.phi();
23  double positivePositionPhi =
24  ( (positionPhi>0) ? positionPhi : (2*M_PI+positionPhi) );
25  double phiDiff = positiveMomentumPhi - positivePositionPhi;
26  if (phiDiff<0.0) phiDiff+= (2*M_PI);
27  double signEpsilon = ( (phiDiff > M_PI) ? -1.0 : 1.0);
28 
29  double epsilon = signEpsilon *
30  sqrt ( impactDistance.x()*impactDistance.x() +
31  impactDistance.y()*impactDistance.y() );
32 
33  // The track parameters:
34  AlgebraicVector5 theTrackParameters;
35 
36  double signTC = - originalFTS.charge();
37  bool isCharged = (signTC!=0) && (std::abs(field)>1.e-10);
38  if (isCharged) {
39  theTrackParameters[0] = field / pt*signTC;
40  } else {
41  theTrackParameters[0] = 1 / pt;
42  }
43  theTrackParameters[1] = theta;
44  theTrackParameters[2] = phi;
45  theTrackParameters[3] = epsilon;
46  theTrackParameters[4] = impactDistance.z();
47  return PerigeeTrajectoryParameters(theTrackParameters, isCharged);
48 }
49 
50 
52  (const FTS& originalFTS)
53 {
54  AlgebraicSymMatrix55 errorMatrix = originalFTS.curvilinearError().matrix();
55  AlgebraicMatrix55 curv2perigee = jacobianCurvilinear2Perigee(originalFTS);
56  return PerigeeTrajectoryError(ROOT::Math::Similarity(curv2perigee,errorMatrix));
57 }
58 
59 
61  (const PerigeeTrajectoryError& perigeeError, const GlobalTrajectoryParameters& gtp)
62 {
64  return CurvilinearTrajectoryError(ROOT::Math::Similarity(perigee2curv, perigeeError.covarianceMatrix()));
65 }
66 
68  (const PerigeeTrajectoryParameters& parameters, const GlobalPoint& referencePoint)
69 {
70  AlgebraicVector5 theVector = parameters.vector();
71  return GlobalPoint(theVector[3]*vdt::fast_sin(theVector[2])+referencePoint.x(),
72  -theVector[3]*vdt::fast_cos(theVector[2])+referencePoint.y(),
73  theVector[4]+referencePoint.z());
74 }
75 
76 
78  (const PerigeeTrajectoryParameters& parameters, double pt, const GlobalPoint& referencePoint)
79 {
80  return GlobalVector(vdt::fast_cos(parameters.phi()) * pt,
81  vdt::fast_sin(parameters.phi()) * pt,
82  pt /vdt::fast_tan(parameters.theta()));
83 }
84 
85 
87  (const AlgebraicVector3& momentum, const TrackCharge& charge,
88  const GlobalPoint& referencePoint, const MagneticField* field)
89 {
90  double pt;
91 
92  double bz = fabs(field->inInverseGeV(referencePoint).z());
93  if ( charge!=0 && std::abs(bz)>1.e-10 ) {
94  pt = std::abs(bz/momentum[0]);
95  // if (pt<1.e-10) throw cms::Exception("PerigeeConversions", "pt is 0");
96  } else {
97  pt = 1 / momentum[0];
98  }
99 
100  return GlobalVector(vdt::fast_cos(momentum[2]) * pt,
101  vdt::fast_sin(momentum[2]) * pt,
102  pt/vdt::fast_tan(momentum[1]));
103 }
104 
105 
107  (const AlgebraicVector3& momentum, const GlobalPoint& referencePoint,
108  const TrackCharge& charge, const AlgebraicSymMatrix66& theCovarianceMatrix,
109  const MagneticField* field)
110 {
112  (momentum, referencePoint, charge, field);
113  CartesianTrajectoryError cartesianTrajErr(ROOT::Math::Similarity(param2cart, theCovarianceMatrix));
114 
115  FTS theFTS(GlobalTrajectoryParameters(referencePoint,
116  momentumFromPerigee(momentum, charge, referencePoint, field), charge,
117  field), cartesianTrajErr);
118 
119  return TrajectoryStateClosestToPoint(theFTS, referencePoint);
120 }
121 
122 
125  const AlgebraicVector3& momentum, const GlobalPoint& position,
126  const TrackCharge& charge, const MagneticField* field)
127 {
128  float factor = -1.;
129  float bField = field->inInverseGeV(position).z();
130  if (charge!=0 && std::abs(bField)>1.e-10f)
131  factor = bField*charge;
132 
133 
134  float s1,c1; vdt::fast_sincosf(momentum[1],s1,c1);
135  float s2,c2; vdt::fast_sincosf(momentum[2],s2,c2);
136  float f1 = factor/(momentum[0]*momentum[0]);
137  float f2 = factor/momentum[0];
138 
139  AlgebraicMatrix66 frameTransJ;
140  frameTransJ(0,0) = 1;
141  frameTransJ(1,1) = 1;
142  frameTransJ(2,2) = 1;
143  frameTransJ(3,3) = (f1 * c2);
144  frameTransJ(4,3) = (f1 * s2);
145  frameTransJ(5,3) = (f1*c1/s1);
146 
147  frameTransJ(3,5) = (f2 * s2);
148  frameTransJ(4,5) = -(f2 * c2);
149  frameTransJ(5,4) = (f2/(s1*s1));
150 
151  return frameTransJ;
152 }
153 
154 
157 
158  GlobalVector p = fts.momentum();
159 
160  GlobalVector Z = GlobalVector(0.,0.,1.);
161  GlobalVector T = p.unit();
162  GlobalVector U = Z.cross(T).unit();;
163  GlobalVector V = T.cross(U);
164 
165  GlobalVector I = GlobalVector(-p.x(), -p.y(), 0.); //opposite to track dir.
166  I = I.unit();
167  GlobalVector J(-I.y(), I.x(),0.); //counterclockwise rotation
168  GlobalVector K(Z);
170  GlobalVector H = B.unit();
171  GlobalVector HxT = H.cross(T);
172  GlobalVector N = HxT.unit();
173  double alpha = HxT.mag();
174  double qbp = fts.signedInverseMomentum();
175  double Q = -B.mag() * qbp;
176  double alphaQ = alpha * Q;
177 
178  double lambda = 0.5 * M_PI - p.theta();
179  double sinlambda, coslambda; vdt::fast_sincos(lambda, sinlambda, coslambda);
180  double seclambda = 1./coslambda;
181 
182  double ITI = 1./T.dot(I);
183  double NU = N.dot(U);
184  double NV = N.dot(V);
185  double UI = U.dot(I);
186  double VI = V.dot(I);
187  double UJ = U.dot(J);
188  double VJ = V.dot(J);
189  double UK = U.dot(K);
190  double VK = V.dot(K);
191 
192  AlgebraicMatrix55 jac;
193 
194  if( fabs(fts.transverseCurvature())<1.e-10 ) {
195  jac(0,0) = seclambda;
196  jac(0,1) = sinlambda*seclambda*seclambda*std::abs(qbp);
197  }else{
198  double Bz = B.z();
199  jac(0,0) = -Bz * seclambda;
200  jac(0,1) = -Bz * sinlambda*seclambda*seclambda*qbp;
201  jac(1,3) = alphaQ * NV * UI*ITI;
202  jac(1,4) = alphaQ * NV * VI*ITI;
203  jac(0,3) = -jac(0,1) * jac(1,3);
204  jac(0,4) = -jac(0,1) * jac(1,4);
205  jac(2,3) = -alphaQ*seclambda * NU * UI*ITI;
206  jac(2,4) = -alphaQ*seclambda * NU * VI*ITI;
207  }
208  jac(1,1) = -1.;
209  jac(2,2) = 1.;
210  jac(3,3) = VK*ITI;
211  jac(3,4) = -UK*ITI;
212  jac(4,3) = -VJ*ITI;
213  jac(4,4) = UJ*ITI;
214 
215  return jac;
216 
217 }
218 
219 
220 
223 
224  GlobalVector p = gtp.momentum();
225 
226  GlobalVector Z = GlobalVector(0.f,0.f,1.f);
227  GlobalVector T = p.unit();
228  GlobalVector U = Z.cross(T).unit();;
229  GlobalVector V = T.cross(U);
230 
231  GlobalVector I = GlobalVector(-p.x(), -p.y(), 0.f); //opposite to track dir.
232  I = I.unit();
233  GlobalVector J(-I.y(), I.x(),0.f); //counterclockwise rotation
234  GlobalVector K(Z);
236  GlobalVector H = B.unit();
237  GlobalVector HxT = H.cross(T);
238  GlobalVector N = HxT.unit();
239  double alpha = HxT.mag();
240  double qbp = gtp.signedInverseMomentum();
241  double Q = -B.mag() * qbp;
242  double alphaQ = alpha * Q;
243 
244 
245  double lambda = 0.5 * M_PI - p.theta();
246  double sinlambda, coslambda; vdt::fast_sincos(lambda, sinlambda, coslambda);
247  double seclambda = 1./coslambda;
248 
249  double mqbpt = -1./coslambda * qbp;
250 
251  double TJ = T.dot(J);
252  double TK = T.dot(K);
253  double NU = N.dot(U);
254  double NV = N.dot(V);
255  double UJ = U.dot(J);
256  double VJ = V.dot(J);
257  double UK = U.dot(K);
258  double VK = V.dot(K);
259 
260  AlgebraicMatrix55 jac;
261 
262  if( fabs(gtp.transverseCurvature())<1.e-10f ) {
263  jac(0,0) = coslambda;
264  jac(0,1) = sinlambda/coslambda/gtp.momentum().mag();
265  }else{
266  jac(0,0) = -coslambda/B.z();
267  jac(0,1) = -sinlambda * mqbpt;
268  jac(1,3) = -alphaQ * NV * TJ;
269  jac(1,4) = -alphaQ * NV * TK;
270  jac(2,3) = -alphaQ*seclambda * NU * TJ;
271  jac(2,4) = -alphaQ*seclambda * NU * TK;
272  }
273  jac(1,1) = -1.;
274  jac(2,2) = 1.;
275  jac(3,3) = UJ;
276  jac(3,4) = UK;
277  jac(4,3) = VJ;
278  jac(4,4) = VK;
279 
280  return jac;
281 }
282 
const double Z[kNumberCalorimeter]
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const AlgebraicVector3 &momentum, const GlobalPoint &referencePoint, const TrackCharge &charge, const AlgebraicSymMatrix66 &theCovarianceMatrix, const MagneticField *field)
const AlgebraicVector5 & vector() const
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt)
float alpha
Definition: AMPTWrapper.h:95
T perp() const
Definition: PV3DBase.h:72
const GlobalTrajectoryParameters & parameters() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepStd< double, 6, 6 > > AlgebraicMatrix66
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrackCharge charge() const
GlobalVector magneticFieldInInverseGeV(const GlobalPoint &x) const
const CurvilinearTrajectoryError & curvilinearError() const
tuple s2
Definition: indexGen.py:106
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
int TrackCharge
Definition: TrackCharge.h:4
GlobalVector inInverseGeV(const GlobalPoint &gp) const
Field value ad specified global point, in 1/Gev.
Definition: MagneticField.h:39
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:18
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
AlgebraicMatrix66 jacobianParameters2Cartesian(const AlgebraicVector3 &momentum, const GlobalPoint &position, const TrackCharge &charge, const MagneticField *field)
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::complex< double > I
Definition: I.h:8
double f[11][100]
AlgebraicMatrix55 jacobianPerigee2Curvilinear(const GlobalTrajectoryParameters &gtp)
GlobalVector momentum() const
const AlgebraicSymMatrix55 & covarianceMatrix() const
#define M_PI
Vector3DBase unit() const
Definition: Vector3DBase.h:57
GlobalPoint position() const
GlobalPoint positionFromPerigee(const PerigeeTrajectoryParameters &parameters, const GlobalPoint &referencePoint)
GlobalVector momentumFromPerigee(const AlgebraicVector3 &momentum, const TrackCharge &charge, const GlobalPoint &referencePoint, const MagneticField *field)
#define N
Definition: blowfish.cc:9
ROOT::Math::SVector< double, 5 > AlgebraicVector5
CurvilinearTrajectoryError curvilinearError(const PerigeeTrajectoryError &perigeeError, const GlobalTrajectoryParameters &gtp)
AlgebraicMatrix55 jacobianCurvilinear2Perigee(const FreeTrajectoryState &fts)
double transverseCurvature() const
Geom::Phi< T > phi() const
const AlgebraicSymMatrix55 & matrix() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
long double T
T x() const
Definition: PV3DBase.h:62
double signedInverseMomentum() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
Global3DVector GlobalVector
Definition: GlobalVector.h:10