CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GhostTrackPrediction.cc
Go to the documentation of this file.
1 #include <cmath>
2 
3 #include <Math/SMatrix.h>
4 #include <Math/MatrixFunctions.h>
5 
10 
14 
16 
17 using namespace reco;
18 
19 namespace {
20 #ifndef __clang__
21  inline double sqr(double arg) { return arg * arg; }
22 #endif
23  typedef ROOT::Math::SMatrix<double, 3, 4> Matrix34;
24  typedef ROOT::Math::SMatrix<double, 4, 5> Matrix45;
25  typedef ROOT::Math::SMatrix<double, 5, 4> Matrix54;
26  typedef ROOT::Math::SMatrix<double, 4, 6> Matrix46;
27  typedef ROOT::Math::SMatrix<double, 6, 4> Matrix64;
28  typedef ROOT::Math::SMatrix<double, 6, 6, ROOT::Math::MatRepSym<double, 6> > Matrix6S;
29 
31  return GhostTrackPrediction::Vector(trajectory.yT() / std::cos(trajectory.lambda()),
32  trajectory.xT(),
33  std::tan(trajectory.lambda()),
34  trajectory.phi());
35  }
36 
38  return convert(CurvilinearTrajectoryParameters(trajectory.position(), trajectory.momentum(), 0));
39  }
40 
43  double rho2 = pred[2] * pred[2] + 1.;
44  double rho = std::sqrt(rho2);
45 
46  Matrix45 jacobian;
47  jacobian(0, 1) = pred[0] * pred[2];
48  jacobian(0, 4) = rho;
49  jacobian(1, 3) = 1.;
50  jacobian(2, 1) = rho2;
51  jacobian(3, 2) = 1.;
52 
53  return ROOT::Math::Similarity(jacobian, error.matrix());
54  }
55 
56 } // namespace
57 
58 void GhostTrackPrediction::init(const GlobalPoint &priorPosition,
59  const GlobalError &priorError,
60  const GlobalVector &direction,
61  const GlobalError &directionError) {
62  double perp2 = direction.perp2();
63  GlobalVector dir = direction / std::sqrt(perp2);
64  double tip = priorPosition.y() * dir.x() - priorPosition.x() * dir.y();
65  double l = priorPosition.x() * dir.x() + priorPosition.y() * dir.y();
66 
67  prediction_[0] = priorPosition.z() - dir.z() * l;
68  prediction_[1] = tip;
69  prediction_[2] = dir.z();
70  prediction_[3] = dir.phi();
71 
72  Matrix46 jacobian;
73  jacobian(0, 0) = -dir.x() * dir.z();
74  jacobian(1, 0) = -dir.y();
75  jacobian(0, 1) = -dir.y() * dir.z();
76  jacobian(1, 1) = dir.x();
77  jacobian(0, 2) = 1.;
78  jacobian(0, 3) = -dir.z() * priorPosition.x();
79  jacobian(1, 3) = priorPosition.y();
80  jacobian(3, 3) = -dir.y();
81  jacobian(0, 4) = -dir.z() * priorPosition.y();
82  jacobian(1, 4) = -priorPosition.x();
83  jacobian(3, 4) = dir.x();
84  jacobian(0, 5) = -l;
85  jacobian(2, 5) = 1.;
86 
87  Matrix6S origCov;
88  origCov.Place_at(priorError.matrix(), 0, 0);
89  origCov.Place_at(directionError.matrix() / perp2, 3, 3);
90 
91  covariance_ = ROOT::Math::Similarity(jacobian, origCov);
92 }
93 
95  const GlobalError &priorError,
96  const GlobalVector &direction,
97  double coneRadius) {
98  double dTheta = std::cosh((double)direction.eta()) * coneRadius;
99 
100  double r2 = direction.mag2();
101  double r = std::sqrt(r2);
102  double perp = direction.perp();
103  double P = direction.x() / perp;
104  double p = direction.y() / perp;
105  double T = direction.z() / r;
106  double t = perp / r;
107  double h2 = dTheta * dTheta;
108  double d2 = coneRadius * coneRadius;
109 
110  GlobalError cov(r2 * (T * T * P * P * h2 + t * t * p * p * d2),
111  r2 * p * P * (T * T * h2 - t * t * d2),
112  r2 * (T * T * p * p * h2 + t * t * P * P * d2),
113  -r2 * t * T * P * h2,
114  -r2 * t * T * p * h2,
115  r2 * t * t * h2);
116 
117  init(priorPosition, priorError, direction, cov);
118 }
119 
122  : prediction_(convert(trajectory)), covariance_(convert(prediction_, error)) {}
123 
125  : prediction_(convert(GlobalTrajectoryParameters(GlobalPoint(track.vx(), track.vy(), track.vz()),
126  GlobalVector(track.px(), track.py(), track.pz()),
127  0,
128  nullptr))),
129  covariance_(convert(prediction_, track.covariance())) {}
130 
132  double x = std::cos(phi());
133  double y = std::sin(phi());
134 
135  Matrix34 jacobian;
136  jacobian(0, 1) = -y;
137  jacobian(0, 3) = -y * lambda - x * ip();
138  jacobian(1, 1) = x;
139  jacobian(1, 3) = x * lambda - y * ip();
140  jacobian(2, 0) = 1.;
141  jacobian(2, 2) = lambda;
142 
143  return ROOT::Math::Similarity(jacobian, covariance());
144 }
145 
146 Matrix6S GhostTrackPrediction::cartesianError(double lambda) const {
147  double x = std::cos(phi());
148  double y = std::sin(phi());
149 
150  Matrix64 jacobian;
151  jacobian(0, 1) = -y;
152  jacobian(0, 3) = -y * lambda - x * ip();
153  jacobian(1, 1) = x;
154  jacobian(1, 3) = x * lambda - y * ip();
155  jacobian(2, 0) = 1.;
156  jacobian(2, 2) = lambda;
157  jacobian(3, 3) = -y;
158  jacobian(4, 3) = x;
159  jacobian(5, 2) = 1.;
160 
161  return ROOT::Math::Similarity(jacobian, covariance());
162 }
163 
165  return GlobalTrajectoryParameters(origin(), direction(), 0, fieldProvider);
166 }
167 
169  double rho2I = 1. / rho2();
170  double rhoI = std::sqrt(rho2I);
171 
172  Matrix54 jacobian;
173  jacobian(1, 2) = rho2I;
174  jacobian(2, 3) = 1.;
175  jacobian(3, 1) = 1.;
176  jacobian(4, 0) = rhoI;
177  jacobian(4, 2) = -z() * rhoI * cotTheta() * rho2I;
178 
179  AlgebraicSymMatrix55 err = Similarity(jacobian, covariance());
180  err(0, 0) = 1.;
181 
182  return CurvilinearTrajectoryError(err);
183 }
184 
186  return FreeTrajectoryState(globalTrajectory(fieldProvider), curvilinearError());
187 }
188 
190  GlobalPoint origin = this->origin();
191  GlobalVector dir = direction().unit();
192 
193  Track::Point point(origin.x(), origin.y(), origin.z());
194  Track::Vector vector(dir.x(), dir.y(), dir.z());
195 
196  return Track(chi2, ndof, point, vector, 0, curvilinearError());
197 }
const GlobalPoint origin() const
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > Error
double lambda(const GlobalPoint &point) const
const AlgebraicSymMatrix33 matrix() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
FreeTrajectoryState fts(const MagneticField *fieldProvider) const
int sqr(const T &t)
A arg
Definition: Factorize.h:31
GlobalTrajectoryParameters globalTrajectory(const MagneticField *fieldProvider) const
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void init(const GlobalPoint &priorPosition, const GlobalError &priorError, const GlobalVector &direction, const GlobalError &directionError)
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
math::XYZPoint Point
point in the space
Definition: TrackBase.h:80
CurvilinearTrajectoryError curvilinearError() const
CartesianError cartesianError(double lambda=0.) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
Definition: Vector3D.h:28
Track track(double ndof=0., double chi2=0.) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
T perp2() const
Squared magnitude of transverse component.
std::pair< OmniClusterRef, TrackingParticleRef > P
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
Definition: Point3D.h:18
T perp() const
Magnitude of transverse component.
const Error & covariance() const
const AlgebraicSymMatrix55 & matrix() const
long double T
ROOT::Math::SVector< double, 4 > Vector
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:77
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
GlobalError positionError(double lambda=0.) const
const GlobalVector direction() const