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