ATLAS Offline Software
ParametersCommon.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Trk
6 #include "TrkEventPrimitives/ParamDefs.h"
7 // STD
8 #include <utility>
9 
10 namespace Trk {
11 // Helper protected ctor
12 template <int DIM, class T>
13  ParametersCommon<DIM, T>::ParametersCommon(
14  const AmgVector(DIM) parameters,
15  std::optional<AmgSymMatrix(DIM)>&& covariance, const T chargeDef)
16  : m_parameters(parameters),
17  m_covariance(std::move(covariance)),
18  // cppcheck-suppress missingReturn; false positive
19  m_chargeDef(chargeDef) {}
20 
21 // Helper protected ctor
22 template <int DIM, class T>
23 ParametersCommon<DIM, T>::ParametersCommon(
24  std::optional<AmgSymMatrix(DIM)>&& covariance)
25  : m_parameters(),
26  m_covariance(std::move(covariance)),
27  m_chargeDef{} {}
28 
29 
30 // Protected Constructor with local arguments
31 template <int DIM, class T>
32 ParametersCommon<DIM, T>::ParametersCommon(
33  const AmgVector(DIM) & parameters,
34  std::optional<AmgSymMatrix(DIM)>&& covariance)
35  : m_parameters(parameters),
36  m_covariance(std::move(covariance)),
37  m_chargeDef{} {}
38 
39 template <int DIM, class T>
40  const AmgVector(DIM) & ParametersCommon<DIM, T>::parameters() const {
41  return m_parameters;
42 }
43 
44 template <int DIM, class T>
45 AmgVector(DIM) & ParametersCommon<DIM, T>::parameters() {
46  return m_parameters;
47 }
48 
49 template <int DIM, class T>
50 const AmgSymMatrix(DIM) *ParametersCommon<DIM, T>::covariance() const {
51  if (m_covariance != std::nullopt) {
52  return m_covariance.operator->();
53  } else {
54  return nullptr;
55  }
56 }
57 
58 template <int DIM, class T>
59 AmgSymMatrix(DIM) * ParametersCommon<DIM, T>::covariance() {
60  if (m_covariance != std::nullopt) {
61  return m_covariance.operator->();
62  } else {
63  return nullptr;
64  }
65 }
66 
67 template <int DIM, class T>
68 constexpr bool ParametersCommon<DIM, T>::isCharged() const {
69  if constexpr (std::is_same<T, Trk::Neutral>::value) {
70  return false;
71  } else {
72  return true;
73  }
74 }
75 
76 template <int DIM, class T>
77 Amg::Vector2D ParametersCommon<DIM, T>::localPosition() const {
78  return Amg::Vector2D(m_parameters[Trk::loc1], m_parameters[Trk::loc2]);
79 }
80 
81 template <int DIM, class T>
82 void ParametersCommon<DIM, T>::setParameters(
83  const AmgVector(DIM) & param) {
84  m_parameters = param;
85 }
86 
87 template <int DIM, class T>
88 void ParametersCommon<DIM, T>::setCovariance(
89  const AmgSymMatrix(DIM) & cov) {
90  m_covariance = cov;
91 }
92 
93 template <int DIM, class T>
94 void ParametersCommon<DIM, T>::updateParameters(
95  const AmgVector(DIM)& updatedParameters) {
96  this->updateParametersHelper(updatedParameters);
97 }
98 
99 template <int DIM, class T>
100 void ParametersCommon<DIM, T>::updateParameters(
101  const AmgVector(DIM) &updatedParameters,
102  const AmgSymMatrix(DIM) & updatedCovariance) {
103  m_covariance = updatedCovariance;
104  this->updateParametersHelper(updatedParameters);
105 }
106 
107 } // end of namespace Trk
108