File indexing completed on 2026-07-16 08:07:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Common.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/Utilities/HashedString.hpp"
0014
0015 namespace Acts {
0016
0017 namespace detail_tp {
0018 inline constexpr HashedString kTipIndexKey = hashString("tipIndex");
0019 inline constexpr HashedString kStemIndexKey = hashString("stemIndex");
0020 inline constexpr HashedString kMeasurementsKey = hashString("nMeasurements");
0021 inline constexpr HashedString kHolesKey = hashString("nHoles");
0022 inline constexpr HashedString kOutliersKey = hashString("nOutliers");
0023 inline constexpr HashedString kSharedHitsKey = hashString("nSharedHits");
0024 inline constexpr HashedString kChi2Key = hashString("chi2");
0025 inline constexpr HashedString kNdfKey = hashString("ndf");
0026 inline constexpr HashedString kNextKey = hashString("next");
0027 }
0028
0029
0030
0031
0032
0033
0034
0035
0036 template <typename Derived, typename index_t, bool read_only>
0037 class TrackProxyCommon {
0038 protected:
0039 constexpr Derived& derived() { return static_cast<Derived&>(*this); }
0040 constexpr const Derived& derived() const {
0041 return static_cast<const Derived&>(*this);
0042 }
0043
0044 public:
0045
0046 using IndexType = index_t;
0047
0048
0049 IndexType tipIndex() const {
0050 return derived().template component<IndexType, detail_tp::kTipIndexKey>();
0051 }
0052
0053
0054 IndexType& tipIndex()
0055 requires(!read_only)
0056 {
0057 return derived().template component<IndexType, detail_tp::kTipIndexKey>();
0058 }
0059
0060
0061 IndexType stemIndex() const {
0062 return derived().template component<IndexType, detail_tp::kStemIndexKey>();
0063 }
0064
0065
0066 IndexType& stemIndex()
0067 requires(!read_only)
0068 {
0069 return derived().template component<IndexType, detail_tp::kStemIndexKey>();
0070 }
0071
0072
0073 unsigned int nMeasurements() const {
0074 return derived()
0075 .template component<unsigned int, detail_tp::kMeasurementsKey>();
0076 }
0077
0078
0079 unsigned int& nMeasurements()
0080 requires(!read_only)
0081 {
0082 return derived()
0083 .template component<unsigned int, detail_tp::kMeasurementsKey>();
0084 }
0085
0086
0087 unsigned int nHoles() const {
0088 return derived().template component<unsigned int, detail_tp::kHolesKey>();
0089 }
0090
0091
0092 unsigned int& nHoles()
0093 requires(!read_only)
0094 {
0095 return derived().template component<unsigned int, detail_tp::kHolesKey>();
0096 }
0097
0098
0099 unsigned int nOutliers() const {
0100 return derived()
0101 .template component<unsigned int, detail_tp::kOutliersKey>();
0102 }
0103
0104
0105 unsigned int& nOutliers()
0106 requires(!read_only)
0107 {
0108 return derived()
0109 .template component<unsigned int, detail_tp::kOutliersKey>();
0110 }
0111
0112
0113 unsigned int nSharedHits() const {
0114 return derived()
0115 .template component<unsigned int, detail_tp::kSharedHitsKey>();
0116 }
0117
0118
0119 unsigned int& nSharedHits()
0120 requires(!read_only)
0121 {
0122 return derived()
0123 .template component<unsigned int, detail_tp::kSharedHitsKey>();
0124 }
0125
0126
0127 float chi2() const {
0128 return derived().template component<float, detail_tp::kChi2Key>();
0129 }
0130
0131
0132 float& chi2()
0133 requires(!read_only)
0134 {
0135 return derived().template component<float, detail_tp::kChi2Key>();
0136 }
0137
0138
0139 unsigned int nDoF() const {
0140 return derived().template component<unsigned int, detail_tp::kNdfKey>();
0141 }
0142
0143
0144 unsigned int& nDoF()
0145 requires(!read_only)
0146 {
0147 return derived().template component<unsigned int, detail_tp::kNdfKey>();
0148 }
0149
0150
0151
0152 double theta() const { return derived().parameters()[eBoundTheta]; }
0153
0154
0155
0156 double phi() const { return derived().parameters()[eBoundPhi]; }
0157
0158
0159
0160 double loc0() const { return derived().parameters()[eBoundLoc0]; }
0161
0162
0163
0164 double loc1() const { return derived().parameters()[eBoundLoc1]; }
0165
0166
0167
0168 double time() const { return derived().parameters()[eBoundTime]; }
0169
0170
0171
0172 double qOverP() const { return derived().parameters()[eBoundQOverP]; }
0173
0174
0175
0176 double charge() const {
0177 return derived().particleHypothesis().extractCharge(qOverP());
0178 }
0179
0180
0181
0182 double absoluteMomentum() const {
0183 return derived().particleHypothesis().extractMomentum(qOverP());
0184 }
0185
0186
0187
0188 double transverseMomentum() const {
0189 return std::sin(derived().theta()) * derived().absoluteMomentum();
0190 }
0191
0192
0193
0194 Vector3 direction() const {
0195 return makeDirectionFromPhiTheta(derived().phi(), derived().theta());
0196 }
0197
0198
0199
0200 Vector3 momentum() const {
0201 return derived().absoluteMomentum() * derived().direction();
0202 }
0203
0204
0205
0206 Vector4 fourMomentum() const {
0207 Vector4 p4 = Vector4::Zero();
0208
0209 Vector3 p3 = derived().momentum();
0210 p4[eMom0] = p3[eMom0];
0211 p4[eMom1] = p3[eMom1];
0212 p4[eMom2] = p3[eMom2];
0213
0214 float m = derived().particleHypothesis().mass();
0215 p4[eEnergy] = std::sqrt(m * m + p3.squaredNorm());
0216
0217 return p4;
0218 }
0219 };
0220
0221 }