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: cleaning the code for filling cylindrical grid #3344

Merged
merged 4 commits into from
Jul 4, 2024
Merged
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
37 changes: 17 additions & 20 deletions Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <boost/container/flat_set.hpp>

template <typename SpacePoint>
Acts::CylindricalSpacePointGrid<SpacePoint>
Acts::CylindricalSpacePointGridCreator::createGrid(
Expand Down Expand Up @@ -165,12 +163,6 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid(
"SeedFinderOptions not in ACTS internal units in BinnedSPGroup");
}

// get region of interest (or full detector if configured accordingly)
float phiMin = config.phiMin;
float phiMax = config.phiMax;
float zMin = config.zMin;
float zMax = config.zMax;

// sort by radius
// add magnitude of beamPos to rMax to avoid excluding measurements
// create number of bins equal to number of millimeters rMax
Expand All @@ -180,7 +172,9 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid(
(config.rMax + options.beamPos.norm()) / config.binSizeR);

// keep track of changed bins while sorting
boost::container::flat_set<std::size_t> rBinsIndex;
std::vector<bool> usedBinIndex(grid.size(), false);
std::vector<std::size_t> rBinsIndex;
rBinsIndex.reserve(grid.size());

std::size_t counter = 0ul;
for (external_spacepoint_iterator_t it = spBegin; it != spEnd;
Expand All @@ -200,11 +194,12 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid(
rRangeSPExtent.extend({spX, spY, spZ});

// remove SPs outside z and phi region
if (spZ > zMax || spZ < zMin) {
if (spZ > config.zMax || spZ < config.zMin) {
continue;
}

float spPhi = std::atan2(spY, spX);
if (spPhi > phiMax || spPhi < phiMin) {
if (spPhi > config.phiMax || spPhi < config.phiMin) {
continue;
}

Expand All @@ -220,23 +215,25 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid(
}

// fill rbins into grid
Acts::Vector2 spLocation(isp->phi(), isp->z());
std::vector<std::unique_ptr<InternalSpacePoint<external_spacepoint_t>>>&
rbin = grid.atPosition(spLocation);
std::size_t globIndex =
grid.globalBinFromPosition(Acts::Vector2{isp->phi(), isp->z()});
auto& rbin = grid.at(globIndex);
rbin.push_back(std::move(isp));

// keep track of the bins we modify so that we can later sort the SPs in
// those bins only
if (rbin.size() > 1) {
rBinsIndex.insert(grid.globalBinFromPosition(spLocation));
if (rbin.size() > 1 && !usedBinIndex[globIndex]) {
usedBinIndex[globIndex] = true;
rBinsIndex.push_back(globIndex);
}
}

/// sort SPs in R for each filled bin
for (auto& binIndex : rBinsIndex) {
for (std::size_t binIndex : rBinsIndex) {
auto& rbin = grid.atPosition(binIndex);
std::sort(rbin.begin(), rbin.end(), [](const auto& a, const auto& b) {
return a->radius() < b->radius();
});
std::sort(rbin.begin(), rbin.end(),
[](const auto& a, const auto& b) -> bool {
return a->radius() < b->radius();
});
}
}
Loading