From f8457f714fa3f955506ff9eaa7359f9c810d6134 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 25 Oct 2024 16:47:48 +0200 Subject: [PATCH 01/11] refactor: Replace particle smearing by track parameter smearing --- .../Generators/EventGenerator.cpp | 38 ++++ .../Generators/EventGenerator.hpp | 9 +- .../TruthTracking/ParticleSmearing.cpp | 164 ------------------ .../TruthTracking/TrackParameterSmearing.cpp | 145 ++++++++++++++++ ...mearing.hpp => TrackParameterSmearing.hpp} | 49 +++--- .../Algorithms/TruthTracking/CMakeLists.txt | 2 +- .../python/acts/examples/reconstruction.py | 61 ++++--- .../Python/python/acts/examples/simulation.py | 6 +- Examples/Python/src/TruthTracking.cpp | 15 +- 9 files changed, 263 insertions(+), 226 deletions(-) delete mode 100644 Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp create mode 100644 Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp rename Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/{ParticleSmearing.hpp => TrackParameterSmearing.hpp} (61%) diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp index 5e7e2af3f9a..3a57b67bd71 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp @@ -8,14 +8,19 @@ #include "ActsExamples/Generators/EventGenerator.hpp" +#include "Acts/Surfaces/PerigeeSurface.hpp" #include "ActsExamples/EventData/SimVertex.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsFatras/EventData/Barcode.hpp" #include "ActsFatras/EventData/Particle.hpp" #include +#include +#include #include #include +#include ActsExamples::EventGenerator::EventGenerator(const Config& cfg, Acts::Logging::Level lvl) @@ -35,6 +40,7 @@ ActsExamples::EventGenerator::EventGenerator(const Config& cfg, m_outputParticles.initialize(m_cfg.outputParticles); m_outputVertices.initialize(m_cfg.outputVertices); + m_outputTrackParameters.maybeInitialize(m_cfg.outputTrackParameters); } std::string ActsExamples::EventGenerator::name() const { @@ -115,8 +121,40 @@ ActsExamples::ProcessCode ActsExamples::EventGenerator::read( << " n_primary_vertices=" << nPrimaryVertices << " n_particles=" << particles.size()); + if (m_outputTrackParameters.isInitialized()) { + std::unordered_map> + perigeeSurfaces; + + for (auto&& [vtxId, vtxParticles] : groupBySecondaryVertex(particles)) { + // a group contains at least one particle by construction. assume that all + // particles within the group originate from the same position and use it + // to as the reference position for the perigee frame. + auto perigee = Acts::Surface::makeShared( + vtxParticles.begin()->position()); + perigeeSurfaces[vtxId] = perigee; + } + + // create track parameters from the particles + TrackParametersContainer trackParameters; + for (const auto& particle : particles) { + const auto vtxId = particle.particleId().vertexId(); + const auto particleHypothesis = particle.hypothesis(); + const auto phi = Acts::VectorHelpers::phi(particle.direction()); + const auto theta = Acts::VectorHelpers::theta(particle.direction()); + const auto qOverP = particle.qOverP(); + const auto time = particle.time(); + + trackParameters.emplace_back( + perigeeSurfaces.at(vtxId), + Acts::BoundVector{0, 0, phi, theta, qOverP, time}, std::nullopt, + particleHypothesis); + } + m_outputTrackParameters(ctx, std::move(trackParameters)); + } + // move generated event to the store m_outputParticles(ctx, std::move(particles)); m_outputVertices(ctx, std::move(vertices)); + return ProcessCode::SUCCESS; } diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp index 46720b9fff1..e18c42eaa37 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp @@ -12,13 +12,13 @@ #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/EventData/SimVertex.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "ActsExamples/Framework/DataHandle.hpp" #include "ActsExamples/Framework/IReader.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" #include -#include #include #include #include @@ -93,8 +93,11 @@ class EventGenerator final : public ActsExamples::IReader { struct Config { /// Name of the output particles collection. std::string outputParticles; - /// Name of the vertex collection. + /// Name of the output vertex collection. std::string outputVertices; + /// Optional. Name of the output track parameters collection. + std::string outputTrackParameters; + /// List of generators that should be used to generate the event. std::vector generators; /// The random number service. @@ -123,6 +126,8 @@ class EventGenerator final : public ActsExamples::IReader { WriteDataHandle m_outputParticles{this, "OutputParticles"}; WriteDataHandle m_outputVertices{this, "OutputVertices"}; + WriteDataHandle m_outputTrackParameters{ + this, "OutputTrackParameters"}; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp deleted file mode 100644 index cfc62ab9da9..00000000000 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.cpp +++ /dev/null @@ -1,164 +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/ParticleSmearing.hpp" - -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" -#include "Acts/EventData/ParticleHypothesis.hpp" -#include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp" -#include "Acts/Surfaces/PerigeeSurface.hpp" -#include "Acts/Surfaces/Surface.hpp" -#include "Acts/Utilities/Helpers.hpp" -#include "Acts/Utilities/detail/periodic.hpp" -#include "ActsExamples/EventData/SimParticle.hpp" -#include "ActsExamples/EventData/Track.hpp" -#include "ActsExamples/Framework/AlgorithmContext.hpp" -#include "ActsExamples/Framework/RandomNumbers.hpp" -#include "ActsExamples/Utilities/GroupBy.hpp" -#include "ActsExamples/Utilities/Range.hpp" -#include "ActsFatras/EventData/Particle.hpp" - -#include -#include -#include -#include -#include -#include - -ActsExamples::ParticleSmearing::ParticleSmearing(const Config& config, - Acts::Logging::Level level) - : IAlgorithm("ParticleSmearing", level), m_cfg(config) { - if (m_cfg.inputParticles.empty()) { - throw std::invalid_argument("Missing input truth particles collection"); - } - if (m_cfg.outputTrackParameters.empty()) { - throw std::invalid_argument("Missing output tracks parameters collection"); - } - if (m_cfg.randomNumbers == nullptr) { - throw std::invalid_argument("Missing random numbers tool"); - } - - if (m_cfg.particleHypothesis) { - ACTS_INFO("Override truth particle hypothesis with " - << *m_cfg.particleHypothesis); - } - - m_inputParticles.initialize(m_cfg.inputParticles); - m_outputTrackParameters.initialize(m_cfg.outputTrackParameters); -} - -ActsExamples::ProcessCode ActsExamples::ParticleSmearing::execute( - const AlgorithmContext& ctx) const { - // setup input and output containers - const auto& particles = m_inputParticles(ctx); - TrackParametersContainer parameters; - parameters.reserve(particles.size()); - - // setup random number generator and standard gaussian - auto rng = m_cfg.randomNumbers->spawnGenerator(ctx); - std::normal_distribution stdNormal(0.0, 1.0); - - for (auto&& [vtxId, vtxParticles] : groupBySecondaryVertex(particles)) { - // a group contains at least one particle by construction. assume that all - // particles within the group originate from the same position and use it to - // as the reference position for the perigee frame. - auto perigee = Acts::Surface::makeShared( - vtxParticles.begin()->position()); - - for (const auto& particle : vtxParticles) { - const auto time = particle.time(); - const auto phi = Acts::VectorHelpers::phi(particle.direction()); - const auto theta = Acts::VectorHelpers::theta(particle.direction()); - const auto pt = particle.transverseMomentum(); - const auto p = particle.absoluteMomentum(); - const auto qOverP = particle.qOverP(); - const auto particleHypothesis = - m_cfg.particleHypothesis.value_or(particle.hypothesis()); - - // compute momentum-dependent resolutions - const double sigmaD0 = - m_cfg.sigmaD0 + - m_cfg.sigmaD0PtA * std::exp(-1.0 * std::abs(m_cfg.sigmaD0PtB) * pt); - const double sigmaZ0 = - m_cfg.sigmaZ0 + - m_cfg.sigmaZ0PtA * std::exp(-1.0 * std::abs(m_cfg.sigmaZ0PtB) * pt); - // shortcuts for other resolutions - const double sigmaT0 = m_cfg.sigmaT0; - const double sigmaPhi = m_cfg.sigmaPhi; - const double sigmaTheta = m_cfg.sigmaTheta; - const double sigmaQOverP = - std::sqrt(std::pow(m_cfg.sigmaPtRel * qOverP, 2) + - std::pow(sigmaTheta * (qOverP * std::tan(theta)), 2)); - - Acts::BoundVector params = Acts::BoundVector::Zero(); - // smear the position/time - // note that we smear d0 and z0 in the perigee frame - params[Acts::eBoundLoc0] = sigmaD0 * stdNormal(rng); - params[Acts::eBoundLoc1] = sigmaZ0 * stdNormal(rng); - params[Acts::eBoundTime] = time + sigmaT0 * stdNormal(rng); - // smear direction angles phi,theta ensuring correct bounds - const auto [newPhi, newTheta] = Acts::detail::normalizePhiTheta( - phi + sigmaPhi * stdNormal(rng), theta + sigmaTheta * stdNormal(rng)); - params[Acts::eBoundPhi] = newPhi; - params[Acts::eBoundTheta] = newTheta; - // compute smeared q/p - params[Acts::eBoundQOverP] = qOverP + sigmaQOverP * stdNormal(rng); - - ACTS_VERBOSE("Smearing particle (pos, time, phi, theta, q/p):"); - ACTS_VERBOSE(" from: " << particle.position().transpose() << ", " << time - << ", " << phi << ", " << theta << ", " << qOverP); - ACTS_VERBOSE(" to: " << perigee - ->localToGlobal( - ctx.geoContext, - Acts::Vector2{params[Acts::eBoundLoc0], - params[Acts::eBoundLoc1]}, - particle.direction() * p) - .transpose() - << ", " << params[Acts::eBoundTime] << ", " - << params[Acts::eBoundPhi] << ", " - << params[Acts::eBoundTheta] << ", " - << params[Acts::eBoundQOverP]); - - // build the track covariance matrix using the smearing sigmas - Acts::BoundSquareMatrix cov = Acts::BoundSquareMatrix::Zero(); - if (m_cfg.initialSigmas) { - // use the initial sigmas if set - - Acts::EstimateTrackParamCovarianceConfig config{ - .initialSigmas = - Eigen::Map{ - m_cfg.initialSigmas->data()}, - .initialSigmaPtRel = m_cfg.initialSigmaPtRel, - .initialVarInflation = Eigen::Map{ - m_cfg.initialVarInflation.data()}}; - - cov = Acts::estimateTrackParamCovariance(config, params, false); - } else { - // otherwise use the smearing sigmas - - Acts::BoundVector sigmas = Acts::BoundVector( - {sigmaD0, sigmaZ0, sigmaPhi, sigmaTheta, sigmaQOverP, sigmaT0}); - - for (std::size_t i = Acts::eBoundLoc0; i < Acts::eBoundSize; ++i) { - double sigma = sigmas[i]; - double variance = sigma * sigma; - - // Inflate the initial covariance - variance *= m_cfg.initialVarInflation[i]; - - cov(i, i) = variance; - } - } - parameters.emplace_back(perigee, params, cov, particleHypothesis); - } - } - - m_outputTrackParameters(ctx, std::move(parameters)); - return ProcessCode::SUCCESS; -} diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp new file mode 100644 index 00000000000..8c0b7723f4f --- /dev/null +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp @@ -0,0 +1,145 @@ +// 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/TrackParameterSmearing.hpp" + +#include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include "ActsExamples/Framework/AlgorithmContext.hpp" +#include "ActsExamples/Framework/RandomNumbers.hpp" + +#include +#include +#include + +namespace ActsExamples { + +TrackParameterSmearing::TrackParameterSmearing(const Config& config, + Acts::Logging::Level level) + : IAlgorithm("TrackParameterSmearing", level), m_cfg(config) { + if (m_cfg.inputTrackParameters.empty()) { + throw std::invalid_argument("Missing input track parameters collection"); + } + if (m_cfg.outputTrackParameters.empty()) { + throw std::invalid_argument("Missing output track parameters collection"); + } + if (m_cfg.randomNumbers == nullptr) { + throw std::invalid_argument("Missing random numbers tool"); + } + + if (m_cfg.particleHypothesis) { + ACTS_INFO("Override truth particle hypothesis with " + << *m_cfg.particleHypothesis); + } + + m_inputTrackParameters.initialize(m_cfg.inputTrackParameters); + m_outputTrackParameters.initialize(m_cfg.outputTrackParameters); +} + +ProcessCode TrackParameterSmearing::execute(const AlgorithmContext& ctx) const { + // setup input and output containers + const auto& inputTrackParametersContainer = m_inputTrackParameters(ctx); + TrackParametersContainer outputTrackParametersContainer; + outputTrackParametersContainer.reserve(inputTrackParametersContainer.size()); + + // setup random number generator and standard gaussian + auto rng = m_cfg.randomNumbers->spawnGenerator(ctx); + std::normal_distribution stdNormal(0.0, 1.0); + + for (const auto& inputTrackParameters : inputTrackParametersContainer) { + const auto time = inputTrackParameters.time(); + const auto phi = inputTrackParameters.phi(); + const auto theta = inputTrackParameters.theta(); + const auto pt = inputTrackParameters.transverseMomentum(); + const auto qOverP = inputTrackParameters.qOverP(); + const auto particleHypothesis = m_cfg.particleHypothesis.value_or( + inputTrackParameters.particleHypothesis()); + + // compute momentum-dependent resolutions + const double sigmaLoc0 = + m_cfg.sigmaLoc0 + + m_cfg.sigmaLoc0PtA * std::exp(-1.0 * std::abs(m_cfg.sigmaLoc0PtB) * pt); + const double sigmaLoc1 = + m_cfg.sigmaLoc1 + + m_cfg.sigmaLoc1PtA * std::exp(-1.0 * std::abs(m_cfg.sigmaLoc1PtB) * pt); + // shortcuts for other resolutions + const double sigmaTime = m_cfg.sigmaTime; + const double sigmaPhi = m_cfg.sigmaPhi; + const double sigmaTheta = m_cfg.sigmaTheta; + const double sigmaQOverP = + std::sqrt(std::pow(m_cfg.sigmaPtRel * qOverP, 2) + + std::pow(sigmaTheta * (qOverP * std::tan(theta)), 2)); + + Acts::BoundVector params = Acts::BoundVector::Zero(); + // smear the position/time + // note that we smear d0 and z0 in the perigee frame + params[Acts::eBoundLoc0] = sigmaLoc0 * stdNormal(rng); + params[Acts::eBoundLoc1] = sigmaLoc1 * stdNormal(rng); + params[Acts::eBoundTime] = time + sigmaTime * stdNormal(rng); + // smear direction angles phi,theta ensuring correct bounds + const auto [newPhi, newTheta] = Acts::detail::normalizePhiTheta( + phi + sigmaPhi * stdNormal(rng), theta + sigmaTheta * stdNormal(rng)); + params[Acts::eBoundPhi] = newPhi; + params[Acts::eBoundTheta] = newTheta; + // compute smeared q/p + params[Acts::eBoundQOverP] = qOverP + sigmaQOverP * stdNormal(rng); + + // build the track covariance matrix using the smearing sigmas + Acts::BoundSquareMatrix cov = Acts::BoundSquareMatrix::Zero(); + if (m_cfg.initialSigmas) { + // use the initial sigmas if set + + Acts::EstimateTrackParamCovarianceConfig config{ + .initialSigmas = + Eigen::Map{m_cfg.initialSigmas->data()}, + .initialSigmaPtRel = m_cfg.initialSigmaPtRel, + .initialVarInflation = Eigen::Map{ + m_cfg.initialVarInflation.data()}}; + + cov = Acts::estimateTrackParamCovariance(config, params, false); + } else { + // otherwise use the smearing sigmas + + Acts::BoundVector sigmas = Acts::BoundVector( + {sigmaLoc0, sigmaLoc1, sigmaPhi, sigmaTheta, sigmaQOverP, sigmaTime}); + + for (std::size_t i = Acts::eBoundLoc0; i < Acts::eBoundSize; ++i) { + double sigma = sigmas[i]; + double variance = sigma * sigma; + + // Inflate the initial covariance + variance *= m_cfg.initialVarInflation[i]; + + cov(i, i) = variance; + } + } + + const auto& outputTrackParameters = + outputTrackParametersContainer.emplace_back( + inputTrackParameters.referenceSurface().shared_from_this(), params, + cov, particleHypothesis); + + ACTS_VERBOSE("Smearing particle (pos, time, phi, theta, q/p):"); + ACTS_VERBOSE( + " from: " << inputTrackParameters.position(ctx.geoContext).transpose() + << ", " << time << ", " << phi << ", " << theta << ", " + << qOverP); + ACTS_VERBOSE( + " to: " << outputTrackParameters.position(ctx.geoContext).transpose() + << ", " << params[Acts::eBoundTime] << ", " + << params[Acts::eBoundPhi] << ", " + << params[Acts::eBoundTheta] << ", " + << params[Acts::eBoundQOverP]); + } + + m_outputTrackParameters(ctx, std::move(outputTrackParametersContainer)); + + return ProcessCode::SUCCESS; +} + +} // namespace ActsExamples diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.hpp similarity index 61% rename from Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp rename to Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.hpp index 3b60f12b099..53bab3b62e5 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.hpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/EventData/ParticleHypothesis.hpp" #include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/EventData/Track.hpp" #include "ActsExamples/Framework/DataHandle.hpp" #include "ActsExamples/Framework/IAlgorithm.hpp" @@ -19,7 +18,6 @@ #include "ActsExamples/Framework/RandomNumbers.hpp" #include -#include #include #include #include @@ -28,36 +26,38 @@ namespace ActsExamples { class RandomNumbers; struct AlgorithmContext; -/// Create track states by smearing truth particle information. +/// @brief Smear track parameters. /// -/// Particles are smeared in the perigee frame anchored at their true vertex -/// position. The `d0` and `z0` parameters are always defined within that -/// perigee frame and not globally. The generated bound parameters are stored in -/// the same order as the input particles. -class ParticleSmearing final : public IAlgorithm { +/// Track parameters are smeared in the local frame. The `loc0` and `loc1` +/// parameters are always defined within that local frame and not globally. The +/// generated bound parameters are stored in the same order as the input +/// parameters. +class TrackParameterSmearing final : public IAlgorithm { public: struct Config { - /// Input truth particles collection. - std::string inputParticles; - /// Output smeared tracks parameters collection. + /// Input track parameters collection. + std::string inputTrackParameters; + /// Output smeared track parameters collection. std::string outputTrackParameters; /// Random numbers service. std::shared_ptr randomNumbers = nullptr; // Smearing parameters - /// Constant term of the d0 resolution. - double sigmaD0 = 20 * Acts::UnitConstants::um; - /// Pt-dependent d0 resolution of the form sigma_d0 = A*exp(-1.*abs(B)*pt). - double sigmaD0PtA = 30 * Acts::UnitConstants::um; - double sigmaD0PtB = 0.3 / Acts::UnitConstants::GeV; - /// Constant term of the z0 resolution. - double sigmaZ0 = 20 * Acts::UnitConstants::um; - /// Pt-dependent z0 resolution of the form sigma_z0 = A*exp(-1.*abs(B)*pt). - double sigmaZ0PtA = 30 * Acts::UnitConstants::um; - double sigmaZ0PtB = 0.3 / Acts::UnitConstants::GeV; + /// Constant term of the loc0 resolution. + double sigmaLoc0 = 20 * Acts::UnitConstants::um; + /// Pt-dependent loc0 resolution of the form sigma_loc0 = + /// A*exp(-1.*abs(B)*pt). + double sigmaLoc0PtA = 30 * Acts::UnitConstants::um; + double sigmaLoc0PtB = 0.3 / Acts::UnitConstants::GeV; + /// Constant term of the loc1 resolution. + double sigmaLoc1 = 20 * Acts::UnitConstants::um; + /// Pt-dependent loc1 resolution of the form sigma_loc1 = + /// A*exp(-1.*abs(B)*pt). + double sigmaLoc1PtA = 30 * Acts::UnitConstants::um; + double sigmaLoc1PtB = 0.3 / Acts::UnitConstants::GeV; /// Time resolution. - double sigmaT0 = 1 * Acts::UnitConstants::ns; + double sigmaTime = 1 * Acts::UnitConstants::ns; /// Phi angular resolution. double sigmaPhi = 1 * Acts::UnitConstants::degree; /// Theta angular resolution. @@ -77,7 +77,7 @@ class ParticleSmearing final : public IAlgorithm { std::optional particleHypothesis = std::nullopt; }; - ParticleSmearing(const Config& config, Acts::Logging::Level level); + TrackParameterSmearing(const Config& config, Acts::Logging::Level level); ProcessCode execute(const AlgorithmContext& ctx) const override; @@ -87,7 +87,8 @@ class ParticleSmearing final : public IAlgorithm { private: Config m_cfg; - ReadDataHandle m_inputParticles{this, "InputParticles"}; + ReadDataHandle m_inputTrackParameters{ + this, "InputTrackParameters"}; WriteDataHandle m_outputTrackParameters{ this, "OutputTrackParameters"}; diff --git a/Examples/Algorithms/TruthTracking/CMakeLists.txt b/Examples/Algorithms/TruthTracking/CMakeLists.txt index 7c1eff1ed51..6e68b92a5c2 100644 --- a/Examples/Algorithms/TruthTracking/CMakeLists.txt +++ b/Examples/Algorithms/TruthTracking/CMakeLists.txt @@ -2,7 +2,7 @@ add_library( ActsExamplesTruthTracking SHARED ActsExamples/TruthTracking/ParticleSelector.cpp - ActsExamples/TruthTracking/ParticleSmearing.cpp + ActsExamples/TruthTracking/TrackParameterSmearing.cpp ActsExamples/TruthTracking/TrackParameterSelector.cpp ActsExamples/TruthTracking/TrackModifier.cpp ActsExamples/TruthTracking/TrackTruthMatcher.cpp diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index fd02c6bddac..ff4b9093a17 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -13,9 +13,20 @@ "Default TruthSmeared TruthEstimated Orthogonal HoughTransform Gbts Hashing", ) -ParticleSmearingSigmas = namedtuple( - "ParticleSmearingSigmas", - ["d0", "d0PtA", "d0PtB", "z0", "z0PtA", "z0PtB", "t0", "phi", "theta", "ptRel"], +TrackSmearingSigmas = namedtuple( + "TrackSmearingSigmas", + [ + "loc0", + "loc0PtA", + "loc0PtB", + "loc1", + "loc1PtA", + "loc1PtB", + "time", + "phi", + "theta", + "ptRel", + ], defaults=[None] * 10, ) @@ -224,7 +235,7 @@ class VertexFinder(Enum): @acts.examples.NamedTypeArgs( seedingAlgorithm=SeedingAlgorithm, - particleSmearingSigmas=ParticleSmearingSigmas, + trackSmearingSigmas=TrackSmearingSigmas, seedFinderConfigArg=SeedFinderConfigArg, seedFinderOptionsArg=SeedFinderOptionsArg, seedFilterConfigArg=SeedFilterConfigArg, @@ -243,7 +254,7 @@ def addSeeding( layerMappingConfigFile: Optional[Union[Path, str]] = None, connector_inputConfigFile: Optional[Union[Path, str]] = None, seedingAlgorithm: SeedingAlgorithm = SeedingAlgorithm.Default, - particleSmearingSigmas: ParticleSmearingSigmas = ParticleSmearingSigmas(), + trackSmearingSigmas: TrackSmearingSigmas = TrackSmearingSigmas(), initialSigmas: Optional[list] = None, initialSigmaPtRel: Optional[float] = None, initialVarInflation: Optional[list] = None, @@ -281,15 +292,15 @@ def addSeeding( Json file for space point geometry selection. Not required for SeedingAlgorithm.TruthSmeared. seedingAlgorithm : SeedingAlgorithm, Default seeding algorithm to use: one of Default (no truth information used), TruthSmeared, TruthEstimated - particleSmearingSigmas : ParticleSmearingSigmas(d0, d0PtA, d0PtB, z0, z0PtA, z0PtB, t0, phi, theta, ptRel) - ParticleSmearing configuration. - Defaults specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp + trackSmearingSigmas : TrackSmearingSigmas(d0, d0PtA, d0PtB, z0, z0PtA, z0PtB, t0, phi, theta, ptRel) + TrackSmearing configuration. + Defaults specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.hpp initialSigmas : list Sets the initial covariance matrix diagonal. This is ignored in case of TruthSmearing. Defaults specified in Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp initialVarInflation : list List of 6 scale factors to inflate the initial covariance matrix - Defaults (all 1) specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSmearing.hpp + Defaults (all 1) specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.hpp seedFinderConfigArg : SeedFinderConfigArg(maxSeedsPerSpM, cotThetaMax, sigmaScattering, radLengthPerSeed, minPt, impactMax, deltaPhiMax, interactionPointCut, deltaZMax, maxPtScattering, zBinEdges, zBinsCustomLooping, rRangeMiddleSP, useVariableMiddleSPRange, binSizeR, seedConfirmation, centralSeedConfirmationRange, forwardSeedConfirmationRange, deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z) SeedFinderConfig settings. deltaR, deltaRBottomSP, deltaRTopSP, deltaRMiddleSPRange, collisionRegion, r, z. Defaults specified in Core/include/Acts/Seeding/SeedFinderConfig.hpp @@ -334,7 +345,8 @@ def addSeeding( s=s, rnd=rnd, selectedParticles=selectedParticles, - particleSmearingSigmas=particleSmearingSigmas, + inputTrackParameters="particle_track_parameters", + trackSmearingSigmas=trackSmearingSigmas, initialSigmas=initialSigmas, initialSigmaPtRel=initialSigmaPtRel, initialVarInflation=initialVarInflation, @@ -488,7 +500,8 @@ def addTruthSmearedSeeding( s: acts.examples.Sequencer, rnd: Optional[acts.examples.RandomNumbers], selectedParticles: str, - particleSmearingSigmas: ParticleSmearingSigmas, + inputTrackParameters: str, + trackSmearingSigmas: TrackSmearingSigmas, initialSigmas: Optional[List[float]], initialSigmaPtRel: Optional[float], initialVarInflation: Optional[List[float]], @@ -501,30 +514,30 @@ def addTruthSmearedSeeding( rnd = rnd or acts.examples.RandomNumbers(seed=42) # Run particle smearing - ptclSmear = acts.examples.ParticleSmearing( + trkSmear = acts.examples.TrackParameterSmearing( level=logLevel, - inputParticles=selectedParticles, + inputTrackParameters=inputTrackParameters, outputTrackParameters="estimatedparameters", randomNumbers=rnd, # gaussian sigmas to smear particle parameters **acts.examples.defaultKWArgs( - sigmaD0=particleSmearingSigmas.d0, - sigmaD0PtA=particleSmearingSigmas.d0PtA, - sigmaD0PtB=particleSmearingSigmas.d0PtB, - sigmaZ0=particleSmearingSigmas.z0, - sigmaZ0PtA=particleSmearingSigmas.z0PtA, - sigmaZ0PtB=particleSmearingSigmas.z0PtB, - sigmaT0=particleSmearingSigmas.t0, - sigmaPhi=particleSmearingSigmas.phi, - sigmaTheta=particleSmearingSigmas.theta, - sigmaPtRel=particleSmearingSigmas.ptRel, + sigmaLoc0=trackSmearingSigmas.loc0, + sigmaLoc0PtA=trackSmearingSigmas.loc0PtA, + sigmaLoc0PtB=trackSmearingSigmas.loc0PtB, + sigmaLoc1=trackSmearingSigmas.loc1, + sigmaLoc1PtA=trackSmearingSigmas.loc1PtA, + sigmaLoc1PtB=trackSmearingSigmas.loc1PtB, + sigmaTime=trackSmearingSigmas.time, + sigmaPhi=trackSmearingSigmas.phi, + sigmaTheta=trackSmearingSigmas.theta, + sigmaPtRel=trackSmearingSigmas.ptRel, initialSigmas=initialSigmas, initialSigmaPtRel=initialSigmaPtRel, initialVarInflation=initialVarInflation, particleHypothesis=particleHypothesis, ), ) - s.addAlgorithm(ptclSmear) + s.addAlgorithm(trkSmear) truthTrkFndAlg = acts.examples.TruthTrackFinder( level=logLevel, diff --git a/Examples/Python/python/acts/examples/simulation.py b/Examples/Python/python/acts/examples/simulation.py index 8f6b6d0e603..201c4b63102 100644 --- a/Examples/Python/python/acts/examples/simulation.py +++ b/Examples/Python/python/acts/examples/simulation.py @@ -132,6 +132,7 @@ def addParticleGun( ], outputParticles="particles_input", outputVertices="vertices_input", + outputTrackParameters="particle_track_parameters", randomNumbers=rnd, ) @@ -296,6 +297,7 @@ def addPythia8( generators=generators, outputParticles="particles_input", outputVertices="vertices_input", + outputTrackParameters="particle_track_parameters", randomNumbers=rnd, ) @@ -335,7 +337,7 @@ def addPythia8( acts.examples.RootParticleWriter( level=customLogLevel(), inputParticles=evGen.config.outputParticles, - filePath=str(outputDirRoot / "pythia8_particles.root"), + filePath=str(outputDirRoot / "particles.root"), ) ) @@ -343,7 +345,7 @@ def addPythia8( acts.examples.RootVertexWriter( level=customLogLevel(), inputVertices=evGen.config.outputVertices, - filePath=str(outputDirRoot / "pythia8_vertices.root"), + filePath=str(outputDirRoot / "vertices.root"), ) ) diff --git a/Examples/Python/src/TruthTracking.cpp b/Examples/Python/src/TruthTracking.cpp index 2c43b3cfc4d..b9913292fa2 100644 --- a/Examples/Python/src/TruthTracking.cpp +++ b/Examples/Python/src/TruthTracking.cpp @@ -9,19 +9,16 @@ #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/TruthTracking/ParticleSelector.hpp" -#include "ActsExamples/TruthTracking/ParticleSmearing.hpp" #include "ActsExamples/TruthTracking/TrackModifier.hpp" #include "ActsExamples/TruthTracking/TrackParameterSelector.hpp" +#include "ActsExamples/TruthTracking/TrackParameterSmearing.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 @@ -88,11 +85,11 @@ void addTruthTracking(Context& ctx) { } ACTS_PYTHON_DECLARE_ALGORITHM( - ActsExamples::ParticleSmearing, mex, "ParticleSmearing", inputParticles, - outputTrackParameters, sigmaD0, sigmaD0PtA, sigmaD0PtB, sigmaZ0, - sigmaZ0PtA, sigmaZ0PtB, sigmaT0, sigmaPhi, sigmaTheta, sigmaPtRel, - initialSigmas, initialSigmaPtRel, initialVarInflation, particleHypothesis, - randomNumbers); + ActsExamples::TrackParameterSmearing, mex, "TrackParameterSmearing", + inputTrackParameters, outputTrackParameters, sigmaLoc0, sigmaLoc0PtA, + sigmaLoc0PtB, sigmaLoc1, sigmaLoc1PtA, sigmaLoc1PtB, sigmaTime, sigmaPhi, + sigmaTheta, sigmaPtRel, initialSigmas, initialSigmaPtRel, + initialVarInflation, particleHypothesis, randomNumbers); { using Alg = ActsExamples::ParticleSelector; From d558ed263de2343341b9c86af564a3cae71b3056 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 28 Oct 2024 09:07:42 +0100 Subject: [PATCH 02/11] downstream changes --- .../workflows/physmon_trackfinding_1muon.py | 4 ++-- Examples/Python/tests/conftest.py | 16 +--------------- Examples/Python/tests/test_algorithms.py | 4 ++-- Examples/Python/tests/test_propagation.py | 16 +--------------- Examples/Scripts/Optimization/ckf.py | 4 ++-- Examples/Scripts/Python/ckf_tracks.py | 4 ++-- Examples/Scripts/Python/material_validation.py | 16 +--------------- .../Scripts/Python/material_validation_itk.py | 17 +---------------- Examples/Scripts/Python/propagation.py | 16 +--------------- Examples/Scripts/Python/vertex_fitting.py | 6 +++--- 10 files changed, 16 insertions(+), 87 deletions(-) diff --git a/CI/physmon/workflows/physmon_trackfinding_1muon.py b/CI/physmon/workflows/physmon_trackfinding_1muon.py index aaa4bc9f71d..bb64757974f 100755 --- a/CI/physmon/workflows/physmon_trackfinding_1muon.py +++ b/CI/physmon/workflows/physmon_trackfinding_1muon.py @@ -18,7 +18,7 @@ from acts.examples.reconstruction import ( addSeeding, - ParticleSmearingSigmas, + TrackSmearingSigmas, SeedFinderConfigArg, SeedFinderOptionsArg, SeedingAlgorithm, @@ -91,7 +91,7 @@ def run_ckf_tracking(label, seeding): s, setup.trackingGeometry, setup.field, - ParticleSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared + TrackSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared # zero eveything so the CKF has a chance to find the measurements d0=0, d0PtA=0, diff --git a/Examples/Python/tests/conftest.py b/Examples/Python/tests/conftest.py index f4e0abbcadd..77be374f549 100644 --- a/Examples/Python/tests/conftest.py +++ b/Examples/Python/tests/conftest.py @@ -209,20 +209,6 @@ def _basic_prop_seq_factory(geo, s=None): rnd=rng, ) - # Run particle smearing - trackParametersGenerator = acts.examples.ParticleSmearing( - level=acts.logging.INFO, - inputParticles="particles_input", - outputTrackParameters="start_parameters", - randomNumbers=rng, - sigmaD0=0.0, - sigmaZ0=0.0, - sigmaPhi=0.0, - sigmaTheta=0.0, - sigmaPtRel=0.0, - ) - s.addAlgorithm(trackParametersGenerator) - nav = acts.Navigator(trackingGeometry=geo) stepper = acts.StraightLineStepper() @@ -232,7 +218,7 @@ def _basic_prop_seq_factory(geo, s=None): level=acts.logging.WARNING, propagatorImpl=prop, sterileLogger=False, - inputTrackParameters="start_parameters", + inputTrackParameters="particle_track_parameters", outputSummaryCollection="propagation_summary", ) diff --git a/Examples/Python/tests/test_algorithms.py b/Examples/Python/tests/test_algorithms.py index ede2610f604..e080109c47a 100644 --- a/Examples/Python/tests/test_algorithms.py +++ b/Examples/Python/tests/test_algorithms.py @@ -15,7 +15,7 @@ TruthTrackFinder, ParticleSelector, TruthVertexFinder, - ParticleSmearing, + TrackParameterSmearing, TrackSelectorAlgorithm, TrackFittingAlgorithm, SurfaceSortingAlgorithm, @@ -46,7 +46,7 @@ TruthTrackFinder, ParticleSelector, TruthVertexFinder, - ParticleSmearing, + TrackParameterSmearing, TrackSelectorAlgorithm, TrackFittingAlgorithm, SurfaceSortingAlgorithm, diff --git a/Examples/Python/tests/test_propagation.py b/Examples/Python/tests/test_propagation.py index 6583098f427..6c5dd88679a 100644 --- a/Examples/Python/tests/test_propagation.py +++ b/Examples/Python/tests/test_propagation.py @@ -56,20 +56,6 @@ def test_steppers(conf_const, trk_geo): rnd=rnd, ) - # Run particle smearing - trackParametersGenerator = acts.examples.ParticleSmearing( - level=acts.logging.INFO, - inputParticles="particles_input", - outputTrackParameters="start_parameters", - randomNumbers=rnd, - sigmaD0=0.0, - sigmaZ0=0.0, - sigmaPhi=0.0, - sigmaTheta=0.0, - sigmaPtRel=0.0, - ) - seq.addAlgorithm(trackParametersGenerator) - prop = acts.examples.ConcretePropagator( acts.Propagator(stepper=s, navigator=nav) ) @@ -78,7 +64,7 @@ def test_steppers(conf_const, trk_geo): acts.examples.PropagationAlgorithm, level=acts.logging.WARNING, propagatorImpl=prop, - inputTrackParameters="start_parameters", + inputTrackParameters="particle_track_parameters", outputSummaryCollection="propagation_summary", sterileLogger=False, ) diff --git a/Examples/Scripts/Optimization/ckf.py b/Examples/Scripts/Optimization/ckf.py index c1761141262..3b11c3438a9 100755 --- a/Examples/Scripts/Optimization/ckf.py +++ b/Examples/Scripts/Optimization/ckf.py @@ -123,7 +123,7 @@ def runCKFTracks( from acts.examples.reconstruction import ( addSeeding, - ParticleSmearingSigmas, + TrackSmearingSigmas, SeedFinderConfigArg, SeedFinderOptionsArg, SeedingAlgorithm, @@ -188,7 +188,7 @@ def runCKFTracks( s, trackingGeometry, field, - ParticleSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared + TrackSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared # zero eveything so the CKF has a chance to find the measurements d0=0, d0PtA=0, diff --git a/Examples/Scripts/Python/ckf_tracks.py b/Examples/Scripts/Python/ckf_tracks.py index 97f56d17ff0..b2ac90ad504 100755 --- a/Examples/Scripts/Python/ckf_tracks.py +++ b/Examples/Scripts/Python/ckf_tracks.py @@ -34,7 +34,7 @@ def runCKFTracks( from acts.examples.reconstruction import ( addSeeding, - ParticleSmearingSigmas, + TrackSmearingSigmas, SeedFinderConfigArg, SeedFinderOptionsArg, SeedingAlgorithm, @@ -99,7 +99,7 @@ def runCKFTracks( s, trackingGeometry, field, - ParticleSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared + TrackSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared # zero eveything so the CKF has a chance to find the measurements d0=0, d0PtA=0, diff --git a/Examples/Scripts/Python/material_validation.py b/Examples/Scripts/Python/material_validation.py index ebc26041cd2..148260c8ba5 100755 --- a/Examples/Scripts/Python/material_validation.py +++ b/Examples/Scripts/Python/material_validation.py @@ -40,26 +40,12 @@ def runMaterialValidation( rnd=rnd, ) - # Run particle smearing - trackParametersGenerator = acts.examples.ParticleSmearing( - level=acts.logging.INFO, - inputParticles="particles_input", - outputTrackParameters="start_parameters", - randomNumbers=rnd, - sigmaD0=0.0, - sigmaZ0=0.0, - sigmaPhi=0.0, - sigmaTheta=0.0, - sigmaPtRel=0.0, - ) - s.addAlgorithm(trackParametersGenerator) - alg = acts.examples.PropagationAlgorithm( propagatorImpl=prop, level=acts.logging.INFO, sterileLogger=True, recordMaterialInteractions=True, - inputTrackParameters="start_parameters", + inputTrackParameters="particle_track_parameters", outputSummaryCollection="propagation_summary", outputMaterialCollection="material_tracks", ) diff --git a/Examples/Scripts/Python/material_validation_itk.py b/Examples/Scripts/Python/material_validation_itk.py index 759f75a5ea2..a467e4bd71a 100755 --- a/Examples/Scripts/Python/material_validation_itk.py +++ b/Examples/Scripts/Python/material_validation_itk.py @@ -44,27 +44,12 @@ def runMaterialValidation( rnd=rnd, ) - # Run particle smearing - trackParametersGenerator = acts.examples.ParticleSmearing( - level=acts.logging.INFO, - inputParticles="particles_input", - outputTrackParameters="start_parameters", - randomNumbers=rnd, - sigmaD0=0.0, - sigmaZ0=0.0, - sigmaPhi=0.0, - sigmaTheta=0.0, - sigmaPRel=0.0, - addCovariances=False, - ) - s.addAlgorithm(trackParametersGenerator) - alg = acts.examples.PropagationAlgorithm( propagatorImpl=prop, level=acts.logging.INFO, sterileLogger=False, recordMaterialInteractions=True, - inputTrackParameters="start_parameters", + inputTrackParameters="particle_track_parameters", outputPropagationSteps="propagation_steps", outputMaterialTracks="material-tracks", ) diff --git a/Examples/Scripts/Python/propagation.py b/Examples/Scripts/Python/propagation.py index ea54919a89f..2561f75df76 100755 --- a/Examples/Scripts/Python/propagation.py +++ b/Examples/Scripts/Python/propagation.py @@ -31,20 +31,6 @@ def runPropagation(trackingGeometry, field, outputDir, s=None, decorators=[]): rnd=rnd, ) - # Run particle smearing - trackParametersGenerator = acts.examples.ParticleSmearing( - level=acts.logging.INFO, - inputParticles="particles_input", - outputTrackParameters="start_parameters", - randomNumbers=rnd, - sigmaD0=0.0, - sigmaZ0=0.0, - sigmaPhi=0.0, - sigmaTheta=0.0, - sigmaPtRel=0.0, - ) - s.addAlgorithm(trackParametersGenerator) - nav = acts.Navigator(trackingGeometry=trackingGeometry) stepper = acts.EigenStepper(field) @@ -57,7 +43,7 @@ def runPropagation(trackingGeometry, field, outputDir, s=None, decorators=[]): propagatorImpl=propagator, level=acts.logging.INFO, sterileLogger=True, - inputTrackParameters="start_parameters", + inputTrackParameters="particle_track_parameters", outputSummaryCollection="propagation_summary", ) s.addAlgorithm(propagationAlgorithm) diff --git a/Examples/Scripts/Python/vertex_fitting.py b/Examples/Scripts/Python/vertex_fitting.py index e8797a5ed12..8916656f421 100755 --- a/Examples/Scripts/Python/vertex_fitting.py +++ b/Examples/Scripts/Python/vertex_fitting.py @@ -6,7 +6,7 @@ from acts.examples import ( Sequencer, ParticleSelector, - ParticleSmearing, + TrackParameterSmearing, TrackParameterSelector, ) from acts.examples.simulation import addPythia8 @@ -65,9 +65,9 @@ def runVertexFitting( if inputTrackSummary is None or inputParticlePath is None: logger.info("Using smeared particles") - ptclSmearing = ParticleSmearing( + ptclSmearing = TrackParameterSmearing( level=acts.logging.INFO, - inputParticles=selectedParticles, + inputTrackParameters="particle_track_parameters", outputTrackParameters=trackParameters, randomNumbers=rnd, ) From ec157745a0ce14597924816df8463da164771b8d Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 28 Oct 2024 10:50:49 +0100 Subject: [PATCH 03/11] bind new output param to python --- Examples/Python/src/Generators.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/Python/src/Generators.cpp b/Examples/Python/src/Generators.cpp index 800c912aa89..3a9f1feaf36 100644 --- a/Examples/Python/src/Generators.cpp +++ b/Examples/Python/src/Generators.cpp @@ -79,6 +79,7 @@ void addGenerators(Context& ctx) { .def(py::init<>()) .def_readwrite("outputParticles", &Config::outputParticles) .def_readwrite("outputVertices", &Config::outputVertices) + .def_readwrite("outputTrackParameters", &Config::outputTrackParameters) .def_readwrite("generators", &Config::generators) .def_readwrite("randomNumbers", &Config::randomNumbers); } From f2a5b7fb16722b84f9cb244d02415d808144caac Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 28 Oct 2024 15:01:10 +0100 Subject: [PATCH 04/11] more downstream changes --- CI/physmon/workflows/physmon_trackfinding_1muon.py | 12 ++++++------ .../Python/python/acts/examples/reconstruction.py | 2 +- Examples/Scripts/Optimization/ckf.py | 12 ++++++------ Examples/Scripts/Python/ckf_tracks.py | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CI/physmon/workflows/physmon_trackfinding_1muon.py b/CI/physmon/workflows/physmon_trackfinding_1muon.py index bb64757974f..37ff6087883 100755 --- a/CI/physmon/workflows/physmon_trackfinding_1muon.py +++ b/CI/physmon/workflows/physmon_trackfinding_1muon.py @@ -93,12 +93,12 @@ def run_ckf_tracking(label, seeding): setup.field, TrackSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared # zero eveything so the CKF has a chance to find the measurements - d0=0, - d0PtA=0, - d0PtB=0, - z0=0, - z0PtA=0, - z0PtB=0, + loc0=0, + loc0PtA=0, + loc0PtB=0, + loc1=0, + loc1PtA=0, + loc1PtB=0, t0=0, phi=0, theta=0, diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index ff4b9093a17..dca1839f663 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -292,7 +292,7 @@ def addSeeding( Json file for space point geometry selection. Not required for SeedingAlgorithm.TruthSmeared. seedingAlgorithm : SeedingAlgorithm, Default seeding algorithm to use: one of Default (no truth information used), TruthSmeared, TruthEstimated - trackSmearingSigmas : TrackSmearingSigmas(d0, d0PtA, d0PtB, z0, z0PtA, z0PtB, t0, phi, theta, ptRel) + trackSmearingSigmas : TrackSmearingSigmas(loc0, loc0PtA, loc0PtB, loc1, loc1PtA, loc1PtB, t0, phi, theta, ptRel) TrackSmearing configuration. Defaults specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.hpp initialSigmas : list diff --git a/Examples/Scripts/Optimization/ckf.py b/Examples/Scripts/Optimization/ckf.py index 3b11c3438a9..af6caf52d17 100755 --- a/Examples/Scripts/Optimization/ckf.py +++ b/Examples/Scripts/Optimization/ckf.py @@ -190,12 +190,12 @@ def runCKFTracks( field, TrackSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared # zero eveything so the CKF has a chance to find the measurements - d0=0, - d0PtA=0, - d0PtB=0, - z0=0, - z0PtA=0, - z0PtB=0, + loc0=0, + loc0PtA=0, + loc0PtB=0, + loc1=0, + loc1PtA=0, + loc1PtB=0, t0=0, phi=0, theta=0, diff --git a/Examples/Scripts/Python/ckf_tracks.py b/Examples/Scripts/Python/ckf_tracks.py index b2ac90ad504..5d9de04e987 100755 --- a/Examples/Scripts/Python/ckf_tracks.py +++ b/Examples/Scripts/Python/ckf_tracks.py @@ -101,12 +101,12 @@ def runCKFTracks( field, TrackSmearingSigmas( # only used by SeedingAlgorithm.TruthSmeared # zero eveything so the CKF has a chance to find the measurements - d0=0, - d0PtA=0, - d0PtB=0, - z0=0, - z0PtA=0, - z0PtB=0, + loc0=0, + loc0PtA=0, + loc0PtB=0, + loc1=0, + loc1PtA=0, + loc1PtB=0, t0=0, phi=0, theta=0, From 4b391714edf5ce73c4d82992d7abae16cc4b36c3 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 29 Oct 2024 08:42:35 +0100 Subject: [PATCH 05/11] fix t0 --- CI/physmon/workflows/physmon_trackfinding_1muon.py | 2 +- Examples/Scripts/Optimization/ckf.py | 2 +- Examples/Scripts/Python/ckf_tracks.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CI/physmon/workflows/physmon_trackfinding_1muon.py b/CI/physmon/workflows/physmon_trackfinding_1muon.py index 37ff6087883..90305112099 100755 --- a/CI/physmon/workflows/physmon_trackfinding_1muon.py +++ b/CI/physmon/workflows/physmon_trackfinding_1muon.py @@ -99,7 +99,7 @@ def run_ckf_tracking(label, seeding): loc1=0, loc1PtA=0, loc1PtB=0, - t0=0, + time=0, phi=0, theta=0, ptRel=0, diff --git a/Examples/Scripts/Optimization/ckf.py b/Examples/Scripts/Optimization/ckf.py index af6caf52d17..54426b0cf9f 100755 --- a/Examples/Scripts/Optimization/ckf.py +++ b/Examples/Scripts/Optimization/ckf.py @@ -196,7 +196,7 @@ def runCKFTracks( loc1=0, loc1PtA=0, loc1PtB=0, - t0=0, + time=0, phi=0, theta=0, ptRel=0, diff --git a/Examples/Scripts/Python/ckf_tracks.py b/Examples/Scripts/Python/ckf_tracks.py index 5d9de04e987..75ec8a7c316 100755 --- a/Examples/Scripts/Python/ckf_tracks.py +++ b/Examples/Scripts/Python/ckf_tracks.py @@ -107,7 +107,7 @@ def runCKFTracks( loc1=0, loc1PtA=0, loc1PtB=0, - t0=0, + time=0, phi=0, theta=0, ptRel=0, From 47c80f0bb6483217fc010a3b3f397a5ce932ee99 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 31 Oct 2024 15:09:05 +0100 Subject: [PATCH 06/11] revert --- Examples/Python/python/acts/examples/reconstruction.py | 2 +- Examples/Python/python/acts/examples/simulation.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index dca1839f663..fecac6068bb 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -292,7 +292,7 @@ def addSeeding( Json file for space point geometry selection. Not required for SeedingAlgorithm.TruthSmeared. seedingAlgorithm : SeedingAlgorithm, Default seeding algorithm to use: one of Default (no truth information used), TruthSmeared, TruthEstimated - trackSmearingSigmas : TrackSmearingSigmas(loc0, loc0PtA, loc0PtB, loc1, loc1PtA, loc1PtB, t0, phi, theta, ptRel) + trackSmearingSigmas : TrackSmearingSigmas(loc0, loc0PtA, loc0PtB, loc1, loc1PtA, loc1PtB, time, phi, theta, ptRel) TrackSmearing configuration. Defaults specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.hpp initialSigmas : list diff --git a/Examples/Python/python/acts/examples/simulation.py b/Examples/Python/python/acts/examples/simulation.py index 201c4b63102..51e4fed5aef 100644 --- a/Examples/Python/python/acts/examples/simulation.py +++ b/Examples/Python/python/acts/examples/simulation.py @@ -337,7 +337,7 @@ def addPythia8( acts.examples.RootParticleWriter( level=customLogLevel(), inputParticles=evGen.config.outputParticles, - filePath=str(outputDirRoot / "particles.root"), + filePath=str(outputDirRoot / "pythia8_particles.root"), ) ) @@ -345,7 +345,7 @@ def addPythia8( acts.examples.RootVertexWriter( level=customLogLevel(), inputVertices=evGen.config.outputVertices, - filePath=str(outputDirRoot / "vertices.root"), + filePath=str(outputDirRoot / "pythia8_vertices.root"), ) ) From b610e1baf7efc61c5933e32be675452749adca73 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Fri, 1 Nov 2024 17:40:50 +0100 Subject: [PATCH 07/11] pin param smearing for physmon fitter chains --- Examples/Scripts/Python/truth_tracking_gsf.py | 24 +++++++++++++++++++ .../Scripts/Python/truth_tracking_gx2f.py | 24 +++++++++++++++++++ .../Scripts/Python/truth_tracking_kalman.py | 24 +++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/Examples/Scripts/Python/truth_tracking_gsf.py b/Examples/Scripts/Python/truth_tracking_gsf.py index ae8aca06d6c..8b84c881075 100755 --- a/Examples/Scripts/Python/truth_tracking_gsf.py +++ b/Examples/Scripts/Python/truth_tracking_gsf.py @@ -31,6 +31,7 @@ def runTruthTrackingGsf( from acts.examples.reconstruction import ( addSeeding, SeedingAlgorithm, + TrackSmearingSigmas, addTruthTrackingGsf, ) @@ -100,6 +101,29 @@ def runTruthTrackingGsf( rnd=rnd, inputParticles="particles_input", seedingAlgorithm=SeedingAlgorithm.TruthSmeared, + trackSmearingSigmas=TrackSmearingSigmas( + # zero eveything so the CKF has a chance to find the measurements + loc0=0, + loc0PtA=0, + loc0PtB=0, + loc1=0, + loc1PtA=0, + loc1PtB=0, + time=0, + phi=0, + theta=0, + ptRel=0, + ), + initialSigmas=[ + 1 * u.mm, + 1 * u.mm, + 1 * u.degree, + 1 * u.degree, + 0.1 * u.e / u.GeV, + 1 * u.ns, + ], + initialSigmaPtRel=0.01, + initialVarInflation=[1.0] * 6, particleHypothesis=acts.ParticleHypothesis.electron, ) diff --git a/Examples/Scripts/Python/truth_tracking_gx2f.py b/Examples/Scripts/Python/truth_tracking_gx2f.py index 8503dc982f4..365b94c4a8b 100644 --- a/Examples/Scripts/Python/truth_tracking_gx2f.py +++ b/Examples/Scripts/Python/truth_tracking_gx2f.py @@ -30,6 +30,7 @@ def runTruthTrackingGx2f( from acts.examples.reconstruction import ( addSeeding, SeedingAlgorithm, + TrackSmearingSigmas, addGx2fTracks, ) @@ -97,6 +98,29 @@ def runTruthTrackingGx2f( rnd=rnd, inputParticles="particles_input", seedingAlgorithm=SeedingAlgorithm.TruthSmeared, + trackSmearingSigmas=TrackSmearingSigmas( + # zero eveything so the CKF has a chance to find the measurements + loc0=0, + loc0PtA=0, + loc0PtB=0, + loc1=0, + loc1PtA=0, + loc1PtB=0, + time=0, + phi=0, + theta=0, + ptRel=0, + ), + initialSigmas=[ + 1 * u.mm, + 1 * u.mm, + 1 * u.degree, + 1 * u.degree, + 0.1 * u.e / u.GeV, + 1 * u.ns, + ], + initialSigmaPtRel=0.01, + initialVarInflation=[1.0] * 6, particleHypothesis=acts.ParticleHypothesis.muon, ) diff --git a/Examples/Scripts/Python/truth_tracking_kalman.py b/Examples/Scripts/Python/truth_tracking_kalman.py index 91c18f1dd28..355ad8cfe4c 100755 --- a/Examples/Scripts/Python/truth_tracking_kalman.py +++ b/Examples/Scripts/Python/truth_tracking_kalman.py @@ -34,6 +34,7 @@ def runTruthTrackingKalman( from acts.examples.reconstruction import ( addSeeding, SeedingAlgorithm, + TrackSmearingSigmas, addKalmanTracks, ) @@ -115,6 +116,29 @@ def runTruthTrackingKalman( rnd=rnd, inputParticles="particles_input", seedingAlgorithm=SeedingAlgorithm.TruthSmeared, + trackSmearingSigmas=TrackSmearingSigmas( + # zero eveything so the CKF has a chance to find the measurements + loc0=0, + loc0PtA=0, + loc0PtB=0, + loc1=0, + loc1PtA=0, + loc1PtB=0, + time=0, + phi=0, + theta=0, + ptRel=0, + ), + initialSigmas=[ + 1 * u.mm, + 1 * u.mm, + 1 * u.degree, + 1 * u.degree, + 0.1 * u.e / u.GeV, + 1 * u.ns, + ], + initialSigmaPtRel=0.01, + initialVarInflation=[1.0] * 6, particleHypothesis=acts.ParticleHypothesis.muon, ) From 75132ff3a055a3722e31c4cd5610d77a135ca27e Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sat, 2 Nov 2024 08:49:54 +0100 Subject: [PATCH 08/11] todo --- Examples/Python/python/acts/examples/reconstruction.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index fecac6068bb..4a09c20429f 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -513,7 +513,10 @@ def addTruthSmearedSeeding( """ rnd = rnd or acts.examples.RandomNumbers(seed=42) - # Run particle smearing + + # TODO do param extraction + + # Smearing track parameters trkSmear = acts.examples.TrackParameterSmearing( level=logLevel, inputTrackParameters=inputTrackParameters, From 2de864619c6589ed3369138d70f057a08fc1132f Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sat, 2 Nov 2024 09:04:32 +0100 Subject: [PATCH 09/11] implement particle track param extractor --- .../Generators/EventGenerator.cpp | 47 +++--------- .../Generators/EventGenerator.hpp | 5 -- .../ParticleTrackParamExtractor.cpp | 72 +++++++++++++++++++ .../ParticleTrackParamExtractor.hpp | 48 +++++++++++++ .../Algorithms/TruthTracking/CMakeLists.txt | 1 + .../python/acts/examples/reconstruction.py | 9 ++- .../Python/python/acts/examples/simulation.py | 1 - Examples/Python/src/Generators.cpp | 3 - Examples/Python/src/TruthTracking.cpp | 5 ++ 9 files changed, 141 insertions(+), 50 deletions(-) create mode 100644 Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.cpp create mode 100644 Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.hpp diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp index 3a57b67bd71..ba9ec37eaaf 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp @@ -22,8 +22,9 @@ #include #include -ActsExamples::EventGenerator::EventGenerator(const Config& cfg, - Acts::Logging::Level lvl) +namespace ActsExamples { + +EventGenerator::EventGenerator(const Config& cfg, Acts::Logging::Level lvl) : m_cfg(cfg), m_logger(Acts::getDefaultLogger("EventGenerator", lvl)) { if (m_cfg.outputParticles.empty()) { throw std::invalid_argument("Missing output particles collection"); @@ -40,20 +41,17 @@ ActsExamples::EventGenerator::EventGenerator(const Config& cfg, m_outputParticles.initialize(m_cfg.outputParticles); m_outputVertices.initialize(m_cfg.outputVertices); - m_outputTrackParameters.maybeInitialize(m_cfg.outputTrackParameters); } -std::string ActsExamples::EventGenerator::name() const { +std::string EventGenerator::name() const { return "EventGenerator"; } -std::pair -ActsExamples::EventGenerator::availableEvents() const { +std::pair EventGenerator::availableEvents() const { return {0u, std::numeric_limits::max()}; } -ActsExamples::ProcessCode ActsExamples::EventGenerator::read( - const AlgorithmContext& ctx) { +ProcessCode EventGenerator::read(const AlgorithmContext& ctx) { SimParticleContainer particles; SimVertexContainer vertices; @@ -121,40 +119,11 @@ ActsExamples::ProcessCode ActsExamples::EventGenerator::read( << " n_primary_vertices=" << nPrimaryVertices << " n_particles=" << particles.size()); - if (m_outputTrackParameters.isInitialized()) { - std::unordered_map> - perigeeSurfaces; - - for (auto&& [vtxId, vtxParticles] : groupBySecondaryVertex(particles)) { - // a group contains at least one particle by construction. assume that all - // particles within the group originate from the same position and use it - // to as the reference position for the perigee frame. - auto perigee = Acts::Surface::makeShared( - vtxParticles.begin()->position()); - perigeeSurfaces[vtxId] = perigee; - } - - // create track parameters from the particles - TrackParametersContainer trackParameters; - for (const auto& particle : particles) { - const auto vtxId = particle.particleId().vertexId(); - const auto particleHypothesis = particle.hypothesis(); - const auto phi = Acts::VectorHelpers::phi(particle.direction()); - const auto theta = Acts::VectorHelpers::theta(particle.direction()); - const auto qOverP = particle.qOverP(); - const auto time = particle.time(); - - trackParameters.emplace_back( - perigeeSurfaces.at(vtxId), - Acts::BoundVector{0, 0, phi, theta, qOverP, time}, std::nullopt, - particleHypothesis); - } - m_outputTrackParameters(ctx, std::move(trackParameters)); - } - // move generated event to the store m_outputParticles(ctx, std::move(particles)); m_outputVertices(ctx, std::move(vertices)); return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp index e18c42eaa37..7a76ac03d71 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.hpp @@ -12,7 +12,6 @@ #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/EventData/SimVertex.hpp" -#include "ActsExamples/EventData/Track.hpp" #include "ActsExamples/Framework/DataHandle.hpp" #include "ActsExamples/Framework/IReader.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" @@ -95,8 +94,6 @@ class EventGenerator final : public ActsExamples::IReader { std::string outputParticles; /// Name of the output vertex collection. std::string outputVertices; - /// Optional. Name of the output track parameters collection. - std::string outputTrackParameters; /// List of generators that should be used to generate the event. std::vector generators; @@ -126,8 +123,6 @@ class EventGenerator final : public ActsExamples::IReader { WriteDataHandle m_outputParticles{this, "OutputParticles"}; WriteDataHandle m_outputVertices{this, "OutputVertices"}; - WriteDataHandle m_outputTrackParameters{ - this, "OutputTrackParameters"}; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.cpp new file mode 100644 index 00000000000..d480ca8f88f --- /dev/null +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.cpp @@ -0,0 +1,72 @@ +// 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/ParticleTrackParamExtractor.hpp" + +#include "Acts/Surfaces/PerigeeSurface.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" +#include "ActsExamples/Framework/AlgorithmContext.hpp" + +#include +#include + +namespace ActsExamples { + +ParticleTrackParamExtractor::ParticleTrackParamExtractor( + const Config& config, Acts::Logging::Level level) + : IAlgorithm("ParticleTrackParamExtractor", level), m_cfg(config) { + if (m_cfg.inputParticles.empty()) { + throw std::invalid_argument("Missing input particles collection"); + } + if (m_cfg.outputTrackParameters.empty()) { + throw std::invalid_argument("Missing output track parameters collection"); + } + + m_inputParticles.initialize(m_cfg.inputParticles); + m_outputTrackParameters.initialize(m_cfg.outputTrackParameters); +} + +ActsExamples::ProcessCode ParticleTrackParamExtractor::execute( + const AlgorithmContext& ctx) const { + const SimParticleContainer& particles = m_inputParticles(ctx); + + std::unordered_map> + perigeeSurfaces; + + for (auto&& [vtxId, vtxParticles] : groupBySecondaryVertex(particles)) { + // a group contains at least one particle by construction. assume that all + // particles within the group originate from the same position and use it + // to as the reference position for the perigee frame. + auto perigee = Acts::Surface::makeShared( + vtxParticles.begin()->position()); + perigeeSurfaces[vtxId] = perigee; + } + + // create track parameters from the particles + TrackParametersContainer trackParameters; + + for (const auto& particle : particles) { + const auto vtxId = particle.particleId().vertexId(); + const auto particleHypothesis = particle.hypothesis(); + const auto phi = Acts::VectorHelpers::phi(particle.direction()); + const auto theta = Acts::VectorHelpers::theta(particle.direction()); + const auto qOverP = particle.qOverP(); + const auto time = particle.time(); + + trackParameters.emplace_back( + perigeeSurfaces.at(vtxId), + Acts::BoundVector{0, 0, phi, theta, qOverP, time}, std::nullopt, + particleHypothesis); + } + + m_outputTrackParameters(ctx, std::move(trackParameters)); + + return ProcessCode::SUCCESS; +} + +} // namespace ActsExamples diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.hpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.hpp new file mode 100644 index 00000000000..60882fa9ace --- /dev/null +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleTrackParamExtractor.hpp @@ -0,0 +1,48 @@ +// 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/SimParticle.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include "ActsExamples/Framework/DataHandle.hpp" +#include "ActsExamples/Framework/IAlgorithm.hpp" +#include "ActsExamples/Framework/ProcessCode.hpp" + +#include + +namespace ActsExamples { +struct AlgorithmContext; + +/// Extract track parameters from particles. +class ParticleTrackParamExtractor final : public IAlgorithm { + public: + struct Config { + /// The input particles collection. + std::string inputParticles; + /// The output track parameters collection. + std::string outputTrackParameters; + }; + + ParticleTrackParamExtractor(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"}; + WriteDataHandle m_outputTrackParameters{ + this, "OutputTrackParameters"}; +}; + +} // namespace ActsExamples diff --git a/Examples/Algorithms/TruthTracking/CMakeLists.txt b/Examples/Algorithms/TruthTracking/CMakeLists.txt index 6e68b92a5c2..85ac94357a8 100644 --- a/Examples/Algorithms/TruthTracking/CMakeLists.txt +++ b/Examples/Algorithms/TruthTracking/CMakeLists.txt @@ -2,6 +2,7 @@ add_library( ActsExamplesTruthTracking SHARED ActsExamples/TruthTracking/ParticleSelector.cpp + ActsExamples/TruthTracking/ParticleTrackParamExtractor.cpp ActsExamples/TruthTracking/TrackParameterSmearing.cpp ActsExamples/TruthTracking/TrackParameterSelector.cpp ActsExamples/TruthTracking/TrackModifier.cpp diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index 4a09c20429f..1d38a4d6ed7 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -500,7 +500,6 @@ def addTruthSmearedSeeding( s: acts.examples.Sequencer, rnd: Optional[acts.examples.RandomNumbers], selectedParticles: str, - inputTrackParameters: str, trackSmearingSigmas: TrackSmearingSigmas, initialSigmas: Optional[List[float]], initialSigmaPtRel: Optional[float], @@ -515,11 +514,17 @@ def addTruthSmearedSeeding( rnd = rnd or acts.examples.RandomNumbers(seed=42) # TODO do param extraction + trkParamExtractor = acts.examples.ParticleTrackParametersExtractor( + level=logLevel, + inputParticles=selectedParticles, + outputTrackParameters="trueparameters", + ) + s.addAlgorithm(trkParamExtractor) # Smearing track parameters trkSmear = acts.examples.TrackParameterSmearing( level=logLevel, - inputTrackParameters=inputTrackParameters, + inputTrackParameters=trkParamExtractor.config.outputTrackParameters, outputTrackParameters="estimatedparameters", randomNumbers=rnd, # gaussian sigmas to smear particle parameters diff --git a/Examples/Python/python/acts/examples/simulation.py b/Examples/Python/python/acts/examples/simulation.py index 51e4fed5aef..428a988f4cd 100644 --- a/Examples/Python/python/acts/examples/simulation.py +++ b/Examples/Python/python/acts/examples/simulation.py @@ -132,7 +132,6 @@ def addParticleGun( ], outputParticles="particles_input", outputVertices="vertices_input", - outputTrackParameters="particle_track_parameters", randomNumbers=rnd, ) diff --git a/Examples/Python/src/Generators.cpp b/Examples/Python/src/Generators.cpp index 3a9f1feaf36..95c6b3dcffa 100644 --- a/Examples/Python/src/Generators.cpp +++ b/Examples/Python/src/Generators.cpp @@ -16,8 +16,6 @@ #include "ActsExamples/Generators/ParametricParticleGenerator.hpp" #include "ActsExamples/Generators/VertexGenerators.hpp" -#include -#include #include #include #include @@ -79,7 +77,6 @@ void addGenerators(Context& ctx) { .def(py::init<>()) .def_readwrite("outputParticles", &Config::outputParticles) .def_readwrite("outputVertices", &Config::outputVertices) - .def_readwrite("outputTrackParameters", &Config::outputTrackParameters) .def_readwrite("generators", &Config::generators) .def_readwrite("randomNumbers", &Config::randomNumbers); } diff --git a/Examples/Python/src/TruthTracking.cpp b/Examples/Python/src/TruthTracking.cpp index b9913292fa2..428c294a082 100644 --- a/Examples/Python/src/TruthTracking.cpp +++ b/Examples/Python/src/TruthTracking.cpp @@ -9,6 +9,7 @@ #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/TruthTracking/ParticleSelector.hpp" +#include "ActsExamples/TruthTracking/ParticleTrackParamExtractor.hpp" #include "ActsExamples/TruthTracking/TrackModifier.hpp" #include "ActsExamples/TruthTracking/TrackParameterSelector.hpp" #include "ActsExamples/TruthTracking/TrackParameterSmearing.hpp" @@ -84,6 +85,10 @@ void addTruthTracking(Context& ctx) { pythonRangeProperty(c, "nHits", &Config::nHitsMin, &Config::nHitsMax); } + ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::ParticleTrackParamExtractor, mex, + "ParticleTrackParamExtractor", inputParticles, + outputTrackParameters); + ACTS_PYTHON_DECLARE_ALGORITHM( ActsExamples::TrackParameterSmearing, mex, "TrackParameterSmearing", inputTrackParameters, outputTrackParameters, sigmaLoc0, sigmaLoc0PtA, From 786bc6d14aeb966290d9a46e34ece32016e59307 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 3 Nov 2024 13:59:53 +0100 Subject: [PATCH 10/11] pr feedback --- .../TruthTracking/TrackParameterSmearing.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp index 8c0b7723f4f..a03ca36aa38 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TrackParameterSmearing.cpp @@ -39,11 +39,40 @@ TrackParameterSmearing::TrackParameterSmearing(const Config& config, m_inputTrackParameters.initialize(m_cfg.inputTrackParameters); m_outputTrackParameters.initialize(m_cfg.outputTrackParameters); + + ACTS_DEBUG("smearing track param loc0 " << m_cfg.sigmaLoc0 << " A " + << m_cfg.sigmaLoc0PtA << " B " + << m_cfg.sigmaLoc0PtB); + ACTS_DEBUG("smearing track param loc1 " << m_cfg.sigmaLoc1 << " A " + << m_cfg.sigmaLoc1PtA << " B " + << m_cfg.sigmaLoc1PtB); + ACTS_DEBUG("smearing track param time " << m_cfg.sigmaTime); + ACTS_DEBUG("smearing track param phi " << m_cfg.sigmaPhi); + ACTS_DEBUG("smearing track param theta " << m_cfg.sigmaTheta); + ACTS_DEBUG("smearing track param q/p " << m_cfg.sigmaPtRel); + ACTS_DEBUG( + "initial sigmas " + << Acts::BoundVector( + m_cfg.initialSigmas.value_or(std::array()).data()) + .transpose()); + ACTS_DEBUG("initial sigma pt rel " << m_cfg.initialSigmaPtRel); + ACTS_DEBUG( + "initial var inflation " + << Acts::BoundVector(m_cfg.initialVarInflation.data()).transpose()); + if (m_cfg.particleHypothesis) { + ACTS_DEBUG("particle hypothesis " << *m_cfg.particleHypothesis); + } else { + ACTS_DEBUG("particle hypothesis truth"); + } } ProcessCode TrackParameterSmearing::execute(const AlgorithmContext& ctx) const { // setup input and output containers const auto& inputTrackParametersContainer = m_inputTrackParameters(ctx); + + ACTS_VERBOSE("Smearing " << inputTrackParametersContainer.size() + << " track parameters"); + TrackParametersContainer outputTrackParametersContainer; outputTrackParametersContainer.reserve(inputTrackParametersContainer.size()); From 99c990a6b05eeadc947452697fc9335b83e97c49 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 6 Nov 2024 13:56:47 +0100 Subject: [PATCH 11/11] fix --- Examples/Python/python/acts/examples/simulation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/Python/python/acts/examples/simulation.py b/Examples/Python/python/acts/examples/simulation.py index 428a988f4cd..8f6b6d0e603 100644 --- a/Examples/Python/python/acts/examples/simulation.py +++ b/Examples/Python/python/acts/examples/simulation.py @@ -296,7 +296,6 @@ def addPythia8( generators=generators, outputParticles="particles_input", outputVertices="vertices_input", - outputTrackParameters="particle_track_parameters", randomNumbers=rnd, )