Skip to content

Commit

Permalink
feat: Track EDM: Add functions to create and return proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Dec 12, 2023
1 parent 15203d1 commit 8c0b283
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,16 @@ class MultiTrajectory {
return {*this, istate};
}

/// Add a track state to the container and return a track state proxy to it
/// This effectively calls @c addTrackState and @c getTrackState
/// @note Only available if the track state container is not read-only
/// @return a track state proxy to the newly added track state
template <bool RO = ReadOnly, typename = std::enable_if_t<!RO>>
TrackStateProxy makeTrackState(
TrackStatePropMask mask = TrackStatePropMask::All,
IndexType iprevious = kInvalid) {
return getTrackState(addTrackState(mask, iprevious));
}
/// Visit all previous states starting at a given endpoint.
///
/// @param iendpoint index of the last state
Expand Down
9 changes: 9 additions & 0 deletions Core/include/Acts/EventData/TrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ 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!
/// @param itrack The index of the track to remove
Expand Down
10 changes: 10 additions & 0 deletions Core/include/Acts/EventData/detail/MultiTrajectoryTestsCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ class MultiTrajectoryTestsCommon {
}
BOOST_CHECK_EQUAL_COLLECTIONS(predictedsAct.begin(), predictedsAct.end(),
predicteds.begin(), predicteds.end());

{
trajectory_t t2 = m_factory.create();
auto ts = t2.makeTrackState(kMask);
BOOST_CHECK_EQUAL(t2.size(), 1);
auto ts2 = t2.makeTrackState(kMask, ts.index());
BOOST_CHECK_EQUAL(t2.size(), 2);
BOOST_CHECK_EQUAL(ts.previous(), MultiTrajectoryTraits::kInvalid);
BOOST_CHECK_EQUAL(ts2.previous(), ts.index());
}
}

void testClear() {
Expand Down
15 changes: 15 additions & 0 deletions Tests/UnitTests/Core/EventData/TrackTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ BOOST_AUTO_TEST_CASE(BuildSharedPtr) {
BOOST_CHECK_EQUAL(vtc.get(), &copy.container());
}

BOOST_AUTO_TEST_CASE(BuildConvenience) {
VectorMultiTrajectory mtj{};
VectorTrackContainer vtc{};
TrackContainer tc{vtc, mtj};

BOOST_CHECK_EQUAL(tc.size(), 0);
auto track1 = tc.makeTrack();
BOOST_CHECK_EQUAL(tc.size(), 1);
auto track2 = tc.makeTrack();
BOOST_CHECK_EQUAL(tc.size(), 2);

BOOST_CHECK_EQUAL(track1.index(), 0);
BOOST_CHECK_EQUAL(track2.index(), 1);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Build, factory_t, holder_types) {
factory_t factory;

Expand Down

0 comments on commit 8c0b283

Please sign in to comment.