Skip to content

Commit

Permalink
refactor: move initialisation of vector in SeedFilter (#2135)
Browse files Browse the repository at this point in the history
This PR moves the initialisation of `compatibleSeedR` in seedFilter to reduce memory allocation
  • Loading branch information
LuisFelipeCoelho committed May 25, 2023
1 parent 9cc6ef0 commit fd8e801
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Core/include/Acts/Seeding/SeedFilter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_2SpFixed(
});
}

// vector containing the radius of all compatible seeds
std::vector<float> compatibleSeedR;
compatibleSeedR.reserve(m_cfg.compatSeedLimit);

size_t beginCompTopIndex = 0;
// loop over top SPs and other compatible top SP candidates
for (const std::size_t topSPIndex : topSPIndexVec) {
// if two compatible seeds with high distance in r are found, compatible
// seeds span 5 layers
// -> weaker requirement for a good seed
std::vector<float> compatibleSeedR;
compatibleSeedR.reserve(m_cfg.compatSeedLimit);
compatibleSeedR.clear();

float invHelixDiameter = invHelixDiameterVec[topSPIndex];
float lowerLimitCurv = invHelixDiameter - m_cfg.deltaInvHelixDiameter;
Expand All @@ -94,6 +96,7 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_2SpFixed(

float weight = -(impact * m_cfg.impactWeightFactor);

// loop over compatible top SP candidates
for (size_t variableCompTopIndex = beginCompTopIndex;
variableCompTopIndex < topSPIndexVec.size(); variableCompTopIndex++) {
size_t compatibleTopSPIndex = topSPIndexVec[variableCompTopIndex];
Expand Down Expand Up @@ -122,7 +125,7 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_2SpFixed(
continue;
}
bool newCompSeed = true;
for (float previousDiameter : compatibleSeedR) {
for (const float& previousDiameter : compatibleSeedR) {
// original ATLAS code uses higher min distance for 2nd found compatible
// seed (20mm instead of 5mm)
// add new compatible seed only if distance larger than rmin to all
Expand Down
2 changes: 1 addition & 1 deletion Examples/Python/python/acts/examples/itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def itkSeedingAlgConfig(inputSpacePointsType: InputSpacePointsType):
seedConfirmationFilter = True
impactWeightFactor = 100
compatSeedLimit = 3
numSeedIncrement = float("inf")
numSeedIncrement = 100
seedWeightIncrement = 0
useDetailedDoubleMeasurementInfo = False
maxSeedsPerSpMConf = 5
Expand Down

0 comments on commit fd8e801

Please sign in to comment.