Skip to content

Commit

Permalink
any_of
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger committed Sep 4, 2024
1 parent 193cd35 commit 570f14f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Core/include/Acts/Surfaces/DiamondBounds.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,6 +19,7 @@
#include <array>
#include <cmath>
#include <iosfwd>
#include <ranges>
#include <stdexcept>
#include <vector>

Expand Down Expand Up @@ -128,8 +129,7 @@ inline std::vector<double> DiamondBounds::values() const {
}

inline void DiamondBounds::checkConsistency() noexcept(false) {
if (std::any_of(m_values.begin(), m_values.end(),
[](auto v) { return v <= 0.; })) {
if (std::ranges::any_of(m_values, [](auto v) { return v <= 0.; })) {
throw std::invalid_argument("DiamondBounds: negative half length.");
}
if (get(eHalfLengthXnegY) > get(eHalfLengthXzeroY) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,6 +19,7 @@
#include "ActsExamples/Framework/WhiteBoard.hpp"

#include <numeric>
#include <ranges>

using namespace ActsExamples;
using namespace Acts::UnitLiterals;
Expand Down Expand Up @@ -96,8 +97,8 @@ ActsExamples::TrackFindingAlgorithmExaTrkX::TrackFindingAlgorithmExaTrkX(
NodeFeature::eClusterX, NodeFeature::eClusterY, NodeFeature::eCellCount,
NodeFeature::eCellSum, NodeFeature::eCluster1R, NodeFeature::eCluster2R};

auto wantClFeatures = std::any_of(
m_cfg.nodeFeatures.begin(), m_cfg.nodeFeatures.end(), [&](const auto& f) {
auto wantClFeatures =
std::ranges::any_of(m_cfg.nodeFeatures, [&](const auto& f) {
return std::find(clFeatures.begin(), clFeatures.end(), f) !=
clFeatures.end();
});
Expand Down
5 changes: 3 additions & 2 deletions Examples/Framework/src/Utilities/EventDataTransforms.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,6 +12,7 @@
#include "ActsExamples/EventData/IndexSourceLink.hpp"
#include "ActsExamples/EventData/SimSpacePoint.hpp"

#include <ranges>
#include <vector>

ActsExamples::ProtoTrack ActsExamples::seedToPrototrack(
Expand All @@ -31,7 +32,7 @@ const ActsExamples::SimSpacePoint* ActsExamples::findSpacePointForIndex(
ActsExamples::Index index, const SimSpacePointContainer& spacepoints) {
auto match = [&](const SimSpacePoint& sp) {
const auto& sls = sp.sourceLinks();
return std::any_of(sls.begin(), sls.end(), [&](const auto& sl) {
return std::ranges::any_of(sls, [&](const auto& sl) {
return sl.template get<IndexSourceLink>().index() == index;
});
};
Expand Down
8 changes: 4 additions & 4 deletions Examples/Io/EDM4hep/src/EDM4hepReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <algorithm>
#include <iomanip>
#include <map>
#include <ranges>
#include <stdexcept>

#include <edm4hep/MCParticle.h>
Expand Down Expand Up @@ -451,10 +452,9 @@ void EDM4hepReader::processChildren(
<< " daughter(s)");

bool parentDecayed =
std::any_of(inParticle.daughters_begin(), inParticle.daughters_end(),
[](const edm4hep::MCParticle& daughter) {
return !daughter.vertexIsNotEndpointOfParent();
});
std::ranges::any_of(inParticle, [](const edm4hep::MCParticle& daughter) {
return !daughter.vertexIsNotEndpointOfParent();
});
std::size_t secondaryVertex = 0;
if (parentDecayed) {
ACTS_VERBOSE(indent(gen) << " -> parent decays");
Expand Down
17 changes: 9 additions & 8 deletions Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Acts/Plugins/GeoModel/IGeoShapeConverter.hpp"

#include <iostream>
#include <ranges>
#include <typeinfo>

#include <GeoModelKernel/GeoBox.h>
Expand Down Expand Up @@ -141,9 +142,9 @@ Acts::GeoModelDetectorObjectFactory::findAllSubVolumes(const PVConstLink &vol) {
}

bool Acts::GeoModelDetectorObjectFactory::convertBox(std::string name) {
auto convB = std::any_of(
m_cfg.convertBox.begin(), m_cfg.convertBox.end(),
[&](const auto &n) { return name.find(n) != std::string::npos; });
auto convB = std::ranges::any_of(m_cfg.convertBox, [&](const auto &n) {
return name.find(n) != std::string::npos;
});
return convB;
}

Expand Down Expand Up @@ -192,14 +193,14 @@ bool Acts::GeoModelDetectorObjectFactory::matches(const std::string &name,
return true;
}

auto matchName = std::any_of(
m_cfg.nameList.begin(), m_cfg.nameList.end(),
[&](const auto &n) { return name.find(n) != std::string::npos; });
auto matchName = std::ranges::any_of(m_cfg.nameList, [&](const auto &n) {
return name.find(n) != std::string::npos;
});

std::string matStr = physvol->getLogVol()->getMaterial()->getName();

auto matchMaterial = std::any_of(
m_cfg.materialList.begin(), m_cfg.materialList.end(),
auto matchMaterial = std::ranges::any_of(
m_cfg.materialList,
[&](const auto &m) { return matStr.find(m) != std::string::npos; });

bool match = matchMaterial && matchName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <fstream>
#include <iostream>
#include <random>
#include <ranges>

using namespace ActsExamples;
using namespace Acts::Test;
Expand Down Expand Up @@ -152,7 +153,7 @@ BOOST_AUTO_TEST_CASE(CsvMeasurementRoundTrip) {
std::abs(ca.activation - cb.activation) < 1.e-4;
};

BOOST_CHECK(std::any_of(b.channels.begin(), b.channels.end(), match));
BOOST_CHECK(std::ranges::any_of(b.channels, match));
}
}

Expand Down

0 comments on commit 570f14f

Please sign in to comment.