Skip to content

Commit

Permalink
feat: TrackSelector can select on number of holes (#2725)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger authored Dec 1, 2023
1 parent 9228e3c commit 86daa5b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 5 deletions.
11 changes: 10 additions & 1 deletion Core/include/Acts/TrackFinding/TrackSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class TrackSelector {
double ptMax = inf;

std::size_t minMeasurements = 0;
std::size_t maxHoles = std::numeric_limits<std::size_t>::max();
std::size_t maxOutliers = std::numeric_limits<std::size_t>::max();
std::size_t maxSharedHits = std::numeric_limits<std::size_t>::max();
float maxChi2 = std::numeric_limits<float>::max();

// Helper factory functions to produce a populated config object more
// conveniently
Expand Down Expand Up @@ -342,6 +346,7 @@ void TrackSelector::selectTracks(const input_tracks_t& inputTracks,
template <typename track_proxy_t>
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);
};
Expand Down Expand Up @@ -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(
Expand Down
80 changes: 76 additions & 4 deletions Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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) {
Expand All @@ -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};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 86daa5b

Please sign in to comment.