diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp deleted file mode 100644 index 49640e5079f1..000000000000 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// This file is part of the ACTS project. -// -// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. - -#include "ActsExamples/TruthTracking/TruthSeedSelector.hpp" - -#include "Acts/Utilities/MultiIndex.hpp" -#include "Acts/Utilities/VectorHelpers.hpp" -#include "ActsExamples/EventData/Index.hpp" -#include "ActsExamples/EventData/SimParticle.hpp" -#include "ActsExamples/Utilities/Range.hpp" -#include "ActsFatras/EventData/Barcode.hpp" -#include "ActsFatras/EventData/Particle.hpp" - -#include -#include -#include - -namespace ActsExamples { -struct AlgorithmContext; -} // namespace ActsExamples - -using namespace ActsExamples; - -TruthSeedSelector::TruthSeedSelector(const Config& config, - Acts::Logging::Level level) - : IAlgorithm("TruthSeedSelector", level), m_cfg(config) { - if (m_cfg.inputParticles.empty()) { - throw std::invalid_argument("Missing input truth particles collection"); - } - if (m_cfg.inputMeasurementParticlesMap.empty()) { - throw std::invalid_argument("Missing input hit-particles map collection"); - } - if (m_cfg.outputParticles.empty()) { - throw std::invalid_argument("Missing output truth particles collection"); - } - - m_inputParticles.initialize(m_cfg.inputParticles); - m_inputMeasurementParticlesMap.initialize(m_cfg.inputMeasurementParticlesMap); - m_outputParticles.initialize(m_cfg.outputParticles); -} - -ProcessCode TruthSeedSelector::execute(const AlgorithmContext& ctx) const { - // prepare input collections - const auto& inputParticles = m_inputParticles(ctx); - const auto& hitParticlesMap = m_inputMeasurementParticlesMap(ctx); - // compute particle_id -> {hit_id...} map from the - // hit_id -> {particle_id...} map on the fly. - const auto& particleHitsMap = invertIndexMultimap(hitParticlesMap); - - // prepare output collection - SimParticleContainer selectedParticles; - selectedParticles.reserve(inputParticles.size()); - - auto within = [](double x, double min, double max) { - return (min <= x) && (x < max); - }; - auto isValidparticle = [&](const auto& p) { - const auto eta = Acts::VectorHelpers::eta(p.direction()); - const auto phi = Acts::VectorHelpers::phi(p.direction()); - const auto rho = Acts::VectorHelpers::perp(p.position()); - // find the corresponding hits for this particle - const auto& hits = makeRange(particleHitsMap.equal_range(p.particleId())); - // number of recorded hits - std::size_t nHits = hits.size(); - return within(rho, 0., m_cfg.rhoMax) && - within(p.position().z(), m_cfg.zMin, m_cfg.zMax) && - within(std::abs(eta), m_cfg.absEtaMin, m_cfg.absEtaMax) && - within(eta, m_cfg.etaMin, m_cfg.etaMax) && - within(phi, m_cfg.phiMin, m_cfg.phiMax) && - within(p.transverseMomentum(), m_cfg.ptMin, m_cfg.ptMax) && - within(nHits, m_cfg.nHitsMin, m_cfg.nHitsMax) && - (m_cfg.keepNeutral || (p.charge() != 0)); - }; - - // create prototracks for all input particles - for (const auto& particle : inputParticles) { - if (isValidparticle(particle)) { - selectedParticles.insert(particle); - } - } - - m_outputParticles(ctx, std::move(selectedParticles)); - return ProcessCode::SUCCESS; -} diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.hpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.hpp deleted file mode 100644 index 1bb12042aa35..000000000000 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedSelector.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// This file is part of the ACTS project. -// -// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. - -#pragma once - -#include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/EventData/SimHit.hpp" -#include "ActsExamples/EventData/SimParticle.hpp" -#include "ActsExamples/Framework/DataHandle.hpp" -#include "ActsExamples/Framework/IAlgorithm.hpp" -#include "ActsExamples/Framework/ProcessCode.hpp" - -#include -#include -#include - -namespace ActsFatras { -class Barcode; -} // namespace ActsFatras - -namespace ActsExamples { -struct AlgorithmContext; - -/// Select truth particles to be used as 'seeds' of reconstruction algorithms, -/// e.g. track fitting and track finding. -/// -/// This pre-selection could help guarantee quality of the 'seeds', i.e. to -/// avoid empty proto track (no recorded hits for the particle). In addition, it -/// could help save unnecessary reconstruction time. For instance, when -/// investigating performance of CombinatorialKalmanFilter (CKF), we might be -/// interested in its performance for only truth particles with pT and number of -/// recorded hits (on sensitive detectors) safistying provided criteria (input -/// measurements of CKF are still recorded hits from all possible particles). -/// Then we could use particles only satisfying provided criteria as the 'seeds' -/// of CKF instead of handling all the truth particles. -// -class TruthSeedSelector final : public IAlgorithm { - public: - struct Config { - /// The input truth particles that should be used to create proto tracks. - std::string inputParticles; - /// The input hit-particles map collection. - std::string inputMeasurementParticlesMap; - /// The output proto tracks collection. - std::string outputParticles; - /// Maximum distance from the origin in the transverse plane - double rhoMin = 0.; - double rhoMax = std::numeric_limits::max(); - /// Minimum/Maximum absolute distance from the origin along z - double zMin = std::numeric_limits::lowest(); - double zMax = std::numeric_limits::max(); - // Truth particle kinematic cuts - double phiMin = std::numeric_limits::lowest(); - double phiMax = std::numeric_limits::max(); - double etaMin = std::numeric_limits::lowest(); - double etaMax = std::numeric_limits::max(); - double absEtaMin = std::numeric_limits::lowest(); - double absEtaMax = std::numeric_limits::max(); - double ptMin = 0.0; - double ptMax = std::numeric_limits::max(); - /// Keep neutral particles - bool keepNeutral = false; - /// Requirement on number of recorded hits - //@TODO: implement detector-specific requirements - std::size_t nHitsMin = 0; - std::size_t nHitsMax = std::numeric_limits::max(); - }; - - TruthSeedSelector(const Config& config, Acts::Logging::Level level); - - ProcessCode execute(const AlgorithmContext& ctx) const final; - - /// Get readonly access to the config parameters - const Config& config() const { return m_cfg; } - - private: - Config m_cfg; - - ReadDataHandle m_inputParticles{this, "InputParticles"}; - ReadDataHandle m_inputMeasurementParticlesMap{ - this, "InputMeasurementParticlesMap"}; - - WriteDataHandle m_outputParticles{this, - "OutputParticles"}; -}; - -} // namespace ActsExamples diff --git a/Examples/Algorithms/TruthTracking/CMakeLists.txt b/Examples/Algorithms/TruthTracking/CMakeLists.txt index 7c1eff1ed51b..4594cdb7480b 100644 --- a/Examples/Algorithms/TruthTracking/CMakeLists.txt +++ b/Examples/Algorithms/TruthTracking/CMakeLists.txt @@ -6,7 +6,6 @@ add_library( ActsExamples/TruthTracking/TrackParameterSelector.cpp ActsExamples/TruthTracking/TrackModifier.cpp ActsExamples/TruthTracking/TrackTruthMatcher.cpp - ActsExamples/TruthTracking/TruthSeedSelector.cpp ActsExamples/TruthTracking/TruthTrackFinder.cpp ActsExamples/TruthTracking/TruthVertexFinder.cpp ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index fd02c6bddacb..846de8995f2d 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -1741,21 +1741,6 @@ def addExaTrkX( ) -> None: customLogLevel = acts.examples.defaultLogging(s, logLevel) - # Run the particle selection - # The pre-selection will select truth particles satisfying provided criteria - # from all particles read in by particle reader for further processing. It - # has no impact on the truth hits themselves - s.addAlgorithm( - acts.examples.TruthSeedSelector( - level=customLogLevel(), - ptMin=500 * u.MeV, - nHitsMin=9, - inputParticles="particles_initial", - inputMeasurementParticlesMap="measurement_particles_map", - outputParticles="particles_seed_selected", - ) - ) - # Create space points s.addAlgorithm( acts.examples.SpacePointMaker( diff --git a/Examples/Python/src/TruthTracking.cpp b/Examples/Python/src/TruthTracking.cpp index 2c43b3cfc4d7..7278b3f821f2 100644 --- a/Examples/Python/src/TruthTracking.cpp +++ b/Examples/Python/src/TruthTracking.cpp @@ -13,15 +13,11 @@ #include "ActsExamples/TruthTracking/TrackModifier.hpp" #include "ActsExamples/TruthTracking/TrackParameterSelector.hpp" #include "ActsExamples/TruthTracking/TrackTruthMatcher.hpp" -#include "ActsExamples/TruthTracking/TruthSeedSelector.hpp" #include "ActsExamples/TruthTracking/TruthSeedingAlgorithm.hpp" #include "ActsExamples/TruthTracking/TruthTrackFinder.hpp" #include "ActsExamples/TruthTracking/TruthVertexFinder.hpp" #include "ActsExamples/Utilities/HitSelector.hpp" -#include "ActsExamples/Utilities/Range.hpp" -#include -#include #include #include @@ -45,48 +41,6 @@ void addTruthTracking(Context& ctx) { ActsExamples::TruthTrackFinder, mex, "TruthTrackFinder", inputParticles, inputMeasurementParticlesMap, outputProtoTracks); - { - using Alg = ActsExamples::TruthSeedSelector; - using Config = Alg::Config; - - auto alg = py::class_>( - mex, "TruthSeedSelector") - .def(py::init(), - py::arg("config"), py::arg("level")) - .def_property_readonly("config", &Alg::config); - - auto c = py::class_(alg, "Config").def(py::init<>()); - - ACTS_PYTHON_STRUCT_BEGIN(c, Config); - ACTS_PYTHON_MEMBER(inputParticles); - ACTS_PYTHON_MEMBER(inputMeasurementParticlesMap); - ACTS_PYTHON_MEMBER(outputParticles); - ACTS_PYTHON_MEMBER(rhoMin); - ACTS_PYTHON_MEMBER(rhoMax); - ACTS_PYTHON_MEMBER(zMin); - ACTS_PYTHON_MEMBER(zMax); - ACTS_PYTHON_MEMBER(phiMin); - ACTS_PYTHON_MEMBER(phiMax); - ACTS_PYTHON_MEMBER(etaMin); - ACTS_PYTHON_MEMBER(etaMax); - ACTS_PYTHON_MEMBER(absEtaMin); - ACTS_PYTHON_MEMBER(absEtaMax); - ACTS_PYTHON_MEMBER(ptMin); - ACTS_PYTHON_MEMBER(ptMax); - ACTS_PYTHON_MEMBER(keepNeutral); - ACTS_PYTHON_MEMBER(nHitsMin); - ACTS_PYTHON_MEMBER(nHitsMax); - ACTS_PYTHON_STRUCT_END(); - - pythonRangeProperty(c, "rho", &Config::rhoMin, &Config::rhoMax); - pythonRangeProperty(c, "z", &Config::zMin, &Config::zMax); - pythonRangeProperty(c, "phi", &Config::phiMin, &Config::phiMax); - pythonRangeProperty(c, "eta", &Config::etaMin, &Config::etaMax); - pythonRangeProperty(c, "absEta", &Config::absEtaMin, &Config::absEtaMax); - pythonRangeProperty(c, "pt", &Config::ptMin, &Config::ptMax); - pythonRangeProperty(c, "nHits", &Config::nHitsMin, &Config::nHitsMax); - } - ACTS_PYTHON_DECLARE_ALGORITHM( ActsExamples::ParticleSmearing, mex, "ParticleSmearing", inputParticles, outputTrackParameters, sigmaD0, sigmaD0PtA, sigmaD0PtB, sigmaZ0, diff --git a/Examples/Python/tests/test_algorithms.py b/Examples/Python/tests/test_algorithms.py index ede2610f6047..4cca71992916 100644 --- a/Examples/Python/tests/test_algorithms.py +++ b/Examples/Python/tests/test_algorithms.py @@ -11,7 +11,6 @@ EventGenerator, FatrasSimulation, MaterialMapping, - TruthSeedSelector, TruthTrackFinder, ParticleSelector, TruthVertexFinder, @@ -42,7 +41,6 @@ EventGenerator, FatrasSimulation, MaterialMapping, - TruthSeedSelector, TruthTrackFinder, ParticleSelector, TruthVertexFinder,