CMS 3D CMS Logo

TrackGhostTrackState.cc
Go to the documentation of this file.
1 #include <cmath>
2 
3 #include <Math/SMatrix.h>
4 #include <Math/MatrixFunctions.h>
5 
9 
15 
17 
19 
20 using namespace reco;
21 
22 namespace {
23  inline double sqr(double arg) { return arg * arg; }
24 
25  using namespace ROOT::Math;
26 
27  typedef SVector<double, 3> Vector3;
28 
29  typedef SMatrix<double, 3, 3, MatRepSym<double, 3> > Matrix3S;
30  typedef SMatrix<double, 6, 6, MatRepSym<double, 6> > Matrix6S;
31  typedef SMatrix<double, 3, 3> Matrix33;
32  typedef SMatrix<double, 3, 6> Matrix36;
33 
34  inline Vector3 conv(const GlobalVector &vec) {
35  Vector3 result;
36  result[0] = vec.x();
37  result[1] = vec.y();
38  result[2] = vec.z();
39  return result;
40  }
41 } // namespace
42 
43 bool TrackGhostTrackState::linearize(const GhostTrackPrediction &pred, bool initial, double lambda) {
45 
46  GlobalPoint origin = pred.origin();
47  GlobalVector direction = pred.direction();
48 
49  if (isValid() && !initial) {
50  GlobalPoint pca = origin + lambda_ * direction;
51  Line line(pca, direction);
52  tsos_ = extrap.extrapolate(tsos_, line);
53  } else {
54  GlobalPoint pca = origin + lambda * direction;
55  Line line(pca, direction);
56  tsos_ = extrap.extrapolate(track_.impactPointState(), line);
57  }
58 
59  if (!isValid())
60  return false;
61 
62  lambda_ = (tsos_.globalPosition() - origin) * direction / pred.rho2();
63 
64  return true;
65 }
66 
67 bool TrackGhostTrackState::linearize(const GhostTrackPrediction &pred, double lambda) {
69 
71 
72  tsos_ = extrap.extrapolate(track_.impactPointState(), point);
73  if (!isValid())
74  return false;
75 
76  lambda_ = lambda;
77 
78  return true;
79 }
80 
82  bool withMeasurementError) const {
83  using namespace ROOT::Math;
84 
85  if (!isValid())
86  return Vertex();
87 
88  GlobalPoint origin = pred.origin();
89  GlobalVector direction = pred.direction();
90 
91  double rho2 = pred.rho2();
92  double rho = std::sqrt(rho2);
93  double lambda = (tsos_.globalPosition() - origin) * direction / rho2;
94  GlobalPoint pos = origin + lambda * direction;
95 
96  GlobalVector momentum = tsos_.globalMomentum();
97  double mom = momentum.mag();
98 
99  Vector3 b = conv(direction) / rho;
100  Vector3 d = conv(momentum) / mom;
101  double l = Dot(b, d);
102  double g = 1. / (1. - sqr(l));
103 
104  Vector3 ca = conv(pos - tsos_.globalPosition());
105  Vector3 bd = b - l * d;
106  b *= g;
107 
108  Matrix33 pA = TensorProd(b, bd);
109  Matrix33 pB = TensorProd(b, ca);
110 
111  Matrix36 jacobian;
112  jacobian.Place_at(-pA + Matrix33(SMatrixIdentity()), 0, 0);
113  jacobian.Place_at(pB / rho, 0, 3);
114  Matrix3S error = Similarity(jacobian, pred.cartesianError(lambda));
115 
116  if (withMeasurementError) {
117  jacobian.Place_at(pA, 0, 0);
118  jacobian.Place_at(-pB / mom, 0, 3);
119  error += Similarity(jacobian, tsos_.cartesianError().matrix());
120  }
121 
122  return Vertex(pos, error);
123 }
124 
126  bool withGhostTrackError) const {
127  using namespace ROOT::Math;
128 
129  if (!isValid())
130  return Vertex();
131 
132  GlobalPoint origin = pred.origin();
133  GlobalVector direction = pred.direction();
134 
135  double rho2 = pred.rho2();
136  double rho = std::sqrt(rho2);
137  double lambda = (tsos_.globalPosition() - origin) * direction / rho2;
138  GlobalPoint pos = origin + lambda * direction;
139 
140  GlobalVector momentum = tsos_.globalMomentum();
141  double mom = momentum.mag();
142 
143  Vector3 b = conv(direction) / rho;
144  Vector3 d = conv(momentum) / mom;
145  double l = Dot(b, d);
146  double g = 1. / (1. - sqr(l));
147 
148  Vector3 ca = conv(tsos_.globalPosition() - pos);
149  Vector3 bd = l * b - d;
150  d *= g;
151 
152  Matrix33 pC = TensorProd(d, bd);
153  Matrix33 pD = TensorProd(d, ca);
154 
155  Matrix36 jacobian;
156  jacobian.Place_at(pC + Matrix33(SMatrixIdentity()), 0, 0);
157  jacobian.Place_at(pD / mom, 0, 3);
158  Matrix3S error = Similarity(jacobian, tsos_.cartesianError().matrix());
159 
160  if (withGhostTrackError) {
161  jacobian.Place_at(-pC, 0, 0);
162  jacobian.Place_at(-pD / rho, 0, 3);
163  error += Similarity(jacobian, pred.cartesianError(lambda));
164  }
165 
166  return Vertex(tsos_.globalPosition(), error);
167 }
bool isValid() const override
std::pair< GlobalPoint, GlobalError > Vertex
TrajectoryStateOnSurface tsos_
GlobalPoint position(double lambda=0.) const
Definition: Line.h:10
T z() const
Definition: PV3DBase.h:61
int sqr(const T &t)
A arg
Definition: Factorize.h:31
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
const CartesianTrajectoryError cartesianError() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
const GlobalVector direction() const
GlobalPoint globalPosition() const
T sqrt(T t)
Definition: SSEVec.h:19
const MagneticField * field() const
T mag() const
Definition: PV3DBase.h:64
Vertex vertexStateOnMeasurement(const GhostTrackPrediction &pred, bool withGhostTrackError) const override
CartesianError cartesianError(double lambda=0.) const
d
Definition: ztail.py:151
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
Definition: Vector3D.h:28
const GlobalPoint origin() const
Vertex vertexStateOnGhostTrack(const GhostTrackPrediction &pred, bool withMeasurementError) const override
double b
Definition: hdecay.h:118
GlobalVector globalMomentum() const
EPOS::IO_EPOS conv
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
Definition: Point3D.h:18
fixed size matrix
const AlgebraicSymMatrix66 & matrix() const
bool linearize(const GhostTrackPrediction &pred, bool initial, double lambda) override
TrajectoryStateOnSurface impactPointState() const
*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