diff --git a/Core/include/Acts/TrackFinding/TrackSelector.hpp b/Core/include/Acts/TrackFinding/TrackSelector.hpp index 34afb8db322..8e82652980f 100644 --- a/Core/include/Acts/TrackFinding/TrackSelector.hpp +++ b/Core/include/Acts/TrackFinding/TrackSelector.hpp @@ -46,6 +46,10 @@ class TrackSelector { double ptMax = inf; std::size_t minMeasurements = 0; + std::size_t maxHoles = std::numeric_limits::max(); + std::size_t maxOutliers = std::numeric_limits::max(); + std::size_t maxSharedHits = std::numeric_limits::max(); + float maxChi2 = std::numeric_limits::max(); // Helper factory functions to produce a populated config object more // conveniently @@ -342,6 +346,7 @@ void TrackSelector::selectTracks(const input_tracks_t& inputTracks, template bool TrackSelector::isValidTrack(const track_proxy_t& track) const { auto checkMin = [](auto x, auto min) { return min <= x; }; + auto checkMax = [](auto x, auto max) { return x <= max; }; auto within = [](double x, double min, double max) { return (min <= x) && (x < max); }; @@ -382,7 +387,11 @@ bool TrackSelector::isValidTrack(const track_proxy_t& track) const { within(track.loc0(), cuts.loc0Min, cuts.loc0Max) && within(track.loc1(), cuts.loc1Min, cuts.loc1Max) && within(track.time(), cuts.timeMin, cuts.timeMax) && - checkMin(track.nMeasurements(), cuts.minMeasurements); + checkMin(track.nMeasurements(), cuts.minMeasurements) && + checkMax(track.nHoles(), cuts.maxHoles) && + checkMax(track.nOutliers(), cuts.maxOutliers) && + checkMax(track.nSharedHits(), cuts.maxSharedHits) && + checkMax(track.chi2(), cuts.maxChi2); } inline TrackSelector::TrackSelector( diff --git a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp index bdb851bf6e0..320044b03a4 100644 --- a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp @@ -23,7 +23,11 @@ struct MockTrack { double m_loc0; double m_loc1; double m_time; - double m_nMeasurements; + std::size_t m_nMeasurements; + std::size_t m_nHoles; + std::size_t m_nOutliers; + std::size_t m_nSharedHits; + float m_chi2; bool hasReferenceSurface() const { return true; } double theta() const { return m_theta; } @@ -32,7 +36,11 @@ struct MockTrack { double loc0() const { return m_loc0; } double loc1() const { return m_loc1; } double time() const { return m_time; } - double nMeasurements() const { return m_nMeasurements; } + std::size_t nMeasurements() const { return m_nMeasurements; } + std::size_t nHoles() const { return m_nHoles; } + std::size_t nOutliers() const { return m_nOutliers; } + std::size_t nSharedHits() const { return m_nSharedHits; } + float chi2() const { return m_chi2; } }; double thetaFromEta(double eta) { @@ -55,7 +63,11 @@ BOOST_DATA_TEST_CASE(TestSingleBinCase, bdata::make(etaValues), eta) { baseTrack.m_loc0 = 0.5; baseTrack.m_loc1 = 0.5; baseTrack.m_time = 0.5; - baseTrack.m_nMeasurements = 0.5; + baseTrack.m_nMeasurements = 1; + baseTrack.m_nHoles = 0; + baseTrack.m_nOutliers = 0; + baseTrack.m_nSharedHits = 0; + baseTrack.m_chi2 = 0.0; { TrackSelector selector{cfgBase}; @@ -257,6 +269,62 @@ BOOST_DATA_TEST_CASE(TestSingleBinCase, bdata::make(etaValues), eta) { track.m_nMeasurements = {0}; BOOST_CHECK(!selector.isValidTrack(track)); } + + { + BOOST_TEST_INFO_SCOPE("nHoles max"); + auto cfg = cfgBase; + cfg.cutSets.at(0).maxHoles = {3}; + TrackSelector selector{cfg}; + MockTrack track = baseTrack; + track.m_nHoles = {2}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_nHoles = {3}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_nHoles = {4}; + BOOST_CHECK(!selector.isValidTrack(track)); + } + + { + BOOST_TEST_INFO_SCOPE("nOutliers max"); + auto cfg = cfgBase; + cfg.cutSets.at(0).maxOutliers = {3}; + TrackSelector selector{cfg}; + MockTrack track = baseTrack; + track.m_nOutliers = {2}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_nOutliers = {3}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_nOutliers = {4}; + BOOST_CHECK(!selector.isValidTrack(track)); + } + + { + BOOST_TEST_INFO_SCOPE("nSharedHits max"); + auto cfg = cfgBase; + cfg.cutSets.at(0).maxSharedHits = {3}; + TrackSelector selector{cfg}; + MockTrack track = baseTrack; + track.m_nSharedHits = {2}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_nSharedHits = {3}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_nSharedHits = {4}; + BOOST_CHECK(!selector.isValidTrack(track)); + } + + { + BOOST_TEST_INFO_SCOPE("nSharedHits max"); + auto cfg = cfgBase; + cfg.cutSets.at(0).maxChi2 = {3}; + TrackSelector selector{cfg}; + MockTrack track = baseTrack; + track.m_chi2 = {2}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_chi2 = {3}; + BOOST_CHECK(selector.isValidTrack(track)); + track.m_chi2 = {4}; + BOOST_CHECK(!selector.isValidTrack(track)); + } } BOOST_AUTO_TEST_CASE(TestSingleBinEtaCutByBinEdge) { @@ -291,7 +359,11 @@ BOOST_AUTO_TEST_CASE(TestMultiBinCuts) { baseTrack.m_loc0 = 0.5; baseTrack.m_loc1 = 0.5; baseTrack.m_time = 0.5; - baseTrack.m_nMeasurements = 0.5; + baseTrack.m_nMeasurements = 1; + baseTrack.m_nHoles = 0; + baseTrack.m_nOutliers = 0; + baseTrack.m_nSharedHits = 0; + baseTrack.m_chi2 = 0.0; using Config = TrackSelector::Config;