ATLAS Offline Software
TrackContainer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTSTRKEVENT_TRACKCONTAINER_H
6 #define ACTSTRKEVENT_TRACKCONTAINER_H 1
7 
10 
11 namespace ActsTrk {
16 
17 template <typename T>
20  DataLinkHolder(const DataLink<T>& link) : m_link{link} {}
21 
22  const T& operator*() const { return *(m_link.cptr()); }
23  const T* operator->() const { return m_link.cptr(); }
24 };
25 
28 
30  public TrackContainerBase
31 {
32 public:
34  using value_type = ConstTrackProxy;
35  ConstTrackProxy operator[](unsigned int index) const {
36  return getTrack(index);
37  }
38  bool empty() const {
39  return size() == 0;
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.
49  {
50  public:
52  using ElementType = std::optional<ConstTrackProxy>;
55  if (src) {
56  m_proxy = *src;
57  }
58  }
61  ConstTrackProxyPtr(const ConstTrackProxy &val) :m_proxy(val) {}
62  ConstTrackProxyPtr(ConstTrackProxy &&val) : m_proxy(std::move(val)) {}
63 
64  ConstTrackProxy operator*() const {
65  return m_proxy.value();
66  }
67  const ConstTrackProxy *operator->() const {
68  return &m_proxy.value();
69  }
70  bool operator!() const {
71  return !m_proxy.has_value();
72  }
74  if (src) {
75  m_proxy = *src;
76  }
77  else {
78  m_proxy.reset();
79  }
80  return *this;
81  }
82 
83  std::optional<ConstTrackProxy> m_proxy;
84  };
85  using ElementConstReference = std::optional<ConstTrackProxy>;
87 
90 
93 
94  static bool isValid (const stored_index_type& index) {
95  return index != ConstTrackProxy::kInvalid;
96  }
97 
99  return index;
100  }
101  static void reset (stored_index_type& index) {
102  index=ConstTrackProxy::kInvalid;
103  }
104  static
106  return container.getTrack(index);
107  }
108 
109  static void
110  reverseLookup([[maybe_unused]] const TrackContainerBase& container,
111  ElementConstReference element,
112  index_type& index) {
113  index= element.has_value() ? element.value().index() : ConstTrackProxy::kInvalid;
114  }
115  };
116 
117 };
118 
120  : public Acts::TrackContainer<ActsTrk::MutableTrackBackend,
121  ActsTrk::MutableTrackStateBackend,
122  Acts::detail::ValueHolder> {
126  Acts::detail::ValueHolder>(
128 };
129 
130 } // namespace ActsTrk
131 
132 // register special indexing policy for element links to Acts tracks i.e.
133 // ElementLink<ActsTrk::TrackContainer>
134 template <>
135 struct DefaultIndexingPolicy <ActsTrk::TrackContainer > {
137 };
138 
139 
140 #include "AthenaKernel/CLASS_DEF.h"
141 CLASS_DEF(ActsTrk::TrackContainer, 1210898253, 1)
142 #endif
ActsTrk::TrackContainer::IndexingPolicy::reverseLookup
static void reverseLookup([[maybe_unused]] const TrackContainerBase &container, ElementConstReference element, index_type &index)
Definition: TrackContainer.h:110
TrackSummaryContainer.h
ActsTrk::TrackContainerBase
Acts::TrackContainer< ActsTrk::TrackBackend, ActsTrk::TrackStateBackend, ActsTrk::DataLinkHolder > TrackContainerBase
Definition: TrackContainer.h:27
ActsTrk::TrackContainer
Definition: TrackContainer.h:31
ActsTrk::TrackContainer::operator[]
ConstTrackProxy operator[](unsigned int index) const
Definition: TrackContainer.h:35
ActsTrk::TrackContainer::IndexingPolicy::lookup
static ElementType lookup(const stored_index_type &index, const TrackContainerBase &container)
Definition: TrackContainer.h:105
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::ConstTrackProxyPtr
ConstTrackProxyPtr(const ElementType *src)
Definition: TrackContainer.h:54
ActsTrk::TrackStateBackend
ActsTrk::MultiTrajectory TrackStateBackend
Definition: TrackContainer.h:15
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
index
Definition: index.py:1
ActsTrk::DataLinkHolder::operator*
const T & operator*() const
Definition: TrackContainer.h:22
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr
Definition: TrackContainer.h:53
ActsTrk::MutableTrackContainer::MutableTrackContainer
MutableTrackContainer()
Definition: TrackContainer.h:123
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::operator=
ConstTrackProxyPtr & operator=(const ElementType *src)
Definition: TrackContainer.h:73
ActsTrk::TrackBackend
ActsTrk::TrackSummaryContainer TrackBackend
Definition: TrackContainer.h:13
ActsTrk::TrackContainer::IndexingPolicy::stored_index_type
index_type stored_index_type
The type of an index, as stored internally within a link.
Definition: TrackContainer.h:92
detail
Definition: extract_histogram_tag.cxx:14
ActsTrk::MultiTrajectory
Read only version of MTJ The implementation is separate as the details are significantly different an...
Definition: MultiTrajectory.h:405
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::ConstTrackProxyPtr
ConstTrackProxyPtr(ConstTrackProxyPtr &&)=default
ActsTrk::TrackContainer::IndexingPolicy::storedToExternal
static index_type storedToExternal(stored_index_type index)
Definition: TrackContainer.h:98
ActsTrk::TrackContainer::IndexingPolicy::ElementConstReference
std::optional< ConstTrackProxy > ElementConstReference
Definition: TrackContainer.h:85
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::operator->
const ConstTrackProxy * operator->() const
Definition: TrackContainer.h:67
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::ConstTrackProxyPtr
ConstTrackProxyPtr(const ConstTrackProxy &val)
Definition: TrackContainer.h:61
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::m_proxy
std::optional< ConstTrackProxy > m_proxy
Definition: TrackContainer.h:83
ActsTrk::DataLinkHolder
Definition: TrackContainer.h:18
xAOD::TrackSummaryContainer
TrackSummaryContainer_v1 TrackSummaryContainer
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackSummaryContainer.h:11
ActsTrk::MutableMultiTrajectory
Athena implementation of ACTS::MultiTrajectory (ReadWrite version) The data is stored in 4 external b...
Definition: MultiTrajectory.h:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ActsTrk::TrackContainer::IndexingPolicy::reset
static void reset(stored_index_type &index)
Definition: TrackContainer.h:101
ActsTrk::TrackContainer::IndexingPolicy::isValid
static bool isValid(const stored_index_type &index)
Definition: TrackContainer.h:94
ActsTrk::IndexType
std::uint32_t IndexType
Definition: Decoration.h:13
Acts
Definition: MultiTrajectory.h:45
ActsTrk::MutableTrackSummaryContainer
Definition: Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h:118
ActsTrk::TrackContainer::IndexingPolicy::ElementType
std::optional< ConstTrackProxy > ElementType
The type we get when we dereference a link, and derived types.
Definition: TrackContainer.h:52
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::ConstTrackProxyPtr
ConstTrackProxyPtr(ConstTrackProxy &&val)
Definition: TrackContainer.h:62
ActsTrk::TrackSummaryContainer
Definition: Tracking/Acts/ActsEvent/ActsEvent/TrackSummaryContainer.h:56
ActsTrk::TrackContainer::empty
bool empty() const
Definition: TrackContainer.h:38
DefaultIndexingPolicy
Definition: DefaultIndexingPolicy.h:23
ActsTrk::TrackContainer::IndexingPolicy
Definition: TrackContainer.h:49
ActsTrk::DataLinkHolder::DataLinkHolder
DataLinkHolder(const DataLink< T > &link)
Definition: TrackContainer.h:20
ActsTrk::DataLinkHolder::operator->
const T * operator->() const
Definition: TrackContainer.h:23
MultiTrajectory.h
ActsTrk::TrackContainer::IndexingPolicy::index_type
TrackContainerBase::IndexType index_type
The type of an index, as provided to or returned from a link.
Definition: TrackContainer.h:89
DeMoScan.index
string index
Definition: DeMoScan.py:362
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::operator*
ConstTrackProxy operator*() const
Definition: TrackContainer.h:64
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::operator!
bool operator!() const
Definition: TrackContainer.h:70
ActsTrk::TrackContainer::IndexingPolicy::ConstTrackProxyPtr::ConstTrackProxyPtr
ConstTrackProxyPtr(const ConstTrackProxyPtr &)=default
ActsTrk::DataLinkHolder::m_link
DataLink< T > m_link
Definition: TrackContainer.h:19
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:34
value_type
Definition: EDM_MasterSearch.h:11
ActsTrk::MutableTrackContainer
Definition: TrackContainer.h:122
CLASS_DEF.h
macros to associate a CLID to a type