CMS 3D CMS Logo

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 
30  inline
33  trajectory.yT() / std::cos(trajectory.lambda()),
34  trajectory.xT(),
35  std::tan(trajectory.lambda()),
36  trajectory.phi());
37  }
38 
39 
40  inline
42  return convert(CurvilinearTrajectoryParameters(trajectory.position(), trajectory.momentum(), 0));
43  }
44 
45 
46  inline
48  const GhostTrackPrediction::Vector &pred,
50 
51  double rho2 = pred[2] * pred[2] + 1.;
52  double rho = std::sqrt(rho2);
53 
54  Matrix45 jacobian;
55  jacobian(0, 1) = pred[0] * pred[2];
56  jacobian(0, 4) = rho;
57  jacobian(1, 3) = 1.;
58  jacobian(2, 1) = rho2;
59  jacobian(3, 2) = 1.;
60 
61  return ROOT::Math::Similarity(jacobian, error.matrix());
62  }
63 
64 }
65 
67  const GlobalPoint &priorPosition,
68  const GlobalError &priorError,
69  const GlobalVector &direction,
70  const GlobalError &directionError)
71 {
72 
73  double perp2 = direction.perp2();
74  GlobalVector dir = direction / std::sqrt(perp2);
75  double tip = priorPosition.y() * dir.x() - priorPosition.x() * dir.y();
76  double l = priorPosition.x() * dir.x() + priorPosition.y() * dir.y();
77 
78  prediction_[0] = priorPosition.z() - dir.z() * l;
79  prediction_[1] = tip;
80  prediction_[2] = dir.z();
81  prediction_[3] = dir.phi();
82 
83  Matrix46 jacobian;
84  jacobian(0, 0) = -dir.x() * dir.z();
85  jacobian(1, 0) = -dir.y();
86  jacobian(0, 1) = -dir.y() * dir.z();
87  jacobian(1, 1) = dir.x();
88  jacobian(0, 2) = 1.;
89  jacobian(0, 3) = -dir.z() * priorPosition.x();
90  jacobian(1, 3) = priorPosition.y();
91  jacobian(3, 3) = -dir.y();
92  jacobian(0, 4) = -dir.z() * priorPosition.y();
93  jacobian(1, 4) = -priorPosition.x();
94  jacobian(3, 4) = dir.x();
95  jacobian(0, 5) = -l;
96  jacobian(2, 5) = 1.;
97 
98  Matrix6S origCov;
99  origCov.Place_at(priorError.matrix(), 0, 0);
100  origCov.Place_at(directionError.matrix() / perp2, 3, 3);
101 
102  covariance_ = ROOT::Math::Similarity(jacobian, origCov);
103 }
104 
106  const GlobalPoint &priorPosition,
107  const GlobalError &priorError,
108  const GlobalVector &direction,
109  double coneRadius)
110 {
111  double dTheta = std::cosh((double)direction.eta()) * coneRadius;
112 
113  double r2 = direction.mag2();
114  double r = std::sqrt(r2);
115  double perp = direction.perp();
116  double P = direction.x() / perp;
117  double p = direction.y() / perp;
118  double T = direction.z() / r;
119  double t = perp / r;
120  double h2 = dTheta * dTheta;
121  double d2 = coneRadius * coneRadius;
122 
123  GlobalError cov(r2 * (T*T * P*P * h2 + t*t * p*p * d2),
124  r2 * p*P * (T*T * h2 - t*t * d2),
125  r2 * (T*T * p*p * h2 + t*t * P*P * d2),
126  -r2 * t*T * P * h2,
127  -r2 * t*T * p * h2,
128  r2 * t*t * h2);
129 
130  init(priorPosition, priorError, direction, cov);
131 }
132 
133 
135  const GlobalTrajectoryParameters &trajectory,
137  prediction_(convert(trajectory)),
139 {
140 }
141 
145  GlobalPoint(track.vx(), track.vy(), track.vz()),
146  GlobalVector(track.px(), track.py(), track.pz()),
147  0, 0))),
149 {
150 }
151 
153 {
154  double x = std::cos(phi());
155  double y = std::sin(phi());
156 
157  Matrix34 jacobian;
158  jacobian(0, 1) = -y;
159  jacobian(0, 3) = -y * lambda - x * ip();
160  jacobian(1, 1) = x;
161  jacobian(1, 3) = x * lambda - y * ip();
162  jacobian(2, 0) = 1.;
163  jacobian(2, 2) = lambda;
164 
165  return ROOT::Math::Similarity(jacobian, covariance());
166 }
167 
169 {
170  double x = std::cos(phi());
171  double y = std::sin(phi());
172 
173  Matrix64 jacobian;
174  jacobian(0, 1) = -y;
175  jacobian(0, 3) = -y * lambda - x * ip();
176  jacobian(1, 1) = x;
177  jacobian(1, 3) = x * lambda - y * ip();
178  jacobian(2, 0) = 1.;
179  jacobian(2, 2) = lambda;
180  jacobian(3, 3) = -y;
181  jacobian(4, 3) = x;
182  jacobian(5, 2) = 1.;
183 
184  return ROOT::Math::Similarity(jacobian, covariance());
185 }
186 
187 
190  0, fieldProvider);
191 }
192 
194 {
195  double rho2I = 1. / rho2();
196  double rhoI = std::sqrt(rho2I);
197 
198  Matrix54 jacobian;
199  jacobian(1, 2) = rho2I;
200  jacobian(2, 3) = 1.;
201  jacobian(3, 1) = 1.;
202  jacobian(4, 0) = rhoI;
203  jacobian(4, 2) = - z() * rhoI * cotTheta() * rho2I;
204 
205  AlgebraicSymMatrix55 err = Similarity(jacobian, covariance());
206  err(0, 0) = 1.;
207 
208  return CurvilinearTrajectoryError(err);
209 }
210 
212 {
213  return FreeTrajectoryState(globalTrajectory(fieldProvider),
214  curvilinearError());
215 }
216 
218 {
219  GlobalPoint origin = this->origin();
220  GlobalVector dir = direction().unit();
221 
222  Track::Point point(origin.x(), origin.y(), origin.z());
223  Track::Vector vector(dir.x(), dir.y(), dir.z());
224 
225  return Track(chi2, ndof, point, vector, 0, curvilinearError());
226 }
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
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
A arg
Definition: Factorize.h:36
T x() const
Cartesian x coordinate.
GlobalTrajectoryParameters globalTrajectory(const MagneticField *fieldProvider) const
T sqrt(T t)
Definition: SSEVec.h:18
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:83
CurvilinearTrajectoryError curvilinearError() const
CartesianError cartesianError(double lambda=0.) const
def convert(infile, ofile)
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.
std::pair< OmniClusterRef, TrackingParticleRef > P
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.
fixed size matrix
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
long double T
ROOT::Math::SVector< double, 4 > Vector
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:80
*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