2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
7 inline PatternTrackParameters::PatternTrackParameters()
8 : ParametersCommon<5, Trk::Charged>() {
9 m_parameters.setZero();
12 inline PatternTrackParameters::PatternTrackParameters(
13 const PatternTrackParameters& P)
14 : PatternTrackParameters() {
18 inline PatternTrackParameters& PatternTrackParameters::operator=(
19 const PatternTrackParameters& P) {
21 if (P.m_surface != nullptr) {
22 m_surface.reset(P.m_surface->isFree() ? P.m_surface->clone()
25 m_surface.reset(nullptr);
28 m_parameters = P.m_parameters;
30 if (P.m_covariance != std::nullopt) {
31 if (m_covariance == std::nullopt) {
32 m_covariance = AmgSymMatrix(5)(*P.m_covariance);
34 *m_covariance = *P.m_covariance;
42 inline void PatternTrackParameters::setParameters(const Surface* s,
44 m_surface.reset(s && s->isFree() ? s->clone() : s);
45 m_parameters[0] = p[0];
46 m_parameters[1] = p[1];
47 m_parameters[2] = p[2];
48 m_parameters[3] = p[3];
49 m_parameters[4] = p[4];
53 inline void PatternTrackParameters::setCovariance(const double* c) {
54 if (m_covariance == std::nullopt) {
55 m_covariance.emplace();
58 m_covariance->fillSymmetric(0, 0, c[0]);
59 m_covariance->fillSymmetric(0, 1, c[1]);
60 m_covariance->fillSymmetric(1, 1, c[2]);
61 m_covariance->fillSymmetric(0, 2, c[3]);
62 m_covariance->fillSymmetric(1, 2, c[4]);
63 m_covariance->fillSymmetric(2, 2, c[5]);
64 m_covariance->fillSymmetric(0, 3, c[6]);
65 m_covariance->fillSymmetric(1, 3, c[7]);
66 m_covariance->fillSymmetric(2, 3, c[8]);
67 m_covariance->fillSymmetric(3, 3, c[9]);
68 m_covariance->fillSymmetric(0, 4, c[10]);
69 m_covariance->fillSymmetric(1, 4, c[11]);
70 m_covariance->fillSymmetric(2, 4, c[12]);
71 m_covariance->fillSymmetric(3, 4, c[13]);
72 m_covariance->fillSymmetric(4, 4, c[14]);
75 inline void PatternTrackParameters::setParametersWithCovariance(
76 const Surface* s, const double* p, const double* c) {
77 m_surface.reset(s && s->isFree() ? s->clone() : s);
78 m_parameters[0] = p[0];
79 m_parameters[1] = p[1];
80 m_parameters[2] = p[2];
81 m_parameters[3] = p[3];
82 m_parameters[4] = p[4];
86 inline void PatternTrackParameters::setParametersWithCovariance(
87 const Surface* s, const double* p, const AmgSymMatrix(5) & c) {
88 double C[15] = {c(0, 0), c(1, 0), c(1, 1), c(2, 0), c(2, 1),
89 c(2, 2), c(3, 0), c(3, 1), c(3, 2), c(3, 3),
90 c(4, 0), c(4, 1), c(4, 2), c(4, 3), c(4, 4)};
91 setParametersWithCovariance(s, p, C);
94 inline void PatternTrackParameters::diagonalization(double D) {
95 if (m_covariance == std::nullopt) {
99 m_covariance->fillSymmetric(0, 1, 0);
100 m_covariance->fillSymmetric(0, 2, 0);
101 m_covariance->fillSymmetric(1, 2, 0);
102 m_covariance->fillSymmetric(0, 3, 0);
103 m_covariance->fillSymmetric(1, 3, 0);
104 m_covariance->fillSymmetric(2, 3, 0);
105 m_covariance->fillSymmetric(0, 4, 0);
106 m_covariance->fillSymmetric(1, 4, 0);
107 m_covariance->fillSymmetric(2, 4, 0);
108 m_covariance->fillSymmetric(3, 4, 0);
110 (*m_covariance)(0, 0) *= D;
111 (*m_covariance)(1, 1) *= D;
112 (*m_covariance)(2, 2) *= D;
113 (*m_covariance)(3, 3) *= D;
114 (*m_covariance)(4, 4) *= D;
117 inline void PatternTrackParameters::addNoise(const NoiseOnSurface& N,
119 if (m_covariance != std::nullopt) {
120 (*m_covariance)(2, 2) += N.covarianceAzim();
121 (*m_covariance)(3, 3) += N.covariancePola();
122 (*m_covariance)(4, 4) += N.covarianceIMom();
126 N.correctionIMom() > 1. ? m_parameters[4] *= N.correctionIMom()
127 : m_parameters[4] /= N.correctionIMom();
129 N.correctionIMom() > 1. ? m_parameters[4] /= N.correctionIMom()
130 : m_parameters[4] *= N.correctionIMom();
134 inline void PatternTrackParameters::removeNoise(const NoiseOnSurface& N,
136 if (m_covariance != std::nullopt) {
137 (*m_covariance)(2, 2) -= N.covarianceAzim();
138 (*m_covariance)(3, 3) -= N.covariancePola();
139 (*m_covariance)(4, 4) -= N.covarianceIMom();
143 N.correctionIMom() > 1. ? m_parameters[4] /= N.correctionIMom()
144 : m_parameters[4] *= N.correctionIMom();
146 N.correctionIMom() > 1. ? m_parameters[4] *= N.correctionIMom()
147 : m_parameters[4] /= N.correctionIMom();
151 inline double PatternTrackParameters::charge() const {
152 if (m_parameters[4] > 0.0) {
159 inline double PatternTrackParameters::sinPhi() const {
160 return std::sin(m_parameters[2]);
163 inline double PatternTrackParameters::cosPhi() const {
164 return std::cos(m_parameters[2]);
167 inline double PatternTrackParameters::sinTheta() const {
168 return std::sin(m_parameters[3]);
171 inline double PatternTrackParameters::cosTheta() const {
172 return std::cos(m_parameters[3]);
175 inline double PatternTrackParameters::cotTheta() const {
176 return (1. / std::tan(m_parameters[3]));
179 inline Amg::Vector3D PatternTrackParameters::momentum() const {
180 return calculateMomentum();
183 inline double PatternTrackParameters::absoluteMomentum() const {
184 return m_parameters[4] != 0. ? 1. / std::abs(m_parameters[4]) : 10e9;
187 inline double PatternTrackParameters::transverseMomentum() const {
188 double p = absoluteMomentum();
189 double Se = std::sin(m_parameters[3]);
193 inline const Surface& PatternTrackParameters::associatedSurface() const {
197 inline bool PatternTrackParameters::hasSurface() const {
198 return m_surface != nullptr;
201 inline Amg::RotationMatrix3D PatternTrackParameters::measurementFrame() const {
202 return associatedSurface().measurementFrame(this->position(),
206 inline PatternTrackParameters* PatternTrackParameters::clone() const {
207 return new PatternTrackParameters(*this);
210 inline constexpr ParametersType PatternTrackParameters::type() const {
214 inline SurfaceType PatternTrackParameters::surfaceType() const {
215 return m_surface->type();
218 inline void PatternTrackParameters::updateParametersHelper(const AmgVector(5) & params) {
219 m_parameters = params;
221 } // end namespace Trk