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