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