Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Dec 12, 2023
1 parent 3634e24 commit 4126080
Show file tree
Hide file tree
Showing 15 changed files with 2,168 additions and 285 deletions.
164 changes: 118 additions & 46 deletions Core/include/Acts/EventData/TrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,31 @@ template <ACTS_CONCEPT(TrackContainerBackend) track_container_t,
template <typename> class holder_t = detail::RefHolder>
class TrackContainer {
public:
/// Indicates if this track container is read-only, or if it can be modified
static constexpr bool ReadOnly =
IsReadOnlyTrackContainer<track_container_t>::value;

/// Indicates it the track state container is read-only, or if it can be
static constexpr bool TrackStateReadOnly =
IsReadOnlyMultiTrajectory<traj_t>::value;

static_assert(ReadOnly == TrackStateReadOnly,
"Either both track container and track state container need to "
"be readonly or both have to be readwrite");

/// The index type of the track container, taken from the container backend
using IndexType = TrackIndexType;

/// Sentinel value that indicates an invalid index
static constexpr IndexType kInvalid = kTrackIndexInvalid;

/// Alias for the mutable version of a track proxy, with the same backends as
/// this container
using TrackProxy =
Acts::TrackProxy<track_container_t, traj_t, holder_t, false>;

/// Alias for the const version of a track proxy, with the same backends as
/// this container
using ConstTrackProxy =
Acts::TrackProxy<track_container_t, traj_t, holder_t, true>;

Expand All @@ -62,6 +73,17 @@ class TrackContainer {
friend ConstTrackProxy;
#endif

/// @anchor track_container_construction
/// @name TrackContainer construction
///
/// Constructors for the track container by using a set of backends
/// (track+track state). The container can either take ownership of the
/// backends or just hold references to them. This is driven by the @c
/// holder_t template parameter, where you can also supply a custom holder
/// type. Template deduction is used to try to guess the correct holder type.
///
/// @{

/// Constructor from a track container backend and a track state container
/// backend
/// @param container the track container backend
Expand Down Expand Up @@ -96,6 +118,16 @@ class TrackContainer {
TrackContainer(const track_container_t& container, const traj_t& traj)
: m_container{&container}, m_traj{&traj} {}

/// @}

/// @anchor track_container_track_access
/// @name TrackContainer track (proxy) access and manipulation
///
/// These methods allow accessing tracks, i.e. adding or retrieving a track
/// proxy that points at a specific track in the container.
///
/// @{

/// Get a const track proxy for a track index
/// @param itrack the track index in the container
/// @return A const track proxy for the index
Expand All @@ -104,21 +136,17 @@ class TrackContainer {
}

/// Get a mutable track proxy for a track index
/// @note Only available if the track container is not read-only
/// @param itrack the track index in the container
/// @return A mutable track proxy for the index
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
TrackProxy getTrack(IndexType itrack) {
return {*this, itrack};
}

/// Get the size of the track container
/// @return the sixe
constexpr IndexType size() const {
return m_container->size_impl();
}

/// Add a track to the container. Note this only creates the logical track and
/// allocates memory. You can combine this with @c getTrack to obtain a track proxy
/// @note Only available if the track container is not read-only
/// @return the index to the newly added track
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
IndexType addTrack() {
Expand All @@ -127,15 +155,68 @@ class TrackContainer {
return track.index();
}

/// Add a track to the container and return a track proxy to it
/// This effectively calls @c addTrack and @c getTrack
/// @note Only available if the track container is not read-only
/// @return a track proxy to the newly added track
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
TrackProxy makeTrack() {
return getTrack(addTrack());
}

/// Remove a track at index @p itrack from the container
/// @note This invalidates all track proxies!
/// @note Only available if the track container is not read-only
/// @note This invalidates track proxies that point to tracks with larger
/// indices than @p itrack!
/// @param itrack The index of the track to remove
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void removeTrack(IndexType itrack) {
m_container->removeTrack_impl(itrack);
}

/// Get a mutable iterator to the first track in the container
/// @note Only available if the track container is not read-only
/// @return a mutable iterator to the first track
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto begin() {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
TrackProxy, false>{*this, 0};
}

/// Get a past-the-end iterator for this container
/// @note Only available if the track container is not read-only
/// @return a past-the-end iterator
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto end() {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
TrackProxy, false>{*this, size()};
}

/// Get an const iterator to the first track in the container
/// @return a const iterator to the first track
auto begin() const {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
ConstTrackProxy, true>{*this, 0};
}

/// Get a past-the-end iterator for this container
/// @return a past-the-end iterator
auto end() const {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
ConstTrackProxy, true>{*this, size()};
}

/// @}

/// @anchor track_container_columns
/// @name TrackContainer column management
/// TrackContainer can manage a set of common static columns, and dynamic
/// columns that can be added at runtime. This set of methods allows you to
/// manage the dynamic columns.
/// @{

/// Add a dymanic column to the track container
/// @note Only available if the track container is not read-only
/// @param key the name of the column to be added
template <typename T, bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
constexpr void addColumn(const std::string& key) {
Expand All @@ -154,7 +235,29 @@ class TrackContainer {
return m_container->hasColumn_impl(key);
}

/// Helper function to make this track container match the dynamic columns of
/// another one. This will only work if the track container supports this
/// source, and depends on the implementation details of the dynamic columns
/// of the container
/// @note Only available if the track container is not read-only
/// @tparam other_track_container_t Type of the other track container
/// @param other The other track container
template <typename other_track_container_t, bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
void ensureDynamicColumns(const other_track_container_t& other) {
container().ensureDynamicColumns_impl(other.container());
}

/// @}

/// @anchor track_congtainer_backend_access
/// @name TrackContainer backend access
/// These methods allow accessing the backend of the track container. In most
/// cases, this is not necessary for interacting with the container.
/// @{

/// Get a mutable reference to the track container backend
/// @note Only available if the track container is not read-only
/// @return a mutable reference to the backend
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto& container() {
Expand All @@ -168,6 +271,7 @@ class TrackContainer {
}

/// Get a mutable reference to the track state container backend
/// @note Only available if the track container is not read-only
/// @return a mutable reference to the backend
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto& trackStateContainer() {
Expand All @@ -176,6 +280,7 @@ class TrackContainer {

/// Retrieve the holder of the track state container
/// @return The track state container including it's holder
/// @note Only available if the track container is not read-only
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto& trackStateContainerHolder() {
return m_traj;
Expand All @@ -193,49 +298,16 @@ class TrackContainer {
return m_traj;
}

/// Get a mutable iterator to the first track in the container
/// @return a mutable iterator to the first track
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto begin() {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
TrackProxy, false>{*this, 0};
}

/// Get a past-the-end iterator for this container
/// @return a past-the-end iterator
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
auto end() {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
TrackProxy, false>{*this, size()};
}
/// @}

/// Get an const iterator to the first track in the container
/// @return a const iterator to the first track
auto begin() const {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
ConstTrackProxy, true>{*this, 0};
}

/// Get a past-the-end iterator for this container
/// @return a past-the-end iterator
auto end() const {
return detail_tc::TrackProxyIterator<std::decay_t<decltype(*this)>,
ConstTrackProxy, true>{*this, size()};
}

/// Helper function to make this track container match the dynamic columns of
/// another one. This will only work if the track container supports this
/// source, and depends on the implementation details of the dynamic columns
/// of the container
/// @tparam other_track_container_t Type of the other track container
/// @param other The other track container
template <typename other_track_container_t, bool RO = ReadOnly,
typename = std::enable_if_t<!RO>>
void ensureDynamicColumns(const other_track_container_t& other) {
container().ensureDynamicColumns_impl(other.container());
/// Get the size (number of tracks) of the track container
/// @return the sixe
constexpr IndexType size() const {
return m_container->size_impl();
}

/// Clear the content of the track container
/// @note Only available if the track container is not read-only
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
void clear() {
m_container->clear();
Expand Down
Loading

0 comments on commit 4126080

Please sign in to comment.