diff --git a/Core/include/Acts/Clusterization/Clusterization.ipp b/Core/include/Acts/Clusterization/Clusterization.ipp index 44f8abd1267..16047295912 100644 --- a/Core/include/Acts/Clusterization/Clusterization.ipp +++ b/Core/include/Acts/Clusterization/Clusterization.ipp @@ -1,11 +1,12 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include #include #include @@ -273,7 +274,7 @@ void labelClusters(CellCollection& cells, Connect connect) { internal::DisjointSets ds{}; // Sort cells by position to enable in-order scan - std::sort(cells.begin(), cells.end(), internal::Compare()); + std::ranges::sort(cells, internal::Compare()); // First pass: Allocate labels and record equivalences for (auto it = cells.begin(); it != cells.end(); ++it) { @@ -308,9 +309,7 @@ ClusterCollection mergeClusters(CellCollection& cells) { if constexpr (GridDim > 1) { // Sort the cells by their cluster label, only needed if more than // one spatial dimension - std::sort(cells.begin(), cells.end(), [](Cell& lhs, Cell& rhs) { - return getCellLabel(lhs) < getCellLabel(rhs); - }); + std::ranges::sort(cells, {}, [](Cell& c) { return getCellLabel(c); }); } return internal::mergeClustersImpl(cells); diff --git a/Core/include/Acts/Material/MaterialComposition.hpp b/Core/include/Acts/Material/MaterialComposition.hpp index 1b11901e032..00073a2b1f0 100644 --- a/Core/include/Acts/Material/MaterialComposition.hpp +++ b/Core/include/Acts/Material/MaterialComposition.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018-2020 CERN for the benefit of the Acts project +// Copyright (C) 2018-2024 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 @@ -100,10 +100,10 @@ class MaterialComposition { /// Rescales the fractions so they all add up to unity within the accuracy. MaterialComposition(std::vector elements) : m_elements(std::move(elements)) { - std::sort(m_elements.begin(), m_elements.end()); + std::ranges::sort(m_elements, std::less{}); // compute the total weight first unsigned total = 0u; - for (auto element : m_elements) { + for (const auto& element : m_elements) { total += element.m_fraction; } // compute scale factor into the [0, 256) range diff --git a/Core/include/Acts/Navigation/DetectorNavigator.hpp b/Core/include/Acts/Navigation/DetectorNavigator.hpp index 02522888f14..eb18295ecef 100644 --- a/Core/include/Acts/Navigation/DetectorNavigator.hpp +++ b/Core/include/Acts/Navigation/DetectorNavigator.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -22,6 +22,7 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Logger.hpp" +#include #include #include #include @@ -405,13 +406,9 @@ class DetectorNavigator { // Sort properly the surface candidates auto& nCandidates = nState.surfaceCandidates; - std::sort(nCandidates.begin(), nCandidates.end(), - [&](const auto& a, const auto& b) { - // The two path lengths - ActsScalar pathToA = a.objectIntersection.pathLength(); - ActsScalar pathToB = b.objectIntersection.pathLength(); - return pathToA < pathToB; - }); + std::ranges::sort(nCandidates, {}, [](const auto& c) { + return c.objectIntersection.pathLength(); + }); // Set the surface candidate nState.surfaceCandidateIndex = 0; } diff --git a/Core/include/Acts/Navigation/MultiLayerNavigation.hpp b/Core/include/Acts/Navigation/MultiLayerNavigation.hpp index 15042881147..12d48e5dcaa 100644 --- a/Core/include/Acts/Navigation/MultiLayerNavigation.hpp +++ b/Core/include/Acts/Navigation/MultiLayerNavigation.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -14,8 +14,10 @@ #include "Acts/Navigation/NavigationStateUpdaters.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include #include #include +#include namespace Acts::Experimental { @@ -105,16 +107,11 @@ class MultiLayerNavigation : public IInternalNavigation { void resolveDuplicates(const GeometryContext& gctx, std::vector& surfaces) const { // sorting the surfaces according to their radial distance - std::sort(surfaces.begin(), surfaces.end(), - [&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) { + assert(s != nullptr && "Uninitialized surface"); + const auto& center = s->center(gctx); + return std::make_tuple(center.x(), center.y(), center.z()); + }); // Remove the duplicates surfaces.erase(std::unique(surfaces.begin(), surfaces.end()), diff --git a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp index 3903d1e123c..b5e4d90f53b 100644 --- a/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp +++ b/Core/include/Acts/Navigation/NavigationStateUpdaters.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -20,6 +20,7 @@ #include "Acts/Utilities/IAxis.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include #include #include @@ -65,11 +66,9 @@ inline void intitializeCandidates(const GeometryContext& gctx, } } - std::sort(confirmedCandidates.begin(), confirmedCandidates.end(), - [&](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); nState.surfaceCandidateIndex = 0; diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index 73e928b762e..dba15d46ac9 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -20,6 +20,7 @@ #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/StringHelpers.hpp" +#include #include #include @@ -889,11 +890,10 @@ class Navigator { state.geoContext, stepper.position(state.stepping), state.options.direction * stepper.direction(state.stepping), navOpts, logger()); - std::sort(state.navigation.navBoundaries.begin(), - state.navigation.navBoundaries.end(), - [](const auto& a, const auto& b) { - return SurfaceIntersection::pathLengthOrder(a.first, b.first); - }); + std::ranges::sort( + state.navigation.navBoundaries, [](const auto& a, const auto& b) { + return SurfaceIntersection::pathLengthOrder(a.first, b.first); + }); // Print boundary information if (logger().doPrint(Logging::VERBOSE)) { @@ -1011,9 +1011,8 @@ class Navigator { state.navigation.navSurfaces = currentLayer->compatibleSurfaces( state.geoContext, stepper.position(state.stepping), state.options.direction * stepper.direction(state.stepping), navOpts); - std::sort(state.navigation.navSurfaces.begin(), - state.navigation.navSurfaces.end(), - SurfaceIntersection::pathLengthOrder); + std::ranges::sort(state.navigation.navSurfaces, + SurfaceIntersection::pathLengthOrder); // Print surface information if (logger().doPrint(Logging::VERBOSE)) { @@ -1079,11 +1078,10 @@ class Navigator { state.geoContext, stepper.position(state.stepping), state.options.direction * stepper.direction(state.stepping), navOpts); - std::sort(state.navigation.navLayers.begin(), - state.navigation.navLayers.end(), - [](const auto& a, const auto& b) { - return SurfaceIntersection::pathLengthOrder(a.first, b.first); - }); + std::ranges::sort( + state.navigation.navLayers, [](const auto& a, const auto& b) { + return SurfaceIntersection::pathLengthOrder(a.first, b.first); + }); // Print layer information if (logger().doPrint(Logging::VERBOSE)) { diff --git a/Core/include/Acts/Propagator/TryAllNavigator.hpp b/Core/include/Acts/Propagator/TryAllNavigator.hpp index a516a3292d2..2ba9cc6a80e 100644 --- a/Core/include/Acts/Propagator/TryAllNavigator.hpp +++ b/Core/include/Acts/Propagator/TryAllNavigator.hpp @@ -354,8 +354,8 @@ class TryAllNavigator : public TryAllNavigatorBase { } } - std::sort(intersectionCandidates.begin(), intersectionCandidates.end(), - detail::IntersectionCandidate::forwardOrder); + std::ranges::sort(intersectionCandidates, + detail::IntersectionCandidate::forwardOrder); ACTS_VERBOSE(volInfo(state) << "found " << intersectionCandidates.size() << " intersections"); @@ -766,9 +766,8 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase { } } - std::sort(state.navigation.activeCandidates.begin(), - state.navigation.activeCandidates.end(), - detail::IntersectionCandidate::forwardOrder); + std::ranges::sort(state.navigation.activeCandidates, + detail::IntersectionCandidate::forwardOrder); state.navigation.activeCandidateIndex = 0; diff --git a/Core/include/Acts/Seeding/GbtsDataStorage.hpp b/Core/include/Acts/Seeding/GbtsDataStorage.hpp index 11debd64d7f..5f088e4138e 100644 --- a/Core/include/Acts/Seeding/GbtsDataStorage.hpp +++ b/Core/include/Acts/Seeding/GbtsDataStorage.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -105,8 +105,8 @@ class GbtsEtaBin { } void sortByPhi() { - std::sort(m_vn.begin(), m_vn.end(), - typename Acts::GbtsNode::CompareByPhi()); + std::ranges::sort(m_vn, + typename Acts::GbtsNode::CompareByPhi()); } bool empty() const { return m_vn.empty(); } diff --git a/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp b/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp index 7ce93170b9a..83a8aa2b362 100644 --- a/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp +++ b/Core/include/Acts/Seeding/GbtsTrackingFilter.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -138,8 +138,8 @@ class GbtsTrackingFilter { if (m_stateVec.empty()) { return; } - std::sort(m_stateVec.begin(), m_stateVec.end(), - typename GbtsEdgeState::Compare()); + std::ranges::sort(m_stateVec, + typename GbtsEdgeState::Compare()); GbtsEdgeState* best = (*m_stateVec.begin()); diff --git a/Core/include/Acts/Seeding/HoughTransformUtils.ipp b/Core/include/Acts/Seeding/HoughTransformUtils.ipp index d6777d1918d..37ebe3ec9d9 100644 --- a/Core/include/Acts/Seeding/HoughTransformUtils.ipp +++ b/Core/include/Acts/Seeding/HoughTransformUtils.ipp @@ -1,12 +1,13 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 // 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::sort(candidates.begin(), candidates.end(), - [&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, std::greater{}, [&yieldMap](std::size_t c) { + return std::make_tuple(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 71d2a6250ce..284ab2932e3 100644 --- a/Core/include/Acts/Seeding/SeedFilter.ipp +++ b/Core/include/Acts/Seeding/SeedFilter.ipp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -69,11 +69,10 @@ void SeedFilter::filterSeeds_2SpFixed( if (topSpVec.size() > 2) { // sort indexes based on comparing values in invHelixDiameterVec - std::sort( - topSPIndexVec.begin(), topSPIndexVec.end(), - [&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 ba36b260909..f65a26e3f58 100644 --- a/Core/include/Acts/Seeding/SeedFinder.ipp +++ b/Core/include/Acts/Seeding/SeedFinder.ipp @@ -496,17 +496,13 @@ SeedFinder::filterCandidates( if constexpr (detailedMeasurement == Acts::DetectorMeasurementInfo::eDefault) { - std::sort(sorted_bottoms.begin(), sorted_bottoms.end(), - [&state](const std::size_t a, const std::size_t b) -> bool { - return state.linCircleBottom[a].cotTheta < - state.linCircleBottom[b].cotTheta; - }); - - std::sort(sorted_tops.begin(), sorted_tops.end(), - [&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/SeedFinderGbts.ipp b/Core/include/Acts/Seeding/SeedFinderGbts.ipp index 92cc7cd1963..5872707754e 100644 --- a/Core/include/Acts/Seeding/SeedFinderGbts.ipp +++ b/Core/include/Acts/Seeding/SeedFinderGbts.ipp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -17,6 +17,7 @@ #include "Acts/Seeding/SeedFinderUtils.hpp" #include "Acts/Utilities/BinningType.hpp" +#include #include #include #include @@ -352,8 +353,8 @@ void SeedFinderGbts::runGbts_TrackFinder( out_sort[outIdx].first = pS->m_p[0]; } - std::sort(in_sort.begin(), in_sort.end()); - std::sort(out_sort.begin(), out_sort.end()); + std::ranges::sort(in_sort); + std::ranges::sort(out_sort); unsigned int last_out = 0; @@ -495,8 +496,8 @@ void SeedFinderGbts::runGbts_TrackFinder( m_triplets.clear(); - std::sort(vSeeds.begin(), vSeeds.end(), - typename Acts::GbtsEdge::CompareLevel()); + std::ranges::sort( + vSeeds, typename Acts::GbtsEdge::CompareLevel()); if (vSeeds.empty()) { return; diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 31757e3e72a..7caad023cf4 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -13,6 +13,7 @@ #include "Acts/Seeding/SeedFinderUtils.hpp" #include "Acts/Utilities/BinningType.hpp" +#include #include #include #include @@ -311,16 +312,14 @@ void SeedFinderOrthogonal::filterCandidates( sorted_tops[i] = i; } - std::sort( - sorted_bottoms.begin(), sorted_bottoms.end(), - [&linCircleBottom](const std::size_t a, const std::size_t b) -> bool { - return linCircleBottom[a].cotTheta < linCircleBottom[b].cotTheta; - }); + std::ranges::sort(sorted_bottoms, {}, + [&linCircleBottom](const std::size_t s) { + return linCircleBottom[s].cotTheta; + }); - std::sort(sorted_tops.begin(), sorted_tops.end(), - [&linCircleTop](const std::size_t a, const std::size_t b) -> bool { - return linCircleTop[a].cotTheta < linCircleTop[b].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 5a88fc341ac..19d7beddbf7 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp @@ -236,9 +236,6 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid( /// sort SPs in R for each filled bin for (std::size_t binIndex : rBinsIndex) { auto& rbin = grid.atPosition(binIndex); - std::sort(rbin.begin(), rbin.end(), - [](const auto& a, const auto& b) -> bool { - return a->radius() < b->radius(); - }); + std::ranges::sort(rbin, {}, [](const auto& rb) { return rb->radius(); }); } } diff --git a/Core/include/Acts/Utilities/BinningData.hpp b/Core/include/Acts/Utilities/BinningData.hpp index ed8668a3aca..e4fcf700c9a 100644 --- a/Core/include/Acts/Utilities/BinningData.hpp +++ b/Core/include/Acts/Utilities/BinningData.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2018 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 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 @@ -481,7 +481,7 @@ class BinningData { } } // sort the total boundary vector - std::sort(m_totalBoundaries.begin(), m_totalBoundaries.end()); + std::ranges::sort(m_totalBoundaries); } } diff --git a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp index 1206528cd5c..0f26a6a1ed3 100644 --- a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp @@ -1,11 +1,12 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include #include #include @@ -463,10 +464,8 @@ Acts::SingleSeedVertexFinder::findClosestPointFromPlanes( triplet.second = distance; } - std::sort(tripletsWithPlanes.begin(), tripletsWithPlanes.end(), - [](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)); @@ -571,10 +570,8 @@ Acts::SingleSeedVertexFinder::findClosestPointFromRays( triplet.second = distance; } - std::sort(tripletsWithRays.begin(), tripletsWithRays.end(), - [](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 260cecf656a..c12bafc7b4c 100644 --- a/Core/src/Detector/LayerStructureBuilder.cpp +++ b/Core/src/Detector/LayerStructureBuilder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -25,6 +25,7 @@ #include "Acts/Utilities/GridAxisGenerators.hpp" #include "Acts/Utilities/Helpers.hpp" +#include #include #include #include @@ -338,10 +339,7 @@ Acts::Experimental::LayerStructureBuilder::construct( adaptBinningRange(binnings, m_cfg.extent.value()); } // Sort the binning for conventions - std::sort(binnings.begin(), binnings.end(), - [](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 305cd58f349..502d91f4d10 100644 --- a/Core/src/Detector/detail/BlueprintHelper.cpp +++ b/Core/src/Detector/detail/BlueprintHelper.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -12,6 +12,7 @@ #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Geometry/VolumeBounds.hpp" +#include #include namespace { @@ -55,19 +56,14 @@ 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::sort( - node.children.begin(), node.children.end(), - [&](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::sort(node.children.begin(), node.children.end(), - [](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/Detector/detail/CuboidalDetectorHelper.cpp b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp index b292db6b15f..fe7656cdfcd 100644 --- a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -379,7 +379,7 @@ Acts::Experimental::detail::CuboidalDetectorHelper::xyzBoundaries( for (auto [key, value] : map) { boundaries[im].push_back(key); } - std::sort(boundaries[im].begin(), boundaries[im].end()); + std::ranges::sort(boundaries[im]); } ACTS_VERBOSE("- did yield " << boundaries[0u].size() << " boundaries in X."); diff --git a/Core/src/Detector/detail/IndexedGridFiller.cpp b/Core/src/Detector/detail/IndexedGridFiller.cpp index 82373d23947..d1bd5d17634 100644 --- a/Core/src/Detector/detail/IndexedGridFiller.cpp +++ b/Core/src/Detector/detail/IndexedGridFiller.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -82,12 +82,12 @@ std::vector Acts::Experimental::detail::binSequence( abs(static_cast(bmin) - static_cast(expand)); fill_linear(nBins - understep, nBins); } - std::sort(rBins.begin(), rBins.end()); + std::ranges::sort(rBins); } else { // Jump over the phi boundary fill_linear(bmax - expand, nBins); fill_linear(1, bmin + expand); - std::sort(rBins.begin(), rBins.end()); + std::ranges::sort(rBins); } } return rBins; diff --git a/Core/src/Geometry/CuboidVolumeBuilder.cpp b/Core/src/Geometry/CuboidVolumeBuilder.cpp index 02b600b37ef..1d226ca05fd 100644 --- a/Core/src/Geometry/CuboidVolumeBuilder.cpp +++ b/Core/src/Geometry/CuboidVolumeBuilder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018-2020 CERN for the benefit of the Acts project +// Copyright (C) 2018-2024 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 @@ -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::sort(volumes.begin(), volumes.end(), - [](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/CylinderVolumeBuilder.cpp b/Core/src/Geometry/CylinderVolumeBuilder.cpp index 195eaefffe6..8690c1d9b82 100644 --- a/Core/src/Geometry/CylinderVolumeBuilder.cpp +++ b/Core/src/Geometry/CylinderVolumeBuilder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2020 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 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 @@ -295,8 +295,8 @@ Acts::CylinderVolumeBuilder::trackingVolume( // we check radii for consistency from the inside outwards, so need to // sort - std::sort(innerRadii.begin(), innerRadii.end()); - std::sort(outerRadii.begin(), outerRadii.end()); + std::ranges::sort(innerRadii); + std::ranges::sort(outerRadii); ACTS_DEBUG("Inner radii:" << [&]() { std::stringstream ss; diff --git a/Core/src/Geometry/CylinderVolumeStack.cpp b/Core/src/Geometry/CylinderVolumeStack.cpp index 9b4f05fc43e..af32f1b743e 100644 --- a/Core/src/Geometry/CylinderVolumeStack.cpp +++ b/Core/src/Geometry/CylinderVolumeStack.cpp @@ -15,6 +15,7 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Logger.hpp" +#include #include #include @@ -159,11 +160,9 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, if (direction == Acts::BinningValue::binZ) { ACTS_VERBOSE("Sorting by volume z position"); - std::sort(volumeTuples.begin(), volumeTuples.end(), - [](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"); std::vector gapVolumes = @@ -192,8 +191,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, ACTS_VERBOSE("*** Volume configuration after r synchronization:"); printVolumeSequence(volumeTuples, logger, Acts::Logging::VERBOSE); - std::sort(volumeTuples.begin(), volumeTuples.end(), - [](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) { @@ -222,8 +220,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, } else if (direction == Acts::BinningValue::binR) { ACTS_VERBOSE("Sorting by volume r middle point"); - std::sort(volumeTuples.begin(), volumeTuples.end(), - [](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 = @@ -250,8 +247,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, ACTS_VERBOSE("*** Volume configuration after z synchronization:"); printVolumeSequence(volumeTuples, logger, Acts::Logging::VERBOSE); - std::sort(volumeTuples.begin(), volumeTuples.end(), - [](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/Geometry/LayerArrayCreator.cpp b/Core/src/Geometry/LayerArrayCreator.cpp index baca1a8c13d..0a9c74d76f5 100644 --- a/Core/src/Geometry/LayerArrayCreator.cpp +++ b/Core/src/Geometry/LayerArrayCreator.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2018 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 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 @@ -42,7 +42,7 @@ std::unique_ptr Acts::LayerArrayCreator::layerArray( // sort it accordingly to the binning value GeometryObjectSorterT> layerSorter(gctx, bValue); - std::sort(layers.begin(), layers.end(), layerSorter); + std::ranges::sort(layers, layerSorter); // useful typedef using LayerOrderPosition = std::pair, Vector3>; // needed for all cases diff --git a/Core/src/Geometry/SurfaceArrayCreator.cpp b/Core/src/Geometry/SurfaceArrayCreator.cpp index c01a4473b4f..7968b576f2c 100644 --- a/Core/src/Geometry/SurfaceArrayCreator.cpp +++ b/Core/src/Geometry/SurfaceArrayCreator.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2020 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 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 @@ -539,7 +539,7 @@ Acts::SurfaceArrayCreator::createVariableAxis( previous = perp((*surface)->binningPosition(gctx, BinningValue::binR)); } } - std::sort(bValues.begin(), bValues.end()); + std::ranges::sort(bValues); ACTS_VERBOSE("Create variable binning Axis for binned SurfaceArray"); ACTS_VERBOSE(" BinningValue: " << bValue); ACTS_VERBOSE(" Number of bins: " << (bValues.size() - 1)); diff --git a/Core/src/Geometry/TrackingVolumeArrayCreator.cpp b/Core/src/Geometry/TrackingVolumeArrayCreator.cpp index 15ca130289a..e2d38b15fb0 100644 --- a/Core/src/Geometry/TrackingVolumeArrayCreator.cpp +++ b/Core/src/Geometry/TrackingVolumeArrayCreator.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2018 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 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 @@ -29,7 +29,7 @@ Acts::TrackingVolumeArrayCreator::trackingVolumeArray( // sort it accordingly to the binning value GeometryObjectSorterT> volumeSorter( gctx, bValue); - std::sort(volumes.begin(), volumes.end(), volumeSorter); + std::ranges::sort(volumes, volumeSorter); // prepare what we need : // (1) arbitrary binning for volumes is fast enough diff --git a/Core/src/MagneticField/BFieldMapUtils.cpp b/Core/src/MagneticField/BFieldMapUtils.cpp index b1977daac0b..bffdc7520ef 100644 --- a/Core/src/MagneticField/BFieldMapUtils.cpp +++ b/Core/src/MagneticField/BFieldMapUtils.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2017-2018 CERN for the benefit of the Acts project +// Copyright (C) 2017-2024 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 @@ -39,8 +39,8 @@ Acts::fieldMapRZ( bool firstQuadrant) { // [1] Create Grid // sort the values - std::sort(rPos.begin(), rPos.end()); - std::sort(zPos.begin(), zPos.end()); + std::ranges::sort(rPos); + std::ranges::sort(zPos); // Get unique values rPos.erase(std::unique(rPos.begin(), rPos.end()), rPos.end()); zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end()); @@ -145,9 +145,9 @@ Acts::fieldMapXYZ( double lengthUnit, double BFieldUnit, bool firstOctant) { // [1] Create Grid // Sort the values - std::sort(xPos.begin(), xPos.end()); - std::sort(yPos.begin(), yPos.end()); - std::sort(zPos.begin(), zPos.end()); + std::ranges::sort(xPos); + std::ranges::sort(yPos); + std::ranges::sort(zPos); // Get unique values xPos.erase(std::unique(xPos.begin(), xPos.end()), xPos.end()); yPos.erase(std::unique(yPos.begin(), yPos.end()), yPos.end()); diff --git a/Core/src/Material/IntersectionMaterialAssigner.cpp b/Core/src/Material/IntersectionMaterialAssigner.cpp index f3f068e8b0f..27adf41f78e 100644 --- a/Core/src/Material/IntersectionMaterialAssigner.cpp +++ b/Core/src/Material/IntersectionMaterialAssigner.cpp @@ -12,6 +12,8 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/StringHelpers.hpp" +#include + namespace { std::vector forwardOrderedIntersections( @@ -35,8 +37,8 @@ std::vector forwardOrderedIntersections( } } // Sort the intersection along the pathlength - std::sort(sIntersections.begin(), sIntersections.end(), - &Acts::SurfaceIntersection::pathLengthOrder); + std::ranges::sort(sIntersections, + &Acts::SurfaceIntersection::pathLengthOrder); return sIntersections; } diff --git a/Core/src/Material/MaterialMapUtils.cpp b/Core/src/Material/MaterialMapUtils.cpp index ee866556cd5..64fdd1f5187 100644 --- a/Core/src/Material/MaterialMapUtils.cpp +++ b/Core/src/Material/MaterialMapUtils.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2020 CERN for the benefit of the Acts project +// Copyright (C) 2019-2024 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 @@ -44,8 +44,8 @@ auto Acts::materialMapperRZ( // [2] Create Grid // sort the values - std::sort(rPos.begin(), rPos.end()); - std::sort(zPos.begin(), zPos.end()); + std::ranges::sort(rPos); + std::ranges::sort(zPos); // Get unique values rPos.erase(std::unique(rPos.begin(), rPos.end()), rPos.end()); zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end()); @@ -126,9 +126,9 @@ auto Acts::materialMapperXYZ( // [2] Create Grid // Sort the values - std::sort(xPos.begin(), xPos.end()); - std::sort(yPos.begin(), yPos.end()); - std::sort(zPos.begin(), zPos.end()); + std::ranges::sort(xPos); + std::ranges::sort(yPos); + std::ranges::sort(zPos); // Get unique values xPos.erase(std::unique(xPos.begin(), xPos.end()), xPos.end()); yPos.erase(std::unique(yPos.begin(), yPos.end()), yPos.end()); diff --git a/Core/src/Surfaces/VerticesHelper.cpp b/Core/src/Surfaces/VerticesHelper.cpp index a0367936dc9..580bb4cbd0c 100644 --- a/Core/src/Surfaces/VerticesHelper.cpp +++ b/Core/src/Surfaces/VerticesHelper.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -8,6 +8,7 @@ #include "Acts/Surfaces/detail/VerticesHelper.hpp" +#include #include #include @@ -42,7 +43,7 @@ std::vector Acts::detail::VerticesHelper::phiSegments( phiSegments.push_back(phiRef); } } - std::sort(phiSegments.begin(), phiSegments.end()); + std::ranges::sort(phiSegments); } return phiSegments; } diff --git a/Core/src/TrackFitting/GsfMixtureReduction.cpp b/Core/src/TrackFitting/GsfMixtureReduction.cpp index 6008ad66a81..d0d5b2dfd79 100644 --- a/Core/src/TrackFitting/GsfMixtureReduction.cpp +++ b/Core/src/TrackFitting/GsfMixtureReduction.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -10,6 +10,8 @@ #include "Acts/TrackFitting/detail/SymmetricKlDistanceMatrix.hpp" +#include + template void reduceWithKLDistanceImpl(std::vector &cmpCache, std::size_t maxCmpsAfterMerge, const proj_t &proj, @@ -35,10 +37,8 @@ void reduceWithKLDistanceImpl(std::vector &cmpCache, } // Remove all components which are labeled with weight -1 - std::sort(cmpCache.begin(), cmpCache.end(), - [&](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 d17518be20b..8d075fe131b 100644 --- a/Core/src/Vertexing/FsmwMode1dFinder.cpp +++ b/Core/src/Vertexing/FsmwMode1dFinder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019 CERN for the benefit of the Acts project +// Copyright (C) 2019-2024 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 @@ -28,10 +28,7 @@ Acts::Result Acts::FsmwMode1dFinder::getMode( // first of all order the vector according to the double value - std::sort(inputVector.begin(), inputVector.end(), - [](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/Digitization/src/DigitizationAlgorithm.cpp b/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp index 3ac84f45bac..3ca9b5964f8 100644 --- a/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp +++ b/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp @@ -98,7 +98,7 @@ ActsExamples::DigitizationAlgorithm::DigitizationAlgorithm( geoCfg.indices.end()); // Make sure the configured input parameter indices are sorted and unique - std::sort(indices.begin(), indices.end()); + std::ranges::sort(indices); auto dup = std::adjacent_find(indices.begin(), indices.end()); if (dup != indices.end()) { diff --git a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp index 9500671c7b3..a452c817377 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -295,13 +295,13 @@ bool ActsExamples::SensitiveSurfaceMapper::checkMapping( const State& state, const Acts::GeometryContext& gctx, bool writeMissingG4VolsAsObj, bool writeMissingSurfacesAsObj) const { auto allSurfaces = m_cfg.candidateSurfaces->queryAll(); - std::sort(allSurfaces.begin(), allSurfaces.end()); + std::ranges::sort(allSurfaces); std::vector found; for (const auto [_, surfacePtr] : state.g4VolumeToSurfaces) { found.push_back(surfacePtr); } - std::sort(found.begin(), found.end()); + std::ranges::sort(found); auto newEnd = std::unique(found.begin(), found.end()); found.erase(newEnd, found.end()); diff --git a/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp b/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp index 5dfbdcbcf73..9faa55eecc6 100644 --- a/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp +++ b/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -11,6 +11,7 @@ #include "ActsExamples/Framework/WhiteBoard.hpp" #include "ActsExamples/Io/HepMC3/HepMC3Particle.hpp" +#include #include #include @@ -167,10 +168,8 @@ void filterAndSort( // Sort the particles based on their momentum for (auto& interaction : interactions) { - std::sort(interaction.after.begin(), interaction.after.end(), - [](ActsExamples::SimParticle& a, ActsExamples::SimParticle& b) { - return a.absoluteMomentum() > b.absoluteMomentum(); - }); + std::ranges::sort(interaction.after, std::greater{}, + [](const auto& a) { return a.absoluteMomentum(); }); } } } // namespace diff --git a/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp b/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp index 3c16d146d65..acd705d855a 100644 --- a/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp +++ b/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -121,10 +121,11 @@ ActsExamples::HoughTransformSeeder::HoughTransformSeeder( // within the same volume hierarchy only consider layers return (ref.layer() == cmp.layer()); }; + // sort geometry selection so the unique filtering works + std::ranges::sort(m_cfg.geometrySelection, + std::less{}); auto geoSelBeg = m_cfg.geometrySelection.begin(); auto geoSelEnd = m_cfg.geometrySelection.end(); - // sort geometry selection so the unique filtering works - std::sort(geoSelBeg, geoSelEnd); auto geoSelLastUnique = std::unique(geoSelBeg, geoSelEnd, isDuplicate); if (geoSelLastUnique != geoSelEnd) { ACTS_WARNING("Removed " << std::distance(geoSelLastUnique, geoSelEnd) diff --git a/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp b/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp index 0605e1b4bc4..99de1dfd646 100644 --- a/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp +++ b/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020-2022 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -80,10 +80,11 @@ ActsExamples::SpacePointMaker::SpacePointMaker(Config cfg, // within the same volume hierarchy only consider layers return (ref.layer() == cmp.layer()); }; + // sort geometry selection so the unique filtering works + std::ranges::sort(m_cfg.geometrySelection, + std::less{}); auto geoSelBeg = m_cfg.geometrySelection.begin(); auto geoSelEnd = m_cfg.geometrySelection.end(); - // sort geometry selection so the unique filtering works - std::sort(geoSelBeg, geoSelEnd); auto geoSelLastUnique = std::unique(geoSelBeg, geoSelEnd, isDuplicate); if (geoSelLastUnique != geoSelEnd) { ACTS_WARNING("Removed " << std::distance(geoSelLastUnique, geoSelEnd) diff --git a/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp b/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp index 83714f83f46..5904b2dddc7 100644 --- a/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp +++ b/Examples/Algorithms/TrackFindingExaTrkX/src/PrototracksToParameters.cpp @@ -22,6 +22,7 @@ #include "ActsExamples/Utilities/EventDataTransforms.hpp" #include +#include using namespace ActsExamples; using namespace Acts::UnitLiterals; @@ -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::sort(track.begin(), track.end(), [&](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::make_tuple(indexToGeoId[t].volume(), indexToGeoId[t].layer()); }); tmpTrack.clear(); @@ -134,8 +132,7 @@ ProcessCode PrototracksToParameters::execute( continue; } - std::sort(tmpSps.begin(), tmpSps.end(), - [](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 4d8df390e50..489bf042ecd 100644 --- a/Examples/Algorithms/TrackFindingExaTrkX/src/TruthGraphBuilder.cpp +++ b/Examples/Algorithms/TrackFindingExaTrkX/src/TruthGraphBuilder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -9,6 +9,8 @@ #include #include +#include + using namespace Acts::UnitLiterals; namespace ActsExamples { @@ -82,9 +84,8 @@ std::vector TruthGraphBuilder::buildFromMeasurements( }; // Sort by radius (this breaks down if the particle has to low momentum) - std::sort(track.begin(), track.end(), [&](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( @@ -148,9 +149,7 @@ std::vector TruthGraphBuilder::buildFromSimhits( for (auto& [pid, track] : tracks) { // Sort by hit index, so the edges are connected correctly - std::sort(track.begin(), track.end(), [](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/TrackFitting/src/RefittingAlgorithm.cpp b/Examples/Algorithms/TrackFitting/src/RefittingAlgorithm.cpp index f3d0df6d1ad..ac1e41f005f 100644 --- a/Examples/Algorithms/TrackFitting/src/RefittingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFitting/src/RefittingAlgorithm.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -24,6 +24,7 @@ #include "ActsExamples/TrackFitting/RefittingCalibrator.hpp" #include "ActsExamples/TrackFitting/TrackFitterFunction.hpp" +#include #include #include #include @@ -96,13 +97,13 @@ ActsExamples::ProcessCode ActsExamples::RefittingAlgorithm::execute( trackSourceLinks.push_back(Acts::SourceLink{sl}); } - std::reverse(surfSequence.begin(), surfSequence.end()); - if (surfSequence.empty()) { ACTS_WARNING("Empty track " << itrack << " found."); continue; } + std::ranges::reverse(surfSequence); + ACTS_VERBOSE("Initial parameters: " << initialParams.fourPosition(ctx.geoContext).transpose() << " -> " << initialParams.direction().transpose()); diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp index 99e6c3ccb8e..5a79534d141 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -151,11 +151,9 @@ ActsExamples::ProcessCode ActsExamples::TruthSeedingAlgorithm::execute( continue; } // Sort the space points - std::sort(spacePointsOnTrack.begin(), spacePointsOnTrack.end(), - [](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 // between the bottom and top space point diff --git a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp index 0844ed89f1d..c4a471669d6 100644 --- a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp @@ -31,6 +31,7 @@ #include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/TruthTracking/TruthVertexFinder.hpp" +#include #include #include #include @@ -256,12 +257,10 @@ ProcessCode AdaptiveMultiVertexFinderAlgorithm::execute( } // sort by number of particles - std::sort(vertexSeederState.truthVertices.begin(), - vertexSeederState.truthVertices.end(), - [&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 " << vertexSeederState.truthVertices.size() << " in event"); diff --git a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp index b9b6e3ec3b1..7b3323fe7af 100644 --- a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp +++ b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022-2023 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -167,10 +167,8 @@ ActsExamples::MockupSectorBuilder::buildSector( // sort the detector volumes by their radial distance (from // innermost---->outermost) - std::sort(detVolumes.begin(), detVolumes.end(), - [](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/Detectors/TelescopeDetector/src/TelescopeDetector.cpp b/Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp index 0d5c35800d5..47dcf82bbd9 100644 --- a/Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp +++ b/Examples/Detectors/TelescopeDetector/src/TelescopeDetector.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020-2021 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -46,7 +46,7 @@ auto ActsExamples::Telescope::TelescopeDetector::finalize( // Sort the provided distances std::vector positions = cfg.positions; std::vector stereos = cfg.stereos; - std::sort(positions.begin(), positions.end()); + std::ranges::sort(positions); /// Return the telescope detector TrackingGeometryPtr gGeometry = ActsExamples::Telescope::buildDetector( diff --git a/Examples/Framework/include/ActsExamples/EventData/Index.hpp b/Examples/Framework/include/ActsExamples/EventData/Index.hpp index 74e7153b78f..6502c246065 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Index.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Index.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2020 CERN for the benefit of the Acts project +// Copyright (C) 2019-2024 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 @@ -55,7 +55,7 @@ inline boost::container::flat_multimap invertIndexMultimap( inverse.insert(i); } #else - std::sort(unordered.begin(), unordered.end()); + std::ranges::sort(unordered); inverse.insert(boost::container::ordered_range_t{}, unordered.begin(), unordered.end()); #endif diff --git a/Examples/Framework/src/Framework/Sequencer.cpp b/Examples/Framework/src/Framework/Sequencer.cpp index 520bc86587e..ccd5007e307 100644 --- a/Examples/Framework/src/Framework/Sequencer.cpp +++ b/Examples/Framework/src/Framework/Sequencer.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2017-2019 CERN for the benefit of the Acts project +// Copyright (C) 2017-2024 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 @@ -622,9 +622,8 @@ void Sequencer::fpeReport() const { std::transform(merged.stackTraces().begin(), merged.stackTraces().end(), std::back_inserter(sorted), [](const auto& f) -> const auto& { return f; }); - std::sort(sorted.begin(), sorted.end(), [](const auto& a, const auto& b) { - return a.get().count > b.get().count; - }); + std::ranges::sort(sorted, std::greater{}, + [](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 b7e53eaeda5..a71ac23e7b0 100644 --- a/Examples/Framework/src/Framework/WhiteBoard.cpp +++ b/Examples/Framework/src/Framework/WhiteBoard.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -8,6 +8,7 @@ #include "ActsExamples/Framework/WhiteBoard.hpp" +#include #include #include @@ -67,8 +68,7 @@ std::vector ActsExamples::WhiteBoard::similarNames( } } - std::sort(names.begin(), names.end(), - [&](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 c32c1875d5d..ab94a4a61a1 100644 --- a/Examples/Framework/src/Utilities/EventDataTransforms.cpp +++ b/Examples/Framework/src/Utilities/EventDataTransforms.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -12,6 +12,7 @@ #include "ActsExamples/EventData/IndexSourceLink.hpp" #include "ActsExamples/EventData/SimSpacePoint.hpp" +#include #include ActsExamples::ProtoTrack ActsExamples::seedToPrototrack( @@ -68,8 +69,7 @@ ActsExamples::SimSeed ActsExamples::prototrackToSeed( std::transform(track.begin(), track.end(), std::back_inserter(ps), findSpacePoint); - std::sort(ps.begin(), ps.end(), - [](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 e163106b291..5763b41d369 100644 --- a/Examples/Framework/src/Validation/TrackClassification.cpp +++ b/Examples/Framework/src/Validation/TrackClassification.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2020 CERN for the benefit of the Acts project +// Copyright (C) 2019-2024 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 @@ -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::sort(particleHitCounts.begin(), particleHitCounts.end(), - [](const ActsExamples::ParticleHitCount& lhs, - const ActsExamples::ParticleHitCount& rhs) { - return (lhs.hitCount > rhs.hitCount); - }); + std::ranges::sort(particleHitCounts, std::greater{}, + [](const auto& p) { return p.hitCount; }); } } // namespace diff --git a/Examples/Io/Csv/src/CsvMeasurementReader.cpp b/Examples/Io/Csv/src/CsvMeasurementReader.cpp index ee036ea86a9..aa68cfce2ba 100644 --- a/Examples/Io/Csv/src/CsvMeasurementReader.cpp +++ b/Examples/Io/Csv/src/CsvMeasurementReader.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -124,7 +124,7 @@ std::vector readMeasurementsByGeometryId( auto measurements = readEverything( inputDir, "measurements.csv", {"geometry_id", "t"}, event); // sort same way they will be sorted in the output container - std::sort(measurements.begin(), measurements.end(), CompareGeometryId{}); + std::ranges::sort(measurements, CompareGeometryId{}); return measurements; } diff --git a/Examples/Io/Csv/src/CsvTrackWriter.cpp b/Examples/Io/Csv/src/CsvTrackWriter.cpp index 5ac430f4b7a..a4155e7c029 100644 --- a/Examples/Io/Csv/src/CsvTrackWriter.cpp +++ b/Examples/Io/Csv/src/CsvTrackWriter.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -159,19 +160,13 @@ ProcessCode CsvTrackWriter::writeT(const AlgorithmContext& context, // Find duplicates std::unordered_set listGoodTracks; for (auto& [particleId, matchedTracks] : matched) { - 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); - }); + std::ranges::sort(matchedTracks, [](const auto& lhs, const auto& rhs) { + const auto& t1 = lhs.first; + const auto& t2 = rhs.first; + // nMajorityHits are sorted descending, others ascending + return std::tie(t2.nMajorityHits, t1.nOutliers, t1.chi2Sum) < + std::tie(t1.nMajorityHits, t2.nOutliers, t2.chi2Sum); + }); listGoodTracks.insert(matchedTracks.front().first.trackId); } diff --git a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp index 7e61ba2a561..5409d67e233 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp @@ -396,10 +396,9 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { } } - std::sort(hitIndices.begin(), hitIndices.end(), - [&](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) { auto& hit = *simHits.nth(hitIndices[i]); diff --git a/Examples/Io/Root/src/RootSimHitReader.cpp b/Examples/Io/Root/src/RootSimHitReader.cpp index 4acd9825af0..65fcb446f0e 100644 --- a/Examples/Io/Root/src/RootSimHitReader.cpp +++ b/Examples/Io/Root/src/RootSimHitReader.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -94,10 +94,8 @@ RootSimHitReader::RootSimHitReader(const RootSimHitReader::Config& config, std::get<2>(m_eventMap.back()) = nEntries; // Sort by event id - std::sort(m_eventMap.begin(), m_eventMap.end(), - [](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 04715e27fe7..c2c0322b609 100644 --- a/Examples/Scripts/TrackingPerformance/defineReconstructionPerformance.C +++ b/Examples/Scripts/TrackingPerformance/defineReconstructionPerformance.C @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2021 CERN for the benefit of the Acts project +// Copyright (C) 2021-2024 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 @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -189,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::sort(matchedTracks.begin(), matchedTracks.end(), - [](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, std::greater{}, [](const auto& m) { + return std::make_tuple(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/Fatras/src/Digitization/PlanarSurfaceMask.cpp b/Fatras/src/Digitization/PlanarSurfaceMask.cpp index f660082bfad..fc25f609917 100644 --- a/Fatras/src/Digitization/PlanarSurfaceMask.cpp +++ b/Fatras/src/Digitization/PlanarSurfaceMask.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -58,8 +58,7 @@ void checkIntersection(std::vector& intersections, Acts::Result maskAndReturn( std::vector& intersections, const ActsFatras::PlanarSurfaceMask::Segment2D& segment, bool firstInside) { - std::sort(intersections.begin(), intersections.end(), - Acts::Intersection2D::pathLengthOrder); + std::ranges::sort(intersections, Acts::Intersection2D::pathLengthOrder); if (intersections.size() >= 2) { return ActsFatras::PlanarSurfaceMask::Segment2D{ intersections[0].position(), intersections[1].position()}; diff --git a/Fatras/src/Digitization/Segmentizer.cpp b/Fatras/src/Digitization/Segmentizer.cpp index 9c2bb72c972..8a3702a772f 100644 --- a/Fatras/src/Digitization/Segmentizer.cpp +++ b/Fatras/src/Digitization/Segmentizer.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -140,7 +140,7 @@ ActsFatras::Segmentizer::segments(const Acts::GeometryContext& geoCtx, // Register the last step if successful if (!cSteps.empty()) { cSteps.push_back(ChannelStep({0, 0}, end, start)); - std::sort(cSteps.begin(), cSteps.end()); + std::ranges::sort(cSteps, std::less{}); } std::vector cSegments; diff --git a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/SeedFinder.ipp b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/SeedFinder.ipp index 6049dd3876b..7ccdc1cee62 100644 --- a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/SeedFinder.ipp +++ b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/SeedFinder.ipp @@ -306,9 +306,9 @@ SeedFinder::createSeedsForGroup( false); } - std::sort(candidates.begin(), candidates.end(), - CandidatesForMiddleSp>::descendingByQuality); + std::ranges::sort(candidates, + CandidatesForMiddleSp>::descendingByQuality); std::size_t numQualitySeeds = 0; // not used but needs to be fixed m_config.seedFilter->filterSeeds_1SpFixed(spacePointData, candidates, numQualitySeeds, diff --git a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp index deee520fab0..7304496aace 100644 --- a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp +++ b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp @@ -23,11 +23,11 @@ #include "Acts/Seeding/InternalSpacePoint.hpp" // System include(s). +#include #include #include -namespace Acts { -namespace Cuda { +namespace Acts::Cuda { template SeedFinder::SeedFinder( @@ -226,8 +226,8 @@ SeedFinder::createSeedsForGroup( candidates.emplace_back(bottomSP, middleSP, topSP, triplet.weight, 0, false); } - std::sort( - candidates.begin(), candidates.end(), + std::ranges::sort( + candidates, CandidatesForMiddleSp>:: descendingByQuality); std::size_t numQualitySeeds = 0; // not used but needs to be fixed @@ -249,5 +249,4 @@ void SeedFinder::setLogger( return m_logger.swap(newLogger); } -} // namespace Cuda -} // namespace Acts +} // namespace Acts::Cuda diff --git a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp index 4d604fbeb42..705426c9bb3 100644 --- a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp +++ b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2017-2019 CERN for the benefit of the Acts project +// Copyright (C) 2017-2024 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 @@ -102,7 +102,7 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::endcapLayers( std::back_inserter(rvalues), [&](const auto& surface) { return VectorHelpers::perp(surface->center(gctx)); }); - std::sort(rvalues.begin(), rvalues.end()); + std::ranges::sort(rvalues); std::vector locs; std::transform(rvalues.begin(), std::unique(rvalues.begin(), rvalues.end()), @@ -275,7 +275,7 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::centralLayers( std::back_inserter(zvalues), [&](const auto& surface) { return surface->center(gctx)[eZ]; }); - std::sort(zvalues.begin(), zvalues.end()); + std::ranges::sort(zvalues); std::vector locs; std::transform(zvalues.begin(), std::unique(zvalues.begin(), zvalues.end()), diff --git a/Plugins/ExaTrkX/src/BoostTrackBuilding.cpp b/Plugins/ExaTrkX/src/BoostTrackBuilding.cpp index 01083f50709..aa072c83994 100644 --- a/Plugins/ExaTrkX/src/BoostTrackBuilding.cpp +++ b/Plugins/ExaTrkX/src/BoostTrackBuilding.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -10,6 +10,7 @@ #include "Acts/Utilities/Zip.hpp" +#include #include #include @@ -82,7 +83,7 @@ std::vector> BoostTrackBuilding::operator()( ACTS_VERBOSE("Number of track labels: " << trackLabels.size()); ACTS_VERBOSE("Number of unique track labels: " << [&]() { std::vector sorted(trackLabels); - std::sort(sorted.begin(), sorted.end()); + std::ranges::sort(sorted); sorted.erase(std::unique(sorted.begin(), sorted.end()), sorted.end()); return sorted.size(); }()); diff --git a/Plugins/ExaTrkX/src/TorchTruthGraphMetricsHook.cpp b/Plugins/ExaTrkX/src/TorchTruthGraphMetricsHook.cpp index f279c5bb2cd..ce829860eb1 100644 --- a/Plugins/ExaTrkX/src/TorchTruthGraphMetricsHook.cpp +++ b/Plugins/ExaTrkX/src/TorchTruthGraphMetricsHook.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -10,6 +10,8 @@ #include "Acts/Plugins/ExaTrkX/detail/TensorVectorConversion.hpp" +#include + #include namespace { @@ -24,7 +26,8 @@ auto cantorize(std::vector edgeIndex, cantorEdgeIndex.emplace_back(*it, *std::next(it)); } - std::sort(cantorEdgeIndex.begin(), cantorEdgeIndex.end()); + std::ranges::sort(cantorEdgeIndex, + std::less>{}); auto new_end = std::unique(cantorEdgeIndex.begin(), cantorEdgeIndex.end()); if (new_end != cantorEdgeIndex.end()) { diff --git a/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp b/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp index d3214e60bc7..4ea9e715120 100644 --- a/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp +++ b/Plugins/GeoModel/src/detail/GeoIntersectionAnnulusConverter.cpp @@ -16,6 +16,8 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/detail/AnnulusBoundsHelper.hpp" +#include + #include #include #include @@ -56,10 +58,9 @@ Acts::detail::GeoIntersectionAnnulusConverter::operator()( std::vector faceVertices(trapVertices.begin(), trapVertices.begin() + 4u); // to make sure they are in the right order - std::sort(faceVertices.begin(), faceVertices.end(), - [](const auto& a, const auto& b) { - return (VectorHelpers::phi(a) > VectorHelpers::phi(b)); - }); + std::ranges::sort(faceVertices, std::greater{}, [](const auto& f) { + return (VectorHelpers::phi(f)); + }); // Turn them into global std::vector faceVertices3D; diff --git a/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp b/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp index b515dd780de..a922d5f7ca4 100644 --- a/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp +++ b/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp @@ -17,6 +17,8 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/TrapezoidBounds.hpp" +#include + #include #include #include @@ -43,10 +45,7 @@ Acts::detail::GeoPolygonConverter::operator()( vertices.push_back({polygon.getXVertex(i), polygon.getYVertex(i)}); } // sort based on the y-coordinate - std::sort(vertices.begin(), vertices.end(), - [](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/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp index eea10efad4c..f04979e03b8 100644 --- a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp +++ b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2019-2020 CERN for the benefit of the Acts project +// Copyright (C) 2019-2024 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 @@ -233,7 +233,7 @@ struct MicroBenchmarkResult { // Sorted benchmark run times, used for computing outlier-robust statistics std::vector sortedRunTimes() const { std::vector sorted_timings = run_timings; - std::sort(sorted_timings.begin(), sorted_timings.end()); + std::ranges::sort(sorted_timings); return sorted_timings; } diff --git a/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp b/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp index 6355f804ce0..69dc85d9fd7 100644 --- a/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp +++ b/Tests/IntegrationTests/Fatras/FatrasSimulationTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020-2021 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -123,10 +123,8 @@ const auto dataset = // helper functions for tests template void sortByParticleId(Container& container) { - std::sort(container.begin(), container.end(), - [](const auto& lhs, const auto& rhs) { - return lhs.particleId() < rhs.particleId(); - }); + std::ranges::sort(container, std::less{}, + [](const auto& c) { return c.particleId(); }); } template bool areParticleIdsUnique(const Container& sortedByParticleId) { diff --git a/Tests/IntegrationTests/Legacy/ATLSeedingIntegrationTest.cpp b/Tests/IntegrationTests/Legacy/ATLSeedingIntegrationTest.cpp index 0e6c730bfac..20876537961 100644 --- a/Tests/IntegrationTests/Legacy/ATLSeedingIntegrationTest.cpp +++ b/Tests/IntegrationTests/Legacy/ATLSeedingIntegrationTest.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018 CERN for the benefit of the Acts project +// Copyright (C) 2018-2024 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 @@ -137,8 +137,8 @@ BOOST_AUTO_TEST_CASE(number_of_seeds_correct_) { // sorting required for set_difference call. sorting assumes space points // inside seed are already sorted. - std::sort(refVec.begin(), refVec.end(), seedComparator()); - std::sort(seedVec.begin(), seedVec.end(), seedComparator()); + std::ranges::sort(refVec, seedComparator()); + std::ranges::sort(seedVec, seedComparator()); // difference between reference and result shows if results exactly the same // (i.e. difference is 0) diff --git a/Tests/IntegrationTests/NavigatorConsistency.cpp b/Tests/IntegrationTests/NavigatorConsistency.cpp index c4a380a5d3f..b8de4d6b8d1 100644 --- a/Tests/IntegrationTests/NavigatorConsistency.cpp +++ b/Tests/IntegrationTests/NavigatorConsistency.cpp @@ -23,6 +23,8 @@ #include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include + namespace bdata = boost::unit_test::data; using namespace Acts::UnitLiterals; using Acts::VectorHelpers::perp; @@ -130,7 +132,7 @@ void runSelfConsistencyTest(const propagator_t& prop, // forward-backward compatibility test { - std::reverse(bwdSurfaces.begin(), bwdSurfaces.end()); + std::ranges::reverse(bwdSurfaces); BOOST_CHECK_EQUAL_COLLECTIONS(bwdSurfaces.begin(), bwdSurfaces.end(), fwdSurfaces.begin(), fwdSurfaces.end()); } @@ -235,7 +237,7 @@ void runSelfConsistencyTest(const propagator_t& prop, // TODO backward-backward step compatibility test - std::reverse(bwdStepSurfaces.begin(), bwdStepSurfaces.end()); + std::ranges::reverse(bwdStepSurfaces); BOOST_CHECK_EQUAL_COLLECTIONS(bwdStepSurfaces.begin(), bwdStepSurfaces.end(), fwdStepSurfaces.begin(), fwdStepSurfaces.end()); } diff --git a/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp b/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp index 83423852791..3ab655ade8d 100644 --- a/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp +++ b/Tests/UnitTests/Core/Clusterization/ClusterizationTests1D.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -54,7 +54,7 @@ bool clHashComp(const Cluster1D& left, const Cluster1D& right) { } void hash(Cluster1D& cl) { - std::sort(cl.cells.begin(), cl.cells.end(), cellComp); + std::ranges::sort(cl.cells, cellComp); cl.hash = 0; for (const Cell1D& c : cl.cells) { boost::hash_combine(cl.hash, c.col); @@ -117,8 +117,8 @@ BOOST_AUTO_TEST_CASE(Grid_1D_rand) { hash(cl); } - std::sort(clusters.begin(), clusters.end(), clHashComp); - std::sort(newCls.begin(), newCls.end(), clHashComp); + std::ranges::sort(clusters, clHashComp); + std::ranges::sort(newCls, clHashComp); BOOST_CHECK_EQUAL(clusters.size(), newCls.size()); for (std::size_t i = 0; i < clusters.size(); i++) { diff --git a/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp b/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp index d4ebb6f2c37..6a2808d90ba 100644 --- a/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp +++ b/Tests/UnitTests/Core/Clusterization/ClusterizationTests2D.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -114,7 +114,7 @@ void clusterAddCell(Cluster2D& cl, const Cell2D& cell) { } void hash(Cluster2D& cl) { - std::sort(cl.cells.begin(), cl.cells.end(), cellComp); + std::ranges::sort(cl.cells, cellComp); cl.hash = 0; for (const Cell2D& c : cl.cells) { boost::hash_combine(cl.hash, c.col); @@ -237,8 +237,8 @@ BOOST_AUTO_TEST_CASE(Grid_2D_rand) { hash(cl); } - std::sort(cls.begin(), cls.end(), clHashComp); - std::sort(newCls.begin(), newCls.end(), clHashComp); + std::ranges::sort(cls, clHashComp); + std::ranges::sort(newCls, clHashComp); BOOST_CHECK_EQUAL(cls.size(), newCls.size()); for (std::size_t i = 0; i < cls.size(); i++) { diff --git a/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp index aba5426de06..9a194dbef1b 100644 --- a/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp +++ b/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2023 CERN for the benefit of the Acts project +// Copyright (C) 2023-2024 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 @@ -26,6 +26,7 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BinningData.hpp" +#include #include class SurfaceBuilder : public Acts::Experimental::IInternalStructureBuilder { @@ -363,7 +364,7 @@ BOOST_AUTO_TEST_CASE(CuboidalDetectorFromBlueprintTest) { portals.insert(portals.end(), volume->portals().begin(), volume->portals().end()); } - std::sort(portals.begin(), portals.end()); + std::ranges::sort(portals); auto last = std::unique(portals.begin(), portals.end()); portals.erase(last, portals.end()); BOOST_CHECK_EQUAL(portals.size(), 19u); diff --git a/Tests/UnitTests/Core/EventData/TrackTests.cpp b/Tests/UnitTests/Core/EventData/TrackTests.cpp index 698ea737d2a..db8863e5e6b 100644 --- a/Tests/UnitTests/Core/EventData/TrackTests.cpp +++ b/Tests/UnitTests/Core/EventData/TrackTests.cpp @@ -24,6 +24,7 @@ #include "Acts/Utilities/HashedString.hpp" #include "Acts/Utilities/Holders.hpp" +#include #include #include #include @@ -441,7 +442,7 @@ BOOST_AUTO_TEST_CASE(ForwardIteration) { indices.push_back(ts.index()); } - std::reverse(indices.begin(), indices.end()); + std::ranges::reverse(indices); std::vector act; for (auto ts : t.trackStates()) { diff --git a/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp b/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp index 2f7df54f055..8dd12203991 100644 --- a/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp +++ b/Tests/UnitTests/Core/EventData/TrackTestsExtra.cpp @@ -16,6 +16,7 @@ #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Utilities/Zip.hpp" +#include #include using namespace Acts; @@ -421,7 +422,7 @@ BOOST_AUTO_TEST_CASE(ReverseTrackStates) { // reverse with jacobians t.reverseTrackStates(true); - std::reverse(exp.begin(), exp.end()); + std::ranges::reverse(exp); std::rotate(exp.rbegin(), std::next(exp.rbegin()), exp.rend()); for (const auto [e, ts] : zip(exp, t.trackStates())) { diff --git a/Tests/UnitTests/Core/Seeding/CandidatesForMiddleSpTests.cpp b/Tests/UnitTests/Core/Seeding/CandidatesForMiddleSpTests.cpp index 3d8b672cb45..e6068ed248c 100644 --- a/Tests/UnitTests/Core/Seeding/CandidatesForMiddleSpTests.cpp +++ b/Tests/UnitTests/Core/Seeding/CandidatesForMiddleSpTests.cpp @@ -10,6 +10,7 @@ #include "Acts/Seeding/CandidatesForMiddleSp.hpp" +#include #include #include @@ -145,16 +146,16 @@ BOOST_AUTO_TEST_CASE(CandidatesForMiddleSpObject) { BOOST_CHECK(storagedValues[i].weight >= storagedValues[i + 1].weight); } - std::sort( - storagedValues.begin(), storagedValues.end(), + std::ranges::sort( + storagedValues, Acts::CandidatesForMiddleSp::ascendingByQuality); // check values are sorted properly for (std::size_t i(0); i < storagedValues.size() - 1; ++i) { BOOST_CHECK(storagedValues[i].weight <= storagedValues[i + 1].weight); } - std::sort( - storagedValues.begin(), storagedValues.end(), + std::ranges::sort( + storagedValues, Acts::CandidatesForMiddleSp::descendingByQuality); // check values are sorted properly for (std::size_t i(0); i < storagedValues.size() - 1; ++i) { diff --git a/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp index 6a8b1ff7cd4..064874a1b75 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfMixtureReductionTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022-2023 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -146,9 +146,8 @@ BOOST_AUTO_TEST_CASE(test_mixture_reduction) { BOOST_CHECK_EQUAL(cmps.size(), 2); - std::sort(cmps.begin(), cmps.end(), [](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::sort(cmps.begin(), cmps.end(), - [](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); diff --git a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp index 644371c45a4..185b3457e43 100644 --- a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp +++ b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2018 CERN for the benefit of the Acts project +// Copyright (C) 2018-2024 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 @@ -51,8 +51,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { std::vector tsfpIntersections = {tIp, sIp, fIp}; // let's sort the tsf intersection, it should give fst - std::sort(tsfpIntersections.begin(), tsfpIntersections.end(), - Intersection3D::pathLengthOrder); + std::ranges::sort(tsfpIntersections, Intersection3D::pathLengthOrder); BOOST_CHECK_EQUAL(fstpIntersections[0].pathLength(), tsfpIntersections[0].pathLength()); BOOST_CHECK_EQUAL(fstpIntersections[1].pathLength(), @@ -66,8 +65,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { std::vector tfnsnpIntersections = {tIp, fIp, nIp, sIp, nIp}; // shuffle the intersections - std::sort(ntfspIntersections.begin(), ntfspIntersections.end(), - Intersection3D::pathLengthOrder); + std::ranges::sort(ntfspIntersections, Intersection3D::pathLengthOrder); BOOST_CHECK_EQUAL(fstpIntersections[0].pathLength(), ntfspIntersections[0].pathLength()); BOOST_CHECK_EQUAL(fstpIntersections[1].pathLength(), @@ -75,8 +73,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { BOOST_CHECK_EQUAL(fstpIntersections[2].pathLength(), ntfspIntersections[2].pathLength()); - std::sort(tfnsnpIntersections.begin(), tfnsnpIntersections.end(), - Intersection3D::pathLengthOrder); + std::ranges::sort(tfnsnpIntersections, Intersection3D::pathLengthOrder); BOOST_CHECK_EQUAL(fstpIntersections[0].pathLength(), tfnsnpIntersections[0].pathLength()); BOOST_CHECK_EQUAL(fstpIntersections[1].pathLength(), @@ -96,8 +93,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { std::vector fstnIntersections = {fIn, sIn, tIn}; // this time around, sort the f-s-t-n to match the t-s-f-n - std::sort(fstnIntersections.begin(), fstnIntersections.end(), - Intersection3D::pathLengthOrder); + std::ranges::sort(fstnIntersections, Intersection3D::pathLengthOrder); BOOST_CHECK_EQUAL(fstnIntersections[0].pathLength(), tsfnIntersections[0].pathLength()); BOOST_CHECK_EQUAL(fstnIntersections[1].pathLength(), @@ -107,8 +103,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { // shuffle negative and positive solutions std::vector pnsolutions = {tIp, sIn, sIp, fIn, tIn, fIp}; - std::sort(pnsolutions.begin(), pnsolutions.end(), - Intersection3D::pathLengthOrder); + std::ranges::sort(pnsolutions, Intersection3D::pathLengthOrder); BOOST_CHECK_EQUAL(pnsolutions[0].pathLength(), -3.); BOOST_CHECK_EQUAL(pnsolutions[1].pathLength(), -2.); @@ -121,8 +116,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { Intersection3D zI(Vector3(0., 0., 0.), 0., Intersection3D::Status::onSurface); std::vector tszfpIntersections = {tIp, sIp, zI, fIp}; - std::sort(tszfpIntersections.begin(), tszfpIntersections.end(), - Intersection3D::pathLengthOrder); + std::ranges::sort(tszfpIntersections, Intersection3D::pathLengthOrder); BOOST_CHECK_EQUAL(tszfpIntersections[0].pathLength(), 0.); BOOST_CHECK_EQUAL(tszfpIntersections[1].pathLength(), 1.); BOOST_CHECK_EQUAL(tszfpIntersections[2].pathLength(), 2.); @@ -131,8 +125,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { std::vector tfsznIntersections = {tIn, fIn, sIn, zI}; std::vector ztfsnIntersections = {zI, tIn, fIn, sIn}; - std::sort(tfsznIntersections.begin(), tfsznIntersections.end(), - Intersection3D::pathLengthOrder); + std::ranges::sort(tfsznIntersections, Intersection3D::pathLengthOrder); BOOST_CHECK_EQUAL(tfsznIntersections[0].pathLength(), -3.); BOOST_CHECK_EQUAL(tfsznIntersections[1].pathLength(), -2.); BOOST_CHECK_EQUAL(tfsznIntersections[2].pathLength(), -1.); diff --git a/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp b/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp index 2fbf0d2ffc4..d61c46a3d69 100644 --- a/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp +++ b/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2020 CERN for the benefit of the Acts project +// Copyright (C) 2020-2024 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 @@ -78,7 +78,7 @@ std::array selectFixedIndices( for (auto i = 0u; i < kSize; ++i) { indices[i] = fullIndices[i]; } - std::sort(indices.begin(), indices.end()); + std::ranges::sort(indices); return indices; } diff --git a/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp b/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp index 65261563e34..0ccbc53e999 100644 --- a/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp +++ b/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXBoostTrackBuildingTests.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -51,9 +51,9 @@ BOOST_AUTO_TEST_CASE(test_track_building) { // Sort tracks, so we can find them std::for_each(testTracks.begin(), testTracks.end(), - [](auto &t) { std::sort(t.begin(), t.end()); }); + [](auto &t) { std::ranges::sort(t); }); std::for_each(refTracks.begin(), refTracks.end(), - [](auto &t) { std::sort(t.begin(), t.end()); }); + [](auto &t) { std::ranges::sort(t); }); // Check what we have here for (const auto &refTrack : refTracks) { diff --git a/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXEdgeBuildingTest.cpp b/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXEdgeBuildingTest.cpp index 7e75b2a8b43..3f671aeb04e 100644 --- a/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXEdgeBuildingTest.cpp +++ b/Tests/UnitTests/Plugins/ExaTrkX/ExaTrkXEdgeBuildingTest.cpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2022 CERN for the benefit of the Acts project +// Copyright (C) 2022-2024 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 @@ -12,6 +12,7 @@ #include "Acts/Plugins/ExaTrkX/detail/TensorVectorConversion.hpp" #include "Acts/Plugins/ExaTrkX/detail/buildEdges.hpp" +#include #include #include @@ -83,8 +84,8 @@ void test_random_graph(int emb_dim, int n_nodes, float r, int knn, edges_test_cantor.push_back(a < b ? CantorPair(a, b) : CantorPair(b, a)); } - std::sort(edges_ref_cantor.begin(), edges_ref_cantor.end()); - std::sort(edges_test_cantor.begin(), edges_test_cantor.end()); + std::ranges::sort(edges_ref_cantor, std::less{}); + std::ranges::sort(edges_test_cantor, std::less{}); #if PRINT std::cout << "test size " << edges_test_cantor.size() << std::endl;