File indexing completed on 2026-06-17 07:59:35
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
0040
0041 constexpr Derived& derived() { return static_cast<Derived&>(*this); }
0042
0043
0044 constexpr const Derived& derived() const {
0045 return static_cast<const Derived&>(*this);
0046 }
0047
0048 public:
0049
0050 using IndexType = index_t;
0051
0052
0053
0054 IndexType tipIndex() const {
0055 return derived().template component<IndexType, detail_tp::kTipIndexKey>();
0056 }
0057
0058
0059
0060 IndexType& tipIndex()
0061 requires(!read_only)
0062 {
0063 return derived().template component<IndexType, detail_tp::kTipIndexKey>();
0064 }
0065
0066
0067
0068 IndexType stemIndex() const {
0069 return derived().template component<IndexType, detail_tp::kStemIndexKey>();
0070 }
0071
0072
0073
0074 IndexType& stemIndex()
0075 requires(!read_only)
0076 {
0077 return derived().template component<IndexType, detail_tp::kStemIndexKey>();
0078 }
0079
0080
0081
0082 unsigned int nMeasurements() const {
0083 return derived()
0084 .template component<unsigned int, detail_tp::kMeasurementsKey>();
0085 }
0086
0087
0088
0089 unsigned int& nMeasurements()
0090 requires(!read_only)
0091 {
0092 return derived()
0093 .template component<unsigned int, detail_tp::kMeasurementsKey>();
0094 }
0095
0096
0097
0098 unsigned int nHoles() const {
0099 return derived().template component<unsigned int, detail_tp::kHolesKey>();
0100 }
0101
0102
0103
0104 unsigned int& nHoles()
0105 requires(!read_only)
0106 {
0107 return derived().template component<unsigned int, detail_tp::kHolesKey>();
0108 }
0109
0110
0111
0112 unsigned int nOutliers() const {
0113 return derived()
0114 .template component<unsigned int, detail_tp::kOutliersKey>();
0115 }
0116
0117
0118
0119 unsigned int& nOutliers()
0120 requires(!read_only)
0121 {
0122 return derived()
0123 .template component<unsigned int, detail_tp::kOutliersKey>();
0124 }
0125
0126
0127
0128 unsigned int nSharedHits() const {
0129 return derived()
0130 .template component<unsigned int, detail_tp::kSharedHitsKey>();
0131 }
0132
0133
0134
0135 unsigned int& nSharedHits()
0136 requires(!read_only)
0137 {
0138 return derived()
0139 .template component<unsigned int, detail_tp::kSharedHitsKey>();
0140 }
0141
0142
0143
0144 float chi2() const {
0145 return derived().template component<float, detail_tp::kChi2Key>();
0146 }
0147
0148
0149
0150 float& chi2()
0151 requires(!read_only)
0152 {
0153 return derived().template component<float, detail_tp::kChi2Key>();
0154 }
0155
0156
0157
0158 unsigned int nDoF() const {
0159 return derived().template component<unsigned int, detail_tp::kNdfKey>();
0160 }
0161
0162
0163
0164 unsigned int& nDoF()
0165 requires(!read_only)
0166 {
0167 return derived().template component<unsigned int, detail_tp::kNdfKey>();
0168 }
0169
0170
0171
0172 double theta() const { return derived().parameters()[eBoundTheta]; }
0173
0174
0175
0176 double phi() const { return derived().parameters()[eBoundPhi]; }
0177
0178
0179
0180 double loc0() const { return derived().parameters()[eBoundLoc0]; }
0181
0182
0183
0184 double loc1() const { return derived().parameters()[eBoundLoc1]; }
0185
0186
0187
0188 double time() const { return derived().parameters()[eBoundTime]; }
0189
0190
0191
0192 double qOverP() const { return derived().parameters()[eBoundQOverP]; }
0193
0194
0195
0196 double charge() const {
0197 return derived().particleHypothesis().extractCharge(qOverP());
0198 }
0199
0200
0201
0202 double absoluteMomentum() const {
0203 return derived().particleHypothesis().extractMomentum(qOverP());
0204 }
0205
0206
0207
0208 double transverseMomentum() const {
0209 return std::sin(derived().theta()) * derived().absoluteMomentum();
0210 }
0211
0212
0213
0214 Vector3 direction() const {
0215 return makeDirectionFromPhiTheta(derived().phi(), derived().theta());
0216 }
0217
0218
0219
0220 Vector3 momentum() const {
0221 return derived().absoluteMomentum() * derived().direction();
0222 }
0223
0224
0225
0226 Vector4 fourMomentum() const {
0227 Vector4 p4 = Vector4::Zero();
0228
0229 Vector3 p3 = derived().momentum();
0230 p4[eMom0] = p3[eMom0];
0231 p4[eMom1] = p3[eMom1];
0232 p4[eMom2] = p3[eMom2];
0233
0234 float m = derived().particleHypothesis().mass();
0235 p4[eEnergy] = std::sqrt(m * m + p3.squaredNorm());
0236
0237 return p4;
0238 }
0239 };
0240
0241 }