File indexing completed on 2025-12-16 09:22:20
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/EventData/SourceLink.hpp"
0013 #include "Acts/EventData/SubspaceHelpers.hpp"
0014 #include "Acts/EventData/TrackStatePropMask.hpp"
0015 #include "Acts/EventData/TrackStateProxyConcept.hpp"
0016 #include "Acts/EventData/TrackStateType.hpp"
0017 #include "Acts/EventData/Types.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Utilities/EigenConcepts.hpp"
0020 #include "Acts/Utilities/HashedString.hpp"
0021 #include "Acts/Utilities/Helpers.hpp"
0022
0023 #include <cstddef>
0024 #include <ranges>
0025 #include <span>
0026
0027 #include <Eigen/Core>
0028
0029 namespace Acts {
0030
0031 template <typename derived_t>
0032 class MultiTrajectory;
0033
0034 namespace detail_tsp {
0035 inline constexpr HashedString kPreviousKey = hashString("previous");
0036 inline constexpr HashedString kChi2Key = hashString("chi2");
0037 inline constexpr HashedString kPathLengthKey = hashString("pathLength");
0038 inline constexpr HashedString kTypeFlagsKey = hashString("typeFlags");
0039 inline constexpr HashedString kPredictedKey = hashString("predicted");
0040 inline constexpr HashedString kFilteredKey = hashString("filtered");
0041 inline constexpr HashedString kSmoothedKey = hashString("smoothed");
0042 inline constexpr HashedString kJacobianKey = hashString("jacobian");
0043 inline constexpr HashedString kProjectorKey = hashString("projector");
0044 inline constexpr HashedString kUncalibratedKey =
0045 hashString("uncalibratedSourceLink");
0046 inline constexpr HashedString kCalibratedKey = hashString("calibrated");
0047 inline constexpr HashedString kCalibratedCovKey = hashString("calibratedCov");
0048 inline constexpr HashedString kNextKey = hashString("next");
0049 }
0050
0051 namespace detail_lt {
0052
0053
0054 template <typename T, bool select>
0055 using ConstIf = std::conditional_t<select, const T, T>;
0056
0057
0058 template <typename T>
0059 class TransitiveConstPointer {
0060 public:
0061 using element_type = T;
0062 TransitiveConstPointer() = default;
0063 explicit TransitiveConstPointer(T* ptr) : m_ptr{ptr} {}
0064
0065 template <typename U>
0066 explicit TransitiveConstPointer(const TransitiveConstPointer<U>& other)
0067 : m_ptr{other.ptr()} {}
0068
0069 template <typename U>
0070 TransitiveConstPointer& operator=(const TransitiveConstPointer<U>& other) {
0071 m_ptr = other.m_ptr;
0072 return *this;
0073 }
0074
0075 template <typename U>
0076 bool operator==(const TransitiveConstPointer<U>& other) const {
0077 return m_ptr == other.m_ptr;
0078 }
0079
0080 const T* operator->() const { return m_ptr; }
0081
0082 T* operator->() { return m_ptr; }
0083
0084 template <typename U>
0085 friend class TransitiveConstPointer;
0086
0087 const T& operator*() const { return *m_ptr; }
0088
0089 T& operator*() { return *m_ptr; }
0090
0091 explicit operator bool() const { return m_ptr != nullptr; }
0092
0093 private:
0094 T* ptr() const { return m_ptr; }
0095
0096 T* m_ptr{nullptr};
0097 };
0098
0099
0100
0101 template <std::size_t Size, bool ReadOnlyMaps = true>
0102 struct FixedSizeTypes {
0103 constexpr static auto Flags = Eigen::ColMajor | Eigen::AutoAlign;
0104
0105
0106 using Coefficients = Eigen::Matrix<double, Size, 1, Flags>;
0107 using Covariance = Eigen::Matrix<double, Size, Size, Flags>;
0108 using CoefficientsMap = Eigen::Map<ConstIf<Coefficients, ReadOnlyMaps>>;
0109 using CovarianceMap = Eigen::Map<ConstIf<Covariance, ReadOnlyMaps>>;
0110
0111 using DynamicCoefficients = Eigen::Matrix<double, Eigen::Dynamic, 1, Flags>;
0112 using DynamicCovariance =
0113 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Flags>;
0114 using DynamicCoefficientsMap =
0115 Eigen::Map<ConstIf<DynamicCoefficients, ReadOnlyMaps>>;
0116 using DynamicCovarianceMap =
0117 Eigen::Map<ConstIf<DynamicCovariance, ReadOnlyMaps>>;
0118 };
0119
0120
0121
0122 template <bool ReadOnlyMaps = true>
0123 struct DynamicSizeTypes {
0124 constexpr static auto Flags = Eigen::ColMajor | Eigen::AutoAlign;
0125
0126 using Coefficients = Eigen::Matrix<double, Eigen::Dynamic, 1, Flags>;
0127 using Covariance =
0128 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Flags>;
0129 using CoefficientsMap = Eigen::Map<ConstIf<Coefficients, ReadOnlyMaps>>;
0130 using CovarianceMap = Eigen::Map<ConstIf<Covariance, ReadOnlyMaps>>;
0131 };
0132
0133 }
0134
0135
0136 template <std::size_t M, bool ReadOnly = true>
0137 struct TrackStateTraits {
0138 using Parameters =
0139 typename detail_lt::FixedSizeTypes<eBoundSize, ReadOnly>::CoefficientsMap;
0140 using Covariance =
0141 typename detail_lt::FixedSizeTypes<eBoundSize, ReadOnly>::CovarianceMap;
0142 using Calibrated =
0143 typename detail_lt::FixedSizeTypes<M, ReadOnly>::CoefficientsMap;
0144 using CalibratedCovariance =
0145 typename detail_lt::FixedSizeTypes<M, ReadOnly>::CovarianceMap;
0146 using EffectiveCalibrated =
0147 typename detail_lt::DynamicSizeTypes<ReadOnly>::CoefficientsMap;
0148 using EffectiveCalibratedCovariance =
0149 typename detail_lt::DynamicSizeTypes<ReadOnly>::CovarianceMap;
0150 };
0151
0152
0153
0154
0155
0156
0157 template <typename trajectory_t, std::size_t M, bool read_only = true>
0158 class TrackStateProxy {
0159 public:
0160
0161
0162 static constexpr bool ReadOnly = read_only;
0163
0164
0165 using ConstProxyType = TrackStateProxy<trajectory_t, M, true>;
0166
0167
0168
0169 using Parameters = typename TrackStateTraits<M, ReadOnly>::Parameters;
0170
0171
0172 using ConstParameters = typename TrackStateTraits<M, true>::Parameters;
0173
0174
0175
0176 using Covariance = typename TrackStateTraits<M, ReadOnly>::Covariance;
0177
0178
0179 using ConstCovariance = typename TrackStateTraits<M, true>::Covariance;
0180
0181
0182
0183 template <std::size_t N>
0184 using Calibrated = typename TrackStateTraits<N, ReadOnly>::Calibrated;
0185
0186
0187 template <std::size_t N>
0188 using ConstCalibrated = typename TrackStateTraits<N, true>::Calibrated;
0189
0190
0191
0192 template <std::size_t N>
0193 using CalibratedCovariance =
0194 typename TrackStateTraits<N, ReadOnly>::CalibratedCovariance;
0195
0196
0197 template <std::size_t N>
0198 using ConstCalibratedCovariance =
0199 typename TrackStateTraits<N, true>::CalibratedCovariance;
0200
0201
0202
0203 using EffectiveCalibrated =
0204 typename TrackStateTraits<M, ReadOnly>::EffectiveCalibrated;
0205
0206
0207 using ConstEffectiveCalibrated =
0208 typename TrackStateTraits<M, true>::EffectiveCalibrated;
0209
0210
0211
0212 using EffectiveCalibratedCovariance =
0213 typename TrackStateTraits<M, ReadOnly>::EffectiveCalibratedCovariance;
0214
0215
0216 using ConstEffectiveCalibratedCovariance =
0217 typename TrackStateTraits<M, true>::EffectiveCalibratedCovariance;
0218
0219
0220 using IndexType = TrackIndexType;
0221
0222
0223 static constexpr IndexType kInvalid = kTrackIndexInvalid;
0224
0225
0226 using Trajectory = trajectory_t;
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239 TrackStateProxy(const TrackStateProxy& other) = default;
0240
0241
0242
0243
0244 TrackStateProxy& operator=(const TrackStateProxy& other) = default;
0245
0246
0247
0248
0249 explicit TrackStateProxy(const TrackStateProxy<Trajectory, M, false>& other)
0250 requires ReadOnly
0251 : m_traj{other.m_traj}, m_istate{other.m_istate} {}
0252
0253
0254
0255
0256
0257 TrackStateProxy& operator=(const TrackStateProxy<Trajectory, M, false>& other)
0258 requires ReadOnly
0259 {
0260 m_traj = other.m_traj;
0261 m_istate = other.m_istate;
0262
0263 return *this;
0264 }
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315 IndexType index() const { return m_istate; }
0316
0317
0318
0319 IndexType previous() const {
0320 return component<IndexType, detail_tsp::kPreviousKey>();
0321 }
0322
0323
0324
0325
0326
0327 IndexType& previous()
0328 requires(!ReadOnly)
0329 {
0330 return component<IndexType, detail_tsp::kPreviousKey>();
0331 }
0332
0333
0334
0335 bool hasPrevious() const {
0336 return component<IndexType, detail_tsp::kPreviousKey>() != kInvalid;
0337 }
0338
0339
0340
0341
0342 TrackStatePropMask getMask() const;
0343
0344
0345
0346
0347 void unset(TrackStatePropMask target)
0348 requires(!ReadOnly)
0349 {
0350 m_traj->self().unset(target, m_istate);
0351 }
0352
0353
0354
0355
0356 void addComponents(TrackStatePropMask mask)
0357 requires(!ReadOnly)
0358 {
0359 m_traj->self().addTrackStateComponents_impl(m_istate, mask);
0360 }
0361
0362
0363
0364 const Surface& referenceSurface() const {
0365 assert(hasReferenceSurface() &&
0366 "TrackState does not have reference surface");
0367 return *m_traj->referenceSurface(m_istate);
0368 }
0369
0370
0371
0372 bool hasReferenceSurface() const {
0373 return m_traj->referenceSurface(m_istate) != nullptr;
0374 }
0375
0376
0377
0378
0379
0380
0381
0382 void setReferenceSurface(std::shared_ptr<const Surface> srf)
0383 requires(!ReadOnly)
0384 {
0385 m_traj->setReferenceSurface(m_istate, std::move(srf));
0386 }
0387
0388
0389
0390
0391
0392
0393
0394 float& chi2()
0395 requires(!ReadOnly)
0396 {
0397 return component<float, detail_tsp::kChi2Key>();
0398 }
0399
0400
0401
0402
0403
0404 float chi2() const { return component<float, detail_tsp::kChi2Key>(); }
0405
0406
0407
0408
0409
0410 double& pathLength()
0411 requires(!ReadOnly)
0412 {
0413 return component<double, detail_tsp::kPathLengthKey>();
0414 }
0415
0416
0417
0418 double pathLength() const {
0419 return component<double, detail_tsp::kPathLengthKey>();
0420 }
0421
0422
0423
0424
0425
0426 TrackStateType typeFlags()
0427 requires(!ReadOnly)
0428 {
0429 return TrackStateType{
0430 component<TrackStateType::raw_type, detail_tsp::kTypeFlagsKey>()};
0431 }
0432
0433
0434
0435 ConstTrackStateType typeFlags() const {
0436 return ConstTrackStateType{
0437 component<TrackStateType::raw_type, detail_tsp::kTypeFlagsKey>()};
0438 }
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450 ConstParameters parameters() const;
0451
0452
0453
0454
0455
0456
0457 ConstCovariance covariance() const;
0458
0459
0460
0461 ConstParameters predicted() const {
0462 assert(has<detail_tsp::kPredictedKey>());
0463 return m_traj->self().parameters(
0464 component<IndexType, detail_tsp::kPredictedKey>());
0465 }
0466
0467
0468
0469 Parameters predicted()
0470 requires(!ReadOnly)
0471 {
0472 assert(has<detail_tsp::kPredictedKey>());
0473 return m_traj->self().parameters(
0474 component<IndexType, detail_tsp::kPredictedKey>());
0475 }
0476
0477
0478
0479 ConstCovariance predictedCovariance() const {
0480 assert(has<detail_tsp::kPredictedKey>());
0481 return m_traj->self().covariance(
0482 component<IndexType, detail_tsp::kPredictedKey>());
0483 }
0484
0485
0486
0487 Covariance predictedCovariance()
0488 requires(!ReadOnly)
0489 {
0490 assert(has<detail_tsp::kPredictedKey>());
0491 return m_traj->self().covariance(
0492 component<IndexType, detail_tsp::kPredictedKey>());
0493 }
0494
0495
0496
0497 bool hasPredicted() const { return has<detail_tsp::kPredictedKey>(); }
0498
0499
0500
0501
0502 ConstParameters filtered() const {
0503 assert(has<detail_tsp::kFilteredKey>());
0504 return m_traj->self().parameters(
0505 component<IndexType, detail_tsp::kFilteredKey>());
0506 }
0507
0508
0509
0510
0511 Parameters filtered()
0512 requires(!ReadOnly)
0513 {
0514 assert(has<detail_tsp::kFilteredKey>());
0515 return m_traj->self().parameters(
0516 component<IndexType, detail_tsp::kFilteredKey>());
0517 }
0518
0519
0520
0521
0522 ConstCovariance filteredCovariance() const {
0523 assert(has<detail_tsp::kFilteredKey>());
0524 return m_traj->self().covariance(
0525 component<IndexType, detail_tsp::kFilteredKey>());
0526 }
0527
0528
0529
0530
0531 Covariance filteredCovariance()
0532 requires(!ReadOnly)
0533 {
0534 assert(has<detail_tsp::kFilteredKey>());
0535 return m_traj->self().covariance(
0536 component<IndexType, detail_tsp::kFilteredKey>());
0537 }
0538
0539
0540
0541 bool hasFiltered() const { return has<detail_tsp::kFilteredKey>(); }
0542
0543
0544
0545
0546 ConstParameters smoothed() const {
0547 assert(has<detail_tsp::kSmoothedKey>());
0548 return m_traj->self().parameters(
0549 component<IndexType, detail_tsp::kSmoothedKey>());
0550 }
0551
0552
0553
0554
0555 Parameters smoothed()
0556 requires(!ReadOnly)
0557 {
0558 assert(has<detail_tsp::kSmoothedKey>());
0559 return m_traj->self().parameters(
0560 component<IndexType, detail_tsp::kSmoothedKey>());
0561 }
0562
0563
0564
0565
0566 ConstCovariance smoothedCovariance() const {
0567 assert(has<detail_tsp::kSmoothedKey>());
0568 return m_traj->self().covariance(
0569 component<IndexType, detail_tsp::kSmoothedKey>());
0570 }
0571
0572
0573
0574
0575 Covariance smoothedCovariance()
0576 requires(!ReadOnly)
0577 {
0578 assert(has<detail_tsp::kSmoothedKey>());
0579 return m_traj->self().covariance(
0580 component<IndexType, detail_tsp::kSmoothedKey>());
0581 }
0582
0583
0584
0585 bool hasSmoothed() const { return has<detail_tsp::kSmoothedKey>(); }
0586
0587
0588
0589
0590 ConstCovariance jacobian() const {
0591 assert(has<detail_tsp::kJacobianKey>());
0592 return m_traj->self().jacobian(m_istate);
0593 }
0594
0595
0596
0597
0598 Covariance jacobian()
0599 requires(!ReadOnly)
0600 {
0601 assert(has<detail_tsp::kJacobianKey>());
0602 return m_traj->self().jacobian(m_istate);
0603 }
0604
0605
0606
0607 bool hasJacobian() const { return has<detail_tsp::kJacobianKey>(); }
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640 template <std::ranges::sized_range index_range_t>
0641 void setProjectorSubspaceIndices(const index_range_t& subspaceIndices)
0642 requires(!ReadOnly &&
0643 std::convertible_to<std::ranges::range_value_t<index_range_t>,
0644 std::uint8_t>)
0645 {
0646 assert(has<detail_tsp::kProjectorKey>());
0647 assert(subspaceIndices.size() <= eBoundSize);
0648 BoundSubspaceIndices boundSubspace{};
0649 std::transform(subspaceIndices.begin(), subspaceIndices.end(),
0650 boundSubspace.begin(),
0651 [](auto i) { return static_cast<std::uint8_t>(i); });
0652 component<SerializedSubspaceIndices, detail_tsp::kProjectorKey>() =
0653 serializeSubspaceIndices(boundSubspace);
0654 }
0655
0656
0657
0658 bool hasProjector() const { return has<detail_tsp::kProjectorKey>(); }
0659
0660
0661
0662 BoundSubspaceIndices projectorSubspaceIndices() const {
0663 assert(has<detail_tsp::kProjectorKey>());
0664 return deserializeSubspaceIndices<eBoundSize>(
0665 component<SerializedSubspaceIndices, detail_tsp::kProjectorKey>());
0666 }
0667
0668
0669
0670 template <std::size_t measdim>
0671 SubspaceIndices<measdim> projectorSubspaceIndices() const {
0672 BoundSubspaceIndices boundSubspace = projectorSubspaceIndices();
0673 SubspaceIndices<measdim> subspace;
0674 std::copy(boundSubspace.begin(), boundSubspace.begin() + measdim,
0675 subspace.begin());
0676 return subspace;
0677 }
0678
0679
0680
0681 VariableBoundSubspaceHelper projectorSubspaceHelper() const {
0682 BoundSubspaceIndices boundSubspace = projectorSubspaceIndices();
0683 std::span<std::uint8_t> validSubspaceIndices(
0684 boundSubspace.begin(), boundSubspace.begin() + calibratedSize());
0685 return VariableBoundSubspaceHelper(validSubspaceIndices);
0686 }
0687
0688
0689
0690 template <std::size_t measdim>
0691 FixedBoundSubspaceHelper<measdim> projectorSubspaceHelper() const {
0692 SubspaceIndices<measdim> subspace = projectorSubspaceIndices<measdim>();
0693 return FixedBoundSubspaceHelper<measdim>(subspace);
0694 }
0695
0696
0697
0698 SourceLink getUncalibratedSourceLink() const;
0699
0700
0701
0702 void setUncalibratedSourceLink(SourceLink&& sourceLink)
0703 requires(!ReadOnly)
0704 {
0705 m_traj->setUncalibratedSourceLink(m_istate, std::move(sourceLink));
0706 }
0707
0708
0709
0710 bool hasUncalibratedSourceLink() const {
0711 return has<detail_tsp::kUncalibratedKey>();
0712 }
0713
0714
0715
0716 bool hasCalibrated() const { return has<detail_tsp::kCalibratedKey>(); }
0717
0718
0719
0720
0721
0722 template <std::size_t measdim>
0723 ConstCalibrated<measdim> calibrated() const {
0724 assert(has<detail_tsp::kCalibratedKey>());
0725 return m_traj->self().template calibrated<measdim>(m_istate);
0726 }
0727
0728
0729
0730
0731
0732 template <std::size_t measdim>
0733 Calibrated<measdim> calibrated()
0734 requires(!ReadOnly)
0735 {
0736 assert(has<detail_tsp::kCalibratedKey>());
0737 return m_traj->self().template calibrated<measdim>(m_istate);
0738 }
0739
0740
0741
0742
0743 template <std::size_t measdim>
0744 ConstCalibratedCovariance<measdim> calibratedCovariance() const {
0745 assert(has<detail_tsp::kCalibratedCovKey>());
0746 return m_traj->self().template calibratedCovariance<measdim>(m_istate);
0747 }
0748
0749
0750
0751
0752 template <std::size_t measdim>
0753 CalibratedCovariance<measdim> calibratedCovariance()
0754 requires(!ReadOnly)
0755 {
0756 assert(has<detail_tsp::kCalibratedCovKey>());
0757 return m_traj->self().template calibratedCovariance<measdim>(m_istate);
0758 }
0759
0760
0761
0762
0763 EffectiveCalibrated effectiveCalibrated()
0764 requires(!ReadOnly)
0765 {
0766 assert(has<detail_tsp::kCalibratedKey>());
0767 return m_traj->self().effectiveCalibrated(m_istate);
0768 }
0769
0770
0771
0772
0773 ConstEffectiveCalibrated effectiveCalibrated() const {
0774 assert(has<detail_tsp::kCalibratedKey>());
0775 return m_traj->self().effectiveCalibrated(m_istate);
0776 }
0777
0778
0779
0780
0781
0782 EffectiveCalibratedCovariance effectiveCalibratedCovariance() {
0783 assert(has<detail_tsp::kCalibratedCovKey>());
0784 return m_traj->self().effectiveCalibratedCovariance(m_istate);
0785 }
0786
0787
0788
0789
0790
0791 ConstEffectiveCalibratedCovariance effectiveCalibratedCovariance() const {
0792 assert(has<detail_tsp::kCalibratedCovKey>());
0793 return m_traj->self().effectiveCalibratedCovariance(m_istate);
0794 }
0795
0796
0797
0798
0799
0800 IndexType calibratedSize() const { return m_traj->calibratedSize(m_istate); }
0801
0802
0803
0804
0805
0806
0807
0808 void allocateCalibrated(std::size_t measdim)
0809 requires(!ReadOnly)
0810 {
0811 m_traj->allocateCalibrated(m_istate, measdim);
0812 }
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822 template <typename val_t, typename cov_t>
0823 void allocateCalibrated(const Eigen::DenseBase<val_t>& val,
0824 const Eigen::DenseBase<cov_t>& cov)
0825 requires(!ReadOnly && Concepts::eigen_base_is_fixed_size<val_t> &&
0826 Concepts::eigen_bases_have_same_num_rows<val_t, cov_t> &&
0827 Concepts::eigen_base_is_square<cov_t> &&
0828 Eigen::PlainObjectBase<val_t>::RowsAtCompileTime <=
0829 static_cast<std::underlying_type_t<BoundIndices>>(eBoundSize))
0830 {
0831 m_traj->template allocateCalibrated<
0832 Eigen::PlainObjectBase<val_t>::RowsAtCompileTime>(m_istate, val, cov);
0833 }
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856
0857 void shareFrom(TrackStatePropMask shareSource, TrackStatePropMask shareTarget)
0858 requires(!ReadOnly)
0859 {
0860 shareFrom(*this, shareSource, shareTarget);
0861 }
0862
0863
0864
0865
0866
0867
0868 template <bool ReadOnlyOther>
0869 void shareFrom(const TrackStateProxy<Trajectory, M, ReadOnlyOther>& other,
0870 TrackStatePropMask component)
0871 requires(!ReadOnly)
0872 {
0873 shareFrom(other, component, component);
0874 }
0875
0876
0877
0878
0879
0880
0881
0882
0883 template <bool ReadOnlyOther>
0884 void shareFrom(const TrackStateProxy<Trajectory, M, ReadOnlyOther>& other,
0885 TrackStatePropMask shareSource, TrackStatePropMask shareTarget)
0886 requires(!ReadOnly)
0887 {
0888 assert(m_traj == other.m_traj &&
0889 "Cannot share components across MultiTrajectories");
0890
0891 assert(ACTS_CHECK_BIT(other.getMask(), shareSource) &&
0892 "Source has incompatible allocation");
0893
0894 m_traj->self().shareFrom(m_istate, other.m_istate, shareSource,
0895 shareTarget);
0896 }
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907 template <TrackStateProxyConcept track_state_proxy_t>
0908 void copyFrom(const track_state_proxy_t& other,
0909 TrackStatePropMask mask = TrackStatePropMask::All,
0910 bool onlyAllocated = true)
0911 requires(!ReadOnly)
0912 {
0913 using PM = TrackStatePropMask;
0914
0915 if (onlyAllocated) {
0916 auto dest = getMask();
0917 auto src = other.getMask() &
0918 mask;
0919
0920 if (ACTS_CHECK_BIT(src, PM::Calibrated)) {
0921
0922 dest |= PM::Calibrated;
0923 }
0924
0925 if ((static_cast<std::underlying_type_t<TrackStatePropMask>>(
0926 (src ^ dest) & src) != 0 ||
0927 dest == TrackStatePropMask::None ||
0928 src == TrackStatePropMask::None) &&
0929 mask != TrackStatePropMask::None) {
0930 throw std::runtime_error(
0931 "Attempt track state copy with incompatible allocations");
0932 }
0933
0934
0935 if (ACTS_CHECK_BIT(src, PM::Predicted)) {
0936 predicted() = other.predicted();
0937 predictedCovariance() = other.predictedCovariance();
0938 }
0939
0940 if (ACTS_CHECK_BIT(src, PM::Filtered)) {
0941 filtered() = other.filtered();
0942 filteredCovariance() = other.filteredCovariance();
0943 }
0944
0945 if (ACTS_CHECK_BIT(src, PM::Smoothed)) {
0946 smoothed() = other.smoothed();
0947 smoothedCovariance() = other.smoothedCovariance();
0948 }
0949
0950 if (other.hasUncalibratedSourceLink()) {
0951 setUncalibratedSourceLink(other.getUncalibratedSourceLink());
0952 }
0953
0954 if (ACTS_CHECK_BIT(src, PM::Jacobian)) {
0955 jacobian() = other.jacobian();
0956 }
0957
0958 if (ACTS_CHECK_BIT(src, PM::Calibrated)) {
0959 visit_measurement(other.calibratedSize(), [&](auto N) {
0960 constexpr int measdim = decltype(N)::value;
0961 allocateCalibrated(
0962 other.template calibrated<measdim>().eval(),
0963 other.template calibratedCovariance<measdim>().eval());
0964 });
0965
0966 setProjectorSubspaceIndices(other.projectorSubspaceIndices());
0967 }
0968 } else {
0969 if (ACTS_CHECK_BIT(mask, PM::Predicted) &&
0970 has<detail_tsp::kPredictedKey>() &&
0971 other.template has<detail_tsp::kPredictedKey>()) {
0972 predicted() = other.predicted();
0973 predictedCovariance() = other.predictedCovariance();
0974 }
0975
0976 if (ACTS_CHECK_BIT(mask, PM::Filtered) &&
0977 has<detail_tsp::kFilteredKey>() &&
0978 other.template has<detail_tsp::kFilteredKey>()) {
0979 filtered() = other.filtered();
0980 filteredCovariance() = other.filteredCovariance();
0981 }
0982
0983 if (ACTS_CHECK_BIT(mask, PM::Smoothed) &&
0984 has<detail_tsp::kSmoothedKey>() &&
0985 other.template has<detail_tsp::kSmoothedKey>()) {
0986 smoothed() = other.smoothed();
0987 smoothedCovariance() = other.smoothedCovariance();
0988 }
0989
0990 if (other.hasUncalibratedSourceLink()) {
0991 setUncalibratedSourceLink(other.getUncalibratedSourceLink());
0992 }
0993
0994 if (ACTS_CHECK_BIT(mask, PM::Jacobian) &&
0995 has<detail_tsp::kJacobianKey>() &&
0996 other.template has<detail_tsp::kJacobianKey>()) {
0997 jacobian() = other.jacobian();
0998 }
0999
1000
1001
1002 if (ACTS_CHECK_BIT(mask, PM::Calibrated) &&
1003 other.template has<detail_tsp::kCalibratedKey>()) {
1004 visit_measurement(other.calibratedSize(), [&](auto N) {
1005 constexpr int measdim = decltype(N)::value;
1006 allocateCalibrated(
1007 other.template calibrated<measdim>().eval(),
1008 other.template calibratedCovariance<measdim>().eval());
1009 });
1010
1011 setProjectorSubspaceIndices(other.projectorSubspaceIndices());
1012 }
1013 }
1014
1015 chi2() = other.chi2();
1016 pathLength() = other.pathLength();
1017 typeFlags() = other.typeFlags();
1018
1019 if (other.hasReferenceSurface()) {
1020 setReferenceSurface(other.referenceSurface().getSharedPtr());
1021 }
1022
1023 m_traj->copyDynamicFrom(m_istate, other.container(), other.index());
1024 }
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035 template <HashedString key>
1036 constexpr bool has() const {
1037 return m_traj->template has<key>(m_istate);
1038 }
1039
1040
1041
1042
1043 constexpr bool has(HashedString key) const {
1044 return m_traj->has(key, m_istate);
1045 }
1046
1047
1048
1049
1050
1051 constexpr bool has(std::string_view key) const {
1052 return has(hashStringDynamic(key));
1053 }
1054
1055
1056
1057
1058
1059 template <typename T, HashedString key>
1060 constexpr T& component()
1061 requires(!ReadOnly)
1062 {
1063 return m_traj->template component<T, key>(m_istate);
1064 }
1065
1066
1067
1068
1069
1070 template <typename T>
1071 constexpr T& component(HashedString key)
1072 requires(!ReadOnly)
1073 {
1074 return m_traj->template component<T>(key, m_istate);
1075 }
1076
1077
1078
1079
1080
1081
1082 template <typename T>
1083 constexpr T& component(std::string_view key)
1084 requires(!ReadOnly)
1085 {
1086 return m_traj->template component<T>(hashStringDynamic(key), m_istate);
1087 }
1088
1089
1090
1091
1092
1093 template <typename T, HashedString key>
1094 constexpr const T& component() const {
1095 return m_traj->template component<T, key>(m_istate);
1096 }
1097
1098
1099
1100
1101
1102 template <typename T>
1103 constexpr const T& component(HashedString key) const {
1104 return m_traj->template component<T>(key, m_istate);
1105 }
1106
1107
1108
1109
1110
1111
1112 template <typename T>
1113 constexpr const T& component(std::string_view key) const {
1114 return m_traj->template component<T>(hashStringDynamic(key), m_istate);
1115 }
1116
1117
1118
1119
1120
1121 MultiTrajectory<Trajectory>& trajectory()
1122 requires(!ReadOnly)
1123 {
1124 return *m_traj;
1125 }
1126
1127
1128
1129 const MultiTrajectory<Trajectory>& trajectory() const { return *m_traj; }
1130
1131
1132
1133 auto& container()
1134 requires(!ReadOnly)
1135 {
1136 return *m_traj;
1137 }
1138
1139
1140
1141 const auto& container() const { return *m_traj; }
1142
1143
1144
1145
1146 bool hasColumn(HashedString key) const { return container().hasColumn(key); }
1147
1148 private:
1149
1150 TrackStateProxy(
1151 detail_lt::ConstIf<MultiTrajectory<Trajectory>, ReadOnly>& trajectory,
1152 IndexType istate);
1153
1154 detail_lt::TransitiveConstPointer<
1155 detail_lt::ConstIf<MultiTrajectory<Trajectory>, ReadOnly>>
1156 m_traj;
1157 IndexType m_istate;
1158
1159 friend class Acts::MultiTrajectory<Trajectory>;
1160 friend class TrackStateProxy<Trajectory, M, true>;
1161 friend class TrackStateProxy<Trajectory, M, false>;
1162 };
1163 }
1164
1165 #include "Acts/EventData/TrackStateProxy.ipp"