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!: Allow trimming other non measurement track states #3993

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 14 additions & 5 deletions Core/include/Acts/Utilities/TrackHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,10 @@ void calculateTrackQuantities(track_proxy_t track)
/// @param trimHoles whether to trim holes
/// @param trimOutliers whether to trim outliers
/// @param trimMaterial whether to trim pure material states
/// @param trimOther whether to trim other, non measurement, states
template <TrackProxyConcept track_proxy_t>
void trimTrackFront(track_proxy_t track, bool trimHoles, bool trimOutliers,
bool trimMaterial)
bool trimMaterial, bool trimOther)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool trimMaterial, bool trimOther)
bool trimMaterial, bool trimNonMeasurement)

?
Sounds a bit weird, but might be a bit clearer than other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also unhappy with the name. trimNonMeasurement sounds also a bit like it would to what the other flags do? which might actually be the case right now, I have to double check the logic. I think it would be good if they are all exclusive. So potentially trimOtherNoneMeasurement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the problem is that it's not obvious from the signature what the remaining possibilities are.
I'm wondering: couldn't we pass in a TrackStateType object that we use as a mask instead of the named arguments?

requires(!track_proxy_t::ReadOnly)
{
using TrackStateProxy = typename track_proxy_t::TrackStateProxy;
Expand All @@ -435,6 +436,9 @@ void trimTrackFront(track_proxy_t track, bool trimHoles, bool trimOutliers,
!typeFlags.test(TrackStateFlag::MeasurementFlag)) {
continue;
}
if (trimOther && !typeFlags.test(TrackStateFlag::MeasurementFlag)) {
continue;
}

front = trackState;
}
Expand All @@ -450,9 +454,10 @@ void trimTrackFront(track_proxy_t track, bool trimHoles, bool trimOutliers,
/// @param trimHoles whether to trim holes
/// @param trimOutliers whether to trim outliers
/// @param trimMaterial whether to trim pure material states
/// @param trimOther whether to trim other, non measurement, states
template <TrackProxyConcept track_proxy_t>
void trimTrackBack(track_proxy_t track, bool trimHoles, bool trimOutliers,
bool trimMaterial)
bool trimMaterial, bool trimOther)
requires(!track_proxy_t::ReadOnly)
{
using TrackStateProxy = typename track_proxy_t::TrackStateProxy;
Expand All @@ -473,6 +478,9 @@ void trimTrackBack(track_proxy_t track, bool trimHoles, bool trimOutliers,
!typeFlags.test(TrackStateFlag::MeasurementFlag)) {
continue;
}
if (trimOther && !typeFlags.test(TrackStateFlag::MeasurementFlag)) {
continue;
}

break;
}
Expand All @@ -488,13 +496,14 @@ void trimTrackBack(track_proxy_t track, bool trimHoles, bool trimOutliers,
/// @param trimHoles whether to trim holes
/// @param trimOutliers whether to trim outliers
/// @param trimMaterial whether to trim pure material states
/// @param trimOther whether to trim other, non measurement, states
template <TrackProxyConcept track_proxy_t>
void trimTrack(track_proxy_t track, bool trimHoles, bool trimOutliers,
bool trimMaterial)
bool trimMaterial, bool trimOther)
requires(!track_proxy_t::ReadOnly)
{
trimTrackFront(track, trimHoles, trimOutliers, trimMaterial);
trimTrackBack(track, trimHoles, trimOutliers, trimMaterial);
trimTrackFront(track, trimHoles, trimOutliers, trimMaterial, trimOther);
trimTrackBack(track, trimHoles, trimOutliers, trimMaterial, trimOther);
andiwand marked this conversation as resolved.
Show resolved Hide resolved
}

/// Helper function to calculate the predicted residual and its covariance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ ProcessCode TrackFindingAlgorithm::execute(const AlgorithmContext& ctx) const {

// trim the track if requested
if (m_cfg.trimTracks) {
Acts::trimTrack(track, true, true, true);
Acts::trimTrack(track, true, true, true, true);
}
Acts::calculateTrackQuantities(track);

Expand Down
12 changes: 9 additions & 3 deletions Tests/UnitTests/Core/Utilities/TrackHelpersTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ BOOST_AUTO_TEST_CASE(CalculateQuantities) {
BOOST_AUTO_TEST_CASE(TrimTrack) {
TrackContainer tc{VectorTrackContainer{}, VectorMultiTrajectory{}};
auto t = createTestTrack(tc, std::vector<std::vector<TrackStateFlag>>{
{},
{HoleFlag},
{MeasurementFlag},
{OutlierFlag},
Expand All @@ -98,34 +99,39 @@ BOOST_AUTO_TEST_CASE(TrimTrack) {
{HoleFlag},
{MeasurementFlag},
{OutlierFlag},
{},
});

calculateTrackQuantities(t);

BOOST_CHECK_EQUAL(t.nTrackStates(), 11);
BOOST_CHECK_EQUAL(t.nHoles(), 3);
BOOST_CHECK_EQUAL(t.nMeasurements(), 3);
BOOST_CHECK_EQUAL(t.nOutliers(), 3);
BOOST_CHECK_EQUAL(t.nSharedHits(), 1);

trimTrackFront(t, true, true, true);
trimTrackFront(t, true, true, true, true);
calculateTrackQuantities(t);

BOOST_CHECK_EQUAL(t.nTrackStates(), 9);
BOOST_CHECK_EQUAL(t.nHoles(), 2);
BOOST_CHECK_EQUAL(t.nMeasurements(), 3);
BOOST_CHECK_EQUAL(t.nOutliers(), 3);
BOOST_CHECK_EQUAL(t.nSharedHits(), 1);

trimTrackBack(t, true, true, true);
trimTrackBack(t, true, true, true, true);
calculateTrackQuantities(t);

BOOST_CHECK_EQUAL(t.nTrackStates(), 7);
BOOST_CHECK_EQUAL(t.nHoles(), 2);
BOOST_CHECK_EQUAL(t.nMeasurements(), 3);
BOOST_CHECK_EQUAL(t.nOutliers(), 2);
BOOST_CHECK_EQUAL(t.nSharedHits(), 1);

trimTrack(t, true, true, true);
trimTrack(t, true, true, true, true);
calculateTrackQuantities(t);

BOOST_CHECK_EQUAL(t.nTrackStates(), 7);
BOOST_CHECK_EQUAL(t.nHoles(), 2);
BOOST_CHECK_EQUAL(t.nMeasurements(), 3);
BOOST_CHECK_EQUAL(t.nOutliers(), 2);
Expand Down
Loading