diff --git a/Core/include/Acts/TrackFitting/KalmanFitter.hpp b/Core/include/Acts/TrackFitting/KalmanFitter.hpp index f55b0fac1cf..b0fe848c17b 100644 --- a/Core/include/Acts/TrackFitting/KalmanFitter.hpp +++ b/Core/include/Acts/TrackFitting/KalmanFitter.hpp @@ -484,11 +484,8 @@ class KalmanFitter { result.fittedStates->applyBackwards( result.lastMeasurementIndex, [&](auto trackState) { auto fSurface = &trackState.referenceSurface(); - auto surface_it = std::find_if( - result.passedAgainSurfaces.begin(), - result.passedAgainSurfaces.end(), - [=](const Surface* s) { return s == fSurface; }); - if (surface_it == result.passedAgainSurfaces.end()) { + if (!rangeContainsValue(result.passedAgainSurfaces, + fSurface)) { // If reversed filtering missed this surface, then there is // no smoothed parameter trackState.unset(TrackStatePropMask::Smoothed); diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp index 73884fd31f3..91f18618673 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp @@ -22,6 +22,7 @@ #include "Acts/Vertexing/VertexingError.hpp" #include "Acts/Vertexing/VertexingOptions.hpp" +#include #include namespace Acts { @@ -81,8 +82,7 @@ class AdaptiveMultiVertexFitter { Result removeVertexFromCollection(Vertex& vtxToRemove, const Logger& logger) { - auto it = std::find(vertexCollection.begin(), vertexCollection.end(), - &vtxToRemove); + auto it = std::ranges::find(vertexCollection, &vtxToRemove); // Check if the value was found before erasing if (it == vertexCollection.end()) { ACTS_ERROR("vtxToRemove is not part of vertexCollection."); diff --git a/Core/src/Geometry/CylinderVolumeBuilder.cpp b/Core/src/Geometry/CylinderVolumeBuilder.cpp index bb741167519..47de379d9be 100644 --- a/Core/src/Geometry/CylinderVolumeBuilder.cpp +++ b/Core/src/Geometry/CylinderVolumeBuilder.cpp @@ -274,19 +274,17 @@ Acts::CylinderVolumeBuilder::trackingVolume( double tolerance = m_cfg.ringTolerance; // Search for the rmin value - and insert if necessary double rMin = discBounds->rMin(); - auto innerSearch = std::find_if( - innerRadii.begin(), innerRadii.end(), [&](double reference) { - return std::abs(rMin - reference) < tolerance; - }); + auto innerSearch = std::ranges::find_if(innerRadii, [&](double r) { + return std::abs(rMin - r) < tolerance; + }); if (innerSearch == innerRadii.end()) { innerRadii.push_back(rMin); } // Search for the rmax value - and insert if necessary double rMax = discBounds->rMax(); - auto outerSearch = std::find_if( - outerRadii.begin(), outerRadii.end(), [&](double reference) { - return std::abs(rMax - reference) < tolerance; - }); + auto outerSearch = std::ranges::find_if(outerRadii, [&](double r) { + return std::abs(rMax - r) < tolerance; + }); if (outerSearch == outerRadii.end()) { outerRadii.push_back(rMax); } @@ -356,10 +354,9 @@ Acts::CylinderVolumeBuilder::trackingVolume( double test = elay->surfaceRepresentation().binningPositionValue( gctx, BinningValue::binR); // Find the right bin - auto ringVolume = std::find_if( - volumeRminRmax.begin(), volumeRminRmax.end(), - [&](const auto& reference) { - return (test > reference.first && test < reference.second); + auto ringVolume = + std::ranges::find_if(volumeRminRmax, [&](const auto& vrr) { + return (test > vrr.first && test < vrr.second); }); if (ringVolume != volumeRminRmax.end()) { unsigned int ringBin = diff --git a/Core/src/Geometry/Layer.cpp b/Core/src/Geometry/Layer.cpp index dca511b3978..024f99e9c42 100644 --- a/Core/src/Geometry/Layer.cpp +++ b/Core/src/Geometry/Layer.cpp @@ -126,11 +126,9 @@ Acts::Layer::compatibleSurfaces( double farLimit = options.farLimit; auto isUnique = [&](const SurfaceIntersection& b) { - auto find_it = std::find_if( - sIntersections.begin(), sIntersections.end(), [&b](const auto& a) { - return a.object() == b.object() && a.index() == b.index(); - }); - return find_it == sIntersections.end(); + return std::ranges::none_of(sIntersections, [&b](const auto& a) { + return a.object() == b.object() && a.index() == b.index(); + }); }; // lemma 0 : accept the surface @@ -140,7 +138,7 @@ Acts::Layer::compatibleSurfaces( if (sensitive && options.resolveSensitive) { return true; } - // next option: it's a material surface and you want to have it + // next option: it's a material surface, and you want to have it if (options.resolveMaterial && sf.surfaceMaterial() != nullptr) { return true; } diff --git a/Core/src/Surfaces/VerticesHelper.cpp b/Core/src/Surfaces/VerticesHelper.cpp index 3ff4785fe37..448ee97e8da 100644 --- a/Core/src/Surfaces/VerticesHelper.cpp +++ b/Core/src/Surfaces/VerticesHelper.cpp @@ -35,11 +35,9 @@ std::vector Acts::detail::VerticesHelper::phiSegments( if (!phiRefs.empty()) { for (const auto& phiRef : phiRefs) { // Trying to find the right patch - auto match = std::find_if( - phiSegments.begin(), phiSegments.end(), [&](ActsScalar phiSeg) { + if (std::ranges::none_of(phiSegments, [&](ActsScalar phiSeg) { return std::abs(phiSeg - phiRef) < phiTolerance; - }); - if (match == phiSegments.end()) { + })) { phiSegments.push_back(phiRef); } } diff --git a/Core/src/TrackFinding/MeasurementSelector.cpp b/Core/src/TrackFinding/MeasurementSelector.cpp index cde6670e4ca..130c8381536 100644 --- a/Core/src/TrackFinding/MeasurementSelector.cpp +++ b/Core/src/TrackFinding/MeasurementSelector.cpp @@ -118,10 +118,10 @@ MeasurementSelector::Cuts MeasurementSelector::getCutsByTheta( // look at the positive half of the Z axis const double constrainedTheta = std::min(theta, M_PI - theta); - auto it = std::find_if(config.begin(), config.end(), - [constrainedTheta](const InternalCutBin& cuts) { - return constrainedTheta < cuts.maxTheta; - }); + auto it = std::ranges::find_if( + config, [constrainedTheta](const InternalCutBin& cuts) { + return constrainedTheta < cuts.maxTheta; + }); assert(it != config.end()); return {it->maxNumMeasurements, it->maxChi2Measurement, it->maxChi2Outlier}; } diff --git a/Core/src/Utilities/BinningType.cpp b/Core/src/Utilities/BinningType.cpp index e1ed3ecea71..8faa7dcd856 100644 --- a/Core/src/Utilities/BinningType.cpp +++ b/Core/src/Utilities/BinningType.cpp @@ -32,8 +32,7 @@ const std::vector& allBinningValues() { } BinningValue binningValueFromName(const std::string& name) { - auto it = - std::find(s_binningValueNames.begin(), s_binningValueNames.end(), name); + auto it = std::ranges::find(s_binningValueNames, name); if (it == s_binningValueNames.end()) { throw std::invalid_argument("Unknown binning value name: " + name); } diff --git a/Core/src/Vertexing/AdaptiveMultiVertexFinder.cpp b/Core/src/Vertexing/AdaptiveMultiVertexFinder.cpp index 655ee0b218f..34d20e32e0a 100644 --- a/Core/src/Vertexing/AdaptiveMultiVertexFinder.cpp +++ b/Core/src/Vertexing/AdaptiveMultiVertexFinder.cpp @@ -12,6 +12,8 @@ #include "Acts/Vertexing/IVertexFinder.hpp" #include "Acts/Vertexing/VertexingError.hpp" +#include + namespace Acts { Result> AdaptiveMultiVertexFinder::find( @@ -364,10 +366,7 @@ std::pair AdaptiveMultiVertexFinder::checkVertexAndCompatibleTracks( !m_cfg.useFastCompatibility)) { // TODO: Understand why looking for compatible tracks only in seed tracks // and not also in all tracks - auto foundIter = - std::find_if(seedTracks.begin(), seedTracks.end(), - [&trk](auto seedTrk) { return trk == seedTrk; }); - if (foundIter != seedTracks.end()) { + if (rangeContainsValue(seedTracks, trk)) { nCompatibleTracks++; ACTS_DEBUG("Compatible track found."); @@ -399,9 +398,7 @@ auto AdaptiveMultiVertexFinder::removeCompatibleTracksFromSeedTracks( trkAtVtx.chi2Track < m_cfg.maxVertexChi2 && !m_cfg.useFastCompatibility)) { // Find and remove track from seedTracks - auto foundSeedIter = - std::find_if(seedTracks.begin(), seedTracks.end(), - [&trk](auto seedTrk) { return trk == seedTrk; }); + auto foundSeedIter = std::ranges::find(seedTracks, trk); if (foundSeedIter != seedTracks.end()) { seedTracks.erase(foundSeedIter); removedSeedTracks.push_back(trk); @@ -425,9 +422,7 @@ bool AdaptiveMultiVertexFinder::removeTrackIfIncompatible( double compatibility = trkAtVtx.vertexCompatibility; if (compatibility > maxCompatibility) { // Try to find track in seed tracks - auto foundSeedIter = - std::find_if(seedTracks.begin(), seedTracks.end(), - [&trk](auto seedTrk) { return trk == seedTrk; }); + auto foundSeedIter = std::ranges::find(seedTracks, trk); if (foundSeedIter != seedTracks.end()) { maxCompatibility = compatibility; maxCompSeedIt = foundSeedIter; diff --git a/Core/src/Vertexing/IterativeVertexFinder.cpp b/Core/src/Vertexing/IterativeVertexFinder.cpp index e455dca47ec..9c03ba8a8f8 100644 --- a/Core/src/Vertexing/IterativeVertexFinder.cpp +++ b/Core/src/Vertexing/IterativeVertexFinder.cpp @@ -222,10 +222,9 @@ inline void Acts::IterativeVertexFinder::removeTracks( const BoundTrackParameters& params = m_cfg.extractParameters(trk); // Find track in seedTracks auto foundIter = - std::find_if(seedTracks.begin(), seedTracks.end(), - [¶ms, this](const auto seedTrk) { - return params == m_cfg.extractParameters(seedTrk); - }); + std::ranges::find_if(seedTracks, [¶ms, this](const auto seedTrk) { + return params == m_cfg.extractParameters(seedTrk); + }); if (foundIter != seedTracks.end()) { // Remove track from seed tracks seedTracks.erase(foundIter); @@ -284,10 +283,7 @@ Acts::Result Acts::IterativeVertexFinder::removeUsedCompatibleTracks( } // Find and remove track from seedTracks auto foundSeedIter = - std::find_if(seedTracks.begin(), seedTracks.end(), - [&trackAtVtx](const auto& seedTrk) { - return trackAtVtx.originalParams == seedTrk; - }); + std::ranges::find(seedTracks, trackAtVtx.originalParams); if (foundSeedIter != seedTracks.end()) { seedTracks.erase(foundSeedIter); } else { @@ -296,10 +292,7 @@ Acts::Result Acts::IterativeVertexFinder::removeUsedCompatibleTracks( // Find and remove track from tracksToFit auto foundFitIter = - std::find_if(tracksToFit.begin(), tracksToFit.end(), - [&trackAtVtx](const auto& fitTrk) { - return trackAtVtx.originalParams == fitTrk; - }); + std::ranges::find(tracksToFit, trackAtVtx.originalParams); if (foundFitIter != tracksToFit.end()) { tracksToFit.erase(foundFitIter); } else { @@ -334,9 +327,7 @@ Acts::Result Acts::IterativeVertexFinder::removeUsedCompatibleTracks( // check if sufficiently compatible with last fitted vertex // (quite loose constraint) if (chi2 < m_cfg.maximumChi2cutForSeeding) { - auto foundIter = - std::find_if(seedTracks.begin(), seedTracks.end(), - [&trk](const auto& seedTrk) { return trk == seedTrk; }); + auto foundIter = std::ranges::find(seedTracks, trk); if (foundIter != seedTracks.end()) { // Remove track from seed tracks seedTracks.erase(foundIter); @@ -345,8 +336,8 @@ Acts::Result Acts::IterativeVertexFinder::removeUsedCompatibleTracks( } else { // Track not compatible with vertex // Remove track from current vertex - auto foundIter = std::find_if( - tracksAtVertex.begin(), tracksAtVertex.end(), + auto foundIter = std::ranges::find_if( + tracksAtVertex, [&trk](auto trkAtVtx) { return trk == trkAtVtx.originalParams; }); if (foundIter != tracksAtVertex.end()) { // Remove track from seed tracks @@ -495,8 +486,8 @@ Acts::Result Acts::IterativeVertexFinder::reassignTracksToNewVertex( // delete it later // when all tracks used to fit current vertex are deleted seedTracks.push_back(tracksIter->originalParams); - // seedTracks.push_back(*std::find_if( - // origTracks.begin(), origTracks.end(), + // seedTracks.push_back(*std::ranges::find_if( + // origTracks, // [&origParams, this](auto origTrack) { // return origParams == m_extractParameters(*origTrack); // })); diff --git a/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp b/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp index 91de17b9eef..808bf931c6a 100644 --- a/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp +++ b/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp @@ -154,11 +154,10 @@ Pythia8Generator::operator()(RandomEngine& rng) { // check if an existing vertex is close enough auto it = - std::find_if(vertices.begin(), vertices.end(), - [&pos4, this](const SimVertex& other) { - return (pos4.head<3>() - other.position()).norm() < - m_cfg.spatialVertexThreshold; - }); + std::ranges::find_if(vertices, [&pos4, this](const SimVertex& v) { + return (pos4.head<3>() - v.position()).norm() < + m_cfg.spatialVertexThreshold; + }); if (it != vertices.end()) { particleId.setVertexSecondary(std::distance(vertices.begin(), it)); diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp index 565b04c9ae3..b06e538885c 100644 --- a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -93,14 +94,10 @@ class MappingMaterialDecorator : public IMaterialDecorator { /// /// @param volume to be looped onto void volumeLoop(const Acts::TrackingVolume* tVolume) { - auto sameId = - [tVolume]( - const std::pair>& pair) { - return (tVolume->geometryId() == pair.first); - }; - if (std::find_if(m_volumeMaterialMap.begin(), m_volumeMaterialMap.end(), - sameId) != m_volumeMaterialMap.end()) { + auto sameId = [tVolume](const auto& pair) { + return (tVolume->geometryId() == pair.first); + }; + if (std::ranges::any_of(m_volumeMaterialMap, sameId)) { // this volume was already visited return; } diff --git a/Examples/Algorithms/Vertexing/src/VertexingHelpers.hpp b/Examples/Algorithms/Vertexing/src/VertexingHelpers.hpp index 9d3afe19646..3222578a3da 100644 --- a/Examples/Algorithms/Vertexing/src/VertexingHelpers.hpp +++ b/Examples/Algorithms/Vertexing/src/VertexingHelpers.hpp @@ -15,6 +15,7 @@ #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/DataHandle.hpp" +#include #include #include @@ -55,8 +56,7 @@ inline ProtoVertexContainer makeProtoVertices( protoVertex.reserve(vertex.tracks().size()); for (const auto& track : vertex.tracks()) { - auto it = std::find(inputTracks.begin(), inputTracks.end(), - track.originalParams); + auto it = std::ranges::find(inputTracks, track.originalParams); if (it != inputTracks.end()) { protoVertex.push_back(std::distance(inputTracks.begin(), it)); } else { diff --git a/Examples/Framework/src/Utilities/EventDataTransforms.cpp b/Examples/Framework/src/Utilities/EventDataTransforms.cpp index bad2764b163..79d3d543a05 100644 --- a/Examples/Framework/src/Utilities/EventDataTransforms.cpp +++ b/Examples/Framework/src/Utilities/EventDataTransforms.cpp @@ -37,7 +37,7 @@ const ActsExamples::SimSpacePoint* ActsExamples::findSpacePointForIndex( }); }; - auto found = std::find_if(spacepoints.begin(), spacepoints.end(), match); + auto found = std::ranges::find_if(spacepoints, match); if (found == spacepoints.end()) { return nullptr; diff --git a/Examples/Framework/src/Validation/TrackClassification.cpp b/Examples/Framework/src/Validation/TrackClassification.cpp index 0341dc09e5a..a89f7c2a07a 100644 --- a/Examples/Framework/src/Validation/TrackClassification.cpp +++ b/Examples/Framework/src/Validation/TrackClassification.cpp @@ -25,10 +25,9 @@ inline void increaseHitCount( std::vector& particleHitCounts, ActsFatras::Barcode particleId) { // linear search since there is no ordering - auto it = std::find_if(particleHitCounts.begin(), particleHitCounts.end(), - [=](const ActsExamples::ParticleHitCount& phc) { - return (phc.particleId == particleId); - }); + auto it = std::ranges::find_if(particleHitCounts, [=](const auto& phc) { + return (phc.particleId == particleId); + }); // either increase count if we saw the particle before or add it if (it != particleHitCounts.end()) { it->hitCount += 1u; diff --git a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp index 3cdbe789e3c..7f4e7b894c3 100644 --- a/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp +++ b/Examples/Io/Csv/include/ActsExamples/Io/Csv/CsvInputOutput.hpp @@ -38,6 +38,7 @@ #include "Acts/Utilities/Concepts.hpp" #include "Acts/Utilities/Helpers.hpp" +#include #include #include #include @@ -605,7 +606,7 @@ inline void NamedTupleDsvReader::parse_header( m_extra_columns.clear(); for (std::size_t i = 0; i < m_columns.size(); ++i) { // find the position of the column in the tuple. - auto it = std::find(names.begin(), names.end(), m_columns[i]); + auto it = std::ranges::find(names, m_columns[i]); if (it != names.end()) { // establish mapping between column and tuple item position m_tuple_column_map[std::distance(names.begin(), it)] = i; diff --git a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp index ec84083f2aa..dfb11c84c9e 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp @@ -181,11 +181,9 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { vtxPos /= Acts::UnitConstants::mm; // linear search for vector - auto it = std::find_if( - primaryVertices.begin(), primaryVertices.end(), - [&vtxPos]( - const std::pair>& - pair) { return pair.first == vtxPos; }); + auto it = std::ranges::find_if(primaryVertices, [&vtxPos](const auto& v) { + return v.first == vtxPos; + }); if (it == primaryVertices.end()) { ACTS_DEBUG("Found primary vertex at " << vtx.x << ", " << vtx.y << ", " diff --git a/Examples/Io/Root/src/RootSimHitReader.cpp b/Examples/Io/Root/src/RootSimHitReader.cpp index 1e503d8711c..4f0d805dc7e 100644 --- a/Examples/Io/Root/src/RootSimHitReader.cpp +++ b/Examples/Io/Root/src/RootSimHitReader.cpp @@ -108,9 +108,9 @@ std::pair RootSimHitReader::availableEvents() const { } ProcessCode RootSimHitReader::read(const AlgorithmContext& context) { - auto it = std::find_if( - m_eventMap.begin(), m_eventMap.end(), - [&](const auto& a) { return std::get<0>(a) == context.eventNumber; }); + auto it = std::ranges::find_if(m_eventMap, [&](const auto& a) { + return std::get<0>(a) == context.eventNumber; + }); if (it == m_eventMap.end()) { // explicitly warn if it happens for the first or last event as that might diff --git a/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp b/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp index f2acf870864..794bb1d43b5 100644 --- a/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp +++ b/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp @@ -13,6 +13,8 @@ #include "Acts/Surfaces/SurfaceArray.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" +#include + std::tuple, Acts::Svg::ProtoGrid, std::vector > Acts::Svg::SurfaceArrayConverter::convert( @@ -93,11 +95,9 @@ Acts::Svg::SurfaceArrayConverter::convert( auto sameBounds = [&](const SurfaceBounds* test) { return ((*test) == sBounds); }; - // Check if you have this template object already - auto tBounds = - std::find_if(templateBounds.begin(), templateBounds.end(), sameBounds); - // New reference bounds and new reference object - if (tBounds == templateBounds.end()) { + // Check if you have this template object already before creating new + // reference bounds and new reference object + if (std::ranges::none_of(templateBounds, sameBounds)) { // Let's get the right style SurfaceConverter::Options sOptions; sOptions.templateSurface = true; @@ -107,7 +107,7 @@ Acts::Svg::SurfaceArrayConverter::convert( sOptions.style = *sfStyle; } - // Create a referese surface and reference object from it + // Create a reference surface and reference object from it auto referenceSurface = SurfaceConverter::convert(gctx, *sf, sOptions); auto referenceObject = View::xy(referenceSurface, @@ -148,8 +148,7 @@ Acts::Svg::SurfaceArrayConverter::convert( return ((*test) == sBounds); }; // Check if you have this template object already - auto tBounds = std::find_if(templateBounds.begin(), templateBounds.end(), - sameBounds); + auto tBounds = std::ranges::find_if(templateBounds, sameBounds); // New reference bounds and new reference object if (tBounds != templateBounds.end()) { std::size_t tObject = std::distance(templateBounds.begin(), tBounds); @@ -196,7 +195,7 @@ Acts::Svg::SurfaceArrayConverter::convert( auto bSurfaces = surfaceArray.neighbors(bCenter); std::vector binnAssoc; for (const auto& bs : bSurfaces) { - auto candidate = std::find(surfaces.begin(), surfaces.end(), bs); + auto candidate = std::ranges::find(surfaces, bs); if (candidate != surfaces.end()) { binnAssoc.push_back(std::distance(surfaces.begin(), candidate)); } diff --git a/Plugins/Detray/src/DetrayGeometryConverter.cpp b/Plugins/Detray/src/DetrayGeometryConverter.cpp index da57d91c2bb..664900841f0 100644 --- a/Plugins/Detray/src/DetrayGeometryConverter.cpp +++ b/Plugins/Detray/src/DetrayGeometryConverter.cpp @@ -21,6 +21,8 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" +#include + #include using namespace detray; @@ -36,7 +38,7 @@ namespace { int findVolume( const Acts::Experimental::DetectorVolume* volume, const std::vector& volumes) { - auto candidate = std::find(volumes.begin(), volumes.end(), volume); + auto candidate = std::ranges::find(volumes, volume); if (candidate != volumes.end()) { return std::distance(volumes.begin(), candidate); } diff --git a/Plugins/FpeMonitoring/src/FpeMonitor.cpp b/Plugins/FpeMonitoring/src/FpeMonitor.cpp index 3b08145668e..8b4feb5f1d2 100644 --- a/Plugins/FpeMonitoring/src/FpeMonitor.cpp +++ b/Plugins/FpeMonitoring/src/FpeMonitor.cpp @@ -87,10 +87,9 @@ void FpeMonitor::Result::add(FpeType type, void *stackPtr, auto st = std::make_unique( boost::stacktrace::stacktrace::from_dump(stackPtr, bufferSize)); - auto it = std::find_if( - m_stracktraces.begin(), m_stracktraces.end(), [&](const FpeInfo &el) { - return areFpesEquivalent({el.type, *el.st}, {type, *st}); - }); + auto it = std::ranges::find_if(m_stracktraces, [&](const FpeInfo &el) { + return areFpesEquivalent({el.type, *el.st}, {type, *st}); + }); if (it != m_stracktraces.end()) { it->count += 1; @@ -101,10 +100,9 @@ void FpeMonitor::Result::add(FpeType type, void *stackPtr, bool FpeMonitor::Result::contains( FpeType type, const boost::stacktrace::stacktrace &st) const { - return std::find_if(m_stracktraces.begin(), m_stracktraces.end(), - [&](const FpeInfo &el) { - return areFpesEquivalent({el.type, *el.st}, {type, st}); - }) != m_stracktraces.end(); + return std::ranges::any_of(m_stracktraces, [&](const FpeInfo &el) { + return areFpesEquivalent({el.type, *el.st}, {type, st}); + }); } FpeMonitor::Result &FpeMonitor::result() { @@ -167,11 +165,9 @@ void FpeMonitor::Result::deduplicate() { m_stracktraces.clear(); for (auto &info : copy) { - auto it = std::find_if(m_stracktraces.begin(), m_stracktraces.end(), - [&info](const FpeInfo &el) { - return areFpesEquivalent({el.type, *el.st}, - {info.type, *info.st}); - }); + auto it = std::ranges::find_if(m_stracktraces, [&info](const FpeInfo &el) { + return areFpesEquivalent({el.type, *el.st}, {info.type, *info.st}); + }); if (it != m_stracktraces.end()) { it->count += info.count; continue; diff --git a/Plugins/Json/src/DetectorVolumeJsonConverter.cpp b/Plugins/Json/src/DetectorVolumeJsonConverter.cpp index 19628c078ab..3d5c03c020d 100644 --- a/Plugins/Json/src/DetectorVolumeJsonConverter.cpp +++ b/Plugins/Json/src/DetectorVolumeJsonConverter.cpp @@ -21,6 +21,7 @@ #include "Acts/Plugins/Json/VolumeBoundsJsonConverter.hpp" #include "Acts/Utilities/Enumerate.hpp" +#include #include nlohmann::json Acts::DetectorVolumeJsonConverter::toJson( @@ -59,7 +60,7 @@ nlohmann::json Acts::DetectorVolumeJsonConverter::toJson( nlohmann::json jPortals; if (!portals.empty()) { for (const auto* p : volume.portals()) { - auto it = std::find(portals.begin(), portals.end(), p); + auto it = std::ranges::find(portals, p); if (it != portals.end()) { jPortals.push_back(std::distance(portals.begin(), it)); } else { diff --git a/Plugins/Json/src/MaterialMapJsonConverter.cpp b/Plugins/Json/src/MaterialMapJsonConverter.cpp index e27c069157c..76fc01f8569 100644 --- a/Plugins/Json/src/MaterialMapJsonConverter.cpp +++ b/Plugins/Json/src/MaterialMapJsonConverter.cpp @@ -336,12 +336,10 @@ void Acts::MaterialMapJsonConverter::convertToHierarchy( std::pair>& surfaceHierarchy, const Acts::TrackingVolume* tVolume) { - auto sameId = - [tVolume]( - const std::pair& - pair) { return (tVolume->geometryId() == pair.first); }; - if (std::find_if(volumeHierarchy.begin(), volumeHierarchy.end(), sameId) != - volumeHierarchy.end()) { + auto sameId = [tVolume](const auto& pair) { + return (tVolume->geometryId() == pair.first); + }; + if (std::ranges::any_of(volumeHierarchy, sameId)) { // this volume was already visited return; } diff --git a/Plugins/Json/src/PortalJsonConverter.cpp b/Plugins/Json/src/PortalJsonConverter.cpp index a7044f7b6dd..e39b6efca17 100644 --- a/Plugins/Json/src/PortalJsonConverter.cpp +++ b/Plugins/Json/src/PortalJsonConverter.cpp @@ -40,7 +40,7 @@ namespace { int findVolume( const Acts::Experimental::DetectorVolume* volume, const std::vector& volumes) { - auto candidate = std::find(volumes.begin(), volumes.end(), volume); + auto candidate = std::ranges::find(volumes, volume); if (candidate != volumes.end()) { return std::distance(volumes.begin(), candidate); }