Skip to content

Commit

Permalink
revert copy_if
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger committed Sep 4, 2024
1 parent 4df1630 commit 0591e2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
11 changes: 4 additions & 7 deletions Examples/Algorithms/Utilities/src/HitSelector.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// This file is part of the Acts project.
//
// Copyright (C) 2019-2024 CERN for the benefit of the Acts project
// Copyright (C) 2019-2023 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 "ActsExamples/Utilities/HitSelector.hpp"

#include <ranges>

ActsExamples::HitSelector::HitSelector(const Config& config,
Acts::Logging::Level level)
: IAlgorithm("HitSelector", level), m_cfg(config) {
Expand All @@ -22,10 +20,9 @@ ActsExamples::ProcessCode ActsExamples::HitSelector::execute(
const auto& hits = m_inputHits(ctx);
SimHitContainer selectedHits;

std::ranges::copy(hits | std::ranges::views::filter([&](const auto& hit) {
return hit.time() < m_cfg.maxTime;
}),
std::inserter(selectedHits, selectedHits.begin()));
std::copy_if(hits.begin(), hits.end(),
std::inserter(selectedHits, selectedHits.begin()),
[&](const auto& hit) { return hit.time() < m_cfg.maxTime; });

ACTS_DEBUG("selected " << selectedHits.size() << " from " << hits.size()
<< " hits");
Expand Down
9 changes: 3 additions & 6 deletions Fatras/include/ActsFatras/Kernel/ContinuousProcess.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) 2018-2024 CERN for the benefit of the Acts project
// Copyright (C) 2018-2020 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 @@ -11,8 +11,6 @@
#include "Acts/Material/MaterialSlab.hpp"
#include "ActsFatras/EventData/Particle.hpp"

#include <ranges>

namespace ActsFatras {

/// A continuous simulation process based on a physics model plus selectors.
Expand Down Expand Up @@ -72,9 +70,8 @@ struct ContinuousProcess {
// modify particle according to the physics process
auto children = physics(generator, slab, particle);
// move selected child particles to the output container
std::ranges::copy(
children | std::ranges::views::filter(selectChildParticle),
std::back_inserter(generated));
std::copy_if(std::begin(children), std::end(children),
std::back_inserter(generated), selectChildParticle);
// break condition is defined by whether the output particle is still valid
// or not e.g. because it has fallen below a momentum threshold.
return !selectOutputParticle(particle);
Expand Down
14 changes: 5 additions & 9 deletions Fatras/include/ActsFatras/Kernel/Simulation.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) 2018-2024 CERN for the benefit of the Acts project
// Copyright (C) 2018-2021 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -29,7 +29,6 @@
#include <cassert>
#include <iterator>
#include <memory>
#include <ranges>
#include <vector>

namespace ActsFatras {
Expand Down Expand Up @@ -289,13 +288,10 @@ struct Simulation {
// store final particle state at the end of the simulation
particlesFinal.push_back(result.particle);
// move generated secondaries that should be simulated to the output
std::ranges::copy(
result.generatedParticles |
std::ranges::views::filter([this](const Particle &particle) {
return selectParticle(particle);
}),
std::back_inserter(particlesInitial));

std::copy_if(
result.generatedParticles.begin(), result.generatedParticles.end(),
std::back_inserter(particlesInitial),
[this](const Particle &particle) { return selectParticle(particle); });
std::copy(result.hits.begin(), result.hits.end(), std::back_inserter(hits));
}

Expand Down

0 comments on commit 0591e2b

Please sign in to comment.