Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(edm): Add functions to create and return track(state) proxies #2817

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Core/include/Acts/EventData/MultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,17 @@ 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 @@ -110,6 +110,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
Loading