20 #include <type_traits>
24 template <
ACTS_CONCEPT(Acts::TrackContainerBackend) track_container_t,
25 typename traj_t, template <typename> class holder_t>
29 template <
typename T,
bool select>
30 using ConstIf = std::conditional_t<select, const T, T>;
33 template <
typename container_t,
typename proxy_t,
bool ReadOnly>
46 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
48 : m_container(&container), m_itrack(itrack) {}
50 template <
bool RO = ReadOnly,
typename = std::enable_if_t<RO>>
52 : m_container(&container), m_itrack(itrack) {}
68 return !(*
this == other);
89 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
91 return m_container->getTrack(m_itrack);
150 template <
typename track_container_t,
typename trajectory_t,
151 template <
typename>
class holder_t,
bool read_only =
true>
189 : m_container{other.m_container},
m_index{other.m_index} {}
195 m_container = other.m_container;
205 typename = std::enable_if_t<!RO>>
206 constexpr
T& component() {
207 return m_container->template component<T, key>(
m_index);
214 template <
typename T,
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
216 return m_container->template component<T>(key,
m_index);
224 template <
typename T,
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
225 constexpr
T& component(std::string_view key) {
233 template <
typename T, HashedString key>
234 constexpr
const T& component()
const {
235 return m_container->template component<T, key>(
m_index);
242 template <
typename T>
244 return m_container->template component<T>(key,
m_index);
252 template <
typename T>
253 constexpr
const T& component(std::string_view key)
const {
260 return component<IndexType>(
hashString(
"tipIndex"));
268 return component<IndexType>(
hashString(
"stemIndex"));
274 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
276 return component<IndexType>(
hashString(
"tipIndex"));
283 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
285 return component<IndexType>(
hashString(
"stemIndex"));
291 auto innermostTrackState()
const {
292 using proxy_t = decltype(m_container->trackStateContainer().getTrackState(
293 std::declval<IndexType>()));
297 return std::optional<proxy_t>{};
299 return std::optional<proxy_t>{
300 m_container->trackStateContainer().getTrackState(stem)};
307 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
308 auto innermostTrackState() {
309 using proxy_t = decltype(m_container->trackStateContainer().getTrackState(
310 std::declval<IndexType>()));
314 return std::optional<proxy_t>{};
316 return std::optional<proxy_t>{
317 m_container->trackStateContainer().getTrackState(stem)};
323 const Surface& referenceSurface()
const {
324 return *m_container->container().referenceSurface_impl(
m_index);
331 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
332 void setReferenceSurface(std::shared_ptr<const Surface> srf) {
339 bool hasReferenceSurface()
const {
341 return m_container->container().referenceSurface_impl(
m_index) !=
nullptr;
348 return m_container->parameters(
m_index);
355 return m_container->covariance(
m_index);
361 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
363 return m_container->parameters(
m_index);
369 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
371 return m_container->covariance(
m_index);
413 return component<ParticleHypothesis,
hashString(
"particleHypothesis")>();
418 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
420 m_container->container().setParticleHypothesis_impl(
m_index,
440 return std::sin(
theta()) * absoluteMomentum();
452 return absoluteMomentum() * direction();
459 auto trackStatesReversed()
const {
460 return m_container->reverseTrackStateRange(
m_index);
467 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
468 auto trackStatesReversed() {
469 return m_container->reverseTrackStateRange(
m_index);
476 auto trackStates()
const {
477 return m_container->forwardTrackStateRange(
m_index);
484 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
486 return m_container->forwardTrackStateRange(
m_index);
491 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
494 for (
auto ts : trackStatesReversed()) {
495 ts.template component<IndexType>(
hashString(
"next")) = last;
506 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
508 auto& tsc = m_container->trackStateContainer();
509 auto ts = tsc.getTrackState(tsc.addTrackState(
mask, tipIndex()));
510 tipIndex() = ts.index();
519 unsigned int nTrackStates()
const {
526 auto tsRange = trackStatesReversed();
532 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
533 unsigned int& nMeasurements() {
534 return component<unsigned int>(
hashString(
"nMeasurements"));
540 unsigned int nMeasurements()
const {
541 return component<unsigned int>(
hashString(
"nMeasurements"));
547 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
548 unsigned int& nHoles() {
549 return component<unsigned int>(
hashString(
"nHoles"));
554 unsigned int nHoles()
const {
555 return component<unsigned int>(
hashString(
"nHoles"));
561 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
562 unsigned int& nOutliers() {
563 return component<unsigned int>(
hashString(
"nOutliers"));
568 unsigned int nOutliers()
const {
569 return component<unsigned int>(
hashString(
"nOutliers"));
575 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
576 unsigned int& nSharedHits() {
577 return component<unsigned int>(
hashString(
"nSharedHits"));
582 unsigned int nSharedHits()
const {
583 return component<unsigned int>(
hashString(
"nSharedHits"));
589 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
603 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
604 unsigned int& nDoF() {
605 return component<unsigned int>(
hashString(
"ndf"));
610 unsigned int nDoF()
const {
611 return component<unsigned int>(
hashString(
"ndf"));
623 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
632 template <
typename track_proxy_t,
bool RO =
ReadOnly,
633 typename = std::enable_if_t<!RO>>
634 void copyFrom(
const track_proxy_t& other,
bool copyTrackStates =
true) {
638 if (copyTrackStates) {
640 for (
const auto& srcTrackState : other.trackStatesReversed()) {
641 auto destTrackState = appendTrackState(srcTrackState.getMask());
642 if (srcTrackState.hasCalibrated()) {
643 destTrackState.allocateCalibrated(srcTrackState.calibratedSize());
645 destTrackState.copyFrom(srcTrackState, Acts::TrackStatePropMask::All,
650 reverseTrackStates();
655 setParticleHypothesis(other.particleHypothesis());
656 if (other.hasReferenceSurface()) {
657 setReferenceSurface(other.referenceSurface().getSharedPtr());
659 nMeasurements() = other.nMeasurements();
660 nHoles() = other.nHoles();
661 nOutliers() = other.nOutliers();
662 nSharedHits() = other.nSharedHits();
663 chi2() = other.chi2();
664 nDoF() = other.nDoF();
667 m_container->copyDynamicFrom(
m_index, other.m_container->container(),
677 template <
bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
678 void reverseTrackStates(
bool invertJacobians =
false) {
683 stemIndex() = tipIndex();
689 auto ts = m_container->trackStateContainer().getTrackState(current);
690 prev = ts.previous();
691 ts.template component<IndexType>(
hashString(
"next")) = prev;
692 ts.previous() =
next;
693 if (invertJacobians) {
696 ts.jacobian() = nextJacobian.inverse();
697 nextJacobian = curJacobian;
699 nextJacobian = ts.jacobian();
700 ts.jacobian().setZero();
704 tipIndex() = current;
719 return &(*m_container) == &(*other.m_container) &&
m_index == other.m_index;
723 template <
typename A,
typename B,
template <
typename>
class H,
bool R>