ATLAS Offline Software
Loading...
Searching...
No Matches
TrackContainer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ACTSTRKEVENT_TRACKCONTAINER_H
6#define ACTSTRKEVENT_TRACKCONTAINER_H 1
7
10#include "Acts/EventData/TrackContainer.hpp"
11#include "Acts/EventData/VectorTrackContainer.hpp"
12#include "Acts/EventData/VectorMultiTrajectory.hpp"
13
14namespace ActsTrk {
15 using TrackBackend = Acts::ConstVectorTrackContainer;
16 using MutableTrackBackend = Acts::VectorTrackContainer;
17 using TrackStateBackend = Acts::ConstVectorMultiTrajectory;
18 using MutableTrackStateBackend = Acts::VectorMultiTrajectory;
19
20 // Containers without xAOD backends - this is for transient objects
21 using TrackContainerBase = Acts::TrackContainer<TrackBackend,
23 Acts::detail::ValueHolder>;
24
25 using MutableTrackContainer = Acts::TrackContainer<MutableTrackBackend,
27 Acts::detail::ValueHolder>;
28
29
31 : public TrackContainerBase {
32 public:
33 //coverity[pass_by_value]
34 using TrackContainerBase::TrackContainerBase;
35 using value_type = typename TrackContainerBase::ConstTrackProxy;
36
37 ConstTrackProxy operator[](unsigned int index) const { return getTrack(index); }
38 bool empty() const { return size() == 0; }
39 };
40
41
42 // Special indexing policy which will dereference element links
43 // into an std::optional rather than a pointer or reference to an
44 // existing element in the destination collection. This is
45 // needed because the Acts track container does have physical
46 // representations of tracks, but only creats proxy objects
47 // for tracks which are created on demand.
48 template <typename track_container_t>
50 public:
52 using ConstTrackProxy = typename track_container_t::ConstTrackProxy;
54 using ElementType = std::optional<ConstTrackProxy>;
55
58 if (src) {
59 m_proxy = *src;
60 }
61 }
66
68 return m_proxy.value();
69 }
70 const ConstTrackProxy *operator->() const {
71 return &m_proxy.value();
72 }
73 bool operator!() const {
74 return !m_proxy.has_value();
75 }
77 if (src) {
78 m_proxy = *src;
79 }
80 else {
81 m_proxy.reset();
82 }
83 return *this;
84 }
85
86 std::optional<ConstTrackProxy> m_proxy {std::nullopt};
87 };
88
89 using ElementConstReference = std::optional<ConstTrackProxy>;
91
93 using index_type = track_container_t::IndexType;
94
97
98 static bool isValid (const stored_index_type& index) {
99 return index != ConstTrackProxy::kInvalid;
100 }
101
105
107 index=ConstTrackProxy::kInvalid;
108 }
109
110 static
111 ElementType lookup(const stored_index_type& index, const track_container_t& container) {
112 return container.getTrack(index);
113 }
114
115 static void
116 reverseLookup([[maybe_unused]] const track_container_t& container,
117 ElementConstReference element,
118 index_type& index) {
119 index = element.has_value() ? element.value().index() : ConstTrackProxy::kInvalid;
120 }
121 };
122
123} // namespace ActsTrk
124
125// register special indexing policy for element links to Acts tracks i.e.
126// ElementLink<ActsTrk::TrackContainer>
127template <>
131
134
135#endif
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
ConstTrackProxyPtr ElementConstPointer
std::optional< ConstTrackProxy > ElementType
The type we get when we dereference a link, and derived types.
static void reverseLookup(const track_container_t &container, ElementConstReference element, index_type &index)
static ElementType lookup(const stored_index_type &index, const track_container_t &container)
static void reset(stored_index_type &index)
std::optional< ConstTrackProxy > ElementConstReference
static bool isValid(const stored_index_type &index)
track_container_t::IndexType index_type
The type of an index, as provided to or returned from a link.
typename track_container_t::ConstTrackProxy ConstTrackProxy
The type of the const track proxy.
index_type stored_index_type
The type of an index, as stored internally within a link.
static index_type storedToExternal(stored_index_type index)
ConstTrackProxy operator[](unsigned int index) const
typename TrackContainerBase::ConstTrackProxy value_type
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Acts::TrackContainer< TrackBackend, TrackStateBackend, Acts::detail::ValueHolder > TrackContainerBase
Acts::VectorMultiTrajectory MutableTrackStateBackend
Acts::ConstVectorTrackContainer TrackBackend
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Acts::VectorTrackContainer MutableTrackBackend
Acts::ConstVectorMultiTrajectory TrackStateBackend
Definition index.py:1
STL namespace.
ConstTrackProxyPtr(const ConstTrackProxyPtr &)=default
std::optional< ConstTrackProxy > m_proxy
const ConstTrackProxy * operator->() const
ConstTrackProxyPtr(ConstTrackProxyPtr &&)=default
ConstTrackProxyPtr & operator=(const ElementType *src)
ConstTrackProxyPtr(const ConstTrackProxy &val)
typename ActsTrk::IndexingPolicy< ActsTrk::TrackContainer > type