33 #include <type_traits>
41 template <
typename derived_t>
47 template <
typename T,
bool select>
48 using ConstIf = std::conditional_t<select, const T, T>;
59 :
m_ptr{other.ptr()} {}
68 bool operator==(
const TransitiveConstPointer<U>& other)
const {
69 return m_ptr == other.m_ptr;
72 const T* operator->()
const {
return m_ptr; }
74 T* operator->() {
return m_ptr; }
90 template <
size_t Size,
bool ReadOnlyMaps = true>
93 Flags = Eigen::ColMajor | Eigen::AutoAlign,
99 using Covariance = Eigen::Matrix<Scalar, Size, Size, Flags>;
105 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Flags>;
107 Eigen::Map<ConstIf<DynamicCoefficients, ReadOnlyMaps>>;
109 Eigen::Map<ConstIf<DynamicCovariance, ReadOnlyMaps>>;
114 template <
size_t M,
bool ReadOnly = true>
126 Eigen::Matrix<typename Covariance::Scalar, M, eBoundSize, ProjectorFlags>;
129 namespace detail_lt {
136 template <
typename trajectory_t,
size_t M,
bool ReadOnly = true>
196 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
203 bool hasPrevious()
const {
218 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
221 shareFrom(*
this, shareSource, shareTarget);
231 template <
bool RO = ReadOnly,
bool ReadOnlyOther,
232 typename = std::enable_if_t<!RO>>
244 template <
bool RO = ReadOnly,
bool ReadOnlyOther,
245 typename = std::enable_if_t<!RO>>
250 "Cannot share components across MultiTrajectories");
253 "Source has incompatible allocation");
268 template <
ACTS_CONCEPT(TrackStateProxyConcept) track_state_proxy_t,
269 bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
272 bool onlyAllocated =
true) {
278 auto dest = getMask();
279 auto src = other.getMask() &
284 dest |= PM::Calibrated;
287 if ((
static_cast<std::underlying_type_t<TrackStatePropMask>
>(
288 (src ^
dest) & src) != 0 ||
289 dest == TrackStatePropMask::None ||
290 src == TrackStatePropMask::None) &&
291 mask != TrackStatePropMask::None) {
292 throw std::runtime_error(
293 "Attempt track state copy with incompatible allocations");
312 if (other.hasUncalibratedSourceLink()) {
327 constexpr
int measdim = decltype(
N)::
value;
328 self->template calibrated<measdim>() =
329 other.template calibrated<measdim>();
330 self->template calibratedCovariance<measdim>() =
331 other.template calibratedCovariance<measdim>();
356 if (other.hasUncalibratedSourceLink()) {
374 constexpr
int measdim = decltype(
N)::
value;
375 self->template calibrated<measdim>() =
376 other.template calibrated<measdim>();
377 self->template calibratedCovariance<measdim>() =
378 other.template calibratedCovariance<measdim>();
385 chi2() = other.chi2();
389 if (other.hasReferenceSurface()) {
396 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
405 "TrackState does not have reference surface");
421 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
430 template <HashedString key>
431 constexpr
bool has()
const {
446 constexpr
bool has(std::string_view key)
const {
455 typename = std::enable_if_t<!RO>>
464 template <
typename T,
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
474 template <
typename T,
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
483 template <
typename T, HashedString key>
492 template <
typename T>
502 template <
typename T>
524 return m_traj->self().parameters(
528 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
531 return m_traj->self().parameters(
539 return m_traj->self().covariance(
543 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
546 return m_traj->self().covariance(
559 return m_traj->self().parameters(
566 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
569 return m_traj->self().parameters(
578 return m_traj->self().covariance(
585 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
588 return m_traj->self().covariance(
601 return m_traj->self().parameters(
608 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
611 return m_traj->self().parameters(
620 return m_traj->self().covariance(
627 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
630 return m_traj->self().covariance(
649 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
687 template <
typename Derived,
bool RO = ReadOnly,
688 typename = std::enable_if_t<!RO>>
690 constexpr
int rows = Eigen::MatrixBase<Derived>::RowsAtCompileTime;
691 constexpr
int cols = Eigen::MatrixBase<Derived>::ColsAtCompileTime;
693 static_assert(rows != -1 && cols != -1,
694 "Assignment of dynamic matrices is currently not supported.");
698 static_assert(rows <= M,
"Given projector has too many rows");
699 static_assert(cols <=
eBoundSize,
"Given projector has too many columns");
703 decltype(fullProjector)::Zero();
707 fullProjector.template topLeftCorner<rows, cols>() = projector;
712 projectorBitset.to_ullong();
730 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
742 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
761 template <
size_t measdim>
771 template <
size_t measdim,
bool RO = ReadOnly,
772 typename = std::enable_if_t<!RO>>
782 template <
size_t measdim>
785 return m_traj->self().template measurementCovariance<measdim>(
m_istate);
792 template <
size_t measdim,
bool RO = ReadOnly,
793 typename = std::enable_if_t<!RO>>
796 return m_traj->self().template measurementCovariance<measdim>(
m_istate);
802 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
809 constexpr
int kMeasurementSize = decltype(
N)::
value;
811 self->template calibrated<kMeasurementSize>().
data(),
825 constexpr
int kMeasurementSize = decltype(
N)::
value;
827 self->template calibrated<kMeasurementSize>().
data(),
835 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
842 constexpr
int kMeasurementSize = decltype(
N)::
value;
844 self->template calibratedCovariance<kMeasurementSize>().
data(),
845 kMeasurementSize, kMeasurementSize};
858 constexpr
int kMeasurementSize = decltype(
N)::
value;
860 self->template calibratedCovariance<kMeasurementSize>().
data(),
861 kMeasurementSize, kMeasurementSize};
881 template <
size_t kMeasurementSize,
bool RO = ReadOnly,
882 typename = std::enable_if_t<!RO>>
885 static_assert(kMeasurementSize <= M,
886 "Input measurement must be within the allowed size");
891 calibrated<kMeasurementSize>().setZero();
892 calibrated<kMeasurementSize>().
template head<kMeasurementSize>() =
894 calibratedCovariance<kMeasurementSize>().setZero();
895 calibratedCovariance<kMeasurementSize>()
896 .
template topLeftCorner<kMeasurementSize, kMeasurementSize>() =
910 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
925 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
940 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
953 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
974 template <
bool reverse,
typename trajectory_t,
size_t M,
bool ReadOnly>
996 if constexpr (reverse) {
997 if (proxy->hasPrevious()) {
998 proxy = proxy->trajectory().getTrackState(proxy->previous());
1001 proxy = std::nullopt;
1008 proxy = proxy->trajectory().getTrackState(next);
1011 proxy = std::nullopt;
1018 if (!proxy && !other.
proxy) {
1021 if (proxy && other.
proxy) {
1022 return proxy->index() == other.
proxy->index();
1034 TrackStateRange() : m_begin{std::nullopt} {}
1036 Iterator
begin() {
return m_begin; }
1037 Iterator
end() {
return Iterator{std::nullopt}; }
1044 template <
typename T,
typename TS>
1047 template <
typename T,
typename TS>
1049 Concepts ::either<Concepts ::identical_to<bool, call_operator_t, T, TS>,
1050 Concepts ::identical_to<void, call_operator_t, T, TS>>>;
1057 namespace MultiTrajectoryTraits {
1063 template <
typename T>
1074 template <
typename derived_t>
1102 return static_cast<const Derived&
>(*this);
1108 using namespace Acts::HashedStringLiteral;
1110 case "predicted"_hash:
1111 case "filtered"_hash:
1112 case "smoothed"_hash:
1113 case "calibrated"_hash:
1114 case "jacobian"_hash:
1115 case "projector"_hash:
1116 return self().has_impl(key, istate);
1127 return {*
this, istate};
1133 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1135 return {*
this, istate};
1142 template <
typename F>
1143 void visitBackwards(
IndexType iendpoint, F&& callable)
const;
1156 return range_t{getTrackState(iendpoint)};
1164 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1172 return range_t{getTrackState(iendpoint)};
1188 return range_t{getTrackState(istartpoint)};
1196 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1204 return range_t{getTrackState(istartpoint)};
1214 template <
typename F,
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1216 static_assert(detail_lt::VisitorConcept<F, TrackStateProxy>,
1217 "Callable needs to satisfy VisitorConcept");
1220 throw std::runtime_error(
1221 "Cannot apply backwards with kInvalid as endpoint");
1225 auto ts = getTrackState(iendpoint);
1226 if constexpr (std::is_same_v<std::invoke_result_t<F, TrackStateProxy>,
1228 bool proceed = callable(ts);
1231 if (!proceed || !ts.hasPrevious()) {
1237 if (!ts.hasPrevious()) {
1241 iendpoint = ts.previous();
1246 auto&& cv =
self().convertToReadOnly_impl();
1249 "convertToReadOnly_impl does not return something that reports "
1255 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1257 self().clear_impl();
1269 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1273 return self().addTrackState_impl(
mask, iprevious);
1280 template <
typename T,
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1282 self().
template addColumn_impl<T>(key);
1289 return self().hasColumn_impl(key);
1300 return self().has_impl(key, istate);
1307 template <HashedString key>
1309 return self().has_impl(key, istate);
1315 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1317 return self().parameters_impl(parIdx);
1325 return self().parameters_impl(parIdx);
1331 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1333 return self().covariance_impl(covIdx);
1341 return self().covariance_impl(covIdx);
1347 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1349 return self().jacobian_impl(jacIdx);
1357 return self().jacobian_impl(jacIdx);
1364 template <
size_t measdim,
bool RO = ReadOnly,
1365 typename = std::enable_if_t<!RO>>
1368 return self().
template measurement_impl<measdim>(measIdx);
1375 template <
size_t measdim>
1378 return self().
template measurement_impl<measdim>(measIdx);
1386 template <
size_t measdim,
bool RO = ReadOnly,
1387 typename = std::enable_if_t<!RO>>
1388 constexpr
typename TrackStateProxy::template MeasurementCovariance<measdim>
1390 return self().
template measurementCovariance_impl<measdim>(covIdx);
1397 template <
size_t measdim>
1399 typename ConstTrackStateProxy::template MeasurementCovariance<measdim>
1401 return self().
template measurementCovariance_impl<measdim>(covIdx);
1408 return self().calibratedSize_impl(istate);
1421 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1425 self().shareFrom_impl(iself, iother, shareSource, shareTarget);
1431 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1433 self().unset_impl(target, istate);
1442 typename = std::enable_if_t<!RO>>
1444 assert(checkOptional(key, istate));
1445 return *std::any_cast<
T*>(
self().component_impl(key, istate));
1453 template <
typename T,
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1455 assert(checkOptional(key, istate));
1456 return *std::any_cast<
T*>(
self().component_impl(key, istate));
1464 template <
typename T, HashedString key>
1466 assert(checkOptional(key, istate));
1467 return *std::any_cast<
const T*>(
self().component_impl(key, istate));
1475 template <
typename T>
1477 assert(checkOptional(key, istate));
1478 return *std::any_cast<
const T*>(
self().component_impl(key, istate));
1488 "Invalid measurement dimension detected");
1490 self().allocateCalibrated_impl(istate, measdim);
1493 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1495 self().setUncalibratedSourceLink_impl(istate,
std::move(sourceLink));
1499 return self().getUncalibratedSourceLink_impl(istate);
1503 return self().referenceSurface_impl(istate);
1506 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
1508 std::shared_ptr<const Surface>
surface) {
1509 self().setReferenceSurface_impl(istate,
std::move(surface));