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

refactor!: Remove redundant variables from Seed filter state #3393

Merged
merged 5 commits into from
Jul 18, 2024
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
8 changes: 8 additions & 0 deletions Core/include/Acts/Seeding/CandidatesForMiddleSp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ class CandidatesForMiddleSp {
/// @returns The comparison result
static bool ascendingByQuality(const value_type& i1, const value_type& i2);

/// @brief Retrieve the number of Low quality candidates
/// @returns The number of Low quality candidates
std::size_t nLowQualityCandidates() const;

/// @brief Retrieve the number of High quality candidates
/// @returns The number of High quality candidates
std::size_t nHighQualityCandidates() const;

private:
/// @brief dding a new triplet candidate to the collection, should it satisfy the
/// selection criteria
Expand Down
12 changes: 12 additions & 0 deletions Core/include/Acts/Seeding/CandidatesForMiddleSp.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,16 @@ bool CandidatesForMiddleSp<external_space_point_t>::ascendingByQuality(
return !descendingByQuality(i1, i2);
}

template <typename external_space_point_t>
std::size_t
CandidatesForMiddleSp<external_space_point_t>::nLowQualityCandidates() const {
return m_n_low;
}

template <typename external_space_point_t>
std::size_t
CandidatesForMiddleSp<external_space_point_t>::nHighQualityCandidates() const {
return m_n_high;
}

} // namespace Acts
9 changes: 1 addition & 8 deletions Core/include/Acts/Seeding/SeedFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ struct SeedFilterState {
// compatible top required
float rMaxSeedConf =
std::numeric_limits<float>::max(); // Acts::UnitConstants::mm
// number of high quality seeds in seed confirmation
std::size_t numQualitySeeds = 0;
// number of seeds that did not pass the quality confirmation but were still
// accepted, if quality confirmation is not used this is the total number of
// seeds
std::size_t numSeeds = 0;
};

/// Filter seeds at various stages with the currently
Expand Down Expand Up @@ -76,15 +70,14 @@ class SeedFilter final {
/// Filter seeds once all seeds for one middle space point have been created
/// @param spacePointData Auxiliary variables used by the seeding
/// @param candidates_collector collection of seed candidates
/// @param numQualitySeeds number of high quality seeds in seed confirmation
/// @param outputCollection Output container for the seeds
/// for all seeds with the same middle space point
template <typename collection_t>
void filterSeeds_1SpFixed(
Acts::SpacePointData& spacePointData,
CandidatesForMiddleSp<const InternalSpacePoint<external_spacepoint_t>>&
candidates_collector,
const std::size_t numQualitySeeds, collection_t& outputCollection) const;
collection_t& outputCollection) const;

/// Filter seeds once all seeds for one middle space point have been created
/// @param spacePointData Auxiliary variables used by the seeding
Expand Down
21 changes: 5 additions & 16 deletions Core/include/Acts/Seeding/SeedFilter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_2SpFixed(
int deltaSeedConf =
compatibleSeedR.size() + 1 - seedFilterState.nTopSeedConf;
if (deltaSeedConf < 0 ||
(seedFilterState.numQualitySeeds != 0 && deltaSeedConf == 0)) {
(candidates_collector.nHighQualityCandidates() != 0 &&
deltaSeedConf == 0)) {
continue;
}
bool seedRangeCuts =
Expand Down Expand Up @@ -204,11 +205,6 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_2SpFixed(
// If this is reached, we remove the seed with the lowest weight.
candidates_collector.push(bottomSP, middleSP, *topSpVec[topSPIndex],
weight, zOrigin, true);
if (seedFilterState.numQualitySeeds < m_cfg.maxQualitySeedsPerSpMConf) {
// fill high quality seed
seedFilterState.numQualitySeeds++;
}

} else if (weight > weightMax) {
// store weight and index of the best "lower quality" seed
weightMax = weight;
Expand All @@ -222,25 +218,17 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_2SpFixed(

candidates_collector.push(bottomSP, middleSP, *topSpVec[topSPIndex],
weight, zOrigin, false);
if (seedFilterState.numSeeds < m_cfg.maxSeedsPerSpMConf) {
// fill seed
seedFilterState.numSeeds++;
}
}
} // loop on tops
// if no high quality seed was found for a certain middle+bottom SP pair,
// lower quality seeds can be accepted
if (m_cfg.seedConfirmation && maxWeightSeed &&
seedFilterState.numQualitySeeds == 0) {
candidates_collector.nHighQualityCandidates() == 0) {
// if we have not yet reached our max number of seeds we add the new seed to
// outCont

candidates_collector.push(bottomSP, middleSP, *topSpVec[maxWeightSeedIndex],
weightMax, zOrigin, false);
if (seedFilterState.numSeeds < m_cfg.maxSeedsPerSpMConf) {
// fill seed
seedFilterState.numSeeds++;
}
}
}

Expand All @@ -252,10 +240,11 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_1SpFixed(
Acts::SpacePointData& spacePointData,
CandidatesForMiddleSp<const InternalSpacePoint<external_spacepoint_t>>&
candidates_collector,
const std::size_t numQualitySeeds, collection_t& outputCollection) const {
collection_t& outputCollection) const {
// retrieve all candidates
// this collection is already sorted
// higher weights first
std::size_t numQualitySeeds = candidates_collector.nHighQualityCandidates();
auto extended_collection = candidates_collector.storage();
filterSeeds_1SpFixed(spacePointData, extended_collection, numQualitySeeds,
outputCollection);
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ void SeedFinder<external_spacepoint_t, grid_t, platform_t>::createSeedsForGroup(
}

m_config.seedFilter->filterSeeds_1SpFixed(
state.spacePointData, state.candidates_collector,
seedFilterState.numQualitySeeds, outputCollection);
state.spacePointData, state.candidates_collector, outputCollection);

} // loop on mediums
}
Expand Down Expand Up @@ -572,7 +571,8 @@ SeedFinder<external_spacepoint_t, grid_t, platform_t>::filterCandidates(
state.compatBottomSP[b]->radius() > seedFilterState.rMaxSeedConf) {
minCompatibleTopSPs = 1;
}
if (m_config.seedConfirmation && seedFilterState.numQualitySeeds) {
if (m_config.seedConfirmation &&
state.candidates_collector.nHighQualityCandidates()) {
minCompatibleTopSPs++;
}

Expand Down
8 changes: 4 additions & 4 deletions Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ void SeedFinderOrthogonal<external_spacepoint_t>::filterCandidates(
bottom[b]->radius() > seedFilterState.rMaxSeedConf) {
minCompatibleTopSPs = 1;
}
if (m_config.seedConfirmation && seedFilterState.numQualitySeeds) {
if (m_config.seedConfirmation &&
candidates_collector.nHighQualityCandidates()) {
minCompatibleTopSPs++;
}

Expand Down Expand Up @@ -676,9 +677,8 @@ void SeedFinderOrthogonal<external_spacepoint_t>::processFromMiddleSP(
*/
if ((!bottom_lh_v.empty() && !top_lh_v.empty()) ||
(!bottom_hl_v.empty() && !top_hl_v.empty())) {
m_config.seedFilter->filterSeeds_1SpFixed(
spacePointData, candidates_collector, seedFilterState.numQualitySeeds,
out_cont);
m_config.seedFilter->filterSeeds_1SpFixed(spacePointData,
candidates_collector, out_cont);
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/core/reconstruction/pattern_recognition/seeding.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ The seed confirmation also sets a limit on the number of seeds produced for each
which retains only the higher quality seeds. If this limit is exceeded, the algorithm
checks if there is any low-quality seed in the seed container of this middle SP that can be removed.

:::{doxygenfunction} Acts::SeedFilter::filterSeeds_1SpFixed (Acts::SpacePointData &spacePointData, CandidatesForMiddleSp<const InternalSpacePoint<external_spacepoint_t>>&, const std::size_t, collection_t&) const
:::{doxygenfunction} Acts::SeedFilter::filterSeeds_1SpFixed (Acts::SpacePointData &spacePointData, CandidatesForMiddleSp<const InternalSpacePoint<external_spacepoint_t>>&, collection_t&) const
:outline:
:::

Expand Down
Loading