Skip to content

Commit

Permalink
projector
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger committed Sep 8, 2024
1 parent e91cc39 commit 9dda03f
Show file tree
Hide file tree
Showing 32 changed files with 99 additions and 179 deletions.
12 changes: 4 additions & 8 deletions Core/include/Acts/Navigation/MultiLayerNavigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include <array>
#include <memory>
#include <tuple>

namespace Acts::Experimental {

Expand Down Expand Up @@ -106,14 +107,9 @@ class MultiLayerNavigation : public IInternalNavigation {
void resolveDuplicates(const GeometryContext& gctx,
std::vector<const Acts::Surface*>& surfaces) const {
// sorting the surfaces according to their radial distance
std::ranges::sort(surfaces, [&gctx](const auto& surf1, const auto& surf2) {
if (surf1->center(gctx).x() != surf2->center(gctx).x()) {
return surf1->center(gctx).x() < surf2->center(gctx).x();
}
if (surf1->center(gctx).y() != surf2->center(gctx).y()) {
return surf1->center(gctx).y() < surf2->center(gctx).y();
}
return surf1->center(gctx).z() < surf2->center(gctx).z();
std::ranges::sort(surfaces, {}, [&gctx](const auto& s) {
const auto& c = s->center(gctx);
return std::tie(c.x(), c.y(), c.z());
});

// Remove the duplicates
Expand Down
5 changes: 2 additions & 3 deletions Core/include/Acts/Navigation/NavigationStateUpdaters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ inline void intitializeCandidates(const GeometryContext& gctx,
}
}

std::ranges::sort(confirmedCandidates, [&](const auto& a, const auto& b) {
return a.objectIntersection.pathLength() <
b.objectIntersection.pathLength();
std::ranges::sort(confirmedCandidates, {}, [](const auto& c) {
return c.objectIntersection.pathLength();
});

nState.surfaceCandidates = std::move(confirmedCandidates);
Expand Down
14 changes: 4 additions & 10 deletions Core/include/Acts/Seeding/HoughTransformUtils.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <algorithm>
#include <tuple>

template <class identifier_t>
template <class PointType>
Expand Down Expand Up @@ -263,16 +264,9 @@ Acts::HoughTransformUtils::PeakFinders::IslandsAroundMax<
}
}
// sort the candidate cells descending in content
std::ranges::sort(
candidates, [&yieldMap](const std::size_t bin1, const std::size_t bin2) {
YieldType h1 = yieldMap[bin1];
YieldType h2 = yieldMap[bin2];

if (h1 != h2) {
return h1 > h2;
}
return bin1 > bin2;
});
std::ranges::sort(candidates, {}, [&yieldMap](const auto c) {
return std::tie(yieldMap[c], c);
});

// now we build islands from the candidate cells, starting with the most
// populated one
Expand Down
9 changes: 4 additions & 5 deletions Core/include/Acts/Seeding/SeedFilter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ void SeedFilter<external_spacepoint_t>::filterSeeds_2SpFixed(

if (topSpVec.size() > 2) {
// sort indexes based on comparing values in invHelixDiameterVec
std::ranges::sort(
topSPIndexVec,
[&invHelixDiameterVec](const std::size_t i1, const std::size_t i2) {
return invHelixDiameterVec[i1] < invHelixDiameterVec[i2];
});
std::ranges::sort(topSPIndexVec, {},
[&invHelixDiameterVec](const std::size_t t) {
return invHelixDiameterVec[t];
});
}

// vector containing the radius of all compatible seeds
Expand Down
20 changes: 7 additions & 13 deletions Core/include/Acts/Seeding/SeedFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -496,19 +496,13 @@ SeedFinder<external_spacepoint_t, grid_t, platform_t>::filterCandidates(

if constexpr (detailedMeasurement ==
Acts::DetectorMeasurementInfo::eDefault) {
std::ranges::sort(
sorted_bottoms,
[&state](const std::size_t a, const std::size_t b) -> bool {
return state.linCircleBottom[a].cotTheta <
state.linCircleBottom[b].cotTheta;
});

std::ranges::sort(
sorted_tops,
[&state](const std::size_t a, const std::size_t b) -> bool {
return state.linCircleTop[a].cotTheta <
state.linCircleTop[b].cotTheta;
});
std::ranges::sort(sorted_bottoms, {}, [&state](const std::size_t s) {
return state.linCircleBottom[s].cotTheta;
});

std::ranges::sort(sorted_tops, {}, [&state](const std::size_t s) {
return state.linCircleTop[s].cotTheta;
});
}

// Reserve enough space, in case current capacity is too little
Expand Down
19 changes: 8 additions & 11 deletions Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,14 @@ void SeedFinderOrthogonal<external_spacepoint_t>::filterCandidates(
sorted_tops[i] = i;
}

std::ranges::sort(
sorted_bottoms,
[&linCircleBottom](const std::size_t a, const std::size_t b) -> bool {
return linCircleBottom[a].cotTheta < linCircleBottom[b].cotTheta;
});

std::ranges::sort(
sorted_tops,
[&linCircleTop](const std::size_t a, const std::size_t b) -> bool {
return linCircleTop[a].cotTheta < linCircleTop[b].cotTheta;
});
std::ranges::sort(sorted_bottoms, {},
[&linCircleBottom](const std::size_t s) {
return linCircleBottom[s].cotTheta;
});

std::ranges::sort(sorted_tops, {}, [&linCircleTop](const std::size_t s) {
return linCircleTop[s].cotTheta;
});

std::vector<float> tanMT;
tanMT.reserve(top.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid(
/// sort SPs in R for each filled bin
for (std::size_t binIndex : rBinsIndex) {
auto& rbin = grid.atPosition(binIndex);
std::ranges::sort(rbin, [](const auto& a, const auto& b) -> bool {
return a->radius() < b->radius();
});
std::ranges::sort(rbin, {},
[](const auto& rb) -> bool { return rb->radius(); });
}
}
11 changes: 4 additions & 7 deletions Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,8 @@ Acts::SingleSeedVertexFinder<spacepoint_t>::findClosestPointFromPlanes(
triplet.second = distance;
}

std::ranges::sort(tripletsWithPlanes,
[](const auto& lhs, const auto& rhs) {
return lhs.second < rhs.second;
});
std::ranges::sort(tripletsWithPlanes, {},
[](const auto& t) { return t.second; });

std::uint32_t threshold = static_cast<std::uint32_t>(
tripletsWithPlanes.size() * (1. - m_cfg.removeFraction));
Expand Down Expand Up @@ -572,9 +570,8 @@ Acts::SingleSeedVertexFinder<spacepoint_t>::findClosestPointFromRays(
triplet.second = distance;
}

std::ranges::sort(tripletsWithRays, [](const auto& lhs, const auto& rhs) {
return lhs.second < rhs.second;
});
std::ranges::sort(tripletsWithRays, {},
[](const auto& t) { return t.second; });

std::uint32_t threshold = static_cast<std::uint32_t>(
tripletsWithRays.size() * (1. - m_cfg.removeFraction));
Expand Down
5 changes: 1 addition & 4 deletions Core/src/Detector/LayerStructureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,7 @@ Acts::Experimental::LayerStructureBuilder::construct(
adaptBinningRange(binnings, m_cfg.extent.value());
}
// Sort the binning for conventions
std::ranges::sort(binnings,
[](const ProtoBinning& a, const ProtoBinning& b) {
return a.binValue < b.binValue;
});
std::ranges::sort(binnings, {}, [](const auto& b) { return b.binValue; });

ACTS_DEBUG("- 2-dimensional surface binning detected.");
// Capture the binnings
Expand Down
10 changes: 4 additions & 6 deletions Core/src/Detector/detail/BlueprintHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ void Acts::Experimental::detail::BlueprintHelper::sort(Blueprint::Node& node,
bVal == BinningValue::binZ) {
Vector3 nodeCenter = node.transform.translation();
Vector3 nodeSortAxis = node.transform.rotation().col(toUnderlying(bVal));
std::ranges::sort(node.children, [&](const auto& a, const auto& b) {
return (a->transform.translation() - nodeCenter).dot(nodeSortAxis) <
(b->transform.translation() - nodeCenter).dot(nodeSortAxis);
std::ranges::sort(node.children, {}, [&](const auto& c) {
return (c->transform.translation() - nodeCenter).dot(nodeSortAxis);
});
} else if (bVal == BinningValue::binR &&
node.boundsType == VolumeBounds::eCylinder) {
std::ranges::sort(node.children, [](const auto& a, const auto& b) {
return 0.5 * (a->boundaryValues[0] + a->boundaryValues[1]) <
0.5 * (b->boundaryValues[0] + b->boundaryValues[1]);
std::ranges::sort(node.children, {}, [](const auto& c) {
return c->boundaryValues[0] + c->boundaryValues[1];
});
}
}
Expand Down
5 changes: 1 addition & 4 deletions Core/src/Geometry/CuboidVolumeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ Acts::MutableTrackingVolumePtr Acts::CuboidVolumeBuilder::trackingVolume(

// Sort the volumes vectors according to the center location, otherwise the
// binning boundaries will fail
std::ranges::sort(
volumes, [](const TrackingVolumePtr& lhs, const TrackingVolumePtr& rhs) {
return lhs->center().x() < rhs->center().x();
});
std::ranges::sort(volumes, {}, [](const auto& v) { return v->center().x(); });

// Glue volumes
for (unsigned int i = 0; i < volumes.size() - 1; i++) {
Expand Down
17 changes: 5 additions & 12 deletions Core/src/Geometry/CylinderVolumeStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction,

if (direction == Acts::BinningValue::binZ) {
ACTS_VERBOSE("Sorting by volume z position");
std::ranges::sort(volumeTuples, [](const auto& a, const auto& b) {
return a.localTransform.translation()[eZ] <
b.localTransform.translation()[eZ];
std::ranges::sort(volumeTuples, {}, [](const auto& v) {
return v.localTransform.translation()[eZ];
});

ACTS_VERBOSE("Checking for overlaps and attaching volumes in z");
Expand Down Expand Up @@ -192,9 +191,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction,
ACTS_VERBOSE("*** Volume configuration after r synchronization:");
printVolumeSequence(volumeTuples, logger, Acts::Logging::VERBOSE);

std::ranges::sort(volumeTuples, [](const auto& a, const auto& b) {
return a.midZ() < b.midZ();
});
std::ranges::sort(volumeTuples, {}, [](const auto& v) { return v.midZ(); });

m_volumes.clear();
for (const auto& vt : volumeTuples) {
Expand Down Expand Up @@ -223,9 +220,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction,

} else if (direction == Acts::BinningValue::binR) {
ACTS_VERBOSE("Sorting by volume r middle point");
std::ranges::sort(volumeTuples, [](const auto& a, const auto& b) {
return a.midR() < b.midR();
});
std::ranges::sort(volumeTuples, {}, [](const auto& v) { return v.midR(); });

ACTS_VERBOSE("Checking for overlaps and attaching volumes in r");
std::vector<VolumeTuple> gapVolumes =
Expand All @@ -252,9 +247,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction,
ACTS_VERBOSE("*** Volume configuration after z synchronization:");
printVolumeSequence(volumeTuples, logger, Acts::Logging::VERBOSE);

std::ranges::sort(volumeTuples, [](const auto& a, const auto& b) {
return a.midR() < b.midR();
});
std::ranges::sort(volumeTuples, {}, [](const auto& v) { return v.midR(); });

m_volumes.clear();
for (const auto& vt : volumeTuples) {
Expand Down
5 changes: 2 additions & 3 deletions Core/src/TrackFitting/GsfMixtureReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ void reduceWithKLDistanceImpl(std::vector<Acts::GsfComponent> &cmpCache,
}

// Remove all components which are labeled with weight -1
std::ranges::sort(cmpCache, [&](const auto &a, const auto &b) {
return proj(a).weight < proj(b).weight;
});
std::ranges::sort(cmpCache, {},
[&](const auto &c) { return proj(c).weight; });
cmpCache.erase(
std::remove_if(cmpCache.begin(), cmpCache.end(),
[&](const auto &a) { return proj(a).weight == -1.0; }),
Expand Down
5 changes: 1 addition & 4 deletions Core/src/Vertexing/FsmwMode1dFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ Acts::Result<double> Acts::FsmwMode1dFinder::getMode(

// first of all order the vector according to the double value

std::ranges::sort(inputVector, [](std::pair<double, double> a,
std::pair<double, double> b) {
return a.first < b.first;
});
std::ranges::sort(inputVector, {}, [](const auto& i) { return i.first; });

// begin to consider a certain number of elements according to the fraction
auto begin = inputVector.begin();
Expand Down
7 changes: 2 additions & 5 deletions Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,8 @@ void filterAndSort(

// Sort the particles based on their momentum
for (auto& interaction : interactions) {
std::ranges::sort(interaction.after,
[](const ActsExamples::SimParticle& a,
const ActsExamples::SimParticle& b) {
return a.absoluteMomentum() > b.absoluteMomentum();
});
std::ranges::sort(interaction.after, {},
[](const auto& a) { return a.absoluteMomentum(); });
}
}
} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "ActsExamples/Framework/WhiteBoard.hpp"
#include "ActsExamples/Utilities/EventDataTransforms.hpp"

#include <tuple>
#include <algorithm>

using namespace ActsExamples;
Expand Down Expand Up @@ -96,11 +97,8 @@ ProcessCode PrototracksToParameters::execute(
// layer-volume spacepoints has 3 or more hits. However, if this is the
// case, we want to keep the whole prototrack. Therefore, we operate on a
// tmpTrack.
std::ranges::sort(track, [&](auto a, auto b) {
if (indexToGeoId[a].volume() != indexToGeoId[b].volume()) {
return indexToGeoId[a].volume() < indexToGeoId[b].volume();
}
return indexToGeoId[a].layer() < indexToGeoId[b].layer();
std::ranges::sort(track, {}, [&](const auto &t) {
return std::tie(indexToGeoId[t].volume(), indexToGeoId[t].layer());
});

tmpTrack.clear();
Expand Down Expand Up @@ -134,8 +132,7 @@ ProcessCode PrototracksToParameters::execute(
continue;
}

std::ranges::sort(
tmpSps, [](const auto &a, const auto &b) { return a->r() < b->r(); });
std::ranges::sort(tmpSps, {}, [](const auto &t) { return t->r(); });

// Simply use r = m*z + t and solve for r=0 to find z vertex position...
// Probably not the textbook way to do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ std::vector<std::int64_t> TruthGraphBuilder::buildFromMeasurements(
};

// Sort by radius (this breaks down if the particle has to low momentum)
std::ranges::sort(track, [&](const auto& a, const auto& b) {
return radiusForOrdering(a) < radiusForOrdering(b);
});
std::ranges::sort(track, {},
[](const auto& t) { return radiusForOrdering(t); });

if (m_cfg.uniqueModules) {
auto newEnd = std::unique(
Expand Down Expand Up @@ -150,9 +149,7 @@ std::vector<std::int64_t> TruthGraphBuilder::buildFromSimhits(

for (auto& [pid, track] : tracks) {
// Sort by hit index, so the edges are connected correctly
std::ranges::sort(track, [](const auto& a, const auto& b) {
return a.hitIndex < b.hitIndex;
});
std::ranges::sort(track, {}, [](const auto& t) { return t.hitIndex; });

auto found = particles.find(pid);
if (found == particles.end()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ ActsExamples::ProcessCode ActsExamples::TruthSeedingAlgorithm::execute(
continue;
}
// Sort the space points
std::ranges::sort(spacePointsOnTrack, [](const SimSpacePoint* lhs,
const SimSpacePoint* rhs) {
return std::hypot(lhs->r(), lhs->z()) < std::hypot(rhs->r(), rhs->z());
std::ranges::sort(spacePointsOnTrack, {}, [](const SimSpacePoint* s) {
return std::hypot(s->r(), s->z());
});

// Loop over the found space points to find the seed with maximum deltaR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,9 @@ ProcessCode AdaptiveMultiVertexFinderAlgorithm::execute(
}

// sort by number of particles
std::ranges::sort(vertexSeederState.truthVertices,
[&vertexParticleCount](const auto& lhs, const auto& rhs) {
return vertexParticleCount[lhs.vertexId()] >
vertexParticleCount[rhs.vertexId()];
std::ranges::sort(vertexSeederState.truthVertices, {},
[&vertexParticleCount](const auto& v) {
return vertexParticleCount[v.vertexId()];
});

ACTS_INFO("Got " << truthVertices.size() << " truth vertices and selected "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ ActsExamples::MockupSectorBuilder::buildSector(

// sort the detector volumes by their radial distance (from
// innermost---->outermost)
std::ranges::sort(detVolumes, [](const auto& detVol1, const auto& detVol2) {
return detVol1->center().y() < detVol2->center().y();
});
std::ranges::sort(detVolumes, {},
[](const auto& detVol) { return detVol->center().y(); });

auto xA = detVolumes.back()->center().x() +
detVolumes.back()->volumeBounds().values()[0];
Expand Down
Loading

0 comments on commit 9dda03f

Please sign in to comment.