From f0dfbcda166aea0345cbd46b57939c570f1b1f45 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Tue, 1 Oct 2024 00:46:51 +0200 Subject: [PATCH] refactor: use `contains` for maps and sets (#3670) I introduced also for `Core/include/Acts/Geometry/GeometryHierarchyMap.hpp` a contains method, as it would be expected from a map. --- .../Acts/EventData/VectorMultiTrajectory.hpp | 4 ++-- .../Acts/EventData/VectorTrackContainer.hpp | 2 +- .../Acts/Geometry/GeometryHierarchyMap.hpp | 17 ++++++++++++++ .../detail/ObjVisualization3D.ipp | 8 +++---- .../Detector/CylindricalContainerBuilder.cpp | 2 +- Core/src/Detector/Detector.cpp | 6 ++--- Core/src/Detector/DetectorVolumeBuilder.cpp | 2 +- .../detail/CuboidalDetectorHelper.cpp | 11 ++++------ .../detail/CylindricalDetectorHelper.cpp | 22 +++++++++---------- Core/src/EventData/VectorTrackContainer.cpp | 2 +- .../MaterialInteractionAssignment.cpp | 8 +++---- Core/src/Material/SurfaceMaterialMapper.cpp | 6 ++--- Core/src/TrackFinding/GbtsConnector.cpp | 3 +-- .../Vertexing/AdaptiveGridTrackDensity.cpp | 4 ++-- .../Vertexing/AdaptiveMultiVertexFitter.cpp | 2 +- .../Digitization/src/DigitizationConfig.cpp | 2 +- .../Algorithms/Geant4/src/Geant4Manager.cpp | 2 +- .../Geant4/src/MaterialSteppingAction.cpp | 2 +- .../Geant4/src/ParticleTrackingAction.cpp | 12 ++++------ .../Geant4/src/SensitiveSteppingAction.cpp | 6 ++--- .../src/TrackFindingAlgorithm.cpp | 9 ++++---- .../TruthTracking/TrackTruthMatcher.cpp | 2 +- .../TruthTracking/TruthVertexFinder.cpp | 2 +- .../src/TGeoITkModuleSplitter.cpp | 6 ++--- .../ActsExamples/EventData/Trajectories.hpp | 2 +- .../ActsExamples/Framework/WhiteBoard.hpp | 5 +++-- Examples/Io/Csv/src/CsvSeedWriter.cpp | 2 +- Examples/Io/Csv/src/CsvTrackWriter.cpp | 2 +- Examples/Python/src/Base.cpp | 2 +- Examples/Python/src/Svg.cpp | 3 +-- .../MaterialMapping/MaterialComposition.cpp | 4 ++-- .../MaterialMapping/materialPlotHelper.cpp | 9 ++++---- .../TrackingPerformance/ResidualsAndPulls.cpp | 2 +- .../TrackingPerformance/TrackSummary.cpp | 2 +- .../boundParamResolution.C | 2 +- .../ActSVG/IndexedSurfacesSvgConverter.hpp | 2 +- Plugins/DD4hep/src/DD4hepLayerStructure.cpp | 2 +- Plugins/ExaTrkX/src/CugraphTrackBuilding.cpp | 2 +- Plugins/Json/src/MaterialJsonConverter.cpp | 2 +- .../Plugins/Podio/PodioTrackContainer.hpp | 4 ++-- .../Podio/PodioTrackStateContainer.hpp | 4 ++-- Tests/Benchmarks/BinUtilityBenchmark.cpp | 2 +- Tests/Benchmarks/StepperBenchmarkCommons.hpp | 2 +- .../Core/Seeding/UtilityFunctionsTests.cpp | 12 +++++----- .../UnitTests/Core/TrackFitting/Gx2fTests.cpp | 2 +- .../Core/Utilities/GridIterationTests.cpp | 10 +++------ 46 files changed, 108 insertions(+), 113 deletions(-) diff --git a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp index 2dbc3b3687d..66d6bd26da0 100644 --- a/Core/include/Acts/EventData/VectorMultiTrajectory.hpp +++ b/Core/include/Acts/EventData/VectorMultiTrajectory.hpp @@ -220,7 +220,7 @@ class VectorMultiTrajectoryBase { case "typeFlags"_hash: return true; default: - return instance.m_dynamic.find(key) != instance.m_dynamic.end(); + return instance.m_dynamic.contains(key); } } @@ -287,7 +287,7 @@ class VectorMultiTrajectoryBase { case "typeFlags"_hash: return true; default: - return instance.m_dynamic.find(key) != instance.m_dynamic.end(); + return instance.m_dynamic.contains(key); } } diff --git a/Core/include/Acts/EventData/VectorTrackContainer.hpp b/Core/include/Acts/EventData/VectorTrackContainer.hpp index 54ae7cdb2b5..d660aeaaf47 100644 --- a/Core/include/Acts/EventData/VectorTrackContainer.hpp +++ b/Core/include/Acts/EventData/VectorTrackContainer.hpp @@ -147,7 +147,7 @@ class VectorTrackContainerBase { using namespace Acts::HashedStringLiteral; switch (key) { default: - return m_dynamic.find(key) != m_dynamic.end(); + return m_dynamic.contains(key); } } diff --git a/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp b/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp index b2b10b9e52f..e7ddd27c5e6 100644 --- a/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp +++ b/Core/include/Acts/Geometry/GeometryHierarchyMap.hpp @@ -117,6 +117,17 @@ class GeometryHierarchyMap { /// @retval `.end()` iterator if no matching element exists Iterator find(const GeometryIdentifier& id) const; + /// Check if the most specific value exists for a given geometry identifier. + /// + /// This function checks if there is an element matching exactly the given + /// geometry id, or from the element for the next available higher level + /// within the geometry hierarchy. + /// + /// @param id geometry identifier for which existence is being checked + /// @retval `true` if a matching element exists + /// @retval `false` if no matching element exists + bool contains(const GeometryIdentifier& id) const; + private: // NOTE this class assumes that it knows the ordering of the levels within // the geometry id. if the geometry id changes, this code has to be @@ -303,4 +314,10 @@ inline auto GeometryHierarchyMap::find( return end(); } +template +inline auto GeometryHierarchyMap::contains( + const GeometryIdentifier& id) const -> bool { + return this->find(id) != this->end(); +} + } // namespace Acts diff --git a/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp b/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp index b959eb9e18c..4709214e206 100644 --- a/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp +++ b/Core/include/Acts/Visualization/detail/ObjVisualization3D.ipp @@ -106,7 +106,7 @@ void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { materialName += std::to_string(color[1]) + std::string("_"); materialName += std::to_string(color[2]); - if (materials.find(materialName) == materials.end()) { + if (!materials.contains(materialName)) { mos << "newmtl " << materialName << "\n"; std::vector shadings = {"Ka", "Kd", "Ks"}; for (const auto& shd : shadings) { @@ -123,7 +123,7 @@ void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { std::size_t iv = 0; Color lastVertexColor = {0, 0, 0}; for (const VertexType& vtx : m_vertices) { - if (m_vertexColors.find(iv) != m_vertexColors.end()) { + if (m_vertexColors.contains(iv)) { auto color = m_vertexColors.find(iv)->second; if (color != lastVertexColor) { os << mixColor(color) << "\n"; @@ -139,7 +139,7 @@ void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { std::size_t il = 0; Color lastLineColor = {0, 0, 0}; for (const LineType& ln : m_lines) { - if (m_lineColors.find(il) != m_lineColors.end()) { + if (m_lineColors.contains(il)) { auto color = m_lineColors.find(il)->second; if (color != lastLineColor) { os << mixColor(color) << "\n"; @@ -152,7 +152,7 @@ void ObjVisualization3D::write(std::ostream& os, std::ostream& mos) const { std::size_t is = 0; Color lastFaceColor = {0, 0, 0}; for (const FaceType& fc : m_faces) { - if (m_faceColors.find(is) != m_faceColors.end()) { + if (m_faceColors.contains(is)) { auto color = m_faceColors.find(is)->second; if (color != lastFaceColor) { os << mixColor(color) << "\n"; diff --git a/Core/src/Detector/CylindricalContainerBuilder.cpp b/Core/src/Detector/CylindricalContainerBuilder.cpp index 18528d2c877..eea4411d7c1 100644 --- a/Core/src/Detector/CylindricalContainerBuilder.cpp +++ b/Core/src/Detector/CylindricalContainerBuilder.cpp @@ -260,7 +260,7 @@ Acts::Experimental::CylindricalContainerBuilder::construct( // Assign the proto material // Material assignment from configuration for (const auto& [ip, bDescription] : m_cfg.portalMaterialBinning) { - if (portalContainer.find(ip) != portalContainer.end()) { + if (portalContainer.contains(ip)) { auto bd = detail::ProtoMaterialHelper::attachProtoMaterial( gctx, portalContainer[ip]->surface(), bDescription); ACTS_VERBOSE("-> Assigning proto material to portal " << ip << " with " diff --git a/Core/src/Detector/Detector.cpp b/Core/src/Detector/Detector.cpp index c63fe1e8802..27edc478961 100644 --- a/Core/src/Detector/Detector.cpp +++ b/Core/src/Detector/Detector.cpp @@ -64,7 +64,7 @@ Acts::Experimental::Detector::Detector( v->closePortals(); // Store the name const std::string vName = v->name(); - if (m_volumeNameIndex.find(vName) != m_volumeNameIndex.end()) { + if (m_volumeNameIndex.contains(vName)) { throw std::invalid_argument("Detector: duplicate volume name " + vName + " detected."); } @@ -79,7 +79,7 @@ Acts::Experimental::Detector::Detector( "' with undefined geometry id detected" + ". Make sure a GeometryIdGenerator is used."); } - if (volumeGeoIdMap.find(vgeoID) != volumeGeoIdMap.end()) { + if (volumeGeoIdMap.contains(vgeoID)) { std::stringstream ss; ss << vgeoID; throw std::invalid_argument("Detector: duplicate volume geometry id '" + @@ -104,7 +104,7 @@ Acts::Experimental::Detector::Detector( } // --------------------------------------------------------------- - if (surfaceGeoIdMap.find(sgeoID) != surfaceGeoIdMap.end()) { + if (surfaceGeoIdMap.contains(sgeoID)) { std::stringstream ss; ss << sgeoID; throw std::invalid_argument( diff --git a/Core/src/Detector/DetectorVolumeBuilder.cpp b/Core/src/Detector/DetectorVolumeBuilder.cpp index f15d96926d5..f45624014b4 100644 --- a/Core/src/Detector/DetectorVolumeBuilder.cpp +++ b/Core/src/Detector/DetectorVolumeBuilder.cpp @@ -93,7 +93,7 @@ Acts::Experimental::DetectorVolumeBuilder::construct( // Assign the proto material if configured to do so for (const auto& [ip, bDescription] : m_cfg.portalMaterialBinning) { - if (portalContainer.find(ip) != portalContainer.end()) { + if (portalContainer.contains(ip)) { auto bd = detail::ProtoMaterialHelper::attachProtoMaterial( gctx, portalContainer[ip]->surface(), bDescription); ACTS_VERBOSE("-> Assigning proto material to portal " << ip << " with " diff --git a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp index fe7656cdfcd..5cd324cc564 100644 --- a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp @@ -270,12 +270,12 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( auto& formerContainer = containers[ic - 1]; auto& currentContainer = containers[ic]; // Check and throw exception - if (formerContainer.find(startIndex) == formerContainer.end()) { + if (!formerContainer.contains(startIndex)) { throw std::invalid_argument( "CuboidalDetectorHelper: proto container has no fuse portal at index " "of former container."); } - if (currentContainer.find(endIndex) == currentContainer.end()) { + if (!currentContainer.contains(endIndex)) { throw std::invalid_argument( "CuboidalDetectorHelper: proto container has no fuse portal at index " "of current container."); @@ -343,11 +343,8 @@ Acts::Experimental::detail::CuboidalDetectorHelper::xyzBoundaries( auto fillMap = [&](std::map& map, const std::array& values) { for (auto v : values) { - if (map.find(v) != map.end()) { - ++map[v]; - } else { - map[v] = 1u; - } + // This will insert v with a value of 0 if it doesn't exist + ++map[v]; } }; diff --git a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp index 2ed29f0b35a..98765e4ee9f 100644 --- a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp @@ -860,16 +860,14 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( auto& formerContainer = containers[ic - 1]; auto& currentContainer = containers[ic]; // Check and throw exception - if (formerContainer.find(2u) == formerContainer.end()) { + if (!formerContainer.contains(2u)) { throw std::invalid_argument( - "CylindricalDetectorHelper: proto container has no outer cover, " - "can " + "CylindricalDetectorHelper: proto container has no outer cover, can " "not be connected in R"); } - if (currentContainer.find(3u) == currentContainer.end()) { + if (!currentContainer.contains(3u)) { throw std::invalid_argument( - "CylindricalDetectorHelper: proto container has no inner cover, " - "can " + "CylindricalDetectorHelper: proto container has no inner cover, can " "not be connected in R"); } @@ -897,7 +895,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( } // Proto container refurbishment - if (containers[0u].find(3u) != containers[0u].end()) { + if (containers[0u].contains(3u)) { dShell[3u] = containers[0u].find(3u)->second; } dShell[2u] = containers[containers.size() - 1u].find(2u)->second; @@ -907,7 +905,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( for (auto [s, volumes] : sideVolumes) { auto pR = connectInR(gctx, volumes, {s}); - if (pR.find(s) != pR.end()) { + if (pR.contains(s)) { dShell[s] = pR.find(s)->second; } } @@ -934,12 +932,12 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( auto& formerContainer = containers[ic - 1]; auto& currentContainer = containers[ic]; // Check and throw exception - if (formerContainer.find(1u) == formerContainer.end()) { + if (!formerContainer.contains(1u)) { throw std::invalid_argument( "CylindricalDetectorHelper: proto container has no negative disc, " "can not be connected in Z"); } - if (currentContainer.find(0u) == currentContainer.end()) { + if (!currentContainer.contains(0u)) { throw std::invalid_argument( "CylindricalDetectorHelper: proto container has no positive disc, " "can not be connected in Z"); @@ -972,7 +970,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( // Check if this is a tube or a cylinder container (check done on 1st) std::vector nominalSides = {2u, 4u, 5u}; - if (containers[0u].find(3u) != containers[0u].end()) { + if (containers[0u].contains(3u)) { nominalSides.push_back(3u); } @@ -985,7 +983,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( for (auto [s, volumes] : sideVolumes) { ACTS_VERBOSE(" - connect " << volumes.size() << " at selected side " << s); auto pR = connectInZ(gctx, volumes, {s}, logLevel); - if (pR.find(s) != pR.end()) { + if (pR.contains(s)) { dShell[s] = pR.find(s)->second; } } diff --git a/Core/src/EventData/VectorTrackContainer.cpp b/Core/src/EventData/VectorTrackContainer.cpp index 663634af5f2..7f21f429d62 100644 --- a/Core/src/EventData/VectorTrackContainer.cpp +++ b/Core/src/EventData/VectorTrackContainer.cpp @@ -115,7 +115,7 @@ void VectorTrackContainer::copyDynamicFrom_impl(IndexType dstIdx, void VectorTrackContainer::ensureDynamicColumns_impl( const detail_vtc::VectorTrackContainerBase& other) { for (auto& [key, value] : other.m_dynamic) { - if (m_dynamic.find(key) == m_dynamic.end()) { + if (!m_dynamic.contains(key)) { m_dynamic[key] = value->clone(true); } } diff --git a/Core/src/Material/MaterialInteractionAssignment.cpp b/Core/src/Material/MaterialInteractionAssignment.cpp index 793a2d3ba4f..549f88e7a25 100644 --- a/Core/src/Material/MaterialInteractionAssignment.cpp +++ b/Core/src/Material/MaterialInteractionAssignment.cpp @@ -73,7 +73,7 @@ Acts::MaterialInteractionAssignment::assign( // A local veta veto kicked in GeometryIdentifier intersectionID = surface->geometryId(); - if (options.localVetos.find(intersectionID) != options.localVetos.end()) { + if (options.localVetos.contains(intersectionID)) { const auto& localVeto = *options.localVetos.find(intersectionID); if (localVeto(materialInteraction, intersectedSurfaces[is])) { unassignedMaterialInteractions.push_back(materialInteraction); @@ -91,8 +91,7 @@ Acts::MaterialInteractionAssignment::assign( assignedMaterialInteraction.intersectionID = intersectionID; // Check for possible reassignment if (is + 1u < intersectedSurfaces.size() && - options.reAssignments.find(intersectionID) != - options.reAssignments.end()) { + options.reAssignments.contains(intersectionID)) { auto reAssignment = (*options.reAssignments.find(intersectionID)); reAssignment(assignedMaterialInteraction, intersectedSurfaces[is], intersectedSurfaces[is + 1]); @@ -110,8 +109,7 @@ Acts::MaterialInteractionAssignment::assign( // (empty bin correction can use this information) std::vector surfacesWithoutAssignments; for (const auto& intersectedSurface : intersectedSurfaces) { - if (assignedSurfaces.find(intersectedSurface.surface) == - assignedSurfaces.end()) { + if (!assignedSurfaces.contains(intersectedSurface.surface)) { surfacesWithoutAssignments.push_back(intersectedSurface); } } diff --git a/Core/src/Material/SurfaceMaterialMapper.cpp b/Core/src/Material/SurfaceMaterialMapper.cpp index 8e56c2ea93d..360d1145e0e 100644 --- a/Core/src/Material/SurfaceMaterialMapper.cpp +++ b/Core/src/Material/SurfaceMaterialMapper.cpp @@ -392,8 +392,7 @@ void Acts::SurfaceMaterialMapper::mapInteraction( // Now assign the material for the accumulation process auto tBin = currentAccMaterial->second.accumulate( currentPos, rmIter->materialSlab, currentPathCorrection); - if (touchedMapBins.find(&(currentAccMaterial->second)) == - touchedMapBins.end()) { + if (!touchedMapBins.contains(&(currentAccMaterial->second))) { touchedMapBins.insert(MapBin(&(currentAccMaterial->second), tBin)); } if (m_cfg.computeVariance) { @@ -483,8 +482,7 @@ void Acts::SurfaceMaterialMapper::mapSurfaceInteraction( // Now assign the material for the accumulation process auto tBin = currentAccMaterial->second.accumulate( currentPos, rmIter->materialSlab, rmIter->pathCorrection); - if (touchedMapBins.find(&(currentAccMaterial->second)) == - touchedMapBins.end()) { + if (!touchedMapBins.contains(&(currentAccMaterial->second))) { touchedMapBins.insert(MapBin(&(currentAccMaterial->second), tBin)); } if (m_cfg.computeVariance) { diff --git a/Core/src/TrackFinding/GbtsConnector.cpp b/Core/src/TrackFinding/GbtsConnector.cpp index 2b6e640bae0..a91e54dce30 100644 --- a/Core/src/TrackFinding/GbtsConnector.cpp +++ b/Core/src/TrackFinding/GbtsConnector.cpp @@ -126,8 +126,7 @@ GbtsConnector::GbtsConnector(std::ifstream &inFile) { std::list::iterator cIt = lConns.begin(); while (cIt != lConns.end()) { - if (zeroLayers.find((*cIt)->m_dst) != - zeroLayers.end()) { // check if contains + if (zeroLayers.contains((*cIt)->m_dst)) { theStage.push_back(*cIt); cIt = lConns.erase(cIt); continue; diff --git a/Core/src/Vertexing/AdaptiveGridTrackDensity.cpp b/Core/src/Vertexing/AdaptiveGridTrackDensity.cpp index bff02fa8910..37f59506f6f 100644 --- a/Core/src/Vertexing/AdaptiveGridTrackDensity.cpp +++ b/Core/src/Vertexing/AdaptiveGridTrackDensity.cpp @@ -286,7 +286,7 @@ Result AdaptiveGridTrackDensity::estimateSeedWidth( bool binFilled = true; while (gridValue > maxValue / 2) { // Check if we are still operating on continuous z values - if (densityMap.count({rhmBin + 1, tMaxBin}) == 0) { + if (!densityMap.contains({rhmBin + 1, tMaxBin})) { binFilled = false; break; } @@ -308,7 +308,7 @@ Result AdaptiveGridTrackDensity::estimateSeedWidth( binFilled = true; while (gridValue > maxValue / 2) { // Check if we are still operating on continuous z values - if (densityMap.count({lhmBin - 1, tMaxBin}) == 0) { + if (!densityMap.contains({lhmBin - 1, tMaxBin})) { binFilled = false; break; } diff --git a/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp b/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp index cc70cee6b15..99a2e401025 100644 --- a/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp +++ b/Core/src/Vertexing/AdaptiveMultiVertexFitter.cpp @@ -224,7 +224,7 @@ Acts::Result Acts::AdaptiveMultiVertexFitter::setAllVertexCompatibilities( auto& trkAtVtx = state.tracksAtVerticesMap.at(std::make_pair(trk, vtx)); // Recover from cases where linearization point != 0 but // more tracks were added later on - if (vtxInfo.impactParams3D.find(trk) == vtxInfo.impactParams3D.end()) { + if (!vtxInfo.impactParams3D.contains(trk)) { auto res = m_cfg.ipEst.estimate3DImpactParameters( vertexingOptions.geoContext, vertexingOptions.magFieldContext, m_cfg.extractParameters(trk), diff --git a/Examples/Algorithms/Digitization/src/DigitizationConfig.cpp b/Examples/Algorithms/Digitization/src/DigitizationConfig.cpp index b1962468d85..901d71a07cd 100644 --- a/Examples/Algorithms/Digitization/src/DigitizationConfig.cpp +++ b/Examples/Algorithms/Digitization/src/DigitizationConfig.cpp @@ -66,7 +66,7 @@ std::vector ActsExamples::GeometricConfig::variances( std::vector rVariances; for (const auto& bIndex : indices) { Acts::ActsScalar var = 0.; - if (varianceMap.find(bIndex) != varianceMap.end()) { + if (varianceMap.contains(bIndex)) { // Try to find the variance for this cluster size std::size_t lsize = std::min(csizes[bIndex], varianceMap.at(bIndex).size()); diff --git a/Examples/Algorithms/Geant4/src/Geant4Manager.cpp b/Examples/Algorithms/Geant4/src/Geant4Manager.cpp index 027c2ce8b09..33c9a5af781 100644 --- a/Examples/Algorithms/Geant4/src/Geant4Manager.cpp +++ b/Examples/Algorithms/Geant4/src/Geant4Manager.cpp @@ -110,7 +110,7 @@ std::shared_ptr Geant4Manager::createHandle( void Geant4Manager::registerPhysicsListFactory( std::string name, std::shared_ptr physicsListFactory) { - if (m_physicsListFactories.find(name) != m_physicsListFactories.end()) { + if (m_physicsListFactories.contains(name)) { throw std::invalid_argument("name already mapped"); } m_physicsListFactories.emplace(std::move(name), diff --git a/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp b/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp index f95b50a19a0..a6d8b8ed25a 100644 --- a/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp +++ b/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp @@ -97,7 +97,7 @@ void ActsExamples::MaterialSteppingAction::UserSteppingAction( G4Track* g4Track = step->GetTrack(); std::size_t trackID = g4Track->GetTrackID(); auto& materialTracks = eventStore().materialTracks; - if (materialTracks.find(trackID - 1) == materialTracks.end()) { + if (!materialTracks.contains(trackID - 1)) { Acts::RecordedMaterialTrack rmTrack; const auto& g4Vertex = g4Track->GetVertexPosition(); Acts::Vector3 vertex(g4Vertex[0], g4Vertex[1], g4Vertex[2]); diff --git a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp index f8e0e2139eb..88aeb33d010 100644 --- a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp +++ b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp @@ -69,8 +69,7 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( const G4Track* aTrack) { // The initial particle maybe was not registered because a particle ID // collision - if (eventStore().trackIdMapping.find(aTrack->GetTrackID()) == - eventStore().trackIdMapping.end()) { + if (!eventStore().trackIdMapping.contains(aTrack->GetTrackID())) { ACTS_WARNING("Particle ID for track ID " << aTrack->GetTrackID() << " not registered. Skip"); return; @@ -78,8 +77,7 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( const auto barcode = eventStore().trackIdMapping.at(aTrack->GetTrackID()); - auto hasHits = eventStore().particleHitCount.find(barcode) != - eventStore().particleHitCount.end() && + auto hasHits = eventStore().particleHitCount.contains(barcode) && eventStore().particleHitCount.at(barcode) > 0; if (!m_cfg.keepParticlesWithoutHits && !hasHits) { @@ -146,13 +144,11 @@ ActsExamples::ParticleTrackingAction::makeParticleId(G4int trackId, G4int parentId) const { // We already have this particle registered (it is one of the input particles // or we are making a final particle state) - if (eventStore().trackIdMapping.find(trackId) != - eventStore().trackIdMapping.end()) { + if (eventStore().trackIdMapping.contains(trackId)) { return std::nullopt; } - if (eventStore().trackIdMapping.find(parentId) == - eventStore().trackIdMapping.end()) { + if (!eventStore().trackIdMapping.contains(parentId)) { ACTS_DEBUG("Parent particle " << parentId << " not registered, cannot build barcode"); eventStore().parentIdNotFound++; diff --git a/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp b/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp index 718e16d0185..f0f015024e6 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp @@ -182,8 +182,7 @@ void ActsExamples::SensitiveSteppingAction::UserSteppingAction( } // This is not the case if we have a particle-ID collision - if (eventStore().trackIdMapping.find(track->GetTrackID()) == - eventStore().trackIdMapping.end()) { + if (!eventStore().trackIdMapping.contains(track->GetTrackID())) { return; } @@ -192,8 +191,7 @@ void ActsExamples::SensitiveSteppingAction::UserSteppingAction( ACTS_VERBOSE("Step of " << particleId << " in sensitive volume " << geoId); // Set particle hit count to zero, so we have this entry in the map later - if (eventStore().particleHitCount.find(particleId) == - eventStore().particleHitCount.end()) { + if (!eventStore().particleHitCount.contains(particleId)) { eventStore().particleHitCount[particleId] = 0; } diff --git a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp index 81e850d297e..1a99805c496 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackFindingAlgorithm.cpp @@ -222,12 +222,11 @@ class BranchStopper { // count both holes and outliers as holes for pixel/strip counts if (trackState.typeFlags().test(Acts::TrackStateFlag::HoleFlag) || trackState.typeFlags().test(Acts::TrackStateFlag::OutlierFlag)) { - if (m_cfg.pixelVolumes.count( - trackState.referenceSurface().geometryId().volume()) >= 1) { + if (m_cfg.pixelVolumes.contains( + trackState.referenceSurface().geometryId().volume())) { ++branchState.nPixelHoles; - } else if (m_cfg.stripVolumes.count( - trackState.referenceSurface().geometryId().volume()) >= - 1) { + } else if (m_cfg.stripVolumes.contains( + trackState.referenceSurface().geometryId().volume())) { ++branchState.nStripHoles; } } diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackTruthMatcher.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackTruthMatcher.cpp index 46ff000f591..dcdb1dc834c 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackTruthMatcher.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackTruthMatcher.cpp @@ -84,7 +84,7 @@ ActsExamples::ProcessCode TrackTruthMatcher::execute( particleHitCounts.front().particleId; std::size_t nMajorityHits = particleHitCounts.front().hitCount; - if (particles.find(majorityParticleId) == particles.end()) { + if (!particles.contains(majorityParticleId)) { ACTS_DEBUG( "The majority particle is not in the input particle collection, " "majorityParticleId = " diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthVertexFinder.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthVertexFinder.cpp index 9c73b49f267..527d0ec6750 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthVertexFinder.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthVertexFinder.cpp @@ -104,7 +104,7 @@ ProcessCode TruthVertexFinder::execute(const AlgorithmContext& ctx) const { particleHitCounts.front().particleId; std::size_t nMajorityHits = particleHitCounts.front().hitCount; - if (particles.find(majorityParticleId) == particles.end()) { + if (!particles.contains(majorityParticleId)) { ACTS_DEBUG( "The majority particle is not in the input particle collection, " "majorityParticleId = " diff --git a/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp b/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp index df88593ff7a..f1dc1c5f5cf 100644 --- a/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp +++ b/Examples/Detectors/TGeoDetector/src/TGeoITkModuleSplitter.cpp @@ -33,11 +33,9 @@ void ActsExamples::TGeoITkModuleSplitter::initSplitCategories() { m_cfg.splitPatterns) { // mark pattern for disc or barrel module splits: bool is_disk = false; - if (m_cfg.discMap.find(pattern_split_category.second) != - m_cfg.discMap.end()) { + if (m_cfg.discMap.contains(pattern_split_category.second)) { is_disk = true; - } else if (m_cfg.barrelMap.find(pattern_split_category.second) == - m_cfg.barrelMap.end()) { + } else if (!m_cfg.barrelMap.contains(pattern_split_category.second)) { ACTS_ERROR( pattern_split_category.second + " is neither a category name for barrel or disk module splits."); diff --git a/Examples/Framework/include/ActsExamples/EventData/Trajectories.hpp b/Examples/Framework/include/ActsExamples/EventData/Trajectories.hpp index b77ab9fd060..90f6eecf366 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Trajectories.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Trajectories.hpp @@ -79,7 +79,7 @@ struct Trajectories final { /// @return Whether having fitted track parameters or not bool hasTrackParameters( Acts::MultiTrajectoryTraits::IndexType entryIndex) const { - return (0 < m_trackParameters.count(entryIndex)); + return m_trackParameters.contains(entryIndex); } /// Access the fitted track parameters for the given index. diff --git a/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp b/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp index 4c79ff0167b..ffadf3f84dc 100644 --- a/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp +++ b/Examples/Framework/include/ActsExamples/Framework/WhiteBoard.hpp @@ -108,7 +108,7 @@ inline void ActsExamples::WhiteBoard::add(const std::string& name, T&& object) { if (name.empty()) { throw std::invalid_argument("Object can not have an empty name"); } - if (0 < m_store.count(name)) { + if (m_store.contains(name)) { throw std::invalid_argument("Object '" + name + "' already exists"); } auto holder = std::make_shared>(std::forward(object)); @@ -154,5 +154,6 @@ inline const T& ActsExamples::WhiteBoard::get(const std::string& name) const { } inline bool ActsExamples::WhiteBoard::exists(const std::string& name) const { - return m_store.find(name) != m_store.end(); + // TODO remove this function? + return m_store.contains(name); } diff --git a/Examples/Io/Csv/src/CsvSeedWriter.cpp b/Examples/Io/Csv/src/CsvSeedWriter.cpp index 6fc55e37f9c..411064591d2 100644 --- a/Examples/Io/Csv/src/CsvSeedWriter.cpp +++ b/Examples/Io/Csv/src/CsvSeedWriter.cpp @@ -130,7 +130,7 @@ ActsExamples::ProcessCode ActsExamples::CsvSeedWriter::writeT( truthDistance = sqrt(dPhi * dPhi + dEta * dEta); // If the seed is truth matched, check if it is the closest one for the // contributing particle - if (goodSeed.find(majorityParticleId) != goodSeed.end()) { + if (goodSeed.contains(majorityParticleId)) { if (goodSeed[majorityParticleId].second > truthDistance) { goodSeed[majorityParticleId] = std::make_pair(iparams, truthDistance); } diff --git a/Examples/Io/Csv/src/CsvTrackWriter.cpp b/Examples/Io/Csv/src/CsvTrackWriter.cpp index a4155e7c029..f7a44668183 100644 --- a/Examples/Io/Csv/src/CsvTrackWriter.cpp +++ b/Examples/Io/Csv/src/CsvTrackWriter.cpp @@ -185,7 +185,7 @@ ProcessCode CsvTrackWriter::writeT(const AlgorithmContext& context, // good/duplicate/fake = 0/1/2 for (auto& [id, trajState] : infoMap) { - if (listGoodTracks.find(id) != listGoodTracks.end()) { + if (listGoodTracks.contains(id)) { trajState.trackType = "good"; } else if (trajState.trackType != "fake") { trajState.trackType = "duplicate"; diff --git a/Examples/Python/src/Base.cpp b/Examples/Python/src/Base.cpp index 1f149820d9a..3f15d70ee98 100644 --- a/Examples/Python/src/Base.cpp +++ b/Examples/Python/src/Base.cpp @@ -177,7 +177,7 @@ void addLogging(Acts::Python::Context& ctx) { logging.def( "getLogger", [](const std::string& name) { - if (pythonLoggers.find(name) == pythonLoggers.end()) { + if (!pythonLoggers.contains(name)) { pythonLoggers[name] = std::make_shared(name, Acts::Logging::INFO); } diff --git a/Examples/Python/src/Svg.cpp b/Examples/Python/src/Svg.cpp index abb67b1b977..a798b9db9b3 100644 --- a/Examples/Python/src/Svg.cpp +++ b/Examples/Python/src/Svg.cpp @@ -79,8 +79,7 @@ actsvg::svg::object drawDetectorVolume(const Svg::ProtoVolume& pVolume, // Helper lambda for material selection auto materialSel = [&](const Svg::ProtoSurface& s) -> bool { - return (materials && - s._decorations.find("material") != s._decorations.end()); + return (materials && s._decorations.contains("material")); }; // Helper lambda for view range selection diff --git a/Examples/Scripts/MaterialMapping/MaterialComposition.cpp b/Examples/Scripts/MaterialMapping/MaterialComposition.cpp index bc9f7936f67..cecaedb49b3 100644 --- a/Examples/Scripts/MaterialMapping/MaterialComposition.cpp +++ b/Examples/Scripts/MaterialMapping/MaterialComposition.cpp @@ -73,7 +73,7 @@ int main(int argc, char** argv) { store(command_line_parser(argc, argv).options(description).run(), vm); notify(vm); - if (vm.count("help") != 0u) { + if (vm.contains("help")) { std::cout << description; } @@ -89,7 +89,7 @@ int main(int argc, char** argv) { // Subdetector configurations std::vector dRegion = {}; - if (vm.count("config") > 0) { + if (vm.contains("config")) { std::filesystem::path config = vm["config"].as(); std::cout << "Reading region configuration from JSON: " << config << std::endl; diff --git a/Examples/Scripts/MaterialMapping/materialPlotHelper.cpp b/Examples/Scripts/MaterialMapping/materialPlotHelper.cpp index 0558219cbbf..4df1adc84b4 100644 --- a/Examples/Scripts/MaterialMapping/materialPlotHelper.cpp +++ b/Examples/Scripts/MaterialMapping/materialPlotHelper.cpp @@ -36,7 +36,7 @@ std::ostream& Acts::operator<<(std::ostream& os, Acts::GeometryIdentifier id) { /// Initialise the information on each surface. void Initialise_info(sinfo& surface_info, - const std::map& surface_name, + const std::map& surfaceName, const std::uint64_t& id, const int& type, const float& pos, const float& range_min, const float& range_max) { Acts::GeometryIdentifier ID(id); @@ -67,10 +67,11 @@ void Initialise_info(sinfo& surface_info, Ids[3] + "_s" + Ids[4]; surface_info.type = type; - if (surface_name.find(surface_id) != surface_name.end()) { - surface_info.name = surface_name.at(surface_id); - } else + if (surfaceName.contains(surface_id)) { + surface_info.name = surfaceName.at(surface_id); + } else { surface_info.name = ""; + } surface_info.id = surface_id; surface_info.pos = pos; diff --git a/Examples/Scripts/TrackingPerformance/ResidualsAndPulls.cpp b/Examples/Scripts/TrackingPerformance/ResidualsAndPulls.cpp index f0875b1a77f..5c87a8fd1c4 100644 --- a/Examples/Scripts/TrackingPerformance/ResidualsAndPulls.cpp +++ b/Examples/Scripts/TrackingPerformance/ResidualsAndPulls.cpp @@ -46,7 +46,7 @@ int main(int argc, char** argv) { variables_map vm; store(command_line_parser(argc, argv).options(description).run(), vm); - if (vm.count("help") != 0u) { + if (vm.contains("help")) { std::cout << description; return 1; } diff --git a/Examples/Scripts/TrackingPerformance/TrackSummary.cpp b/Examples/Scripts/TrackingPerformance/TrackSummary.cpp index 06d547bd357..05e33a81d46 100644 --- a/Examples/Scripts/TrackingPerformance/TrackSummary.cpp +++ b/Examples/Scripts/TrackingPerformance/TrackSummary.cpp @@ -109,7 +109,7 @@ int main(int argc, char** argv) { variables_map vm; store(command_line_parser(argc, argv).options(description).run(), vm); - if (vm.count("help") != 0u) { + if (vm.contains("help")) { std::cout << description; return 1; } diff --git a/Examples/Scripts/TrackingPerformance/boundParamResolution.C b/Examples/Scripts/TrackingPerformance/boundParamResolution.C index 80baebd47f9..da91f1465b6 100644 --- a/Examples/Scripts/TrackingPerformance/boundParamResolution.C +++ b/Examples/Scripts/TrackingPerformance/boundParamResolution.C @@ -141,7 +141,7 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, for (int volID = 1; volID <= volBins; ++volID) { for (int layID = 1; layID <= layBins; ++layID) { if (h2_volID_layID->GetBinContent(volID, layID) != 0.) { - if (volLayIds.find(volID) == volLayIds.end()) { + if (!volLayIds.contains(volID)) { // First occurrence of this layer, add -1 for volume plots volLayIds[volID] = {-1, layID}; } else { diff --git a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp index 71a5e6862fa..5d02953e950 100644 --- a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp +++ b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp @@ -302,7 +302,7 @@ static inline actsvg::svg::object xy(const ProtoIndexedSurfaceGrid& pIndexGrid, for (const auto [is, sis] : enumerate(pIndices[ig])) { const auto& ps = pSurfaces[sis]; std::string oInfo = std::string("- object: ") + std::to_string(sis); - if (ps._aux_info.find("center") != ps._aux_info.end()) { + if (ps._aux_info.contains("center")) { for (const auto& ci : ps._aux_info.at("center")) { oInfo += ci; } diff --git a/Plugins/DD4hep/src/DD4hepLayerStructure.cpp b/Plugins/DD4hep/src/DD4hepLayerStructure.cpp index f2b45ab2e46..d72de42b88d 100644 --- a/Plugins/DD4hep/src/DD4hepLayerStructure.cpp +++ b/Plugins/DD4hep/src/DD4hepLayerStructure.cpp @@ -26,7 +26,7 @@ Acts::Experimental::DD4hepLayerStructure::builder( DD4hepDetectorElement::Store& dd4hepStore, const GeometryContext& gctx, const dd4hep::DetElement& dd4hepElement, const Options& options) const { // Check for misconfiguration with double naming - if (dd4hepStore.find(options.name) != dd4hepStore.end()) { + if (dd4hepStore.contains(options.name)) { std::string reMessage = "DD4hepLayerStructure: structure with name '"; reMessage += options.name; reMessage += "' already registered in DetectorElementStore"; diff --git a/Plugins/ExaTrkX/src/CugraphTrackBuilding.cpp b/Plugins/ExaTrkX/src/CugraphTrackBuilding.cpp index 87e2adbf161..56469e79083 100644 --- a/Plugins/ExaTrkX/src/CugraphTrackBuilding.cpp +++ b/Plugins/ExaTrkX/src/CugraphTrackBuilding.cpp @@ -65,7 +65,7 @@ std::vector> CugraphTrackBuilding::operator()( int spacepointID = spacepointIDs[idx]; int trkId; - if (trackLableToIds.find(trackLabel) != trackLableToIds.end()) { + if (trackLableToIds.contains(trackLabel)) { trkId = trackLableToIds[trackLabel]; trackCandidates[trkId].push_back(spacepointID); } else { diff --git a/Plugins/Json/src/MaterialJsonConverter.cpp b/Plugins/Json/src/MaterialJsonConverter.cpp index 7213f4bca17..2e7312ab346 100644 --- a/Plugins/Json/src/MaterialJsonConverter.cpp +++ b/Plugins/Json/src/MaterialJsonConverter.cpp @@ -726,7 +726,7 @@ nlohmann::json Acts::MaterialJsonConverter::toJsonDetray( nlohmann::json jGridLink; jGridLink["type"] = gridIndexType; std::size_t gridIndex = 0; - if (gridLink.find(gridIndexType) != gridLink.end()) { + if (gridLink.contains(gridIndexType)) { std::size_t& fGridIndex = gridLink[gridIndex]; gridIndex = fGridIndex; fGridIndex++; diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp index f04cf6d7c6a..16a25795f6a 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp @@ -189,7 +189,7 @@ class MutablePodioTrackContainer : public PodioTrackContainerBase { } bool hasColumn_impl(HashedString key) const { - return m_dynamic.find(key) != m_dynamic.end(); + return m_dynamic.contains(key); } std::size_t size_impl() const { return m_collection->size(); } @@ -365,7 +365,7 @@ class ConstPodioTrackContainer : public PodioTrackContainerBase { } bool hasColumn_impl(HashedString key) const { - return m_dynamic.find(key) != m_dynamic.end(); + return m_dynamic.contains(key); } std::size_t size_impl() const { return m_collection->size(); } diff --git a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp index 590d62a8d87..53643ab4a7d 100644 --- a/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp +++ b/Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackStateContainer.hpp @@ -88,7 +88,7 @@ class PodioTrackStateContainerBase { case "typeFlags"_hash: return true; default: - return instance.m_dynamic.find(key) != instance.m_dynamic.end(); + return instance.m_dynamic.contains(key); } return false; @@ -166,7 +166,7 @@ class PodioTrackStateContainerBase { case "typeFlags"_hash: return true; default: - return instance.m_dynamic.find(key) != instance.m_dynamic.end(); + return instance.m_dynamic.contains(key); } } diff --git a/Tests/Benchmarks/BinUtilityBenchmark.cpp b/Tests/Benchmarks/BinUtilityBenchmark.cpp index 6c9abdf5e4d..d6ed2970a80 100644 --- a/Tests/Benchmarks/BinUtilityBenchmark.cpp +++ b/Tests/Benchmarks/BinUtilityBenchmark.cpp @@ -34,7 +34,7 @@ int main(int argc, char* argv[]) { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); - if (vm.count("help") != 0u) { + if (vm.contains("help")) { std::cout << desc << std::endl; return 0; } diff --git a/Tests/Benchmarks/StepperBenchmarkCommons.hpp b/Tests/Benchmarks/StepperBenchmarkCommons.hpp index 3fc6d361bef..0d4462f96c9 100644 --- a/Tests/Benchmarks/StepperBenchmarkCommons.hpp +++ b/Tests/Benchmarks/StepperBenchmarkCommons.hpp @@ -54,7 +54,7 @@ struct BenchmarkStepper { po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); - if (vm.count("help") != 0u) { + if (vm.contains("help")) { std::cout << desc << std::endl; return 0; } diff --git a/Tests/UnitTests/Core/Seeding/UtilityFunctionsTests.cpp b/Tests/UnitTests/Core/Seeding/UtilityFunctionsTests.cpp index 31085adaa63..9c5f86f6037 100644 --- a/Tests/UnitTests/Core/Seeding/UtilityFunctionsTests.cpp +++ b/Tests/UnitTests/Core/Seeding/UtilityFunctionsTests.cpp @@ -62,9 +62,9 @@ BOOST_AUTO_TEST_CASE(pushBackOrInsertAtEnd_set) { Acts::detail::pushBackOrInsertAtEnd(coll, val); BOOST_CHECK(coll.size() == 3ul); - BOOST_CHECK(coll.find(2ul) != coll.end()); - BOOST_CHECK(coll.find(5ul) != coll.end()); - BOOST_CHECK(coll.find(1ul) != coll.end()); + BOOST_CHECK(coll.contains(2ul)); + BOOST_CHECK(coll.contains(5ul)); + BOOST_CHECK(coll.contains(1ul)); } BOOST_AUTO_TEST_CASE(pushBackOrInsertAtEnd_unordered_set) { @@ -77,9 +77,9 @@ BOOST_AUTO_TEST_CASE(pushBackOrInsertAtEnd_unordered_set) { Acts::detail::pushBackOrInsertAtEnd(coll, val); BOOST_CHECK(coll.size() == 3ul); - BOOST_CHECK(coll.find(2ul) != coll.end()); - BOOST_CHECK(coll.find(5ul) != coll.end()); - BOOST_CHECK(coll.find(1ul) != coll.end()); + BOOST_CHECK(coll.contains(2ul)); + BOOST_CHECK(coll.contains(5ul)); + BOOST_CHECK(coll.contains(1ul)); } } // namespace Acts::Test diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index 2d9d110ec5f..e03f67f6cfe 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -149,7 +149,7 @@ std::shared_ptr makeToyDetector( RectangleBounds(halfSizeSurface, halfSizeSurface)); // Add material only for selected surfaces - if (surfaceIndexWithMaterial.count(surfPos) != 0) { + if (surfaceIndexWithMaterial.contains(surfPos)) { // Material of the surfaces MaterialSlab matProp(makeSilicon(), 5_mm); cfg.surMat = std::make_shared(matProp); diff --git a/Tests/UnitTests/Core/Utilities/GridIterationTests.cpp b/Tests/UnitTests/Core/Utilities/GridIterationTests.cpp index f3e8210eb55..fd67a2f03b3 100644 --- a/Tests/UnitTests/Core/Utilities/GridIterationTests.cpp +++ b/Tests/UnitTests/Core/Utilities/GridIterationTests.cpp @@ -538,9 +538,7 @@ BOOST_AUTO_TEST_CASE(grid_iteration_test_3d_local_norepetitions) { for (std::size_t z : navigation[2ul]) { std::array locPos({x, y, z}); std::size_t globPos = grid.globalBinFromLocalBins(locPos); - BOOST_CHECK_EQUAL( - allowed_global_bins.find(globPos) != allowed_global_bins.end(), - false); + BOOST_CHECK(!allowed_global_bins.contains(globPos)); allowed_global_bins.insert(globPos); } } @@ -559,10 +557,8 @@ BOOST_AUTO_TEST_CASE(grid_iteration_test_3d_local_norepetitions) { ++numIterations; std::array locPos = gridStart.localBinsIndices(); std::size_t globPos = grid.globalBinFromLocalBins(locPos); - BOOST_CHECK_EQUAL( - visited_global_bins.find(globPos) != visited_global_bins.end(), false); - BOOST_CHECK_EQUAL( - allowed_global_bins.find(globPos) != allowed_global_bins.end(), true); + BOOST_CHECK(!visited_global_bins.contains(globPos)); + BOOST_CHECK(allowed_global_bins.contains(globPos)); visited_global_bins.insert(globPos); }