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