CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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  inline double sqr(double arg) { return arg * arg; }
21 
22  typedef ROOT::Math::SMatrix<double, 3, 4> Matrix34;
23  typedef ROOT::Math::SMatrix<double, 4, 5> Matrix45;
24  typedef ROOT::Math::SMatrix<double, 5, 4> Matrix54;
25  typedef ROOT::Math::SMatrix<double, 4, 6> Matrix46;
26  typedef ROOT::Math::SMatrix<double, 6, 4> Matrix64;
27  typedef ROOT::Math::SMatrix<double, 6, 6, ROOT::Math::MatRepSym<double, 6> > Matrix6S;
28 
29  inline
32  trajectory.yT() / std::cos(trajectory.lambda()),
33  trajectory.xT(),
34  std::tan(trajectory.lambda()),
35  trajectory.phi());
36  }
37 
38 
39  inline
41  return convert(CurvilinearTrajectoryParameters(trajectory.position(), trajectory.momentum(), 0));
42  }
43 
44 
45  inline
47  const GhostTrackPrediction::Vector &pred,
49 
50  double rho2 = pred[2] * pred[2] + 1.;
51  double rho = std::sqrt(rho2);
52 
53  Matrix45 jacobian;
54  jacobian(0, 1) = pred[0] * pred[2];
55  jacobian(0, 4) = rho;
56  jacobian(1, 3) = 1.;
57  jacobian(2, 1) = rho2;
58  jacobian(3, 2) = 1.;
59 
60  return ROOT::Math::Similarity(jacobian, error.matrix());
61  }
62 
63 }
64 
66  const GlobalPoint &priorPosition,
67  const GlobalError &priorError,
68  const GlobalVector &direction,
69  const GlobalError &directionError)
70 {
71 
72  double perp2 = direction.perp2();
73  GlobalVector dir = direction / std::sqrt(perp2);
74  double tip = priorPosition.y() * dir.x() - priorPosition.x() * dir.y();
75  double l = priorPosition.x() * dir.x() + priorPosition.y() * dir.y();
76 
77  prediction_[0] = priorPosition.z() - dir.z() * l;
78  prediction_[1] = tip;
79  prediction_[2] = dir.z();
80  prediction_[3] = dir.phi();
81 
82  Matrix46 jacobian;
83  jacobian(0, 0) = -dir.x() * dir.z();
84  jacobian(1, 0) = -dir.y();
85  jacobian(0, 1) = -dir.y() * dir.z();
86  jacobian(1, 1) = dir.x();
87  jacobian(0, 2) = 1.;
88  jacobian(0, 3) = -dir.z() * priorPosition.x();
89  jacobian(1, 3) = priorPosition.y();
90  jacobian(3, 3) = -dir.y();
91  jacobian(0, 4) = -dir.z() * priorPosition.y();
92  jacobian(1, 4) = -priorPosition.x();
93  jacobian(3, 4) = dir.x();
94  jacobian(0, 5) = -l;
95  jacobian(2, 5) = 1.;
96 
97  Matrix6S origCov;
98  origCov.Place_at(priorError.matrix_new(), 0, 0);
99  origCov.Place_at(directionError.matrix_new() / perp2, 3, 3);
100 
101  covariance_ = ROOT::Math::Similarity(jacobian, origCov);
102 }
103 
105  const GlobalPoint &priorPosition,
106  const GlobalError &priorError,
107  const GlobalVector &direction,
108  double coneRadius)
109 {
110  double dTheta = std::cosh((double)direction.eta()) * coneRadius;
111 
112  double r2 = direction.mag2();
113  double r = std::sqrt(r2);
114  double perp = direction.perp();
115  double P = direction.x() / perp;
116  double p = direction.y() / perp;
117  double T = direction.z() / r;
118  double t = perp / r;
119  double h2 = dTheta * dTheta;
120  double d2 = coneRadius * coneRadius;
121 
122  GlobalError cov(r2 * (T*T * P*P * h2 + t*t * p*p * d2),
123  r2 * p*P * (T*T * h2 - t*t * d2),
124  r2 * (T*T * p*p * h2 + t*t * P*P * d2),
125  -r2 * t*T * P * h2,
126  -r2 * t*T * p * h2,
127  r2 * t*t * h2);
128 
129  init(priorPosition, priorError, direction, cov);
130 }
131 
132 
134  const GlobalTrajectoryParameters &trajectory,
136  prediction_(convert(trajectory)),
137  covariance_(convert(prediction_, error))
138 {
139 }
140 
142  prediction_(convert(
144  GlobalPoint(track.vx(), track.vy(), track.vz()),
145  GlobalVector(track.px(), track.py(), track.pz()),
146  0, 0))),
147  covariance_(convert(prediction_, track.covariance()))
148 {
149 }
150 
152 {
153  double x = std::cos(phi());
154  double y = std::sin(phi());
155 
156  Matrix34 jacobian;
157  jacobian(0, 1) = -y;
158  jacobian(0, 3) = -y * lambda - x * ip();
159  jacobian(1, 1) = x;
160  jacobian(1, 3) = x * lambda - y * ip();
161  jacobian(2, 0) = 1.;
162  jacobian(2, 2) = lambda;
163 
164  return ROOT::Math::Similarity(jacobian, covariance());
165 }
166 
167 Matrix6S GhostTrackPrediction::cartesianError(double lambda) const
168 {
169  double x = std::cos(phi());
170  double y = std::sin(phi());
171 
172  Matrix64 jacobian;
173  jacobian(0, 1) = -y;
174  jacobian(0, 3) = -y * lambda - x * ip();
175  jacobian(1, 1) = x;
176  jacobian(1, 3) = x * lambda - y * ip();
177  jacobian(2, 0) = 1.;
178  jacobian(2, 2) = lambda;
179  jacobian(3, 3) = -y;
180  jacobian(4, 3) = x;
181  jacobian(5, 2) = 1.;
182 
183  return ROOT::Math::Similarity(jacobian, covariance());
184 }
185 
186 
189  0, fieldProvider);
190 }
191 
193 {
194  double rho2I = 1. / rho2();
195  double rhoI = std::sqrt(rho2I);
196 
197  Matrix54 jacobian;
198  jacobian(1, 2) = rho2I;
199  jacobian(2, 3) = 1.;
200  jacobian(3, 1) = 1.;
201  jacobian(4, 0) = rhoI;
202  jacobian(4, 2) = - z() * rhoI * cotTheta() * rho2I;
203 
204  AlgebraicSymMatrix55 err = Similarity(jacobian, covariance());
205  err(0, 0) = 1.;
206 
207  return CurvilinearTrajectoryError(err);
208 }
209 
211 {
212  return FreeTrajectoryState(globalTrajectory(fieldProvider),
213  curvilinearError());
214 }
215 
216 Track GhostTrackPrediction::track(double ndof, double chi2) const
217 {
218  GlobalPoint origin = this->origin();
219  GlobalVector dir = direction().unit();
220 
221  Track::Point point(origin.x(), origin.y(), origin.z());
222  Track::Vector vector(dir.x(), dir.y(), dir.z());
223 
224  return Track(chi2, ndof, point, vector, 0, curvilinearError());
225 }
const GlobalPoint origin() const
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > Error
double lambda(const GlobalPoint &point) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Definition: DDAxes.h:10
FreeTrajectoryState fts(const MagneticField *fieldProvider) const
#define P
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
A arg
Definition: Factorize.h:36
void convert(uint32 i, char_uint32 v)
Definition: MsgTools.h:46
const AlgebraicSymMatrix33 & matrix_new() const
GlobalTrajectoryParameters globalTrajectory(const MagneticField *fieldProvider) const
T sqrt(T t)
Definition: SSEVec.h:48
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:74
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:27
Track track(double ndof=0., double chi2=0.) const
T perp2() const
Squared magnitude of transverse component.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
Definition: Point3D.h:17
T perp() const
Magnitude of transverse component.
const Error & covariance() const
const AlgebraicSymMatrix55 & matrix() const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
dbl *** dir
Definition: mlp_gen.cc:35
Definition: DDAxes.h:10
long double T
ROOT::Math::SVector< double, 4 > Vector
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:72
*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