diff --git a/Core/include/Acts/Navigation/MultiLayerNavigation.hpp b/Core/include/Acts/Navigation/MultiLayerNavigation.hpp index 6c292026331..8ce76972878 100644 --- a/Core/include/Acts/Navigation/MultiLayerNavigation.hpp +++ b/Core/include/Acts/Navigation/MultiLayerNavigation.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace Acts::Experimental { @@ -106,14 +107,9 @@ class MultiLayerNavigation : public IInternalNavigation { void resolveDuplicates(const GeometryContext& gctx, std::vector& 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 diff --git a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp index a49c3702852..b5e4d90f53b 100644 --- a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp +++ b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp @@ -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); diff --git a/Core/include/Acts/Seeding/HoughTransformUtils.ipp b/Core/include/Acts/Seeding/HoughTransformUtils.ipp index 19c739ce0e6..bf4d839a8b6 100644 --- a/Core/include/Acts/Seeding/HoughTransformUtils.ipp +++ b/Core/include/Acts/Seeding/HoughTransformUtils.ipp @@ -7,6 +7,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include +#include template template @@ -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 diff --git a/Core/include/Acts/Seeding/SeedFilter.ipp b/Core/include/Acts/Seeding/SeedFilter.ipp index 672749e5487..284ab2932e3 100644 --- a/Core/include/Acts/Seeding/SeedFilter.ipp +++ b/Core/include/Acts/Seeding/SeedFilter.ipp @@ -69,11 +69,10 @@ void SeedFilter::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 diff --git a/Core/include/Acts/Seeding/SeedFinder.ipp b/Core/include/Acts/Seeding/SeedFinder.ipp index 7826e2f2abc..f65a26e3f58 100644 --- a/Core/include/Acts/Seeding/SeedFinder.ipp +++ b/Core/include/Acts/Seeding/SeedFinder.ipp @@ -496,19 +496,13 @@ SeedFinder::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 diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 0721ce29edb..7caad023cf4 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -312,17 +312,14 @@ void SeedFinderOrthogonal::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 tanMT; tanMT.reserve(top.size()); diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp index 926c192ff6c..bad3fc4c285 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp @@ -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(); }); } } diff --git a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp index 90aaf3c59df..0f26a6a1ed3 100644 --- a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp @@ -464,10 +464,8 @@ Acts::SingleSeedVertexFinder::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( tripletsWithPlanes.size() * (1. - m_cfg.removeFraction)); @@ -572,9 +570,8 @@ Acts::SingleSeedVertexFinder::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( tripletsWithRays.size() * (1. - m_cfg.removeFraction)); diff --git a/Core/src/Detector/LayerStructureBuilder.cpp b/Core/src/Detector/LayerStructureBuilder.cpp index b2ef8d9cfbc..7af5bdf5e5a 100644 --- a/Core/src/Detector/LayerStructureBuilder.cpp +++ b/Core/src/Detector/LayerStructureBuilder.cpp @@ -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 diff --git a/Core/src/Detector/detail/BlueprintHelper.cpp b/Core/src/Detector/detail/BlueprintHelper.cpp index 6b787f1fd55..502d91f4d10 100644 --- a/Core/src/Detector/detail/BlueprintHelper.cpp +++ b/Core/src/Detector/detail/BlueprintHelper.cpp @@ -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]; }); } } diff --git a/Core/src/Geometry/CuboidVolumeBuilder.cpp b/Core/src/Geometry/CuboidVolumeBuilder.cpp index 84a5897c98b..1d226ca05fd 100644 --- a/Core/src/Geometry/CuboidVolumeBuilder.cpp +++ b/Core/src/Geometry/CuboidVolumeBuilder.cpp @@ -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++) { diff --git a/Core/src/Geometry/CylinderVolumeStack.cpp b/Core/src/Geometry/CylinderVolumeStack.cpp index ab218de93f2..7be032e3850 100644 --- a/Core/src/Geometry/CylinderVolumeStack.cpp +++ b/Core/src/Geometry/CylinderVolumeStack.cpp @@ -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"); @@ -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) { @@ -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 gapVolumes = @@ -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) { diff --git a/Core/src/TrackFitting/GsfMixtureReduction.cpp b/Core/src/TrackFitting/GsfMixtureReduction.cpp index b5469ccba31..d0d5b2dfd79 100644 --- a/Core/src/TrackFitting/GsfMixtureReduction.cpp +++ b/Core/src/TrackFitting/GsfMixtureReduction.cpp @@ -37,9 +37,8 @@ void reduceWithKLDistanceImpl(std::vector &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; }), diff --git a/Core/src/Vertexing/FsmwMode1dFinder.cpp b/Core/src/Vertexing/FsmwMode1dFinder.cpp index 798aba5dfc1..8d075fe131b 100644 --- a/Core/src/Vertexing/FsmwMode1dFinder.cpp +++ b/Core/src/Vertexing/FsmwMode1dFinder.cpp @@ -28,10 +28,7 @@ Acts::Result Acts::FsmwMode1dFinder::getMode( // first of all order the vector according to the double value - std::ranges::sort(inputVector, [](std::pair a, - std::pair 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(); diff --git a/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp b/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp index 01666daec9a..628f87f4c69 100644 --- a/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp +++ b/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp @@ -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 diff --git a/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp b/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp index e6565c782e7..ce45d49b31f 100644 --- a/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp +++ b/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp @@ -21,6 +21,7 @@ #include "ActsExamples/Framework/WhiteBoard.hpp" #include "ActsExamples/Utilities/EventDataTransforms.hpp" +#include #include using namespace ActsExamples; @@ -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(); @@ -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 diff --git a/Examples/Algorithms/TrackFindingExaTrkX/src/TruthGraphBuilder.cpp b/Examples/Algorithms/TrackFindingExaTrkX/src/TruthGraphBuilder.cpp index 78c31a7e058..9dc0d407862 100644 --- a/Examples/Algorithms/TrackFindingExaTrkX/src/TruthGraphBuilder.cpp +++ b/Examples/Algorithms/TrackFindingExaTrkX/src/TruthGraphBuilder.cpp @@ -84,9 +84,8 @@ std::vector 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( @@ -150,9 +149,7 @@ std::vector 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()) { diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp index 975349af446..5a79534d141 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp @@ -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 diff --git a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp index 54c96d57258..c4a471669d6 100644 --- a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp @@ -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 " diff --git a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp index 17ede59023d..7b3323fe7af 100644 --- a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp +++ b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp @@ -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]; diff --git a/Examples/Framework/src/Framework/Sequencer.cpp b/Examples/Framework/src/Framework/Sequencer.cpp index 5afde17c0d7..db5b856d4be 100644 --- a/Examples/Framework/src/Framework/Sequencer.cpp +++ b/Examples/Framework/src/Framework/Sequencer.cpp @@ -622,9 +622,7 @@ void Sequencer::fpeReport() const { std::transform(merged.stackTraces().begin(), merged.stackTraces().end(), std::back_inserter(sorted), [](const auto& f) -> const auto& { return f; }); - std::ranges::sort(sorted, [](const auto& a, const auto& b) { - return a.get().count > b.get().count; - }); + std::ranges::sort(sorted, {}, [](const auto& s) { return s.get().count; }); std::vector> remaining; diff --git a/Examples/Framework/src/Framework/WhiteBoard.cpp b/Examples/Framework/src/Framework/WhiteBoard.cpp index e0a633c9819..a71ac23e7b0 100644 --- a/Examples/Framework/src/Framework/WhiteBoard.cpp +++ b/Examples/Framework/src/Framework/WhiteBoard.cpp @@ -68,8 +68,7 @@ std::vector ActsExamples::WhiteBoard::similarNames( } } - std::ranges::sort( - names, [&](const auto &a, const auto &b) { return a.first < b.first; }); + std::ranges::sort(names, {}, [](const auto &n) { return n.first; }); std::vector selected_names; for (std::size_t i = 0; i < std::min(names.size(), maxNumber); ++i) { diff --git a/Examples/Framework/src/Utilities/EventDataTransforms.cpp b/Examples/Framework/src/Utilities/EventDataTransforms.cpp index 55c3d4b66ec..ab94a4a61a1 100644 --- a/Examples/Framework/src/Utilities/EventDataTransforms.cpp +++ b/Examples/Framework/src/Utilities/EventDataTransforms.cpp @@ -69,8 +69,7 @@ ActsExamples::SimSeed ActsExamples::prototrackToSeed( std::transform(track.begin(), track.end(), std::back_inserter(ps), findSpacePoint); - std::ranges::sort( - ps, [](const auto& a, const auto& b) { return a->r() < b->r(); }); + std::ranges::sort(ps, {}, [](const auto& p) { return p->r(); }); // Simply use r = m*z + t and solve for r=0 to find z vertex position... // Probably not the textbook way to do diff --git a/Examples/Framework/src/Validation/TrackClassification.cpp b/Examples/Framework/src/Validation/TrackClassification.cpp index 29d4edbebbc..8102f0bc9c9 100644 --- a/Examples/Framework/src/Validation/TrackClassification.cpp +++ b/Examples/Framework/src/Validation/TrackClassification.cpp @@ -40,11 +40,8 @@ inline void increaseHitCount( /// Sort hit counts by decreasing values, i.e. majority particle comes first. inline void sortHitCount( std::vector& particleHitCounts) { - std::ranges::sort(particleHitCounts, - [](const ActsExamples::ParticleHitCount& lhs, - const ActsExamples::ParticleHitCount& rhs) { - return (lhs.hitCount > rhs.hitCount); - }); + std::ranges::sort(particleHitCounts, {}, + [](const auto& p) { return p.hitCount; }); } } // namespace diff --git a/Examples/Io/Csv/src/CsvTrackWriter.cpp b/Examples/Io/Csv/src/CsvTrackWriter.cpp index c0c25dfe51a..5ac430f4b7a 100644 --- a/Examples/Io/Csv/src/CsvTrackWriter.cpp +++ b/Examples/Io/Csv/src/CsvTrackWriter.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021-2024 CERN for the benefit of the Acts project +// Copyright (C) 2021 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -159,19 +159,19 @@ ProcessCode CsvTrackWriter::writeT(const AlgorithmContext& context, // Find duplicates std::unordered_set listGoodTracks; for (auto& [particleId, matchedTracks] : matched) { - std::ranges::sort( - matchedTracks, [](const RecoTrackInfo& lhs, const RecoTrackInfo& rhs) { - // sort by nMajorityHits - if (lhs.first.nMajorityHits != rhs.first.nMajorityHits) { - return (lhs.first.nMajorityHits > rhs.first.nMajorityHits); - } - // sort by nOutliers - if (lhs.first.nOutliers != rhs.first.nOutliers) { - return (lhs.first.nOutliers < rhs.first.nOutliers); - } - // sort by chi2 - return (lhs.first.chi2Sum < rhs.first.chi2Sum); - }); + std::sort(matchedTracks.begin(), matchedTracks.end(), + [](const RecoTrackInfo& lhs, const RecoTrackInfo& rhs) { + // sort by nMajorityHits + if (lhs.first.nMajorityHits != rhs.first.nMajorityHits) { + return (lhs.first.nMajorityHits > rhs.first.nMajorityHits); + } + // sort by nOutliers + if (lhs.first.nOutliers != rhs.first.nOutliers) { + return (lhs.first.nOutliers < rhs.first.nOutliers); + } + // sort by chi2 + return (lhs.first.chi2Sum < rhs.first.chi2Sum); + }); listGoodTracks.insert(matchedTracks.front().first.trackId); } diff --git a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp index 885248c49c0..5409d67e233 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp @@ -396,8 +396,8 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { } } - std::ranges::sort(hitIndices, [&](std::size_t a, std::size_t b) { - return simHits.nth(a)->time() < simHits.nth(b)->time(); + std::ranges::sort(hitIndices, {}, [&simHits](std::size_t h) { + return simHits.nth(h)->time(); }); for (std::size_t i = 0; i < hitIndices.size(); ++i) { diff --git a/Examples/Io/Root/src/RootSimHitReader.cpp b/Examples/Io/Root/src/RootSimHitReader.cpp index 33db881483c..65fcb446f0e 100644 --- a/Examples/Io/Root/src/RootSimHitReader.cpp +++ b/Examples/Io/Root/src/RootSimHitReader.cpp @@ -94,9 +94,8 @@ RootSimHitReader::RootSimHitReader(const RootSimHitReader::Config& config, std::get<2>(m_eventMap.back()) = nEntries; // Sort by event id - std::ranges::sort(m_eventMap, [](const auto& a, const auto& b) { - return std::get<0>(a) < std::get<0>(b); - }); + std::ranges::sort(m_eventMap, {}, + [](const auto& m) { return std::get<0>(m); }); // Re-Enable all branches m_inputChain->SetBranchStatus("*", true); diff --git a/Examples/Scripts/TrackingPerformance/defineReconstructionPerformance.C b/Examples/Scripts/TrackingPerformance/defineReconstructionPerformance.C index 78387955785..e510b013b7f 100644 --- a/Examples/Scripts/TrackingPerformance/defineReconstructionPerformance.C +++ b/Examples/Scripts/TrackingPerformance/defineReconstructionPerformance.C @@ -190,19 +190,9 @@ void defineReconstructionPerformance( for (auto& [id, matchedTracks] : matchedParticles) { // Sort all tracks matched to this particle according to majority prob // and track quality - std::ranges::sort(matchedTracks, - [](const RecoTrackInfo& lhs, const RecoTrackInfo& rhs) { - if (lhs.nMajorityHits > rhs.nMajorityHits) { - return true; - } - if (lhs.nMajorityHits < rhs.nMajorityHits) { - return false; - } - if (lhs.nMeasurements > rhs.nMeasurements) { - return true; - } - return false; - }); + std::ranges::sort(matchedTracks, {}, [](const auto& m) { + return std::tie(m.nMajorityHits, m.nMeasurements); + }); // Fill the duplication rate plots for (std::size_t k = 0; k < matchedTracks.size(); ++k) { auto eta = matchedTracks[k].eta; diff --git a/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp b/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp index cbf06328dcf..2062ae152b4 100644 --- a/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp +++ b/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp @@ -58,8 +58,8 @@ Acts::detail::GeoIntersectionAnnulusConverter::operator()( std::vector faceVertices(trapVertices.begin(), trapVertices.begin() + 4u); // to make sure they are in the right order - std::ranges::sort(faceVertices, [](const auto& a, const auto& b) { - return (VectorHelpers::phi(a) > VectorHelpers::phi(b)); + std::ranges::sort(faceVertices, {}, [](const auto& f) { + return (VectorHelpers::phi(f)); }); // Turn them into global diff --git a/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp b/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp index 3f5e1404295..6e60770f6e4 100644 --- a/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp +++ b/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp @@ -45,10 +45,7 @@ Acts::detail::GeoPolygonConverter::operator()( vertices.push_back({polygon.getXVertex(i), polygon.getYVertex(i)}); } // sort based on the y-coordinate - std::ranges::sort( - vertices, [](const std::vector& a, const std::vector& b) { - return a[1] < b[1]; - }); + std::ranges::sort(vertices, {}, [](const auto& v) { return v[1]; }); if (nVertices == 4) { double hlxnegy = fabs(vertices[0][0] - vertices[1][0]) / 2; double hlxposy = fabs(vertices[2][0] - vertices[3][0]) / 2; diff --git a/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp b/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp index 97703092e8f..ee84a5ce820 100644 --- a/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp +++ b/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp @@ -123,9 +123,8 @@ const auto dataset = // helper functions for tests template void sortByParticleId(Container& container) { - std::ranges::sort(container, [](const auto& lhs, const auto& rhs) { - return lhs.particleId() < rhs.particleId(); - }); + std::ranges::sort(container, {}, + [](const auto& c) { return c.particleId(); }); } template bool areParticleIdsUnique(const Container& sortedByParticleId) { diff --git a/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp index 9cda5545aa9..064874a1b75 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp @@ -146,9 +146,8 @@ BOOST_AUTO_TEST_CASE(test_mixture_reduction) { BOOST_CHECK_EQUAL(cmps.size(), 2); - std::ranges::sort(cmps, [](const auto &a, const auto &b) { - return a.boundPars[eBoundQOverP] < b.boundPars[eBoundQOverP]; - }); + std::ranges::sort(cmps, {}, + [](const auto &c) { return c.boundPars[eBoundQOverP]; }); BOOST_CHECK_CLOSE(cmps[0].boundPars[eBoundQOverP], 1.0_GeV, 1.e-8); BOOST_CHECK_CLOSE(cmps[1].boundPars[eBoundQOverP], 4.0_GeV, 1.e-8); @@ -182,8 +181,7 @@ BOOST_AUTO_TEST_CASE(test_weight_cut_reduction) { Acts::reduceMixtureLargestWeights(cmps, 2, *dummy); BOOST_CHECK_EQUAL(cmps.size(), 2); - std::ranges::sort( - cmps, [](const auto &a, const auto &b) { return a.weight < b.weight; }); + std::ranges::sort(cmps, {}, [](const auto &c) { return c.weight; }); BOOST_CHECK_EQUAL(cmps[0].weight, 3.0); BOOST_CHECK_EQUAL(cmps[1].weight, 4.0);