From 0bfe316184736fd272b2b745a87091187ce283c5 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 10 Nov 2024 14:42:06 +0100 Subject: [PATCH 1/5] refactor: Remove `CalculateResiduals.hpp` (#3837) This helper is not used anywhere and should be either removed or made use of. I opted to remove it for now as finding all the spots where it could be used is much more tedious and time consuming. Discovered in https://github.com/acts-project/acts/pull/3836 --- .../EventData/detail/CalculateResiduals.hpp | 96 ------------------- .../ActsExamples/EventData/Measurement.hpp | 1 - 2 files changed, 97 deletions(-) delete mode 100644 Core/include/Acts/EventData/detail/CalculateResiduals.hpp diff --git a/Core/include/Acts/EventData/detail/CalculateResiduals.hpp b/Core/include/Acts/EventData/detail/CalculateResiduals.hpp deleted file mode 100644 index 33d800d16e6..00000000000 --- a/Core/include/Acts/EventData/detail/CalculateResiduals.hpp +++ /dev/null @@ -1,96 +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/Definitions/TrackParametrization.hpp" -#include "Acts/Utilities/detail/periodic.hpp" - -#include - -#include - -namespace Acts::detail { - -/// Residuals between bound reference parameters and a measured subspace. -/// -/// @tparam index_container_t SequenceContainer for measured indices -/// @tparam measured_t Measured parameters vector type -/// @tparam residuals_t Residuals vector type -/// @param[in] size Size of the measured parameters subspace -/// @param[in] indices Indices of measured subspace, must have `size` entries -/// @param[in] reference Reference bound parameters -/// @param[in] measured Measured parameters subspace -/// @param[out] residuals Resulting residuals in the measured subspace -/// -/// @note The separate `size` parameter is also used to allow the selection of -/// the correct residuals methods depending on the parameters type. -template -inline void calculateResiduals(BoundIndices size, - const index_container_t& indices, - const BoundVector& reference, - const Eigen::MatrixBase& measured, - Eigen::MatrixBase& residuals) { - using OutputScalar = typename residuals_t::Scalar; - - EIGEN_STATIC_ASSERT_VECTOR_ONLY(measured_t); - EIGEN_STATIC_ASSERT_VECTOR_ONLY(residuals_t); - assert((size <= eBoundSize) && "Measured subspace is too large"); - assert((size <= measured.size()) && "Inconsistent measured size"); - assert((size <= residuals.size()) && "Inconsistent residuals size"); - - for (std::size_t i = 0; i < size; ++i) { - std::size_t fullIndex = indices[i]; - // this is neither elegant nor smart but it is the simplest solution. - // - // only phi must be handled specially here. the theta limits can only be - // correctly handled if phi is updated, too. since we can not ensure that - // both are available, it is probably less error-prone to treat theta as a - // regular, unrestricted parameter. - if (fullIndex == eBoundPhi) { - residuals[i] = difference_periodic( - measured[i], reference[fullIndex], - static_cast(2 * M_PI)); - } else { - residuals[i] = measured[i] - reference[fullIndex]; - } - } -} - -/// Residuals between free reference parameters and a measured subspace. -/// -/// @tparam index_container_t SequenceContainer for measured inidices -/// @tparam measured_t Measured parameters vector type -/// @tparam residuals_t Residuals vector type -/// @param[in] size Size of the measured parameters subspace -/// @param[in] indices Indices of measured subspace, must have `size` entries -/// @param[in] reference Reference free parameters -/// @param[in] measured Measured parameters subspace -/// @param[out] residuals Resulting residuals in the measured subspace -/// -/// @note The separate `size` parameter is also used to allow the selection of -/// the correct residuals methods depending on the parameters type. -template -inline void calculateResiduals(FreeIndices size, - const index_container_t& indices, - const FreeVector& reference, - const Eigen::MatrixBase& measured, - Eigen::MatrixBase& residuals) { - EIGEN_STATIC_ASSERT_VECTOR_ONLY(measured_t); - EIGEN_STATIC_ASSERT_VECTOR_ONLY(residuals_t); - assert((size <= eFreeSize) && "Measured subspace is too large"); - assert((size <= measured.size()) && "Inconsistent measured size"); - assert((size <= residuals.size()) && "Inconsistent residuals size"); - - for (std::size_t i = 0; i < size; ++i) { - // all free parameters are unrestricted. no need to call parameter traits - residuals[i] = measured[i] - reference[indices[i]]; - } -} - -} // namespace Acts::detail diff --git a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp index a0bf4559509..ab232628341 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp @@ -13,7 +13,6 @@ #include "Acts/EventData/MeasurementHelpers.hpp" #include "Acts/EventData/SubspaceHelpers.hpp" #include "Acts/EventData/Types.hpp" -#include "Acts/EventData/detail/CalculateResiduals.hpp" #include "Acts/EventData/detail/ParameterTraits.hpp" #include "Acts/EventData/detail/PrintParameters.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" From 69031ba9caf5184341e9e320a48b097af1f255a5 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sun, 10 Nov 2024 18:33:02 +0100 Subject: [PATCH 2/5] refactor: Fuse initial and final sim particles in Examples (#3804) The split of initial and final state of particles became more and more a burden. Currently we have a single EDM to store the particle state after generation and after simulation. While for simulation we have more properties on the particle which is split into `initial` and `final` states. Here I propose to combine the information into the particle object by carrying all states. Replaces https://github.com/acts-project/acts/pull/3795 ## Summary by CodeRabbit - **New Features** - Consolidated output handling for particles by replacing `outputParticlesInitial` and `outputParticlesFinal` with a single `outputParticlesSimulation` parameter across multiple components. - Enhanced `SimParticle` class with new methods and properties for better particle management. - **Bug Fixes** - Improved error handling and validation processes in various components to ensure robustness. - **Documentation** - Updated documentation to reflect changes in parameter names and functionality across several modules. - **Chores** - Removed unused include statements and optimized dependencies in various files to streamline the codebase. - **Tests** - Updated tests to validate new output naming conventions and ensure compatibility with the revised particle handling logic. --- CI/physmon/config/pythia8_ttbar.yml | 5 + CI/physmon/workflows/physmon_simulation.py | 6 +- .../ActsExamples/Fatras/FatrasSimulation.hpp | 12 +- .../Fatras/src/FatrasSimulation.cpp | 77 ++++--- .../ActsExamples/Geant4/EventStore.hpp | 8 +- .../ActsExamples/Geant4/Geant4Simulation.hpp | 13 +- .../Geant4/ParticleTrackingAction.hpp | 5 +- .../Geant4/src/Geant4Simulation.cpp | 25 +-- .../Geant4/src/ParticleTrackingAction.cpp | 28 ++- .../Geant4/src/SimParticleTranslation.cpp | 4 - .../Generators/EventGenerator.cpp | 4 +- .../ParametricParticleGenerator.cpp | 5 +- .../Generators/Pythia8ProcessGenerator.cpp | 9 +- .../HepMC/src/HepMCProcessExtractor.cpp | 55 +++-- .../Printers/ParticlesPrinter.cpp | 2 - .../TruthTracking/ParticleSelector.cpp | 44 +--- .../TruthTracking/ParticleSelector.hpp | 12 -- Examples/Framework/CMakeLists.txt | 1 + .../ActsExamples/EventData/SimParticle.hpp | 204 ++++++++++++++++-- .../Validation/DuplicationPlotTool.hpp | 4 +- .../ActsExamples/Validation/EffPlotTool.hpp | 7 +- .../Validation/FakeRatePlotTool.hpp | 4 +- .../ActsExamples/Validation/ResPlotTool.hpp | 4 +- .../Framework/src/EventData/SimParticle.cpp | 21 ++ .../src/Validation/DuplicationPlotTool.cpp | 5 +- .../Framework/src/Validation/EffPlotTool.cpp | 4 +- .../src/Validation/FakeRatePlotTool.cpp | 5 +- .../Framework/src/Validation/ResPlotTool.cpp | 6 +- Examples/Io/Csv/src/CsvParticleReader.cpp | 10 +- .../ActsExamples/Io/EDM4hep/EDM4hepReader.hpp | 24 +-- .../ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp | 8 +- .../Io/EDM4hep/src/EDM4hepParticleWriter.cpp | 3 - Examples/Io/EDM4hep/src/EDM4hepReader.cpp | 95 ++++---- Examples/Io/EDM4hep/src/EDM4hepUtil.cpp | 33 ++- Examples/Io/HepMC3/src/HepMC3Particle.cpp | 7 +- .../Io/Root/RootParticleReader.hpp | 6 + .../Io/Root/RootParticleWriter.hpp | 7 - .../ActsExamples/Io/Root/RootSimHitReader.hpp | 3 - .../Io/Root/RootTrackSummaryReader.hpp | 1 - Examples/Io/Root/src/RootAthenaDumpReader.cpp | 17 +- Examples/Io/Root/src/RootParticleReader.cpp | 49 +++-- Examples/Io/Root/src/RootParticleWriter.cpp | 68 ++---- .../Io/Root/src/RootTrackSummaryReader.cpp | 4 +- .../Io/Root/src/SeedingPerformanceWriter.cpp | 5 +- .../Root/src/TrackFinderPerformanceWriter.cpp | 9 +- .../Root/src/TrackFitterPerformanceWriter.cpp | 6 +- .../NuclearInteractionParametrisation.cpp | 17 +- .../Python/python/acts/examples/simulation.py | 112 ++++------ Examples/Python/src/EDM4hepComponent.cpp | 8 +- Examples/Python/src/ExampleAlgorithms.cpp | 10 +- Examples/Python/src/Geant4Component.cpp | 5 +- Examples/Python/src/Output.cpp | 4 +- Examples/Python/src/TruthTracking.cpp | 2 - Examples/Python/tests/conftest.py | 3 +- Examples/Python/tests/root_file_hashes.txt | 20 +- Examples/Python/tests/test_examples.py | 19 +- Examples/Python/tests/test_reader.py | 3 +- Examples/Scripts/Python/full_chain_odd.py | 3 +- Examples/Scripts/Python/full_chain_odd_LRT.py | 3 +- Examples/Scripts/Python/seeding.py | 1 - .../include/ActsFatras/EventData/Particle.hpp | 45 ++-- .../include/ActsFatras/Kernel/Simulation.hpp | 6 - 62 files changed, 620 insertions(+), 575 deletions(-) create mode 100644 Examples/Framework/src/EventData/SimParticle.cpp diff --git a/CI/physmon/config/pythia8_ttbar.yml b/CI/physmon/config/pythia8_ttbar.yml index 301aba1c7e5..6a71fe03988 100644 --- a/CI/physmon/config/pythia8_ttbar.yml +++ b/CI/physmon/config/pythia8_ttbar.yml @@ -65,3 +65,8 @@ exclude: - particle - generation - sub_particle + - e_loss + - total_x0 + - total_l0 + - number_of_hits + - outcome diff --git a/CI/physmon/workflows/physmon_simulation.py b/CI/physmon/workflows/physmon_simulation.py index 37874663187..206890540b8 100755 --- a/CI/physmon/workflows/physmon_simulation.py +++ b/CI/physmon/workflows/physmon_simulation.py @@ -81,8 +81,7 @@ preSelectParticles=None, postSelectParticles=ParticleSelectorConfig(removeSecondaries=True), inputParticles="particles_input", - outputParticlesInitial="particles_initial_fatras", - outputParticlesFinal="particles_final_fatras", + outputParticles="particles_fatras", outputSimHits="simhits_fatras", outputDirRoot=tp / "fatras", ) @@ -99,8 +98,7 @@ killAfterTime=25 * u.ns, killSecondaries=True, inputParticles="particles_input", - outputParticlesInitial="particles_initial_geant4", - outputParticlesFinal="particles_final_geant4", + outputParticles="particles_geant4", outputSimHits="simhits_geant4", outputDirRoot=tp / "geant4", ) diff --git a/Examples/Algorithms/Fatras/include/ActsExamples/Fatras/FatrasSimulation.hpp b/Examples/Algorithms/Fatras/include/ActsExamples/Fatras/FatrasSimulation.hpp index 100a34b6257..75395218a9e 100644 --- a/Examples/Algorithms/Fatras/include/ActsExamples/Fatras/FatrasSimulation.hpp +++ b/Examples/Algorithms/Fatras/include/ActsExamples/Fatras/FatrasSimulation.hpp @@ -43,10 +43,8 @@ class FatrasSimulation final : public IAlgorithm { struct Config { /// The particles input collection. std::string inputParticles; - /// The simulated particles initial state collection. - std::string outputParticlesInitial; - /// The simulated particles final state collection. - std::string outputParticlesFinal; + /// The simulated particles collection. + std::string outputParticles; /// The simulated hits output collection. std::string outputSimHits; /// Parametrisation of nuclear interaction @@ -110,10 +108,8 @@ class FatrasSimulation final : public IAlgorithm { WriteDataHandle m_outputSimHits{this, "OutputSimHits"}; - WriteDataHandle m_outputParticlesInitial{ - this, "OutputParticlesInitial"}; - WriteDataHandle m_outputParticlesFinal{ - this, "OutputParticlesFinal"}; + WriteDataHandle m_outputParticles{this, + "OutputParticles"}; private: Config m_cfg; diff --git a/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp b/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp index 48c66eeff3f..f9e627f482a 100644 --- a/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp +++ b/Examples/Algorithms/Fatras/src/FatrasSimulation.cpp @@ -8,8 +8,6 @@ #include "ActsExamples/Fatras/FatrasSimulation.hpp" -#include "Acts/Definitions/Direction.hpp" -#include "Acts/EventData/TrackParameters.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Propagator/Navigator.hpp" @@ -24,20 +22,17 @@ #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/IAlgorithm.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" -#include "ActsFatras/EventData/Barcode.hpp" +#include "ActsFatras/EventData/Hit.hpp" #include "ActsFatras/EventData/Particle.hpp" #include "ActsFatras/Kernel/InteractionList.hpp" #include "ActsFatras/Kernel/Simulation.hpp" #include "ActsFatras/Physics/Decay/NoDecay.hpp" #include "ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp" -#include "ActsFatras/Physics/NuclearInteraction/NuclearInteractionParameters.hpp" #include "ActsFatras/Physics/StandardInteractions.hpp" #include "ActsFatras/Selectors/SelectorHelpers.hpp" #include "ActsFatras/Selectors/SurfaceSelectors.hpp" #include -#include -#include #include #include #include @@ -73,10 +68,9 @@ struct ActsExamples::detail::FatrasSimulation { virtual ~FatrasSimulation() = default; virtual Acts::Result> simulate( const Acts::GeometryContext &, const Acts::MagneticFieldContext &, - ActsExamples::RandomEngine &, const ActsExamples::SimParticleContainer &, - ActsExamples::SimParticleContainer::sequence_type &, - ActsExamples::SimParticleContainer::sequence_type &, - ActsExamples::SimHitContainer::sequence_type &) const = 0; + ActsExamples::RandomEngine &, const std::vector &, + std::vector &, std::vector &, + std::vector &) const = 0; }; namespace { @@ -172,12 +166,10 @@ struct FatrasSimulationT final : ActsExamples::detail::FatrasSimulation { Acts::Result> simulate( const Acts::GeometryContext &geoCtx, const Acts::MagneticFieldContext &magCtx, ActsExamples::RandomEngine &rng, - const ActsExamples::SimParticleContainer &inputParticles, - ActsExamples::SimParticleContainer::sequence_type - &simulatedParticlesInitial, - ActsExamples::SimParticleContainer::sequence_type - &simulatedParticlesFinal, - ActsExamples::SimHitContainer::sequence_type &simHits) const final { + const std::vector &inputParticles, + std::vector &simulatedParticlesInitial, + std::vector &simulatedParticlesFinal, + std::vector &simHits) const final { return simulation.simulate(geoCtx, magCtx, rng, inputParticles, simulatedParticlesInitial, simulatedParticlesFinal, simHits); @@ -212,8 +204,7 @@ ActsExamples::FatrasSimulation::FatrasSimulation(Config cfg, m_sim = std::make_unique(m_cfg, lvl); m_inputParticles.initialize(m_cfg.inputParticles); - m_outputParticlesInitial.initialize(m_cfg.outputParticlesInitial); - m_outputParticlesFinal.initialize(m_cfg.outputParticlesFinal); + m_outputParticles.initialize(m_cfg.outputParticles); m_outputSimHits.initialize(m_cfg.outputSimHits); } @@ -227,10 +218,17 @@ ActsExamples::ProcessCode ActsExamples::FatrasSimulation::execute( ACTS_DEBUG(inputParticles.size() << " input particles"); + // prepare input container + std::vector particlesInput; + particlesInput.reserve(inputParticles.size()); + for (const auto &p : inputParticles) { + particlesInput.push_back(p.initial()); + } + // prepare output containers - SimParticleContainer::sequence_type particlesInitialUnordered; - SimParticleContainer::sequence_type particlesFinalUnordered; - SimHitContainer::sequence_type simHitsUnordered; + std::vector particlesInitialUnordered; + std::vector particlesFinalUnordered; + std::vector simHitsUnordered; // reserve appropriate resources particlesInitialUnordered.reserve(inputParticles.size()); particlesFinalUnordered.reserve(inputParticles.size()); @@ -240,7 +238,7 @@ ActsExamples::ProcessCode ActsExamples::FatrasSimulation::execute( // run the simulation w/ a local random generator auto rng = m_cfg.randomNumbers->spawnGenerator(ctx); auto ret = m_sim->simulate(ctx.geoContext, ctx.magFieldContext, rng, - inputParticles, particlesInitialUnordered, + particlesInput, particlesInitialUnordered, particlesFinalUnordered, simHitsUnordered); // fatal error leads to panic if (!ret.ok()) { @@ -263,19 +261,23 @@ ActsExamples::ProcessCode ActsExamples::FatrasSimulation::execute( << " simulated particles (final state)"); ACTS_DEBUG(simHitsUnordered.size() << " simulated hits"); + if (particlesInitialUnordered.size() != particlesFinalUnordered.size()) { + ACTS_ERROR("number of initial and final state particles differ"); + } + // order output containers #if BOOST_VERSION >= 107800 - SimParticleContainer particlesInitial(particlesInitialUnordered.begin(), - particlesInitialUnordered.end()); - SimParticleContainer particlesFinal(particlesFinalUnordered.begin(), - particlesFinalUnordered.end()); + SimParticleStateContainer particlesInitial(particlesInitialUnordered.begin(), + particlesInitialUnordered.end()); + SimParticleStateContainer particlesFinal(particlesFinalUnordered.begin(), + particlesFinalUnordered.end()); SimHitContainer simHits(simHitsUnordered.begin(), simHitsUnordered.end()); #else // working around a nasty boost bug // https://github.com/boostorg/container/issues/244 - SimParticleContainer particlesInitial; - SimParticleContainer particlesFinal; + SimParticleStateContainer particlesInitial; + SimParticleStateContainer particlesFinal; SimHitContainer simHits; particlesInitial.reserve(particlesInitialUnordered.size()); @@ -293,9 +295,24 @@ ActsExamples::ProcessCode ActsExamples::FatrasSimulation::execute( } #endif + SimParticleContainer particlesSimulated; + particlesSimulated.reserve(particlesInitial.size()); + for (const auto &particleInitial : particlesInitial) { + SimParticle particleSimulated(particleInitial, particleInitial); + + if (auto it = particlesFinal.find(particleInitial.particleId()); + it != particlesFinal.end()) { + particleSimulated.final() = *it; + } else { + ACTS_ERROR("particle " << particleInitial.particleId() + << " has no final state"); + } + + particlesSimulated.insert(particleSimulated); + } + // store ordered output containers - m_outputParticlesInitial(ctx, std::move(particlesInitial)); - m_outputParticlesFinal(ctx, std::move(particlesFinal)); + m_outputParticles(ctx, std::move(particlesSimulated)); m_outputSimHits(ctx, std::move(simHits)); return ActsExamples::ProcessCode::SUCCESS; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp index f7ef51638d6..a46512ce299 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp @@ -33,11 +33,13 @@ struct EventStore { /// Use a std::set here because it allows for fast insertion and ensures /// uniqueness. Thus particle collisions are detected early. using ParticleContainer = - std::set; + std::set; - /// Initial and final particle collections + /// Initial particle collection ParticleContainer particlesInitial; - ParticleContainer particlesFinal; + + /// Simulated particle collection + ParticleContainer particlesSimulated; /// The hits in sensitive detectors SimHitContainer::sequence_type hits; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp index 487aadaba36..f735dcd3859 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp @@ -118,11 +118,8 @@ class Geant4Simulation final : public Geant4SimulationBase { /// Name of the output collection : hits std::string outputSimHits = "simhits"; - /// Name of the output collection : initial particles - std::string outputParticlesInitial = "particles_initial"; - - /// Name of the output collection : final particles - std::string outputParticlesFinal = "particles_final"; + /// Name of the output collection : simulated particles + std::string outputParticles = "particles_simulated"; /// The ACTS sensitive surfaces in a mapper, used for hit creation std::shared_ptr sensitiveSurfaceMapper = @@ -170,10 +167,8 @@ class Geant4Simulation final : public Geant4SimulationBase { std::unique_ptr m_magneticField; std::unique_ptr m_fieldManager; - WriteDataHandle m_outputParticlesInitial{ - this, "OutputParticlesInitial"}; - WriteDataHandle m_outputParticlesFinal{ - this, "OutputParticlesFinal"}; + WriteDataHandle m_outputParticles{this, + "OutputParticles"}; WriteDataHandle m_outputSimHits{this, "OutputSimHIts"}; }; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp index 6e79f654db6..acf07ec75dc 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp @@ -62,11 +62,12 @@ class ParticleTrackingAction : public G4UserTrackingAction { Config m_cfg; private: - /// Convert a G4Track to a SimParticle + /// Convert a G4Track to a SimParticleState /// /// @param aTrack the current Geant4 track /// @param particleId the particle ID the particle will have - SimParticle convert(const G4Track& aTrack, SimBarcode particleId) const; + /// @return SimParticleState the converted particle state + SimParticleState convert(const G4Track& aTrack, SimBarcode particleId) const; /// Make the particle id std::optional makeParticleId(G4int trackId, G4int parentId) const; diff --git a/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp b/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp index 515159e3e51..795ddad78fa 100644 --- a/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp +++ b/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Plugins/FpeMonitoring/FpeMonitor.hpp" #include "Acts/Utilities/Logger.hpp" -#include "Acts/Utilities/MultiIndex.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/IAlgorithm.hpp" #include "ActsExamples/Framework/RandomNumbers.hpp" @@ -28,12 +27,8 @@ #include "ActsExamples/Geant4/SensitiveSurfaceMapper.hpp" #include "ActsExamples/Geant4/SimParticleTranslation.hpp" #include "ActsExamples/Geant4/SteppingActionList.hpp" -#include "ActsFatras/EventData/Barcode.hpp" -#include -#include #include -#include #include #include @@ -135,14 +130,6 @@ ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::execute( runManager().BeamOn(1); } - // Since these are std::set, this ensures that each particle is in both sets - throw_assert( - eventStore().particlesInitial.size() == - eventStore().particlesFinal.size(), - "initial and final particle collections does not have the same size: " - << eventStore().particlesInitial.size() << " vs " - << eventStore().particlesFinal.size()); - // Print out warnings about possible particle collision if happened if (eventStore().particleIdCollisionsInitial > 0 || eventStore().particleIdCollisionsFinal > 0 || @@ -298,8 +285,7 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, m_inputParticles.initialize(cfg.inputParticles); m_outputSimHits.initialize(cfg.outputSimHits); - m_outputParticlesInitial.initialize(cfg.outputParticlesInitial); - m_outputParticlesFinal.initialize(cfg.outputParticlesFinal); + m_outputParticles.initialize(cfg.outputParticles); } ActsExamples::Geant4Simulation::~Geant4Simulation() = default; @@ -312,12 +298,9 @@ ActsExamples::ProcessCode ActsExamples::Geant4Simulation::execute( } // Output handling: Simulation - m_outputParticlesInitial( - ctx, SimParticleContainer(eventStore().particlesInitial.begin(), - eventStore().particlesInitial.end())); - m_outputParticlesFinal( - ctx, SimParticleContainer(eventStore().particlesFinal.begin(), - eventStore().particlesFinal.end())); + m_outputParticles( + ctx, SimParticleContainer(eventStore().particlesSimulated.begin(), + eventStore().particlesSimulated.end())); #if BOOST_VERSION < 107800 SimHitContainer container; diff --git a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp index d56509e1ad1..ba59debc893 100644 --- a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp +++ b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp @@ -11,9 +11,9 @@ #include "Acts/Definitions/PdgParticle.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/Utilities/MultiIndex.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Geant4/EventStore.hpp" #include "ActsFatras/EventData/Barcode.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -50,7 +50,8 @@ void ActsExamples::ParticleTrackingAction::PreUserTrackingAction( return; } - auto particle = convert(*aTrack, *barcode); + auto fatrasParticle = convert(*aTrack, *barcode); + SimParticle particle(fatrasParticle, fatrasParticle); auto [it, success] = eventStore().particlesInitial.insert(particle); // Only register particle at the initial state AND if there is no particle ID @@ -67,7 +68,7 @@ void ActsExamples::ParticleTrackingAction::PreUserTrackingAction( void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( const G4Track* aTrack) { - // The initial particle maybe was not registered because a particle ID + // The initial particle maybe was not registered because of a particle ID // collision if (!eventStore().trackIdMapping.contains(aTrack->GetTrackID())) { ACTS_WARNING("Particle ID for track ID " << aTrack->GetTrackID() @@ -81,14 +82,22 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( eventStore().particleHitCount.at(barcode) > 0; if (!m_cfg.keepParticlesWithoutHits && !hasHits) { - [[maybe_unused]] auto n = eventStore().particlesInitial.erase( - ActsExamples::SimParticle{barcode, Acts::PdgParticle::eInvalid}); + [[maybe_unused]] auto n = eventStore().particlesSimulated.erase( + ActsExamples::SimParticle(barcode, Acts::PdgParticle::eInvalid)); assert(n == 1); return; } - auto particle = convert(*aTrack, barcode); - auto [it, success] = eventStore().particlesFinal.insert(particle); + auto particleIt = eventStore().particlesInitial.find(barcode); + if (particleIt == eventStore().particlesInitial.end()) { + ACTS_WARNING("Particle ID " << barcode + << " not found in initial particles"); + return; + } + SimParticle particle = *particleIt; + particle.final() = convert(*aTrack, barcode); + + auto [it, success] = eventStore().particlesSimulated.insert(particle); if (!success) { eventStore().particleIdCollisionsFinal++; @@ -98,7 +107,7 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( } } -ActsExamples::SimParticle ActsExamples::ParticleTrackingAction::convert( +ActsExamples::SimParticleState ActsExamples::ParticleTrackingAction::convert( const G4Track& aTrack, SimBarcode particleId) const { // Unit conversions G4->::ACTS constexpr double convertTime = Acts::UnitConstants::ns / CLHEP::ns; @@ -129,8 +138,7 @@ ActsExamples::SimParticle ActsExamples::ParticleTrackingAction::convert( } // Now create the Particle - ActsExamples::SimParticle aParticle(particleId, Acts::PdgParticle{pdg}, - charge, mass); + SimParticleState aParticle(particleId, Acts::PdgParticle{pdg}, charge, mass); aParticle.setPosition4(pPosition[0], pPosition[1], pPosition[2], pTime); aParticle.setDirection(pDirection[0], pDirection[1], pDirection[2]); aParticle.setAbsoluteMomentum(p); diff --git a/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp b/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp index 0543a62119b..8b8156ff3e4 100644 --- a/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp +++ b/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp @@ -10,16 +10,12 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Units.hpp" -#include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/DataHandle.hpp" #include "ActsExamples/Framework/WhiteBoard.hpp" #include "ActsExamples/Geant4/EventStore.hpp" -#include "ActsFatras/EventData/Barcode.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include -#include #include #include diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp index 5e7e2af3f9a..a11d62c928f 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/EventGenerator.cpp @@ -80,7 +80,9 @@ ActsExamples::ProcessCode ActsExamples::EventGenerator::read( const auto pos4 = (vertexPosition + particle.fourPosition()).eval(); ACTS_VERBOSE(" - particle at " << pos4.transpose()); // `withParticleId` returns a copy because it changes the identity - particle = particle.withParticleId(pid).setPosition4(pos4); + particle = particle.withParticleId(pid); + particle.initial().setPosition4(pos4); + particle.final().setPosition4(pos4); }; for (auto& vertexParticle : newParticles) { updateParticleInPlace(vertexParticle); diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.cpp b/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.cpp index 240669274b0..34363410f42 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.cpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.cpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/ParticleData.hpp" #include "Acts/Utilities/AngleHelpers.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsFatras/EventData/Barcode.hpp" #include "ActsFatras/EventData/Particle.hpp" @@ -115,12 +116,12 @@ ParametricParticleGenerator::operator()(RandomEngine& rng) { const double p = someP * (m_cfg.pTransverse ? 1. / sinTheta : 1.); // construct the particle; - ActsFatras::Particle particle(pid, pdg, q, m_mass); + SimParticleState particle(pid, pdg, q, m_mass); particle.setDirection(dir); particle.setAbsoluteMomentum(p); // generated particle ids are already ordered and should end up at the end - particles.insert(particles.end(), std::move(particle)); + particles.insert(particles.end(), SimParticle(particle, particle)); } std::pair out; diff --git a/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp b/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp index ae7c2b85403..cd80d64bf08 100644 --- a/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp +++ b/Examples/Algorithms/GeneratorsPythia8/ActsExamples/Generators/Pythia8ProcessGenerator.cpp @@ -141,9 +141,8 @@ Pythia8Generator::operator()(RandomEngine& rng) { } // production vertex. Pythia8 time uses units mm/c, and we use c=1 - SimParticle::Vector4 pos4( - genParticle.xProd() * 1_mm, genParticle.yProd() * 1_mm, - genParticle.zProd() * 1_mm, genParticle.tProd() * 1_mm); + Acts::Vector4 pos4(genParticle.xProd() * 1_mm, genParticle.yProd() * 1_mm, + genParticle.zProd() * 1_mm, genParticle.tProd() * 1_mm); // define the particle identifier including possible secondary vertices @@ -181,7 +180,7 @@ Pythia8Generator::operator()(RandomEngine& rng) { const auto pdg = static_cast(genParticle.id()); const auto charge = genParticle.charge() * 1_e; const auto mass = genParticle.m0() * 1_GeV; - ActsFatras::Particle particle(particleId, pdg, charge, mass); + SimParticleState particle(particleId, pdg, charge, mass); particle.setPosition4(pos4); // normalization/ units are not import for the direction particle.setDirection(genParticle.px(), genParticle.py(), genParticle.pz()); @@ -189,7 +188,7 @@ Pythia8Generator::operator()(RandomEngine& rng) { Acts::fastHypot(genParticle.px(), genParticle.py(), genParticle.pz()) * 1_GeV); - particles.push_back(std::move(particle)); + particles.push_back(SimParticle(particle, particle)); } std::pair out; diff --git a/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp b/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp index eae5c98bfb4..6cc00f77430 100644 --- a/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp +++ b/Examples/Algorithms/HepMC/src/HepMCProcessExtractor.cpp @@ -18,6 +18,8 @@ #include #include +namespace ActsExamples { + namespace { /// @brief This method searches for an outgoing particle from a vertex @@ -47,7 +49,7 @@ HepMC3::ConstGenParticlePtr searchProcessParticleById( /// @param [in] id The track ID /// @param [in, out] particle The particle that get the passed material attached void setPassedMaterial(const HepMC3::ConstGenVertexPtr& vertex, const int id, - ActsExamples::SimParticle& particle) { + SimParticle& particle) { double x0 = 0.; double l0 = 0.; HepMC3::ConstGenParticlePtr currentParticle = nullptr; @@ -74,7 +76,7 @@ void setPassedMaterial(const HepMC3::ConstGenVertexPtr& vertex, const int id, currentVertex = currentParticle->production_vertex(); } // Assign the passed material to the particle - particle.setMaterialPassed(x0, l0); + particle.final().setMaterialPassed(x0, l0); } /// @brief This function collects outgoing particles from a vertex while keeping @@ -84,9 +86,9 @@ void setPassedMaterial(const HepMC3::ConstGenVertexPtr& vertex, const int id, /// @param [in] trackID The track ID of the ingoing particle /// /// @return Vector containing the outgoing particles from a vertex -std::vector selectOutgoingParticles( +std::vector selectOutgoingParticles( const HepMC3::ConstGenVertexPtr& vertex, const int trackID) { - std::vector finalStateParticles; + std::vector finalStateParticles; // Identify the ingoing particle in the outgoing particles HepMC3::ConstGenParticlePtr procPart = @@ -99,8 +101,7 @@ std::vector selectOutgoingParticles( std::to_string(trackID)) ->value() != "Death") { // Store the particle if it survives - finalStateParticles.push_back( - ActsExamples::HepMC3Particle::particle(procPart)); + finalStateParticles.push_back(HepMC3Particle::particle(procPart)); } else { // Store the leftovers if it dies for (const HepMC3::ConstGenParticlePtr& procPartOut : @@ -110,8 +111,7 @@ std::vector selectOutgoingParticles( procPartOut->end_vertex()) { for (const HepMC3::ConstGenParticlePtr& dyingPartOut : procPartOut->end_vertex()->particles_out()) { - finalStateParticles.push_back( - ActsExamples::HepMC3Particle::particle(dyingPartOut)); + finalStateParticles.push_back(HepMC3Particle::particle(dyingPartOut)); } } } @@ -132,14 +132,14 @@ std::vector selectOutgoingParticles( auto pid = static_cast(genParticle->pid()); // Build an Acts particle out of the data - ActsExamples::SimParticle simParticle(barcode, pid); + SimParticleState simParticle(barcode, pid); simParticle.setPosition4(pos4.x(), pos4.y(), pos4.z(), pos4.t()); Acts::Vector3 mom3(mom4[0], mom4[1], mom4[2]); simParticle.setDirection(mom3.normalized()); simParticle.setAbsoluteMomentum(mom3.norm()); // Store the particle - finalStateParticles.push_back(simParticle); + finalStateParticles.push_back(SimParticle(simParticle, simParticle)); } } @@ -150,9 +150,8 @@ std::vector selectOutgoingParticles( /// /// @param [in] cfg Configuration of the filtering /// @param [in, out] interactions The recorded interactions -void filterAndSort( - const ActsExamples::HepMCProcessExtractor::Config& cfg, - ActsExamples::ExtractedSimulationProcessContainer& interactions) { +void filterAndSort(const HepMCProcessExtractor::Config& cfg, + ExtractedSimulationProcessContainer& interactions) { for (auto& interaction : interactions) { for (auto cit = interaction.after.cbegin(); cit != interaction.after.cend();) { @@ -172,15 +171,14 @@ void filterAndSort( [](const auto& a) { return a.absoluteMomentum(); }); } } + } // namespace -ActsExamples::HepMCProcessExtractor::~HepMCProcessExtractor() = default; +HepMCProcessExtractor::~HepMCProcessExtractor() = default; -ActsExamples::HepMCProcessExtractor::HepMCProcessExtractor( - ActsExamples::HepMCProcessExtractor::Config config, - Acts::Logging::Level level) - : ActsExamples::IAlgorithm("HepMCProcessExtractor", level), - m_cfg(std::move(config)) { +HepMCProcessExtractor::HepMCProcessExtractor( + HepMCProcessExtractor::Config config, Acts::Logging::Level level) + : IAlgorithm("HepMCProcessExtractor", level), m_cfg(std::move(config)) { if (m_cfg.inputEvents.empty()) { throw std::invalid_argument("Missing input event collection"); } @@ -195,12 +193,12 @@ ActsExamples::HepMCProcessExtractor::HepMCProcessExtractor( m_outputSimulationProcesses.initialize(m_cfg.outputSimulationProcesses); } -ActsExamples::ProcessCode ActsExamples::HepMCProcessExtractor::execute( - const ActsExamples::AlgorithmContext& context) const { +ProcessCode HepMCProcessExtractor::execute( + const AlgorithmContext& context) const { // Retrieve the initial particles const auto events = m_inputEvents(context); - ActsExamples::ExtractedSimulationProcessContainer fractions; + ExtractedSimulationProcessContainer fractions; for (const HepMC3::GenEvent& event : events) { // Fast exit if (event.particles().empty() || event.vertices().empty()) { @@ -209,12 +207,11 @@ ActsExamples::ProcessCode ActsExamples::HepMCProcessExtractor::execute( // Get the initial particle HepMC3::ConstGenParticlePtr initialParticle = event.particles()[0]; - ActsExamples::SimParticle simParticle = - HepMC3Particle::particle(initialParticle); + SimParticle simParticle = HepMC3Particle::particle(initialParticle); // Get the final state particles - ActsExamples::SimParticle particleToInteraction; - std::vector finalStateParticles; + SimParticle particleToInteraction; + std::vector finalStateParticles; // Search the process vertex bool vertexFound = false; for (const auto& vertex : event.vertices()) { @@ -238,7 +235,7 @@ ActsExamples::ProcessCode ActsExamples::HepMCProcessExtractor::execute( break; } } - fractions.push_back(ActsExamples::ExtractedSimulationProcess{ + fractions.push_back(ExtractedSimulationProcess{ simParticle, particleToInteraction, finalStateParticles}); } @@ -250,5 +247,7 @@ ActsExamples::ProcessCode ActsExamples::HepMCProcessExtractor::execute( // Write the recorded material to the event store m_outputSimulationProcesses(context, std::move(fractions)); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp b/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp index a03cc280043..3f0e9de0d7b 100644 --- a/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp +++ b/Examples/Algorithms/Printers/ActsExamples/Printers/ParticlesPrinter.cpp @@ -12,12 +12,10 @@ #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include "ActsFatras/EventData/ProcessType.hpp" #include #include -#include ActsExamples::ParticlesPrinter::ParticlesPrinter(const Config& cfg, Acts::Logging::Level lvl) diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp index 5fa3ee0e4b2..738399a1e42 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.cpp @@ -10,11 +10,8 @@ #include "Acts/Definitions/Common.hpp" #include "Acts/Utilities/VectorHelpers.hpp" -#include "ActsExamples/EventData/GeometryContainers.hpp" -#include "ActsExamples/EventData/IndexSourceLink.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -29,16 +26,9 @@ ActsExamples::ParticleSelector::ParticleSelector(const Config& config, if (m_cfg.outputParticles.empty()) { throw std::invalid_argument("Missing output particles collection"); } - if (!m_cfg.outputParticlesFinal.empty() && - m_cfg.inputParticlesFinal.empty()) { - throw std::invalid_argument( - "Output final particles collection requires input final particles"); - } m_inputParticles.initialize(m_cfg.inputParticles); - m_inputParticlesFinal.maybeInitialize(m_cfg.inputParticlesFinal); m_outputParticles.initialize(m_cfg.outputParticles); - m_outputParticlesFinal.maybeInitialize(m_cfg.outputParticlesFinal); ACTS_DEBUG("selection particle rho [" << m_cfg.rhoMin << "," << m_cfg.rhoMax << ")"); @@ -65,9 +55,6 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute( const AlgorithmContext& ctx) const { // prepare input/ output types const SimParticleContainer& inputParticles = m_inputParticles(ctx); - const SimParticleContainer& inputParticlesFinal = - (m_inputParticlesFinal.isInitialized()) ? m_inputParticlesFinal(ctx) - : inputParticles; std::size_t nInvalidCharge = 0; std::size_t nInvalidMeasurementCount = 0; @@ -77,7 +64,7 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute( return (min <= x) && (x < max); }; - auto isValidParticle = [&](const ActsFatras::Particle& p) { + auto isValidParticle = [&](const SimParticle& 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()); @@ -89,15 +76,8 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute( nInvalidCharge += static_cast(!validCharge); - bool validMeasurementCount = true; - if (auto finalParticleIt = inputParticlesFinal.find(p.particleId()); - finalParticleIt != inputParticlesFinal.end()) { - validMeasurementCount = - within(finalParticleIt->numberOfHits(), m_cfg.measurementsMin, - m_cfg.measurementsMax); - } else { - ACTS_WARNING("No final particle found for " << p.particleId()); - } + bool validMeasurementCount = + within(p.numberOfHits(), m_cfg.measurementsMin, m_cfg.measurementsMax); nInvalidMeasurementCount += static_cast(!validMeasurementCount); @@ -126,11 +106,6 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute( SimParticleContainer outputParticles; outputParticles.reserve(inputParticles.size()); - SimParticleContainer outputParticlesFinal; - if (m_outputParticlesFinal.isInitialized()) { - outputParticlesFinal.reserve(inputParticles.size()); - } - // copy selected particles for (const auto& inputParticle : inputParticles) { if (!isValidParticle(inputParticle)) { @@ -138,18 +113,8 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute( } outputParticles.insert(outputParticles.end(), inputParticle); - - if (m_outputParticlesFinal.isInitialized()) { - if (auto particleFinalIt = - inputParticlesFinal.find(inputParticle.particleId()); - particleFinalIt != inputParticlesFinal.end()) { - outputParticlesFinal.insert(outputParticlesFinal.end(), - *particleFinalIt); - } - } } outputParticles.shrink_to_fit(); - outputParticlesFinal.shrink_to_fit(); ACTS_DEBUG("event " << ctx.eventNumber << " selected " << outputParticles.size() << " from " @@ -159,9 +124,6 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute( << nInvalidMeasurementCount); m_outputParticles(ctx, std::move(outputParticles)); - if (m_outputParticlesFinal.isInitialized()) { - m_outputParticlesFinal(ctx, std::move(outputParticlesFinal)); - } return ProcessCode::SUCCESS; } diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.hpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.hpp index de05bf621ca..78326844f19 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.hpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.hpp @@ -8,10 +8,7 @@ #pragma once -#include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/EventData/Index.hpp" -#include "ActsExamples/EventData/Measurement.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/DataHandle.hpp" #include "ActsExamples/Framework/IAlgorithm.hpp" @@ -29,13 +26,8 @@ class ParticleSelector final : public IAlgorithm { struct Config { /// The input particles collection. std::string inputParticles; - /// Optional. The input final state particles collection. - /// If provided, this will be used to access the number of measurements. - std::string inputParticlesFinal; /// The output particles collection. std::string outputParticles; - /// Optional. The output final state particles collection. - std::string outputParticlesFinal; // Minimum/maximum distance from the origin in the transverse plane. double rhoMin = 0; @@ -83,13 +75,9 @@ class ParticleSelector final : public IAlgorithm { Config m_cfg; ReadDataHandle m_inputParticles{this, "InputParticles"}; - ReadDataHandle m_inputParticlesFinal{ - this, "InputParticlesFinal"}; WriteDataHandle m_outputParticles{this, "OutputParticles"}; - WriteDataHandle m_outputParticlesFinal{ - this, "OutputParticlesFinal"}; }; } // namespace ActsExamples diff --git a/Examples/Framework/CMakeLists.txt b/Examples/Framework/CMakeLists.txt index db45cffc925..032627e0b89 100644 --- a/Examples/Framework/CMakeLists.txt +++ b/Examples/Framework/CMakeLists.txt @@ -8,6 +8,7 @@ add_library( src/EventData/Measurement.cpp src/EventData/MeasurementCalibration.cpp src/EventData/ScalingCalibrator.cpp + src/EventData/SimParticle.cpp src/Framework/IAlgorithm.cpp src/Framework/SequenceElement.cpp src/Framework/WhiteBoard.cpp diff --git a/Examples/Framework/include/ActsExamples/EventData/SimParticle.hpp b/Examples/Framework/include/ActsExamples/EventData/SimParticle.hpp index a557ea94646..cfcf8a5e25e 100644 --- a/Examples/Framework/include/ActsExamples/EventData/SimParticle.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/SimParticle.hpp @@ -10,47 +10,221 @@ #include "ActsExamples/Utilities/GroupBy.hpp" #include "ActsFatras/EventData/Particle.hpp" +#include "ActsFatras/EventData/ParticleOutcome.hpp" #include namespace ActsExamples { + +using SimBarcode = ::ActsFatras::Barcode; +using SimBarcodeContainer = ::boost::container::flat_set; + +using SimParticleState = ::ActsFatras::Particle; + +class SimParticle final { + public: + using Scalar = Acts::ActsScalar; + using Vector3 = Acts::ActsVector<3>; + using Vector4 = Acts::ActsVector<4>; + + /// Construct a default particle with invalid identity. + SimParticle() = default; + + /// Construct a particle at rest with explicit mass and charge. + /// + /// @param particleId Particle identifier within an event + /// @param pdg PDG id + /// @param charge Particle charge in native units + /// @param mass Particle mass in native units + /// + /// @warning It is the users responsibility that charge and mass match + /// the PDG particle number. + SimParticle(SimBarcode particleId, Acts::PdgParticle pdg, Scalar charge, + Scalar mass) + : m_initial(particleId, pdg, charge, mass), + m_final(particleId, pdg, charge, mass) {} + + /// Construct a particle at rest from a PDG particle number. + /// + /// @param particleId Particle identifier within an event + /// @param pdg PDG particle number + /// + /// Charge and mass are retrieved from the particle data table. + SimParticle(SimBarcode particleId, Acts::PdgParticle pdg) + : m_initial(particleId, pdg), m_final(particleId, pdg) {} + + SimParticle(const SimParticleState& initial, const SimParticleState& final) + : m_initial(initial), m_final(final) { + if (m_initial.particleId() != m_final.particleId()) { + throw std::invalid_argument("Particle id mismatch"); + } + } + + const SimParticleState& initial() const { return m_initial; } + const SimParticleState& final() const { return m_final; } + + SimParticleState& initial() { return m_initial; } + SimParticleState& final() { return m_final; } + + /// Construct a new particle with a new identifier but same kinematics. + /// + /// @note This is intentionally not a regular setter. The particle id + /// is used to identify the whole particle. Setting it on an existing + /// particle is usually a mistake. + SimParticle withParticleId(SimBarcode particleId) const { + return SimParticle(initial().withParticleId(particleId), + final().withParticleId(particleId)); + } + + /// Set the process type that generated this particle. + SimParticle& setProcess(ActsFatras::ProcessType proc) { + initial().setProcess(proc); + final().setProcess(proc); + return *this; + } + /// Set the pdg. + SimParticle& setPdg(Acts::PdgParticle pdg) { + initial().setPdg(pdg); + final().setPdg(pdg); + return *this; + } + /// Set the charge. + SimParticle& setCharge(Scalar charge) { + initial().setCharge(charge); + final().setCharge(charge); + return *this; + } + /// Set the mass. + SimParticle& setMass(Scalar mass) { + initial().setMass(mass); + final().setMass(mass); + return *this; + } + /// Set the particle ID. + SimParticle& setParticleId(SimBarcode barcode) { + initial().setParticleId(barcode); + final().setParticleId(barcode); + return *this; + } + + /// Particle identifier within an event. + SimBarcode particleId() const { return initial().particleId(); } + /// Which type of process generated this particle. + ActsFatras::ProcessType process() const { return initial().process(); } + /// PDG particle number that identifies the type. + Acts::PdgParticle pdg() const { return initial().pdg(); } + /// Absolute PDG particle number that identifies the type. + Acts::PdgParticle absolutePdg() const { return initial().absolutePdg(); } + /// Particle charge. + double charge() const { return initial().charge(); } + /// Particle absolute charge. + double absoluteCharge() const { return initial().absoluteCharge(); } + /// Particle mass. + double mass() const { return initial().mass(); } + + /// Check if this is a secondary particle. + bool isSecondary() const { return initial().isSecondary(); } + + /// Particle hypothesis. + Acts::ParticleHypothesis hypothesis() const { return initial().hypothesis(); } + /// Particl qOverP. + double qOverP() const { return initial().qOverP(); } + + /// Space-time position four-vector. + const Acts::Vector4& fourPosition() const { return initial().fourPosition(); } + /// Three-position, i.e. spatial coordinates without the time. + auto position() const { return initial().position(); } + /// Time coordinate. + double time() const { return initial().time(); } + /// Energy-momentum four-vector. + Acts::Vector4 fourMomentum() const { return initial().fourMomentum(); } + /// Unit three-direction, i.e. the normalized momentum three-vector. + const Acts::Vector3& direction() const { return initial().direction(); } + /// Polar angle. + double theta() const { return initial().theta(); } + /// Azimuthal angle. + double phi() const { return initial().phi(); } + /// Absolute momentum in the x-y plane. + double transverseMomentum() const { return initial().transverseMomentum(); } + /// Absolute momentum. + double absoluteMomentum() const { return initial().absoluteMomentum(); } + /// Absolute momentum. + Acts::Vector3 momentum() const { return initial().momentum(); } + /// Total energy, i.e. norm of the four-momentum. + double energy() const { return initial().energy(); } + + /// Energy loss over the particles lifetime or simulation time. + double energyLoss() const { return initial().energy() - final().energy(); } + + /// Accumulated path within material measured in radiation lengths. + double pathInX0() const { return final().pathInX0(); } + /// Accumulated path within material measured in interaction lengths. + double pathInL0() const { return final().pathInL0(); } + + /// Number of hits. + std::uint32_t numberOfHits() const { return final().numberOfHits(); } + + /// Particle outcome. + ActsFatras::ParticleOutcome outcome() const { return final().outcome(); } + + private: + SimParticleState m_initial; + SimParticleState m_final; +}; + +std::ostream& operator<<(std::ostream& os, const SimParticle& particle); + namespace detail { struct CompareParticleId { using is_transparent = void; - constexpr bool operator()(const ActsFatras::Particle& lhs, - const ActsFatras::Particle& rhs) const { + bool operator()(const SimParticleState& lhs, + const SimParticleState& rhs) const { return lhs.particleId() < rhs.particleId(); } - constexpr bool operator()(ActsFatras::Barcode lhs, - const ActsFatras::Particle& rhs) const { + bool operator()(const SimParticle& lhs, const SimParticle& rhs) const { + return lhs.particleId() < rhs.particleId(); + } + bool operator()(SimBarcode lhs, const SimParticleState& rhs) const { return lhs < rhs.particleId(); } - constexpr bool operator()(const ActsFatras::Particle& lhs, - ActsFatras::Barcode rhs) const { + bool operator()(SimBarcode lhs, const SimParticle& rhs) const { + return lhs < rhs.particleId(); + } + bool operator()(const SimParticleState& lhs, SimBarcode rhs) const { + return lhs.particleId() < rhs; + } + bool operator()(const SimParticle& lhs, SimBarcode rhs) const { return lhs.particleId() < rhs; } }; struct PrimaryVertexIdGetter { - constexpr ActsFatras::Barcode operator()( - const ActsFatras::Particle& particle) const { - return ActsFatras::Barcode(0u).setVertexPrimary( + SimBarcode operator()(const SimParticleState& particle) const { + return SimBarcode(0u).setVertexPrimary( + particle.particleId().vertexPrimary()); + } + SimBarcode operator()(const SimParticle& particle) const { + return SimBarcode(0u).setVertexPrimary( particle.particleId().vertexPrimary()); } }; struct SecondaryVertexIdGetter { - constexpr ActsFatras::Barcode operator()( - const ActsFatras::Particle& particle) const { - return ActsFatras::Barcode(0u) + SimBarcode operator()(const SimParticleState& particle) const { + return SimBarcode(0u) + .setVertexPrimary(particle.particleId().vertexPrimary()) + .setVertexSecondary(particle.particleId().vertexSecondary()); + } + SimBarcode operator()(const SimParticle& particle) const { + return SimBarcode(0u) .setVertexPrimary(particle.particleId().vertexPrimary()) .setVertexSecondary(particle.particleId().vertexSecondary()); } }; } // namespace detail -using SimBarcode = ::ActsFatras::Barcode; -using SimParticle = ::ActsFatras::Particle; +using SimParticleStateContainer = + ::boost::container::flat_set; + /// Store particles ordered by particle identifier. -using SimBarcodeContainer = ::boost::container::flat_set; using SimParticleContainer = ::boost::container::flat_set; diff --git a/Examples/Framework/include/ActsExamples/Validation/DuplicationPlotTool.hpp b/Examples/Framework/include/ActsExamples/Validation/DuplicationPlotTool.hpp index 55fbf056015..86b96539f3c 100644 --- a/Examples/Framework/include/ActsExamples/Validation/DuplicationPlotTool.hpp +++ b/Examples/Framework/include/ActsExamples/Validation/DuplicationPlotTool.hpp @@ -10,8 +10,8 @@ #include "Acts/EventData/TrackParameters.hpp" #include "Acts/Utilities/Logger.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Utilities/Helpers.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -80,7 +80,7 @@ class DuplicationPlotTool { /// @param truthParticle the truth Particle /// @param nDuplicatedTracks the number of duplicated tracks void fill(DuplicationPlotCache& duplicationPlotCache, - const ActsFatras::Particle& truthParticle, + const SimParticleState& truthParticle, std::size_t nDuplicatedTracks) const; /// @brief write the duplication plots to file diff --git a/Examples/Framework/include/ActsExamples/Validation/EffPlotTool.hpp b/Examples/Framework/include/ActsExamples/Validation/EffPlotTool.hpp index 7ac49098a0a..d6fcd57bad3 100644 --- a/Examples/Framework/include/ActsExamples/Validation/EffPlotTool.hpp +++ b/Examples/Framework/include/ActsExamples/Validation/EffPlotTool.hpp @@ -9,8 +9,8 @@ #pragma once #include "Acts/Utilities/Logger.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Utilities/Helpers.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -66,9 +66,8 @@ class EffPlotTool { /// @param truthParticle the truth Particle /// @param deltaR the distance to the closest truth particle /// @param status the reconstruction status - void fill(EffPlotCache& effPlotCache, - const ActsFatras::Particle& truthParticle, double deltaR, - bool status) const; + void fill(EffPlotCache& effPlotCache, const SimParticleState& truthParticle, + double deltaR, bool status) const; /// @brief write the efficiency plots to file /// diff --git a/Examples/Framework/include/ActsExamples/Validation/FakeRatePlotTool.hpp b/Examples/Framework/include/ActsExamples/Validation/FakeRatePlotTool.hpp index 13b4b4fd86f..988e9f2ec41 100644 --- a/Examples/Framework/include/ActsExamples/Validation/FakeRatePlotTool.hpp +++ b/Examples/Framework/include/ActsExamples/Validation/FakeRatePlotTool.hpp @@ -10,8 +10,8 @@ #include "Acts/EventData/TrackParameters.hpp" #include "Acts/Utilities/Logger.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Utilities/Helpers.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -86,7 +86,7 @@ class FakeRatePlotTool { /// @param nTruthMatchedTracks the number of truth-Matched tracks /// @param nFakeTracks the number of fake tracks void fill(FakeRatePlotCache& fakeRatePlotCache, - const ActsFatras::Particle& truthParticle, + const SimParticleState& truthParticle, std::size_t nTruthMatchedTracks, std::size_t nFakeTracks) const; /// @brief write the fake rate plots to file diff --git a/Examples/Framework/include/ActsExamples/Validation/ResPlotTool.hpp b/Examples/Framework/include/ActsExamples/Validation/ResPlotTool.hpp index 5eeddb7ed8c..1f1bb6ea85f 100644 --- a/Examples/Framework/include/ActsExamples/Validation/ResPlotTool.hpp +++ b/Examples/Framework/include/ActsExamples/Validation/ResPlotTool.hpp @@ -11,8 +11,8 @@ #include "Acts/EventData/TrackParameters.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Utilities/Logger.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Utilities/Helpers.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -100,7 +100,7 @@ class ResPlotTool { /// @param truthParticle the truth particle /// @param fittedParamters the fitted parameters at perigee surface void fill(ResPlotCache& resPlotCache, const Acts::GeometryContext& gctx, - const ActsFatras::Particle& truthParticle, + const SimParticleState& truthParticle, const Acts::BoundTrackParameters& fittedParamters) const; /// @brief extract the details of the residual/pull plots and fill details diff --git a/Examples/Framework/src/EventData/SimParticle.cpp b/Examples/Framework/src/EventData/SimParticle.cpp new file mode 100644 index 00000000000..900d55f1018 --- /dev/null +++ b/Examples/Framework/src/EventData/SimParticle.cpp @@ -0,0 +1,21 @@ +// 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/EventData/SimParticle.hpp" + +std::ostream& ActsExamples::operator<<(std::ostream& os, + const SimParticle& particle) { + // compact format w/ only identity information but no kinematics + os << "id=" << particle.particleId().value() << "(" << particle.particleId() + << ")"; + os << "|pdg=" << particle.pdg(); + os << "|q=" << particle.charge(); + os << "|m=" << particle.mass(); + os << "|p=" << particle.absoluteMomentum(); + return os; +} diff --git a/Examples/Framework/src/Validation/DuplicationPlotTool.cpp b/Examples/Framework/src/Validation/DuplicationPlotTool.cpp index b200957e0c0..8b6aaca0925 100644 --- a/Examples/Framework/src/Validation/DuplicationPlotTool.cpp +++ b/Examples/Framework/src/Validation/DuplicationPlotTool.cpp @@ -8,9 +8,8 @@ #include "ActsExamples/Validation/DuplicationPlotTool.hpp" -#include "Acts/Definitions/Algebra.hpp" #include "Acts/Utilities/VectorHelpers.hpp" -#include "ActsFatras/EventData/Particle.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include #include @@ -98,7 +97,7 @@ void ActsExamples::DuplicationPlotTool::fill( void ActsExamples::DuplicationPlotTool::fill( DuplicationPlotTool::DuplicationPlotCache& duplicationPlotCache, - const ActsFatras::Particle& truthParticle, + const SimParticleState& truthParticle, std::size_t nDuplicatedTracks) const { const auto t_phi = phi(truthParticle.direction()); const auto t_eta = eta(truthParticle.direction()); diff --git a/Examples/Framework/src/Validation/EffPlotTool.cpp b/Examples/Framework/src/Validation/EffPlotTool.cpp index eb92cfa7b63..17e3bb7034e 100644 --- a/Examples/Framework/src/Validation/EffPlotTool.cpp +++ b/Examples/Framework/src/Validation/EffPlotTool.cpp @@ -9,7 +9,7 @@ #include "ActsExamples/Validation/EffPlotTool.hpp" #include "Acts/Utilities/VectorHelpers.hpp" -#include "ActsFatras/EventData/Particle.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include @@ -66,7 +66,7 @@ void ActsExamples::EffPlotTool::write( } void ActsExamples::EffPlotTool::fill(EffPlotTool::EffPlotCache& effPlotCache, - const ActsFatras::Particle& truthParticle, + const SimParticleState& truthParticle, double deltaR, bool status) const { const auto t_phi = phi(truthParticle.direction()); const auto t_eta = eta(truthParticle.direction()); diff --git a/Examples/Framework/src/Validation/FakeRatePlotTool.cpp b/Examples/Framework/src/Validation/FakeRatePlotTool.cpp index 9b37bc673fe..af23d225d56 100644 --- a/Examples/Framework/src/Validation/FakeRatePlotTool.cpp +++ b/Examples/Framework/src/Validation/FakeRatePlotTool.cpp @@ -8,9 +8,8 @@ #include "ActsExamples/Validation/FakeRatePlotTool.hpp" -#include "Acts/Definitions/Algebra.hpp" #include "Acts/Utilities/VectorHelpers.hpp" -#include "ActsFatras/EventData/Particle.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include #include @@ -109,7 +108,7 @@ void ActsExamples::FakeRatePlotTool::fill( void ActsExamples::FakeRatePlotTool::fill( FakeRatePlotTool::FakeRatePlotCache& fakeRatePlotCache, - const ActsFatras::Particle& truthParticle, std::size_t nTruthMatchedTracks, + const SimParticleState& truthParticle, std::size_t nTruthMatchedTracks, std::size_t nFakeTracks) const { const auto t_eta = eta(truthParticle.direction()); const auto t_pT = truthParticle.transverseMomentum(); diff --git a/Examples/Framework/src/Validation/ResPlotTool.cpp b/Examples/Framework/src/Validation/ResPlotTool.cpp index c1e3e4a6c1b..882e1e41fb7 100644 --- a/Examples/Framework/src/Validation/ResPlotTool.cpp +++ b/Examples/Framework/src/Validation/ResPlotTool.cpp @@ -10,11 +10,9 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Result.hpp" -#include "ActsFatras/EventData/Particle.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" -#include #include #include #include @@ -146,7 +144,7 @@ void ActsExamples::ResPlotTool::write( void ActsExamples::ResPlotTool::fill( ResPlotTool::ResPlotCache& resPlotCache, const Acts::GeometryContext& gctx, - const ActsFatras::Particle& truthParticle, + const SimParticleState& truthParticle, const Acts::BoundTrackParameters& fittedParamters) const { using ParametersVector = Acts::BoundTrackParameters::ParametersVector; using Acts::VectorHelpers::eta; diff --git a/Examples/Io/Csv/src/CsvParticleReader.cpp b/Examples/Io/Csv/src/CsvParticleReader.cpp index c738acc0fc4..de8d70c9014 100644 --- a/Examples/Io/Csv/src/CsvParticleReader.cpp +++ b/Examples/Io/Csv/src/CsvParticleReader.cpp @@ -63,10 +63,10 @@ ActsExamples::ProcessCode ActsExamples::CsvParticleReader::read( ParticleData data; while (reader.read(data)) { - ActsFatras::Particle particle(ActsFatras::Barcode(data.particle_id), - Acts::PdgParticle{data.particle_type}, - data.q * Acts::UnitConstants::e, - data.m * Acts::UnitConstants::GeV); + SimParticleState particle(ActsFatras::Barcode(data.particle_id), + Acts::PdgParticle{data.particle_type}, + data.q * Acts::UnitConstants::e, + data.m * Acts::UnitConstants::GeV); particle.setProcess(static_cast(data.process)); particle.setPosition4( data.vx * Acts::UnitConstants::mm, data.vy * Acts::UnitConstants::mm, @@ -75,7 +75,7 @@ ActsExamples::ProcessCode ActsExamples::CsvParticleReader::read( particle.setDirection(data.px, data.py, data.pz); particle.setAbsoluteMomentum(std::hypot(data.px, data.py, data.pz) * Acts::UnitConstants::GeV); - unordered.push_back(std::move(particle)); + unordered.push_back(SimParticle(particle, particle)); } // Write ordered particles container to the EventStore diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp index bfa87a6a7da..204f88ad83a 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepReader.hpp @@ -15,7 +15,6 @@ #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/DataHandle.hpp" #include "ActsExamples/Framework/IReader.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include @@ -44,13 +43,10 @@ class EDM4hepReader final : public IReader { std::string inputParticles = "MCParticles"; /// Names of the sim hit collections std::vector inputSimHits{}; - /// Particles at creation - std::string outputParticlesInitial; - /// Particles at their endpoints - std::string outputParticlesFinal; /// Particles from the generator std::string outputParticlesGenerator; - + /// Particles from the simulation + std::string outputParticlesSimulation; /// Output simulated (truth) hits collection. std::string outputSimHits; @@ -88,15 +84,14 @@ class EDM4hepReader final : public IReader { const Config& config() const { return m_cfg; } void processChildren(const edm4hep::MCParticle& particle, SimBarcode parentId, - SimParticleContainer::sequence_type& particles, + std::vector& particles, ParentRelationship& parentRelationship, std::unordered_map& particleMap, std::size_t& nSecondaryVertices, std::size_t& maxGen) const; - static void setSubParticleIds( - const SimParticleContainer::sequence_type::iterator& begin, - const SimParticleContainer::sequence_type::iterator& end); + static void setSubParticleIds(std::vector::iterator begin, + std::vector::iterator end); private: const Acts::Logger& logger() const { return *m_logger; } @@ -111,17 +106,14 @@ class EDM4hepReader final : public IReader { Acts::PodioUtil::ROOTReader& reader(); - WriteDataHandle m_outputParticlesInitial{ - this, "OutputParticlesInitial"}; - WriteDataHandle m_outputParticlesFinal{ - this, "OutputParticlesFinal"}; WriteDataHandle m_outputParticlesGenerator{ this, "OutputParticlesGenerator"}; + WriteDataHandle m_outputParticlesSimulation{ + this, "OutputParticlesSimulation"}; WriteDataHandle m_outputSimHits{this, "OutputSimHits"}; - void graphviz(std::ostream& os, - const SimParticleContainer::sequence_type& particles, + void graphviz(std::ostream& os, const std::vector& particles, const ParentRelationship& parents) const; }; diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp index 35d84acd043..bdce08bc876 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp @@ -10,9 +10,9 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "ActsExamples/EventData/Cluster.hpp" #include "ActsExamples/EventData/Measurement.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/EventData/Trajectories.hpp" #include "ActsFatras/EventData/Hit.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include @@ -20,7 +20,6 @@ #include "edm4hep/MutableMCParticle.h" #include "edm4hep/MutableSimTrackerHit.h" #include "edm4hep/MutableTrack.h" -#include "edm4hep/MutableTrackerHit.h" #include "edm4hep/MutableTrackerHitPlane.h" #include "edm4hep/SimTrackerHit.h" #include "edm4hep/TrackerHit.h" @@ -49,7 +48,7 @@ using MapGeometryIdTo = /// Inpersistent information: /// - particle ID /// - process -ActsFatras::Particle readParticle( +SimParticle readParticle( const edm4hep::MCParticle& from, const MapParticleIdFrom& particleMapper = zeroParticleMapper); @@ -58,8 +57,7 @@ ActsFatras::Particle readParticle( /// Inpersistent information: /// - particle ID /// - process -void writeParticle(const ActsFatras::Particle& from, - edm4hep::MutableMCParticle to); +void writeParticle(const SimParticle& from, edm4hep::MutableMCParticle to); /// Reads a Fatras hit from EDM4hep. /// diff --git a/Examples/Io/EDM4hep/src/EDM4hepParticleWriter.cpp b/Examples/Io/EDM4hep/src/EDM4hepParticleWriter.cpp index 9ffcb29e593..fc0806acb43 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepParticleWriter.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepParticleWriter.cpp @@ -8,10 +8,7 @@ #include "ActsExamples/Io/EDM4hep/EDM4hepParticleWriter.hpp" -#include "Acts/Definitions/Units.hpp" -#include "ActsExamples/Framework/WhiteBoard.hpp" #include "ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp" -#include "ActsExamples/Utilities/Paths.hpp" #include diff --git a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp index dfb11c84c9e..3d5008863a3 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp @@ -9,7 +9,6 @@ #include "ActsExamples/Io/EDM4hep/EDM4hepReader.hpp" #include "Acts/Definitions/Units.hpp" -#include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp" @@ -36,28 +35,22 @@ namespace ActsExamples { EDM4hepReader::EDM4hepReader(const Config& config, Acts::Logging::Level level) : m_cfg(config), m_logger(Acts::getDefaultLogger("EDM4hepParticleReader", level)) { - if (m_cfg.outputParticlesInitial.empty()) { - throw std::invalid_argument("Missing output collection initial particles"); - } - - if (m_cfg.outputParticlesFinal.empty()) { - throw std::invalid_argument("Missing output collection final particles"); - } - if (m_cfg.outputParticlesGenerator.empty()) { throw std::invalid_argument( "Missing output collection generator particles"); } - + if (m_cfg.outputParticlesSimulation.empty()) { + throw std::invalid_argument( + "Missing output collection simulated particles"); + } if (m_cfg.outputSimHits.empty()) { throw std::invalid_argument("Missing output collection sim hits"); } m_eventsRange = std::make_pair(0, reader().getEntries("events")); - m_outputParticlesInitial.initialize(m_cfg.outputParticlesInitial); - m_outputParticlesFinal.initialize(m_cfg.outputParticlesFinal); m_outputParticlesGenerator.initialize(m_cfg.outputParticlesGenerator); + m_outputParticlesSimulation.initialize(m_cfg.outputParticlesSimulation); m_outputSimHits.initialize(m_cfg.outputSimHits); m_cfg.trackingGeometry->visitSurfaces([&](const auto* surface) { @@ -119,9 +112,9 @@ std::string plabel(const SimParticle& particle) { } // namespace -void EDM4hepReader::graphviz( - std::ostream& os, const SimParticleContainer::sequence_type& particles, - const ParentRelationship& parents) const { +void EDM4hepReader::graphviz(std::ostream& os, + const std::vector& particles, + const ParentRelationship& parents) const { os << "digraph Event {\n"; std::set primaryVertices; @@ -164,7 +157,7 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { ACTS_DEBUG("Reading EDM4hep inputs"); - SimParticleContainer::sequence_type unordered; + std::vector unorderedParticlesInitial; // Read particles from the input file // Find particles without parents and group them by vtx position to find @@ -212,13 +205,14 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { std::size_t nParticles = 0; std::size_t nSecondaryVertices = 0; std::size_t maxGen = 0; - auto startSize = unordered.size(); + auto startSize = unorderedParticlesInitial.size(); for (const auto& inParticle : particles) { nParticles += 1; - SimParticle particle{EDM4hepUtil::readParticle(inParticle)}; - particle.setParticleId(SimBarcode{} - .setParticle(nParticles) - .setVertexPrimary(nPrimaryVertices)); + SimParticle particle = + EDM4hepUtil::readParticle(inParticle) + .withParticleId(SimBarcode{} + .setParticle(nParticles) + .setVertexPrimary(nPrimaryVertices)); ACTS_VERBOSE("+ add particle " << particle); ACTS_VERBOSE(" - at " << particle.position().transpose()); ACTS_VERBOSE(" - createdInSim: " << inParticle.isCreatedInSimulation()); @@ -229,24 +223,28 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { << inParticle.getEndpoint().y << ", " << inParticle.getEndpoint().z); const auto pid = particle.particleId(); - unordered.push_back(std::move(particle)); - edm4hepParticleMap[inParticle.getObjectID().index] = unordered.size() - 1; - processChildren(inParticle, pid, unordered, parentRelationship, - edm4hepParticleMap, nSecondaryVertices, maxGen); + unorderedParticlesInitial.push_back(std::move(particle)); + edm4hepParticleMap[inParticle.getObjectID().index] = + unorderedParticlesInitial.size() - 1; + processChildren(inParticle, pid, unorderedParticlesInitial, + parentRelationship, edm4hepParticleMap, + nSecondaryVertices, maxGen); } ACTS_VERBOSE("Primary vertex complete, produced " - << (unordered.size() - startSize) << " particles and " - << nSecondaryVertices << " secondary vertices in " << maxGen - << " generations"); - setSubParticleIds(std::next(unordered.begin(), startSize), unordered.end()); + << (unorderedParticlesInitial.size() - startSize) + << " particles and " << nSecondaryVertices + << " secondary vertices in " << maxGen << " generations"); + setSubParticleIds(std::next(unorderedParticlesInitial.begin(), startSize), + unorderedParticlesInitial.end()); } - ACTS_DEBUG("Found " << unordered.size() << " particles"); + ACTS_DEBUG("Found " << unorderedParticlesInitial.size() << " particles"); // @TODO: Order simhits by time - SimParticleContainer particlesFinal; SimParticleContainer particlesGenerator; + SimParticleContainer particlesSimulated; + for (const auto& inParticle : mcParticleCollection) { auto particleIt = edm4hepParticleMap.find(inParticle.getObjectID().index); if (particleIt == edm4hepParticleMap.end()) { @@ -255,11 +253,11 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { continue; } const std::size_t index = particleIt->second; - const auto& particleInitial = unordered.at(index); + const auto& particleInitial = unorderedParticlesInitial.at(index); if (!inParticle.isCreatedInSimulation()) { particlesGenerator.insert(particleInitial); } - SimParticle particleFinal = particleInitial; + SimParticle particleSimulated = particleInitial; float time = inParticle.getTime() * Acts::UnitConstants::ns; for (const auto& daughter : inParticle.getDaughters()) { @@ -269,7 +267,7 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { } } - particleFinal.setPosition4( + particleSimulated.final().setPosition4( inParticle.getEndpoint()[0] * Acts::UnitConstants::mm, inParticle.getEndpoint()[1] * Acts::UnitConstants::mm, inParticle.getEndpoint()[2] * Acts::UnitConstants::mm, time); @@ -277,28 +275,24 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { Acts::Vector3 momentumFinal = {inParticle.getMomentumAtEndpoint()[0], inParticle.getMomentumAtEndpoint()[1], inParticle.getMomentumAtEndpoint()[2]}; - particleFinal.setDirection(momentumFinal.normalized()); - particleFinal.setAbsoluteMomentum(momentumFinal.norm()); + particleSimulated.final().setDirection(momentumFinal.normalized()); + particleSimulated.final().setAbsoluteMomentum(momentumFinal.norm()); ACTS_VERBOSE("- Updated particle initial -> final, position: " << particleInitial.fourPosition().transpose() << " -> " - << particleFinal.fourPosition().transpose()); + << particleSimulated.final().fourPosition().transpose()); ACTS_VERBOSE(" momentum: " << particleInitial.fourMomentum().transpose() << " -> " - << particleFinal.fourMomentum().transpose()); + << particleSimulated.final().fourMomentum().transpose()); - particlesFinal.insert(particleFinal); + particlesSimulated.insert(particleSimulated); } - // Write ordered particles container to the EventStore - SimParticleContainer particlesInitial; - particlesInitial.insert(unordered.begin(), unordered.end()); - if (!m_cfg.graphvizOutput.empty()) { std::string path = perEventFilepath(m_cfg.graphvizOutput, "particles.dot", ctx.eventNumber); std::ofstream dot(path); - graphviz(dot, unordered, parentRelationship); + graphviz(dot, unorderedParticlesInitial, parentRelationship); } SimHitContainer simHits; @@ -320,7 +314,7 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { "SimHit has source particle that we did not see before"); return SimBarcode{}; } - const auto& particle = unordered.at(it->second); + const auto& particle = unorderedParticlesInitial.at(it->second); ACTS_VERBOSE("- " << inParticle.getObjectID().index << " -> " << particle.particleId()); return particle.particleId(); @@ -416,9 +410,8 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { } } - m_outputParticlesInitial(ctx, std::move(particlesInitial)); - m_outputParticlesFinal(ctx, std::move(particlesFinal)); m_outputParticlesGenerator(ctx, std::move(particlesGenerator)); + m_outputParticlesSimulation(ctx, std::move(particlesSimulated)); m_outputSimHits(ctx, std::move(simHits)); @@ -427,8 +420,7 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { void EDM4hepReader::processChildren( const edm4hep::MCParticle& inParticle, SimBarcode parentId, - SimParticleContainer::sequence_type& particles, - ParentRelationship& parentRelationship, + std::vector& particles, ParentRelationship& parentRelationship, std::unordered_map& particleMap, std::size_t& nSecondaryVertices, std::size_t& maxGen) const { constexpr auto indent = [&](std::size_t n) { @@ -500,9 +492,8 @@ void EDM4hepReader::processChildren( } } -void EDM4hepReader::setSubParticleIds( - const SimParticleContainer::sequence_type::iterator& begin, - const SimParticleContainer::sequence_type::iterator& end) { +void EDM4hepReader::setSubParticleIds(std::vector::iterator begin, + std::vector::iterator end) { std::vector numByGeneration; numByGeneration.reserve(10); diff --git a/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp b/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp index 09dcbc6331b..38e26038779 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp @@ -10,16 +10,12 @@ #include "Acts/Definitions/Common.hpp" #include "Acts/Definitions/Units.hpp" -#include "Acts/EventData/Charge.hpp" -#include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/MultiTrajectoryHelpers.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Plugins/EDM4hep/EDM4hepUtil.hpp" #include "ActsExamples/Digitization/MeasurementCreation.hpp" #include "ActsExamples/EventData/Index.hpp" -#include "ActsExamples/EventData/IndexSourceLink.hpp" #include "ActsExamples/EventData/Measurement.hpp" -#include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/Validation/TrackClassification.hpp" #include "edm4hep/TrackState.h" @@ -28,34 +24,33 @@ using namespace Acts::UnitLiterals; namespace ActsExamples { -ActsFatras::Particle EDM4hepUtil::readParticle( - const edm4hep::MCParticle& from, const MapParticleIdFrom& particleMapper) { +SimParticle EDM4hepUtil::readParticle(const edm4hep::MCParticle& from, + const MapParticleIdFrom& particleMapper) { ActsFatras::Barcode particleId = particleMapper(from); - ActsFatras::Particle to(particleId, - static_cast(from.getPDG()), - from.getCharge() * Acts::UnitConstants::e, - from.getMass() * Acts::UnitConstants::GeV); + SimParticle to(particleId, static_cast(from.getPDG()), + from.getCharge() * Acts::UnitConstants::e, + from.getMass() * Acts::UnitConstants::GeV); // TODO do we have that in EDM4hep? // particle.setProcess(static_cast(data.process)); - to.setPosition4(from.getVertex()[0] * Acts::UnitConstants::mm, - from.getVertex()[1] * Acts::UnitConstants::mm, - from.getVertex()[2] * Acts::UnitConstants::mm, - from.getTime() * Acts::UnitConstants::ns); + to.initial().setPosition4(from.getVertex()[0] * Acts::UnitConstants::mm, + from.getVertex()[1] * Acts::UnitConstants::mm, + from.getVertex()[2] * Acts::UnitConstants::mm, + from.getTime() * Acts::UnitConstants::ns); // Only used for direction; normalization/units do not matter Acts::Vector3 momentum = {from.getMomentum()[0], from.getMomentum()[1], from.getMomentum()[2]}; - to.setDirection(momentum.normalized()); + to.initial().setDirection(momentum.normalized()); - to.setAbsoluteMomentum(momentum.norm() * 1_GeV); + to.initial().setAbsoluteMomentum(momentum.norm() * 1_GeV); return to; } -void EDM4hepUtil::writeParticle(const ActsFatras::Particle& from, +void EDM4hepUtil::writeParticle(const SimParticle& from, edm4hep::MutableMCParticle to) { // TODO what about particleId? @@ -66,6 +61,10 @@ void EDM4hepUtil::writeParticle(const ActsFatras::Particle& from, to.setMomentum({static_cast(from.fourMomentum().x()), static_cast(from.fourMomentum().y()), static_cast(from.fourMomentum().z())}); + to.setMomentumAtEndpoint( + {static_cast(from.final().fourMomentum().x()), + static_cast(from.final().fourMomentum().y()), + static_cast(from.final().fourMomentum().z())}); } ActsFatras::Hit EDM4hepUtil::readSimHit( diff --git a/Examples/Io/HepMC3/src/HepMC3Particle.cpp b/Examples/Io/HepMC3/src/HepMC3Particle.cpp index 5d5625b5b2a..315c79dced1 100644 --- a/Examples/Io/HepMC3/src/HepMC3Particle.cpp +++ b/Examples/Io/HepMC3/src/HepMC3Particle.cpp @@ -9,6 +9,7 @@ #include "ActsExamples/Io/HepMC3/HepMC3Particle.hpp" #include "Acts/Definitions/ParticleData.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Io/HepMC3/HepMC3Vertex.hpp" namespace ActsExamples { @@ -23,12 +24,12 @@ SimParticle HepMC3Particle::particle( const HepMC3::ConstGenParticlePtr& particle) { SimBarcode particleId = barcode(particle); Acts::PdgParticle pdg = static_cast(particle->pid()); - SimParticle fw(particleId, pdg, Acts::findCharge(pdg).value_or(0), - particle->generated_mass()); + SimParticleState fw(particleId, pdg, Acts::findCharge(pdg).value_or(0), + particle->generated_mass()); fw.setDirection(particle->momentum().x(), particle->momentum().y(), particle->momentum().z()); fw.setAbsoluteMomentum(particle->momentum().p3mod()); - return fw; + return SimParticle(fw, fw); } int HepMC3Particle::id(const std::shared_ptr& particle) { diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleReader.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleReader.hpp index a58e84c1978..0bcd108570c 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleReader.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleReader.hpp @@ -114,6 +114,12 @@ class RootParticleReader : public IReader { std::vector* m_particle = new std::vector; std::vector* m_generation = new std::vector; std::vector* m_subParticle = new std::vector; + + std::vector* m_eLoss = new std::vector; + std::vector* m_pathInX0 = new std::vector; + std::vector* m_pathInL0 = new std::vector; + std::vector* m_numberOfHits = new std::vector; + std::vector* m_outcome = new std::vector; }; } // namespace ActsExamples diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleWriter.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleWriter.hpp index 8be9f05b735..670008c6631 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleWriter.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootParticleWriter.hpp @@ -37,9 +37,6 @@ class RootParticleWriter final : public WriterT { struct Config { /// Input particle collection to write. std::string inputParticles; - /// Optional. If given, the the energy loss and traversed material is - /// computed and written. - std::string inputParticlesFinal; /// Path to the output file. std::string filePath; /// Output file access mode. @@ -74,9 +71,6 @@ class RootParticleWriter final : public WriterT { private: Config m_cfg; - ReadDataHandle m_inputParticlesFinal{ - this, "InputParticlesFinal"}; - std::mutex m_writeMutex; TFile* m_outputFile = nullptr; @@ -119,7 +113,6 @@ class RootParticleWriter final : public WriterT { std::vector m_generation; std::vector m_subParticle; - // Optional information depending on input collections. /// Total energy loss in GeV. std::vector m_eLoss; /// Accumulated material diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootSimHitReader.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootSimHitReader.hpp index ade13f060a3..bf05678cd8f 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootSimHitReader.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootSimHitReader.hpp @@ -8,8 +8,6 @@ #pragma once -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Propagator/MaterialInteractor.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/Framework/DataHandle.hpp" @@ -18,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackSummaryReader.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackSummaryReader.hpp index 3ad5a7eda35..71ff807fb32 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackSummaryReader.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootTrackSummaryReader.hpp @@ -8,7 +8,6 @@ #pragma once -#include "Acts/EventData/TrackParameters.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/EventData/Track.hpp" #include "ActsExamples/Framework/DataHandle.hpp" diff --git a/Examples/Io/Root/src/RootAthenaDumpReader.cpp b/Examples/Io/Root/src/RootAthenaDumpReader.cpp index a732bb3b49e..47e5150501a 100644 --- a/Examples/Io/Root/src/RootAthenaDumpReader.cpp +++ b/Examples/Io/Root/src/RootAthenaDumpReader.cpp @@ -13,12 +13,10 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Utilities/Zip.hpp" #include "ActsExamples/EventData/Cluster.hpp" -#include "ActsExamples/EventData/GeometryContainers.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include -#include - #include #include @@ -40,7 +38,8 @@ std::pair splitInt(std::uint64_t v) { /// In cases when there is built up a particle collection in an iterative way it /// can be way faster to build up a vector and afterwards use a special /// constructor to speed up the set creation. -inline auto particleVectorToSet(std::vector& particles) { +inline auto particleVectorToSet( + std::vector& particles) { using namespace ActsExamples; auto cmp = [](const auto& a, const auto& b) { return a.particleId().value() == b.particleId().value(); @@ -250,7 +249,7 @@ RootAthenaDumpReader::RootAthenaDumpReader( } // constructor SimParticleContainer RootAthenaDumpReader::readParticles() const { - std::vector particles; + std::vector particles; particles.reserve(nPartEVT); for (auto ip = 0; ip < nPartEVT; ++ip) { @@ -259,8 +258,8 @@ SimParticleContainer RootAthenaDumpReader::readParticles() const { } auto dummyBarcode = concatInts(Part_barcode[ip], Part_event_number[ip]); - SimParticle particle(dummyBarcode, - static_cast(Part_pdg_id[ip])); + SimParticleState particle(dummyBarcode, + static_cast(Part_pdg_id[ip])); Acts::Vector3 p = Acts::Vector3{Part_px[ip], Part_py[ip], Part_pz[ip]} * Acts::UnitConstants::MeV; @@ -271,7 +270,7 @@ SimParticleContainer RootAthenaDumpReader::readParticles() const { auto x = Acts::Vector4{Part_vx[ip], Part_vy[ip], Part_vz[ip], 0.0}; particle.setPosition4(x); - particles.push_back(particle); + particles.push_back(SimParticle(particle, particle)); } ACTS_DEBUG("Created " << particles.size() << " particles"); @@ -635,7 +634,7 @@ std::pair> RootAthenaDumpReader::reprocessParticles( const SimParticleContainer& particles, const IndexMultimap& measPartMap) const { - std::vector newParticles; + std::vector newParticles; newParticles.reserve(particles.size()); IndexMultimap newMeasPartMap; diff --git a/Examples/Io/Root/src/RootParticleReader.cpp b/Examples/Io/Root/src/RootParticleReader.cpp index 973986d6704..a76255dbb4a 100644 --- a/Examples/Io/Root/src/RootParticleReader.cpp +++ b/Examples/Io/Root/src/RootParticleReader.cpp @@ -13,10 +13,9 @@ #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Io/Root/RootUtility.hpp" +#include "ActsFatras/EventData/ParticleOutcome.hpp" #include "ActsFatras/EventData/ProcessType.hpp" -#include -#include #include #include @@ -64,6 +63,12 @@ RootParticleReader::RootParticleReader(const RootParticleReader::Config& config, m_inputChain->SetBranchAddress("generation", &m_generation); m_inputChain->SetBranchAddress("sub_particle", &m_subParticle); + m_inputChain->SetBranchAddress("e_loss", &m_eLoss); + m_inputChain->SetBranchAddress("total_x0", &m_pathInX0); + m_inputChain->SetBranchAddress("total_l0", &m_pathInL0); + m_inputChain->SetBranchAddress("number_of_hits", &m_numberOfHits); + m_inputChain->SetBranchAddress("outcome", &m_outcome); + auto path = m_cfg.filePath; // add file to the input chain @@ -109,6 +114,12 @@ RootParticleReader::~RootParticleReader() { delete m_particle; delete m_generation; delete m_subParticle; + + delete m_eLoss; + delete m_pathInX0; + delete m_pathInL0; + delete m_numberOfHits; + delete m_outcome; } ProcessCode RootParticleReader::read(const AlgorithmContext& context) { @@ -136,18 +147,30 @@ ProcessCode RootParticleReader::read(const AlgorithmContext& context) { for (unsigned int i = 0; i < nParticles; i++) { SimParticle p; - p.setProcess(static_cast((*m_process)[i])); - p.setPdg(static_cast((*m_particleType)[i])); - p.setCharge((*m_q)[i] * Acts::UnitConstants::e); - p.setMass((*m_m)[i] * Acts::UnitConstants::GeV); - p.setParticleId((*m_particleId)[i]); - p.setPosition4((*m_vx)[i] * Acts::UnitConstants::mm, - (*m_vy)[i] * Acts::UnitConstants::mm, - (*m_vz)[i] * Acts::UnitConstants::mm, - (*m_vt)[i] * Acts::UnitConstants::mm); + p.setProcess(static_cast((*m_process).at(i))); + p.setPdg(static_cast((*m_particleType).at(i))); + p.setCharge((*m_q).at(i) * Acts::UnitConstants::e); + p.setMass((*m_m).at(i) * Acts::UnitConstants::GeV); + p.setParticleId((*m_particleId).at(i)); + + SimParticleState& initialState = p.initial(); + + initialState.setPosition4((*m_vx).at(i) * Acts::UnitConstants::mm, + (*m_vy).at(i) * Acts::UnitConstants::mm, + (*m_vz).at(i) * Acts::UnitConstants::mm, + (*m_vt).at(i) * Acts::UnitConstants::mm); // NOTE: direction is normalized inside `setDirection` - p.setDirection((*m_px)[i], (*m_py)[i], (*m_pz)[i]); - p.setAbsoluteMomentum((*m_p)[i] * Acts::UnitConstants::GeV); + initialState.setDirection((*m_px).at(i), (*m_py).at(i), (*m_pz).at(i)); + initialState.setAbsoluteMomentum((*m_p).at(i) * Acts::UnitConstants::GeV); + + SimParticleState& finalState = p.final(); + + // TODO eloss cannot be read since we need the final momentum + finalState.setMaterialPassed((*m_pathInX0).at(i) * Acts::UnitConstants::mm, + (*m_pathInL0).at(i) * Acts::UnitConstants::mm); + finalState.setNumberOfHits((*m_numberOfHits).at(i)); + finalState.setOutcome( + static_cast((*m_outcome).at(i))); particles.insert(p); } diff --git a/Examples/Io/Root/src/RootParticleWriter.cpp b/Examples/Io/Root/src/RootParticleWriter.cpp index 436601eb97d..ac6d47d10da 100644 --- a/Examples/Io/Root/src/RootParticleWriter.cpp +++ b/Examples/Io/Root/src/RootParticleWriter.cpp @@ -11,13 +11,11 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" -#include "ActsFatras/EventData/Barcode.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include #include -#include #include #include @@ -36,8 +34,6 @@ ActsExamples::RootParticleWriter::RootParticleWriter( throw std::invalid_argument("Missing tree name"); } - m_inputParticlesFinal.maybeInitialize(m_cfg.inputParticlesFinal); - // open root file and create the tree m_outputFile = TFile::Open(m_cfg.filePath.c_str(), m_cfg.fileMode.c_str()); if (m_outputFile == nullptr) { @@ -73,13 +69,11 @@ ActsExamples::RootParticleWriter::RootParticleWriter( m_outputTree->Branch("generation", &m_generation); m_outputTree->Branch("sub_particle", &m_subParticle); - if (m_inputParticlesFinal.isInitialized()) { - m_outputTree->Branch("e_loss", &m_eLoss); - m_outputTree->Branch("total_x0", &m_pathInX0); - m_outputTree->Branch("total_l0", &m_pathInL0); - m_outputTree->Branch("number_of_hits", &m_numberOfHits); - m_outputTree->Branch("outcome", &m_outcome); - } + m_outputTree->Branch("e_loss", &m_eLoss); + m_outputTree->Branch("total_x0", &m_pathInX0); + m_outputTree->Branch("total_l0", &m_pathInL0); + m_outputTree->Branch("number_of_hits", &m_numberOfHits); + m_outputTree->Branch("outcome", &m_outcome); } ActsExamples::RootParticleWriter::~RootParticleWriter() { @@ -101,16 +95,9 @@ ActsExamples::ProcessCode ActsExamples::RootParticleWriter::finalize() { ActsExamples::ProcessCode ActsExamples::RootParticleWriter::writeT( const AlgorithmContext& ctx, const SimParticleContainer& particles) { - const SimParticleContainer* finalParticles = nullptr; - if (m_inputParticlesFinal.isInitialized()) { - finalParticles = &m_inputParticlesFinal(ctx); - } - // ensure exclusive access to tree/file while writing std::lock_guard lock(m_writeMutex); - auto nan = std::numeric_limits::quiet_NaN(); - m_eventId = ctx.eventNumber; for (const auto& particle : particles) { m_particleId.push_back(particle.particleId().value()); @@ -150,41 +137,14 @@ ActsExamples::ProcessCode ActsExamples::RootParticleWriter::writeT( m_generation.push_back(particle.particleId().generation()); m_subParticle.push_back(particle.particleId().subParticle()); - bool wroteFinalParticle = false; - if (finalParticles != nullptr) { - // get the final particle - auto it = finalParticles->find(particle); - if (it == finalParticles->end()) { - ACTS_ERROR("Could not find final particle for " - << particle.particleId() << " in event " << ctx.eventNumber); - } else { - const auto& finalParticle = *it; - // get the energy loss - m_eLoss.push_back(Acts::clampValue( - (particle.energy() - finalParticle.energy()) / - Acts::UnitConstants::GeV)); - // get the path in X0 - m_pathInX0.push_back(Acts::clampValue(finalParticle.pathInX0() / - Acts::UnitConstants::mm)); - // get the path in L0 - m_pathInL0.push_back(Acts::clampValue(finalParticle.pathInL0() / - Acts::UnitConstants::mm)); - // get the number of hits - m_numberOfHits.push_back(finalParticle.numberOfHits()); - // get the particle outcome - m_outcome.push_back( - static_cast(finalParticle.outcome())); - - wroteFinalParticle = true; - } - } - if (!wroteFinalParticle) { - m_eLoss.push_back(nan); - m_pathInX0.push_back(nan); - m_pathInL0.push_back(nan); - m_numberOfHits.push_back(-1); - m_outcome.push_back(0); - } + m_eLoss.push_back(Acts::clampValue(particle.energyLoss() / + Acts::UnitConstants::GeV)); + m_pathInX0.push_back( + Acts::clampValue(particle.pathInX0() / Acts::UnitConstants::mm)); + m_pathInL0.push_back( + Acts::clampValue(particle.pathInL0() / Acts::UnitConstants::mm)); + m_numberOfHits.push_back(particle.numberOfHits()); + m_outcome.push_back(static_cast(particle.outcome())); } m_outputTree->Fill(); diff --git a/Examples/Io/Root/src/RootTrackSummaryReader.cpp b/Examples/Io/Root/src/RootTrackSummaryReader.cpp index 3a4f206c927..1827c26ad30 100644 --- a/Examples/Io/Root/src/RootTrackSummaryReader.cpp +++ b/Examples/Io/Root/src/RootTrackSummaryReader.cpp @@ -208,7 +208,7 @@ ProcessCode RootTrackSummaryReader::read(const AlgorithmContext& context) { unsigned int nTruthParticles = m_t_vx->size(); for (unsigned int i = 0; i < nTruthParticles; i++) { - ActsFatras::Particle truthParticle; + SimParticleState truthParticle; truthParticle.setPosition4((*m_t_vx)[i], (*m_t_vy)[i], (*m_t_vz)[i], (*m_t_time)[i]); @@ -216,7 +216,7 @@ ProcessCode RootTrackSummaryReader::read(const AlgorithmContext& context) { truthParticle.setParticleId((*m_majorityParticleId)[i]); truthParticleCollection.insert(truthParticleCollection.end(), - truthParticle); + SimParticle(truthParticle, truthParticle)); } // Write the collections to the EventStore m_outputTrackParameters(context, std::move(trackParameterCollection)); diff --git a/Examples/Io/Root/src/SeedingPerformanceWriter.cpp b/Examples/Io/Root/src/SeedingPerformanceWriter.cpp index 4ac7ea269ef..d11de8bc018 100644 --- a/Examples/Io/Root/src/SeedingPerformanceWriter.cpp +++ b/Examples/Io/Root/src/SeedingPerformanceWriter.cpp @@ -177,8 +177,9 @@ ActsExamples::ProcessCode ActsExamples::SeedingPerformanceWriter::writeT( minDeltaR = distance; } } - m_effPlotTool.fill(m_effPlotCache, particle, minDeltaR, isMatched); - m_duplicationPlotTool.fill(m_duplicationPlotCache, particle, + m_effPlotTool.fill(m_effPlotCache, particle.initial(), minDeltaR, + isMatched); + m_duplicationPlotTool.fill(m_duplicationPlotCache, particle.initial(), nMatchedSeedsForParticle - 1); } ACTS_DEBUG("Number of seeds: " << nSeeds); diff --git a/Examples/Io/Root/src/TrackFinderPerformanceWriter.cpp b/Examples/Io/Root/src/TrackFinderPerformanceWriter.cpp index ecec2fd59ce..0265aa3ea8b 100644 --- a/Examples/Io/Root/src/TrackFinderPerformanceWriter.cpp +++ b/Examples/Io/Root/src/TrackFinderPerformanceWriter.cpp @@ -260,14 +260,15 @@ ProcessCode TrackFinderPerformanceWriter::writeT( } // Fill efficiency plots - m_effPlotTool.fill(m_effPlotCache, particle, minDeltaR, isReconstructed); + m_effPlotTool.fill(m_effPlotCache, particle.initial(), minDeltaR, + isReconstructed); // Fill number of duplicated tracks for this particle - m_duplicationPlotTool.fill(m_duplicationPlotCache, particle, + m_duplicationPlotTool.fill(m_duplicationPlotCache, particle.initial(), nMatchedTracks - 1); // Fill number of reconstructed/truth-matched/fake tracks for this particle - m_fakeRatePlotTool.fill(m_fakeRatePlotCache, particle, nMatchedTracks, - nFakeTracks); + m_fakeRatePlotTool.fill(m_fakeRatePlotCache, particle.initial(), + nMatchedTracks, nFakeTracks); m_nTotalParticles += 1; } diff --git a/Examples/Io/Root/src/TrackFitterPerformanceWriter.cpp b/Examples/Io/Root/src/TrackFitterPerformanceWriter.cpp index 2063f03b53b..6a183cef4dd 100644 --- a/Examples/Io/Root/src/TrackFitterPerformanceWriter.cpp +++ b/Examples/Io/Root/src/TrackFitterPerformanceWriter.cpp @@ -148,7 +148,8 @@ ActsExamples::ProcessCode ActsExamples::TrackFitterPerformanceWriter::writeT( // Record this majority particle ID of this trajectory reconParticleIds.push_back(ip->particleId()); // Fill the residual plots - m_resPlotTool.fill(m_resPlotCache, ctx.geoContext, *ip, fittedParameters); + m_resPlotTool.fill(m_resPlotCache, ctx.geoContext, ip->initial(), + fittedParameters); // Fill the trajectory summary info m_trackSummaryPlotTool.fill(m_trackSummaryPlotCache, fittedParameters, track.nTrackStates(), track.nMeasurements(), @@ -181,7 +182,8 @@ ActsExamples::ProcessCode ActsExamples::TrackFitterPerformanceWriter::writeT( minDeltaR = distance; } } - m_effPlotTool.fill(m_effPlotCache, particle, minDeltaR, isReconstructed); + m_effPlotTool.fill(m_effPlotCache, particle.initial(), minDeltaR, + isReconstructed); } return ProcessCode::SUCCESS; diff --git a/Examples/Io/Root/src/detail/NuclearInteractionParametrisation.cpp b/Examples/Io/Root/src/detail/NuclearInteractionParametrisation.cpp index 91f59c56648..174f3648ce1 100644 --- a/Examples/Io/Root/src/detail/NuclearInteractionParametrisation.cpp +++ b/Examples/Io/Root/src/detail/NuclearInteractionParametrisation.cpp @@ -9,13 +9,10 @@ #include "ActsExamples/Io/Root/detail/NuclearInteractionParametrisation.hpp" #include "Acts/Definitions/Common.hpp" -#include "ActsFatras/EventData/Particle.hpp" #include -#include #include #include -#include #include #include @@ -23,6 +20,7 @@ #include namespace ActsExamples::detail::NuclearInteractionParametrisation { + namespace { /// @brief Evaluate the location in a standard normal distribution for a value @@ -52,14 +50,14 @@ float gaussianValue(TH1F const* histo, const float mom) { /// @param [in] fourVector2 The other four vector /// /// @return The invariant mass -float invariantMass(const ActsExamples::SimParticle::Vector4& fourVector1, - const ActsExamples::SimParticle::Vector4& fourVector2) { - ActsExamples::SimParticle::Vector4 sum = fourVector1 + fourVector2; - const ActsExamples::SimParticle::Scalar energy = sum[Acts::eEnergy]; - ActsExamples::SimParticle::Scalar momentum = - sum.template segment<3>(Acts::eMom0).norm(); +float invariantMass(const Acts::Vector4& fourVector1, + const Acts::Vector4& fourVector2) { + Acts::Vector4 sum = fourVector1 + fourVector2; + const Acts::ActsScalar energy = sum[Acts::eEnergy]; + Acts::ActsScalar momentum = sum.template segment<3>(Acts::eMom0).norm(); return std::sqrt(energy * energy - momentum * momentum); } + } // namespace std::pair calculateMeanAndCovariance( @@ -377,4 +375,5 @@ CumulativeDistribution cumulativeNuclearInteractionProbability( return histo; // TODO: in this case the normalisation is not taking into // account } + } // namespace ActsExamples::detail::NuclearInteractionParametrisation diff --git a/Examples/Python/python/acts/examples/simulation.py b/Examples/Python/python/acts/examples/simulation.py index b72d1f456df..21c4149661f 100644 --- a/Examples/Python/python/acts/examples/simulation.py +++ b/Examples/Python/python/acts/examples/simulation.py @@ -356,8 +356,6 @@ def addParticleSelection( config: ParticleSelectorConfig, inputParticles: str, outputParticles: str, - inputParticlesFinal: Optional[str] = None, - outputParticlesFinal: Optional[str] = None, logLevel: Optional[acts.logging.Level] = None, ) -> None: """ @@ -372,19 +370,13 @@ def addParticleSelection( inputParticles: str the identifier for the input particles to be selected outputParticles: str - the identifier for the final selected particle collection - inputParticlesFinal: str, None - the identifier for the input final particles to be selected - outputParticlesFinal: str, None - the identifier for the final selected final particle collection + the identifier for the selected particle collection """ customLogLevel = acts.examples.defaultLogging(s, logLevel) s.addAlgorithm( acts.examples.ParticleSelector( **acts.examples.defaultKWArgs( - inputParticlesFinal=inputParticlesFinal, - outputParticlesFinal=outputParticlesFinal, rhoMin=config.rho[0], rhoMax=config.rho[1], absZMin=config.absZ[0], @@ -424,8 +416,7 @@ def addFatras( enableInteractions: bool = True, pMin: Optional[float] = None, inputParticles: str = "particles_input", - outputParticlesInitial: str = "particles_initial", - outputParticlesFinal: str = "particles_final", + outputParticles: str = "particles_simulated", outputSimHits: str = "simhits", outputDirCsv: Optional[Union[Path, str]] = None, outputDirRoot: Optional[Union[Path, str]] = None, @@ -446,7 +437,7 @@ def addFatras( Default of no selections specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.hpp Specify preSelectParticles=None to inhibit ParticleSelector altogether. postSelectParticles : ParticleSelectorConfig(rho, absZ, time, phi, eta, absEta, pt, removeCharged, removeNeutral), None - Similar to preSelectParticles but applied after simulation to "particles_initial", therefore also filters secondaries. + Similar to preSelectParticles but applied after simulation to "particles_simulated", therefore also filters secondaries. enableInteractions : Enable the particle interactions in the simulation pMin : Minimum monmentum of particles simulated by FATRAS outputDirCsv : Path|str, path, None @@ -459,24 +450,24 @@ def addFatras( # Selector if preSelectParticles is not None: - particlesSelected = "fatras_particles_preselected" + particlesPreSelected = "fatras_particles_preselected" addParticleSelection( s, preSelectParticles, inputParticles=inputParticles, - outputParticles=particlesSelected, + outputParticles=particlesPreSelected, ) - s.addWhiteboardAlias("particles_selected", particlesSelected) else: - particlesSelected = inputParticles + particlesPreSelected = inputParticles + + s.addWhiteboardAlias("particles_selected", particlesPreSelected) # Simulation alg = acts.examples.FatrasSimulation( **acts.examples.defaultKWArgs( level=customLogLevel(), - inputParticles=particlesSelected, - outputParticlesInitial=outputParticlesInitial, - outputParticlesFinal=outputParticlesFinal, + inputParticles=particlesPreSelected, + outputParticles=outputParticles, outputSimHits=outputSimHits, randomNumbers=rnd, trackingGeometry=trackingGeometry, @@ -493,32 +484,27 @@ def addFatras( # Sequencer s.addAlgorithm(alg) + s.addWhiteboardAlias("particles", outputParticles) + # Selector if postSelectParticles is not None: - particlesInitial = "fatras_particles_initial_selected" - particlesFinal = "fatras_particles_final_selected" + particlesPostSelected = "fatras_particles_postselected" addParticleSelection( s, postSelectParticles, - inputParticles=outputParticlesInitial, - inputParticlesFinal=outputParticlesFinal, - outputParticles=particlesInitial, - outputParticlesFinal=particlesFinal, + inputParticles=outputParticles, + outputParticles=particlesPostSelected, ) - s.addWhiteboardAlias("particles_selected", particlesInitial) else: - particlesInitial = outputParticlesInitial - particlesFinal = outputParticlesFinal + particlesPostSelected = outputParticles - # Only add alias for 'particles_initial' as this is the one we use most - s.addWhiteboardAlias("particles", outputParticlesInitial) + s.addWhiteboardAlias("particles_selected", particlesPostSelected) # Output addSimWriters( s, alg.config.outputSimHits, - particlesInitial, - particlesFinal, + particlesPostSelected, outputDirCsv, outputDirRoot, logLevel, @@ -529,9 +515,8 @@ def addFatras( def addSimWriters( s: acts.examples.Sequencer, - simHits: Optional[str] = None, - particlesInitial="particles_initial", - particlesFinal="particles_final", + simHits: str = "simhits", + particlesSimulated: str = "particles_simulated", outputDirCsv: Optional[Union[Path, str]] = None, outputDirRoot: Optional[Union[Path, str]] = None, logLevel: Optional[acts.logging.Level] = None, @@ -546,16 +531,8 @@ def addSimWriters( acts.examples.CsvParticleWriter( level=customLogLevel(), outputDir=str(outputDirCsv), - inputParticles=particlesInitial, - outputStem="particles_initial", - ) - ) - s.addWriter( - acts.examples.CsvParticleWriter( - level=customLogLevel(), - outputDir=str(outputDirCsv), - inputParticles=particlesFinal, - outputStem="particles_final", + inputParticles=particlesSimulated, + outputStem="particles_simulated", ) ) s.addWriter( @@ -574,8 +551,7 @@ def addSimWriters( s.addWriter( acts.examples.RootParticleWriter( level=customLogLevel(), - inputParticles=particlesInitial, - inputParticlesFinal=particlesFinal, + inputParticles=particlesSimulated, filePath=str(outputDirRoot / "particles_simulation.root"), ) ) @@ -636,8 +612,7 @@ def addGeant4( volumeMappings: List[str] = [], materialMappings: List[str] = ["Silicon"], inputParticles: str = "particles_input", - outputParticlesInitial: str = "particles_initial", - outputParticlesFinal: str = "particles_final", + outputParticles: str = "particles_simulated", outputSimHits: str = "simhits", preSelectParticles: Optional[ParticleSelectorConfig] = ParticleSelectorConfig(), postSelectParticles: Optional[ParticleSelectorConfig] = None, @@ -667,7 +642,7 @@ def addGeant4( Default of no selections specified in Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/ParticleSelector.hpp Specify preSelectParticles=None to inhibit ParticleSelector altogether. postSelectParticles : ParticleSelectorConfig(rho, absZ, time, phi, eta, absEta, pt, removeCharged, removeNeutral), None - Similar to preSelectParticles but applied after simulation to "particles_initial", therefore also filters secondaries. + Similar to preSelectParticles but applied after simulation to "particles_simulated", therefore also filters secondaries. outputDirCsv : Path|str, path, None the output folder for the Csv output, None triggers no output outputDirRoot : Path|str, path, None @@ -686,16 +661,17 @@ def addGeant4( # Selector if preSelectParticles is not None: - particlesSelected = "geant4_particles_preselected" + particlesPreSelected = "geant4_particles_preselected" addParticleSelection( s, preSelectParticles, inputParticles=inputParticles, - outputParticles=particlesSelected, + outputParticles=particlesPreSelected, ) - s.addWhiteboardAlias("particles_selected", particlesSelected) else: - particlesSelected = inputParticles + particlesPreSelected = inputParticles + + s.addWhiteboardAlias("particles_selected", particlesPreSelected) if g4DetectorConstructionFactory is None: if detector is None: @@ -719,9 +695,8 @@ def addGeant4( geant4Handle=__geant4Handle, detectorConstructionFactory=g4DetectorConstructionFactory, randomNumbers=rnd, - inputParticles=particlesSelected, - outputParticlesInitial=outputParticlesInitial, - outputParticlesFinal=outputParticlesFinal, + inputParticles=particlesPreSelected, + outputParticles=outputParticles, outputSimHits=outputSimHits, sensitiveSurfaceMapper=sensitiveMapper, magneticField=field, @@ -738,35 +713,30 @@ def addGeant4( # Sequencer s.addAlgorithm(alg) + s.addWhiteboardAlias("particles", outputParticles) + # Selector if postSelectParticles is not None: - particlesInitial = "geant4_particles_initial_postselected" - particlesFinal = "geant4_particles_final_postselected" + particlesPostSelected = "geant4_particles_postselected" addParticleSelection( s, postSelectParticles, - inputParticles=outputParticlesInitial, - inputParticlesFinal=outputParticlesFinal, - outputParticles=particlesInitial, - outputParticlesFinal=particlesFinal, + inputParticles=outputParticles, + outputParticles=particlesPostSelected, ) - s.addWhiteboardAlias("particles_selected", particlesInitial) else: - particlesInitial = outputParticlesInitial - particlesFinal = outputParticlesFinal + particlesPostSelected = outputParticles - # Only add alias for 'particles_initial' as this is the one we use most - s.addWhiteboardAlias("particles", outputParticlesInitial) + s.addWhiteboardAlias("particles_selected", particlesPostSelected) # Output addSimWriters( s, alg.config.outputSimHits, - particlesInitial, - particlesFinal, + particlesPostSelected, outputDirCsv, outputDirRoot, - logLevel=logLevel, + logLevel, ) return s diff --git a/Examples/Python/src/EDM4hepComponent.cpp b/Examples/Python/src/EDM4hepComponent.cpp index 75746587be8..f7b4c949172 100644 --- a/Examples/Python/src/EDM4hepComponent.cpp +++ b/Examples/Python/src/EDM4hepComponent.cpp @@ -17,8 +17,6 @@ #include "ActsExamples/Io/EDM4hep/EDM4hepTrackReader.hpp" #include "ActsExamples/Io/EDM4hep/EDM4hepTrackWriter.hpp" -#include - #include #include @@ -31,9 +29,9 @@ using namespace Acts::Python; PYBIND11_MODULE(ActsPythonBindingsEDM4hep, m) { ACTS_PYTHON_DECLARE_READER( ActsExamples::EDM4hepReader, m, "EDM4hepReader", inputPath, - inputParticles, inputSimHits, outputParticlesInitial, - outputParticlesFinal, outputParticlesGenerator, outputSimHits, - graphvizOutput, dd4hepDetector, trackingGeometry, sortSimHitsInTime); + inputParticles, inputSimHits, outputParticlesGenerator, + outputParticlesSimulation, outputSimHits, graphvizOutput, dd4hepDetector, + trackingGeometry, sortSimHitsInTime); ACTS_PYTHON_DECLARE_WRITER( ActsExamples::EDM4hepSimHitWriter, m, "EDM4hepSimHitWriter", inputSimHits, diff --git a/Examples/Python/src/ExampleAlgorithms.cpp b/Examples/Python/src/ExampleAlgorithms.cpp index 598dde87b99..7d9007183e8 100644 --- a/Examples/Python/src/ExampleAlgorithms.cpp +++ b/Examples/Python/src/ExampleAlgorithms.cpp @@ -35,11 +35,11 @@ void addExampleAlgorithms(Context& ctx) { ACTS_PYTHON_DECLARE_ALGORITHM( ActsExamples::FatrasSimulation, mex, "FatrasSimulation", inputParticles, - outputParticlesInitial, outputParticlesFinal, outputSimHits, - imputParametrisationNuclearInteraction, randomNumbers, trackingGeometry, - magneticField, pMin, emScattering, emEnergyLossIonisation, - emEnergyLossRadiation, emPhotonConversion, generateHitsOnSensitive, - generateHitsOnMaterial, generateHitsOnPassive, averageHitsPerParticle); + outputParticles, outputSimHits, imputParametrisationNuclearInteraction, + randomNumbers, trackingGeometry, magneticField, pMin, emScattering, + emEnergyLossIonisation, emEnergyLossRadiation, emPhotonConversion, + generateHitsOnSensitive, generateHitsOnMaterial, generateHitsOnPassive, + averageHitsPerParticle); ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::ParticlesPrinter, mex, "ParticlesPrinter", inputParticles); diff --git a/Examples/Python/src/Geant4Component.cpp b/Examples/Python/src/Geant4Component.cpp index ff34da94cc0..1a7edd58e7f 100644 --- a/Examples/Python/src/Geant4Component.cpp +++ b/Examples/Python/src/Geant4Component.cpp @@ -29,9 +29,7 @@ #include "ActsExamples/TelescopeDetector/TelescopeDetector.hpp" #include "ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp" -#include #include -#include #include #include #include @@ -206,8 +204,7 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { .def(py::init<>()); ACTS_PYTHON_STRUCT_BEGIN(c1, Config); ACTS_PYTHON_MEMBER(outputSimHits); - ACTS_PYTHON_MEMBER(outputParticlesInitial); - ACTS_PYTHON_MEMBER(outputParticlesFinal); + ACTS_PYTHON_MEMBER(outputParticles); ACTS_PYTHON_MEMBER(sensitiveSurfaceMapper); ACTS_PYTHON_MEMBER(magneticField); ACTS_PYTHON_MEMBER(physicsList); diff --git a/Examples/Python/src/Output.cpp b/Examples/Python/src/Output.cpp index dce56dc681e..5adead2a9b4 100644 --- a/Examples/Python/src/Output.cpp +++ b/Examples/Python/src/Output.cpp @@ -193,8 +193,8 @@ void addOutput(Context& ctx) { inputSummaryCollection, filePath, fileMode); ACTS_PYTHON_DECLARE_WRITER(ActsExamples::RootParticleWriter, mex, - "RootParticleWriter", inputParticles, - inputParticlesFinal, filePath, fileMode, treeName); + "RootParticleWriter", inputParticles, filePath, + fileMode, treeName); ACTS_PYTHON_DECLARE_WRITER(ActsExamples::RootVertexWriter, mex, "RootVertexWriter", inputVertices, filePath, diff --git a/Examples/Python/src/TruthTracking.cpp b/Examples/Python/src/TruthTracking.cpp index 7278b3f821f..3f0d8a0915a 100644 --- a/Examples/Python/src/TruthTracking.cpp +++ b/Examples/Python/src/TruthTracking.cpp @@ -62,9 +62,7 @@ void addTruthTracking(Context& ctx) { ACTS_PYTHON_STRUCT_BEGIN(c, Config); ACTS_PYTHON_MEMBER(inputParticles); - ACTS_PYTHON_MEMBER(inputParticlesFinal); ACTS_PYTHON_MEMBER(outputParticles); - ACTS_PYTHON_MEMBER(outputParticlesFinal); ACTS_PYTHON_MEMBER(rhoMin); ACTS_PYTHON_MEMBER(rhoMax); ACTS_PYTHON_MEMBER(absZMin); diff --git a/Examples/Python/tests/conftest.py b/Examples/Python/tests/conftest.py index f4e0abbcadd..b2015c3f6a0 100644 --- a/Examples/Python/tests/conftest.py +++ b/Examples/Python/tests/conftest.py @@ -342,8 +342,7 @@ def _factory(s): simAlg = acts.examples.FatrasSimulation( level=acts.logging.INFO, inputParticles=evGen.config.outputParticles, - outputParticlesInitial="particles_initial", - outputParticlesFinal="particles_final", + outputParticles="particles_simulated", outputSimHits="simhits", randomNumbers=rng, trackingGeometry=trk_geo, diff --git a/Examples/Python/tests/root_file_hashes.txt b/Examples/Python/tests/root_file_hashes.txt index eb97555e084..c6ed65f4564 100644 --- a/Examples/Python/tests/root_file_hashes.txt +++ b/Examples/Python/tests/root_file_hashes.txt @@ -1,20 +1,20 @@ -test_pythia8__particles.root: 91c852f3e0e20bcd382c616a7b643985d092decd42bdd653deae67ed8652e8d8 +test_pythia8__particles.root: 125182a9647ef3cec71afbc1b9e1676e40c13826c8333d6704345dd5133d5e91 test_fatras__particles_simulation.root: bc970873fef0c2efd86ed5413623802353d2cd04abea72de14e8cdfc0e40076f test_fatras__hits.root: 6e4beb045fa1712c4d14c280ba33c3fa13e4aff9de88d55c3e32f62ad226f724 test_geant4__particles_simulation.root: 49926c71a9b54e13aa1cc7596d3302baf3c87d8e2c1d0267cb4523f6abdc0ac2 test_geant4__hits.root: 4c9e704a75f47ed2e61652679a1d6f18fa4d9cf53faa8f8f5bbf7995634207aa test_seeding__estimatedparams.root: 69c0e268f9025a0991a212ea2a7f26f53112fecf614b475605bd1cb08415ba56 test_seeding__performance_seeding.root: 992f9c611d30dde0d3f3ab676bab19ada61ab6a4442828e27b65ec5e5b7a2880 -test_seeding__particles.root: 7855b021f39ad238bca098e4282667be0666f2d1630e5bcb9d51d3b5ee39fa14 +test_seeding__particles.root: c423bc666df3674f1a1140dec68ea13f44173232b8057e8a02572aee4f3e7d5b test_seeding__particles_simulation.root: f937a4cc474e80cfbb6eac4384e42e9c5c7ac981fcd6870d624cc898d1a0c006 test_hashing_seeding__estimatedparams.root: 8daa3f04342c265f32f1608ccc921ab0041686a6280b956f811638ad4328330e test_seeding_orthogonal__estimatedparams.root: ca5896ec325daf5c8012291bc454269c61c32fe3d7e33bd1fa3b812826930299 test_seeding_orthogonal__performance_seeding.root: 60fbedcf5cb2b37cd8e526251940564432890d3a159d231ed819e915a904682c -test_seeding_orthogonal__particles.root: 7855b021f39ad238bca098e4282667be0666f2d1630e5bcb9d51d3b5ee39fa14 +test_seeding_orthogonal__particles.root: c423bc666df3674f1a1140dec68ea13f44173232b8057e8a02572aee4f3e7d5b test_seeding_orthogonal__particles_simulation.root: f937a4cc474e80cfbb6eac4384e42e9c5c7ac981fcd6870d624cc898d1a0c006 test_itk_seeding__estimatedparams.root: 1cc05f9f2aefb5f71a85b31e97bc4e5845fedfcef6c53199495a6340c6b6210b test_itk_seeding__performance_seeding.root: 78ebda54cd0f026ba4b7f316724ffd946de56a932735914baf1b7bba9505c29d -test_itk_seeding__particles.root: 0b6f4ad438010ac48803d48ed98e80b5e87d310bae6c2c02b16cd94d7a4d7d07 +test_itk_seeding__particles.root: 907ff693262c0db14b12c74b16586cb20d79caf5f03f93b178943e41ed35a1b6 test_itk_seeding__particles_simulation.root: ef0246069aa697019f28a8b270a68de95312cae5f2f2c74848566c3ce4f70363 test_propagation__propagation_summary.root: 280c1a6fcfe71974ac39587b4afad27a31640bec42ca6537cc92e2d5e09d7ed6 test_material_recording__geant4_material_tracks.root: c022b9362249b29f57a07926b20644e3ab4ab8ebcf03f773fbf46c446fc1a0a1 @@ -22,16 +22,16 @@ test_truth_tracking_gsf[generic]__trackstates_gsf.root: 4df2c69d5dd7d5446a547651 test_truth_tracking_gsf[generic]__tracksummary_gsf.root: 8c01d139cb865afa1959c62dbca76f3a1fb8b684c57ea4c2968baa6ffedadb6f test_truth_tracking_gsf[odd]__trackstates_gsf.root: c7397e53ea093f2432943ae263fc99bc9aa774504ea6152c6907066a06d21caf test_truth_tracking_gsf[odd]__tracksummary_gsf.root: 4562341f12a61ea0d5e25872b6bf466b79a73781dc95fc18ef9c6515f0a47916 -test_particle_gun__particles.root: 5fe7dda2933ee6b9615b064d192322fe07831133cd998e5ed99a3b992b713a10 +test_particle_gun__particles.root: 669d0304eb8bcf244aa627809a117944e5e3b994fdfcfb8710f2b9a8f9a62d3b test_material_mapping__material-map_tracks.root: 938b1a855369e9304401cb10d2751df3fd7acf32a2573f2057eb1691cd94edf3 test_material_mapping__propagation-material.root: 5eacd0cb804d381171c8fb65d7b2d36e1d57db9f4cb2b58c0f24703479218cbf test_volume_material_mapping__material-map-volume_tracks.root: 98e212d32ca054fa3d01af4167c1f49755a139d43b82c57908197f5985e0a4ff test_volume_material_mapping__propagation-volume-material.root: 3e9d38cc541a1956b2f33be320d457559bb230311130a8531bf09371c272f913 test_digitization_example[smeared]__measurements.root: 2b583b886b76f94786c6c2832aa84d176059cbbc35882fb34b4fd1f22dd4c006 test_digitization_example[geometric]__measurements.root: 85efa861d14207fd7d1798dab093edcd0a2685bc189b4fc9a96b07d1001013a0 -test_digitization_example_input[smeared]__particles.root: 5fe7dda2933ee6b9615b064d192322fe07831133cd998e5ed99a3b992b713a10 +test_digitization_example_input[smeared]__particles.root: 669d0304eb8bcf244aa627809a117944e5e3b994fdfcfb8710f2b9a8f9a62d3b test_digitization_example_input[smeared]__measurements.root: 243c2f69b7b0db9dbeaa7494d4ea0f3dd1691dc90f16e10df6c0491ff4dc7d62 -test_digitization_example_input[geometric]__particles.root: 5fe7dda2933ee6b9615b064d192322fe07831133cd998e5ed99a3b992b713a10 +test_digitization_example_input[geometric]__particles.root: 669d0304eb8bcf244aa627809a117944e5e3b994fdfcfb8710f2b9a8f9a62d3b test_digitization_example_input[geometric]__measurements.root: 63ec81635979058fb8976f94455bf490cf92b7b142c4a05cc39de6225f5de2fb test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: 7c48ec32a2cb1723416a9791a8067ef09825fcf71a6cf561c1f6d2ab9dc1c1ad test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: e6b9e539998ba007e9b7d2c8d9d022c47726a39e8ab9b1724c52b1d78234be03 @@ -59,9 +59,9 @@ test_bfield_writing__solenoid2.root: 2db149336c9cd749dc50025076b49f9bc0586d53792 test_root_prop_step_writer[configPosConstructor]__prop_steps.root: a783d525eebb4737e6e6bcf20d63d6f35520f4bcf23301ae8c4657309cbccdda test_root_prop_step_writer[configKwConstructor]__prop_steps.root: a783d525eebb4737e6e6bcf20d63d6f35520f4bcf23301ae8c4657309cbccdda test_root_prop_step_writer[kwargsConstructor]__prop_steps.root: a783d525eebb4737e6e6bcf20d63d6f35520f4bcf23301ae8c4657309cbccdda -test_root_particle_writer[configPosConstructor]__particles.root: 759f7c0225a30afc28c3dda6010295207254ebb0194b88f692d538b8c65d4326 -test_root_particle_writer[configKwConstructor]__particles.root: 759f7c0225a30afc28c3dda6010295207254ebb0194b88f692d538b8c65d4326 -test_root_particle_writer[kwargsConstructor]__particles.root: 759f7c0225a30afc28c3dda6010295207254ebb0194b88f692d538b8c65d4326 +test_root_particle_writer[configPosConstructor]__particles.root: e5d723e138b4e121c6e74a6dba072072f622995e117a40b8e63755ac784baad6 +test_root_particle_writer[configKwConstructor]__particles.root: e5d723e138b4e121c6e74a6dba072072f622995e117a40b8e63755ac784baad6 +test_root_particle_writer[kwargsConstructor]__particles.root: e5d723e138b4e121c6e74a6dba072072f622995e117a40b8e63755ac784baad6 test_root_meas_writer__meas.root: 0f7e51c3c6e0133c6c1fc0da6d936e16f59ca2b579d15108e6c7b82bdf0a1e73 test_root_simhits_writer[configPosConstructor]__meas.root: 66fee65a672bbf28098aac7af59ef181c2ac8331f87a379132873da86bdb1ba5 test_root_simhits_writer[configKwConstructor]__meas.root: 66fee65a672bbf28098aac7af59ef181c2ac8331f87a379132873da86bdb1ba5 diff --git a/Examples/Python/tests/test_examples.py b/Examples/Python/tests/test_examples.py index 69f06101fdd..2261e58cea4 100644 --- a/Examples/Python/tests/test_examples.py +++ b/Examples/Python/tests/test_examples.py @@ -130,8 +130,7 @@ def test_fatras(trk_geo, tmp_path, field, assert_root_hash): seq = Sequencer(events=nevents) runFatras(trk_geo, field, str(tmp_path), s=seq).run() - assert_csv_output(csv, "particles_final") - assert_csv_output(csv, "particles_initial") + assert_csv_output(csv, "particles_simulated") assert_csv_output(csv, "hits") for f, tn in root_files: rfp = tmp_path / f @@ -186,8 +185,7 @@ def test_geant4(tmp_path, assert_root_hash): print(e.output.decode("utf-8")) raise - assert_csv_output(csv, "particles_final") - assert_csv_output(csv, "particles_initial") + assert_csv_output(csv, "particles_simulated") assert_csv_output(csv, "hits") for f in root_files: rfp = tmp_path / f @@ -244,8 +242,7 @@ def test_seeding(tmp_path, trk_geo, field, assert_root_hash): assert_root_hash(fn, fp) assert_csv_output(csv, "particles") - assert_csv_output(csv, "particles_final") - assert_csv_output(csv, "particles_initial") + assert_csv_output(csv, "particles_simulated") @pytest.mark.slow @@ -304,8 +301,7 @@ def test_hashing_seeding(tmp_path, trk_geo, field, assert_root_hash): assert_has_entries(fp, tn) assert_root_hash(fn, fp) - assert_csv_output(tmp_path, "particles_final") - assert_csv_output(tmp_path, "particles_initial") + assert_csv_output(tmp_path, "particles_simulated") assert_csv_output(tmp_path, "buckets") assert_csv_output(tmp_path, "seed") @@ -363,8 +359,7 @@ def test_seeding_orthogonal(tmp_path, trk_geo, field, assert_root_hash): assert_root_hash(fn, fp) assert_csv_output(csv, "particles") - assert_csv_output(csv, "particles_final") - assert_csv_output(csv, "particles_initial") + assert_csv_output(csv, "particles_simulated") def test_itk_seeding(tmp_path, trk_geo, field, assert_root_hash): @@ -460,7 +455,6 @@ def test_itk_seeding(tmp_path, trk_geo, field, assert_root_hash): acts.logging.VERBOSE, geoSelectionConfigFile=srcdir / "Examples/Algorithms/TrackFinding/share/geoSelection-genericDetector.json", - inputParticles="particles_final", # use this to reproduce the original root_file_hashes.txt - remove to fix outputDirRoot=str(tmp_path), ) @@ -476,8 +470,7 @@ def test_itk_seeding(tmp_path, trk_geo, field, assert_root_hash): assert_root_hash(fn, fp) assert_csv_output(csv, "particles") - assert_csv_output(csv, "particles_final") - assert_csv_output(csv, "particles_initial") + assert_csv_output(csv, "particles_simulated") @pytest.mark.slow diff --git a/Examples/Python/tests/test_reader.py b/Examples/Python/tests/test_reader.py index b83b1317cc8..104a4e0f98f 100644 --- a/Examples/Python/tests/test_reader.py +++ b/Examples/Python/tests/test_reader.py @@ -314,8 +314,7 @@ def test_edm4hep_simhit_particle_reader(tmp_path): "LongStripEndcapReadout", ], outputParticlesGenerator="particles_input", - outputParticlesInitial="particles_initial", - outputParticlesFinal="particles_final", + outputParticlesSimulation="particles_simulated", outputSimHits="simhits", dd4hepDetector=detector, trackingGeometry=trackingGeometry, diff --git a/Examples/Scripts/Python/full_chain_odd.py b/Examples/Scripts/Python/full_chain_odd.py index 347e52714ea..8b86402b820 100755 --- a/Examples/Scripts/Python/full_chain_odd.py +++ b/Examples/Scripts/Python/full_chain_odd.py @@ -189,8 +189,7 @@ "LongStripEndcapReadout", ], outputParticlesGenerator="particles_input", - outputParticlesInitial="particles_initial", - outputParticlesFinal="particles_final", + outputParticlesSimulation="particles_simulated", outputSimHits="simhits", graphvizOutput="graphviz", dd4hepDetector=detector, diff --git a/Examples/Scripts/Python/full_chain_odd_LRT.py b/Examples/Scripts/Python/full_chain_odd_LRT.py index 5cbac847baa..cfa03b5336c 100644 --- a/Examples/Scripts/Python/full_chain_odd_LRT.py +++ b/Examples/Scripts/Python/full_chain_odd_LRT.py @@ -187,8 +187,7 @@ "LongStripEndcapReadout", ], outputParticlesGenerator="particles_input", - outputParticlesInitial="particles_initial", - outputParticlesFinal="particles_final", + outputParticlesSimulation="particles_simulated", outputSimHits="simhits", graphvizOutput="graphviz", dd4hepDetector=detector, diff --git a/Examples/Scripts/Python/seeding.py b/Examples/Scripts/Python/seeding.py index afe8983eec7..3beb6071aae 100755 --- a/Examples/Scripts/Python/seeding.py +++ b/Examples/Scripts/Python/seeding.py @@ -133,7 +133,6 @@ def runSeeding( seedingAlgorithm=seedingAlgorithm, geoSelectionConfigFile=srcdir / "Examples/Algorithms/TrackFinding/share/geoSelection-genericDetector.json", - inputParticles="particles_final", # use this to reproduce the original root_file_hashes.txt - remove to fix outputDirRoot=outputDir, ) return s diff --git a/Fatras/include/ActsFatras/EventData/Particle.hpp b/Fatras/include/ActsFatras/EventData/Particle.hpp index 6eff75c404b..5b6eb2f7a61 100644 --- a/Fatras/include/ActsFatras/EventData/Particle.hpp +++ b/Fatras/include/ActsFatras/EventData/Particle.hpp @@ -153,33 +153,33 @@ class Particle { } /// Particle identifier within an event. - constexpr Barcode particleId() const { return m_particleId; } + Barcode particleId() const { return m_particleId; } /// Which type of process generated this particle. - constexpr ProcessType process() const { return m_process; } + ProcessType process() const { return m_process; } /// PDG particle number that identifies the type. - constexpr Acts::PdgParticle pdg() const { return m_pdg; } + Acts::PdgParticle pdg() const { return m_pdg; } /// Absolute PDG particle number that identifies the type. - constexpr Acts::PdgParticle absolutePdg() const { + Acts::PdgParticle absolutePdg() const { return Acts::makeAbsolutePdgParticle(pdg()); } /// Particle charge. - constexpr Scalar charge() const { return m_charge; } + Scalar charge() const { return m_charge; } /// Particle absolute charge. - constexpr Scalar absoluteCharge() const { return std::abs(m_charge); } + Scalar absoluteCharge() const { return std::abs(m_charge); } /// Particle mass. - constexpr Scalar mass() const { return m_mass; } + Scalar mass() const { return m_mass; } /// Particle hypothesis. - constexpr Acts::ParticleHypothesis hypothesis() const { + Acts::ParticleHypothesis hypothesis() const { return Acts::ParticleHypothesis(absolutePdg(), mass(), absoluteCharge()); } /// Particl qOverP. - constexpr Scalar qOverP() const { + Scalar qOverP() const { return hypothesis().qOverP(absoluteMomentum(), charge()); } /// Space-time position four-vector. - constexpr const Vector4 &fourPosition() const { return m_position4; } + const Vector4 &fourPosition() const { return m_position4; } /// Three-position, i.e. spatial coordinates without the time. auto position() const { return m_position4.segment<3>(Acts::ePos0); } /// Time coordinate. @@ -205,16 +205,17 @@ class Particle { return m_absMomentum * m_direction.segment<2>(Acts::eMom0).norm(); } /// Absolute momentum. - constexpr Scalar absoluteMomentum() const { return m_absMomentum; } + Scalar absoluteMomentum() const { return m_absMomentum; } /// Absolute momentum. Vector3 momentum() const { return absoluteMomentum() * direction(); } /// Total energy, i.e. norm of the four-momentum. Scalar energy() const { return std::hypot(m_mass, m_absMomentum); } /// Check if the particle is alive, i.e. is not at rest. - constexpr bool isAlive() const { return Scalar{0} < m_absMomentum; } + bool isAlive() const { return Scalar{0} < m_absMomentum; } - constexpr bool isSecondary() const { + /// Check if this is a secondary particle. + bool isSecondary() const { return particleId().vertexSecondary() != 0 || particleId().generation() != 0 || particleId().subParticle() != 0; } @@ -224,26 +225,26 @@ class Particle { /// Set the proper time in the particle rest frame. /// /// @param properTime passed proper time in the rest frame - constexpr Particle &setProperTime(Scalar properTime) { + Particle &setProperTime(Scalar properTime) { m_properTime = properTime; return *this; } /// Proper time in the particle rest frame. - constexpr Scalar properTime() const { return m_properTime; } + Scalar properTime() const { return m_properTime; } /// Set the accumulated material measured in radiation/interaction lengths. /// /// @param pathInX0 accumulated material measured in radiation lengths /// @param pathInL0 accumulated material measured in interaction lengths - constexpr Particle &setMaterialPassed(Scalar pathInX0, Scalar pathInL0) { + Particle &setMaterialPassed(Scalar pathInX0, Scalar pathInL0) { m_pathInX0 = pathInX0; m_pathInL0 = pathInL0; return *this; } /// Accumulated path within material measured in radiation lengths. - constexpr Scalar pathInX0() const { return m_pathInX0; } + Scalar pathInX0() const { return m_pathInX0; } /// Accumulated path within material measured in interaction lengths. - constexpr Scalar pathInL0() const { return m_pathInL0; } + Scalar pathInL0() const { return m_pathInL0; } /// Set the reference surface. /// @@ -285,24 +286,24 @@ class Particle { /// Set the number of hits. /// /// @param nHits number of hits - constexpr Particle &setNumberOfHits(std::uint32_t nHits) { + Particle &setNumberOfHits(std::uint32_t nHits) { m_numberOfHits = nHits; return *this; } /// Number of hits. - constexpr std::uint32_t numberOfHits() const { return m_numberOfHits; } + std::uint32_t numberOfHits() const { return m_numberOfHits; } /// Set the outcome of particle. /// /// @param outcome outcome code - constexpr Particle &setOutcome(ParticleOutcome outcome) { + Particle &setOutcome(ParticleOutcome outcome) { m_outcome = outcome; return *this; } /// Particle outcome. - constexpr ParticleOutcome outcome() const { return m_outcome; } + ParticleOutcome outcome() const { return m_outcome; } private: // identity, i.e. things that do not change over the particle lifetime. diff --git a/Fatras/include/ActsFatras/Kernel/Simulation.hpp b/Fatras/include/ActsFatras/Kernel/Simulation.hpp index 2d8280737f0..b6975c34172 100644 --- a/Fatras/include/ActsFatras/Kernel/Simulation.hpp +++ b/Fatras/include/ActsFatras/Kernel/Simulation.hpp @@ -8,17 +8,11 @@ #pragma once -#include "Acts/EventData/Charge.hpp" -#include "Acts/EventData/GenericCurvilinearTrackParameters.hpp" -#include "Acts/EventData/TrackParameters.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/Propagator/ActorList.hpp" -#include "Acts/Propagator/Propagator.hpp" -#include "Acts/Propagator/StandardAborters.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/Result.hpp" -#include "ActsFatras/EventData/Hit.hpp" #include "ActsFatras/EventData/Particle.hpp" #include "ActsFatras/Kernel/SimulationResult.hpp" #include "ActsFatras/Kernel/detail/SimulationActor.hpp" From 257473abebd711e445a1c4048351539e761a9c4f Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:08:41 +0100 Subject: [PATCH 3/5] refactor: use mathematical constants from `std::numbers` (#3781) blocked: - https://github.com/acts-project/acts/pull/3783 Asked co-pilot to summarise the PR: Summary: The pull request aims to refactor the code to use mathematical constants from the C++20 header, replacing existing instances of M_PI with std::numbers::pi. The changes span multiple files, primarily focusing on improving the consistency and modernity of mathematical constant usage across the codebase. --- .../ScoreBasedAmbiguityResolution.hpp | 5 +- Core/include/Acts/Definitions/Units.hpp | 4 +- .../Acts/EventData/TransformationHelpers.hpp | 7 +- .../Acts/EventData/detail/ParameterTraits.hpp | 7 +- .../Acts/Geometry/CylinderVolumeBounds.hpp | 6 +- .../Acts/Geometry/SurfaceArrayCreator.hpp | 3 +- Core/include/Acts/Geometry/VolumeBounds.hpp | 15 ++- .../Acts/Propagator/RiddersPropagator.ipp | 22 +-- .../Acts/Propagator/detail/LoopProtection.hpp | 5 +- Core/include/Acts/Seeding/GbtsDataStorage.hpp | 13 +- .../include/Acts/Seeding/SeedFinderConfig.hpp | 5 +- Core/include/Acts/Seeding/SeedFinderGbts.ipp | 12 +- .../Seeding/SeedFinderOrthogonalConfig.hpp | 5 +- .../detail/CylindricalSpacePointGrid.hpp | 2 +- .../detail/CylindricalSpacePointGrid.ipp | 7 +- Core/include/Acts/Surfaces/AnnulusBounds.hpp | 3 +- Core/include/Acts/Surfaces/ConeBounds.hpp | 10 +- Core/include/Acts/Surfaces/ConeSurface.hpp | 3 +- Core/include/Acts/Surfaces/CylinderBounds.hpp | 8 +- .../include/Acts/Surfaces/CylinderSurface.hpp | 3 +- Core/include/Acts/Surfaces/DiscSurface.hpp | 3 +- .../Acts/Surfaces/DiscTrapezoidBounds.hpp | 3 +- Core/include/Acts/Surfaces/EllipseBounds.hpp | 6 +- Core/include/Acts/Surfaces/RadialBounds.hpp | 7 +- .../Acts/Surfaces/detail/VerticesHelper.hpp | 28 ++-- .../Acts/TrackFitting/BetheHeitlerApprox.hpp | 3 +- .../detail/GsfComponentMerging.hpp | 23 ++-- .../Acts/Utilities/BinAdjustmentVolume.hpp | 5 +- Core/include/Acts/Utilities/Frustum.ipp | 10 +- .../Acts/Utilities/detail/periodic.hpp | 11 +- .../Acts/Vertexing/SingleSeedVertexFinder.ipp | 28 ++-- .../Acts/Visualization/EventDataView3D.hpp | 5 +- Core/src/Detector/VolumeStructureBuilder.cpp | 4 +- .../detail/CylindricalDetectorHelper.cpp | 9 +- .../Detector/detail/SupportSurfacesHelper.cpp | 14 +- Core/src/Geometry/ConeVolumeBounds.cpp | 7 +- Core/src/Geometry/CylinderVolumeBounds.cpp | 11 +- Core/src/Geometry/CylinderVolumeHelper.cpp | 8 +- Core/src/Geometry/CylinderVolumeStack.cpp | 3 +- Core/src/Geometry/Extent.cpp | 5 +- Core/src/Geometry/GridPortalLink.cpp | 16 ++- Core/src/Geometry/Polyhedron.cpp | 4 +- Core/src/Geometry/SurfaceArrayCreator.cpp | 19 +-- Core/src/Geometry/TrapezoidVolumeBounds.cpp | 23 ++-- Core/src/MagneticField/SolenoidBField.cpp | 7 +- .../Seeding/EstimateTrackParamsFromSeed.cpp | 4 +- Core/src/Surfaces/ConeSurface.cpp | 3 +- Core/src/Surfaces/CylinderBounds.cpp | 5 +- Core/src/Surfaces/PlaneSurface.cpp | 5 +- Core/src/Surfaces/StrawSurface.cpp | 3 +- .../Surfaces/detail/AnnulusBoundsHelper.cpp | 4 +- Core/src/Surfaces/detail/MergeHelper.cpp | 23 ++-- Core/src/Surfaces/detail/VerticesHelper.cpp | 6 +- Core/src/TrackFinding/MeasurementSelector.cpp | 3 +- Core/src/Vertexing/GaussianTrackDensity.cpp | 5 +- .../Vertexing/NumericalTrackLinearizer.cpp | 7 +- ...ScoreBasedAmbiguityResolutionAlgorithm.hpp | 5 +- .../ParametricParticleGenerator.hpp | 7 +- .../Generators/VertexGenerators.hpp | 5 +- .../Geometry/src/VolumeAssociationTest.cpp | 4 +- .../MappingMaterialDecorator.hpp | 9 +- .../MaterialMapping/MaterialValidation.hpp | 5 +- .../TrackFinding/HoughTransformSeeder.hpp | 9 +- .../TrackFinding/src/GbtsSeedingAlgorithm.cpp | 9 +- .../src/BuildGenericDetector.cpp | 9 +- .../src/MockupSectorBuilder.cpp | 8 +- Examples/Io/Csv/src/CsvSeedWriter.cpp | 8 +- .../Io/Root/src/RootTrackParameterWriter.cpp | 3 +- .../Io/Root/src/RootTrackStatesWriter.cpp | 3 +- .../Io/Root/src/RootTrackSummaryWriter.cpp | 6 +- Examples/Io/Root/src/VertexNTupleWriter.cpp | 5 +- Examples/Python/src/Geometry.cpp | 3 +- .../MaterialMapping/materialComposition.C | 5 +- .../TrackingPerformance/TrackSummary.cpp | 8 +- .../trackSummaryAnalysis.C | 3 +- Examples/Scripts/momentumDistributions.C | 4 +- .../Physics/ElectroMagnetic/BetheHeitler.hpp | 5 +- .../ElectroMagnetic/PhotonConversion.hpp | 5 +- .../Physics/ElectroMagnetic/Scattering.hpp | 5 +- .../detail/GaussianMixture.hpp | 3 +- .../ElectroMagnetic/detail/GeneralMixture.hpp | 3 +- .../ElectroMagnetic/detail/Highland.hpp | 4 +- .../NuclearInteraction/NuclearInteraction.hpp | 7 +- Fatras/src/Digitization/PlanarSurfaceMask.cpp | 3 +- Fatras/src/Physics/BetheHeitler.cpp | 3 +- .../Acts/Plugins/ActSVG/LayerSvgConverter.hpp | 6 +- .../ActSVG/src/SurfaceArraySvgConverter.cpp | 4 +- Plugins/DD4hep/src/DD4hepBinningHelpers.cpp | 15 ++- Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp | 5 +- .../Detray/src/DetrayMaterialConverter.cpp | 7 +- Plugins/EDM4hep/src/EDM4hepUtil.cpp | 7 +- Plugins/Geant4/src/Geant4Converters.cpp | 13 +- .../GeoModel/src/GeoModelToDetectorVolume.cpp | 10 +- .../src/detail/GeoModelBinningHelper.cpp | 6 +- .../Acts/Plugins/Hashing/HashingAnnoy.ipp | 5 +- Plugins/Json/src/MaterialJsonConverter.cpp | 7 +- Plugins/Json/src/MaterialMapJsonConverter.cpp | 19 +-- .../include/Acts/Seeding/AtlasSeedFinder.ipp | 5 +- .../Plugins/TGeo/TGeoSurfaceConverter.hpp | 5 +- Plugins/TGeo/src/TGeoCylinderDiscSplitter.cpp | 17 +-- Plugins/TGeo/src/TGeoSurfaceConverter.cpp | 12 +- Tests/Benchmarks/RayFrustumBenchmark.cpp | 19 +-- Tests/Benchmarks/SolenoidFieldBenchmark.cpp | 4 +- .../SurfaceIntersectionBenchmark.cpp | 8 +- .../Tests/CommonHelpers/BenchmarkTools.hpp | 4 +- .../CylindricalTrackingGeometry.hpp | 11 +- .../InterpolatedSolenoidBFieldTest.cpp | 9 +- .../IntegrationTests/NavigatorConsistency.cpp | 7 +- Tests/IntegrationTests/PropagationTests.hpp | 7 +- .../UnitTests/Core/Definitions/UnitsTests.cpp | 15 ++- .../CylindricalContainerBuilderTests.cpp | 17 ++- .../CylindricalDetectorHelperTests.cpp | 8 +- .../Detector/DetectorVolumeBuilderTests.cpp | 5 +- .../IndexedSurfaceGridFillerTests.cpp | 18 ++- .../IndexedSurfacesGeneratorTests.cpp | 31 +++-- .../Detector/LayerStructureBuilderTests.cpp | 13 +- .../MultiWireStructureBuilderTests.cpp | 3 +- .../Core/Detector/PortalGeneratorsTests.cpp | 3 +- .../Core/Detector/ProtoBinningTests.cpp | 7 +- .../Detector/SupportSurfacesHelperTests.cpp | 5 +- .../EventData/BoundTrackParametersTests.cpp | 3 +- .../CorrectedTransformFreeToBoundTests.cpp | 5 +- .../CurvilinearTrackParametersTests.cpp | 9 +- .../EventData/TrackParametersDatasets.hpp | 12 +- .../Core/EventData/TransformHelpersTests.cpp | 5 +- .../Core/Geometry/ConeLayerTests.cpp | 7 +- .../Core/Geometry/ConeVolumeBoundsTests.cpp | 19 ++- .../Geometry/CuboidVolumeBuilderTests.cpp | 5 +- .../Geometry/CylinderVolumeBoundsTests.cpp | 79 ++++++----- .../Geometry/CylinderVolumeStackTests.cpp | 18 ++- .../GenericCuboidVolumeBoundsTests.cpp | 11 +- .../Core/Geometry/LayerCreatorTests.cpp | 60 +++++---- .../Core/Geometry/PortalLinkTests.cpp | 17 ++- .../Core/Geometry/ProtoLayerTests.cpp | 17 ++- .../Geometry/SurfaceArrayCreatorTests.cpp | 75 ++++++----- .../Geometry/SurfaceBinningMatcherTests.cpp | 15 ++- .../Geometry/TrapezoidVolumeBoundsTests.cpp | 3 +- .../BinnedSurfaceMaterialAccumulaterTests.cpp | 4 +- .../Material/GridSurfaceMaterialTests.cpp | 21 +-- .../Core/Material/MaterialGridHelperTests.cpp | 7 +- .../Core/Material/MaterialValidaterTests.cpp | 3 +- .../Core/Propagator/CovarianceEngineTests.cpp | 18 ++- .../Core/Propagator/DirectNavigatorTests.cpp | 13 +- .../Core/Propagator/EigenStepperTests.cpp | 3 +- .../Core/Propagator/ExtrapolatorTests.cpp | 52 ++++---- .../Core/Propagator/LoopProtectionTests.cpp | 25 ++-- .../Propagator/MaterialCollectionTests.cpp | 13 +- .../Core/Propagator/MultiStepperTests.cpp | 23 ++-- .../Core/Propagator/PropagatorTests.cpp | 39 +++--- .../Core/Seeding/BinnedGroupTest.cpp | 5 +- .../UnitTests/Core/Seeding/PathSeederTest.cpp | 4 +- .../Core/Surfaces/ConeBoundsTests.cpp | 2 +- .../Core/TrackFinding/TrackSelectorTests.cpp | 4 +- .../TrackFitting/GainMatrixSmootherTests.cpp | 13 +- .../TrackFitting/GainMatrixUpdaterTests.cpp | 5 +- .../TrackFitting/GsfComponentMergingTests.cpp | 15 ++- .../UnitTests/Core/TrackFitting/Gx2fTests.cpp | 21 ++- .../Core/TrackFitting/MbfSmootherTests.cpp | 13 +- .../Core/Utilities/BinAdjustmentTests.cpp | 15 ++- .../Utilities/BinAdjustmentVolumeTests.cpp | 13 +- .../Core/Utilities/BinUtilityTests.cpp | 11 +- .../Core/Utilities/BinningDataTests.cpp | 95 ++++++------- .../Core/Utilities/BoundingBoxTest.cpp | 126 +++++++++--------- .../UnitTests/Core/Utilities/FrustumTest.cpp | 7 +- .../Utilities/GridAxisGeneratorsTests.cpp | 6 +- .../UnitTests/Core/Utilities/HelpersTests.cpp | 49 ++++--- .../Core/Utilities/PeriodicTests.cpp | 68 ++++++---- .../Core/Utilities/UnitVectorsTests.cpp | 87 +++++++----- .../AdaptiveGridTrackDensityTests.cpp | 8 +- .../AdaptiveMultiVertexFinderTests.cpp | 13 +- .../AdaptiveMultiVertexFitterTests.cpp | 6 +- .../FullBilloirVertexFitterTests.cpp | 6 +- .../GridDensityVertexFinderTests.cpp | 4 +- .../Vertexing/IterativeVertexFinderTests.cpp | 6 +- .../Vertexing/KalmanVertexUpdaterTests.cpp | 6 +- .../Vertexing/LinearizedTrackFactoryTests.cpp | 6 +- .../TrackDensityVertexFinderTests.cpp | 4 +- .../Core/Vertexing/ZScanVertexFinderTests.cpp | 6 +- .../Visualization/PrimitivesView3DTests.cpp | 7 +- .../Core/Visualization/SurfaceView3DBase.hpp | 5 +- .../Core/Visualization/VolumeView3DBase.hpp | 23 ++-- .../Digitization/PlanarSurfaceMaskTests.cpp | 10 +- .../Digitization/PlanarSurfaceTestBeds.hpp | 24 ++-- .../Fatras/Physics/ScatteringTests.cpp | 3 +- .../DetectorVolumeSvgConverterTests.cpp | 17 +-- .../Plugins/ActSVG/GridSvgConverterTests.cpp | 5 +- .../IndexedSurfacesSvgConverterTests.cpp | 15 ++- .../Plugins/ActSVG/LayerSvgConverterTests.cpp | 9 +- .../ActSVG/SurfaceSvgConverterTests.cpp | 7 +- .../Detray/DetrayGeometryConverterTests.cpp | 3 +- .../Detray/DetrayMaterialConverterTests.cpp | 12 +- .../EDM4hep/ConvertTrackEDM4hepTest.cpp | 18 ++- .../Plugins/Geant4/Geant4ConvertersTests.cpp | 27 ++-- .../Geant4DetectorSurfaceFactoryTests.cpp | 11 +- .../Json/DetectorJsonConverterTests.cpp | 21 +-- .../Json/DetectorVolumeJsonConverterTests.cpp | 15 ++- .../Plugins/Json/GridJsonConverterTests.cpp | 4 +- .../Json/MaterialJsonConverterTests.cpp | 21 +-- .../Json/ProtoDetectorJsonConverterTests.cpp | 11 +- .../Json/UtilitiesJsonConverterTests.cpp | 4 +- .../Json/VolumeBoundsJsonConverterTests.cpp | 9 +- .../Plugins/TGeo/TGeoTubeConversionTests.cpp | 5 +- 202 files changed, 1448 insertions(+), 1011 deletions(-) diff --git a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp index c5c0293b8ad..fbccb611d1a 100644 --- a/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp +++ b/Core/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -103,8 +104,8 @@ class ScoreBasedAmbiguityResolution { double pTMin = 0 * UnitConstants::GeV; double pTMax = 1e5 * UnitConstants::GeV; - double phiMin = -M_PI * UnitConstants::rad; - double phiMax = M_PI * UnitConstants::rad; + double phiMin = -std::numbers::pi * UnitConstants::rad; + double phiMax = std::numbers::pi * UnitConstants::rad; double etaMin = -5; double etaMax = 5; diff --git a/Core/include/Acts/Definitions/Units.hpp b/Core/include/Acts/Definitions/Units.hpp index c41aa7dd830..65d7cee775d 100644 --- a/Core/include/Acts/Definitions/Units.hpp +++ b/Core/include/Acts/Definitions/Units.hpp @@ -8,6 +8,8 @@ #pragma once +#include + namespace Acts { /// @verbatim embed:rst:leading-slashes @@ -170,7 +172,7 @@ constexpr double h = 3600.0 * s; // Angles, native unit radian constexpr double mrad = 1e-3; constexpr double rad = 1.0; -constexpr double degree = 0.017453292519943295; // = M_PI / 180.0 * rad; +constexpr double degree = std::numbers::pi / 180. / rad; // Energy/mass/momentum, native unit GeV constexpr double GeV = 1.0; constexpr double eV = 1e-9 * GeV; diff --git a/Core/include/Acts/EventData/TransformationHelpers.hpp b/Core/include/Acts/EventData/TransformationHelpers.hpp index 39240bf469e..e31e29fd3c0 100644 --- a/Core/include/Acts/EventData/TransformationHelpers.hpp +++ b/Core/include/Acts/EventData/TransformationHelpers.hpp @@ -15,6 +15,8 @@ #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/detail/periodic.hpp" +#include + namespace Acts { class Surface; @@ -25,8 +27,9 @@ class Surface; /// @return Reflected bound track parameters vector inline BoundVector reflectBoundParameters(const BoundVector& boundParams) { BoundVector reflected = boundParams; - auto [phi, theta] = detail::normalizePhiTheta( - boundParams[eBoundPhi] - M_PI, M_PI - boundParams[eBoundTheta]); + auto [phi, theta] = + detail::normalizePhiTheta(boundParams[eBoundPhi] - std::numbers::pi, + std::numbers::pi - boundParams[eBoundTheta]); reflected[eBoundPhi] = phi; reflected[eBoundTheta] = theta; reflected[eBoundQOverP] = -boundParams[eBoundQOverP]; diff --git a/Core/include/Acts/EventData/detail/ParameterTraits.hpp b/Core/include/Acts/EventData/detail/ParameterTraits.hpp index ae5eb8eeb30..ff3cdd81835 100644 --- a/Core/include/Acts/EventData/detail/ParameterTraits.hpp +++ b/Core/include/Acts/EventData/detail/ParameterTraits.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace Acts::detail { @@ -106,12 +107,12 @@ struct CyclicParameterTraits { // // The functions names are chosen to be consistent w/ std::numeric_limits struct PhiBoundParameterLimits { - static constexpr double lowest() { return -M_PI; } - static constexpr double max() { return M_PI; } + static constexpr double lowest() { return -std::numbers::pi; } + static constexpr double max() { return std::numbers::pi; } }; struct ThetaBoundParameterLimits { static constexpr double lowest() { return 0; } - static constexpr double max() { return M_PI; } + static constexpr double max() { return std::numbers::pi; } }; // Traits implementation structs for single parameters. diff --git a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp index 002af04cd59..7f368442f40 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -105,8 +106,9 @@ class CylinderVolumeBounds : public VolumeBounds { /// @param bevelMinZ The bevel angle, in radians, for the negative side /// @param bevelMaxZ The bevel angle, in radians, for the positive side CylinderVolumeBounds(ActsScalar rmin, ActsScalar rmax, ActsScalar halfz, - ActsScalar halfphi = M_PI, ActsScalar avgphi = 0., - ActsScalar bevelMinZ = 0., ActsScalar bevelMaxZ = 0.); + ActsScalar halfphi = std::numbers::pi_v, + ActsScalar avgphi = 0., ActsScalar bevelMinZ = 0., + ActsScalar bevelMaxZ = 0.); /// Constructor - from a fixed size array /// diff --git a/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp b/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp index bc52d700c72..584e8ee6992 100644 --- a/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp +++ b/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -257,7 +258,7 @@ class SurfaceArrayCreator { // ...so by injecting them into atan2, we get the angle between them auto dPhi = std::atan2(sin_dPhi_n2, cos_dPhi_n2); - return std::abs(dPhi) < M_PI / 180.; + return std::abs(dPhi) < std::numbers::pi / 180.; } if (bValue == Acts::BinningValue::binZ) { diff --git a/Core/include/Acts/Geometry/VolumeBounds.hpp b/Core/include/Acts/Geometry/VolumeBounds.hpp index 3b5810ff4c8..28bcc029166 100644 --- a/Core/include/Acts/Geometry/VolumeBounds.hpp +++ b/Core/include/Acts/Geometry/VolumeBounds.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -33,12 +34,14 @@ struct OrientedSurface { // Planar definitions to help construct the boundary surfaces static const Transform3 s_planeXY = Transform3::Identity(); -static const Transform3 s_planeYZ = AngleAxis3(0.5 * M_PI, Vector3::UnitY()) * - AngleAxis3(0.5 * M_PI, Vector3::UnitZ()) * - Transform3::Identity(); -static const Transform3 s_planeZX = AngleAxis3(-0.5 * M_PI, Vector3::UnitX()) * - AngleAxis3(-0.5 * M_PI, Vector3::UnitZ()) * - Transform3::Identity(); +static const Transform3 s_planeYZ = + AngleAxis3(std::numbers::pi / 2., Vector3::UnitY()) * + AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()) * + Transform3::Identity(); +static const Transform3 s_planeZX = + AngleAxis3(-std::numbers::pi / 2., Vector3::UnitX()) * + AngleAxis3(-std::numbers::pi / 2., Vector3::UnitZ()) * + Transform3::Identity(); /// @class VolumeBounds /// diff --git a/Core/include/Acts/Propagator/RiddersPropagator.ipp b/Core/include/Acts/Propagator/RiddersPropagator.ipp index cef7c79bd4f..1b1764a13d7 100644 --- a/Core/include/Acts/Propagator/RiddersPropagator.ipp +++ b/Core/include/Acts/Propagator/RiddersPropagator.ipp @@ -8,6 +8,8 @@ #include "Acts/Definitions/TrackParametrization.hpp" +#include + template template auto Acts::RiddersPropagator::propagate( @@ -150,8 +152,8 @@ bool Acts::RiddersPropagator::inconsistentDerivativesOnDisc( for (unsigned int j = 0; j < derivatives.size(); j++) { // If there is at least one with a similar angle then it seems to work // properly - if (i != j && - std::abs(derivatives[i](1) - derivatives[j](1)) < 0.5 * M_PI) { + if (i != j && std::abs(derivatives[i](1) - derivatives[j](1)) < + std::numbers::pi / 2.) { jumpedAngle = false; break; } @@ -179,8 +181,8 @@ Acts::RiddersPropagator::wiggleParameter( // Treatment for theta if (param == eBoundTheta) { const double current_theta = start.template get(); - if (current_theta + h > M_PI) { - h = M_PI - current_theta; + if (current_theta + h > std::numbers::pi) { + h = std::numbers::pi - current_theta; } if (current_theta + h < 0) { h = -current_theta; @@ -202,10 +204,14 @@ Acts::RiddersPropagator::wiggleParameter( if (param == eBoundPhi) { double phi0 = nominal(Acts::eBoundPhi); double phi1 = r.endParameters->parameters()(Acts::eBoundPhi); - if (std::abs(phi1 + 2. * M_PI - phi0) < std::abs(phi1 - phi0)) { - derivatives.back()[Acts::eBoundPhi] = (phi1 + 2. * M_PI - phi0) / h; - } else if (std::abs(phi1 - 2. * M_PI - phi0) < std::abs(phi1 - phi0)) { - derivatives.back()[Acts::eBoundPhi] = (phi1 - 2. * M_PI - phi0) / h; + if (std::abs(phi1 + 2. * std::numbers::pi - phi0) < + std::abs(phi1 - phi0)) { + derivatives.back()[Acts::eBoundPhi] = + (phi1 + 2. * std::numbers::pi - phi0) / h; + } else if (std::abs(phi1 - 2. * std::numbers::pi - phi0) < + std::abs(phi1 - phi0)) { + derivatives.back()[Acts::eBoundPhi] = + (phi1 - 2. * std::numbers::pi - phi0) / h; } } } diff --git a/Core/include/Acts/Propagator/detail/LoopProtection.hpp b/Core/include/Acts/Propagator/detail/LoopProtection.hpp index a5efe15306e..62c7e363423 100644 --- a/Core/include/Acts/Propagator/detail/LoopProtection.hpp +++ b/Core/include/Acts/Propagator/detail/LoopProtection.hpp @@ -11,6 +11,8 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Utilities/Logger.hpp" +#include + namespace Acts::detail { /// Estimate the loop protection limit @@ -46,7 +48,8 @@ void setupLoopProtection(propagator_state_t& state, const stepper_t& stepper, // Transverse component at start is taken for the loop protection const double p = stepper.absoluteMomentum(state.stepping); // Calculate the full helix path - const double helixPath = state.options.direction * 2 * M_PI * p / B; + const double helixPath = + state.options.direction * 2 * std::numbers::pi * p / B; // And set it as the loop limit if it overwrites the internal limit const double loopLimit = state.options.loopFraction * helixPath; const double previousLimit = pathAborter.internalLimit; diff --git a/Core/include/Acts/Seeding/GbtsDataStorage.hpp b/Core/include/Acts/Seeding/GbtsDataStorage.hpp index 64ba0bff1b9..c28b0cc2413 100644 --- a/Core/include/Acts/Seeding/GbtsDataStorage.hpp +++ b/Core/include/Acts/Seeding/GbtsDataStorage.hpp @@ -14,6 +14,7 @@ #include #include +#include #include namespace Acts { @@ -117,12 +118,12 @@ class GbtsEtaBin { // float phi = pN->m_sp.phi(); // float phi = (std::atan(pN->m_sp.x() / pN->m_sp.y())); float phi = pN->m_spGbts.phi(); - if (phi <= M_PI - dphi) { + if (phi <= std::numbers::pi_v - dphi) { continue; } - m_vPhiNodes.push_back( - std::pair(phi - 2 * M_PI, nIdx)); + m_vPhiNodes.push_back(std::pair( + phi - static_cast(2. * std::numbers::pi), nIdx)); } for (unsigned int nIdx = 0; nIdx < m_vn.size(); nIdx++) { @@ -134,11 +135,11 @@ class GbtsEtaBin { for (unsigned int nIdx = 0; nIdx < m_vn.size(); nIdx++) { GbtsNode *pN = m_vn.at(nIdx); float phi = pN->m_spGbts.phi(); - if (phi >= -M_PI + dphi) { + if (phi >= -std::numbers::pi_v + dphi) { break; } - m_vPhiNodes.push_back( - std::pair(phi + 2 * M_PI, nIdx)); + m_vPhiNodes.push_back(std::pair( + phi + static_cast(2. * std::numbers::pi), nIdx)); } } diff --git a/Core/include/Acts/Seeding/SeedFinderConfig.hpp b/Core/include/Acts/Seeding/SeedFinderConfig.hpp index bb20f9fead0..93dacaeafd8 100644 --- a/Core/include/Acts/Seeding/SeedFinderConfig.hpp +++ b/Core/include/Acts/Seeding/SeedFinderConfig.hpp @@ -15,6 +15,7 @@ #include #include +#include #include namespace Acts { @@ -33,8 +34,8 @@ struct SeedFinderConfig { /// Geometry Settings + Detector ROI /// (r, z, phi) range for limiting location of all measurements and grid /// creation - float phiMin = -M_PI; - float phiMax = M_PI; + float phiMin = -std::numbers::pi_v; + float phiMax = std::numbers::pi_v; float zMin = -2800 * Acts::UnitConstants::mm; float zMax = 2800 * Acts::UnitConstants::mm; float rMax = 600 * Acts::UnitConstants::mm; diff --git a/Core/include/Acts/Seeding/SeedFinderGbts.ipp b/Core/include/Acts/Seeding/SeedFinderGbts.ipp index ab557d86977..ed2fe157acf 100644 --- a/Core/include/Acts/Seeding/SeedFinderGbts.ipp +++ b/Core/include/Acts/Seeding/SeedFinderGbts.ipp @@ -9,7 +9,6 @@ // SeedFinderGbts.ipp // TODO: update to C++17 style -#include "Acts/Definitions/Algebra.hpp" //for M_PI #include "Acts/Geometry/Extent.hpp" #include "Acts/Seeding/SeedFilter.hpp" #include "Acts/Seeding/SeedFinder.hpp" @@ -23,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +54,7 @@ void SeedFinderGbts::loadSpacePoints( m_storage->addSpacePoint(gbtssp, (m_config.m_useClusterWidth > 0)); } - m_config.m_phiSliceWidth = 2 * M_PI / m_config.m_nMaxPhiSlice; + m_config.m_phiSliceWidth = 2 * std::numbers::pi / m_config.m_nMaxPhiSlice; m_storage->sortByPhi(); @@ -390,10 +390,10 @@ void SeedFinderGbts::runGbts_TrackFinder( float dPhi = pNS->m_p[3] - Phi1; - if (dPhi < -M_PI) { - dPhi += 2 * M_PI; - } else if (dPhi > M_PI) { - dPhi -= 2 * M_PI; + if (dPhi < -std::numbers::pi_v) { + dPhi += static_cast(2 * std::numbers::pi); + } else if (dPhi > std::numbers::pi_v) { + dPhi -= static_cast(2 * std::numbers::pi); } if (dPhi < -m_config.cut_dphi_max || dPhi > m_config.cut_dphi_max) { diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonalConfig.hpp b/Core/include/Acts/Seeding/SeedFinderOrthogonalConfig.hpp index 4bb710abc78..ac0b51f5d34 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonalConfig.hpp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonalConfig.hpp @@ -14,6 +14,7 @@ #include "Acts/Utilities/Delegate.hpp" #include +#include namespace Acts { // forward declaration to avoid cyclic dependence @@ -28,8 +29,8 @@ struct SeedFinderOrthogonalConfig { /// Seeding parameters for geometry settings and detector ROI // Limiting location of all measurements - float phiMin = -M_PI; - float phiMax = M_PI; + float phiMin = -std::numbers::pi_v; + float phiMax = std::numbers::pi_v; /// limiting location of measurements float zMin = -2800 * Acts::UnitConstants::mm; float zMax = 2800 * Acts::UnitConstants::mm; diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp index a2a214fa39b..dcbe2289ffb 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp @@ -71,7 +71,7 @@ struct CylindricalSpacePointGridConfig { // maximum phi value for phiAxis construction float phiMax = std::numbers::pi_v; // Multiplicator for the number of phi-bins. The minimum number of phi-bins - // depends on min_pt, magnetic field: 2*M_PI/(minPT particle phi-deflection). + // depends on min_pt, magnetic field: 2*pi/(minPT particle phi-deflection). // phiBinDeflectionCoverage is a multiplier for this number. If // numPhiNeighbors (in the configuration of the BinFinders) is configured to // return 1 neighbor on either side of the current phi-bin (and you want to diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp index b99cdbdfaf9..2a8f3dad41d 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp @@ -7,6 +7,7 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. #include +#include template Acts::CylindricalSpacePointGrid @@ -91,16 +92,14 @@ Acts::CylindricalSpacePointGridCreator::createGrid( // divide 2pi by angle delta to get number of phi-bins // size is always 2pi even for regions of interest - phiBins = static_cast(std::ceil(2 * M_PI / deltaPhi)); + phiBins = static_cast(std::ceil(2 * std::numbers::pi / deltaPhi)); // need to scale the number of phi bins accordingly to the number of // consecutive phi bins in the seed making step. // Each individual bin should be approximately a fraction (depending on this // number) of the maximum expected azimutal deflection. // set protection for large number of bins, by default it is large - if (phiBins > config.maxPhiBins) { - phiBins = config.maxPhiBins; - } + phiBins = std::min(phiBins, config.maxPhiBins); } Acts::Axis phiAxis( diff --git a/Core/include/Acts/Surfaces/AnnulusBounds.hpp b/Core/include/Acts/Surfaces/AnnulusBounds.hpp index f1283ec63b8..942c20dc764 100644 --- a/Core/include/Acts/Surfaces/AnnulusBounds.hpp +++ b/Core/include/Acts/Surfaces/AnnulusBounds.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -231,7 +232,7 @@ inline double AnnulusBounds::phiMax() const { } inline bool AnnulusBounds::coversFullAzimuth() const { - return (std::abs((get(eMinPhiRel) - get(eMaxPhiRel)) - M_PI) < + return (std::abs((get(eMinPhiRel) - get(eMaxPhiRel)) - std::numbers::pi) < s_onSurfaceTolerance); } diff --git a/Core/include/Acts/Surfaces/ConeBounds.hpp b/Core/include/Acts/Surfaces/ConeBounds.hpp index 55b2203686c..d0d684016a8 100644 --- a/Core/include/Acts/Surfaces/ConeBounds.hpp +++ b/Core/include/Acts/Surfaces/ConeBounds.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -55,7 +56,7 @@ class ConeBounds : public SurfaceBounds { /// @param halfphi is the half opening angle (default is pi) /// @param avphi is the phi value around which the bounds are opened /// (default=0) - ConeBounds(double alpha, bool symm, double halfphi = M_PI, + ConeBounds(double alpha, bool symm, double halfphi = std::numbers::pi, double avphi = 0.) noexcept(false); /// Constructor - open cone with alpha, minz and maxz, by @@ -67,7 +68,8 @@ class ConeBounds : public SurfaceBounds { /// @param halfphi is the half opening angle (default is pi) /// @param avphi is the phi value around which the bounds are opened /// (default=0) - ConeBounds(double alpha, double minz, double maxz, double halfphi = M_PI, + ConeBounds(double alpha, double minz, double maxz, + double halfphi = std::numbers::pi, double avphi = 0.) noexcept(false); /// Constructor - from parameters array @@ -141,14 +143,14 @@ inline std::vector ConeBounds::values() const { } inline void ConeBounds::checkConsistency() noexcept(false) { - if (get(eAlpha) < 0. || get(eAlpha) >= M_PI) { + if (get(eAlpha) < 0. || get(eAlpha) >= std::numbers::pi) { throw std::invalid_argument("ConeBounds: invalid open angle."); } if (get(eMinZ) > get(eMaxZ) || std::abs(get(eMinZ) - get(eMaxZ)) < s_epsilon) { throw std::invalid_argument("ConeBounds: invalid z range setup."); } - if (get(eHalfPhiSector) < 0. || abs(eHalfPhiSector) > M_PI) { + if (get(eHalfPhiSector) < 0. || abs(eHalfPhiSector) > std::numbers::pi) { throw std::invalid_argument("ConeBounds: invalid phi sector setup."); } if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { diff --git a/Core/include/Acts/Surfaces/ConeSurface.hpp b/Core/include/Acts/Surfaces/ConeSurface.hpp index a2b2572bba8..2f88bfe9532 100644 --- a/Core/include/Acts/Surfaces/ConeSurface.hpp +++ b/Core/include/Acts/Surfaces/ConeSurface.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include namespace Acts { @@ -61,7 +62,7 @@ class ConeSurface : public RegularSurface { /// @param zmax is the z range over which the cone spans /// @param halfPhi is the opening angle for cone ssectors ConeSurface(const Transform3& transform, double alpha, double zmin, - double zmax, double halfPhi = M_PI); + double zmax, double halfPhi = std::numbers::pi); /// Constructor from HepTransform and ConeBounds /// diff --git a/Core/include/Acts/Surfaces/CylinderBounds.hpp b/Core/include/Acts/Surfaces/CylinderBounds.hpp index 51508055e06..d144c8b995b 100644 --- a/Core/include/Acts/Surfaces/CylinderBounds.hpp +++ b/Core/include/Acts/Surfaces/CylinderBounds.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -69,11 +70,11 @@ class CylinderBounds : public SurfaceBounds { /// @param avgPhi (optional) The phi value from which the opening angle spans /// @param bevelMinZ (optional) The bevel on the negative z side /// @param bevelMaxZ (optional) The bevel on the positive z sid The bevel on the positive z side - CylinderBounds(double r, double halfZ, double halfPhi = M_PI, + CylinderBounds(double r, double halfZ, double halfPhi = std::numbers::pi, double avgPhi = 0., double bevelMinZ = 0., double bevelMaxZ = 0.) noexcept(false) : m_values({r, halfZ, halfPhi, avgPhi, bevelMinZ, bevelMaxZ}), - m_closed(std::abs(halfPhi - M_PI) < s_epsilon) { + m_closed(std::abs(halfPhi - std::numbers::pi) < s_epsilon) { checkConsistency(); } @@ -82,7 +83,8 @@ class CylinderBounds : public SurfaceBounds { /// @param values The parameter values CylinderBounds(const std::array& values) noexcept(false) : m_values(values), - m_closed(std::abs(values[eHalfPhiSector] - M_PI) < s_epsilon) { + m_closed(std::abs(values[eHalfPhiSector] - std::numbers::pi) < + s_epsilon) { checkConsistency(); } diff --git a/Core/include/Acts/Surfaces/CylinderSurface.hpp b/Core/include/Acts/Surfaces/CylinderSurface.hpp index 09b953afce1..53c52f13f50 100644 --- a/Core/include/Acts/Surfaces/CylinderSurface.hpp +++ b/Core/include/Acts/Surfaces/CylinderSurface.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include namespace Acts { @@ -57,7 +58,7 @@ class CylinderSurface : public RegularSurface { /// @param bevelMinZ (optional) The bevel on the negative z side /// @param bevelMaxZ (optional) The bevel on the positive z sid The bevel on the positive z side CylinderSurface(const Transform3& transform, double radius, double halfz, - double halfphi = M_PI, double avphi = 0., + double halfphi = std::numbers::pi, double avphi = 0., double bevelMinZ = 0., double bevelMaxZ = 0.); /// Constructor from Transform3 and CylinderBounds arguments diff --git a/Core/include/Acts/Surfaces/DiscSurface.hpp b/Core/include/Acts/Surfaces/DiscSurface.hpp index e2c10df4023..d2db14fc566 100644 --- a/Core/include/Acts/Surfaces/DiscSurface.hpp +++ b/Core/include/Acts/Surfaces/DiscSurface.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace Acts { @@ -64,7 +65,7 @@ class DiscSurface : public RegularSurface { /// @param hphisec The opening angle of the disc surface and is optional /// the default is a full disc DiscSurface(const Transform3& transform, double rmin, double rmax, - double hphisec = M_PI); + double hphisec = std::numbers::pi); /// Constructor for Discs from Transform3, \f$ r_{min}, r_{max}, hx_{min}, /// hx_{max} \f$ diff --git a/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp b/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp index a3e4e5ea28f..32c63c2aef6 100644 --- a/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp +++ b/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,7 @@ class DiscTrapezoidBounds : public DiscBounds { /// @param avgPhi average phi value /// @param stereo optional stero angle applied DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR, - double maxR, double avgPhi = M_PI_2, + double maxR, double avgPhi = std::numbers::pi / 2., double stereo = 0.) noexcept(false); /// Constructor - from fixed size array diff --git a/Core/include/Acts/Surfaces/EllipseBounds.hpp b/Core/include/Acts/Surfaces/EllipseBounds.hpp index aec08d10381..ea90e3d2a88 100644 --- a/Core/include/Acts/Surfaces/EllipseBounds.hpp +++ b/Core/include/Acts/Surfaces/EllipseBounds.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -57,7 +58,8 @@ class EllipseBounds : public PlanarBounds { /// @param halfPhi spanning phi sector (is set to pi as default) /// @param averagePhi average phi (is set to 0. as default) EllipseBounds(double innerRx, double innerRy, double outerRx, double outerRy, - double halfPhi = M_PI, double averagePhi = 0.) noexcept(false) + double halfPhi = std::numbers::pi, + double averagePhi = 0.) noexcept(false) : m_values({innerRx, innerRy, outerRx, outerRy, halfPhi, averagePhi}), m_boundingBox(m_values[eInnerRy], m_values[eOuterRy]) { checkConsistency(); @@ -134,7 +136,7 @@ inline void EllipseBounds::checkConsistency() noexcept(false) { get(eOuterRy) <= 0.) { throw std::invalid_argument("EllipseBounds: invalid along y axis."); } - if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > M_PI) { + if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { throw std::invalid_argument("EllipseBounds: invalid phi sector setup."); } if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { diff --git a/Core/include/Acts/Surfaces/RadialBounds.hpp b/Core/include/Acts/Surfaces/RadialBounds.hpp index 0c7aea81400..ef3e8996572 100644 --- a/Core/include/Acts/Surfaces/RadialBounds.hpp +++ b/Core/include/Acts/Surfaces/RadialBounds.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ class RadialBounds : public DiscBounds { /// @param maxR The outer radius /// @param halfPhi The half opening angle (Pi for full angular coverage) /// @param avgPhi The average phi for the disc/ring sector - RadialBounds(double minR, double maxR, double halfPhi = M_PI, + RadialBounds(double minR, double maxR, double halfPhi = std::numbers::pi, double avgPhi = 0.) noexcept(false) : m_values({minR, maxR, halfPhi, avgPhi}) { checkConsistency(); @@ -142,7 +143,7 @@ inline double RadialBounds::rMax() const { } inline bool RadialBounds::coversFullAzimuth() const { - return (get(eHalfPhiSector) == M_PI); + return (get(eHalfPhiSector) == std::numbers::pi); } inline bool RadialBounds::insideRadialBounds(double R, double tolerance) const { @@ -167,7 +168,7 @@ inline void RadialBounds::checkConsistency() noexcept(false) { if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) { throw std::invalid_argument("RadialBounds: invalid radial setup"); } - if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > M_PI) { + if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { throw std::invalid_argument("RadialBounds: invalid phi sector setup."); } if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { diff --git a/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp b/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp index dd18f3e800e..4384c17139c 100644 --- a/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp +++ b/Core/include/Acts/Surfaces/detail/VerticesHelper.hpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -29,10 +30,11 @@ namespace Acts::detail::VerticesHelper { /// @param quarterSegments number of segments used to approximate a segment quarter /// /// @return a vector of generated phi values -std::vector phiSegments(ActsScalar phiMin = -M_PI, - ActsScalar phiMax = M_PI, - const std::vector& phiRefs = {}, - unsigned int quarterSegments = 2u); +std::vector phiSegments( + ActsScalar phiMin = -std::numbers::pi_v, + ActsScalar phiMax = std::numbers::pi_v, + const std::vector& phiRefs = {}, + unsigned int quarterSegments = 2u); /// Helper method to create a regular 2 or 3 D segment /// between two phi values with a given number of segments @@ -83,11 +85,11 @@ std::vector segmentVertices( /// @param quarterSegments number of segments used to approximate a segment quarter /// /// @return a vector of 2d-vectors -std::vector ellipsoidVertices(ActsScalar innerRx, ActsScalar innerRy, - ActsScalar outerRx, ActsScalar outerRy, - ActsScalar avgPhi = 0., - ActsScalar halfPhi = M_PI, - unsigned int quarterSegments = 2u); +std::vector ellipsoidVertices( + ActsScalar innerRx, ActsScalar innerRy, ActsScalar outerRx, + ActsScalar outerRy, ActsScalar avgPhi = 0., + ActsScalar halfPhi = std::numbers::pi_v, + unsigned int quarterSegments = 2u); /// Construct vertices on an disc/wheel-like bound object. /// @@ -98,10 +100,10 @@ std::vector ellipsoidVertices(ActsScalar innerRx, ActsScalar innerRy, /// @param quarterSegments number of segments used to approximate a segment quarter /// /// @return a vector of 2d-vectors -std::vector circularVertices(ActsScalar innerR, ActsScalar outerR, - ActsScalar avgPhi = 0., - ActsScalar halfPhi = M_PI, - unsigned int quarterSegments = 2u); +std::vector circularVertices( + ActsScalar innerR, ActsScalar outerR, ActsScalar avgPhi = 0., + ActsScalar halfPhi = std::numbers::pi_v, + unsigned int quarterSegments = 2u); /// Check if the point is inside the polygon w/o any tolerances. /// diff --git a/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp b/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp index 666ebf6aa23..5d0c5601bea 100644 --- a/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp +++ b/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +87,7 @@ struct BetheHeitlerApproxSingleCmp { ret[0].weight = 1.0; - const double c = x / std::log(2); + const double c = x / std::numbers::ln2; ret[0].mean = std::pow(2, -c); ret[0].var = std::pow(3, -c) - std::pow(4, -c); diff --git a/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp b/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp index 019865f49c1..b7ea835e460 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfComponentMerging.hpp @@ -15,6 +15,7 @@ #include "Acts/Utilities/detail/periodic.hpp" #include +#include #include #include @@ -90,10 +91,10 @@ auto gaussianMixtureCov(const components_t components, // Apply corrections for cyclic coordinates auto handleCyclicCov = [&l = pars_l, &m = mean, &diff = diff](auto desc) { - diff[desc.idx] = - difference_periodic(l[desc.idx] / desc.constant, - m[desc.idx] / desc.constant, 2 * M_PI) * - desc.constant; + diff[desc.idx] = difference_periodic(l[desc.idx] / desc.constant, + m[desc.idx] / desc.constant, + 2 * std::numbers::pi) * + desc.constant; }; std::apply([&](auto... dsc) { (handleCyclicCov(dsc), ...); }, angleDesc); @@ -174,10 +175,10 @@ auto gaussianMixtureMeanCov(const components_t components, &weight = weight_l, &mean = mean](auto desc) { const auto delta = (ref[desc.idx] - pars[desc.idx]) / desc.constant; - if (delta > M_PI) { - mean[desc.idx] += (2 * M_PI) * weight * desc.constant; - } else if (delta < -M_PI) { - mean[desc.idx] -= (2 * M_PI) * weight * desc.constant; + if (delta > std::numbers::pi) { + mean[desc.idx] += 2. * std::numbers::pi * weight * desc.constant; + } else if (delta < -std::numbers::pi) { + mean[desc.idx] -= 2. * std::numbers::pi * weight * desc.constant; } }; @@ -187,9 +188,9 @@ auto gaussianMixtureMeanCov(const components_t components, mean /= sumOfWeights; auto wrap = [&](auto desc) { - mean[desc.idx] = - wrap_periodic(mean[desc.idx] / desc.constant, -M_PI, 2 * M_PI) * - desc.constant; + mean[desc.idx] = wrap_periodic(mean[desc.idx] / desc.constant, + -std::numbers::pi, 2 * std::numbers::pi) * + desc.constant; }; std::apply([&](auto... dsc) { (wrap(dsc), ...); }, angleDesc); diff --git a/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp b/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp index 7e115e7b607..bef7bff3e83 100644 --- a/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp +++ b/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp @@ -19,6 +19,7 @@ #include "Acts/Geometry/Volume.hpp" #include "Acts/Utilities/BinUtility.hpp" +#include #include namespace Acts { @@ -94,8 +95,8 @@ BinUtility adjustBinUtility(const BinUtility& bu, // The parameters from the cutout cylinder bounds double minR = cBounds.get(CutoutCylinderVolumeBounds::eMinR); double maxR = cBounds.get(CutoutCylinderVolumeBounds::eMaxR); - double minPhi = -M_PI; - double maxPhi = M_PI; + double minPhi = -std::numbers::pi; + double maxPhi = std::numbers::pi; double minZ = -cBounds.get(CutoutCylinderVolumeBounds::eHalfLengthZ); double maxZ = cBounds.get(CutoutCylinderVolumeBounds::eHalfLengthZ); // Retrieve the binning data diff --git a/Core/include/Acts/Utilities/Frustum.ipp b/Core/include/Acts/Utilities/Frustum.ipp index 5854ef2d94a..bca40c35464 100644 --- a/Core/include/Acts/Utilities/Frustum.ipp +++ b/Core/include/Acts/Utilities/Frustum.ipp @@ -8,6 +8,8 @@ #include "Acts/Utilities/VectorHelpers.hpp" +#include + template Acts::Frustum::Frustum(const VertexType& origin, const VertexType& dir, @@ -17,13 +19,13 @@ Acts::Frustum::Frustum(const VertexType& origin, using rotation_t = Eigen::Rotation2D; static_assert(SIDES == 2, "2D frustum can only have 2 sides"); - assert(opening_angle < M_PI); + assert(opening_angle < std::numbers::pi_v); translation_t translation(origin); value_type angle = VectorHelpers::phi(dir); Eigen::Rotation2D rot(angle); - value_type normal_angle = 0.5 * M_PI - 0.5 * opening_angle; + value_type normal_angle = std::numbers::pi / 2. - opening_angle / 2.; VertexType normal1 = rotation_t(normal_angle) * VertexType::UnitX(); VertexType normal2 = rotation_t(-normal_angle) * VertexType::UnitX(); @@ -37,7 +39,7 @@ Acts::Frustum::Frustum(const VertexType& origin, requires(DIM == 3) : m_origin(origin) { static_assert(SIDES > 2, "3D frustum must have 3 or more sides"); - assert(opening_angle < M_PI); + assert(opening_angle < std::numbers::pi_v); using angle_axis_t = Eigen::AngleAxis; const VertexType ldir = VertexType::UnitZ(); @@ -48,7 +50,7 @@ Acts::Frustum::Frustum(const VertexType& origin, m_normals[0] = ldir; - const value_type phi_sep = 2 * M_PI / sides; + const value_type phi_sep = 2. * std::numbers::pi_v / sides; transform_type rot; rot = angle_axis_t(phi_sep, ldir); diff --git a/Core/include/Acts/Utilities/detail/periodic.hpp b/Core/include/Acts/Utilities/detail/periodic.hpp index b128a1e7cc4..a2fdd823b48 100644 --- a/Core/include/Acts/Utilities/detail/periodic.hpp +++ b/Core/include/Acts/Utilities/detail/periodic.hpp @@ -9,6 +9,7 @@ #pragma once #include +#include namespace Acts::detail { @@ -49,13 +50,13 @@ inline T difference_periodic(T lhs, T rhs, T range) { /// Calculate the equivalent angle in the [0, 2*pi) range. template inline T radian_pos(T x) { - return wrap_periodic(x, T{0}, T{2 * M_PI}); + return wrap_periodic(x, T{0}, T{2 * std::numbers::pi}); } /// Calculate the equivalent angle in the [-pi, pi) range. template inline T radian_sym(T x) { - return wrap_periodic(x, T{-M_PI}, T{2 * M_PI}); + return wrap_periodic(x, -std::numbers::pi_v, T{2 * std::numbers::pi}); } /// Ensure both phi and theta direction angles are within the allowed range. @@ -81,11 +82,11 @@ inline std::pair normalizePhiTheta(T phi, T theta) { // moving it first to the periodic range simplifies further steps as the // possible range of theta becomes fixed. theta = radian_pos(theta); - if (M_PI < theta) { + if (std::numbers::pi_v < theta) { // theta is in the second half of the great circle and outside its nominal // range. need to change both phi and theta to be within range. - phi += M_PI; - theta = 2 * M_PI - theta; + phi += std::numbers::pi_v; + theta = T{2 * std::numbers::pi} - theta; } return {radian_sym(phi), theta}; } diff --git a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp index ed5bfeeffba..83b13d37d57 100644 --- a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -85,8 +86,8 @@ Acts::SingleSeedVertexFinder::sortSpacepoints( for (const auto& sp : spacepoints) { // phi will be saved for later Acts::ActsScalar phi = detail::radian_pos(std::atan2(sp.y(), sp.x())); - std::uint32_t phislice = - static_cast(phi / (2 * M_PI) * m_cfg.numPhiSlices); + std::uint32_t phislice = static_cast( + phi / (2 * std::numbers::pi) * m_cfg.numPhiSlices); if (phislice >= m_cfg.numPhiSlices) { phislice = 0; } @@ -134,7 +135,7 @@ Acts::SingleSeedVertexFinder::findTriplets( std::uint32_t phiStep = static_cast(m_cfg.maxPhideviation / - (2 * M_PI / m_cfg.numPhiSlices)) + + (2 * std::numbers::pi / m_cfg.numPhiSlices)) + 1; // calculate limits for middle spacepoints @@ -194,7 +195,7 @@ Acts::SingleSeedVertexFinder::findTriplets( Acts::ActsScalar angleZfrom = std::atan2(rMiddle[isLessFrom], deltaZfrom) + m_cfg.maxXYZdeviation; std::uint32_t nearZFrom = 0; - if (angleZfrom < M_PI) { + if (angleZfrom < std::numbers::pi_v) { Acts::ActsScalar new_deltaZfrom = rMiddle[isLessFrom] / std::tan(angleZfrom) / zBinLength; nearZFrom = static_cast(std::max( @@ -217,8 +218,8 @@ Acts::SingleSeedVertexFinder::findTriplets( } for (std::uint32_t nearZ = nearZFrom; nearZ < nearZTo; ++nearZ) { - // calculate limits for far spacepoits, assuming middle and near - // spacepoits are within some boundaries + // calculate limits for far spacepoints, assuming middle and near + // spacepoints are within some boundaries bool isMiddleLess = (middleZ <= nearZ); Acts::ActsScalar delta2Zfrom = (middleZ - nearZ - 1) * zBinLength; @@ -226,7 +227,7 @@ Acts::SingleSeedVertexFinder::findTriplets( std::atan2(rFarDelta[isMiddleLess], delta2Zfrom) + m_cfg.maxXYZdeviation; std::uint32_t farZFrom = 0; - if (angle2Zfrom < M_PI) { + if (angle2Zfrom < std::numbers::pi_v) { farZFrom = static_cast(std::max( (rFarDelta[isMiddleLess] / std::tan(angle2Zfrom) / zBinLength) + middleZ, @@ -287,8 +288,8 @@ Acts::SingleSeedVertexFinder::findTriplets( for (const auto& middleSP : sortedSpacepoints.getSP(1, middlePhi, middleZ)) { Acts::ActsScalar phiB = middleSP.second; - Acts::ActsScalar deltaPhiAB = - detail::difference_periodic(phiA, phiB, 2 * M_PI); + Acts::ActsScalar deltaPhiAB = detail::difference_periodic( + phiA, phiB, 2 * std::numbers::pi); if (std::abs(deltaPhiAB) > m_cfg.maxPhideviation) { continue; } @@ -297,8 +298,9 @@ Acts::SingleSeedVertexFinder::findTriplets( for (const auto& farSP : sortedSpacepoints.getSP(2, farPhi, farZ)) { Acts::ActsScalar phiC = farSP.second; - Acts::ActsScalar deltaPhiBC = - detail::difference_periodic(phiB, phiC, 2 * M_PI); + Acts::ActsScalar deltaPhiBC = detail::difference_periodic( + phiB, phiC, + static_cast(2 * std::numbers::pi)); if (std::abs(deltaPhiBC) > m_cfg.maxPhideviation) { continue; } @@ -332,8 +334,8 @@ bool Acts::SingleSeedVertexFinder::tripletValidationAndUpdate( Acts::ActsScalar alpha2 = std::atan2(triplet.b.y() - triplet.c.y(), triplet.b.x() - triplet.c.x()); // these two slopes shouldn't be too different - Acts::ActsScalar deltaAlpha = - detail::difference_periodic(alpha1, alpha2, 2 * M_PI); + Acts::ActsScalar deltaAlpha = detail::difference_periodic( + alpha1, alpha2, static_cast(2 * std::numbers::pi)); if (std::abs(deltaAlpha) > m_cfg.maxXYdeviation) { return false; } diff --git a/Core/include/Acts/Visualization/EventDataView3D.hpp b/Core/include/Acts/Visualization/EventDataView3D.hpp index 9d62d57ea82..3d8282bb255 100644 --- a/Core/include/Acts/Visualization/EventDataView3D.hpp +++ b/Core/include/Acts/Visualization/EventDataView3D.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -81,9 +82,9 @@ struct EventDataView3D { // Now generate the ellipse points std::vector ellipse; ellipse.reserve(lseg); - double thetaStep = 2 * M_PI / lseg; + double thetaStep = 2 * std::numbers::pi / lseg; for (std::size_t it = 0; it < lseg; ++it) { - double phi = -M_PI + it * thetaStep; + double phi = -std::numbers::pi + it * thetaStep; double cphi = std::cos(phi); double sphi = std::sin(phi); double x = lposition.x() + (l1sq * ctheta * cphi - l2sq * stheta * sphi); diff --git a/Core/src/Detector/VolumeStructureBuilder.cpp b/Core/src/Detector/VolumeStructureBuilder.cpp index a7e7c8695d5..e63a13d5039 100644 --- a/Core/src/Detector/VolumeStructureBuilder.cpp +++ b/Core/src/Detector/VolumeStructureBuilder.cpp @@ -19,6 +19,8 @@ #include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/StringHelpers.hpp" +#include + Acts::Experimental::VolumeStructureBuilder::VolumeStructureBuilder( const Acts::Experimental::VolumeStructureBuilder::Config& cfg, std::unique_ptr mlogger) @@ -142,7 +144,7 @@ Acts::Experimental::VolumeStructureBuilder::construct( } // Check if phi has been constraint, otherwise fill it with full coverage if (boundValues.size() == 3u) { - boundValues.push_back(M_PI); + boundValues.push_back(std::numbers::pi_v); boundValues.push_back(0.); } ACTS_VERBOSE(" - cylindrical shape with [iR, oR, hZ, sPhi, mPhi] = " diff --git a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp index ba78a51b84e..499d28c0785 100644 --- a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -404,7 +405,8 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( } } else { ACTS_VERBOSE( - "No sector planes present, full 2 * M_PI cylindrical geometry."); + "No sector planes present, full 2 * std::numbers::pi cylindrical " + "geometry."); } // Attach the new volume multi links @@ -604,7 +606,8 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( } } else { ACTS_VERBOSE( - "No sector planes present, full 2 * M_PI cylindrical geometry."); + "No sector planes present, full 2 * std::numbers::pi cylindrical " + "geometry."); } // Attach the new volume multi links @@ -823,7 +826,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::wrapInZR( std::vector pReplacements; pReplacements.push_back(createCylinderReplacement( volumes[0u]->transform(gctx), innerR, {-HlZ, -hlZ, hlZ, HlZ}, - {-M_PI, M_PI}, 3u, Direction::Forward)); + {-std::numbers::pi, std::numbers::pi}, 3u, Direction::Forward)); std::vector> zVolumes = { volumes[1u], volumes[0u], volumes[1u]}; // Attach the new volume multi links diff --git a/Core/src/Detector/detail/SupportSurfacesHelper.cpp b/Core/src/Detector/detail/SupportSurfacesHelper.cpp index ec888733deb..62916abe39c 100644 --- a/Core/src/Detector/detail/SupportSurfacesHelper.cpp +++ b/Core/src/Detector/detail/SupportSurfacesHelper.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -39,7 +40,7 @@ operator()(const Extent& lExtent) const { ActsScalar maxZ = lExtent.max(BinningValue::binZ) - std::abs(zClearance[1u]); // Phi sector - ActsScalar hPhiSector = M_PI; + ActsScalar hPhiSector = std::numbers::pi_v; ActsScalar avgPhi = 0.; if (lExtent.constrains(BinningValue::binPhi)) { // Min / Max phi with clearances adapted @@ -83,7 +84,7 @@ Acts::Experimental::detail::SupportSurfacesHelper::DiscSupport::operator()( ActsScalar maxR = lExtent.max(BinningValue::binR) - std::abs(rClearance[1u]); // Phi sector - ActsScalar hPhiSector = M_PI; + ActsScalar hPhiSector = std::numbers::pi_v; ActsScalar avgPhi = 0.; if (lExtent.constrains(BinningValue::binPhi)) { // Min / Max phi with clearances adapted @@ -192,7 +193,8 @@ Acts::Experimental::detail::SupportSurfacesHelper::cylindricalSupport( // Now create the Trapezoids for (unsigned int iphi = 0; iphi < splits; ++iphi) { // Get the moduleTransform - ActsScalar phi = -M_PI + (iphi + 0.5) * 2 * dHalfPhi; + ActsScalar phi = + -std::numbers::pi_v + (2 * iphi + 1) * dHalfPhi; ActsScalar cosPhi = std::cos(phi); ActsScalar sinPhi = std::sin(phi); ActsScalar planeX = planeR * cosPhi; @@ -271,10 +273,12 @@ Acts::Experimental::detail::SupportSurfacesHelper::discSupport( // Now create the Trapezoids for (unsigned int iphi = 0; iphi < splits; ++iphi) { // Create the split module transform - ActsScalar phi = -M_PI + (iphi + 0.5) * 2 * dHalfPhi; + ActsScalar phi = + -std::numbers::pi_v + (2 * iphi + 1) * dHalfPhi; auto sTransform = Transform3( Translation3(hR * std::cos(phi), hR * std::sin(phi), zPosition) * - AngleAxis3(phi - 0.5 * M_PI, zAxis)); + AngleAxis3(phi - static_cast(std::numbers::pi / 2.), + zAxis)); // Place it dSupport.push_back( Surface::makeShared(sTransform, sTrapezoid)); diff --git a/Core/src/Geometry/ConeVolumeBounds.cpp b/Core/src/Geometry/ConeVolumeBounds.cpp index 8eb10e7055a..31339ca4779 100644 --- a/Core/src/Geometry/ConeVolumeBounds.cpp +++ b/Core/src/Geometry/ConeVolumeBounds.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -179,7 +180,7 @@ void ConeVolumeBounds::checkConsistency() noexcept(false) { throw std::invalid_argument( "ConeVolumeBounds: invalid longitudinal input."); } - if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > M_PI) { + if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { throw std::invalid_argument("ConeVolumeBounds: invalid phi sector setup."); } if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { @@ -200,7 +201,7 @@ bool ConeVolumeBounds::inside(const Vector3& pos, ActsScalar tol) const { return false; } ActsScalar r = VectorHelpers::perp(pos); - if (std::abs(get(eHalfPhiSector) - M_PI) > s_onSurfaceTolerance) { + if (std::abs(get(eHalfPhiSector) - std::numbers::pi) > s_onSurfaceTolerance) { // need to check the phi sector - approximate phi tolerance ActsScalar phitol = tol / r; ActsScalar phi = VectorHelpers::phi(pos); @@ -280,7 +281,7 @@ void ConeVolumeBounds::buildSurfaceBounds() { m_innerRmax, m_outerRmax, get(eHalfPhiSector), get(eAveragePhi)); // Create the sector bounds - if (std::abs(get(eHalfPhiSector) - M_PI) > s_epsilon) { + if (std::abs(get(eHalfPhiSector) - std::numbers::pi) > s_epsilon) { // The 4 points building the sector std::vector polyVertices = {{-get(eHalfLengthZ), m_innerRmin}, {get(eHalfLengthZ), m_innerRmax}, diff --git a/Core/src/Geometry/CylinderVolumeBounds.cpp b/Core/src/Geometry/CylinderVolumeBounds.cpp index d9af620ea45..b4f8084a4c0 100644 --- a/Core/src/Geometry/CylinderVolumeBounds.cpp +++ b/Core/src/Geometry/CylinderVolumeBounds.cpp @@ -21,6 +21,7 @@ #include "Acts/Utilities/BoundingBox.hpp" #include +#include #include namespace Acts { @@ -142,7 +143,7 @@ std::vector CylinderVolumeBounds::orientedSurfaces( AngleAxis3(get(eAveragePhi) - get(eHalfPhiSector), Vector3(0., 0., 1.)) * Translation3(0.5 * (get(eMinR) + get(eMaxR)), 0., 0.) * - AngleAxis3(M_PI / 2, Vector3(1., 0., 0.))); + AngleAxis3(std::numbers::pi / 2, Vector3(1., 0., 0.))); auto pSurface = Surface::makeShared(sp1Transform, m_sectorPlaneBounds); oSurfaces.push_back( @@ -153,7 +154,7 @@ std::vector CylinderVolumeBounds::orientedSurfaces( AngleAxis3(get(eAveragePhi) + get(eHalfPhiSector), Vector3(0., 0., 1.)) * Translation3(0.5 * (get(eMinR) + get(eMaxR)), 0., 0.) * - AngleAxis3(-M_PI / 2, Vector3(1., 0., 0.))); + AngleAxis3(-std::numbers::pi / 2, Vector3(1., 0., 0.))); pSurface = Surface::makeShared(sp2Transform, m_sectorPlaneBounds); oSurfaces.push_back( @@ -174,7 +175,7 @@ void CylinderVolumeBounds::buildSurfaceBounds() { m_discBounds = std::make_shared( get(eMinR), get(eMaxR), get(eHalfPhiSector), get(eAveragePhi)); - if (std::abs(get(eHalfPhiSector) - M_PI) > s_epsilon) { + if (std::abs(get(eHalfPhiSector) - std::numbers::pi) > s_epsilon) { m_sectorPlaneBounds = std::make_shared( 0.5 * (get(eMaxR) - get(eMinR)), get(eHalfLengthZ)); } @@ -197,7 +198,7 @@ Volume::BoundingBox CylinderVolumeBounds::boundingBox( ActsScalar xmax = 0, xmin = 0, ymax = 0, ymin = 0; xmax = get(eMaxR); - if (get(eHalfPhiSector) > M_PI / 2.) { + if (get(eHalfPhiSector) > std::numbers::pi / 2.) { // more than half ymax = xmax; ymin = -xmax; @@ -274,7 +275,7 @@ void CylinderVolumeBounds::checkConsistency() { "CylinderVolumeBounds: invalid longitudinal input: hlZ (" + std::to_string(get(eHalfLengthZ)) + ") <= 0"); } - if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > M_PI) { + if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { throw std::invalid_argument( "CylinderVolumeBounds: invalid phi sector setup."); } diff --git a/Core/src/Geometry/CylinderVolumeHelper.cpp b/Core/src/Geometry/CylinderVolumeHelper.cpp index f02435d1bfc..f5b244983ef 100644 --- a/Core/src/Geometry/CylinderVolumeHelper.cpp +++ b/Core/src/Geometry/CylinderVolumeHelper.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -969,7 +970,8 @@ Acts::CylinderVolumeHelper::createCylinderLayer(double z, double r, } else { // break the phi symmetry // update the BinUtility: local position on Cylinder is rPhi, z - BinUtility layerBinUtilityPhiZ(binsPhi, -r * M_PI, +r * M_PI, closed, + BinUtility layerBinUtilityPhiZ(binsPhi, -r * std::numbers::pi, + r * std::numbers::pi, closed, BinningValue::binPhi); layerBinUtilityPhiZ += layerBinUtility; // ---------------------> create material for the layer surface @@ -1002,8 +1004,8 @@ std::shared_ptr Acts::CylinderVolumeHelper::createDiscLayer( } else { // also binning in phi chosen materialBinUtility += - BinUtility(binsPhi, -static_cast(M_PI), static_cast(M_PI), - closed, BinningValue::binPhi); + BinUtility(binsPhi, -std::numbers::pi_v, + std::numbers::pi_v, closed, BinningValue::binPhi); ACTS_VERBOSE(" -> Preparing the binned material with " << binsPhi << " / " << binsR << " bins in phi / R. "); } diff --git a/Core/src/Geometry/CylinderVolumeStack.cpp b/Core/src/Geometry/CylinderVolumeStack.cpp index 9155087d57e..5dd0949ac79 100644 --- a/Core/src/Geometry/CylinderVolumeStack.cpp +++ b/Core/src/Geometry/CylinderVolumeStack.cpp @@ -17,6 +17,7 @@ #include #include +#include #include namespace Acts { @@ -1046,7 +1047,7 @@ void CylinderVolumeStack::update(std::shared_ptr volbounds, void CylinderVolumeStack::checkNoPhiOrBevel(const CylinderVolumeBounds& bounds, const Logger& logger) { - if (bounds.get(CylinderVolumeBounds::eHalfPhiSector) != M_PI) { + if (bounds.get(CylinderVolumeBounds::eHalfPhiSector) != std::numbers::pi) { ACTS_ERROR( "CylinderVolumeStack requires all volumes to have a full " "phi sector"); diff --git a/Core/src/Geometry/Extent.cpp b/Core/src/Geometry/Extent.cpp index 2f07f6358bc..bd50d8536ef 100644 --- a/Core/src/Geometry/Extent.cpp +++ b/Core/src/Geometry/Extent.cpp @@ -15,13 +15,14 @@ #include #include #include +#include Acts::Extent::Extent(const ExtentEnvelope& envelope) : m_constrains(0), m_envelope(envelope) { m_range[toUnderlying(BinningValue::binR)] = Range1D(0., std::numeric_limits::max()); - m_range[toUnderlying(BinningValue::binPhi)] = - Range1D(-M_PI, M_PI); + m_range[toUnderlying(BinningValue::binPhi)] = Range1D( + -std::numbers::pi_v, std::numbers::pi_v); m_range[toUnderlying(BinningValue::binRPhi)] = Range1D(0., std::numeric_limits::max()); m_range[toUnderlying(BinningValue::binMag)] = diff --git a/Core/src/Geometry/GridPortalLink.cpp b/Core/src/Geometry/GridPortalLink.cpp index 57a3e1d3141..632289d9dc3 100644 --- a/Core/src/Geometry/GridPortalLink.cpp +++ b/Core/src/Geometry/GridPortalLink.cpp @@ -11,6 +11,8 @@ #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RadialBounds.hpp" +#include + namespace Acts { std::unique_ptr GridPortalLink::make( @@ -24,8 +26,9 @@ std::unique_ptr GridPortalLink::make( if (direction == BinningValue::binRPhi) { ActsScalar r = cylinder->bounds().get(CylinderBounds::eR); if (cylinder->bounds().coversFullAzimuth()) { - grid = GridPortalLink::make(surface, direction, - Axis{AxisClosed, -M_PI * r, M_PI * r, 1}); + grid = GridPortalLink::make( + surface, direction, + Axis{AxisClosed, -std::numbers::pi * r, std::numbers::pi * r, 1}); } else { ActsScalar hlPhi = cylinder->bounds().get(CylinderBounds::eHalfPhiSector); @@ -50,8 +53,9 @@ std::unique_ptr GridPortalLink::make( Axis{AxisBound, minR, maxR, 1}); } else if (direction == BinningValue::binPhi) { if (bounds.coversFullAzimuth()) { - grid = GridPortalLink::make(surface, direction, - Axis{AxisClosed, -M_PI, M_PI, 1}); + grid = GridPortalLink::make( + surface, direction, + Axis{AxisClosed, -std::numbers::pi, std::numbers::pi, 1}); } else { ActsScalar hlPhi = bounds.get(RadialBounds::eHalfPhiSector); grid = GridPortalLink::make(surface, direction, @@ -106,7 +110,7 @@ void GridPortalLink::checkConsistency(const CylinderSurface& cyl) const { } // If full cylinder, make sure axis wraps around - if (same(hlPhi, M_PI)) { + if (same(hlPhi, std::numbers::pi)) { if (axis.getBoundaryType() != AxisBoundaryType::Closed) { throw std::invalid_argument( "GridPortalLink: CylinderBounds: invalid phi sector setup: " @@ -168,7 +172,7 @@ void GridPortalLink::checkConsistency(const DiscSurface& disc) const { "GridPortalLink: DiscBounds: invalid phi sector setup."); } // If full disc, make sure axis wraps around - if (same(hlPhi, M_PI)) { + if (same(hlPhi, std::numbers::pi)) { if (axis.getBoundaryType() != Acts::AxisBoundaryType::Closed) { throw std::invalid_argument( "GridPortalLink: DiscBounds: invalid phi sector setup: axis is " diff --git a/Core/src/Geometry/Polyhedron.cpp b/Core/src/Geometry/Polyhedron.cpp index 2d67f086872..5f7336ca3fc 100644 --- a/Core/src/Geometry/Polyhedron.cpp +++ b/Core/src/Geometry/Polyhedron.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include void Acts::Polyhedron::merge(const Acts::Polyhedron& other) { @@ -62,7 +63,8 @@ Acts::Extent Acts::Polyhedron::extent(const Transform3& transform) const { } if (detail::VerticesHelper::isInsidePolygon(origin, tface)) { extent.range(BinningValue::binR).setMin(0.); - extent.range(BinningValue::binPhi).set(-M_PI, M_PI); + extent.range(BinningValue::binPhi) + .set(-std::numbers::pi, std::numbers::pi); break; } } diff --git a/Core/src/Geometry/SurfaceArrayCreator.cpp b/Core/src/Geometry/SurfaceArrayCreator.cpp index 727d9e173e9..3ec85b020f6 100644 --- a/Core/src/Geometry/SurfaceArrayCreator.cpp +++ b/Core/src/Geometry/SurfaceArrayCreator.cpp @@ -21,6 +21,7 @@ #include #include +#include #include using Acts::VectorHelpers::perp; @@ -444,7 +445,7 @@ Acts::SurfaceArrayCreator::createVariableAxis( phi(keys.at(1)->binningPosition(gctx, BinningValue::binPhi))); // create rotation, so that maxPhi is +pi - AxisScalar angle = -(M_PI + maxPhi); + AxisScalar angle = -(std::numbers::pi + maxPhi); transform = (transform)*AngleAxis3(angle, Vector3::UnitZ()); // iterate over all key surfaces, and use their mean position as bValues, @@ -488,7 +489,7 @@ Acts::SurfaceArrayCreator::createVariableAxis( bValues.push_back(maxBValue); - bValues.push_back(M_PI); + bValues.push_back(std::numbers::pi_v); } else if (bValue == Acts::BinningValue::binZ) { std::stable_sort( @@ -612,16 +613,16 @@ Acts::SurfaceArrayCreator::createEquidistantAxis( if (keys.size() > 1) { // bOption = Acts::closed; - minimum = -M_PI; - maximum = M_PI; + minimum = -std::numbers::pi; + maximum = std::numbers::pi; - // double step = 2 * M_PI / keys.size(); - double step = 2 * M_PI / binNumber; + // double step = 2 * std::numbers::pi / keys.size(); + double step = 2 * std::numbers::pi / binNumber; // rotate to max phi module plus one half step // this should make sure that phi wrapping at +- pi // never falls on a module center double max = phi(maxElem->binningPosition(gctx, BinningValue::binR)); - double angle = M_PI - (max + 0.5 * step); + double angle = std::numbers::pi - (max + 0.5 * step); // replace given transform ref transform = (transform)*AngleAxis3(angle, Vector3::UnitZ()); @@ -632,8 +633,8 @@ Acts::SurfaceArrayCreator::createEquidistantAxis( // we do not need a transform in this case } } else { - minimum = -M_PI; - maximum = M_PI; + minimum = -std::numbers::pi; + maximum = std::numbers::pi; } } else { maximum = protoLayer.max(bValue, false); diff --git a/Core/src/Geometry/TrapezoidVolumeBounds.cpp b/Core/src/Geometry/TrapezoidVolumeBounds.cpp index d17ce06e38b..96d682a35dc 100644 --- a/Core/src/Geometry/TrapezoidVolumeBounds.cpp +++ b/Core/src/Geometry/TrapezoidVolumeBounds.cpp @@ -18,6 +18,7 @@ #include #include +#include #include namespace Acts { @@ -31,7 +32,7 @@ TrapezoidVolumeBounds::TrapezoidVolumeBounds(ActsScalar minhalex, m_values[eHalfLengthY] = haley; m_values[eHalfLengthZ] = halez; m_values[eAlpha] = atan2(2 * haley, (maxhalex - minhalex)); - m_values[eBeta] = M_PI - get(eAlpha); + m_values[eBeta] = std::numbers::pi - get(eAlpha); checkConsistency(); buildSurfaceBounds(); } @@ -46,8 +47,8 @@ TrapezoidVolumeBounds::TrapezoidVolumeBounds(ActsScalar minhalex, m_values[eAlpha] = alpha; m_values[eBeta] = beta; // now calculate the remaining max half X - ActsScalar gamma = - (alpha > beta) ? (alpha - 0.5 * M_PI) : (beta - 0.5 * M_PI); + ActsScalar gamma = (alpha > beta) ? (alpha - std::numbers::pi / 2.) + : (beta - std::numbers::pi / 2.); m_values[eHalfLengthXposY] = minhalex + (2. * haley) * tan(gamma); checkConsistency(); @@ -84,9 +85,10 @@ std::vector TrapezoidVolumeBounds::orientedSurfaces( // Face surfaces yz // (3) - At point B, attached to beta opening angle Vector3 fbPosition(-get(eHalfLengthXnegY) + neghOffset, 0., 0.); - auto fbTransform = transform * Translation3(fbPosition) * - AngleAxis3(-0.5 * M_PI + get(eBeta), Vector3(0., 0., 1.)) * - s_planeYZ; + auto fbTransform = + transform * Translation3(fbPosition) * + AngleAxis3(-std::numbers::pi / 2. + get(eBeta), Vector3(0., 0., 1.)) * + s_planeYZ; sf = Surface::makeShared(fbTransform, m_faceBetaRectangleBounds); oSurfaces.push_back(OrientedSurface{std::move(sf), Direction::AlongNormal}); @@ -95,7 +97,8 @@ std::vector TrapezoidVolumeBounds::orientedSurfaces( Vector3 faPosition(get(eHalfLengthXnegY) + poshOffset, 0., 0.); auto faTransform = transform * Translation3(faPosition) * - AngleAxis3(-0.5 * M_PI + get(eAlpha), Vector3(0., 0., 1.)) * s_planeYZ; + AngleAxis3(-std::numbers::pi / 2. + get(eAlpha), Vector3(0., 0., 1.)) * + s_planeYZ; sf = Surface::makeShared(faTransform, m_faceAlphaRectangleBounds); oSurfaces.push_back( @@ -124,10 +127,12 @@ void TrapezoidVolumeBounds::buildSurfaceBounds() { get(eHalfLengthXnegY), get(eHalfLengthXposY), get(eHalfLengthY)); m_faceAlphaRectangleBounds = std::make_shared( - get(eHalfLengthY) / cos(get(eAlpha) - 0.5 * M_PI), get(eHalfLengthZ)); + get(eHalfLengthY) / cos(get(eAlpha) - std::numbers::pi / 2.), + get(eHalfLengthZ)); m_faceBetaRectangleBounds = std::make_shared( - get(eHalfLengthY) / cos(get(eBeta) - 0.5 * M_PI), get(eHalfLengthZ)); + get(eHalfLengthY) / cos(get(eBeta) - std::numbers::pi / 2.), + get(eHalfLengthZ)); m_faceZXRectangleBoundsBottom = std::make_shared( get(eHalfLengthZ), get(eHalfLengthXnegY)); diff --git a/Core/src/MagneticField/SolenoidBField.cpp b/Core/src/MagneticField/SolenoidBField.cpp index b6b4fbfc2df..6fefe017b38 100644 --- a/Core/src/MagneticField/SolenoidBField.cpp +++ b/Core/src/MagneticField/SolenoidBField.cpp @@ -12,6 +12,7 @@ #include #include +#include #define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS @@ -110,7 +111,8 @@ double Acts::SolenoidBField::B_r(const Vector2& pos, double scale) const { double k_2 = k2(r, z); double k = std::sqrt(k_2); double constant = - scale * k * z / (4 * M_PI * std::sqrt(m_cfg.radius * r * r * r)); + scale * k * z / + (4 * std::numbers::pi * std::sqrt(m_cfg.radius * r * r * r)); double B = (2. - k_2) / (2. - 2. * k_2) * ellint_2(k_2) - ellint_1(k_2); @@ -147,7 +149,8 @@ double Acts::SolenoidBField::B_z(const Vector2& pos, double scale) const { double k_2 = k2(r, z); double k = std::sqrt(k_2); - double constant = scale * k / (4 * M_PI * std::sqrt(m_cfg.radius * r)); + double constant = + scale * k / (4 * std::numbers::pi * std::sqrt(m_cfg.radius * r)); double B = ((m_cfg.radius + r) * k_2 - 2. * r) / (2. * r * (1. - k_2)) * ellint_2(k_2) + ellint_1(k_2); diff --git a/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp b/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp index 83d950fc3a1..eebcd1c5760 100644 --- a/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp +++ b/Core/src/Seeding/EstimateTrackParamsFromSeed.cpp @@ -10,10 +10,12 @@ #include "Acts/Definitions/TrackParametrization.hpp" +#include + Acts::BoundMatrix Acts::estimateTrackParamCovariance( const EstimateTrackParamCovarianceConfig& config, const BoundVector& params, bool hasTime) { - assert((params[eBoundTheta] > 0 && params[eBoundTheta] < M_PI) && + assert((params[eBoundTheta] > 0 && params[eBoundTheta] < std::numbers::pi) && "Theta must be in the range (0, pi)"); BoundSquareMatrix result = BoundSquareMatrix::Zero(); diff --git a/Core/src/Surfaces/ConeSurface.cpp b/Core/src/Surfaces/ConeSurface.cpp index ce10c59815f..b6d04e87e06 100644 --- a/Core/src/Surfaces/ConeSurface.cpp +++ b/Core/src/Surfaces/ConeSurface.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -210,7 +211,7 @@ Acts::Polyhedron Acts::ConeSurface::polyhedronRepresentation( ActsScalar hPhiSec = bounds().get(ConeBounds::eHalfPhiSector); ActsScalar avgPhi = bounds().get(ConeBounds::eAveragePhi); std::vector refPhi = {}; - if (bool fullCone = (hPhiSec == M_PI); !fullCone) { + if (bool fullCone = (hPhiSec == std::numbers::pi_v); !fullCone) { refPhi = {avgPhi}; } diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index 64d3e9f547f..82f809c6c5b 100644 --- a/Core/src/Surfaces/CylinderBounds.cpp +++ b/Core/src/Surfaces/CylinderBounds.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include using Acts::VectorHelpers::perp; @@ -160,11 +161,11 @@ void Acts::CylinderBounds::checkConsistency() noexcept(false) { throw std::invalid_argument( "CylinderBounds: invalid length setup: half length is negative"); } - if (get(eHalfPhiSector) <= 0. || get(eHalfPhiSector) > M_PI) { + if (get(eHalfPhiSector) <= 0. || get(eHalfPhiSector) > std::numbers::pi) { throw std::invalid_argument("CylinderBounds: invalid phi sector setup."); } if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi)) && - std::abs(std::abs(get(eAveragePhi)) - M_PI) > s_epsilon) { + std::abs(std::abs(get(eAveragePhi)) - std::numbers::pi) > s_epsilon) { throw std::invalid_argument("CylinderBounds: invalid phi positioning."); } if (get(eBevelMinZ) != detail::radian_sym(get(eBevelMinZ))) { diff --git a/Core/src/Surfaces/PlaneSurface.cpp b/Core/src/Surfaces/PlaneSurface.cpp index b33ef82eb46..658920e6686 100644 --- a/Core/src/Surfaces/PlaneSurface.cpp +++ b/Core/src/Surfaces/PlaneSurface.cpp @@ -23,6 +23,7 @@ #include "Acts/Utilities/ThrowAssert.hpp" #include +#include #include #include #include @@ -107,8 +108,8 @@ Acts::Polyhedron Acts::PlaneSurface::polyhedronRepresentation( auto vStore = bounds().values(); innerExists = vStore[EllipseBounds::eInnerRx] > s_epsilon && vStore[EllipseBounds::eInnerRy] > s_epsilon; - coversFull = - std::abs(vStore[EllipseBounds::eHalfPhiSector] - M_PI) < s_epsilon; + coversFull = std::abs(vStore[EllipseBounds::eHalfPhiSector] - + std::numbers::pi) < s_epsilon; } // All of those can be described as convex // @todo same as for Discs: coversFull is not the right criterium diff --git a/Core/src/Surfaces/StrawSurface.cpp b/Core/src/Surfaces/StrawSurface.cpp index 2ce1ef74b42..b6e241af858 100644 --- a/Core/src/Surfaces/StrawSurface.cpp +++ b/Core/src/Surfaces/StrawSurface.cpp @@ -15,6 +15,7 @@ #include "Acts/Surfaces/detail/VerticesHelper.hpp" #include +#include #include #include @@ -63,7 +64,7 @@ Acts::Polyhedron Acts::StrawSurface::polyhedronRepresentation( for (auto& side : sides) { /// Helper method to create the segment auto svertices = detail::VerticesHelper::segmentVertices( - {r, r}, -M_PI, M_PI, {}, quarterSegments, + {r, r}, -std::numbers::pi, std::numbers::pi, {}, quarterSegments, Vector3(0., 0., side * m_bounds->get(LineBounds::eHalfLengthZ)), ctransform); vertices.insert(vertices.end(), svertices.begin(), svertices.end()); diff --git a/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp b/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp index 68e22e4c72b..47cb4e2e9a6 100644 --- a/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp +++ b/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp @@ -12,6 +12,7 @@ #include "Acts/Utilities/VectorHelpers.hpp" #include +#include std::tuple, Acts::Transform3> Acts::detail::AnnulusBoundsHelper::create(const Transform3& transform, @@ -27,7 +28,8 @@ Acts::detail::AnnulusBoundsHelper::create(const Transform3& transform, Vector2 ab = b - a; double phi = VectorHelpers::phi(ab); - if (std::abs(phi) > 3 * M_PI / 4. || std::abs(phi) < M_PI / 4.) { + if (std::abs(phi) > 3 * std::numbers::pi / 4. || + std::abs(phi) < std::numbers::pi / 4.) { if (a.norm() < b.norm()) { boundLines.push_back(std::make_pair(a, b)); } else { diff --git a/Core/src/Surfaces/detail/MergeHelper.cpp b/Core/src/Surfaces/detail/MergeHelper.cpp index 8d0b1fa0b5a..414e5761686 100644 --- a/Core/src/Surfaces/detail/MergeHelper.cpp +++ b/Core/src/Surfaces/detail/MergeHelper.cpp @@ -8,6 +8,8 @@ #include "Acts/Surfaces/detail/MergeHelper.hpp" +#include + namespace Acts::detail { std::tuple mergedPhiSector( @@ -15,23 +17,24 @@ std::tuple mergedPhiSector( ActsScalar avgPhi2, const Logger& logger, ActsScalar tolerance) { using namespace Acts::UnitLiterals; - if (std::abs(hlPhi1 - M_PI / 2.0) < tolerance && - std::abs(hlPhi2 - M_PI / 2.0) < tolerance) { + if (std::abs(hlPhi1 - std::numbers::pi / 2.) < tolerance && + std::abs(hlPhi2 - std::numbers::pi / 2.) < tolerance) { ACTS_VERBOSE("Both phi sectors cover a half circle"); - ACTS_VERBOSE("-> distance between sectors: " - << detail::difference_periodic(avgPhi1, avgPhi2, 2 * M_PI) / - 1_degree); + ACTS_VERBOSE("-> distance between sectors: " << detail::difference_periodic( + avgPhi1, avgPhi2, + 2 * std::numbers::pi) / + 1_degree); - if (std::abs( - std::abs(detail::difference_periodic(avgPhi1, avgPhi2, 2 * M_PI)) - - M_PI) > tolerance) { + if (std::abs(std::abs(detail::difference_periodic(avgPhi1, avgPhi2, + 2 * std::numbers::pi)) - + std::numbers::pi) > tolerance) { throw std::invalid_argument( "Phi sectors cover half a circle but are not opposite"); } - ActsScalar newAvgPhi = detail::radian_sym(avgPhi1 + M_PI / 2.0); - ActsScalar newHlPhi = M_PI; + ActsScalar newAvgPhi = detail::radian_sym(avgPhi1 + std::numbers::pi / 2.); + ActsScalar newHlPhi = std::numbers::pi; ACTS_VERBOSE("merged: [" << detail::radian_sym(newAvgPhi - newHlPhi) / 1_degree << ", " << detail::radian_sym(newAvgPhi + newHlPhi) / 1_degree diff --git a/Core/src/Surfaces/detail/VerticesHelper.cpp b/Core/src/Surfaces/detail/VerticesHelper.cpp index b8bed1fb50f..e97d75d45bf 100644 --- a/Core/src/Surfaces/detail/VerticesHelper.cpp +++ b/Core/src/Surfaces/detail/VerticesHelper.cpp @@ -11,6 +11,7 @@ #include #include #include +#include std::vector Acts::detail::VerticesHelper::phiSegments( ActsScalar phiMin, ActsScalar phiMax, @@ -39,7 +40,8 @@ std::vector Acts::detail::VerticesHelper::phiSegments( // Minimum approximation for a circle need // - if the circle is closed the last point is given twice for (unsigned int i = 0; i < 4 * quarterSegments + 1; ++i) { - ActsScalar phiExt = -M_PI + i * 2 * M_PI / (4 * quarterSegments); + ActsScalar phiExt = + -std::numbers::pi + i * 2 * std::numbers::pi / (4 * quarterSegments); if (phiExt > phiMin && phiExt < phiMax && std::ranges::none_of(phiSegments, [&phiExt](ActsScalar phi) { return std::abs(phi - phiExt) < @@ -76,7 +78,7 @@ std::vector Acts::detail::VerticesHelper::ellipsoidVertices( std::vector overtices; // outer verices bool innerExists = (innerRx > 0. && innerRy > 0.); - bool closed = std::abs(halfPhi - M_PI) < s_onSurfaceTolerance; + bool closed = std::abs(halfPhi - std::numbers::pi) < s_onSurfaceTolerance; std::vector refPhi = {}; if (avgPhi != 0.) { diff --git a/Core/src/TrackFinding/MeasurementSelector.cpp b/Core/src/TrackFinding/MeasurementSelector.cpp index f3de466f5df..2a3c0e2d390 100644 --- a/Core/src/TrackFinding/MeasurementSelector.cpp +++ b/Core/src/TrackFinding/MeasurementSelector.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace Acts { @@ -121,7 +122,7 @@ MeasurementSelector::Cuts MeasurementSelector::getCutsByTheta( const InternalCutBins& config, double theta) { // since theta is in [0, pi] and we have a symmetric cut in eta, we can just // look at the positive half of the Z axis - const double constrainedTheta = std::min(theta, M_PI - theta); + const double constrainedTheta = std::min(theta, std::numbers::pi - theta); auto it = std::ranges::find_if( config, [constrainedTheta](const InternalCutBin& cuts) { diff --git a/Core/src/Vertexing/GaussianTrackDensity.cpp b/Core/src/Vertexing/GaussianTrackDensity.cpp index 073c4500dbf..3acf5f6bbfc 100644 --- a/Core/src/Vertexing/GaussianTrackDensity.cpp +++ b/Core/src/Vertexing/GaussianTrackDensity.cpp @@ -10,7 +10,8 @@ #include "Acts/Vertexing/VertexingError.hpp" -#include +#include +#include namespace Acts { @@ -124,7 +125,7 @@ Result Acts::GaussianTrackDensity::addTracks( discriminant = std::sqrt(discriminant); const double zMax = (-linearTerm - discriminant) / (2. * quadraticTerm); const double zMin = (-linearTerm + discriminant) / (2. * quadraticTerm); - constantTerm -= std::log(2. * M_PI * std::sqrt(covDeterminant)); + constantTerm -= std::log(2. * std::numbers::pi * std::sqrt(covDeterminant)); state.trackEntries.emplace_back(z0, constantTerm, linearTerm, quadraticTerm, zMin, zMax); diff --git a/Core/src/Vertexing/NumericalTrackLinearizer.cpp b/Core/src/Vertexing/NumericalTrackLinearizer.cpp index 035e42ab3c8..ca9af5825e4 100644 --- a/Core/src/Vertexing/NumericalTrackLinearizer.cpp +++ b/Core/src/Vertexing/NumericalTrackLinearizer.cpp @@ -13,6 +13,8 @@ #include "Acts/Utilities/UnitVectors.hpp" #include "Acts/Vertexing/LinearizerTrackParameters.hpp" +#include + Acts::Result Acts::NumericalTrackLinearizer::linearizeTrack( const BoundTrackParameters& params, double linPointTime, @@ -94,7 +96,7 @@ Acts::NumericalTrackLinearizer::linearizeTrack( BoundVector newPerigeeParams; // Check if wiggled angle theta are within definition range [0, pi] - if (paramVec(eLinTheta) + m_cfg.delta > M_PI) { + if (paramVec(eLinTheta) + m_cfg.delta > std::numbers::pi) { ACTS_ERROR( "Wiggled theta outside range, choose a smaller wiggle (i.e., delta)! " "You might need to decrease targetTolerance as well."); @@ -141,7 +143,8 @@ Acts::NumericalTrackLinearizer::linearizeTrack( // previously computed value for better readability. completeJacobian(eLinPhi, i) = Acts::detail::difference_periodic(newPerigeeParams(eLinPhi), - perigeeParams(eLinPhi), 2 * M_PI) / + perigeeParams(eLinPhi), + 2 * std::numbers::pi) / m_cfg.delta; } diff --git a/Examples/Algorithms/AmbiguityResolution/include/ActsExamples/AmbiguityResolution/ScoreBasedAmbiguityResolutionAlgorithm.hpp b/Examples/Algorithms/AmbiguityResolution/include/ActsExamples/AmbiguityResolution/ScoreBasedAmbiguityResolutionAlgorithm.hpp index 1ffeef6ac29..b63100f8751 100644 --- a/Examples/Algorithms/AmbiguityResolution/include/ActsExamples/AmbiguityResolution/ScoreBasedAmbiguityResolutionAlgorithm.hpp +++ b/Examples/Algorithms/AmbiguityResolution/include/ActsExamples/AmbiguityResolution/ScoreBasedAmbiguityResolutionAlgorithm.hpp @@ -16,6 +16,7 @@ #include "ActsExamples/Framework/IAlgorithm.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" +#include #include namespace ActsExamples { @@ -56,8 +57,8 @@ class ScoreBasedAmbiguityResolutionAlgorithm final : public IAlgorithm { double pTMin = 0 * Acts::UnitConstants::GeV; double pTMax = 1e5 * Acts::UnitConstants::GeV; - double phiMin = -M_PI * Acts::UnitConstants::rad; - double phiMax = M_PI * Acts::UnitConstants::rad; + double phiMin = -std::numbers::pi * Acts::UnitConstants::rad; + double phiMax = std::numbers::pi * Acts::UnitConstants::rad; double etaMin = -5; double etaMax = 5; diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.hpp b/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.hpp index 0efc47a0c5c..b671e597d66 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.hpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -32,8 +33,8 @@ class ParametricParticleGenerator : public EventGenerator::ParticlesGenerator { public: struct Config { /// Low, high (exclusive) for the transverse direction angle. - double phiMin = -M_PI; - double phiMax = M_PI; + double phiMin = -std::numbers::pi; + double phiMax = std::numbers::pi; /// Low, high (inclusive) for the longitudinal direction angle. /// /// This intentionally uses theta instead of eta so it can represent the @@ -44,7 +45,7 @@ class ParametricParticleGenerator : public EventGenerator::ParticlesGenerator { /// this can be set by the etaUniform flag; /// double thetaMin = std::numeric_limits::min(); - double thetaMax = M_PI - std::numeric_limits::epsilon(); + double thetaMax = std::numbers::pi - std::numeric_limits::epsilon(); bool etaUniform = false; /// Low, high (exclusive) for absolute/transverse momentum. double pMin = 1 * Acts::UnitConstants::GeV; diff --git a/Examples/Algorithms/Generators/ActsExamples/Generators/VertexGenerators.hpp b/Examples/Algorithms/Generators/ActsExamples/Generators/VertexGenerators.hpp index b32b04cfc36..6060e9bcc6a 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/VertexGenerators.hpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/VertexGenerators.hpp @@ -12,6 +12,7 @@ #include "ActsExamples/Framework/RandomNumbers.hpp" #include "ActsExamples/Generators/EventGenerator.hpp" +#include #include namespace ActsExamples { @@ -57,8 +58,8 @@ struct GaussianDisplacedVertexPositionGenerator double tStdDev = 1; Acts::Vector4 operator()(RandomEngine& rng) const override { - double min_value = -M_PI; // -π - double max_value = M_PI; // π + double min_value = -std::numbers::pi; + double max_value = std::numbers::pi; std::uniform_real_distribution<> uniform(min_value, max_value); diff --git a/Examples/Algorithms/Geometry/src/VolumeAssociationTest.cpp b/Examples/Algorithms/Geometry/src/VolumeAssociationTest.cpp index 8ee44a77764..353bcf94bac 100644 --- a/Examples/Algorithms/Geometry/src/VolumeAssociationTest.cpp +++ b/Examples/Algorithms/Geometry/src/VolumeAssociationTest.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -37,7 +38,8 @@ ActsExamples::ProcessCode ActsExamples::VolumeAssociationTest::execute( auto rng = m_cfg.randomNumbers->spawnGenerator(ctx); // Setup random number distributions for some quantities - std::uniform_real_distribution phiDist(-M_PI, M_PI); + std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); std::uniform_real_distribution rDist(0., m_cfg.randomRange[0u]); std::uniform_real_distribution zDist(-m_cfg.randomRange[1u], diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp index b06e538885c..e61d6e6ba5a 100644 --- a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp @@ -24,6 +24,7 @@ #include #include #include +#include // Convenience shorthand @@ -197,8 +198,8 @@ class MappingMaterialDecorator : public IMaterialDecorator { radialBounds->get(Acts::RadialBounds::eHalfPhiSector), radialBounds->get(Acts::RadialBounds::eAveragePhi) + radialBounds->get(Acts::RadialBounds::eHalfPhiSector), - (radialBounds->get(Acts::RadialBounds::eHalfPhiSector) - M_PI) < - Acts::s_epsilon + (radialBounds->get(Acts::RadialBounds::eHalfPhiSector) - + std::numbers::pi) < Acts::s_epsilon ? Acts::closed : Acts::open, Acts::BinningValue::binPhi); @@ -214,8 +215,8 @@ class MappingMaterialDecorator : public IMaterialDecorator { cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector), cylinderBounds->get(Acts::CylinderBounds::eAveragePhi) + cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector), - (cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector) - M_PI) < - Acts::s_epsilon + (cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector) - + std::numbers::pi) < Acts::s_epsilon ? Acts::closed : Acts::open, Acts::BinningValue::binPhi); diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp index a629902250a..ad1a7a93dff 100644 --- a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MaterialValidation.hpp @@ -19,6 +19,8 @@ #include "ActsExamples/Framework/RandomNumbers.hpp" #include "ActsExamples/MaterialMapping/IMaterialWriter.hpp" +#include + namespace ActsExamples { /// @class MaterialValidation @@ -35,7 +37,8 @@ class MaterialValidation : public IAlgorithm { Acts::Vector3 startPosition = Acts::Vector3(0., 0., 0.); /// Start direction for the scan: phi - std::pair phiRange = {-M_PI, M_PI}; + std::pair phiRange = {-std::numbers::pi, + std::numbers::pi}; /// Start direction for the scan: eta std::pair etaRange = {-4., 4.}; diff --git a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/HoughTransformSeeder.hpp b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/HoughTransformSeeder.hpp index b74047ca6a2..b8fd5ef3f75 100644 --- a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/HoughTransformSeeder.hpp +++ b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/HoughTransformSeeder.hpp @@ -85,6 +85,7 @@ #include #include +#include #include #include #include @@ -194,10 +195,10 @@ class HoughTransformSeeder final : public IAlgorithm { unsigned nLayers = 10; // total number of layers - float xMin = 0; // minphi - float xMax = 2 * 3.14159; // maxphi - float yMin = -1.0; // min q/pt, -1/1 GeV - float yMax = 1.0; // max q/pt, +1/1 GeV + float xMin = 0.; // minphi + float xMax = 2 * std::numbers::pi; // maxphi + float yMin = -1.; // min q/pt, -1/1 GeV + float yMax = 1.; // max q/pt, +1/1 GeV /// Size of the houghHists. One obvious concern with this being too big is /// that it will take up more memory But the bins of the houghHist are diff --git a/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp index 48f1490946e..677ba2b4c10 100644 --- a/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -108,11 +109,11 @@ ActsExamples::ProcessCode ActsExamples::GbtsSeedingAlgorithm::execute( finder.loadSpacePoints(GbtsSpacePoints); // trigGbts file : - Acts::RoiDescriptor internalRoi(0, -4.5, 4.5, 0, -M_PI, M_PI, 0, -150.0, - 150.0); + Acts::RoiDescriptor internalRoi(0, -4.5, 4.5, 0, -std::numbers::pi, + std::numbers::pi, 0, -150., 150.); // ROI file: - // Acts::RoiDescriptor internalRoi(0, -5, 5, 0, -M_PI, M_PI, 0, -225.0, - // 225.0); + // Acts::RoiDescriptor internalRoi(0, -5, 5, 0, -std::numbers::pi, + // std::numbers::pi, 0, -225., 225.); // new version returns seeds SimSeedContainer seeds = finder.createSeeds(internalRoi, *m_gbtsGeo); diff --git a/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp b/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp index 5a21d36dd65..5f396bbe4e8 100644 --- a/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp +++ b/Examples/Detectors/GenericDetector/src/BuildGenericDetector.cpp @@ -9,6 +9,7 @@ #include "ActsExamples/GenericDetector/BuildGenericDetector.hpp" #include +#include namespace ActsExamples::Generic { @@ -22,8 +23,8 @@ std::vector modulePositionsCylinder( std::vector mPositions; mPositions.reserve(nPhiBins * nZbins); // prep work - double phiStep = 2 * M_PI / nPhiBins; - double minPhi = -M_PI + 0.5 * phiStep; + double phiStep = 2 * std::numbers::pi / nPhiBins; + double minPhi = -std::numbers::pi + 0.5 * phiStep; double zStart = -0.5 * (nZbins - 1) * (2 * moduleHalfLength - lOverlap); double zStep = 2 * std::abs(zStart) / (nZbins - 1); // loop over the bins @@ -102,8 +103,8 @@ std::vector modulePositionsRing(double z, double radius, std::vector rPositions; rPositions.reserve(nPhiBins); // prep work - double phiStep = 2 * M_PI / nPhiBins; - double minPhi = -M_PI + 0.5 * phiStep; + double phiStep = 2 * std::numbers::pi / nPhiBins; + double minPhi = -std::numbers::pi + 0.5 * phiStep; // phi loop for (std::size_t iphi = 0; iphi < static_cast(nPhiBins); ++iphi) { diff --git a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp index bdfe8fe532c..f6431c5ddbe 100644 --- a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp +++ b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -188,9 +189,10 @@ ActsExamples::MockupSectorBuilder::buildSector( // calculate the phi angles of the vectors auto phiA = Acts::VectorHelpers::phi(pointA); auto phiB = Acts::VectorHelpers::phi(pointB); - auto sectorAngle = M_PI; + Acts::ActsScalar sectorAngle = std::numbers::pi_v; - auto halfPhi = M_PI / mCfg.NumberOfSectors; + Acts::ActsScalar halfPhi = + std::numbers::pi_v / mCfg.NumberOfSectors; if (mCfg.NumberOfSectors == 1) { halfPhi = (phiB - phiA) / 2; @@ -223,7 +225,7 @@ ActsExamples::MockupSectorBuilder::buildSector( const Acts::Vector3 pos = {0., 0., 0.}; // the transform of the cylinder volume - Acts::AngleAxis3 rotZ(M_PI / 2, Acts::Vector3(0., 0., 1)); + Acts::AngleAxis3 rotZ(std::numbers::pi / 2., Acts::Vector3(0., 0., 1)); auto transform = Acts::Transform3(Acts::Translation3(pos)); transform *= rotZ; diff --git a/Examples/Io/Csv/src/CsvSeedWriter.cpp b/Examples/Io/Csv/src/CsvSeedWriter.cpp index fe9d881c24f..29dd72ce8df 100644 --- a/Examples/Io/Csv/src/CsvSeedWriter.cpp +++ b/Examples/Io/Csv/src/CsvSeedWriter.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -124,9 +125,10 @@ ActsExamples::ProcessCode ActsExamples::CsvSeedWriter::writeT( float truthPhi = phi(truthUnitDir); float truthEta = std::atanh(std::cos(theta(truthUnitDir))); float dEta = std::abs(truthEta - seedEta); - float dPhi = std::abs(truthPhi - seedPhi) < M_PI - ? std::abs(truthPhi - seedPhi) - : std::abs(truthPhi - seedPhi) - M_PI; + float dPhi = + std::abs(truthPhi - seedPhi) < std::numbers::pi_v + ? std::abs(truthPhi - seedPhi) + : std::abs(truthPhi - seedPhi) - std::numbers::pi_v; truthDistance = sqrt(dPhi * dPhi + dEta * dEta); // If the seed is truth matched, check if it is the closest one for the // contributing particle diff --git a/Examples/Io/Root/src/RootTrackParameterWriter.cpp b/Examples/Io/Root/src/RootTrackParameterWriter.cpp index d413adc519d..a4e74a44e2c 100644 --- a/Examples/Io/Root/src/RootTrackParameterWriter.cpp +++ b/Examples/Io/Root/src/RootTrackParameterWriter.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -284,7 +285,7 @@ ProcessCode RootTrackParameterWriter::writeT( m_res_loc0 = m_loc0 - m_t_loc0; m_res_loc1 = m_loc1 - m_t_loc1; m_res_phi = Acts::detail::difference_periodic( - m_phi, m_t_phi, static_cast(2 * M_PI)); + m_phi, m_t_phi, static_cast(2 * std::numbers::pi)); m_res_theta = m_theta - m_t_theta; m_res_qop = m_qop - m_t_qop; m_res_time = m_time - m_t_time; diff --git a/Examples/Io/Root/src/RootTrackStatesWriter.cpp b/Examples/Io/Root/src/RootTrackStatesWriter.cpp index 160eada776b..edf396384de 100644 --- a/Examples/Io/Root/src/RootTrackStatesWriter.cpp +++ b/Examples/Io/Root/src/RootTrackStatesWriter.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -618,7 +619,7 @@ ProcessCode RootTrackStatesWriter::writeT(const AlgorithmContext& ctx, residuals = parameters - truthParams; residuals[Acts::eBoundPhi] = Acts::detail::difference_periodic( parameters[Acts::eBoundPhi], truthParams[Acts::eBoundPhi], - 2 * M_PI); + 2 * std::numbers::pi); m_res_eLOC0[ipar].push_back( static_cast(residuals[Acts::eBoundLoc0])); m_res_eLOC1[ipar].push_back( diff --git a/Examples/Io/Root/src/RootTrackSummaryWriter.cpp b/Examples/Io/Root/src/RootTrackSummaryWriter.cpp index e3ae0d31943..ad23b4e6195 100644 --- a/Examples/Io/Root/src/RootTrackSummaryWriter.cpp +++ b/Examples/Io/Root/src/RootTrackSummaryWriter.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -418,8 +419,9 @@ ProcessCode RootTrackSummaryWriter::writeT(const AlgorithmContext& ctx, if (foundMajorityParticle && hasFittedParams) { res = {param[Acts::eBoundLoc0] - t_d0, param[Acts::eBoundLoc1] - t_z0, - Acts::detail::difference_periodic(param[Acts::eBoundPhi], t_phi, - static_cast(2 * M_PI)), + Acts::detail::difference_periodic( + param[Acts::eBoundPhi], t_phi, + static_cast(2 * std::numbers::pi)), param[Acts::eBoundTheta] - t_theta, param[Acts::eBoundQOverP] - t_qop, param[Acts::eBoundTime] - t_time}; diff --git a/Examples/Io/Root/src/VertexNTupleWriter.cpp b/Examples/Io/Root/src/VertexNTupleWriter.cpp index c5a800741d3..07c71f115c1 100644 --- a/Examples/Io/Root/src/VertexNTupleWriter.cpp +++ b/Examples/Io/Root/src/VertexNTupleWriter.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -847,7 +848,7 @@ ProcessCode VertexNTupleWriter::writeT( // Accounting for the periodicity of phi. We overwrite the // previously computed value for better readability. diffMom[0] = Acts::detail::difference_periodic(recoMom(0), trueMom(0), - 2 * M_PI); + 2 * std::numbers::pi); innerResPhi.push_back(diffMom[0]); innerResTheta.push_back(diffMom[1]); innerResQOverP.push_back(diffMom[2]); @@ -900,7 +901,7 @@ ProcessCode VertexNTupleWriter::writeT( // Accounting for the periodicity of phi. We overwrite the // previously computed value for better readability. diffMomFitted[0] = Acts::detail::difference_periodic( - recoMomFitted(0), trueMom(0), 2 * M_PI); + recoMomFitted(0), trueMom(0), 2 * std::numbers::pi); innerResPhiFitted.push_back(diffMomFitted[0]); innerResThetaFitted.push_back(diffMomFitted[1]); innerResQOverPFitted.push_back(diffMomFitted[2]); diff --git a/Examples/Python/src/Geometry.cpp b/Examples/Python/src/Geometry.cpp index d676dbe6243..ee98bac3fb5 100644 --- a/Examples/Python/src/Geometry.cpp +++ b/Examples/Python/src/Geometry.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -200,7 +201,7 @@ void addGeometry(Context& ctx) { Acts::VolumeBounds>(m, "CylinderVolumeBounds") .def(py::init(), - "rmin"_a, "rmax"_a, "halfz"_a, "halfphi"_a = M_PI, + "rmin"_a, "rmax"_a, "halfz"_a, "halfphi"_a = std::numbers::pi, "avgphi"_a = 0., "bevelMinZ"_a = 0., "bevelMaxZ"_a = 0.); py::enum_(cvb, "Face") diff --git a/Examples/Scripts/MaterialMapping/materialComposition.C b/Examples/Scripts/MaterialMapping/materialComposition.C index c041930ff00..91293812abf 100644 --- a/Examples/Scripts/MaterialMapping/materialComposition.C +++ b/Examples/Scripts/MaterialMapping/materialComposition.C @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -56,9 +57,9 @@ struct MaterialHistograms { : name + std::string("_l0_vs_phi_A") + std::to_string(iA); x0_vs_phi = - new TProfile(x0NamePhi.c_str(), "X_{0} vs. #phi", bins, -M_PI, M_PI); + new TProfile(x0NamePhi.c_str(), "X_{0} vs. #phi", bins, -std::numbers::pi, std::numbers::pi); l0_vs_phi = - new TProfile(l0NamePhi.c_str(), "L_{0} vs. #phi", bins, -M_PI, M_PI); + new TProfile(l0NamePhi.c_str(), "L_{0} vs. #phi", bins, -std::numbers::pi, std::numbers::pi); } /// This fills the event into the histograms diff --git a/Examples/Scripts/TrackingPerformance/TrackSummary.cpp b/Examples/Scripts/TrackingPerformance/TrackSummary.cpp index d606d07980b..deba72311d5 100644 --- a/Examples/Scripts/TrackingPerformance/TrackSummary.cpp +++ b/Examples/Scripts/TrackingPerformance/TrackSummary.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -79,7 +80,8 @@ int main(int argc, char** argv) { ao("phi-bins", value()->default_value(10), "Number of bins in phi."); ao("phi-range", - value()->value_name("MIN:MAX")->default_value({-M_PI, M_PI}), + value()->value_name("MIN:MAX")->default_value( + {-std::numbers::pi, std::numbers::pi}), "Range for the phi bins."); ao("pt-borders", value()->required(), "Transverse momentum borders."); @@ -141,8 +143,8 @@ int main(int argc, char** argv) { unsigned int nPhiBins = vm["phi-bins"].as(); auto phiInterval = vm["phi-range"].as(); std::array phiRange = { - static_cast(phiInterval.lower.value_or(-M_PI)), - static_cast(phiInterval.upper.value_or(M_PI))}; + static_cast(phiInterval.lower.value_or(-std::numbers::pi)), + static_cast(phiInterval.upper.value_or(std::numbers::pi))}; auto ptBorders = vm["pt-borders"].as().values; if (ptBorders.empty()) { diff --git a/Examples/Scripts/TrackingPerformance/trackSummaryAnalysis.C b/Examples/Scripts/TrackingPerformance/trackSummaryAnalysis.C index 2b32ca271ee..317c7d4c11e 100644 --- a/Examples/Scripts/TrackingPerformance/trackSummaryAnalysis.C +++ b/Examples/Scripts/TrackingPerformance/trackSummaryAnalysis.C @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -56,7 +57,7 @@ int trackSummaryAnalysis( const std::string& outConfig = "", unsigned long nEntries = 0, unsigned int nPeakEntries = 0, float pullRange = 6., unsigned int nHistBins = 61, unsigned int nPhiBins = 10, - const std::array& phiRange = {-M_PI, M_PI}, + const std::array& phiRange = {-std::numbers::pi_v, std::numbers::pi_v}, unsigned int nEtaBins = 10, const std::array& etaRange = {-3, 3}, const std::vector& ptBorders = {0., std::numeric_limits::infinity()}, diff --git a/Examples/Scripts/momentumDistributions.C b/Examples/Scripts/momentumDistributions.C index e16a1b709db..211477e9b0e 100644 --- a/Examples/Scripts/momentumDistributions.C +++ b/Examples/Scripts/momentumDistributions.C @@ -8,6 +8,8 @@ #include "Acts/Utilities/AngleHelpers.hpp" +#include + #include "TFile.h" #include "TH1F.h" #include "TH2F.h" @@ -23,7 +25,7 @@ void momentumDistributions(std::string inFile, std::string treeName, std::string outFile, int nBins, float r, float zMin, float zMax, float etaMin, float etaMax, - float thetaMin = 0., float thetaMax = M_PI) { + float thetaMin = 0., float thetaMax = std::numbers::pi_v) { std::cout << "Opening file: " << inFile << std::endl; TFile inputFile(inFile.c_str()); std::cout << "Reading tree: " << treeName << std::endl; diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp index 416497c77e0..d0529837b7f 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp @@ -14,6 +14,7 @@ #include #include +#include #include namespace ActsFatras { @@ -58,8 +59,8 @@ struct BetheHeitler { const Acts::MaterialSlab &slab, Particle &particle) const { // Take a random gamma-distributed value - depending on t/X0 - std::gamma_distribution gDist(slab.thicknessInX0() / std::log(2.0), - 1.0); + std::gamma_distribution gDist( + slab.thicknessInX0() / std::numbers::ln2, 1.); const auto u = gDist(generator); const auto z = std::exp(-u); // MARK: fpeMask(FLTUND, 1, #2346) diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp index 6bc567dfd1d..d54b17e7407 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -241,8 +242,8 @@ Particle::Vector3 PhotonConversion::generateChildDirection( : u * 1. / 3.; // 9./(9.+27) = 0.25 // draw the random orientation angle - const auto psi = - std::uniform_real_distribution(-M_PI, M_PI)(generator); + const auto psi = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi)(generator); Acts::Vector3 direction = particle.direction(); // construct the combined rotation to the scattered direction diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp index 82ca49200d1..054aacded9f 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/Scattering.hpp @@ -17,6 +17,7 @@ #include "ActsFatras/Physics/ElectroMagnetic/detail/Highland.hpp" #include +#include #include namespace ActsFatras { @@ -52,8 +53,8 @@ struct GenericScattering { // drawn from the specific scattering model distribution. // draw the random orientation angle - const auto psi = - std::uniform_real_distribution(-M_PI, M_PI)(generator); + const auto psi = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi)(generator); // draw the scattering angle const auto theta = angle(generator, slab, particle); diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GaussianMixture.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GaussianMixture.hpp index 771d7edaf11..54c2afce19f 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GaussianMixture.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GaussianMixture.hpp @@ -10,6 +10,7 @@ #include "Acts/Material/Interactions.hpp" +#include #include namespace ActsFatras::detail { @@ -84,7 +85,7 @@ struct GaussianMixture { sigma2 *= (1. - (1. - epsilon) * sigma1square) / epsilon; } // return back to the - return M_SQRT2 * std::sqrt(sigma2) * gaussDist(generator); + return std::numbers::sqrt2 * std::sqrt(sigma2) * gaussDist(generator); } }; diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GeneralMixture.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GeneralMixture.hpp index 5a9e2d2b7a3..621aae2180a 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GeneralMixture.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/GeneralMixture.hpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/PdgParticle.hpp" #include "Acts/Material/Interactions.hpp" +#include #include namespace ActsFatras::detail { @@ -87,7 +88,7 @@ struct GeneralMixture { theta = std::normal_distribution(0.0, theta0)(generator); } // scale from planar to 3d angle - return M_SQRT2 * theta; + return std::numbers::sqrt2 * theta; } // helper methods for getting parameters and simulating diff --git a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/Highland.hpp b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/Highland.hpp index e3a0f59f84c..cee57f0248b 100644 --- a/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/Highland.hpp +++ b/Fatras/include/ActsFatras/Physics/ElectroMagnetic/detail/Highland.hpp @@ -10,6 +10,7 @@ #include "Acts/Material/Interactions.hpp" +#include #include namespace ActsFatras::detail { @@ -35,7 +36,8 @@ struct Highland { slab, particle.absolutePdg(), particle.mass(), particle.qOverP(), particle.absoluteCharge()); // draw from the normal distribution representing the 3d angle distribution - return std::normal_distribution(0.0, M_SQRT2 * theta0)(generator); + return std::normal_distribution( + 0., std::numbers::sqrt2 * theta0)(generator); } }; diff --git a/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp b/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp index b1066919dc7..89072e78536 100644 --- a/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp +++ b/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -517,9 +518,9 @@ std::vector NuclearInteraction::convertParametersToParticles( const float p1p2 = 2. * momentum * parametrizedMomentum; const float costheta = 1. - invariantMass * invariantMass / p1p2; - const auto phiTheta = - globalAngle(phi, theta, uniformDistribution(generator) * 2. * M_PI, - std::acos(costheta)); + const auto phiTheta = globalAngle( + phi, theta, uniformDistribution(generator) * 2. * std::numbers::pi, + std::acos(costheta)); const auto direction = Acts::makeDirectionFromPhiTheta(phiTheta.first, phiTheta.second); diff --git a/Fatras/src/Digitization/PlanarSurfaceMask.cpp b/Fatras/src/Digitization/PlanarSurfaceMask.cpp index 490100e8180..1b73ff409e6 100644 --- a/Fatras/src/Digitization/PlanarSurfaceMask.cpp +++ b/Fatras/src/Digitization/PlanarSurfaceMask.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace { @@ -217,7 +218,7 @@ ActsFatras::PlanarSurfaceMask::radialMask(const Acts::RadialBounds& rBounds, }; // Intersect phi lines - if ((M_PI - hPhi) > Acts::s_epsilon) { + if ((std::numbers::pi - hPhi) > Acts::s_epsilon) { if (sPhi < phii[0] || ePhi < phii[0]) { intersectPhiLine(phii[0]); } diff --git a/Fatras/src/Physics/BetheHeitler.cpp b/Fatras/src/Physics/BetheHeitler.cpp index 66d8d8176a0..af8cbd2711f 100644 --- a/Fatras/src/Physics/BetheHeitler.cpp +++ b/Fatras/src/Physics/BetheHeitler.cpp @@ -16,6 +16,7 @@ #include #include +#include #include ActsFatras::Particle ActsFatras::BetheHeitler::bremPhoton( @@ -30,7 +31,7 @@ ActsFatras::Particle ActsFatras::BetheHeitler::bremPhoton( // later // the azimutal angle - Scalar psi = 2. * M_PI * rndPsi; + Scalar psi = 2. * std::numbers::pi * rndPsi; // the start of the equation Scalar theta = 0.; diff --git a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/LayerSvgConverter.hpp b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/LayerSvgConverter.hpp index 9743d95f33e..079f5ae7aec 100644 --- a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/LayerSvgConverter.hpp +++ b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/LayerSvgConverter.hpp @@ -14,6 +14,8 @@ #include #include +#include + namespace Acts { class Layer; @@ -26,7 +28,9 @@ static std::array noLimitZ = { std::numeric_limits::lowest(), std::numeric_limits::max()}; -static std::array noLimitPhi = {-M_PI, M_PI}; +static std::array noLimitPhi = { + -std::numbers::pi_v, + std::numbers::pi_v}; namespace LayerConverter { diff --git a/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp b/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp index 5cffbe73a1a..7cb9ec40897 100644 --- a/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp +++ b/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp @@ -14,6 +14,7 @@ #include "Acts/Surfaces/SurfaceBounds.hpp" #include +#include std::tuple, Acts::Svg::ProtoGrid, std::vector > @@ -164,7 +165,8 @@ Acts::Svg::SurfaceArrayConverter::convert( Vector3 localZ = sTransform.rotation().col(2); // Find out orientation w.r.t. global transform ActsScalar projZ = localZ.dot(Vector3(0., 0., 1.)); - ActsScalar alpha = std::atan2(localA[1], localA[0]) / M_PI * 180.; + ActsScalar alpha = + std::atan2(localA[1], localA[0]) / std::numbers::pi * 180.; if (projZ < 0.) { alpha += 180.; } diff --git a/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp b/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp index 349050c8fc0..d96ef4ec228 100644 --- a/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp +++ b/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp @@ -8,6 +8,8 @@ #include "Acts/Plugins/DD4hep/DD4hepBinningHelpers.hpp" +#include + std::vector Acts::DD4hepBinningHelpers::convertBinning( const dd4hep::DetElement &dd4hepElement, const std::string &bname) { @@ -36,14 +38,19 @@ Acts::DD4hepBinningHelpers::convertBinning( Experimental::ProtoBinning(bVal, bType, nBins, nExpansion)); } else { // Equidistant binning - ActsScalar minDefault = bVal == BinningValue::binPhi ? -M_PI : 0.; - ActsScalar maxDefault = bVal == BinningValue::binPhi ? M_PI : 0.; + ActsScalar minDefault = bVal == BinningValue::binPhi + ? -std::numbers::pi_v + : 0.; + ActsScalar maxDefault = bVal == BinningValue::binPhi + ? std::numbers::pi_v + : 0.; auto min = getParamOr(bname + "_" + ab + "_min", dd4hepElement, minDefault); auto max = getParamOr(bname + "_" + ab + "_max", dd4hepElement, maxDefault); // Check for closed phi binning - if (bVal == BinningValue::binPhi && (max - min) > 1.9 * M_PI) { + if (bVal == BinningValue::binPhi && + (max - min) > 1.9 * std::numbers::pi) { bType = Acts::AxisBoundaryType::Closed; } protoBinnings.push_back(Experimental::ProtoBinning( @@ -58,7 +65,7 @@ Acts::DD4hepBinningHelpers::convertBinning( } // Check for closed phi binning if (bVal == BinningValue::binPhi && - (edges.back() - edges.front()) > 1.9 * M_PI) { + (edges.back() - edges.front()) > 1.9 * std::numbers::pi) { bType = Acts::AxisBoundaryType::Closed; } protoBinnings.push_back( diff --git a/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp b/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp index 3c897a5ddef..c3d6b346c72 100644 --- a/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp +++ b/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -40,8 +41,8 @@ std::shared_ptr Acts::createProtoMaterial( double min = 0.; double max = 0.; if (bopt == Acts::closed) { - min = -M_PI; - max = M_PI; + min = -std::numbers::pi; + max = std::numbers::pi; } int bins = params.get(valueTag + "_"s + bin.first); ACTS_VERBOSE(" - material binning for " << bin.first << " on " << valueTag diff --git a/Plugins/Detray/src/DetrayMaterialConverter.cpp b/Plugins/Detray/src/DetrayMaterialConverter.cpp index c08bdc447bf..f6b61236ec5 100644 --- a/Plugins/Detray/src/DetrayMaterialConverter.cpp +++ b/Plugins/Detray/src/DetrayMaterialConverter.cpp @@ -18,6 +18,7 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Helpers.hpp" +#include #include namespace { @@ -157,10 +158,12 @@ Acts::DetrayMaterialConverter::convertGridSurfaceMaterial( swapped = true; } else if (bUtility.binningData()[0u].binvalue == BinningValue::binR) { // Turn to R-Phi - bUtility += BinUtility(1u, -M_PI, M_PI, closed, BinningValue::binPhi); + bUtility += BinUtility(1u, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); } else if (bUtility.binningData()[0u].binvalue == BinningValue::binZ) { // Turn to Phi-Z - swap needed - BinUtility nbUtility(1u, -M_PI, M_PI, closed, BinningValue::binPhi); + BinUtility nbUtility(1u, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); nbUtility += bUtility; bUtility = std::move(nbUtility); swapped = true; diff --git a/Plugins/EDM4hep/src/EDM4hepUtil.cpp b/Plugins/EDM4hep/src/EDM4hepUtil.cpp index d90e555f173..515063da679 100644 --- a/Plugins/EDM4hep/src/EDM4hepUtil.cpp +++ b/Plugins/EDM4hep/src/EDM4hepUtil.cpp @@ -16,6 +16,8 @@ #include "Acts/Propagator/detail/CovarianceEngine.hpp" #include "Acts/Propagator/detail/JacobianEngine.hpp" +#include + #include "edm4hep/TrackState.h" namespace Acts::EDM4hepUtil::detail { @@ -149,7 +151,8 @@ Parameters convertTrackParametersToEdm4hep(const Acts::GeometryContext& gctx, result.values[0] = targetPars[Acts::eBoundLoc0]; result.values[1] = targetPars[Acts::eBoundLoc1]; result.values[2] = targetPars[Acts::eBoundPhi]; - result.values[3] = std::tan(M_PI_2 - targetPars[Acts::eBoundTheta]); + result.values[3] = + std::tan(std::numbers::pi / 2. - targetPars[Acts::eBoundTheta]); result.values[4] = targetPars[Acts::eBoundQOverP] / std::sin(targetPars[Acts::eBoundTheta]) * Bz; result.values[5] = targetPars[Acts::eBoundTime]; @@ -174,7 +177,7 @@ BoundTrackParameters convertTrackParametersFromEdm4hep( targetPars[eBoundLoc0] = params.values[0]; targetPars[eBoundLoc1] = params.values[1]; targetPars[eBoundPhi] = params.values[2]; - targetPars[eBoundTheta] = M_PI_2 - std::atan(params.values[3]); + targetPars[eBoundTheta] = std::numbers::pi / 2. - std::atan(params.values[3]); targetPars[eBoundQOverP] = params.values[4] * std::sin(targetPars[eBoundTheta]) / Bz; targetPars[eBoundTime] = params.values[5]; diff --git a/Plugins/Geant4/src/Geant4Converters.cpp b/Plugins/Geant4/src/Geant4Converters.cpp index db7d9f93f1e..d75e73ea13c 100644 --- a/Plugins/Geant4/src/Geant4Converters.cpp +++ b/Plugins/Geant4/src/Geant4Converters.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -98,9 +99,9 @@ Acts::Geant4ShapeConverter::cylinderBounds(const G4Tubs& g4Tubs) { tArray[B::eHalfLengthZ] = static_cast(g4Tubs.GetZHalfLength()); tArray[B::eHalfPhiSector] = 0.5 * static_cast(g4Tubs.GetDeltaPhiAngle()); - // Geant fiddles around with user given values, i.e. it would not - // allow [-M_PI, +M_PI) as a full segment (has to be [0, 2PI)]) - if (std::abs(tArray[B::eHalfPhiSector] - M_PI) < + // Geant fiddles around with user given values, i.e. it would not allow [-PI, + // +PI) as a full segment (has to be [0, 2PI)]) + if (std::abs(tArray[B::eHalfPhiSector] - std::numbers::pi) < std::numeric_limits::epsilon()) { tArray[B::eAveragePhi] = 0.; } else { @@ -122,9 +123,9 @@ Acts::Geant4ShapeConverter::radialBounds(const G4Tubs& g4Tubs) { tArray[B::eMaxR] = static_cast(g4Tubs.GetOuterRadius()); tArray[B::eHalfPhiSector] = 0.5 * static_cast(g4Tubs.GetDeltaPhiAngle()); - // Geant fiddles around with user given values, i.e. it would not - // allow [-M_PI, +M_PI) as a full segment (has to be [0, 2PI)]) - if (std::abs(tArray[B::eHalfPhiSector] - M_PI) < + // Geant fiddles around with user given values, i.e. it would not allow [-PI, + // +PI) as a full segment (has to be [0, 2PI)]) + if (std::abs(tArray[B::eHalfPhiSector] - std::numbers::pi) < std::numeric_limits::epsilon()) { tArray[B::eAveragePhi] = 0.; } else { diff --git a/Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp b/Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp index f784a12a990..854c85103af 100644 --- a/Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp +++ b/Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp @@ -18,6 +18,8 @@ #include "Acts/Navigation/DetectorVolumeFinders.hpp" #include "Acts/Navigation/InternalNavigation.hpp" +#include + #include #include #include @@ -65,23 +67,23 @@ Volume convertVolume(const Transform3& trf, const GeoShape& shape) { if (x1 <= x2) { // y axis in ACTS is z axis in geomodel bounds = std::make_shared(x1, x2, z, y1); - constexpr double rotationAngle = M_PI / 2; + constexpr double rotationAngle = std::numbers::pi / 2.; newTrf = trf * GeoTrf::RotateX3D(rotationAngle); } else { bounds = std::make_shared(x2, x1, z, y1); - constexpr double rotationAngle = M_PI; + constexpr double rotationAngle = std::numbers::pi; newTrf = trf * GeoTrf::RotateY3D(rotationAngle) * GeoTrf::RotateZ3D(rotationAngle); } } else if (x1 == x2) { if (y1 < y2) { bounds = std::make_shared(y1, y2, z, x1); - auto rotationAngle = M_PI / 2; + auto rotationAngle = std::numbers::pi / 2.; newTrf = trf * GeoTrf::RotateZ3D(rotationAngle) * GeoTrf::RotateX3D(rotationAngle); } else { bounds = std::make_shared(y2, y1, z, x1); - auto rotationAngle = M_PI; + auto rotationAngle = std::numbers::pi; newTrf = trf * GeoTrf::RotateX3D(rotationAngle) * GeoTrf::RotateZ3D(rotationAngle / 2) * GeoTrf::RotateX3D(rotationAngle / 2); diff --git a/Plugins/GeoModel/src/detail/GeoModelBinningHelper.cpp b/Plugins/GeoModel/src/detail/GeoModelBinningHelper.cpp index 032e3ef9a5c..0cfa03870e8 100644 --- a/Plugins/GeoModel/src/detail/GeoModelBinningHelper.cpp +++ b/Plugins/GeoModel/src/detail/GeoModelBinningHelper.cpp @@ -8,6 +8,8 @@ #include "Acts/Plugins/GeoModel/detail/GeoModelBinningHelper.hpp" +#include + #include Acts::Experimental::ProtoBinning @@ -47,8 +49,8 @@ Acts::detail::GeoModelBinningHelper::toProtoBinning( ActsScalar rangeMax = 0.; if (bValue == BinningValue::binPhi && boundaryType == AxisBoundaryType::Closed) { - rangeMin = -M_PI; - rangeMax = M_PI; + rangeMin = -std::numbers::pi_v; + rangeMax = std::numbers::pi_v; } else { if (binningDetails.size() > 3u && binningDetails[3] != "*") { autoRange = false; diff --git a/Plugins/Hashing/include/Acts/Plugins/Hashing/HashingAnnoy.ipp b/Plugins/Hashing/include/Acts/Plugins/Hashing/HashingAnnoy.ipp index 85680fccaca..d5e4f28f3a5 100644 --- a/Plugins/Hashing/include/Acts/Plugins/Hashing/HashingAnnoy.ipp +++ b/Plugins/Hashing/include/Acts/Plugins/Hashing/HashingAnnoy.ipp @@ -10,6 +10,7 @@ #include "Acts/Definitions/Units.hpp" #include +#include #include #include @@ -67,8 +68,8 @@ void HashingAnnoy:: }; auto getBinIndexPhi = [&phiBins](Scalar phi) { - Scalar binSize = 2 * M_PI / phiBins; - auto binIndex = static_cast((phi + M_PI) / binSize); + Scalar binSize = 2 * std::numbers::pi / phiBins; + auto binIndex = static_cast((phi + std::numbers::pi) / binSize); return binIndex; }; diff --git a/Plugins/Json/src/MaterialJsonConverter.cpp b/Plugins/Json/src/MaterialJsonConverter.cpp index e98df359cf0..a3935d4bbc2 100644 --- a/Plugins/Json/src/MaterialJsonConverter.cpp +++ b/Plugins/Json/src/MaterialJsonConverter.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -687,10 +688,12 @@ nlohmann::json Acts::MaterialJsonConverter::toJsonDetray( if (bUtility.dimensions() == 1u) { if (bUtility.binningData()[0u].binvalue == BinningValue::binR) { // Turn to R-Phi - bUtility += BinUtility(1u, -M_PI, M_PI, closed, BinningValue::binPhi); + bUtility += BinUtility(1u, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); } else if (bUtility.binningData()[0u].binvalue == BinningValue::binZ) { // Turn to Phi-Z - swap needed - BinUtility nbUtility(1u, -M_PI, M_PI, closed, BinningValue::binPhi); + BinUtility nbUtility(1u, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); nbUtility += bUtility; bUtility = std::move(nbUtility); swapped = true; diff --git a/Plugins/Json/src/MaterialMapJsonConverter.cpp b/Plugins/Json/src/MaterialMapJsonConverter.cpp index 2424156ec1d..dc423ecc50b 100644 --- a/Plugins/Json/src/MaterialMapJsonConverter.cpp +++ b/Plugins/Json/src/MaterialMapJsonConverter.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include namespace Acts { @@ -114,8 +115,8 @@ Acts::SurfaceAndMaterialWithContext defaultSurfaceMaterial( radialBounds->get(Acts::RadialBounds::eHalfPhiSector), radialBounds->get(Acts::RadialBounds::eAveragePhi) + radialBounds->get(Acts::RadialBounds::eHalfPhiSector), - (radialBounds->get(Acts::RadialBounds::eHalfPhiSector) - M_PI) < - Acts::s_epsilon + (radialBounds->get(Acts::RadialBounds::eHalfPhiSector) - + std::numbers::pi) < Acts::s_epsilon ? Acts::closed : Acts::open, Acts::BinningValue::binPhi); @@ -129,8 +130,8 @@ Acts::SurfaceAndMaterialWithContext defaultSurfaceMaterial( cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector), cylinderBounds->get(Acts::CylinderBounds::eAveragePhi) + cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector), - (cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector) - M_PI) < - Acts::s_epsilon + (cylinderBounds->get(Acts::CylinderBounds::eHalfPhiSector) - + std::numbers::pi) < Acts::s_epsilon ? Acts::closed : Acts::open, Acts::BinningValue::binPhi); @@ -195,8 +196,8 @@ Acts::TrackingVolumeAndMaterial defaultVolumeMaterial( bUtility += Acts::BinUtility( 1, -cyBounds->get(Acts::CylinderVolumeBounds::eHalfPhiSector), cyBounds->get(Acts::CylinderVolumeBounds::eHalfPhiSector), - (cyBounds->get(Acts::CylinderVolumeBounds::eHalfPhiSector) - M_PI) < - Acts::s_epsilon + (cyBounds->get(Acts::CylinderVolumeBounds::eHalfPhiSector) - + std::numbers::pi) < Acts::s_epsilon ? Acts::closed : Acts::open, Acts::BinningValue::binPhi); @@ -210,9 +211,9 @@ Acts::TrackingVolumeAndMaterial defaultVolumeMaterial( 1, cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eMinR), cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eMaxR), Acts::open, Acts::BinningValue::binR); - bUtility += - Acts::BinUtility(1, -static_cast(M_PI), static_cast(M_PI), - Acts::closed, Acts::BinningValue::binPhi); + bUtility += Acts::BinUtility(1, -std::numbers::pi_v, + std::numbers::pi_v, Acts::closed, + Acts::BinningValue::binPhi); bUtility += Acts::BinUtility( 1, -cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eHalfLengthZ), cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eHalfLengthZ), diff --git a/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp b/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp index 4b5b5c60875..76f53cd12da 100644 --- a/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp +++ b/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp @@ -11,6 +11,7 @@ /////////////////////////////////////////////////////////////////// #include +#include /////////////////////////////////////////////////////////////////// // Constructor @@ -247,7 +248,7 @@ void Acts::Legacy::AtlasSeedFinder::buildFrameWork() { // Build radius-azimuthal sorted containers // - const float pi2 = 2. * M_PI; + const float pi2 = 2. * std::numbers::pi; const int NFmax = 53; const float sFmax = static_cast(NFmax) / pi2; const float m_sFmin = 100. / 60.; @@ -413,7 +414,7 @@ void Acts::Legacy::AtlasSeedFinder::convertToBeamFrameWork( /////////////////////////////////////////////////////////////////// template void Acts::Legacy::AtlasSeedFinder::fillLists() { - const float pi2 = 2. * M_PI; + const float pi2 = 2. * std::numbers::pi; typename std::list*>::iterator r, re; int ir0 = 0; diff --git a/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoSurfaceConverter.hpp b/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoSurfaceConverter.hpp index a489a4743a6..d796e18830d 100644 --- a/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoSurfaceConverter.hpp +++ b/Plugins/TGeo/include/Acts/Plugins/TGeo/TGeoSurfaceConverter.hpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -77,7 +78,7 @@ struct TGeoSurfaceConverter { /// Convert a TGeoShape to a Surface /// /// @param tgShape The TGeoShape - /// @param tgMatrix The matrix representing the tranbsform + /// @param tgMatrix The matrix representing the transform /// @param axes The axes definition /// @param scalor The unit scalor between TGeo and Acts /// @@ -95,7 +96,7 @@ struct TGeoSurfaceConverter { if (degree > 180. && degree < 360.) { degree -= 360.; } - return degree / 180. * M_PI; + return degree / 180. * std::numbers::pi; } }; diff --git a/Plugins/TGeo/src/TGeoCylinderDiscSplitter.cpp b/Plugins/TGeo/src/TGeoCylinderDiscSplitter.cpp index 2dbf09c56ad..4ad967d8c29 100644 --- a/Plugins/TGeo/src/TGeoCylinderDiscSplitter.cpp +++ b/Plugins/TGeo/src/TGeoCylinderDiscSplitter.cpp @@ -19,6 +19,7 @@ #include #include +#include #include Acts::TGeoCylinderDiscSplitter::TGeoCylinderDiscSplitter( @@ -54,7 +55,7 @@ Acts::TGeoCylinderDiscSplitter::split( ActsScalar discMinR = boundValues[Acts::RadialBounds::eMinR]; ActsScalar discMaxR = boundValues[Acts::RadialBounds::eMaxR]; - ActsScalar phiStep = 2 * M_PI / m_cfg.discPhiSegments; + ActsScalar phiStep = 2 * std::numbers::pi / m_cfg.discPhiSegments; ActsScalar cosPhiHalf = std::cos(0.5 * phiStep); ActsScalar sinPhiHalf = std::sin(0.5 * phiStep); @@ -86,11 +87,11 @@ Acts::TGeoCylinderDiscSplitter::split( for (int im = 0; im < m_cfg.discPhiSegments; ++im) { // Get the moduleTransform - ActsScalar phi = -M_PI + im * phiStep; - auto tgTransform = - Transform3(Translation3(hR * std::cos(phi), hR * std::sin(phi), - discCenter.z()) * - AngleAxis3(phi - 0.5 * M_PI, Vector3::UnitZ())); + ActsScalar phi = -std::numbers::pi + im * phiStep; + auto tgTransform = Transform3( + Translation3(hR * std::cos(phi), hR * std::sin(phi), + discCenter.z()) * + AngleAxis3(phi - std::numbers::pi / 2., Vector3::UnitZ())); // Create a new detector element per split auto tgDetectorElement = std::make_shared( @@ -120,7 +121,7 @@ Acts::TGeoCylinderDiscSplitter::split( ActsScalar cylinderHalfZ = boundValues[Acts::CylinderBounds::eHalfLengthZ]; - ActsScalar phiStep = 2 * M_PI / m_cfg.cylinderPhiSegments; + ActsScalar phiStep = 2 * std::numbers::pi / m_cfg.cylinderPhiSegments; ActsScalar cosPhiHalf = std::cos(0.5 * phiStep); ActsScalar sinPhiHalf = std::sin(0.5 * phiStep); @@ -151,7 +152,7 @@ Acts::TGeoCylinderDiscSplitter::split( for (int im = 0; im < m_cfg.cylinderPhiSegments; ++im) { // Get the moduleTransform - ActsScalar phi = -M_PI + im * phiStep; + ActsScalar phi = -std::numbers::pi + im * phiStep; ActsScalar cosPhi = std::cos(phi); ActsScalar sinPhi = std::sin(phi); ActsScalar planeX = planeR * cosPhi; diff --git a/Plugins/TGeo/src/TGeoSurfaceConverter.cpp b/Plugins/TGeo/src/TGeoSurfaceConverter.cpp index 1cbc670e253..a00275f5231 100644 --- a/Plugins/TGeo/src/TGeoSurfaceConverter.cpp +++ b/Plugins/TGeo/src/TGeoSurfaceConverter.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -87,14 +88,14 @@ Acts::TGeoSurfaceConverter::cylinderComponents(const TGeoShape& tgShape, double halfZ = tube->GetDz() * scalor; if (halfZ > deltaR) { transform = TGeoPrimitivesHelper::makeTransform(ax, ay, az, t); - double halfPhi = M_PI; + double halfPhi = std::numbers::pi; double avgPhi = 0.; // Check if it's a segment auto tubeSeg = dynamic_cast(tube); if (tubeSeg != nullptr) { double phi1 = toRadian(tubeSeg->GetPhi1()); double phi2 = toRadian(tubeSeg->GetPhi2()); - if (std::abs(phi2 - phi1) < M_PI * (1. - s_epsilon)) { + if (std::abs(phi2 - phi1) < std::numbers::pi * (1. - s_epsilon)) { if (!boost::starts_with(axes, "X")) { throw std::invalid_argument( "TGeoShape -> CylinderSurface (sectorial): can only be " @@ -176,7 +177,8 @@ Acts::TGeoSurfaceConverter::discComponents(const TGeoShape& tgShape, Vector2 ab = b - a; double phi = VectorHelpers::phi(ab); - if (std::abs(phi) > 3 * M_PI / 4. || std::abs(phi) < M_PI / 4.) { + if (std::abs(phi) > 3 * std::numbers::pi / 4. || + std::abs(phi) < std::numbers::pi / 4.) { if (a.norm() < b.norm()) { boundLines.push_back(std::make_pair(a, b)); } else { @@ -245,14 +247,14 @@ Acts::TGeoSurfaceConverter::discComponents(const TGeoShape& tgShape, double minR = tube->GetRmin() * scalor; double maxR = tube->GetRmax() * scalor; double halfZ = tube->GetDz() * scalor; - double halfPhi = M_PI; + double halfPhi = std::numbers::pi; double avgPhi = 0.; // Check if it's a segment auto tubeSeg = dynamic_cast(tube); if (tubeSeg != nullptr) { double phi1 = toRadian(tubeSeg->GetPhi1()); double phi2 = toRadian(tubeSeg->GetPhi2()); - if (std::abs(phi2 - phi1) < 2 * M_PI * (1. - s_epsilon)) { + if (std::abs(phi2 - phi1) < 2 * std::numbers::pi * (1. - s_epsilon)) { if (!boost::starts_with(axes, "X")) { throw std::invalid_argument( "TGeoShape -> CylinderSurface (sectorial): can only be " diff --git a/Tests/Benchmarks/RayFrustumBenchmark.cpp b/Tests/Benchmarks/RayFrustumBenchmark.cpp index e4f11e60991..c5b666a5f23 100644 --- a/Tests/Benchmarks/RayFrustumBenchmark.cpp +++ b/Tests/Benchmarks/RayFrustumBenchmark.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -38,7 +39,8 @@ int main(int /*argc*/, char** /*argv[]*/) { std::mt19937 rng(42); std::uniform_real_distribution dir(0, 1); std::uniform_real_distribution loc(-10, 10); - std::uniform_real_distribution ang(M_PI / 10., M_PI / 4.); + std::uniform_real_distribution ang(std::numbers::pi / 10., + std::numbers::pi / 4.); Box testBox{nullptr, {0, 0, 0}, Box::Size{{1, 2, 3}}}; @@ -351,7 +353,8 @@ int main(int /*argc*/, char** /*argv[]*/) { return result; }; - std::vector frustums{n, Frustum3{{0, 0, 0}, {1, 0, 0}, M_PI / 2.}}; + std::vector frustums{ + n, Frustum3{{0, 0, 0}, {1, 0, 0}, std::numbers::pi / 2.}}; std::generate(frustums.begin(), frustums.end(), [&]() { const Vector3F d{dir(rng), dir(rng), dir(rng)}; const Vector3F l{loc(rng), loc(rng), loc(rng)}; @@ -392,12 +395,12 @@ int main(int /*argc*/, char** /*argv[]*/) { std::size_t iters_per_run = 1000; std::vector> testFrusts = { - {"away", Frustum3{{0, 0, -10}, {0, 0, -1}, M_PI / 4.}}, - {"towards", Frustum3{{0, 0, -10}, {0, 0, 1}, M_PI / 4.}}, - {"left", Frustum3{{0, 0, -10}, {0, 1, 0}, M_PI / 4.}}, - {"right", Frustum3{{0, 0, -10}, {0, -1, 0}, M_PI / 4.}}, - {"up", Frustum3{{0, 0, -10}, {1, 0, 0}, M_PI / 4.}}, - {"down", Frustum3{{0, 0, -10}, {-1, 0, 0}, M_PI / 4.}}, + {"away", Frustum3{{0, 0, -10}, {0, 0, -1}, std::numbers::pi / 4.}}, + {"towards", Frustum3{{0, 0, -10}, {0, 0, 1}, std::numbers::pi / 4.}}, + {"left", Frustum3{{0, 0, -10}, {0, 1, 0}, std::numbers::pi / 4.}}, + {"right", Frustum3{{0, 0, -10}, {0, -1, 0}, std::numbers::pi / 4.}}, + {"up", Frustum3{{0, 0, -10}, {1, 0, 0}, std::numbers::pi / 4.}}, + {"down", Frustum3{{0, 0, -10}, {-1, 0, 0}, std::numbers::pi / 4.}}, }; std::cout << "Run benchmarks: " << std::endl; diff --git a/Tests/Benchmarks/SolenoidFieldBenchmark.cpp b/Tests/Benchmarks/SolenoidFieldBenchmark.cpp index 22a779f6582..dca46a5e531 100644 --- a/Tests/Benchmarks/SolenoidFieldBenchmark.cpp +++ b/Tests/Benchmarks/SolenoidFieldBenchmark.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -57,7 +58,8 @@ int main(int argc, char* argv[]) { std::minstd_rand rng; std::uniform_real_distribution zDist(1.5 * (-L / 2.), 1.5 * L / 2.); std::uniform_real_distribution rDist(0, R * 1.5); - std::uniform_real_distribution phiDist(-M_PI, M_PI); + std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); auto genPos = [&]() -> Acts::Vector3 { const double z = zDist(rng), r = rDist(rng), phi = phiDist(rng); return {r * std::cos(phi), r * std::sin(phi), z}; diff --git a/Tests/Benchmarks/SurfaceIntersectionBenchmark.cpp b/Tests/Benchmarks/SurfaceIntersectionBenchmark.cpp index acad43fad34..4d92589bd66 100644 --- a/Tests/Benchmarks/SurfaceIntersectionBenchmark.cpp +++ b/Tests/Benchmarks/SurfaceIntersectionBenchmark.cpp @@ -21,6 +21,7 @@ #include "Acts/Tests/CommonHelpers/BenchmarkTools.hpp" #include +#include #include namespace bdata = boost::unit_test::data; @@ -88,8 +89,8 @@ MicroBenchmarkResult intersectionTest(const surface_t& surface, double phi, BOOST_DATA_TEST_CASE( benchmark_surface_intersections, bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, M_PI))) ^ + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 22, bdata::distribution = std::uniform_real_distribution(-0.3, 0.3))) ^ @@ -116,7 +117,8 @@ BOOST_DATA_TEST_CASE( } if (testStraw) { std::cout << "- Straw: " - << intersectionTest(*aStraw, phi, theta + M_PI) + << intersectionTest(*aStraw, phi, + theta + std::numbers::pi) << std::endl; } } diff --git a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp index 947596edbac..4988150c735 100644 --- a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp +++ b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/BenchmarkTools.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -299,7 +300,8 @@ struct MicroBenchmarkResult { // Duration runTimeRobustStddev() const { auto [firstq, thirdq] = runTimeQuartiles(); - return (thirdq - firstq) / (2. * std::sqrt(2.) * 0.4769362762044698733814); + return (thirdq - firstq) / + (2. * std::numbers::sqrt2 * 0.4769362762044698733814); } // Standard error on the median benchmark run time diff --git a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp index 9ff25d480fa..a37bbcb1e8f 100644 --- a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp +++ b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp @@ -36,6 +36,7 @@ #include "Acts/Tests/CommonHelpers/PredefinedMaterials.hpp" #include +#include #include namespace Acts::Test { @@ -88,15 +89,15 @@ struct CylindricalTrackingGeometry { moduleHalfXmaxY, moduleHalfY); } - double phiStep = 2 * M_PI / nPhi; + double phiStep = 2 * std::numbers::pi / nPhi; for (int im = 0; im < nPhi; ++im) { // Get the moduleTransform - double phi = -M_PI + im * phiStep; + double phi = -std::numbers::pi + im * phiStep; auto mModuleTransform = Transform3( Translation3(ringRadius * std::cos(phi), ringRadius * std::sin(phi), ringZ + (im % 2) * zStagger) * - AngleAxis3(phi - 0.5 * M_PI, Vector3::UnitZ()) * + AngleAxis3(phi - std::numbers::pi / 2., Vector3::UnitZ()) * AngleAxis3(moduleTilt, Vector3::UnitY())); // Create the detector element @@ -186,8 +187,8 @@ struct CylindricalTrackingGeometry { std::vector mPositions; mPositions.reserve(nPhiBins * nZbins); // prep work - double phiStep = 2 * M_PI / (nPhiBins); - double minPhi = -M_PI + 0.5 * phiStep; + double phiStep = 2 * std::numbers::pi / (nPhiBins); + double minPhi = -std::numbers::pi + phiStep / 2.; double zStart = -0.5 * (nZbins - 1) * (2 * moduleHalfLength - lOverlap); double zStep = 2 * std::abs(zStart) / (nZbins - 1); // loop over the bins diff --git a/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp b/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp index 5c3b0aa9ee2..9bfd63e6a88 100644 --- a/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp +++ b/Tests/IntegrationTests/InterpolatedSolenoidBFieldTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -100,10 +101,10 @@ BOOST_DATA_TEST_CASE( bdata::distribution = std::uniform_real_distribution(0, R * 1.5))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 3, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::xrange(ntests), z, r, phi, index) { if (index % 1000 == 0) { diff --git a/Tests/IntegrationTests/NavigatorConsistency.cpp b/Tests/IntegrationTests/NavigatorConsistency.cpp index f084afeae6b..ea74491a1c0 100644 --- a/Tests/IntegrationTests/NavigatorConsistency.cpp +++ b/Tests/IntegrationTests/NavigatorConsistency.cpp @@ -24,6 +24,7 @@ #include "Acts/Utilities/VectorHelpers.hpp" #include +#include namespace bdata = boost::unit_test::data; using namespace Acts::UnitLiterals; @@ -356,11 +357,11 @@ auto eventGen = bdata::distribution = std::uniform_real_distribution( 0.5_GeV, 10_GeV))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, M_PI))) ^ + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 22, bdata::distribution = std::uniform_real_distribution( - 1.0, M_PI - 1.0))) ^ + 1., std::numbers::pi - 1.))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 23, bdata::distribution = std::uniform_int_distribution(0, 1))); diff --git a/Tests/IntegrationTests/PropagationTests.hpp b/Tests/IntegrationTests/PropagationTests.hpp index 9355e726b3b..fc2e2cfcfe5 100644 --- a/Tests/IntegrationTests/PropagationTests.hpp +++ b/Tests/IntegrationTests/PropagationTests.hpp @@ -21,6 +21,7 @@ #include "Acts/Utilities/UnitVectors.hpp" #include "Acts/Utilities/detail/periodic.hpp" +#include #include // parameter construction helpers @@ -33,7 +34,7 @@ inline Acts::CurvilinearTrackParameters makeParametersCurvilinear( // phi is ill-defined in forward/backward tracks. normalize the value to // ensure parameter comparisons give correct answers. - if (!((0 < theta) && (theta < M_PI))) { + if (!((0 < theta) && (theta < std::numbers::pi))) { phi = 0; } @@ -52,7 +53,7 @@ inline Acts::CurvilinearTrackParameters makeParametersCurvilinearWithCovariance( // phi is ill-defined in forward/backward tracks. normalize the value to // ensure parameter comparisons give correct answers. - if (!((0 < theta) && (theta < M_PI))) { + if (!((0 < theta) && (theta < std::numbers::pi))) { phi = 0; } @@ -89,7 +90,7 @@ inline Acts::CurvilinearTrackParameters makeParametersCurvilinearNeutral( // phi is ill-defined in forward/backward tracks. normalize the value to // ensure parameter comparisons give correct answers. - if (!((0 < theta) && (theta < M_PI))) { + if (!((0 < theta) && (theta < std::numbers::pi))) { phi = 0; } diff --git a/Tests/UnitTests/Core/Definitions/UnitsTests.cpp b/Tests/UnitTests/Core/Definitions/UnitsTests.cpp index 6ca934ea751..1cb42011e21 100644 --- a/Tests/UnitTests/Core/Definitions/UnitsTests.cpp +++ b/Tests/UnitTests/Core/Definitions/UnitsTests.cpp @@ -13,6 +13,7 @@ #include #include +#include using namespace Acts::UnitLiterals; @@ -63,10 +64,10 @@ BOOST_AUTO_TEST_CASE(Time) { } BOOST_AUTO_TEST_CASE(Angle) { - CHECK_CLOSE_REL(45_degree, M_PI / 4 * 1_rad, eps); - CHECK_CLOSE_REL(90_degree, M_PI / 2 * 1_rad, eps); - CHECK_CLOSE_REL(180_degree, M_PI * 1_rad, eps); - CHECK_CLOSE_REL(360_degree, 2 * M_PI * 1_rad, eps); + CHECK_CLOSE_REL(45_degree, std::numbers::pi / 4. * 1_rad, eps); + CHECK_CLOSE_REL(90_degree, std::numbers::pi / 2. * 1_rad, eps); + CHECK_CLOSE_REL(180_degree, std::numbers::pi * 1_rad, eps); + CHECK_CLOSE_REL(360_degree, 2 * std::numbers::pi * 1_rad, eps); CHECK_CLOSE_REL(1_mm / 1_m, 1_mrad, eps); CHECK_CLOSE_REL(1_um / 1_mm, 1_mrad, eps); } @@ -126,8 +127,10 @@ BOOST_AUTO_TEST_CASE(MomentumRadius) { BOOST_AUTO_TEST_CASE(PhysicalConstants) { using Acts::PhysicalConstants::hbar; // see https://en.wikipedia.org/wiki/Planck_constant - CHECK_CLOSE_REL(hbar, 6.62607015e-34 * 1_J * 1_s / (2 * M_PI), 1e-6); - CHECK_CLOSE_REL(hbar, 4.135667696e-15 * 1_eV * 1_s / (2 * M_PI), 1e-7); + CHECK_CLOSE_REL(hbar, 6.62607015e-34 * 1_J * 1_s / (2 * std::numbers::pi), + 1e-6); + CHECK_CLOSE_REL(hbar, 4.135667696e-15 * 1_eV * 1_s / (2 * std::numbers::pi), + 1e-7); using Acts::PhysicalConstants::c; // we really want c to be 1 diff --git a/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp b/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp index d99fd272a16..87681ee8ae0 100644 --- a/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -131,8 +132,8 @@ BOOST_AUTO_TEST_CASE(CylindricaContainerBuildingZ) { // Create a materialBinning tripleZCfg.portalMaterialBinning[2u] = BinningDescription{ {ProtoBinning(BinningValue::binZ, Acts::AxisBoundaryType::Bound, 50), - ProtoBinning(BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, - M_PI, 12)}}; + ProtoBinning(BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 12)}}; // Let's test the reverse generation tripleZCfg.geoIdReverseGen = true; @@ -201,16 +202,18 @@ BOOST_AUTO_TEST_CASE(CylindricaContainerBuildingPhi) { barrelPhiCfg.binning = {BinningValue::binPhi}; unsigned int phiSectors = 5; - Acts::ActsScalar phiHalfSector = M_PI / phiSectors; + Acts::ActsScalar phiHalfSector = std::numbers::pi / phiSectors; std::vector> phiVolumes = {}; for (unsigned int i = 0; i < phiSectors; ++i) { // The volume bounds Acts::CylinderVolumeBounds volumeBounds( - 10., 100., 100., phiHalfSector, -M_PI + (2u * i + 1u) * phiHalfSector); - // The surface boudns - Acts::CylinderBounds surfaceBounds(50., 90., 0.99 * phiHalfSector, - -M_PI + (2u * i + 1u) * phiHalfSector); + 10., 100., 100., phiHalfSector, + -std::numbers::pi + (2u * i + 1u) * phiHalfSector); + // The surface bounds + Acts::CylinderBounds surfaceBounds( + 50., 90., 0.99 * phiHalfSector, + -std::numbers::pi + (2u * i + 1u) * phiHalfSector); auto builder = std::make_shared< CylindricalVolumeBuilder>( diff --git a/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp b/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp index 44ffc1630b9..4c9bfee3fbe 100644 --- a/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp +++ b/Tests/UnitTests/Core/Detector/CylindricalDetectorHelperTests.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -110,7 +111,8 @@ BOOST_AUTO_TEST_CASE(ConnectInR) { ACTS_LOCAL_LOGGER(getDefaultLogger("Connect: R", logLevel)); ACTS_INFO("*** Test: connect DetectorVolumes in R, create proto container"); // Test with different opening angles - std::vector testOpenings = {M_PI, 0.5 * M_PI}; + std::vector testOpenings = {std::numbers::pi, + std::numbers::pi / 2.}; std::vector radii = {0., 10., 100., 200.}; ActsScalar halfZ = 100.; @@ -345,7 +347,7 @@ BOOST_AUTO_TEST_CASE(ConnectInPhi) { std::vector transforms = {Transform3::Identity()}; unsigned int phiSectors = 5; - ActsScalar phiHalfSector = M_PI / phiSectors; + ActsScalar phiHalfSector = std::numbers::pi / phiSectors; for (auto [it, t] : enumerate(transforms)) { ACTS_INFO(" -> test series with transform id " << it); @@ -354,7 +356,7 @@ BOOST_AUTO_TEST_CASE(ConnectInPhi) { for (unsigned int i = 0; i < phiSectors; ++i) { auto cBounds = std::make_unique( 10., 100., 100., phiHalfSector, - -M_PI + (2u * i + 1u) * phiHalfSector); + -std::numbers::pi + (2u * i + 1u) * phiHalfSector); // create the volume phiVolumes.push_back(DetectorVolumeFactory::construct( diff --git a/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp b/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp index e0b5d2bfbb2..7b0a551f36e 100644 --- a/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp @@ -27,6 +27,7 @@ #include "Acts/Utilities/Logger.hpp" #include +#include #include #include #include @@ -161,8 +162,8 @@ BOOST_AUTO_TEST_CASE(DetectorVolumeBuilder_EmptyVolume) { // Assign proto material to dvCfg.portalMaterialBinning[2u] = BinningDescription{ {ProtoBinning(BinningValue::binZ, Acts::AxisBoundaryType::Bound, 50), - ProtoBinning(BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, - M_PI, 12)}}; + ProtoBinning(BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 12)}}; auto dvBuilder = std::make_shared( dvCfg, getDefaultLogger("DetectorVolumeBuilder", Logging::VERBOSE)); diff --git a/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp b/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp index 198016678b8..ffe66a708c6 100644 --- a/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -267,7 +268,7 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfacePolyhedronBinExpansion) { // z-phi Axes & Grid Axis axisZ(AxisBound, -9., 9., 9); - Axis axisPhi(AxisClosed, -M_PI, M_PI, 36); + Axis axisPhi(AxisClosed, -std::numbers::pi, std::numbers::pi, 36); Grid gridZPhi(Type>, std::move(axisZ), std::move(axisPhi)); @@ -275,7 +276,8 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfacePolyhedronBinExpansion) { IndexedSurfacesNavigation indexedGridZPhi( std::move(gridZPhi), {BinningValue::binZ, BinningValue::binPhi}); - auto cBounds = std::make_shared(10, 2., M_PI / 30, 0.); + auto cBounds = + std::make_shared(10, 2., std::numbers::pi / 30, 0.); auto cSurface = Surface::makeShared(Transform3::Identity(), std::move(cBounds)); @@ -298,11 +300,13 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfacePolyhedronBinExpansion) { BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfaceMPIPolyhedronBinExpansion) { ACTS_LOCAL_LOGGER(getDefaultLogger("*** Test 4", logLevel)); ACTS_INFO("Testing Phi-Z grid."); - ACTS_INFO("Testing one surface at M_PI jump, with polyhedron generator"); + ACTS_INFO( + "Testing one surface at std::numbers::pi jump, with polyhedron " + "generator"); // z-phi Axes & Grid Axis axisZ(AxisBound, -9., 9., 9); - Axis axisPhi(AxisClosed, -M_PI, M_PI, 36); + Axis axisPhi(AxisClosed, -std::numbers::pi, std::numbers::pi, 36); Grid gridZPhi(Type>, std::move(axisZ), std::move(axisPhi)); @@ -310,8 +314,10 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfaceMPIPolyhedronBinExpansion) { IndexedSurfacesNavigation indexedGridZPhi( std::move(gridZPhi), {BinningValue::binZ, BinningValue::binPhi}); - auto cBounds = std::make_shared(10, 2., M_PI / 10, 0.); - auto tf = AngleAxis3(M_PI, Vector3::UnitZ()) * Transform3::Identity(); + auto cBounds = + std::make_shared(10, 2., std::numbers::pi / 10, 0.); + auto tf = + AngleAxis3(std::numbers::pi, Vector3::UnitZ()) * Transform3::Identity(); auto cSurface = Surface::makeShared(tf, std::move(cBounds)); // The Filler instance and a center based generator diff --git a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp index 4f88dee007e..f95adbdcb3b 100644 --- a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -55,7 +56,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { IndexedSurfacesGenerator irSurfaces{rSurfaces, {}, {BinningValue::binPhi}}; - GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; + GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi}, + 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -80,9 +82,9 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { BOOST_CHECK(grid.atPosition(p) == reference); - // Check that surfaces 0, 1, 21 build the bins at phi == -M_PI + epsilon + // Check that surfaces 0, 1, 21 build the bins at phi == -pi + epsilon reference = {0, 1, 21}; - p = {-M_PI + 0.05}; + p = {-std::numbers::pi + 0.05}; BOOST_CHECK(grid.atPosition(p) == reference); } @@ -100,7 +102,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { IndexedSurfacesGenerator irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {BinningValue::binPhi}}; - GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; + GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi}, + 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -126,9 +129,9 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { GridType::point_t p = {0.05}; BOOST_CHECK(grid.atPosition(p) == reference); - // Check that surfaces 0, 1, 21 build the bins at phi == -M_PI + epsilon + // Check that surfaces 0, 1, 21 build the bins at phi == -pi + epsilon reference = {0, 1, 21, 22}; - p = {-M_PI + 0.05}; + p = {-std::numbers::pi + 0.05}; BOOST_CHECK(grid.atPosition(p) == reference); } @@ -148,7 +151,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::VarBoundEqClosed aGenerator{ - {24., 74., 110.}, {-M_PI, M_PI}, 44u}; + {24., 74., 110.}, {-std::numbers::pi, std::numbers::pi}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -170,7 +173,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { // Check that now two rows of surfaces are given std::vector reference = {16, 17, 38, 39}; - GridType::point_t p = {65., M_PI * 0.49}; + GridType::point_t p = {65., std::numbers::pi * 0.49}; BOOST_CHECK(grid.atPosition(p) == reference); } @@ -194,7 +197,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ - {24., 152}, 8u, {-M_PI, M_PI}, 88u}; + {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -217,7 +220,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { // Fine binning created fewer candidates std::vector reference = {38, 39}; - GridType::point_t p = {80., M_PI * 0.49}; + GridType::point_t p = {80., std::numbers::pi * 0.49}; BOOST_CHECK(grid.atPosition(p) == reference); } @@ -242,7 +245,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}, {2u, 4u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ - {24., 152}, 8u, {-M_PI, M_PI}, 88u}; + {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -263,7 +266,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { // Bin expansion created again more elements std::vector reference = {38, 39}; - GridType::point_t p = {80., M_PI * 0.49}; + GridType::point_t p = {80., std::numbers::pi * 0.49}; BOOST_CHECK_GT(grid.atPosition(p).size(), 2u); } @@ -277,7 +280,7 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { surfaces, {}, {BinningValue::binZ, BinningValue::binPhi}, {1u, 1u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ - {-500., 500}, 28, {-M_PI, M_PI}, 52u}; + {-500., 500}, 28, {-std::numbers::pi, std::numbers::pi}, 52u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedCylinder = icSurfaces(tContext, aGenerator, rGenerator); @@ -298,7 +301,7 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { // Bin expansion created again more elements std::vector reference = {676, 677, 725, 726, 727}; - GridType::point_t p = {490., M_PI * 0.99}; + GridType::point_t p = {490., std::numbers::pi * 0.99}; BOOST_CHECK(grid.atPosition(p) == reference); } diff --git a/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp b/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp index a109a61931a..bf4009335c6 100644 --- a/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -66,9 +67,9 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationRing) { Acts::Experimental::LayerStructureBuilder::Config lsConfig; lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; - lsConfig.binnings = {ProtoBinning(Acts::BinningValue::binPhi, - Acts::AxisBoundaryType::Closed, -M_PI, M_PI, - 22u, 1u)}; + lsConfig.binnings = { + ProtoBinning(Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 22u, 1u)}; auto endcapBuilder = Acts::Experimental::LayerStructureBuilder( lsConfig, Acts::getDefaultLogger("EndcapBuilder", Logging::VERBOSE)); @@ -189,9 +190,9 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationCylinder) { Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, - Acts::AxisBoundaryType::Closed, -M_PI, - M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning( + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 32u, 1u)}; auto barrelBuilder = Acts::Experimental::LayerStructureBuilder( lsConfig, Acts::getDefaultLogger("BarrelBuilder", Logging::VERBOSE)); diff --git a/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp b/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp index 99839806aae..471594170df 100644 --- a/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ BOOST_AUTO_TEST_CASE(Multi_Wire_Structure_Builder_StrawSurfacesCreation) { // The transform of the 1st surface Vector3 ipos = {-0.5 * nSurfacesX * 2 * radius + radius, -0.5 * nSurfacesY * 2 * radius + radius, 0.}; - AngleAxis3 rotation(M_PI / 2, Acts::Vector3(0., 1., 0.)); + AngleAxis3 rotation(std::numbers::pi / 2., Acts::Vector3(0., 1., 0.)); Vector3 pos = ipos; diff --git a/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp b/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp index 79a402137ea..ba9b2bb7e6e 100644 --- a/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp +++ b/Tests/UnitTests/Core/Detector/PortalGeneratorsTests.cpp @@ -20,6 +20,7 @@ #include #include +#include #include using namespace Acts::Experimental; @@ -103,7 +104,7 @@ BOOST_AUTO_TEST_CASE(CylindricalPortalGenerator) { testDetectorVolumeUpdate(*cTubePortals[3], innerPos, -innerDir, nullptr); // Sectoral tube cylinder - Acts::ActsScalar alpha = 0.25 * M_PI; + Acts::ActsScalar alpha = std::numbers::pi / 4.; Acts::ActsScalar r = 50; Acts::Vector3 negPhiSecPos(r * std::cos(-alpha), r * std::sin(-alpha), 0.); diff --git a/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp b/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp index 725331ae8b7..e2de5cc1369 100644 --- a/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp +++ b/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp @@ -12,6 +12,8 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/BinUtility.hpp" +#include + using namespace Acts::Experimental; BOOST_AUTO_TEST_SUITE(Detector) @@ -70,7 +72,7 @@ BOOST_AUTO_TEST_CASE(ProtoBinningVariable) { BOOST_AUTO_TEST_CASE(BinningDescriptionFromAndToBinUtility) { // A valid binning Acts::BinUtility bUtility(5u, 0., 10., Acts::open, Acts::BinningValue::binR); - std::vector edges = {-M_PI, 0.1, M_PI}; + std::vector edges = {-std::numbers::pi, 0.1, std::numbers::pi}; bUtility += Acts::BinUtility(edges, Acts::closed, Acts::BinningValue::binPhi); auto bDescription = BinningDescription::fromBinUtility(bUtility); @@ -100,7 +102,8 @@ BOOST_AUTO_TEST_CASE(BinningDescriptionFromAndToBinUtility) { BOOST_CHECK_EQUAL(binUtility.binningData()[0].bins(), 5u); BOOST_CHECK_EQUAL(binUtility.binningData()[1].bins(), 2u); BOOST_CHECK_EQUAL(binUtility.binningData()[1].boundaries().size(), 3u); - CHECK_CLOSE_ABS(binUtility.binningData()[1].boundaries()[0], -M_PI, 1e-5); + CHECK_CLOSE_ABS(binUtility.binningData()[1].boundaries()[0], + -std::numbers::pi, 1e-5); CHECK_CLOSE_ABS(binUtility.binningData()[1].boundaries()[1], 0.1, 1e-4); } diff --git a/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp b/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp index d8289efdc72..cfd6bb11dcc 100644 --- a/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp +++ b/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -97,7 +98,7 @@ BOOST_AUTO_TEST_CASE(DiscSupportCase) { // As a single disc // rmin = 100 // rmax = 400 - /// phi min = 0 + // phi min = 0 // phi max = 2pi Acts::Extent lExtent; lExtent.set(Acts::BinningValue::binR, 100., 400.); @@ -147,7 +148,7 @@ BOOST_AUTO_TEST_CASE(DiscSupportCase) { dsValues = {120., 399.}; BOOST_CHECK_THROW(cylindricalSupport(dsComponents), std::invalid_argument); - dsValues = {120., 399., M_PI, 0.}; + dsValues = {120., 399., std::numbers::pi, 0.}; dsType = Acts::Surface::SurfaceType::Cylinder; BOOST_CHECK_THROW(cylindricalSupport(dsComponents), std::invalid_argument); } diff --git a/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp b/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp index 9daf24c8a79..eaf97f24a43 100644 --- a/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp +++ b/Tests/UnitTests/Core/EventData/BoundTrackParametersTests.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -89,7 +90,7 @@ void checkParameters(const BoundTrackParameters& params, double l0, double l1, void runTest(const std::shared_ptr& surface, double l0, double l1, double time, double phi, double theta, double p) { // phi is ill-defined in forward/backward tracks - phi = ((0 < theta) && (theta < M_PI)) ? phi : 0.0; + phi = ((0 < theta) && (theta < std::numbers::pi)) ? phi : 0.; // global direction for reference const Vector3 dir = makeDirectionFromPhiTheta(phi, theta); diff --git a/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp b/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp index a8bfcbb6637..ab1d1c1473a 100644 --- a/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp +++ b/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,7 @@ BOOST_AUTO_TEST_CASE(CorrectedFreeToBoundTrackParameters) { const auto loc0 = 0.0; const auto loc1 = 0.0; const auto phi = 0.0; - const auto theta = M_PI / 4; + const auto theta = std::numbers::pi / 4.; const auto qOverP = 1 / 1_GeV; const auto t = 1_ns; @@ -81,7 +82,7 @@ BOOST_AUTO_TEST_CASE(CorrectedFreeToBoundTrackParameters) { Vector3 tpos = intersection.position(); auto s = intersection.pathLength(); - BOOST_CHECK_EQUAL(s, distance * std::sqrt(2)); + BOOST_CHECK_EQUAL(s, distance * std::numbers::sqrt2); // construct the free parameters vector FreeVector eFreeParams = FreeVector::Zero(); diff --git a/Tests/UnitTests/Core/EventData/CurvilinearTrackParametersTests.cpp b/Tests/UnitTests/Core/EventData/CurvilinearTrackParametersTests.cpp index 143515148d4..444bf398f66 100644 --- a/Tests/UnitTests/Core/EventData/CurvilinearTrackParametersTests.cpp +++ b/Tests/UnitTests/Core/EventData/CurvilinearTrackParametersTests.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -59,7 +60,7 @@ void checkParameters(const CurvilinearTrackParameters& params, double phi, detail::radian_sym(phi), eps, eps); CHECK_CLOSE_OR_SMALL(params.template get(), theta, eps, eps); CHECK_CLOSE_OR_SMALL(params.template get(), qOverP, eps, eps); - // convenience accessorss + // convenience accessors CHECK_CLOSE_OR_SMALL(params.fourPosition(geoCtx), pos4, eps, eps); CHECK_CLOSE_OR_SMALL(params.position(geoCtx), pos, eps, eps); CHECK_CLOSE_OR_SMALL(params.time(), pos4[eTime], eps, eps); @@ -93,7 +94,7 @@ BOOST_DATA_TEST_CASE( posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps, x, y, z, time, phiInput, theta, p) { // phi is ill-defined in forward/backward tracks - const auto phi = ((0 < theta) && (theta < M_PI)) ? phiInput : 0.0; + const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.; const Vector4 pos4(x, y, z, time); const Vector3 dir = makeDirectionFromPhiTheta(phi, theta); @@ -114,7 +115,7 @@ BOOST_DATA_TEST_CASE( posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero, x, y, z, time, phiInput, theta, p, q) { // phi is ill-defined in forward/backward tracks - const auto phi = ((0 < theta) && (theta < M_PI)) ? phiInput : 0.0; + const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.; const Vector4 pos4(x, y, z, time); const Vector3 dir = makeDirectionFromPhiTheta(phi, theta); @@ -135,7 +136,7 @@ BOOST_DATA_TEST_CASE( posSymmetric* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsAny, x, y, z, time, phiInput, theta, p, q) { // phi is ill-defined in forward/backward tracks - const auto phi = ((0 < theta) && (theta < M_PI)) ? phiInput : 0.0; + const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.; const Vector4 pos4(x, y, z, time); const Vector3 dir = makeDirectionFromPhiTheta(phi, theta); diff --git a/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp b/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp index 3174658a578..668047c6ed2 100644 --- a/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp +++ b/Tests/UnitTests/Core/EventData/TrackParametersDatasets.hpp @@ -19,6 +19,7 @@ #include "Acts/Surfaces/RegularSurface.hpp" #include +#include #include namespace { @@ -40,16 +41,19 @@ const auto surfaces = CurvilinearSurface(Vector3::Zero(), Vector3::UnitZ()).planeSurface(), }); // positions -const auto posAngle = bdata::xrange(-M_PI, M_PI, 0.50); +const auto posAngle = bdata::xrange(-std::numbers::pi, std::numbers::pi, 0.5); const auto posPositiveNonzero = bdata::xrange(0.25, 1.0, 0.25); const auto posPositive = bdata::make(0.0) + posPositiveNonzero; const auto posSymmetric = bdata::xrange(-1.0, 1.0, 0.50); // time const auto ts = bdata::make(1.0); // direction angles -const auto phis = bdata::make({0.0, M_PI, -M_PI, M_PI_2, -M_PI_2}); -const auto thetasNoForwardBackward = bdata::xrange(M_PI_4, M_PI, M_PI_4); -const auto thetas = bdata::make({0.0, M_PI}) + thetasNoForwardBackward; +const auto phis = bdata::make({0., std::numbers::pi, -std::numbers::pi, + std::numbers::pi / 2., -std::numbers::pi / 2.}); +const auto thetasNoForwardBackward = bdata::xrange( + std::numbers::pi / 4., std::numbers::pi, std::numbers::pi / 4.); +const auto thetas = + bdata::make({0., std::numbers::pi}) + thetasNoForwardBackward; // absolute momenta const auto ps = bdata::make({1.0, 10.0}); // charges diff --git a/Tests/UnitTests/Core/EventData/TransformHelpersTests.cpp b/Tests/UnitTests/Core/EventData/TransformHelpersTests.cpp index 2ae0daee9dc..2d3bcb3ce70 100644 --- a/Tests/UnitTests/Core/EventData/TransformHelpersTests.cpp +++ b/Tests/UnitTests/Core/EventData/TransformHelpersTests.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -74,7 +75,7 @@ BOOST_DATA_TEST_CASE( surfaces* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero, surface, l0, l1, time, phiInput, theta, p, q) { // phi is ill-defined in forward/backward tracks - const auto phi = ((0 < theta) && (theta < M_PI)) ? phiInput : 0.0; + const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.; const auto qOverP = q / p; GeometryContext geoCtx; @@ -158,7 +159,7 @@ BOOST_DATA_TEST_CASE(GlobalToCurvilinearParameters, ts* phis* thetas* ps* qsNonZero, time, phiInput, theta, p, q) { // phi is ill-defined in forward/backward tracks - const auto phi = ((0 < theta) && (theta < M_PI)) ? phiInput : 0.0; + const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.; const auto qOverP = q / p; GeometryContext geoCtx; diff --git a/Tests/UnitTests/Core/Geometry/ConeLayerTests.cpp b/Tests/UnitTests/Core/Geometry/ConeLayerTests.cpp index 95054224201..e10cac3073d 100644 --- a/Tests/UnitTests/Core/Geometry/ConeLayerTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ConeLayerTests.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -35,8 +36,8 @@ BOOST_AUTO_TEST_CASE(ConeLayerConstruction) { // ConeBounds) to construct Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); - double alpha(M_PI / 8.0); - const bool symmetric(false); + const double alpha = std::numbers::pi / 8.; + const bool symmetric = false; auto pCone = std::make_shared(alpha, symmetric); // for some reason, this one doesn't exist // auto pConeLayer = ConeLayer::create(pTransform, pCone); @@ -48,7 +49,7 @@ BOOST_AUTO_TEST_CASE(ConeLayerConstruction) { const std::vector> aSurfaces{ Surface::makeShared(Transform3::Identity(), rBounds), Surface::makeShared(Transform3::Identity(), rBounds)}; - const double thickness(1.0); + const double thickness = 1.; auto pConeLayerFromSurfaces = ConeLayer::create(pTransform, pCone, nullptr); BOOST_CHECK_EQUAL(pConeLayerFromSurfaces->layerType(), LayerType::active); // construct with thickness: diff --git a/Tests/UnitTests/Core/Geometry/ConeVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/ConeVolumeBoundsTests.cpp index 855fac2ff1b..f65937b386b 100644 --- a/Tests/UnitTests/Core/Geometry/ConeVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ConeVolumeBoundsTests.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -27,7 +28,7 @@ BOOST_AUTO_TEST_SUITE(VolumeBounds) BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) { // Single solid Cone - ConeVolumeBounds solidCone(0., 0., 0.45, 50_mm, 50_mm, 0., M_PI); + ConeVolumeBounds solidCone(0., 0., 0.45, 50_mm, 50_mm, 0., std::numbers::pi); // Test correct parameter return BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerAlpha), 0.); @@ -36,7 +37,8 @@ BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) { BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterOffsetZ), 50.); BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfLengthZ), 50.); BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eAveragePhi), 0.); - BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfPhiSector), M_PI); + BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfPhiSector), + std::numbers::pi); // Derived quantities BOOST_CHECK_EQUAL(solidCone.innerTanAlpha(), 0.); BOOST_CHECK_EQUAL(solidCone.innerRmin(), 0.); @@ -51,12 +53,13 @@ BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) { BOOST_CHECK_EQUAL(solidConeSurfaces.size(), 2); // Single solid Cone - with cut off - ConeVolumeBounds cutOffCone(0., 0., 0.45, 80_mm, 50_mm, 0., M_PI); + ConeVolumeBounds cutOffCone(0., 0., 0.45, 80_mm, 50_mm, 0., std::numbers::pi); auto cutOffConeSurfaces = cutOffCone.orientedSurfaces(); BOOST_CHECK_EQUAL(cutOffConeSurfaces.size(), 3); // Cone - Cone inlay - ConeVolumeBounds cutOffHollowCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0., M_PI); + ConeVolumeBounds cutOffHollowCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0., + std::numbers::pi); auto cutOffHollowConeSurfaces = cutOffHollowCone.orientedSurfaces(); BOOST_CHECK_EQUAL(cutOffHollowConeSurfaces.size(), 4); @@ -68,18 +71,20 @@ BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) { BOOST_CHECK_EQUAL(cutOffHollowSectoralConeSurfaces.size(), 6); // Sectoral Cone - Hollow Cone - ConeVolumeBounds cutOffHollowCylCone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI); + ConeVolumeBounds cutOffHollowCylCone(10_mm, 0.45, 80_mm, 50_mm, 0., + std::numbers::pi); auto cutOffHollowCylConeSurfaces = cutOffHollowCylCone.orientedSurfaces(); BOOST_CHECK_EQUAL(cutOffHollowCylConeSurfaces.size(), 4); // Single Hollow Cylinder - Cone inlay - ConeVolumeBounds cutOffHollowConeCyl(120_mm, 0.35, 70_mm, 50_mm, 0., M_PI); + ConeVolumeBounds cutOffHollowConeCyl(120_mm, 0.35, 70_mm, 50_mm, 0., + std::numbers::pi); auto cutOffHollowConeCylSurfaces = cutOffHollowConeCyl.orientedSurfaces(); BOOST_CHECK_EQUAL(cutOffHollowConeCylSurfaces.size(), 4); } BOOST_AUTO_TEST_CASE(ConeVolumeBoundsSurfaceOrientation) { - ConeVolumeBounds hcone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI); + ConeVolumeBounds hcone(10_mm, 0.45, 80_mm, 50_mm, 0., std::numbers::pi); auto cvbOrientedSurfaces = hcone.orientedSurfaces(Transform3::Identity()); BOOST_CHECK_EQUAL(cvbOrientedSurfaces.size(), 4); diff --git a/Tests/UnitTests/Core/Geometry/CuboidVolumeBuilderTests.cpp b/Tests/UnitTests/Core/Geometry/CuboidVolumeBuilderTests.cpp index ff08e5c9996..f20628b809e 100644 --- a/Tests/UnitTests/Core/Geometry/CuboidVolumeBuilderTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CuboidVolumeBuilderTests.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,7 @@ BOOST_AUTO_TEST_CASE(CuboidVolumeBuilderTest) { cfg.position = {i * UnitConstants::m, 0., 0.}; // Rotation of the surfaces - double rotationAngle = M_PI * 0.5; + double rotationAngle = std::numbers::pi / 2.; Vector3 xPos(cos(rotationAngle), 0., sin(rotationAngle)); Vector3 yPos(0., 1., 0.); Vector3 zPos(-sin(rotationAngle), 0., cos(rotationAngle)); @@ -177,7 +178,7 @@ BOOST_AUTO_TEST_CASE(CuboidVolumeBuilderTest) { cfg.position = {-i * UnitConstants::m, 0., 0.}; // Rotation of the surfaces - double rotationAngle = M_PI * 0.5; + double rotationAngle = std::numbers::pi / 2.; Vector3 xPos(cos(rotationAngle), 0., sin(rotationAngle)); Vector3 yPos(0., 1., 0.); Vector3 zPos(-sin(rotationAngle), 0., cos(rotationAngle)); diff --git a/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp index e0d22344a9a..9de254dfb68 100644 --- a/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -34,7 +35,8 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Geometry) BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsConstruction) { - double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.}; + double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{std::numbers::pi / 4.}, + avgphi{0.}; // Test different construction modes: solid CylinderVolumeBounds solidCylinder(0., rmax, halfz); @@ -76,7 +78,8 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsConstruction) { } BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsRecreation) { - double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.}; + double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{std::numbers::pi / 4.}, + avgphi{0.}; CylinderVolumeBounds original(rmin, rmax, halfz, halfphi, avgphi); std::array values{}; @@ -87,7 +90,8 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsRecreation) { } BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsExceptions) { - double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.}; + double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{std::numbers::pi / 4.}, + avgphi{0.}; // Negative inner radius BOOST_CHECK_THROW(CylinderVolumeBounds(-rmin, rmax, halfz, halfphi, avgphi), @@ -133,7 +137,8 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsExceptions) { } BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsAccess) { - double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{M_PI / 4}, avgphi{0.}; + double rmin{10.}, rmax{20.}, halfz{30.}, halfphi{std::numbers::pi / 4.}, + avgphi{0.}; CylinderVolumeBounds cvBounds(rmin, rmax, halfz, halfphi, avgphi); // Test the accessors @@ -149,16 +154,16 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsAccess) { BOOST_DATA_TEST_CASE( CylinderVolumeBoundsOrientedSurfaces, bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1, - bdata::distribution = - std::uniform_real_distribution(-M_PI, M_PI))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 2, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 3, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 4, bdata::distribution = std::uniform_real_distribution(-10., 10.))) ^ @@ -253,7 +258,7 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsBoundingBox) { auto bb = cvb.boundingBox(); Transform3 rot; - rot = AngleAxis3(M_PI / 2., Vector3::UnitX()); + rot = AngleAxis3(std::numbers::pi / 2., Vector3::UnitX()); BOOST_CHECK_EQUAL(bb.entity(), nullptr); BOOST_CHECK_EQUAL(bb.max(), Vector3(5, 5, 10)); @@ -270,7 +275,7 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsBoundingBox) { BOOST_CHECK_EQUAL(bb.max(), Vector3(8, 8, 12)); BOOST_CHECK_EQUAL(bb.min(), Vector3(-8, -8, -12)); - double angle = M_PI / 8.; + double angle = std::numbers::pi / 8.; cvb = CylinderVolumeBounds(5, 8, 13, angle); bb = cvb.boundingBox(); BOOST_CHECK_EQUAL(bb.entity(), nullptr); @@ -278,14 +283,14 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsBoundingBox) { CHECK_CLOSE_ABS(bb.min(), Vector3(5 * std::cos(angle), -8 * std::sin(angle), -13), tol); - rot = AngleAxis3(M_PI / 2., Vector3::UnitZ()); + rot = AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()); bb = cvb.boundingBox(&rot); BOOST_CHECK_EQUAL(bb.entity(), nullptr); CHECK_CLOSE_ABS(bb.max(), Vector3(8 * std::sin(angle), 8, 13), tol); CHECK_CLOSE_ABS(bb.min(), Vector3(-8 * std::sin(angle), 5 * std::cos(angle), -13), tol); - rot = AngleAxis3(M_PI / 2., Vector3(-2, 4, 5).normalized()); + rot = AngleAxis3(std::numbers::pi / 2., Vector3(-2, 4, 5).normalized()); bb = cvb.boundingBox(&rot); BOOST_CHECK_EQUAL(bb.entity(), nullptr); CHECK_CLOSE_ABS(bb.max(), Vector3(8.40007, 15.2828, 3.88911), tol); @@ -352,30 +357,37 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsSetValues) { cyl.set(CylinderVolumeBounds::eHalfLengthZ, 150); BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfLengthZ), 150); - BOOST_CHECK_THROW(cyl.set(CylinderVolumeBounds::eHalfPhiSector, -M_PI), - std::invalid_argument); - BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI); + BOOST_CHECK_THROW( + cyl.set(CylinderVolumeBounds::eHalfPhiSector, -std::numbers::pi), + std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), + std::numbers::pi); - BOOST_CHECK_THROW(cyl.set(CylinderVolumeBounds::eHalfPhiSector, 1.5 * M_PI), - std::invalid_argument); - BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI); + BOOST_CHECK_THROW( + cyl.set(CylinderVolumeBounds::eHalfPhiSector, 1.5 * std::numbers::pi), + std::invalid_argument); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), + std::numbers::pi); - cyl.set(CylinderVolumeBounds::eHalfPhiSector, M_PI / 2); - BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI / 2); + cyl.set(CylinderVolumeBounds::eHalfPhiSector, std::numbers::pi / 2.); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), + std::numbers::pi / 2.); for (auto bValue : {CylinderVolumeBounds::eAveragePhi, CylinderVolumeBounds::eBevelMaxZ, CylinderVolumeBounds::eBevelMinZ}) { - BOOST_CHECK_THROW(cyl.set(bValue, -1.5 * M_PI), std::invalid_argument); + BOOST_CHECK_THROW(cyl.set(bValue, -1.5 * std::numbers::pi), + std::invalid_argument); BOOST_CHECK_EQUAL(cyl.get(bValue), 0); - BOOST_CHECK_THROW(cyl.set(bValue, 1.5 * M_PI), std::invalid_argument); + BOOST_CHECK_THROW(cyl.set(bValue, 1.5 * std::numbers::pi), + std::invalid_argument); BOOST_CHECK_EQUAL(cyl.get(bValue), 0); - cyl.set(bValue, 0.5 * M_PI); - BOOST_CHECK_EQUAL(cyl.get(bValue), 0.5 * M_PI); - cyl.set(bValue, -0.5 * M_PI); - BOOST_CHECK_EQUAL(cyl.get(bValue), -0.5 * M_PI); + cyl.set(bValue, std::numbers::pi / 2.); + BOOST_CHECK_EQUAL(cyl.get(bValue), std::numbers::pi / 2.); + cyl.set(bValue, -std::numbers::pi / 2.); + BOOST_CHECK_EQUAL(cyl.get(bValue), -std::numbers::pi / 2.); } cyl = CylinderVolumeBounds(100, 300, 200); @@ -400,7 +412,8 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeBoundsSetValues) { BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMinR), 50); BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eMaxR), 200); BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfLengthZ), 150); - BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), M_PI); + BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eHalfPhiSector), + std::numbers::pi); BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eAveragePhi), 0); BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eBevelMinZ), 0); BOOST_CHECK_EQUAL(cyl.get(CylinderVolumeBounds::eBevelMaxZ), 0); diff --git a/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp b/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp index 19850be4bbe..3f9b2649bb7 100644 --- a/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp @@ -24,6 +24,8 @@ #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/Zip.hpp" +#include + using namespace Acts::UnitLiterals; namespace Acts::Test { @@ -1821,15 +1823,17 @@ BOOST_DATA_TEST_CASE(JoinCylinderVolumesInvalidInput, BOOST_TEST_CONTEXT("Volume has phi values or bevel values") { std::vector> invalidVolumeBounds = { std::make_shared(100_mm, 400_mm, 400_mm, - 0.2 * M_PI), + 0.2 * std::numbers::pi), - std::make_shared(100_mm, 400_mm, 400_mm, M_PI, - 0.3 * M_PI), + std::make_shared( + 100_mm, 400_mm, 400_mm, std::numbers::pi, 0.3 * std::numbers::pi), - std::make_shared(100_mm, 400_mm, 400_mm, M_PI, - 0.0, 0.3 * M_PI), - std::make_shared(100_mm, 400_mm, 400_mm, M_PI, - 0.0, 0.0, 0.3 * M_PI), + std::make_shared(100_mm, 400_mm, 400_mm, + std::numbers::pi, 0., + 0.3 * std::numbers::pi), + std::make_shared(100_mm, 400_mm, 400_mm, + std::numbers::pi, 0., 0., + 0.3 * std::numbers::pi), }; for (const auto& invalid : invalidVolumeBounds) { diff --git a/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp index 1a7f5a7d056..62f94975a48 100644 --- a/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/GenericCuboidVolumeBoundsTests.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE(GenericCuboidBoundsOrientedSurfaces) { Transform3 trf; trf = Translation3(Vector3(0, 8, -5)) * - AngleAxis3(M_PI / 3., Vector3(1, -3, 9).normalized()); + AngleAxis3(std::numbers::pi / 3., Vector3(1, -3, 9).normalized()); surfaces = cubo.orientedSurfaces(trf); for (const auto& srf : surfaces) { @@ -160,7 +161,7 @@ BOOST_AUTO_TEST_CASE(bounding_box_creation) { auto bb = gcvb.boundingBox(); Transform3 rot; - rot = AngleAxis3(M_PI / 2., Vector3::UnitX()); + rot = AngleAxis3(std::numbers::pi / 2., Vector3::UnitX()); BOOST_CHECK_EQUAL(bb.entity(), nullptr); BOOST_CHECK_EQUAL(bb.max(), Vector3(2, 1, 1)); @@ -172,14 +173,14 @@ BOOST_AUTO_TEST_CASE(bounding_box_creation) { CHECK_CLOSE_ABS(bb.max(), Vector3(2, 0, 1), tol); BOOST_CHECK_EQUAL(bb.min(), Vector3(0, -1, 0)); - rot = AngleAxis3(M_PI / 2., Vector3::UnitZ()); + rot = AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()); bb = gcvb.boundingBox(&rot); BOOST_CHECK_EQUAL(bb.entity(), nullptr); CHECK_CLOSE_ABS(bb.max(), Vector3(0, 2, 1), tol); CHECK_CLOSE_ABS(bb.min(), Vector3(-1, 0., 0.), tol); rot = AngleAxis3(0.542, Vector3::UnitZ()) * - AngleAxis3(M_PI / 5., Vector3(1, 3, 6).normalized()); + AngleAxis3(std::numbers::pi / 5., Vector3(1, 3, 6).normalized()); bb = gcvb.boundingBox(&rot); BOOST_CHECK_EQUAL(bb.entity(), nullptr); @@ -198,7 +199,7 @@ BOOST_AUTO_TEST_CASE(bounding_box_creation) { // Redo the check from above rot = AngleAxis3(0.542, Vector3::UnitZ()) * - AngleAxis3(M_PI / 5., Vector3(1, 3, 6).normalized()); + AngleAxis3(std::numbers::pi / 5., Vector3(1, 3, 6).normalized()); bb = gcvbCopy.boundingBox(&rot); BOOST_CHECK_EQUAL(bb.entity(), nullptr); diff --git a/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp b/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp index 866a714a7ff..13aec3ff545 100644 --- a/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp +++ b/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -124,7 +125,7 @@ struct LayerCreatorFixture { double zbase = 0, double r = 10) { SrfVec res; - double phiStep = 2 * M_PI / n; + double phiStep = 2 * std::numbers::pi / n; for (std::size_t i = 0; i < n; ++i) { double z = zbase + ((i % 2 == 0) ? 1 : -1) * 0.2; @@ -146,11 +147,11 @@ struct LayerCreatorFixture { } SrfVec fullPhiTestSurfacesBRL(int n = 10, double shift = 0, double zbase = 0, - double incl = M_PI / 9., double w = 2, - double h = 1.5) { + double incl = std::numbers::pi / 9., + double w = 2, double h = 1.5) { SrfVec res; - double phiStep = 2 * M_PI / n; + double phiStep = 2 * std::numbers::pi / n; for (int i = 0; i < n; ++i) { double z = zbase; @@ -159,7 +160,7 @@ struct LayerCreatorFixture { trans.rotate(Eigen::AngleAxisd(i * phiStep + shift, Vector3(0, 0, 1))); trans.translate(Vector3(10, 0, z)); trans.rotate(Eigen::AngleAxisd(incl, Vector3(0, 0, 1))); - trans.rotate(Eigen::AngleAxisd(M_PI / 2., Vector3(0, 1, 0))); + trans.rotate(Eigen::AngleAxisd(std::numbers::pi / 2., Vector3(0, 1, 0))); auto bounds = std::make_shared(w, h); std::shared_ptr srf = @@ -180,7 +181,8 @@ struct LayerCreatorFixture { for (int i = 0; i < nZ; i++) { double z = i * w * 2 + z0; std::cout << "z=" << z << std::endl; - SrfVec ring = fullPhiTestSurfacesBRL(nPhi, 0, z, M_PI / 9., w, h); + SrfVec ring = + fullPhiTestSurfacesBRL(nPhi, 0, z, std::numbers::pi / 9., w, h); res.insert(res.end(), ring.begin(), ring.end()); } @@ -188,8 +190,9 @@ struct LayerCreatorFixture { } std::pair>> - makeBarrelStagger(int nPhi, int nZ, double shift = 0, double incl = M_PI / 9., - double w = 2, double h = 1.5) { + makeBarrelStagger(int nPhi, int nZ, double shift = 0, + double incl = std::numbers::pi / 9., double w = 2, + double h = 1.5) { double z0 = -(nZ - 1) * w; SrfVec res; @@ -198,14 +201,15 @@ struct LayerCreatorFixture { for (int i = 0; i < nZ; i++) { double z = i * w * 2 + z0; - double phiStep = 2 * M_PI / nPhi; + double phiStep = 2 * std::numbers::pi / nPhi; for (int j = 0; j < nPhi; ++j) { Transform3 trans; trans.setIdentity(); trans.rotate(Eigen::AngleAxisd(j * phiStep + shift, Vector3(0, 0, 1))); trans.translate(Vector3(10, 0, z)); trans.rotate(Eigen::AngleAxisd(incl, Vector3(0, 0, 1))); - trans.rotate(Eigen::AngleAxisd(M_PI / 2., Vector3(0, 1, 0))); + trans.rotate( + Eigen::AngleAxisd(std::numbers::pi / 2., Vector3(0, 1, 0))); auto bounds = std::make_shared(w, h); std::shared_ptr srfA = @@ -258,8 +262,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createCylinderLayer, LayerCreatorFixture) { auto axes = layer->surfaceArray()->getAxes(); BOOST_CHECK_EQUAL(axes.at(0)->getNBins(), 30u); BOOST_CHECK_EQUAL(axes.at(1)->getNBins(), 7u); - CHECK_CLOSE_REL(axes.at(0)->getMin(), -M_PI, 1e-3); - CHECK_CLOSE_REL(axes.at(0)->getMax(), M_PI, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMin(), -std::numbers::pi, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMax(), std::numbers::pi, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMin(), -14, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMax(), 14, 1e-3); @@ -278,8 +282,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createCylinderLayer, LayerCreatorFixture) { axes = layer->surfaceArray()->getAxes(); BOOST_CHECK_EQUAL(axes.at(0)->getNBins(), 30u); BOOST_CHECK_EQUAL(axes.at(1)->getNBins(), 7u); - CHECK_CLOSE_REL(axes.at(0)->getMin(), -M_PI, 1e-3); - CHECK_CLOSE_REL(axes.at(0)->getMax(), M_PI, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMin(), -std::numbers::pi, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMax(), std::numbers::pi, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMin(), -14, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMax(), 14, 1e-3); @@ -295,8 +299,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createCylinderLayer, LayerCreatorFixture) { axes = layer->surfaceArray()->getAxes(); BOOST_CHECK_EQUAL(axes.at(0)->getNBins(), 13u); BOOST_CHECK_EQUAL(axes.at(1)->getNBins(), 3u); - CHECK_CLOSE_REL(axes.at(0)->getMin(), -M_PI, 1e-3); - CHECK_CLOSE_REL(axes.at(0)->getMax(), M_PI, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMin(), -std::numbers::pi, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMax(), std::numbers::pi, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMin(), -14, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMax(), 14, 1e-3); @@ -319,8 +323,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createCylinderLayer, LayerCreatorFixture) { axes = layer->surfaceArray()->getAxes(); BOOST_CHECK_EQUAL(axes.at(0)->getNBins(), 30u); BOOST_CHECK_EQUAL(axes.at(1)->getNBins(), 7u); - CHECK_CLOSE_REL(axes.at(0)->getMin(), -M_PI, 1e-3); - CHECK_CLOSE_REL(axes.at(0)->getMax(), M_PI, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMin(), -std::numbers::pi, 1e-3); + CHECK_CLOSE_REL(axes.at(0)->getMax(), std::numbers::pi, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMin(), -25, 1e-3); CHECK_CLOSE_REL(axes.at(1)->getMax(), 25, 1e-3); } @@ -351,14 +355,14 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createDiscLayer, LayerCreatorFixture) { BOOST_CHECK_EQUAL(axes.at(1)->getNBins(), 30u); CHECK_CLOSE_REL(axes.at(0)->getMin(), 5, 1e-3); CHECK_CLOSE_REL(axes.at(0)->getMax(), 25, 1e-3); - CHECK_CLOSE_REL(axes.at(1)->getMin(), -M_PI, 1e-3); - CHECK_CLOSE_REL(axes.at(1)->getMax(), M_PI, 1e-3); + CHECK_CLOSE_REL(axes.at(1)->getMin(), -std::numbers::pi, 1e-3); + CHECK_CLOSE_REL(axes.at(1)->getMax(), std::numbers::pi, 1e-3); checkBinContentSize(layer->surfaceArray(), 1); // check that it's applying a rotation transform to improve phi binning // BOOST_CHECK_NE(bu->transform(), nullptr); // double actAngle = ((*bu->transform()) * Vector3(1, 0, 0)).phi(); - // double expAngle = -2 * M_PI / 30 / 2.; + // double expAngle = -2 * std::numbers::pi / 30 / 2.; // CHECK_CLOSE_REL(actAngle, expAngle, 1e-3); double envMinR = 1, envMaxR = 1, envZ = 5; @@ -380,14 +384,14 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createDiscLayer, LayerCreatorFixture) { BOOST_CHECK_EQUAL(axes.at(1)->getNBins(), nBinsPhi); CHECK_CLOSE_REL(axes.at(0)->getMin(), rMin, 1e-3); CHECK_CLOSE_REL(axes.at(0)->getMax(), rMax, 1e-3); - CHECK_CLOSE_REL(axes.at(1)->getMin(), -M_PI, 1e-3); - CHECK_CLOSE_REL(axes.at(1)->getMax(), M_PI, 1e-3); + CHECK_CLOSE_REL(axes.at(1)->getMin(), -std::numbers::pi, 1e-3); + CHECK_CLOSE_REL(axes.at(1)->getMax(), std::numbers::pi, 1e-3); checkBinContentSize(layer->surfaceArray(), 1); // check that it's applying a rotation transform to improve phi binning // BOOST_CHECK_NE(bu->transform(), nullptr); // actAngle = ((*bu->transform()) * Vector3(1, 0, 0)).phi(); - // expAngle = -2 * M_PI / 30 / 2.; + // expAngle = -2 * std::numbers::pi / 30 / 2.; // CHECK_CLOSE_REL(actAngle, expAngle, 1e-3); layer = std::dynamic_pointer_cast( @@ -402,19 +406,19 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createDiscLayer, LayerCreatorFixture) { BOOST_CHECK_EQUAL(axes.at(1)->getNBins(), nBinsPhi); CHECK_CLOSE_REL(axes.at(0)->getMin(), rMin, 1e-3); CHECK_CLOSE_REL(axes.at(0)->getMax(), rMax, 1e-3); - CHECK_CLOSE_REL(axes.at(1)->getMin(), -M_PI, 1e-3); - CHECK_CLOSE_REL(axes.at(1)->getMax(), M_PI, 1e-3); + CHECK_CLOSE_REL(axes.at(1)->getMin(), -std::numbers::pi, 1e-3); + CHECK_CLOSE_REL(axes.at(1)->getMax(), std::numbers::pi, 1e-3); checkBinContentSize(layer->surfaceArray(), 1); // check that it's applying a rotation transform to improve phi binning // BOOST_CHECK_NE(bu->transform(), nullptr); // actAngle = ((*bu->transform()) * Vector3(1, 0, 0)).phi(); - // expAngle = -2 * M_PI / 30 / 2.; + // expAngle = -2 * std::numbers::pi / 30 / 2.; // CHECK_CLOSE_REL(actAngle, expAngle, 1e-3); } BOOST_FIXTURE_TEST_CASE(LayerCreator_barrelStagger, LayerCreatorFixture) { - auto barrel = makeBarrelStagger(30, 7, 0, M_PI / 9.); + auto barrel = makeBarrelStagger(30, 7, 0, std::numbers::pi / 9.); auto brl = barrel.first; draw_surfaces(brl, "LayerCreator_barrelStagger.obj"); diff --git a/Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp b/Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp index e5345268e84..d44df588af5 100644 --- a/Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp +++ b/Tests/UnitTests/Core/Geometry/PortalLinkTests.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include using namespace Acts::UnitLiterals; @@ -152,7 +153,8 @@ BOOST_AUTO_TEST_CASE(Cylinder) { const auto* axis1 = grid2dCyl1->grid().axes().front(); const auto* axis2 = grid2dCyl1->grid().axes().back(); - Axis axis1Expected{AxisClosed, -M_PI * 30_mm, M_PI * 30_mm, 1}; + Axis axis1Expected{AxisClosed, -std::numbers::pi * 30_mm, + std::numbers::pi * 30_mm, 1}; BOOST_CHECK_EQUAL(*axis1, axis1Expected); Axis axis2Expected{AxisBound, -100_mm, 100_mm, 10}; BOOST_CHECK_EQUAL(*axis2, axis2Expected); @@ -163,7 +165,8 @@ BOOST_AUTO_TEST_CASE(Cylinder) { checkAllBins(concrete); - Axis axis1Explicit{AxisClosed, -M_PI * 30_mm, M_PI * 30_mm, 13}; + Axis axis1Explicit{AxisClosed, -std::numbers::pi * 30_mm, + std::numbers::pi * 30_mm, 13}; auto grid2dCyl1Explicit = grid1dCyl->extendTo2d(&axis1Explicit); BOOST_REQUIRE(grid2dCyl1Explicit); BOOST_CHECK_EQUAL(grid2dCyl1Explicit->grid().axes().size(), 2); @@ -497,7 +500,8 @@ BOOST_AUTO_TEST_CASE(FromTrivial) { BOOST_CHECK_EQUAL(gridRPhi->grid().axes().size(), 1); BOOST_CHECK_EQUAL(gridRPhi->surface().bounds(), cyl->bounds()); - Axis axisRPhiExpected{AxisClosed, -M_PI * 30_mm, M_PI * 30_mm, 1}; + Axis axisRPhiExpected{AxisClosed, -std::numbers::pi * 30_mm, + std::numbers::pi * 30_mm, 1}; BOOST_CHECK_EQUAL(*gridRPhi->grid().axes().front(), axisRPhiExpected); auto cylPhi = Surface::makeShared( @@ -556,7 +560,7 @@ BOOST_AUTO_TEST_CASE(FromTrivial) { BOOST_CHECK_EQUAL(gridPhi->grid().axes().size(), 1); BOOST_CHECK_EQUAL(gridPhi->surface().bounds(), disc->bounds()); - Axis axisPhiExpected{AxisClosed, -M_PI, M_PI, 1}; + Axis axisPhiExpected{AxisClosed, -std::numbers::pi, std::numbers::pi, 1}; BOOST_CHECK_EQUAL(*gridPhi->grid().axes().front(), axisPhiExpected); BOOST_CHECK_EQUAL( @@ -2310,8 +2314,9 @@ BOOST_AUTO_TEST_CASE(TrivialGridR) { auto trivial = std::make_unique(disc2, *vol2); BOOST_REQUIRE(trivial); - auto gridPhi = GridPortalLink::make(disc1, BinningValue::binPhi, - Axis{AxisClosed, -M_PI, M_PI, 2}); + auto gridPhi = GridPortalLink::make( + disc1, BinningValue::binPhi, + Axis{AxisClosed, -std::numbers::pi, std::numbers::pi, 2}); gridPhi->setVolume(vol1.get()); auto gridR = GridPortalLink::make(disc1, BinningValue::binR, diff --git a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp index efde97d9b41..3fdf8ec1c16 100644 --- a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -41,12 +42,14 @@ BOOST_AUTO_TEST_CASE(ProtoLayerTests) { auto recBounds = std::make_shared(3., 6.); // Planar definitions to help construct the boundary surfaces - static const Transform3 planeYZ = AngleAxis3(0.5 * M_PI, Vector3::UnitY()) * - AngleAxis3(0.5 * M_PI, Vector3::UnitZ()) * - Transform3::Identity(); - static const Transform3 planeZX = AngleAxis3(-0.5 * M_PI, Vector3::UnitX()) * - AngleAxis3(-0.5 * M_PI, Vector3::UnitZ()) * - Transform3::Identity(); + static const Transform3 planeYZ = + AngleAxis3(std::numbers::pi / 2., Vector3::UnitY()) * + AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()) * + Transform3::Identity(); + static const Transform3 planeZX = + AngleAxis3(-std::numbers::pi / 2., Vector3::UnitX()) * + AngleAxis3(-std::numbers::pi / 2., Vector3::UnitZ()) * + Transform3::Identity(); std::vector> surfaceStore; surfaceStore.reserve(100); @@ -171,7 +174,7 @@ BOOST_AUTO_TEST_CASE(OrientedLayer) { detectorElements.clear(); std::size_t nSensors = 8; - double deltaPhi = 2 * M_PI / nSensors; + double deltaPhi = 2 * std::numbers::pi / nSensors; double r = 20_mm; std::vector> surfaces; for (std::size_t i = 0; i < nSensors; i++) { diff --git a/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp b/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp index 91eaebabe8e..00b6509ef25 100644 --- a/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp +++ b/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -91,7 +92,7 @@ struct SurfaceArrayCreatorFixture { SrfVec res; // TODO: The test is extremely numerically unstable in the face of upward // rounding in this multiplication and division. Find out why. - double phiStep = 2 * M_PI / n; + double phiStep = 2 * std::numbers::pi / n; for (std::size_t i = 0; i < n; ++i) { double z = zbase + ((i % 2 == 0) ? 1 : -1) * 0.2; double phi = std::fma(i, phiStep, shift); @@ -115,12 +116,13 @@ struct SurfaceArrayCreatorFixture { } SrfVec fullPhiTestSurfacesBRL(std::size_t n = 10, double shift = 0, - double zbase = 0, double incl = M_PI / 9., + double zbase = 0, + double incl = std::numbers::pi / 9., double w = 2, double h = 1.5) { SrfVec res; // TODO: The test is extremely numerically unstable in the face of upward // rounding in this multiplication and division. Find out why. - double phiStep = 2 * M_PI / n; + double phiStep = 2 * std::numbers::pi / n; for (std::size_t i = 0; i < n; ++i) { double z = zbase; double phi = std::fma(i, phiStep, shift); @@ -130,7 +132,7 @@ struct SurfaceArrayCreatorFixture { trans.rotate(Eigen::AngleAxisd(phi, Vector3(0, 0, 1))); trans.translate(Vector3(10, 0, z)); trans.rotate(Eigen::AngleAxisd(incl, Vector3(0, 0, 1))); - trans.rotate(Eigen::AngleAxisd(M_PI / 2., Vector3(0, 1, 0))); + trans.rotate(Eigen::AngleAxisd(std::numbers::pi / 2., Vector3(0, 1, 0))); auto bounds = std::make_shared(w, h); std::shared_ptr srf = @@ -153,8 +155,8 @@ struct SurfaceArrayCreatorFixture { Transform3 trans; trans.setIdentity(); trans.translate(origin + dir * step * i); - // trans.rotate(AngleAxis3(M_PI/9., Vector3(0, 0, 1))); - trans.rotate(AngleAxis3(M_PI / 2., Vector3(1, 0, 0))); + // trans.rotate(AngleAxis3(std::numbers::pi / 9., Vector3(0, 0, 1))); + trans.rotate(AngleAxis3(std::numbers::pi / 2., Vector3(1, 0, 0))); trans = trans * pretrans; auto bounds = std::make_shared(2, 1.5); @@ -177,7 +179,8 @@ struct SurfaceArrayCreatorFixture { for (int i = 0; i < nZ; i++) { double z = i * w * 2 + z0; // std::cout << "z=" << z << std::endl; - SrfVec ring = fullPhiTestSurfacesBRL(nPhi, 0, z, M_PI / 9., w, h); + SrfVec ring = + fullPhiTestSurfacesBRL(nPhi, 0, z, std::numbers::pi / 9., w, h); res.insert(res.end(), ring.begin(), ring.end()); } @@ -185,14 +188,15 @@ struct SurfaceArrayCreatorFixture { } std::pair>> - makeBarrelStagger(int nPhi, int nZ, double shift = 0, double incl = M_PI / 9., - double w = 2, double h = 1.5) { + makeBarrelStagger(int nPhi, int nZ, double shift = 0, + double incl = std::numbers::pi / 9., double w = 2, + double h = 1.5) { double z0 = -(nZ - 1) * w; SrfVec res; std::vector> pairs; // TODO: The test is extremely numerically unstable in the face of upward // rounding in this multiplication and division. Find out why. - double phiStep = 2 * M_PI / nPhi; + double phiStep = 2 * std::numbers::pi / nPhi; for (int i = 0; i < nZ; i++) { double z = i * w * 2 + z0; for (int j = 0; j < nPhi; ++j) { @@ -202,7 +206,8 @@ struct SurfaceArrayCreatorFixture { trans.rotate(Eigen::AngleAxisd(phi, Vector3(0, 0, 1))); trans.translate(Vector3(10, 0, z)); trans.rotate(Eigen::AngleAxisd(incl, Vector3(0, 0, 1))); - trans.rotate(Eigen::AngleAxisd(M_PI / 2., Vector3(0, 1, 0))); + trans.rotate( + Eigen::AngleAxisd(std::numbers::pi / 2., Vector3(0, 1, 0))); auto bounds = std::make_shared(w, h); std::shared_ptr srfA = @@ -278,7 +283,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, 1.25664, 1.46608, 1.67552, 1.88496, 2.09439, 2.30383, 2.51327, 2.72271, 2.93215, 3.14159}; - double step = 2 * M_PI / 30.; + double step = 2 * std::numbers::pi / 30.; // endcap style modules @@ -294,8 +299,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, BinningValue::binPhi, pl, tr); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); CHECK_SMALL(phi(tr * Vector3::UnitX()), 1e-6); @@ -310,8 +315,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, draw_surfaces(surfaces, "SurfaceArrayCreator_createEquidistantAxis_EC_2.obj"); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); // CHECK_CLOSE_REL(bdExp, axis.binEdges, 0.001); CHECK_CLOSE_REL(phi(tr * Vector3::UnitX()), -0.5 * step, 1e-3); @@ -326,8 +331,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, draw_surfaces(surfaces, "SurfaceArrayCreator_createEquidistantAxis_EC_3.obj"); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); CHECK_CLOSE_REL(phi(tr * Vector3::UnitX()), step / -4., 1e-3); @@ -344,8 +349,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, draw_surfaces(surfaces, "SurfaceArrayCreator_createEquidistantAxis_EC_4.obj"); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); CHECK_CLOSE_REL(phi(tr * Vector3::UnitX()), step / 4., 1e-3); } @@ -363,8 +368,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, draw_surfaces(surfaces, "SurfaceArrayCreator_createEquidistantAxis_BRL_1.obj"); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); CHECK_SMALL(phi(tr * Vector3::UnitX()), 1e-6); @@ -379,8 +384,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, draw_surfaces(surfaces, "SurfaceArrayCreator_createEquidistantAxis_BRL_2.obj"); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); // CHECK_CLOSE_REL(bdExp, axis.binEdges, 0.001); CHECK_CLOSE_REL(phi(tr * Vector3::UnitX()), -0.5 * step, 1e-3); @@ -396,8 +401,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, draw_surfaces(surfaces, "SurfaceArrayCreator_createEquidistantAxis_BRL_3.obj"); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); // CHECK_CLOSE_REL(bdExp, axis.binEdges, 0.001); CHECK_CLOSE_REL(phi(tr * Vector3::UnitX()), step / -4., 1e-3); @@ -413,8 +418,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Phi, draw_surfaces(surfaces, "SurfaceArrayCreator_createEquidistantAxis_BRL_4.obj"); BOOST_CHECK_EQUAL(axis.nBins, 30u); - CHECK_CLOSE_REL(axis.max, M_PI, 1e-6); - CHECK_CLOSE_REL(axis.min, -M_PI, 1e-6); + CHECK_CLOSE_REL(axis.max, std::numbers::pi, 1e-6); + CHECK_CLOSE_REL(axis.min, -std::numbers::pi, 1e-6); BOOST_CHECK_EQUAL(axis.bType, equidistant); // CHECK_CLOSE_REL(bdExp, axis.binEdges, 0.001); CHECK_CLOSE_REL(phi(tr * Vector3::UnitX()), step / 4., 1e-3); @@ -477,7 +482,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_createEquidistantAxis_Z, // z row where elements are rotated around y Transform3 tr = Transform3::Identity(); - tr.rotate(AngleAxis3(M_PI / 4., Vector3(0, 0, 1))); + tr.rotate(AngleAxis3(std::numbers::pi / 4., Vector3(0, 0, 1))); surfaces = straightLineSurfaces(10, 3, Vector3(0, 0, 0 + 1.5), tr); surfacesRaw = unpack_shared_vector(surfaces); pl = ProtoLayer(tgContext, surfacesRaw); @@ -563,16 +568,16 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_completeBinning, std::vector brlRaw = unpack_shared_vector(brl); draw_surfaces(brl, "SurfaceArrayCreator_completeBinning_BRL.obj"); - Axis phiAxis(-M_PI, M_PI, - 30u); + Axis phiAxis( + -std::numbers::pi, std::numbers::pi, 30u); Axis zAxis(-14, 14, 7u); double R = 10.; auto globalToLocal = [](const Vector3& pos) { - return Vector2(phi(pos) + 2 * M_PI / 30 / 2, pos.z()); + return Vector2(phi(pos) + 2 * std::numbers::pi / 30 / 2, pos.z()); }; auto localToGlobal = [R](const Vector2& loc) { - double phi = loc[0] - 2 * M_PI / 30 / 2; + double phi = loc[0] - 2 * std::numbers::pi / 30 / 2; return Vector3(R * std::cos(phi), R * std::sin(phi), loc[1]); }; @@ -600,7 +605,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_completeBinning, BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_barrelStagger, SurfaceArrayCreatorFixture) { - auto barrel = makeBarrelStagger(30, 7, 0, M_PI / 9.); + auto barrel = makeBarrelStagger(30, 7, 0, std::numbers::pi / 9.); auto brl = barrel.first; std::vector brlRaw = unpack_shared_vector(brl); draw_surfaces(brl, "SurfaceArrayCreator_barrelStagger.obj"); @@ -696,7 +701,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_barrelStagger, for (const auto& edge : axes.at(0)->getBinEdges()) { BOOST_TEST_INFO("phi edge index " << i); auto phiEdge = phiEdgesExp.at(i); - CHECK_CLOSE_ABS(edge, phiEdge, 1e-5 * M_PI); + CHECK_CLOSE_ABS(edge, phiEdge, 1e-5 * std::numbers::pi); i++; } i = 0; diff --git a/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp b/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp index 398e4279a9d..6a3c92aa8a3 100644 --- a/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp +++ b/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -37,20 +38,22 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceMatcher) { double phiTol = 0.1; - auto oneBounds = std::make_shared(rMin, rMax, M_PI / 16, 0.); + auto oneBounds = + std::make_shared(rMin, rMax, std::numbers::pi / 16., 0.); auto oneSurface = Surface::makeShared(identity, oneBounds); - auto otherBounds = - std::make_shared(2 * rMax, 4 * rMax, M_PI / 16, 0.5 * M_PI); + auto otherBounds = std::make_shared( + 2 * rMax, 4 * rMax, std::numbers::pi / 16., std::numbers::pi / 2.); auto otherSurface = Surface::makeShared(identity, otherBounds); auto similarRbounds = std::make_shared( - rMin - 0.5 * rMinTol, rMax + 0.5 * rMaxTol, M_PI / 16, 0.5 * M_PI); + rMin - 0.5 * rMinTol, rMax + 0.5 * rMaxTol, std::numbers::pi / 1., + std::numbers::pi / 2.); auto similarRSurface = Surface::makeShared(identity, similarRbounds); - auto similarPhiBounds = - std::make_shared(0.25 * rMin, 0.5 * rMin, M_PI / 16, 0.); + auto similarPhiBounds = std::make_shared( + 0.25 * rMin, 0.5 * rMin, std::numbers::pi / 16., 0.); auto similarPhiSurface = Surface::makeShared(identity, similarPhiBounds); diff --git a/Tests/UnitTests/Core/Geometry/TrapezoidVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/TrapezoidVolumeBoundsTests.cpp index 79e21127ba1..a6bd725bd3d 100644 --- a/Tests/UnitTests/Core/Geometry/TrapezoidVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/TrapezoidVolumeBoundsTests.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -44,7 +45,7 @@ BOOST_AUTO_TEST_CASE(bounding_box_creation) { CHECK_CLOSE_ABS(bb.max(), Vector3(10, 38, 24), tol); CHECK_CLOSE_ABS(bb.min(), Vector3(-10, 22, 16), tol); - trf = AngleAxis3(M_PI / 2., Vector3(-2, 4, 5).normalized()); + trf = AngleAxis3(std::numbers::pi / 2., Vector3(-2, 4, 5).normalized()); bb = tvb.boundingBox(&trf); CHECK_CLOSE_ABS(bb.max(), Vector3(9.32577, 11.4906, 11.5777), tol); diff --git a/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp b/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp index 36a7941e0fd..a249d22ba4b 100644 --- a/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp +++ b/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp @@ -22,6 +22,7 @@ #include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/Logger.hpp" +#include #include #include #include @@ -85,7 +86,8 @@ BOOST_AUTO_TEST_CASE(AccumulationTest) { std::make_shared(mp, 1.)); // Second surface is binned Phi / Z - BinUtility sb1(4, -M_PI, M_PI, closed, BinningValue::binPhi); + BinUtility sb1(4, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); sb1 += BinUtility(2, -100., 100., open, BinningValue::binZ); surfaces[1u]->assignSurfaceMaterial( std::make_shared(sb1)); diff --git a/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp b/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp index 52b3af3358b..fbce80b8d5e 100644 --- a/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/GridSurfaceMaterialTests.cpp @@ -14,6 +14,7 @@ #include "Acts/Utilities/GridAxisGenerators.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include #include // this is a global access to the x coordinate @@ -206,18 +207,20 @@ BOOST_AUTO_TEST_CASE(GridIndexedMaterial2D) { using EqEqGrid = EqBoundEqClosed::grid_type; using Point = EqEqGrid::point_t; - EqBoundEqClosed eqeqBound{{-1., 1.}, 2, {-M_PI, M_PI}, 4}; + EqBoundEqClosed eqeqBound{ + {-1., 1.}, 2, {-std::numbers::pi, std::numbers::pi}, 4}; EqEqGrid eqeqGrid{eqeqBound()}; - eqeqGrid.atPosition(Point{-0.5, -M_PI * 0.75}) = 1u; // material 1 - eqeqGrid.atPosition(Point{-0.5, -M_PI * 0.25}) = 1u; // material 1 - eqeqGrid.atPosition(Point{-0.5, M_PI * 0.25}) = 0u; // vacuum - eqeqGrid.atPosition(Point{-0.5, M_PI * 0.75}) = 2u; // material 2 + eqeqGrid.atPosition(Point{-0.5, -std::numbers::pi * 0.75}) = + 1u; // material 1 + eqeqGrid.atPosition(Point{-0.5, -std::numbers::pi / 4.}) = 1u; // material 1 + eqeqGrid.atPosition(Point{-0.5, std::numbers::pi / 4.}) = 0u; // vacuum + eqeqGrid.atPosition(Point{-0.5, std::numbers::pi * 0.75}) = 2u; // material 2 - eqeqGrid.atPosition(Point{0.5, -M_PI * 0.75}) = 0u; // vacuum - eqeqGrid.atPosition(Point{0.5, -M_PI * 0.25}) = 3u; // material 3 - eqeqGrid.atPosition(Point{0.5, M_PI * 0.25}) = 3u; // material 3 - eqeqGrid.atPosition(Point{0.5, M_PI * 0.75}) = 0u; // vacuum + eqeqGrid.atPosition(Point{0.5, -std::numbers::pi * 0.75}) = 0u; // vacuum + eqeqGrid.atPosition(Point{0.5, -std::numbers::pi / 4.}) = 3u; // material 3 + eqeqGrid.atPosition(Point{0.5, std::numbers::pi / 4.}) = 3u; // material 3 + eqeqGrid.atPosition(Point{0.5, std::numbers::pi * 0.75}) = 0u; // vacuum // With radius 20 auto boundToGrid = std::make_unique(20.); diff --git a/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp b/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp index dde3a05edba..1c76cf866f7 100644 --- a/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp +++ b/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -129,7 +130,8 @@ BOOST_AUTO_TEST_CASE(Square_Grid_test) { /// with a 2D grid BOOST_AUTO_TEST_CASE(PhiZ_Grid_test) { BinUtility bu(2, -2., 2., open, BinningValue::binZ); - bu += BinUtility(3, -M_PI, M_PI, closed, BinningValue::binPhi); + bu += BinUtility(3, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); auto bd = bu.binningData(); std::function transfoGlobalToLocal; @@ -309,7 +311,8 @@ BOOST_AUTO_TEST_CASE(Cubic_Grid_test) { /// @brief Various test for the Material in the case of a Cylindrical volume BOOST_AUTO_TEST_CASE(Cylindrical_Grid_test) { BinUtility bu(4, 1., 4., open, BinningValue::binR); - bu += BinUtility(3, -M_PI, M_PI, closed, BinningValue::binPhi); + bu += BinUtility(3, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); bu += BinUtility(2, -2., 2., open, BinningValue::binZ); auto bd = bu.binningData(); std::function transfoGlobalToLocal; diff --git a/Tests/UnitTests/Core/Material/MaterialValidaterTests.cpp b/Tests/UnitTests/Core/Material/MaterialValidaterTests.cpp index af98a7df659..7a8004f1b65 100644 --- a/Tests/UnitTests/Core/Material/MaterialValidaterTests.cpp +++ b/Tests/UnitTests/Core/Material/MaterialValidaterTests.cpp @@ -22,6 +22,7 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include +#include namespace Acts::Test { @@ -125,7 +126,7 @@ BOOST_AUTO_TEST_CASE(MaterialValidaterFlowTest) { tContext, MagneticFieldContext(), Vector3(0, 0, 0), Vector3(1, 0, 1).normalized()); - ActsScalar pathCorrection = std::sqrt(2.); + ActsScalar pathCorrection = std::numbers::sqrt2; CHECK_CLOSE_ABS(rMaterial2.materialInX0, pathCorrection * (2. / 21. + 4. / 41. + 6. / 61.), 1e-6); CHECK_CLOSE_ABS(rMaterial2.materialInL0, diff --git a/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp b/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp index fb1a1717b5c..5ba2af8da41 100644 --- a/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp +++ b/Tests/UnitTests/Core/Propagator/CovarianceEngineTests.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -255,7 +256,7 @@ auto makeDist(double a, double b) { const auto locDist = makeDist(-5_mm, 5_mm); const auto bFieldDist = makeDist(0, 3_T); -const auto angleDist = makeDist(-2 * M_PI, 2 * M_PI); +const auto angleDist = makeDist(-2 * std::numbers::pi, 2 * std::numbers::pi); const auto posDist = makeDist(-50_mm, 50_mm); #define MAKE_SURFACE() \ @@ -286,7 +287,8 @@ BOOST_DATA_TEST_CASE(CovarianceConversionSamePlane, covA.diagonal() << 1, 2, 3, 4, 5, 6; BoundVector parA; - parA << l0, l1, M_PI / 4., M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; + parA << l0, l1, std::numbers::pi / 4., std::numbers::pi / 2. * 0.9, + -1 / 1_GeV, 5_ns; // identical surface, this should work auto [parB, covB] = @@ -336,7 +338,8 @@ BOOST_DATA_TEST_CASE(CovarianceConversionRotatedPlane, covA.diagonal() << 1, 2, 3, 4, 5, 6; BoundVector parA; - parA << l0, l1, M_PI / 4., M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; + parA << l0, l1, std::numbers::pi / 4., std::numbers::pi / 2. * 0.9, + -1 / 1_GeV, 5_ns; auto [parB, covB] = boundToBound(parA, covA, *planeSurfaceA, *planeSurfaceB, bField); @@ -384,7 +387,8 @@ BOOST_DATA_TEST_CASE(CovarianceConversionL0TiltedPlane, BoundVector parA; // loc 0 must be zero so we're on the intersection of both surfaces. - parA << 0, l1, M_PI / 4., M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; + parA << 0, l1, std::numbers::pi / 4., std::numbers::pi / 2. * 0.9, -1 / 1_GeV, + 5_ns; BoundMatrix covA; covA.setZero(); @@ -432,7 +436,8 @@ BOOST_DATA_TEST_CASE(CovarianceConversionL1TiltedPlane, BoundVector parA; // loc 1 must be zero so we're on the intersection of both surfaces. - parA << l0, 0, M_PI / 4., M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; + parA << l0, 0, std::numbers::pi / 4., std::numbers::pi / 2. * 0.9, -1 / 1_GeV, + 5_ns; BoundMatrix covA; covA.setZero(); @@ -470,7 +475,8 @@ BOOST_DATA_TEST_CASE(CovarianceConversionPerigee, auto planeSurfaceA = MAKE_SURFACE(); BoundVector parA; - parA << l0, l1, M_PI / 4., M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; + parA << l0, l1, std::numbers::pi / 4., std::numbers::pi / 2. * 0.9, + -1 / 1_GeV, 5_ns; BoundMatrix covA; covA.setZero(); diff --git a/Tests/UnitTests/Core/Propagator/DirectNavigatorTests.cpp b/Tests/UnitTests/Core/Propagator/DirectNavigatorTests.cpp index f01e2da6339..586e51bfc31 100644 --- a/Tests/UnitTests/Core/Propagator/DirectNavigatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/DirectNavigatorTests.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -178,14 +179,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 20, bdata::distribution = std::uniform_real_distribution( 0.15_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 21, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 22, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 23, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ diff --git a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp index e818e220915..d784c0b26bb 100644 --- a/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/EigenStepperTests.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -968,7 +969,7 @@ BOOST_AUTO_TEST_CASE(step_extension_vacmatvac_test) { // Test case a). The DenseEnvironmentExtension should state that it is not // valid in this case. BOOST_AUTO_TEST_CASE(step_extension_trackercalomdt_test) { - double rotationAngle = M_PI * 0.5; + double rotationAngle = std::numbers::pi / 2.; Vector3 xPos(cos(rotationAngle), 0., sin(rotationAngle)); Vector3 yPos(0., 1., 0.); Vector3 zPos(-sin(rotationAngle), 0., cos(rotationAngle)); diff --git a/Tests/UnitTests/Core/Propagator/ExtrapolatorTests.cpp b/Tests/UnitTests/Core/Propagator/ExtrapolatorTests.cpp index 4316c7ba563..e8171faf004 100644 --- a/Tests/UnitTests/Core/Propagator/ExtrapolatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/ExtrapolatorTests.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -85,14 +86,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 0, bdata::distribution = std::uniform_real_distribution( 0.4_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 1, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 2, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ @@ -127,14 +128,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 10, bdata::distribution = std::uniform_real_distribution( 0.4_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 11, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 11, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 12, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 13, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ @@ -193,14 +194,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 20, bdata::distribution = std::uniform_real_distribution( 0.4_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 21, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 22, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 23, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ @@ -240,14 +241,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 20, bdata::distribution = std::uniform_real_distribution( 0.1_GeV, 0.5_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 21, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 22, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 23, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ @@ -279,7 +280,8 @@ BOOST_DATA_TEST_CASE( auto bCache = bField->makeCache(mfContext); double pmax = options.pathLimit * - bField->getField(start.position(tgContext), bCache).value().norm() / M_PI; + bField->getField(start.position(tgContext), bCache).value().norm() / + std::numbers::pi; if (p < pmax) { BOOST_CHECK_LT(status.pathLength, options.pathLimit); } else { diff --git a/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp b/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp index 20493c86f45..ecb3fab014b 100644 --- a/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp +++ b/Tests/UnitTests/Core/Propagator/LoopProtectionTests.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -122,12 +123,12 @@ struct PropagatorState { BOOST_DATA_TEST_CASE( loop_aborter_test, bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, M_PI))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 22, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 22, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::xrange(1), phi, deltaPhi, index) { (void)index; @@ -165,14 +166,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 20, bdata::distribution = std::uniform_real_distribution( 0.5_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 21, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 22, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 23, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ diff --git a/Tests/UnitTests/Core/Propagator/MaterialCollectionTests.cpp b/Tests/UnitTests/Core/Propagator/MaterialCollectionTests.cpp index 1e729221425..e7f8f70080c 100644 --- a/Tests/UnitTests/Core/Propagator/MaterialCollectionTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MaterialCollectionTests.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -355,14 +356,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 20, bdata::distribution = std::uniform_real_distribution( 0.5_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 21, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 21, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 22, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 23, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index e7edefb1f03..3fee9d4b6dd 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -127,11 +128,11 @@ auto makeDefaultBoundPars(bool cov = true, std::size_t n = 4, // note that we are using the default random device std::mt19937 gen; - std::uniform_real_distribution<> locDis(-10.0, 10.0); - std::uniform_real_distribution<> phiDis(-M_PI, M_PI); - std::uniform_real_distribution<> thetaDis(0, M_PI); - std::uniform_real_distribution<> qOverPDis(-10.0, 10.0); - std::uniform_real_distribution<> timeDis(0.0, 100.0); + std::uniform_real_distribution<> locDis(-10., 10.); + std::uniform_real_distribution<> phiDis(-std::numbers::pi, std::numbers::pi); + std::uniform_real_distribution<> thetaDis(0., std::numbers::pi); + std::uniform_real_distribution<> qOverPDis(-10., 10.); + std::uniform_real_distribution<> timeDis(0., 100.); for (auto i = 0ul; i < n; ++i) { BoundVector params = BoundVector::Zero(); @@ -451,9 +452,9 @@ void test_multi_stepper_surface_status_update() { std::vector>> cmps(2, {0.5, BoundVector::Zero(), std::nullopt}); - std::get(cmps[0])[eBoundTheta] = M_PI_2; - std::get(cmps[1])[eBoundPhi] = M_PI; - std::get(cmps[1])[eBoundTheta] = M_PI_2; + std::get(cmps[0])[eBoundTheta] = std::numbers::pi / 2.; + std::get(cmps[1])[eBoundPhi] = std::numbers::pi; + std::get(cmps[1])[eBoundTheta] = std::numbers::pi / 2.; std::get(cmps[0])[eBoundQOverP] = 1.0; std::get(cmps[1])[eBoundQOverP] = 1.0; @@ -563,9 +564,9 @@ void test_component_bound_state() { std::vector>> cmps(2, {0.5, BoundVector::Zero(), std::nullopt}); - std::get(cmps[0])[eBoundTheta] = M_PI_2; - std::get(cmps[1])[eBoundPhi] = M_PI; - std::get(cmps[1])[eBoundTheta] = M_PI_2; + std::get(cmps[0])[eBoundTheta] = std::numbers::pi / 2.; + std::get(cmps[1])[eBoundPhi] = std::numbers::pi; + std::get(cmps[1])[eBoundTheta] = std::numbers::pi / 2.; std::get(cmps[0])[eBoundQOverP] = 1.0; std::get(cmps[1])[eBoundQOverP] = 1.0; diff --git a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp index c434aa0044d..3728ca7b78e 100644 --- a/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/PropagatorTests.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -165,14 +166,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 0, bdata::distribution = std::uniform_real_distribution( 0.4_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 1, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 2, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ @@ -225,14 +226,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 0, bdata::distribution = std::uniform_real_distribution( 0.4_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 1, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 2, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ @@ -305,14 +306,14 @@ BOOST_DATA_TEST_CASE( bdata::random((bdata::engine = std::mt19937(), bdata::seed = 0, bdata::distribution = std::uniform_real_distribution( 0.4_GeV, 10_GeV))) ^ - bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1, - bdata::distribution = - std::uniform_real_distribution(-M_PI, - M_PI))) ^ + bdata::random( + (bdata::engine = std::mt19937(), bdata::seed = 1, + bdata::distribution = std::uniform_real_distribution( + -std::numbers::pi, std::numbers::pi))) ^ bdata::random( (bdata::engine = std::mt19937(), bdata::seed = 2, - bdata::distribution = - std::uniform_real_distribution(1.0, M_PI - 1.0))) ^ + bdata::distribution = std::uniform_real_distribution( + 1., std::numbers::pi - 1.))) ^ bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3, bdata::distribution = std::uniform_int_distribution(0, 1))) ^ @@ -395,7 +396,7 @@ BOOST_AUTO_TEST_CASE(BasicPropagatorInterface) { .planeSurface(); BoundVector startPars; - startPars << 0, 0, 0, M_PI / 2, 1 / 1_GeV, 0; + startPars << 0, 0, 0, std::numbers::pi / 2., 1 / 1_GeV, 0; BoundTrackParameters startParameters{startSurface, startPars, std::nullopt, ParticleHypothesis::pion()}; diff --git a/Tests/UnitTests/Core/Seeding/BinnedGroupTest.cpp b/Tests/UnitTests/Core/Seeding/BinnedGroupTest.cpp index 1549472f1f6..97c6df0ae4a 100644 --- a/Tests/UnitTests/Core/Seeding/BinnedGroupTest.cpp +++ b/Tests/UnitTests/Core/Seeding/BinnedGroupTest.cpp @@ -15,6 +15,7 @@ #include #include +#include #include namespace Acts::Test { @@ -156,7 +157,7 @@ BOOST_AUTO_TEST_CASE(binned_group_fill_2d) { using value_t = std::size_t; using binfinder_t = Acts::GridBinFinder<2ul>; - Axis phiAxis(AxisClosed, -M_PI, M_PI, 40); + Axis phiAxis(AxisClosed, -std::numbers::pi, std::numbers::pi, 40); Axis zAxis(AxisBound, 0, 100, 10); Grid grid(Type>, std::move(phiAxis), std::move(zAxis)); @@ -192,7 +193,7 @@ BOOST_AUTO_TEST_CASE(binned_group_fill_3d) { using grid_t = Acts::Grid, phiAxis_t, zAxis_t, rAxis_t>; using binfinder_t = Acts::GridBinFinder<3ul>; - phiAxis_t phiAxis(-M_PI, M_PI, 40); + phiAxis_t phiAxis(-std::numbers::pi, std::numbers::pi, 40); zAxis_t zAxis(0, 100, 10); rAxis_t rAxis(0, 11000, 1); diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index e8338925747..428c5b0ef1f 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -30,6 +30,8 @@ #include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp" #include "Acts/Utilities/Logger.hpp" +#include + BOOST_AUTO_TEST_SUITE(PathSeeder) using namespace Acts; @@ -51,7 +53,7 @@ const ActsScalar deltaYZ = 1.; const Vector4 trueVertex(-5., 0., 0., 0); const std::vector truePhis = {-0.15, -0.1, -0.05, 0, 0.05, 0.1, 0.15}; -const ActsScalar trueTheta = M_PI_2; +const ActsScalar trueTheta = std::numbers::pi / 2.; const ActsScalar trueQOverP = 1. / 1._GeV; // Intersection finding to get the diff --git a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp index ba38f5d11c1..057f4164514 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { BOOST_CHECK_THROW(ConeBounds(-alpha, zMin, zMax, halfPhi, averagePhi), std::logic_error); - // Exception for opening angle bigger std::numbers::pi + // Exception for opening angle bigger pi BOOST_CHECK_THROW( ConeBounds(std::numbers::pi, zMin, zMax, halfPhi, averagePhi), std::logic_error); diff --git a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp index af7eef54015..d97369fbfef 100644 --- a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp @@ -22,6 +22,7 @@ #include "Acts/Utilities/AngleHelpers.hpp" #include +#include using namespace Acts; namespace bdata = boost::unit_test::data; @@ -639,7 +640,8 @@ BOOST_AUTO_TEST_CASE(SubsetHitCountCut) { auto track = tc.makeTrack(); using namespace Acts::UnitLiterals; - track.parameters() << 0, 0, M_PI / 2, M_PI / 2, 1 / 1_GeV, 0; + track.parameters() << 0, 0, std::numbers::pi / 2., std::numbers::pi / 2., + 1 / 1_GeV, 0; auto perigee = Surface::makeShared(Vector3::Zero()); track.setReferenceSurface(perigee); return track; diff --git a/Tests/UnitTests/Core/TrackFitting/GainMatrixSmootherTests.cpp b/Tests/UnitTests/Core/TrackFitting/GainMatrixSmootherTests.cpp index ec8845ade2e..f92c8f50e87 100644 --- a/Tests/UnitTests/Core/TrackFitting/GainMatrixSmootherTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GainMatrixSmootherTests.cpp @@ -20,6 +20,7 @@ #include #include +#include namespace { @@ -46,12 +47,12 @@ BOOST_AUTO_TEST_CASE(Smooth) { covTrk.setIdentity(); covTrk.diagonal() << 0.08, 0.3, 1, 1, 1, 1; BoundVector parValues; - parValues << 0.3, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.; + parValues << 0.3, 0.5, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.predicted() = parValues; ts.predictedCovariance() = covTrk; - parValues << 0.301, 0.503, 0.5 * M_PI, 0., 1 / 100., 0.; + parValues << 0.301, 0.503, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.filtered() = parValues; ts.filteredCovariance() = covTrk; @@ -61,11 +62,11 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts_idx = traj.addTrackState(TrackStatePropMask::All, ts_idx); ts = traj.getTrackState(ts_idx); - parValues << 0.2, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.; + parValues << 0.2, 0.5, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.predicted() = parValues; ts.predictedCovariance() = covTrk; - parValues << 0.27, 0.53, 0.5 * M_PI, 0., 1 / 100., 0.; + parValues << 0.27, 0.53, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.filtered() = parValues; ts.filteredCovariance() = covTrk; ts.pathLength() = 2.; @@ -74,11 +75,11 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts_idx = traj.addTrackState(TrackStatePropMask::All, ts_idx); ts = traj.getTrackState(ts_idx); - parValues << 0.35, 0.49, 0.5 * M_PI, 0., 1 / 100., 0.; + parValues << 0.35, 0.49, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.predicted() = parValues; ts.predictedCovariance() = covTrk; - parValues << 0.33, 0.43, 0.5 * M_PI, 0., 1 / 100., 0.; + parValues << 0.33, 0.43, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.filtered() = parValues; ts.filteredCovariance() = covTrk; ts.pathLength() = 3.; diff --git a/Tests/UnitTests/Core/TrackFitting/GainMatrixUpdaterTests.cpp b/Tests/UnitTests/Core/TrackFitting/GainMatrixUpdaterTests.cpp index 6123b8ca81e..57c9f49f05d 100644 --- a/Tests/UnitTests/Core/TrackFitting/GainMatrixUpdaterTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GainMatrixUpdaterTests.cpp @@ -24,6 +24,7 @@ #include #include +#include #include namespace { @@ -51,7 +52,7 @@ BOOST_AUTO_TEST_CASE(Update) { // Make dummy track parameters ParametersVector trkPar; - trkPar << 0.3, 0.5, 0.5 * M_PI, 0.3 * M_PI, 0.01, 0.; + trkPar << 0.3, 0.5, std::numbers::pi / 2., 0.3 * std::numbers::pi, 0.01, 0.; CovarianceMatrix trkCov = CovarianceMatrix::Zero(); trkCov.diagonal() << 0.08, 0.3, 1, 1, 1, 0; @@ -102,7 +103,7 @@ BOOST_AUTO_TEST_CASE(UpdateFailed) { // Make dummy track parameters ParametersVector trkPar; - trkPar << 0.3, 0.5, 0.5 * M_PI, 0.3 * M_PI, 0.01, 0.; + trkPar << 0.3, 0.5, std::numbers::pi / 2., 0.3 * std::numbers::pi, 0.01, 0.; CovarianceMatrix trkCov = CovarianceMatrix::Zero(); // Make trajectory w/ one state diff --git a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp index 49b8304928e..8f6e9be94d3 100644 --- a/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/GsfComponentMergingTests.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -231,8 +232,8 @@ void test_surface(const Surface &surface, const angle_description_t &desc, a.boundPars = BoundVector::Ones(); a.boundPars[eBoundLoc0] *= p_it->first; a.boundPars[eBoundLoc1] *= p_it->second; - a.boundPars[eBoundPhi] = - detail::wrap_periodic(phi + dphi, -M_PI, 2 * M_PI); + a.boundPars[eBoundPhi] = detail::wrap_periodic( + phi + dphi, -std::numbers::pi, 2 * std::numbers::pi); a.boundPars[eBoundTheta] = theta + dtheta; // We don't look at covariance in this test @@ -293,7 +294,7 @@ BOOST_AUTO_TEST_CASE(test_with_data_circular) { const auto boundCov_data = boundCov(samples, mean_data, [](auto a, auto b) { Vector2 res = Vector2::Zero(); for (int i = 0; i < 2; ++i) { - res[i] = detail::difference_periodic(a[i], b[i], 2 * M_PI); + res[i] = detail::difference_periodic(a[i], b[i], 2 * std::numbers::pi); } return res; }); @@ -303,10 +304,10 @@ BOOST_AUTO_TEST_CASE(test_with_data_circular) { const auto [mean_test, boundCov_test] = detail::gaussianMixtureMeanCov(cmps, std::identity{}, d); - BOOST_CHECK(std::abs(detail::difference_periodic(mean_data[0], mean_test[0], - 2 * M_PI)) < 1.e-1); - BOOST_CHECK(std::abs(detail::difference_periodic(mean_data[1], mean_test[1], - 2 * M_PI)) < 1.e-1); + BOOST_CHECK(std::abs(detail::difference_periodic( + mean_data[0], mean_test[0], 2 * std::numbers::pi)) < 1.e-1); + BOOST_CHECK(std::abs(detail::difference_periodic( + mean_data[1], mean_test[1], 2 * std::numbers::pi)) < 1.e-1); CHECK_CLOSE_MATRIX(boundCov_data, boundCov_test, 1.e-1); } diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index bce69cba0b2..e3dbe1d4cde 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -33,6 +33,7 @@ #include "Acts/Visualization/GeometryView3D.hpp" #include "Acts/Visualization/ObjVisualization3D.hpp" +#include #include #include "FitterTestsCommon.hpp" @@ -122,7 +123,7 @@ std::shared_ptr makeToyDetector( const double halfSizeSurface = 1_m; // Rotation of the surfaces around the y-axis - const double rotationAngle = M_PI * 0.5; + const double rotationAngle = std::numbers::pi / 2.; const Vector3 xPos(cos(rotationAngle), 0., sin(rotationAngle)); const Vector3 yPos(0., 1., 0.); const Vector3 zPos(-sin(rotationAngle), 0., cos(rotationAngle)); @@ -394,7 +395,8 @@ BOOST_AUTO_TEST_CASE(Fit5Iterations) { BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc0], -11., 7e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc1], -15., 6e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], std::numbers::pi / 2, + 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], startParametersFit.parameters()[eBoundTime], 1e-6); @@ -499,7 +501,8 @@ BOOST_AUTO_TEST_CASE(MixedDetector) { BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc0], -11., 7e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc1], -15., 6e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], std::numbers::pi / 2, + 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], startParametersFit.parameters()[eBoundTime], 1e-6); @@ -596,7 +599,8 @@ BOOST_AUTO_TEST_CASE(FitWithBfield) { BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc0], -11., 8e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc1], -15., 6e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-4, 1e3); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], std::numbers::pi / 2, + 1e-3); BOOST_CHECK_CLOSE(track.parameters()[eBoundQOverP], 0.5, 2e-1); BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], startParametersFit.parameters()[eBoundTime], 1e-6); @@ -693,7 +697,8 @@ BOOST_AUTO_TEST_CASE(relChi2changeCutOff) { BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc0], -11., 7e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc1], -15., 6e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], std::numbers::pi / 2, + 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], startParametersFit.parameters()[eBoundTime], 1e-6); @@ -955,7 +960,8 @@ BOOST_AUTO_TEST_CASE(FindHoles) { BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc0], -11., 7e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc1], -15., 6e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], std::numbers::pi / 2, + 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], startParametersFit.parameters()[eBoundTime], 1e-6); @@ -1105,7 +1111,8 @@ BOOST_AUTO_TEST_CASE(Material) { BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc0], -11., 7e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundLoc1], -15., 6e0); BOOST_CHECK_CLOSE(track.parameters()[eBoundPhi], 1e-5, 1e3); - BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], M_PI / 2, 1e-3); + BOOST_CHECK_CLOSE(track.parameters()[eBoundTheta], std::numbers::pi / 2, + 1e-3); BOOST_CHECK_EQUAL(track.parameters()[eBoundQOverP], 1); BOOST_CHECK_CLOSE(track.parameters()[eBoundTime], startParametersFit.parameters()[eBoundTime], 1e-6); diff --git a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp index ab720dba11b..21d0a347e56 100644 --- a/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/MbfSmootherTests.cpp @@ -21,6 +21,7 @@ #include #include +#include namespace { @@ -52,7 +53,7 @@ BOOST_AUTO_TEST_CASE(Smooth) { auto ts = traj.getTrackState(ts_idx); ts.typeFlags().set(TrackStateFlag::MeasurementFlag); - ts.predicted() << 0.3, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.; + ts.predicted() << 0.3, 0.5, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.predictedCovariance() = covTrk; ts.allocateCalibrated(2); @@ -60,7 +61,7 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8; ts.setSubspaceIndices<2>(projector); - ts.filtered() << 0.301, 0.503, 0.5 * M_PI, 0., 1 / 100., 0.; + ts.filtered() << 0.301, 0.503, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; ts.pathLength() = 1.; ts.jacobian().setIdentity(); @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts = traj.getTrackState(ts_idx); ts.typeFlags().set(TrackStateFlag::MeasurementFlag); - ts.predicted() << 0.2, 0.5, 0.5 * M_PI, 0., 1 / 100., 0.; + ts.predicted() << 0.2, 0.5, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.predictedCovariance() = covTrk; ts.allocateCalibrated(2); @@ -77,7 +78,7 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8; ts.setSubspaceIndices<2>(projector); - ts.filtered() << 0.27, 0.53, 0.5 * M_PI, 0., 1 / 100., 0.; + ts.filtered() << 0.27, 0.53, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; ts.pathLength() = 2.; ts.jacobian().setIdentity(); @@ -86,7 +87,7 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts = traj.getTrackState(ts_idx); ts.typeFlags().set(TrackStateFlag::MeasurementFlag); - ts.predicted() << 0.35, 0.49, 0.5 * M_PI, 0., 1 / 100., 0.; + ts.predicted() << 0.35, 0.49, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.predictedCovariance() = covTrk; ts.allocateCalibrated(2); @@ -94,7 +95,7 @@ BOOST_AUTO_TEST_CASE(Smooth) { ts.calibratedCovariance<2>() << 1e+8, 0., 0., 1e+8; ts.setSubspaceIndices<2>(projector); - ts.filtered() << 0.33, 0.43, 0.5 * M_PI, 0., 1 / 100., 0.; + ts.filtered() << 0.33, 0.43, std::numbers::pi / 2., 0., 1 / 100., 0.; ts.filteredCovariance() = covTrk; ts.pathLength() = 3.; ts.jacobian().setIdentity(); diff --git a/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp b/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp index 6b755ddd386..1db5ee9ccfe 100644 --- a/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp @@ -19,13 +19,14 @@ #include #include +#include #include namespace Acts::Test { // Test Radial BOOST_AUTO_TEST_CASE(BinAdjustment_Radial) { - RadialBounds bound(50, 75, M_PI, 0); + RadialBounds bound(50, 75, std::numbers::pi, 0); BinUtility bu; bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binR); bu += BinUtility(1, 0, 1, Acts::closed, Acts::BinningValue::binPhi); @@ -34,21 +35,23 @@ BOOST_AUTO_TEST_CASE(BinAdjustment_Radial) { BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 50); BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 75); - BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, float{-M_PI}); - BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, float{M_PI}); + BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -std::numbers::pi_v); + BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, std::numbers::pi_v); } // Test Cylinder BOOST_AUTO_TEST_CASE(BinAdjustment_Cylinder) { - CylinderBounds bound(25, 50, M_PI / 4, 0); + CylinderBounds bound(25, 50, std::numbers::pi / 4, 0); BinUtility bu; bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binPhi); bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binZ); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); - BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, float{-M_PI / 4}); - BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, float{M_PI / 4}); + BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, + -static_cast(std::numbers::pi / 4.)); + BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, + static_cast(std::numbers::pi / 4.)); BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -50); BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 50); } diff --git a/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp b/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp index 202f9be263d..1b91120dd7f 100644 --- a/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp @@ -18,13 +18,14 @@ #include #include +#include #include namespace Acts::Test { // Test Cylinder BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_Cylinder) { - CylinderVolumeBounds bound(10, 50, 150, M_PI / 2, 0); + CylinderVolumeBounds bound(10, 50, 150, std::numbers::pi / 2., 0); BinUtility bu; bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binR); bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binPhi); @@ -34,8 +35,10 @@ BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_Cylinder) { BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 10); BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 50); - BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, float{-M_PI / 2}); - BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, float{M_PI / 2}); + BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, + -static_cast(std::numbers::pi / 2.)); + BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, + static_cast(std::numbers::pi / 2.)); BOOST_CHECK_EQUAL(buAdjust.binningData()[2].min, -150); BOOST_CHECK_EQUAL(buAdjust.binningData()[2].max, 150); } @@ -52,8 +55,8 @@ BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_CutoutCylinder) { BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 10); BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 50); - BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, float{-M_PI}); - BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, float{M_PI}); + BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -std::numbers::pi_v); + BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, std::numbers::pi_v); BOOST_CHECK_EQUAL(buAdjust.binningData()[2].min, -100); BOOST_CHECK_EQUAL(buAdjust.binningData()[2].max, 100); } diff --git a/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp b/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp index e861a2331b7..b44d939831f 100644 --- a/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -89,12 +90,14 @@ BOOST_AUTO_TEST_CASE(BinUtility_arbitrary_binning) { BOOST_AUTO_TEST_CASE(BinUtility_transform) { Transform3 transform_LtoG = Transform3::Identity(); transform_LtoG = transform_LtoG * Translation3(0., 0., -50); - transform_LtoG = transform_LtoG * AngleAxis3(M_PI / 4, Vector3(0, 0, 1)); + transform_LtoG = + transform_LtoG * AngleAxis3(std::numbers::pi / 4., Vector3(0, 0, 1)); Transform3 transform_GtoL = transform_LtoG.inverse(); BinUtility rUtil(10, 0., 100., open, BinningValue::binR); - BinUtility phiUtil(10, -M_PI, M_PI, closed, BinningValue::binPhi); + BinUtility phiUtil(10, -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); BinUtility zUtil(10, -100., 100., open, BinningValue::binZ); BinUtility noTranform; @@ -109,9 +112,9 @@ BOOST_AUTO_TEST_CASE(BinUtility_transform) { Vector3 pos1(0, 0, 0); Vector3 pos2(60, 0, 0); - Vector3 pos3(34, M_PI / 2, 0); + Vector3 pos3(34, std::numbers::pi / 2., 0); Vector3 pos4(0, 0, -80); - Vector3 pos5(80, -M_PI / 4, 50); + Vector3 pos5(80, -std::numbers::pi / 4., 50); for (int i = 0; i < 3; i++) { BOOST_CHECK_EQUAL(withTranform.bin(pos1, i), diff --git a/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp b/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp index d2585905589..95de3899f92 100644 --- a/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -30,7 +31,7 @@ Vector3 eta0Position(0.5, 1.5, 0.); // the test positions in 2D Vector2 xyPosition(0.5, 1.5); Vector2 rphizPosition(0.1, 2.5); -Vector2 rphiPosition(3.5, M_PI / 8.); +Vector2 rphiPosition(3.5, std::numbers::pi / 8.); // the binnings - equidistant // x/y/zData @@ -44,12 +45,11 @@ BinningData zData_eq(open, BinningValue::binZ, 10, 0., 10.); // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | BinningData rData_eq(open, BinningValue::binR, 10, 0., 10.); // bin boundaries -// > -M_PI | -3/5 M_PI | -1/5 M_PI | 1/5 M_PI | 3/5 M_PI | M_PI < -BinningData phiData_eq(closed, BinningValue::binPhi, 5, -M_PI, M_PI); -// BinningData rPhiData_eq(closed, BinningValue::binRPhi, 5, -M_PI, M_PI); -// h/etaData -// bin boundaries -// | 0 | 2 | 4 | 6 | 8 | 10 | +// > -PI | -3/5 PI | -1/5 PI | 1/5 PI | 3/5 PI | PI < +BinningData phiData_eq(closed, BinningValue::binPhi, 5, -std::numbers::pi, + std::numbers::pi); +// BinningData rPhiData_eq(closed, BinningValue::binRPhi, 5, -std::numbers::pi, +// std::numbers::pi); h/etaData bin boundaries | 0 | 2 | 4 | 6 | 8 | 10 | // BinningData hData_eq(open, BinningValue::binH, 5, 0., 10.); // | -2.5 | -1.5 | -0.5 | 0.5 | 1.5 | 2.5 | BinningData etaData_eq(open, BinningValue::binEta, 5, -2.5, 2.5); @@ -63,15 +63,16 @@ std::vector values = {0., 1., 2., 3., 4., 10.}; // | 0 | 1 | 2 | 3 | 4 | 10 | BinningData xData_arb(open, BinningValue::binX, values); BinningData yData_arb(open, BinningValue::binY, values); -// | -M_PI | -2 | -1 | 1 | 2 | M_PI | -std::vector phiValues = {-M_PI, -2., -1., 1., 2., M_PI}; +// | -PI | -2 | -1 | 1 | 2 | PI | +std::vector phiValues = {-std::numbers::pi, -2., -1., 1., 2., + std::numbers::pi}; BinningData phiData_arb(closed, BinningValue::binPhi, phiValues); // the binnings - arbitrary when switching to binary search - for boundary // sizes >= 50 std::size_t nBins_binary = 59; double valueMin = 0.; -double phiMin = -M_PI; +double phiMin = -std::numbers::pi; double delta = 0.5; double phiDelta = 0.1064; @@ -146,8 +147,9 @@ BOOST_AUTO_TEST_CASE(BinningData_BinningValue) { CHECK_CLOSE_REL(rData_eq.value(xyzPosition), std::hypot(0.5, 1.5), 1e-5); BOOST_CHECK_EQUAL(rData_eq.value(rphiPosition), 3.5); - CHECK_SMALL(phiData_eq.value(phi0Position), 1e-6 * M_PI); - CHECK_CLOSE_REL(phiData_eq.value(phiPihPosition), M_PI / 2, 1e-5); + CHECK_SMALL(phiData_eq.value(phi0Position), 1e-6 * std::numbers::pi); + CHECK_CLOSE_REL(phiData_eq.value(phiPihPosition), std::numbers::pi / 2., + 1e-5); BOOST_CHECK_EQUAL(phiData_eq.bins(), std::size_t{5}); BOOST_CHECK_EQUAL(phiData_arb.bins(), std::size_t{5}); @@ -219,7 +221,8 @@ BOOST_AUTO_TEST_CASE(BinningData_bins) { BOOST_CHECK_EQUAL(rData_eq.searchLocal(rphiPosition), std::size_t{3}); BOOST_CHECK_EQUAL(phiData_eq.searchGlobal(phi0Position), std::size_t{2}); BOOST_CHECK_EQUAL(phiData_eq.searchGlobal(phiPihPosition), std::size_t{3}); - BOOST_CHECK_EQUAL(phiData_arb_binary.search(M_PI), std::size_t{0}); + BOOST_CHECK_EQUAL(phiData_arb_binary.search(std::numbers::pi), + std::size_t{0}); // h/etaData BOOST_CHECK_EQUAL(etaData_eq.searchGlobal(eta0Position), std::size_t{2}); @@ -310,14 +313,14 @@ BOOST_AUTO_TEST_CASE(BinningData_boundaries) { xData_eq.boundaries().end(), boundaries.begin(), boundaries.end()); - float phiStep = M_PI * 2. / 5.; - std::vector phiBoundaries_eq = { - -M_PI, - static_cast(-M_PI + 1 * phiStep), - static_cast(-M_PI + 2 * phiStep), - static_cast(-M_PI + 3 * phiStep), - static_cast(-M_PI + 4 * phiStep), - static_cast(-M_PI + 5 * phiStep)}; + const float phiStep = std::numbers::pi * 2. / 5.; + std::vector phiBoundaries_eq; + + for (int i = 0; i <= 5; ++i) { + phiBoundaries_eq.push_back( + static_cast(-std::numbers::pi + i * phiStep)); + } + CHECK_CLOSE_REL(phiData_eq.boundaries(), phiBoundaries_eq, 1e-5); } @@ -362,13 +365,13 @@ BOOST_AUTO_TEST_CASE(BinningData_bincenter) { } // running into rounding errors here - float phiStep = M_PI * 2. / 5.; - std::vector phiCenters_eq = { - static_cast(-M_PI + 0.5 * phiStep), - static_cast(-M_PI + 1.5 * phiStep), - static_cast(-M_PI + 2.5 * phiStep), - static_cast(-M_PI + 3.5 * phiStep), - static_cast(-M_PI + 4.5 * phiStep)}; + const float phiStep = std::numbers::pi * 2. / 5.; + std::vector phiCenters_eq; + + for (int i = 0; i < 5; ++i) { + phiCenters_eq.push_back( + static_cast(-std::numbers::pi + (i + 0.5) * phiStep)); + } for (std::size_t ib = 0; ib < phiCenters_eq.size(); ++ib) { CHECK_CLOSE_ABS(phiData_eq.center(ib), phiCenters_eq[ib], 1e-3); @@ -377,41 +380,43 @@ BOOST_AUTO_TEST_CASE(BinningData_bincenter) { // special test for phi binning BOOST_AUTO_TEST_CASE(BinningData_phi_modules) { - // n phi modules with phi boundary at -M_Pi/+M_PI are checked above - // one module expands over -M_Pi/+M_PI - float deltaPhi = 0.1; - BinningData phiData_mod(closed, BinningValue::binPhi, 5, -M_PI + deltaPhi, - M_PI + deltaPhi); - float phiStep = M_PI * 2. / 5.; - std::vector phiBoundaries_mod = { - static_cast(-M_PI + deltaPhi), - static_cast(-M_PI + 1 * phiStep) + deltaPhi, - static_cast(-M_PI + 2 * phiStep) + deltaPhi, - static_cast(-M_PI + 3 * phiStep) + deltaPhi, - static_cast(-M_PI + 4 * phiStep) + deltaPhi, - static_cast(-M_PI + 5 * phiStep) + deltaPhi}; + // n phi modules with phi boundary at -pi/+pi are checked above one module + // expands over -pi/+pi + const float deltaPhi = 0.1; + BinningData phiData_mod(closed, BinningValue::binPhi, 5, + -std::numbers::pi + deltaPhi, + std::numbers::pi + deltaPhi); + + const float phiStep = std::numbers::pi * 2. / 5.; + std::vector phiBoundaries_mod; + + for (int i = 0; i <= 5; ++i) { + phiBoundaries_mod.push_back( + static_cast(-std::numbers::pi + i * phiStep) + deltaPhi); + } + // this is the boundary test CHECK_CLOSE_REL(phiData_mod.boundaries(), phiBoundaries_mod, 1e-5); // now test the bin jump 0/maxbin - float firstAngle = (-M_PI + 1.5 * deltaPhi); + float firstAngle = (-std::numbers::pi + 1.5 * deltaPhi); Vector3 firstBin(cos(firstAngle), sin(firstAngle), 0.); BOOST_CHECK_EQUAL(phiData_mod.search(firstAngle), std::size_t{0}); BOOST_CHECK_EQUAL(phiData_mod.searchGlobal(firstBin), std::size_t{0}); - float firstAngleNeg = (-M_PI + 0.5 * deltaPhi); + float firstAngleNeg = (-std::numbers::pi + 0.5 * deltaPhi); Vector3 lastBinNeg(cos(firstAngleNeg), sin(firstAngleNeg), 0.); BOOST_CHECK_EQUAL(phiData_mod.search(firstAngleNeg), std::size_t{4}); BOOST_CHECK_EQUAL(phiData_mod.searchGlobal(lastBinNeg), std::size_t{4}); - float lastAnglePos = (M_PI + 0.5 * deltaPhi); + float lastAnglePos = (std::numbers::pi + 0.5 * deltaPhi); Vector3 lastBinPos(cos(lastAnglePos), sin(lastAnglePos), 0.); BOOST_CHECK_EQUAL(phiData_mod.search(lastAnglePos), std::size_t{4}); BOOST_CHECK_EQUAL(phiData_mod.searchGlobal(lastBinPos), std::size_t{4}); // now test the (remaining) phi scaling - float underscaledAngle = -M_PI - 0.5 * deltaPhi; + float underscaledAngle = -std::numbers::pi - 0.5 * deltaPhi; Vector3 underscaledPos(cos(underscaledAngle), sin(underscaledAngle), 0.); BOOST_CHECK_EQUAL(phiData_mod.search(underscaledAngle), std::size_t{4}); BOOST_CHECK_EQUAL(phiData_mod.searchGlobal(underscaledPos), std::size_t{4}); diff --git a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp index 5541e3e8d36..f3aa6b2de14 100644 --- a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp +++ b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,7 @@ BOOST_AUTO_TEST_CASE(box_construction) { Box bb(&o, {-1, -1}, {2, 2}); typename Box::transform_type rot; - rot = Eigen::Rotation2D(M_PI / 7.); + rot = Eigen::Rotation2D(std::numbers::pi / 7.); Box bb_rot = bb.transformed(rot); CHECK_CLOSE_ABS(bb_rot.min(), Vector2F(-1.76874, -1.33485), 1e-4); @@ -75,13 +76,13 @@ BOOST_AUTO_TEST_CASE(box_construction) { Box bb(&o, {-1, -1, -1}, {2, 2, 2}); typename Box::transform_type rot; - rot = AngleAxis3F(M_PI / 3., Vector3F::UnitZ()); + rot = AngleAxis3F(std::numbers::pi / 3., Vector3F::UnitZ()); Box bb_rot = bb.transformed(rot); CHECK_CLOSE_ABS(bb_rot.min(), Vector3F(-2.23205, -1.36603, -1), 1e-4); CHECK_CLOSE_ABS(bb_rot.max(), Vector3F(1.86603, 2.73205, 2), 1e-4); - rot *= AngleAxis3F(M_PI / 5., Vector3F(1, 1, 0).normalized()); + rot *= AngleAxis3F(std::numbers::pi / 5., Vector3F(1, 1, 0).normalized()); Box bb_rot2 = bb.transformed(rot); CHECK_CLOSE_ABS(bb_rot2.min(), Vector3F(-2.40848, -1.51816, -2.0559), 1e-4); @@ -408,8 +409,9 @@ BOOST_AUTO_TEST_CASE(ray_obb_intersect) { {1.8, 1, 1}, {0, 1, 1}}}; auto cubo = std::make_shared(vertices); - auto trf = Transform3(Translation3(Vector3(0, 8, -5)) * - AngleAxis3(M_PI / 3., Vector3(1, -3, 9).normalized())); + auto trf = Transform3( + Translation3(Vector3(0, 8, -5)) * + AngleAxis3(std::numbers::pi / 3., Vector3(1, -3, 9).normalized())); Volume vol(trf, cubo); @@ -440,15 +442,15 @@ BOOST_AUTO_TEST_CASE(ray_obb_intersect) { for (const auto& vtx_ : vertices) { Vector3 vtx = trf * vtx_; - // this ray goes straight to the actual vertex, this should - // definitely intersect the OBB + // this ray goes straight to the actual vertex, this should definitely + // intersect the OBB Ray ray(origin, (vtx - origin).normalized()); ray = ray.transformed(trf.inverse()); BOOST_CHECK(obb.intersect(ray)); ray.draw(ply, (vtx - origin).norm()); - // now shift the target point away from the centroid - // this should definitely NOT intersect the OBB + // now shift the target point away from the centroid this should definitely + // NOT intersect the OBB vtx += (vtx - centroid); ray = Ray(origin, (vtx - origin).normalized()); ray = ray.transformed(trf.inverse()); @@ -471,8 +473,8 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { std::ofstream os; - std::size_t w = 1000; - std::size_t n = 10; + const std::size_t w = 1000; + const std::size_t n = 10; // BEGIN VISUAL PARAMETER TEST @@ -485,9 +487,9 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // ActsVector dir = {1, 0}; // ActsVector origin = {min + step * i, min + step * // j}; origin.x() *= 1.10; // visual Eigen::Rotation2D - // rot(2 * M_PI / static_cast(n) * i); BoundingBoxScalar - // angle = 0.5 * M_PI / n * j; Frustum2 fr(origin, rot * - // dir, angle); fr.svg(os, w, w, 2); + // rot(2 * std::numbers::pi / static_cast(n) * i); + // BoundingBoxScalar angle = std::numbers::pi / 2. / n * j; Frustum2 + // fr(origin, rot * dir, angle); fr.svg(os, w, w, 2); //} //} @@ -496,14 +498,12 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // END VISUAL PARAMETER TEST - w = 1000; - BoundingBoxScalar unit = 20; + const BoundingBoxScalar unit = 20; using Box = AxisAlignedBoundingBox; Object o; Box::Size size(Eigen::Matrix(2, 2)); - n = 10; BoundingBoxScalar minx = -20; BoundingBoxScalar miny = -20; BoundingBoxScalar maxx = 20; @@ -516,66 +516,66 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // clang-format off std::vector>> fr_exp; fr_exp = { - {Frustum2({0, 0}, {1, 0}, M_PI / 2.), + {Frustum2({0, 0}, {1, 0}, std::numbers::pi / 2.), {60, 70, 71, 72, 80, 81, 82, 83, 84, 90, 91, 92, 93, 94, 95, 96, 100, 101, 102, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120} }, - {Frustum2({0, 0}, {1, 0}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {1, 0}, 0.5 * std::numbers::pi / 2.), {60, 71, 81, 82, 83, 92, 93, 94, 102, 103, 104, 105, 106, 113, 114, 115, 116, 117} }, - {Frustum2({0, 0}, {1, 0}, 0.2 * M_PI / 2.), + {Frustum2({0, 0}, {1, 0}, 0.2 * std::numbers::pi / 2.), {60, 71, 82, 93, 104, 114, 115, 116} }, - {Frustum2({0, 0}, {1, 0}, 3 * M_PI / 4.), + {Frustum2({0, 0}, {1, 0}, 3 * std::numbers::pi / 4.), {60, 68, 69, 70, 71, 72, 73, 74, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120} }, - {Frustum2({0, 0}, {0, 1}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {0, 1}, 0.5 * std::numbers::pi / 2.), {42, 43, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 73, 74, 75, 76, 86, 87} }, - {Frustum2({0, 0}, {-1, 0}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {-1, 0}, 0.5 * std::numbers::pi / 2.), {3, 4, 5, 6, 7, 14, 15, 16, 17, 18, 26, 27, 28, 37, 38, 39, 49, 60} }, - {Frustum2({0, 0}, {0, -1}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {0, -1}, 0.5 * std::numbers::pi / 2.), {33, 34, 44, 45, 46, 47, 55, 56, 57, 58, 59, 60, 66, 67, 68, 69, 77, 78} }, - {Frustum2({0, 0}, {1, 1}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {1, 1}, 0.5 * std::numbers::pi / 2.), {60, 72, 73, 74, 83, 84, 85, 86, 87, 94, 95, 96, 97, 98, 106, 107, 108, 109, 117, 118, 119, 120} }, - {Frustum2({0, 0}, {-1, 1}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {-1, 1}, 0.5 * std::numbers::pi / 2.), {7, 8, 9, 10, 18, 19, 20, 21, 28, 29, 30, 31, 32, 39, 40, 41, 42, 43, 50, 51, 52, 60} }, - {Frustum2({0, 0}, {-1, -1}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {-1, -1}, 0.5 * std::numbers::pi / 2.), {0, 1, 2, 3, 11, 12, 13, 14, 22, 23, 24, 25, 26, 33, 34, 35, 36, 37, 46, 47, 48, 60} }, - {Frustum2({0, 0}, {1, -1}, 0.5 * M_PI / 2.), + {Frustum2({0, 0}, {1, -1}, 0.5 * std::numbers::pi / 2.), {60, 68, 69, 70, 77, 78, 79, 80, 81, 88, 89, 90, 91, 92, 99, 100, 101, 102, 110, 111, 112, 113} }, - {Frustum2({1, 1}, {1, -1}, M_PI / 2.), + {Frustum2({1, 1}, {1, -1}, std::numbers::pi / 2.), {55, 56, 57, 58, 59, 60, 66, 67, 68, 69, 70, 71, 77, 78, 79, 80, 81, 82, 88, 89, 90, 91, 92, 93, 99, 100, 101, 102, 103, 104, 110, 111, 112, 113, 114, 115} }, - {Frustum2({-1, -1}, {1, -1}, M_PI / 2.), + {Frustum2({-1, -1}, {1, -1}, std::numbers::pi / 2.), {55, 56, 57, 58, 59, 60, 66, 67, 68, 69, 70, 71, 77, 78, 79, 80, 81, 82, 88, 89, 90, 91, 92, 93, 99, 100, 101, 102, 103, 104, 110, 111, 112, 113, 114, 115} }, - {Frustum2({10, -10}, {1, 1}, 0.5 * M_PI / 2.), + {Frustum2({10, -10}, {1, 1}, 0.5 * std::numbers::pi / 2.), {91, 92, 102, 103, 104, 105, 114, 115, 116, 117, 118, 119} }, - {Frustum2({-10.3, 12.8}, {0.3, -1}, 0.5 * M_PI / 2.), + {Frustum2({-10.3, 12.8}, {0.3, -1}, 0.5 * std::numbers::pi / 2.), {22, 23, 24, 25, 26, 27, 28, 33, 34, 35, 36, 37, 38, 39, 40, 41, 44, 45, 46, 47, 48, 49, 50, 55, 56, 57, 58, 59, 60, 66, 67, 68, 69, 70, 77, 78, 79, 80, 88, 89, 99} }, - {Frustum2({17.2, 19.45}, {-1, -0.1}, 0.5 * M_PI / 2.), + {Frustum2({17.2, 19.45}, {-1, -0.1}, 0.5 * std::numbers::pi / 2.), {5, 6, 7, 8, 9, 10, 17, 18, 19, 20, 21, 28, 29, 30, 31, 32, 40, 41, 42, 43, 51, 52, 53, 54, 63, 64, 65, 74, 75, 76, 86, 87, 97, 98, 109} @@ -665,7 +665,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // ActsVector origin( // min + i * step, min + j * step, min + k * step); //// std::cout << origin.transpose() << std::endl; - // make(M_PI / 4., origin, os); + // make(std::numbers::pi / 4., origin, os); //} //} //} @@ -677,9 +677,10 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // Eigen::Affine3f rot; // for (std::size_t i = 0; i <= n; i++) { // ActsVector origin(i * 4, 0, 0); - // rot = Eigen::AngleAxisf(M_PI / static_cast(n) * i, + // rot = Eigen::AngleAxisf(std::numbers::pi / + // static_cast(n) * i, // ActsVector::UnitY()); BoundingBoxScalar angle = - // (M_PI / 2.) / static_cast(n) * (1 + i); + // (std::numbers::pi / 2.) / static_cast(n) * (1 + i); // ActsVector dir(1, 0, 0); Frustum3 fr(origin, rot * // dir, angle); fr.draw(helper, 2); //} @@ -693,7 +694,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { std::vector>> fr_exp; fr_exp = { - {Frustum3({0, 0, 0}, {1, 0, 0}, M_PI / 2.), + {Frustum3({0, 0, 0}, {1, 0, 0}, std::numbers::pi / 2.), { 665, 763, 774, 775, 785, 786, 787, 788, 796, 797, 807, 872, 873, 883, 884, 885, 886, 894, 895, 896, 897, 898, @@ -724,7 +725,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1314, 1315, 1316, 1317, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, }}, - {Frustum3({0, 0, 0}, {0, 1, 0}, M_PI / 2.), + {Frustum3({0, 0, 0}, {0, 1, 0}, std::numbers::pi / 2.), {93, 102, 103, 104, 105, 106, 112, 113, 114, 115, 116, 117, 118, 203, 213, 214, 215, 223, 224, 225, 226, 227, 233, 234, 235, 236, 237, 238, 239, 324, 333, 334, 335, @@ -753,7 +754,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330}}, - {Frustum3({0, 0, 0}, {0, 0, 1}, M_PI / 2.), + {Frustum3({0, 0, 0}, {0, 0, 1}, std::numbers::pi / 2.), {32, 42, 43, 53, 54, 63, 64, 65, 75, 76, 86, 87, 98, 153, 163, 164, 173, 174, 175, 183, 184, 185, 186, 195, 196, 197, 207, 208, 219, 263, 273, 274, 283, @@ -782,17 +783,17 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1153, 1154, 1164, 1165, 1175, 1176, 1186, 1187, 1197, 1198, 1208, 1209, 1220, 1231, 1242, 1253, 1264, 1275, 1286, 1297, 1308, 1319, 1330}}, - {Frustum3({0, 0, 0}, {0, 0, 1}, M_PI / 4.), + {Frustum3({0, 0, 0}, {0, 0, 1}, std::numbers::pi / 4.), {186, 305, 306, 307, 416, 417, 425, 426, 427, 428, 438, 439, 527, 536, 537, 538, 545, 546, 547, 548, 549, 558, 559, 560, 571, 647, 648, 656, 657, 658, 659, 665, 666, 667, 668, 669, 670, 678, 679, 680, 681, 691, 692, 758, 767, 768, 769, 777, 778, 779, 780, 788, 789, 790, 791, 799, 800, 801, 802, 811, 812, 813, 824, 879, 890, 901, 912, 923, 934, 945}}, - {Frustum3({0, 0, 0}, {0, 0, 1}, M_PI / 8.), + {Frustum3({0, 0, 0}, {0, 0, 1}, std::numbers::pi / 8.), {427, 428, 546, 547, 548, 549, 658, 659, 665, 666, 667, 668, 669, 670, 680, 681, 780, 791, 802}}, - {Frustum3({0, 0, 0}, {0, 0, 1}, M_PI * 3. / 4.), + {Frustum3({0, 0, 0}, {0, 0, 1}, std::numbers::pi * 3. / 4.), {8, 9, 10, 19, 20, 21, 29, 30, 31, 32, 40, 41, 42, 43, 51, 52, 53, 54, 61, 62, 63, 64, 65, 73, 74, 75, 76, 84, 85, 86, 87, 95, 96, @@ -841,7 +842,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1273, 1274, 1275, 1283, 1284, 1285, 1286, 1294, 1295, 1296, 1297, 1305, 1306, 1307, 1308, 1316, 1317, 1318, 1319, 1327, 1328, 1329, 1330}}, - {Frustum3({1.3, -5.9, 3.5}, {0.2, 0.4, 1}, M_PI / 3.), + {Frustum3({1.3, -5.9, 3.5}, {0.2, 0.4, 1}, std::numbers::pi / 3.), {318, 426, 427, 428, 438, 439, 450, 538, 546, 547, 548, 549, 558, 559, 560, 570, 571, 582, 655, 656, 657, 658, 659, 667, 668, 669, 670, 678, 679, 680, 681, 690, 691, @@ -922,7 +923,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // helper.clear(); // os = tmp("frust3d-4s_dir.ply"); - // double angle = M_PI / 4.; + // double angle = std::numbers::pi / 4.; // for (std::size_t i = 0; i <= s; i++) { // for (std::size_t j = 0; j <= s; j++) { // for (std::size_t k = 0; k <= s; k++) { @@ -931,11 +932,14 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // ActsVector dir(1, 0, 0); // Eigen::Affine3f rot; - // rot = Eigen::AngleAxisf(M_PI / static_cast(s) * i, + // rot = Eigen::AngleAxisf(std::numbers::pi / + // static_cast(s) * i, // ActsVector::UnitX()) - //* Eigen::AngleAxisf(M_PI / static_cast(s) * j, + //* Eigen::AngleAxisf(std::numbers::pi / static_cast(s) * + // j, // ActsVector::UnitY()) - //* Eigen::AngleAxisf(M_PI / static_cast(s) * k, + //* Eigen::AngleAxisf(std::numbers::pi / static_cast(s) * + // k, // ActsVector::UnitZ()); // Frustum34 fr(origin, rot * dir, angle); @@ -953,12 +957,12 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // for (std::size_t i = 0; i <= n; i++) { // ActsVector origin(i * 4, 0, 0); // Eigen::Affine3f rot; - // rot = Eigen::AngleAxisf(M_PI / static_cast(n) * i, + // rot = Eigen::AngleAxisf(std::numbers::pi / + // static_cast(n) * i, // ActsVector::UnitY()); - // angle = (M_PI / 2.) / static_cast(n) * (1 + i); - // ActsVector dir(1, 0, 0); - // Frustum34 fr(origin, rot * dir, angle); - // fr.draw(helper, 2); + // angle = (std::numbers::pi / 2.) / static_cast(n) * (1 + // + i); ActsVector dir(1, 0, 0); Frustum34 fr(origin, + // rot * dir, angle); fr.draw(helper, 2); //} // os << helper << std::flush; @@ -970,7 +974,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { std::vector>> fr_exp; fr_exp = { - {Frustum34({0, 0, 0}, {1, 0, 0}, M_PI / 2.), + {Frustum34({0, 0, 0}, {1, 0, 0}, std::numbers::pi / 2.), {665, 774, 775, 776, 785, 786, 787, 796, 797, 798, 883, 884, 885, 886, 887, 894, 895, 896, 897, 898, 905, 906, 907, 908, 909, 916, 917, 918, 919, 920, 927, 928, 929, @@ -997,7 +1001,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330}}, - {Frustum34({0, 0, 0}, {0, 1, 0}, M_PI / 2.), + {Frustum34({0, 0, 0}, {0, 1, 0}, std::numbers::pi / 2.), {110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 221, 222, 223, 224, 225, 226, 227, 228, 229, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 332, 333, @@ -1024,7 +1028,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1087, 1088, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330}}, - {Frustum34({0, 0, 0}, {0, 0, 1}, M_PI / 2.), + {Frustum34({0, 0, 0}, {0, 0, 1}, std::numbers::pi / 2.), {10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 141, 142, 152, 153, 163, 164, 174, 175, 185, 186, 196, 197, 207, 208, 218, 219, 229, 230, 241, 252, 262, @@ -1051,15 +1055,15 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1077, 1088, 1099, 1109, 1110, 1120, 1121, 1131, 1132, 1142, 1143, 1153, 1154, 1164, 1165, 1175, 1176, 1186, 1187, 1197, 1198, 1209, 1220, 1231, 1242, 1253, 1264, 1275, 1286, 1297, 1308, 1319, 1330}}, - {Frustum34({0, 0, 0}, {0, 0, 1}, M_PI / 4.), + {Frustum34({0, 0, 0}, {0, 0, 1}, std::numbers::pi / 4.), {406, 417, 428, 439, 450, 527, 535, 536, 537, 538, 546, 547, 548, 549, 557, 558, 559, 560, 571, 648, 656, 657, 658, 659, 665, 666, 667, 668, 669, 670, 678, 679, 680, 681, 692, 769, 777, 778, 779, 780, 788, 789, 790, 791, 799, 800, 801, 802, 813, 890, 901, 912, 923, 934}}, - {Frustum34({0, 0, 0}, {0, 0, 1}, M_PI / 8.), + {Frustum34({0, 0, 0}, {0, 0, 1}, std::numbers::pi / 8.), {538, 549, 560, 659, 665, 666, 667, 668, 669, 670, 681, 780, 791, 802}}, - {Frustum34({0, 0, 0}, {0, 0, 1}, M_PI * 3. / 4.), + {Frustum34({0, 0, 0}, {0, 0, 1}, std::numbers::pi * 3. / 4.), {7, 8, 9, 10, 18, 19, 20, 21, 29, 30, 31, 32, 40, 41, 42, 43, 51, 52, 53, 54, 62, 63, 64, 65, 73, 74, 75, 76, 84, 85, 86, 87, 95, @@ -1107,7 +1111,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { 1263, 1264, 1272, 1273, 1274, 1275, 1283, 1284, 1285, 1286, 1294, 1295, 1296, 1297, 1305, 1306, 1307, 1308, 1316, 1317, 1318, 1319, 1327, 1328, 1329, 1330}}, - {Frustum34({1.3, -5.9, 3.5}, {0.2, 0.4, 1}, M_PI / 3.), + {Frustum34({1.3, -5.9, 3.5}, {0.2, 0.4, 1}, std::numbers::pi / 3.), {461, 472, 537, 538, 548, 549, 558, 559, 560, 569, 570, 571, 581, 582, 593, 655, 656, 657, 658, 659, 666, 667, 668, 669, 670, 678, 679, 680, 681, 690, 691, 692, 702, @@ -1179,7 +1183,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { PlyVisualization3D ply; - Frustum fr({0, 0, 0}, {0, 0, 1}, M_PI / 8.); + Frustum fr({0, 0, 0}, {0, 0, 1}, std::numbers::pi / 8.); fr.draw(ply, 10); Box bb(&o, {0, 0, 10}, size); @@ -1202,7 +1206,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { PlyVisualization3D ply; - // Frustum fr({0, 0, 0}, {0, 0, 1}, M_PI/8.); + // Frustum fr({0, 0, 0}, {0, 0, 1}, std::numbers::pi/8.); vec3 pos = {-12.4205, 29.3578, 44.6207}; vec3 dir = {-0.656862, 0.48138, 0.58035}; Frustum fr(pos, dir, 0.972419); diff --git a/Tests/UnitTests/Core/Utilities/FrustumTest.cpp b/Tests/UnitTests/Core/Utilities/FrustumTest.cpp index 7b7221abfa0..52b713349a9 100644 --- a/Tests/UnitTests/Core/Utilities/FrustumTest.cpp +++ b/Tests/UnitTests/Core/Utilities/FrustumTest.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -28,7 +29,7 @@ BOOST_AUTO_TEST_CASE(frustum_construction) { using Vector2F = Eigen::Matrix; using Frustum2f2 = Frustum; - Frustum2f2 fr({1, 0}, {0, 2}, M_PI / 2.); + Frustum2f2 fr({1, 0}, {0, 2}, std::numbers::pi / 2.); BOOST_CHECK_EQUAL(fr.origin(), Vector2F(1, 0)); CHECK_CLOSE_ABS(fr.dir(), Vector2F(0, 1), 1e-6); @@ -42,7 +43,7 @@ BOOST_AUTO_TEST_CASE(frustum_construction) { using Vector3F = Eigen::Matrix; using Frustum3f3 = Frustum; - Frustum3f3 fr33({1, 0, 0}, {0, 2, 1}, M_PI / 2.); + Frustum3f3 fr33({1, 0, 0}, {0, 2, 1}, std::numbers::pi / 2.); BOOST_CHECK_EQUAL(fr33.origin(), Vector3F(1, 0, 0)); CHECK_CLOSE_ABS(fr33.dir(), Vector3F(0, 2, 1).normalized(), 1e-6); @@ -55,7 +56,7 @@ BOOST_AUTO_TEST_CASE(frustum_construction) { // fr33.draw(hlp); using Frustum3f4 = Frustum; - Frustum3f4 fr34({1, 0, 0}, {0, 2, 1}, M_PI / 2.); + Frustum3f4 fr34({1, 0, 0}, {0, 2, 1}, std::numbers::pi / 2.); BOOST_CHECK_EQUAL(fr34.origin(), Vector3F(1, 0, 0)); CHECK_CLOSE_ABS(fr34.dir(), Vector3F(0, 2, 1).normalized(), 1e-6); diff --git a/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp b/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp index a7f3eefdeba..4cfb0ea6088 100644 --- a/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp +++ b/Tests/UnitTests/Core/Utilities/GridAxisGeneratorsTests.cpp @@ -15,6 +15,7 @@ #include "Acts/Utilities/GridAxisGenerators.hpp" #include +#include #include #include @@ -48,7 +49,7 @@ BOOST_AUTO_TEST_CASE(Eq1D) { } BOOST_AUTO_TEST_CASE(EqEq2D) { - EqOpenEqClosed eoec{{0, 10}, 10u, {-M_PI, M_PI}, 16u}; + EqOpenEqClosed eoec{{0, 10}, 10u, {-std::numbers::pi, std::numbers::pi}, 16u}; auto axisTuple = eoec(); BOOST_CHECK_EQUAL(std::tuple_size{}, 2u); auto axisVar = std::get<0u>(axisTuple); @@ -76,7 +77,8 @@ BOOST_AUTO_TEST_CASE(EqVar2D) { } BOOST_AUTO_TEST_CASE(VarEq2D) { - VarBoundEqClosed vbec{{10., 20, 30, 40}, {-M_PI, M_PI}, 12u}; + VarBoundEqClosed vbec{ + {10., 20, 30, 40}, {-std::numbers::pi, std::numbers::pi}, 12u}; auto axisTuple = vbec(); BOOST_CHECK_EQUAL(std::tuple_size{}, 2u); auto axisVar = std::get<0u>(axisTuple); diff --git a/Tests/UnitTests/Core/Utilities/HelpersTests.cpp b/Tests/UnitTests/Core/Utilities/HelpersTests.cpp index 68f173db492..85e8454d052 100644 --- a/Tests/UnitTests/Core/Utilities/HelpersTests.cpp +++ b/Tests/UnitTests/Core/Utilities/HelpersTests.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -55,7 +56,7 @@ struct MyStruct { BOOST_AUTO_TEST_CASE(phi_helper_test) { Vector3 v(0, 1, 0); - CHECK_CLOSE_ABS(phi(v), M_PI / 2., 1e-9); + CHECK_CLOSE_ABS(phi(v), std::numbers::pi / 2., 1e-9); MyStruct s; BOOST_CHECK_EQUAL(phi(s), 42u); @@ -227,7 +228,7 @@ BOOST_AUTO_TEST_CASE(incidentAnglesTest) { Vector3 dir = Vector3::Zero(); dir[i] = 1; std::pair angles = incidentAngles(dir, ref); - double expect = (i < 2) ? 0 : M_PI_2; + double expect = (i < 2) ? 0 : std::numbers::pi / 2.; CHECK_CLOSE_ABS(angles.first, expect, std::numeric_limits::epsilon()); CHECK_CLOSE_ABS(angles.second, expect, @@ -238,62 +239,74 @@ BOOST_AUTO_TEST_CASE(incidentAnglesTest) { { Vector3 dir = Vector3({1, 1, 1}).normalized(); auto [a0, a1] = incidentAngles(dir, ref); - CHECK_CLOSE_ABS(a0, M_PI_4, std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(a1, M_PI_4, std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a0, std::numbers::pi / 4., + std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a1, std::numbers::pi / 4., + std::numeric_limits::epsilon()); } // 45 degree on first axis { Vector3 dir = Vector3({1, 0, 1}).normalized(); auto [a0, a1] = incidentAngles(dir, ref); - CHECK_CLOSE_ABS(a0, M_PI_4, std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(a1, M_PI_2, std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a0, std::numbers::pi / 4., + std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a1, std::numbers::pi / 2., + std::numeric_limits::epsilon()); } // 45 degree on second axis { Vector3 dir = Vector3({0, 1, 1}).normalized(); auto [a0, a1] = incidentAngles(dir, ref); - CHECK_CLOSE_ABS(a0, M_PI_2, std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(a1, M_PI_4, std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a0, std::numbers::pi / 2., + std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a1, std::numbers::pi / 4., + std::numeric_limits::epsilon()); } // Reverse crossing { Vector3 dir = {0, 0, -1}; auto [a0, a1] = incidentAngles(dir, ref); - CHECK_CLOSE_ABS(a0, -M_PI_2, std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(a1, -M_PI_2, std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a0, -std::numbers::pi / 2., + std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a1, -std::numbers::pi / 2., + std::numeric_limits::epsilon()); } // 45 degree but different quadrant { Vector3 dir = {-1, -1, 1}; auto [a0, a1] = incidentAngles(dir, ref); - CHECK_CLOSE_ABS(a0, 3 * M_PI_4, std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(a1, 3 * M_PI_4, std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a0, 3 * std::numbers::pi / 4., + std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a1, 3 * std::numbers::pi / 4., + std::numeric_limits::epsilon()); } // 45 degree but different quadrant & other side { Vector3 dir = {-1, -1, -1}; auto [a0, a1] = incidentAngles(dir, ref); - CHECK_CLOSE_ABS(a0, -3 * M_PI_4, + CHECK_CLOSE_ABS(a0, -3 * std::numbers::pi / 4., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(a1, -3 * M_PI_4, + CHECK_CLOSE_ABS(a1, -3 * std::numbers::pi / 4., std::numeric_limits::epsilon()); } // Rotate the reference frame instead { - double s45 = std::sin(M_PI_4); - double c45 = std::cos(M_PI_4); + double s45 = std::sin(std::numbers::pi / 4.); + double c45 = std::cos(std::numbers::pi / 4.); RotationMatrix3 ref45; ref45 << c45, 0, s45, 0, 1, 0, -s45, 0, c45; Vector3 dir = {0, 0, 1}; auto [a0, a1] = incidentAngles(dir, ref45); - CHECK_CLOSE_ABS(a0, M_PI_4, std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(a1, M_PI_2, std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a0, std::numbers::pi / 4., + std::numeric_limits::epsilon()); + CHECK_CLOSE_ABS(a1, std::numbers::pi / 2., + std::numeric_limits::epsilon()); } } diff --git a/Tests/UnitTests/Core/Utilities/PeriodicTests.cpp b/Tests/UnitTests/Core/Utilities/PeriodicTests.cpp index da575ce2a83..a6f66328689 100644 --- a/Tests/UnitTests/Core/Utilities/PeriodicTests.cpp +++ b/Tests/UnitTests/Core/Utilities/PeriodicTests.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -51,9 +52,10 @@ constexpr std::tuple {0.75, 5.25, 2.0, -0.5}, {1.25, -2.5, 2.0, -0.25}, // one of lhs,rhs is over the edge and close together - {-0.25, +0.25, 2 * M_PI, -0.5}, - {+0.25, -0.25, 2 * M_PI, +0.5}, - {2 * M_PI - 0.25, 2 * M_PI + 0.25, 2 * M_PI, -0.5}, + {-0.25, +0.25, 2 * std::numbers::pi, -0.5}, + {+0.25, -0.25, 2 * std::numbers::pi, +0.5}, + {2 * std::numbers::pi - 0.25, 2 * std::numbers::pi + 0.25, + 2 * std::numbers::pi, -0.5}, }; } // namespace BOOST_DATA_TEST_CASE(DifferencePeriodic, bd::make(kDifferencePeriodicDataset), @@ -62,29 +64,38 @@ BOOST_DATA_TEST_CASE(DifferencePeriodic, bd::make(kDifferencePeriodicDataset), CHECK_CLOSE_ABS(difference_periodic(rhs, lhs, range), -diff, tol); } -BOOST_DATA_TEST_CASE(RadianPos, bd::xrange(0.25, M_PI, 0.5), delta) { +BOOST_DATA_TEST_CASE(RadianPos, bd::xrange(0.25, std::numbers::pi, 0.5), + delta) { // above upper limit folds back just above lower limit - CHECK_CLOSE_ABS(radian_pos(0 - delta), 2 * M_PI - delta, tol); + CHECK_CLOSE_ABS(radian_pos(0 - delta), 2 * std::numbers::pi - delta, tol); // below lower limit folds back just below upper limit - CHECK_CLOSE_ABS(radian_pos(2 * M_PI + delta), delta, tol); + CHECK_CLOSE_ABS(radian_pos(2 * std::numbers::pi + delta), delta, tol); // same as above but with additional 2pi shifts - CHECK_CLOSE_ABS(radian_pos(-2 * M_PI - delta), 2 * M_PI - delta, tol); - CHECK_CLOSE_ABS(radian_pos(4 * M_PI + delta), delta, tol); + CHECK_CLOSE_ABS(radian_pos(-2 * std::numbers::pi - delta), + 2 * std::numbers::pi - delta, tol); + CHECK_CLOSE_ABS(radian_pos(4 * std::numbers::pi + delta), delta, tol); } -BOOST_DATA_TEST_CASE(RadianSym, bd::xrange(0.25, M_PI, 0.5), delta) { +BOOST_DATA_TEST_CASE(RadianSym, bd::xrange(0.25, std::numbers::pi, 0.5), + delta) { // above upper limit folds back just above lower limit - CHECK_CLOSE_ABS(radian_sym(-M_PI - delta), M_PI - delta, tol); + CHECK_CLOSE_ABS(radian_sym(-std::numbers::pi - delta), + std::numbers::pi - delta, tol); // below lower limit folds back just below upper limit - CHECK_CLOSE_ABS(radian_sym(M_PI + delta), -M_PI + delta, tol); + CHECK_CLOSE_ABS(radian_sym(std::numbers::pi + delta), + -std::numbers::pi + delta, tol); // same as above but with additional 2pi shifts - CHECK_CLOSE_ABS(radian_sym(-M_PI - delta - 2 * M_PI), M_PI - delta, tol); - CHECK_CLOSE_ABS(radian_sym(M_PI + delta + 2 * M_PI), -M_PI + delta, tol); + CHECK_CLOSE_ABS(radian_sym(-std::numbers::pi - delta - 2 * std::numbers::pi), + std::numbers::pi - delta, tol); + CHECK_CLOSE_ABS(radian_sym(std::numbers::pi + delta + 2 * std::numbers::pi), + -std::numbers::pi + delta, tol); } BOOST_DATA_TEST_CASE(NormalizePhiThetaInBounds, - bd::xrange(-M_PI, M_PI, M_PI_2) * - bd::xrange(0.0, M_PI, M_PI_4), + bd::xrange(-std::numbers::pi, std::numbers::pi, + std::numbers::pi / 2.) * + bd::xrange(0., std::numbers::pi, + std::numbers::pi / 4.), phix, thetax) { // both phi and theta are in bounds and should remain unchanged auto [phi, theta] = normalizePhiTheta(phix, thetax); @@ -93,38 +104,41 @@ BOOST_DATA_TEST_CASE(NormalizePhiThetaInBounds, } BOOST_DATA_TEST_CASE(NormalizePhiThetaCyclicPhi, - bd::xrange(0.25, M_PI, 0.5) * - bd::xrange(0.0, M_PI, M_PI_4), + bd::xrange(0.25, std::numbers::pi, 0.5) * + bd::xrange(0., std::numbers::pi, + std::numbers::pi / 4.), deltaPhi, thetax) { // phi is outside bounds, but theta is within and should remain unchanged { // phi is too large - auto [phi, theta] = normalizePhiTheta(M_PI + deltaPhi, thetax); - CHECK_CLOSE_ABS(phi, -M_PI + deltaPhi, tol); + auto [phi, theta] = normalizePhiTheta(std::numbers::pi + deltaPhi, thetax); + CHECK_CLOSE_ABS(phi, -std::numbers::pi + deltaPhi, tol); CHECK_CLOSE_ABS(theta, thetax, tol); } { // phi is too small - auto [phi, theta] = normalizePhiTheta(-M_PI - deltaPhi, thetax); - CHECK_CLOSE_ABS(phi, M_PI - deltaPhi, tol); + auto [phi, theta] = normalizePhiTheta(-std::numbers::pi - deltaPhi, thetax); + CHECK_CLOSE_ABS(phi, std::numbers::pi - deltaPhi, tol); CHECK_CLOSE_ABS(theta, thetax, tol); } } BOOST_DATA_TEST_CASE(NormalizePhiThetaOutOfBoundsTheta, - bd::xrange(0.0, M_PI, 1.0) * bd::xrange(0.25, M_PI, 1.0), + bd::xrange(0., std::numbers::pi, 1.) * + bd::xrange(0.25, std::numbers::pi, 1.), positivePhi, deltaTheta) { // theta is outside bounds, both phi and theta are updated { // theta is too large - auto [phi, theta] = normalizePhiTheta(positivePhi, M_PI + deltaTheta); - CHECK_CLOSE_ABS(phi, -M_PI + positivePhi, tol); - CHECK_CLOSE_ABS(theta, M_PI - deltaTheta, tol); + auto [phi, theta] = + normalizePhiTheta(positivePhi, std::numbers::pi + deltaTheta); + CHECK_CLOSE_ABS(phi, -std::numbers::pi + positivePhi, tol); + CHECK_CLOSE_ABS(theta, std::numbers::pi - deltaTheta, tol); } { // theta is too small - auto [phi, theta] = normalizePhiTheta(positivePhi, 0.0 - deltaTheta); - CHECK_CLOSE_ABS(phi, -M_PI + positivePhi, tol); + auto [phi, theta] = normalizePhiTheta(positivePhi, 0. - deltaTheta); + CHECK_CLOSE_ABS(phi, -std::numbers::pi + positivePhi, tol); CHECK_CLOSE_ABS(theta, deltaTheta, tol); } } diff --git a/Tests/UnitTests/Core/Utilities/UnitVectorsTests.cpp b/Tests/UnitTests/Core/Utilities/UnitVectorsTests.cpp index 7fc467d1971..150479a02b5 100644 --- a/Tests/UnitTests/Core/Utilities/UnitVectorsTests.cpp +++ b/Tests/UnitTests/Core/Utilities/UnitVectorsTests.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using Acts::Vector3; @@ -31,28 +32,28 @@ BOOST_AUTO_TEST_CASE(DirectionPhiEta) { const auto xPos1 = makeDirectionFromPhiEta(0.0, 0.0); CHECK_CLOSE_REL(xPos1.norm(), 1, eps); CHECK_CLOSE_REL(xPos1.dot(Vector3(1, 0, 0)), 1, eps); - const auto xPos2 = makeDirectionFromPhiEta(2 * M_PI, 0.0); + const auto xPos2 = makeDirectionFromPhiEta(2 * std::numbers::pi, 0.); CHECK_CLOSE_REL(xPos2.norm(), 1, eps); CHECK_CLOSE_REL(xPos2.dot(Vector3(1, 0, 0)), 1, eps); // along negative x - const auto xNeg1 = makeDirectionFromPhiEta(M_PI, 0.0); + const auto xNeg1 = makeDirectionFromPhiEta(std::numbers::pi, 0.); CHECK_CLOSE_REL(xNeg1.norm(), 1, eps); CHECK_CLOSE_REL(xNeg1.dot(Vector3(-1, 0, 0)), 1, eps); - const auto xNeg2 = makeDirectionFromPhiEta(-M_PI, 0.0); + const auto xNeg2 = makeDirectionFromPhiEta(-std::numbers::pi, 0.); CHECK_CLOSE_REL(xNeg2.norm(), 1, eps); CHECK_CLOSE_REL(xNeg2.dot(Vector3(-1, 0, 0)), 1, eps); // along positive y - const auto yPos1 = makeDirectionFromPhiEta(M_PI_2, 0.0); + const auto yPos1 = makeDirectionFromPhiEta(std::numbers::pi / 2., 0.); CHECK_CLOSE_REL(yPos1.norm(), 1, eps); CHECK_CLOSE_REL(yPos1.dot(Vector3(0, 1, 0)), 1, eps); - const auto yPos2 = makeDirectionFromPhiEta(-3 * M_PI_2, 0.0); + const auto yPos2 = makeDirectionFromPhiEta(-3 * std::numbers::pi / 2., 0.); CHECK_CLOSE_REL(yPos2.norm(), 1, eps); CHECK_CLOSE_REL(yPos2.dot(Vector3(0, 1, 0)), 1, eps); // along negative y - const auto yNeg1 = makeDirectionFromPhiEta(-M_PI_2, 0.0); + const auto yNeg1 = makeDirectionFromPhiEta(-std::numbers::pi / 2., 0.); CHECK_CLOSE_REL(yNeg1.norm(), 1, eps); CHECK_CLOSE_REL(yNeg1.dot(Vector3(0, -1, 0)), 1, eps); - const auto yNeg2 = makeDirectionFromPhiEta(3 * M_PI_2, 0.0); + const auto yNeg2 = makeDirectionFromPhiEta(3 * std::numbers::pi / 2., 0.); CHECK_CLOSE_REL(yNeg2.norm(), 1, eps); CHECK_CLOSE_REL(yNeg2.dot(Vector3(0, -1, 0)), 1, eps); @@ -61,63 +62,74 @@ BOOST_AUTO_TEST_CASE(DirectionPhiEta) { const auto zPos1 = makeDirectionFromPhiEta(0.0, inf); CHECK_CLOSE_REL(zPos1.norm(), 1, eps); CHECK_CLOSE_REL(zPos1.dot(Vector3(0, 0, 1)), 1, eps); - const auto zPos2 = makeDirectionFromPhiEta(M_PI_2, inf); + const auto zPos2 = makeDirectionFromPhiEta(std::numbers::pi / 2., inf); CHECK_CLOSE_REL(zPos2.norm(), 1, eps); CHECK_CLOSE_REL(zPos2.dot(Vector3(0, 0, 1)), 1, eps); // along negative z const auto zNeg1 = makeDirectionFromPhiEta(0.0, -inf); CHECK_CLOSE_REL(zNeg1.norm(), 1, eps); CHECK_CLOSE_REL(zNeg1.dot(Vector3(0, 0, -1)), 1, eps); - const auto zNeg2 = makeDirectionFromPhiEta(M_PI_2, -inf); + const auto zNeg2 = makeDirectionFromPhiEta(std::numbers::pi / 2., -inf); CHECK_CLOSE_REL(zNeg2.norm(), 1, eps); CHECK_CLOSE_REL(zNeg2.dot(Vector3(0, 0, -1)), 1, eps); // mixed direction - const auto mixed1 = makeDirectionFromPhiEta(M_PI_4, 1.0); + const auto mixed1 = makeDirectionFromPhiEta(std::numbers::pi / 4., 1.); CHECK_CLOSE_REL(mixed1.norm(), 1, eps); CHECK_CLOSE_REL( - mixed1.dot(Vector3(1, 1, M_SQRT2 * std::sinh(1.0)).normalized()), 1, eps); - const auto mixed2 = makeDirectionFromPhiEta(M_PI_4, -1.0); + mixed1.dot( + Vector3(1, 1, std::numbers::sqrt2 * std::sinh(1.0)).normalized()), + 1, eps); + const auto mixed2 = makeDirectionFromPhiEta(std::numbers::pi / 4., -1.); CHECK_CLOSE_REL(mixed2.norm(), 1, eps); CHECK_CLOSE_REL( - mixed2.dot(Vector3(1, 1, M_SQRT2 * std::sinh(-1.0)).normalized()), 1, - eps); - const auto mixed3 = makeDirectionFromPhiEta(-M_PI_4, -1.0); + mixed2.dot( + Vector3(1, 1, std::numbers::sqrt2 * std::sinh(-1.0)).normalized()), + 1, eps); + const auto mixed3 = makeDirectionFromPhiEta(-std::numbers::pi / 4., -1.); CHECK_CLOSE_REL(mixed3.norm(), 1, eps); CHECK_CLOSE_REL( - mixed3.dot(Vector3(1, -1, M_SQRT2 * std::sinh(-1.0)).normalized()), 1, - eps); + mixed3.dot( + Vector3(1, -1, std::numbers::sqrt2 * std::sinh(-1.)).normalized()), + 1, eps); } BOOST_AUTO_TEST_CASE(DirectionPhiTheta) { using Acts::makeDirectionFromPhiTheta; // along positive x - const auto xPos1 = makeDirectionFromPhiTheta(0.0, M_PI_2); + const auto xPos1 = makeDirectionFromPhiTheta(0., std::numbers::pi / 2.); CHECK_CLOSE_REL(xPos1.norm(), 1, eps); CHECK_CLOSE_REL(xPos1.dot(Vector3(1, 0, 0)), 1, eps); - const auto xPos2 = makeDirectionFromPhiTheta(2 * M_PI, M_PI_2); + const auto xPos2 = + makeDirectionFromPhiTheta(2 * std::numbers::pi, std::numbers::pi / 2.); CHECK_CLOSE_REL(xPos2.norm(), 1, eps); CHECK_CLOSE_REL(xPos2.dot(Vector3(1, 0, 0)), 1, eps); // along negative x - const auto xNeg1 = makeDirectionFromPhiTheta(M_PI, M_PI_2); + const auto xNeg1 = + makeDirectionFromPhiTheta(std::numbers::pi, std::numbers::pi / 2.); CHECK_CLOSE_REL(xNeg1.norm(), 1, eps); CHECK_CLOSE_REL(xNeg1.dot(Vector3(-1, 0, 0)), 1, eps); - const auto xNeg2 = makeDirectionFromPhiTheta(-M_PI, M_PI_2); + const auto xNeg2 = + makeDirectionFromPhiTheta(-std::numbers::pi, std::numbers::pi / 2.); CHECK_CLOSE_REL(xNeg2.norm(), 1, eps); CHECK_CLOSE_REL(xNeg2.dot(Vector3(-1, 0, 0)), 1, eps); // along positive y - const auto yPos1 = makeDirectionFromPhiTheta(M_PI_2, M_PI_2); + const auto yPos1 = + makeDirectionFromPhiTheta(std::numbers::pi / 2., std::numbers::pi / 2.); CHECK_CLOSE_REL(yPos1.norm(), 1, eps); CHECK_CLOSE_REL(yPos1.dot(Vector3(0, 1, 0)), 1, eps); - const auto yPos2 = makeDirectionFromPhiTheta(-3 * M_PI_2, M_PI_2); + const auto yPos2 = makeDirectionFromPhiTheta(-3 * std::numbers::pi / 2., + std::numbers::pi / 2.); CHECK_CLOSE_REL(yPos2.norm(), 1, eps); CHECK_CLOSE_REL(yPos2.dot(Vector3(0, 1, 0)), 1, eps); // along negative y - const auto yNeg1 = makeDirectionFromPhiTheta(-M_PI_2, M_PI_2); + const auto yNeg1 = + makeDirectionFromPhiTheta(-std::numbers::pi / 2., std::numbers::pi / 2.); CHECK_CLOSE_REL(yNeg1.norm(), 1, eps); CHECK_CLOSE_REL(yNeg1.dot(Vector3(0, -1, 0)), 1, eps); - const auto yNeg2 = makeDirectionFromPhiTheta(3 * M_PI_2, M_PI_2); + const auto yNeg2 = makeDirectionFromPhiTheta(3 * std::numbers::pi / 2., + std::numbers::pi / 2.); CHECK_CLOSE_REL(yNeg2.norm(), 1, eps); CHECK_CLOSE_REL(yNeg2.dot(Vector3(0, -1, 0)), 1, eps); @@ -125,27 +137,34 @@ BOOST_AUTO_TEST_CASE(DirectionPhiTheta) { const auto zPos1 = makeDirectionFromPhiTheta(0.0, 0.0); CHECK_CLOSE_REL(zPos1.norm(), 1, eps); CHECK_CLOSE_REL(zPos1.dot(Vector3(0, 0, 1)), 1, eps); - const auto zPos2 = makeDirectionFromPhiTheta(M_PI_2, 0.0); + const auto zPos2 = makeDirectionFromPhiTheta(std::numbers::pi / 2., 0.); CHECK_CLOSE_REL(zPos2.norm(), 1, eps); CHECK_CLOSE_REL(zPos2.dot(Vector3(0, 0, 1)), 1, eps); // along negative z - const auto zNeg1 = makeDirectionFromPhiTheta(0.0, M_PI); + const auto zNeg1 = makeDirectionFromPhiTheta(0., std::numbers::pi); CHECK_CLOSE_REL(zNeg1.norm(), 1, eps); CHECK_CLOSE_REL(zNeg1.dot(Vector3(0, 0, -1)), 1, eps); - const auto zNeg2 = makeDirectionFromPhiTheta(M_PI_2, M_PI); + const auto zNeg2 = + makeDirectionFromPhiTheta(std::numbers::pi / 2., std::numbers::pi); CHECK_CLOSE_REL(zNeg2.norm(), 1, eps); CHECK_CLOSE_REL(zNeg2.dot(Vector3(0, 0, -1)), 1, eps); // mixed direction - const auto mixed1 = makeDirectionFromPhiTheta(M_PI_4, M_PI_4); + const auto mixed1 = + makeDirectionFromPhiTheta(std::numbers::pi / 4., std::numbers::pi / 4.); CHECK_CLOSE_REL(mixed1.norm(), 1, eps); - CHECK_CLOSE_REL(mixed1.dot(Vector3(1, 1, M_SQRT2).normalized()), 1, eps); - const auto mixed2 = makeDirectionFromPhiTheta(M_PI_4, 3 * M_PI_4); + CHECK_CLOSE_REL(mixed1.dot(Vector3(1, 1, std::numbers::sqrt2).normalized()), + 1, eps); + const auto mixed2 = makeDirectionFromPhiTheta(std::numbers::pi / 4., + 3 * std::numbers::pi / 4.); CHECK_CLOSE_REL(mixed2.norm(), 1, eps); - CHECK_CLOSE_REL(mixed2.dot(Vector3(1, 1, -M_SQRT2).normalized()), 1, eps); - const auto mixed3 = makeDirectionFromPhiTheta(-M_PI_4, 3 * M_PI_4); + CHECK_CLOSE_REL(mixed2.dot(Vector3(1, 1, -std::numbers::sqrt2).normalized()), + 1, eps); + const auto mixed3 = makeDirectionFromPhiTheta(-std::numbers::pi / 4., + 3 * std::numbers::pi / 4.); CHECK_CLOSE_REL(mixed3.norm(), 1, eps); - CHECK_CLOSE_REL(mixed3.dot(Vector3(1, -1, -M_SQRT2).normalized()), 1, eps); + CHECK_CLOSE_REL(mixed3.dot(Vector3(1, -1, -std::numbers::sqrt2).normalized()), + 1, eps); } namespace { diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveGridTrackDensityTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveGridTrackDensityTests.cpp index 89d5385c125..337ca19a9e6 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveGridTrackDensityTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveGridTrackDensityTests.cpp @@ -19,6 +19,7 @@ #include "Acts/Vertexing/AdaptiveGridTrackDensity.hpp" #include +#include #include #include @@ -105,8 +106,8 @@ BOOST_AUTO_TEST_CASE(compare_to_analytical_solution_for_single_track) { // https://en.wikipedia.org/wiki/Full_width_at_half_maximum#Normal_distribution // but the calculation needs to be slightly modified in our case) double correctFWHM = - 2. * - std::sqrt(2 * std::log(2.) * subCovMat.determinant() / subCovMat(0, 0)); + 2. * std::sqrt(2 * std::numbers::ln2 * subCovMat.determinant() / + subCovMat(0, 0)); // Estimate maximum z position and seed width auto res = grid.getMaxZTPositionAndWidth(mainDensityMap); @@ -210,7 +211,8 @@ BOOST_AUTO_TEST_CASE( ActsScalar correctMaxT = tNom / denom * d0 + t0; // Analytical FWHM of the Gaussian - ActsScalar correctFWHM = 2. * std::sqrt(2 * std::log(2.) / ipWeights(1, 1)); + ActsScalar correctFWHM = + 2. * std::sqrt(2 * std::numbers::ln2 / ipWeights(1, 1)); // Estimate maximum z position and seed width auto res = grid.getMaxZTPositionAndWidth(mainDensityMap); diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp index bbb5caa7111..0b6c5982067 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -85,7 +86,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); ImpactPointEstimator ipEstimator(ipEstimatorCfg); - std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; + std::vector temperatures{ + 8., 4., 2., std::numbers::sqrt2, std::sqrt(3. / 2.), 1.}; AnnealingUtility::Config annealingConfig; annealingConfig.setOfTemperatures = temperatures; AnnealingUtility annealingUtility(annealingConfig); @@ -243,7 +245,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_usertype_test) { ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); ImpactPointEstimator ipEstimator(ipEstimatorCfg); - std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; + std::vector temperatures{ + 8., 4., 2., std::numbers::sqrt2, std::sqrt(3. / 2.), 1.}; AnnealingUtility::Config annealingConfig; annealingConfig.setOfTemperatures = temperatures; AnnealingUtility annealingUtility(annealingConfig); @@ -386,7 +389,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_grid_seed_finder_test) { ImpactPointEstimator::Config ipEstCfg(bField, propagator); ImpactPointEstimator ipEst(ipEstCfg); - std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; + std::vector temperatures{ + 8., 4., 2., std::numbers::sqrt2, std::sqrt(3. / 2.), 1.}; AnnealingUtility::Config annealingConfig; annealingConfig.setOfTemperatures = temperatures; AnnealingUtility annealingUtility(annealingConfig); @@ -535,7 +539,8 @@ BOOST_AUTO_TEST_CASE( ImpactPointEstimator::Config ipEstCfg(bField, propagator); ImpactPointEstimator ipEst(ipEstCfg); - std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; + std::vector temperatures{ + 8., 4., 2., std::numbers::sqrt2, std::sqrt(3. / 2.), 1.}; AnnealingUtility::Config annealingConfig; annealingConfig.setOfTemperatures = temperatures; AnnealingUtility annealingUtility(annealingConfig); diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp index 15a815eb8f5..3b3acf01bfd 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -75,9 +76,10 @@ std::uniform_real_distribution z0Dist(-0.2_mm, 0.2_mm); // Track pT distribution std::uniform_real_distribution pTDist(1._GeV, 30._GeV); // Track phi distribution -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // Track theta distribution -std::uniform_real_distribution thetaDist(1.0, M_PI - 1.0); +std::uniform_real_distribution thetaDist(1., std::numbers::pi - 1.); // Track charge helper distribution std::uniform_real_distribution qDist(-1, 1); // Distribution of track time (relative to vertex time). Values are unrealistic diff --git a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp index 805081eab79..5c4deb84a38 100644 --- a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -69,9 +70,10 @@ std::uniform_real_distribution z0Dist(-0.2_mm, 0.2_mm); // pT std::uniform_real_distribution pTDist(0.4_GeV, 10_GeV); // phi -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // theta -std::uniform_real_distribution thetaDist(1.0, M_PI - 1.0); +std::uniform_real_distribution thetaDist(1., std::numbers::pi - 1.); // charge helper std::uniform_real_distribution qDist(-1, 1); // time diff --git a/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp index 8775fe1a76f..d8aa16a1c94 100644 --- a/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/GridDensityVertexFinderTests.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -60,7 +61,8 @@ std::normal_distribution z2dist(zVertexPos2 * 1_mm, 0.5_mm); // Track pT distribution std::uniform_real_distribution pTDist(0.1_GeV, 100_GeV); // Track phi distribution -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // Track eta distribution std::uniform_real_distribution etaDist(-4., 4.); diff --git a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp index 9e35453759e..37925947d28 100644 --- a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -79,9 +80,10 @@ std::uniform_real_distribution z0Dist(-0.2_mm, 0.2_mm); // Track pT distribution std::uniform_real_distribution pTDist(0.4_GeV, 10_GeV); // Track phi distribution -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // Track theta distribution -std::uniform_real_distribution thetaDist(1.0, M_PI - 1.0); +std::uniform_real_distribution thetaDist(1., std::numbers::pi - 1.); // Track charge helper distribution std::uniform_real_distribution qDist(-1, 1); // Track IP resolution distribution diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp index de89859bc51..641d48aafb5 100644 --- a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -65,9 +66,10 @@ std::uniform_real_distribution z0Dist(-0.2_mm, 0.2_mm); // Track pT distribution std::uniform_real_distribution pTDist(0.4_GeV, 10_GeV); // Track phi distribution -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // Track theta distribution -std::uniform_real_distribution thetaDist(1.0, M_PI - 1.0); +std::uniform_real_distribution thetaDist(1., std::numbers::pi - 1.); // Track charge helper distribution std::uniform_real_distribution qDist(-1, 1); // Track IP resolution distribution diff --git a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp index 99b0d6c03ac..f8e1c545373 100644 --- a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -70,9 +71,10 @@ std::uniform_real_distribution z0Dist(-0.2_mm, 0.2_mm); // Track pT distribution std::uniform_real_distribution pTDist(0.4_GeV, 10_GeV); // Track phi distribution -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // Track theta distribution -std::uniform_real_distribution thetaDist(1.0, M_PI - 1.0); +std::uniform_real_distribution thetaDist(1., std::numbers::pi - 1.); // Track charge helper distribution std::uniform_real_distribution qDist(-1, 1); // Track time distribution diff --git a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp index b45943217b7..a865a19f7ba 100644 --- a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -204,7 +205,8 @@ std::normal_distribution z2dist(-3_mm, 0.5_mm); // Track pT distribution std::uniform_real_distribution pTDist(0.1_GeV, 100_GeV); // Track phi distribution -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // Track eta distribution std::uniform_real_distribution etaDist(-4., 4.); diff --git a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp index 6fa0c81a928..01d0c033bb1 100644 --- a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -66,9 +67,10 @@ std::uniform_real_distribution z0Dist(-0.2_mm, 0.2_mm); // Track pT distribution std::uniform_real_distribution pTDist(0.4_GeV, 10_GeV); // Track phi distribution -std::uniform_real_distribution phiDist(-M_PI, M_PI); +std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); // Track theta distribution -std::uniform_real_distribution thetaDist(1.0, M_PI - 1.0); +std::uniform_real_distribution thetaDist(1., std::numbers::pi - 1.); // Track charge helper distribution std::uniform_real_distribution qDist(-1, 1); // Track IP resolution distribution diff --git a/Tests/UnitTests/Core/Visualization/PrimitivesView3DTests.cpp b/Tests/UnitTests/Core/Visualization/PrimitivesView3DTests.cpp index 37b0abbee82..ee10409261a 100644 --- a/Tests/UnitTests/Core/Visualization/PrimitivesView3DTests.cpp +++ b/Tests/UnitTests/Core/Visualization/PrimitivesView3DTests.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,7 @@ BOOST_AUTO_TEST_CASE(Visualization3DHelpers) { decops = Acts::EventDataView3D::decomposeCovariance(covariance); BOOST_CHECK_EQUAL(decops[0], 8.); BOOST_CHECK_EQUAL(decops[1], 0.); - CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001); + CHECK_CLOSE_ABS(decops[2], std::numbers::pi / 4., 0.0001); // Fully negatively correlated covariance.setZero(); @@ -53,7 +54,7 @@ BOOST_AUTO_TEST_CASE(Visualization3DHelpers) { decops = Acts::EventDataView3D::decomposeCovariance(covariance); BOOST_CHECK_EQUAL(decops[0], 8.); BOOST_CHECK_EQUAL(decops[1], 0.); - CHECK_CLOSE_ABS(decops[2], 3 * M_PI / 4, 0.0001); + CHECK_CLOSE_ABS(decops[2], 3 * std::numbers::pi / 4., 0.0001); // Correlation coefficient 0.5 (off-diagonal: 3*2*0.5) covariance.setZero(); @@ -61,7 +62,7 @@ BOOST_AUTO_TEST_CASE(Visualization3DHelpers) { decops = Acts::EventDataView3D::decomposeCovariance(covariance); BOOST_CHECK_EQUAL(decops[0], 6.); BOOST_CHECK_EQUAL(decops[1], 2.); - CHECK_CLOSE_ABS(decops[2], M_PI / 4, 0.0001); + CHECK_CLOSE_ABS(decops[2], std::numbers::pi / 4., 0.0001); // Correlation coefficient -0.5 & different diagonal (off-diagonal: 3*2*0.5) covariance.setZero(); diff --git a/Tests/UnitTests/Core/Visualization/SurfaceView3DBase.hpp b/Tests/UnitTests/Core/Visualization/SurfaceView3DBase.hpp index 146935279f0..efbabb202a3 100644 --- a/Tests/UnitTests/Core/Visualization/SurfaceView3DBase.hpp +++ b/Tests/UnitTests/Core/Visualization/SurfaceView3DBase.hpp @@ -29,6 +29,7 @@ #include "Acts/Visualization/IVisualization3D.hpp" #include +#include #include #include @@ -47,8 +48,8 @@ static inline std::string run(IVisualization3D& helper, bool triangulate, auto identity = Transform3::Identity(); std::stringstream cStream; - double halfPhiSector = M_PI / 4.; - double centralPhi = M_PI / 2.; + const double halfPhiSector = std::numbers::pi / 4.; + const double centralPhi = std::numbers::pi / 2.; ViewConfig sConfig = s_viewSensitive; sConfig.triangulate = triangulate; diff --git a/Tests/UnitTests/Core/Visualization/VolumeView3DBase.hpp b/Tests/UnitTests/Core/Visualization/VolumeView3DBase.hpp index a485086bd5e..28620637d8d 100644 --- a/Tests/UnitTests/Core/Visualization/VolumeView3DBase.hpp +++ b/Tests/UnitTests/Core/Visualization/VolumeView3DBase.hpp @@ -18,6 +18,7 @@ #include "Acts/Visualization/IVisualization3D.hpp" #include +#include #include #include @@ -37,7 +38,7 @@ static inline std::string run(IVisualization3D& helper, bool triangulate, auto identity = Transform3::Identity(); std::stringstream cStream; - double halfPhiSector = M_PI / 4.; + const double halfPhiSector = std::numbers::pi / 4.; ViewConfig vConfig = s_viewVolume; vConfig.triangulate = triangulate; @@ -55,8 +56,8 @@ static inline std::string run(IVisualization3D& helper, bool triangulate, //---------------------------------------------------- // Cone volume section // Single solid Cone - auto solidCone = - std::make_shared(0., 0., 0.45, 5., 5., 0., M_PI); + auto solidCone = std::make_shared(0., 0., 0.45, 5., 5., 0., + std::numbers::pi); auto cone = std::make_shared(identity, solidCone); GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(), vConfig); @@ -65,8 +66,8 @@ static inline std::string run(IVisualization3D& helper, bool triangulate, helper.clear(); // Single solid Cone - with cut off - auto cutOffCone = - std::make_shared(0., 0., 0.45, 8., 5., 0., M_PI); + auto cutOffCone = std::make_shared(0., 0., 0.45, 8., 5., 0., + std::numbers::pi); cone = std::make_shared(identity, cutOffCone); GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(), vConfig); @@ -75,8 +76,8 @@ static inline std::string run(IVisualization3D& helper, bool triangulate, helper.clear(); // Cone - Cone inlay - auto cutOffHollowCone = - std::make_shared(0.35, 7., 0.45, 8., 5, 0., M_PI); + auto cutOffHollowCone = std::make_shared( + 0.35, 7., 0.45, 8., 5, 0., std::numbers::pi); cone = std::make_shared(identity, cutOffHollowCone); GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(), vConfig); @@ -95,8 +96,8 @@ static inline std::string run(IVisualization3D& helper, bool triangulate, helper.clear(); // Single Hollow Cone - cylindrical inlay - auto cutOffHollowCylCone = - std::make_shared(1., 0.45, 8., 5., 0., M_PI); + auto cutOffHollowCylCone = std::make_shared( + 1., 0.45, 8., 5., 0., std::numbers::pi); cone = std::make_shared(identity, cutOffHollowCylCone); GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(), vConfig); @@ -105,8 +106,8 @@ static inline std::string run(IVisualization3D& helper, bool triangulate, helper.clear(); // Single Hollow Cylinder - Cone inlay - auto cutOffHollowConeCyl = - std::make_shared(12., 0.35, 7., 5., 0., M_PI); + auto cutOffHollowConeCyl = std::make_shared( + 12., 0.35, 7., 5., 0., std::numbers::pi); cone = std::make_shared(identity, cutOffHollowConeCyl); GeometryView3D::drawVolume(helper, *cone, gctx, Transform3::Identity(), vConfig); diff --git a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceMaskTests.cpp b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceMaskTests.cpp index f389b50237b..f17e4432e6b 100644 --- a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceMaskTests.cpp +++ b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceMaskTests.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -81,8 +82,8 @@ BOOST_AUTO_TEST_CASE(PlaneMaskRectangleBounds) { } BOOST_AUTO_TEST_CASE(DiscMaskRadialBounds) { - auto discRadial = - std::make_shared(2., 7.5, M_PI_4, M_PI_2); + auto discRadial = std::make_shared( + 2., 7.5, std::numbers::pi / 4., std::numbers::pi / 2.); auto discSurface = Acts::Surface::makeShared( Acts::Transform3::Identity(), discRadial); @@ -117,13 +118,14 @@ BOOST_AUTO_TEST_CASE(DiscMaskRadialBounds) { /// Case four: outside phi min segment = {Acts::Vector2(2.8, 2.5), Acts::Vector2(0., 3.5)}; clipped = psm.apply(*discSurface, segment).value(); - CHECK_CLOSE_ABS(Acts::VectorHelpers::phi(clipped[0]), M_PI_4, + CHECK_CLOSE_ABS(Acts::VectorHelpers::phi(clipped[0]), std::numbers::pi / 4., Acts::s_epsilon); /// Case five: outside phi max segment = {Acts::Vector2(0., 3.5), Acts::Vector2(-8., 5.)}; clipped = psm.apply(*discSurface, segment).value(); - CHECK_CLOSE_ABS(Acts::VectorHelpers::phi(clipped[1]), M_PI_2 + M_PI_4, + CHECK_CLOSE_ABS(Acts::VectorHelpers::phi(clipped[1]), + std::numbers::pi / 2. + std::numbers::pi / 4., Acts::s_epsilon); } diff --git a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp index 467d2b9952e..42327d7e5eb 100644 --- a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp +++ b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp @@ -22,6 +22,7 @@ #include "Acts/Utilities/BinningType.hpp" #include +#include #include #include @@ -87,23 +88,28 @@ struct PlanarSurfaceTestBeds { Acts::Transform3::Identity(), discTrapezoid); Acts::BinUtility stripsPhi(1, rmin, rmax, Acts::open, Acts::BinningValue::binR); - stripsPhi += Acts::BinUtility(25, M_PI_2 - alpha, M_PI_2 + alpha, - Acts::open, Acts::BinningValue::binPhi); + stripsPhi += Acts::BinUtility(25, std::numbers::pi / 2. - alpha, + std::numbers::pi / 2. + alpha, Acts::open, + Acts::BinningValue::binPhi); TrapezoidRandom dtRandom(xmin * rScale, xmax * rScale, rmin * irScale, ymax * rScale); // Raidal disc test - auto discRadial = - std::make_shared(rmin, rmax, M_PI_4, M_PI_2); + auto discRadial = std::make_shared( + rmin, rmax, std::numbers::pi / 4., std::numbers::pi / 2.); auto dSurface = Acts::Surface::makeShared( Acts::Transform3::Identity(), discRadial); Acts::BinUtility rphiseg(10, rmin, rmax, Acts::open, Acts::BinningValue::binR); - rphiseg += Acts::BinUtility(20, (M_PI_2 - M_PI_4), (M_PI_2 + M_PI_4), - Acts::open, Acts::BinningValue::binPhi); - - DiscRandom dRandom(rmin * irScale, rmax * rScale, - (M_PI_2 - M_PI_4) * irScale, (M_PI_2 + M_PI_4) * rScale); + rphiseg += + Acts::BinUtility(20, (std::numbers::pi / 2. - std::numbers::pi / 4.), + (std::numbers::pi / 2. + std::numbers::pi / 4.), + Acts::open, Acts::BinningValue::binPhi); + + DiscRandom dRandom( + rmin * irScale, rmax * rScale, + (std::numbers::pi / 2. - std::numbers::pi / 4.) * irScale, + (std::numbers::pi / 2. + std::numbers::pi / 4.) * rScale); // Annulus disc test rmin = 2.5; diff --git a/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp b/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp index a68326ae1f7..5f2015d844f 100644 --- a/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp +++ b/Tests/UnitTests/Fatras/Physics/ScatteringTests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "Dataset.hpp" @@ -104,7 +105,7 @@ BOOST_AUTO_TEST_CASE(HighlandRms) { double rmsTheta3D = rms(theta3Ds, 0); CHECK_CLOSE_REL(rmsThetaYZ, theta0, 0.02); - CHECK_CLOSE_REL(rmsTheta3D, M_SQRT2 * theta0, 0.02); + CHECK_CLOSE_REL(rmsTheta3D, std::numbers::sqrt2 * theta0, 0.02); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp index 0d7ee71c62a..28b69de1050 100644 --- a/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace { @@ -97,7 +98,7 @@ BOOST_AUTO_TEST_CASE(TubeSectorCylindricalDetectorVolume) { Acts::ActsScalar rInner = 10.; Acts::ActsScalar rOuter = 100.; Acts::ActsScalar zHalfL = 300.; - Acts::ActsScalar phiSector = 0.25 * M_PI; + Acts::ActsScalar phiSector = std::numbers::pi / 4.; std::vector avgPhi = {0., 0.75}; std::vector avgPhiTag = {"zero", "nonzero"}; @@ -149,8 +150,8 @@ BOOST_AUTO_TEST_CASE(EndcapVolumeWithSurfaces) { lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; lsConfig.binnings = {Acts::Experimental::ProtoBinning( - Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, - 22u, 1u)}; + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 22u, 1u)}; auto layerBuilder = std::make_shared( @@ -158,7 +159,7 @@ BOOST_AUTO_TEST_CASE(EndcapVolumeWithSurfaces) { Acts::Logging::VERBOSE)); Acts::Experimental::VolumeStructureBuilder::Config shapeConfig; - shapeConfig.boundValues = {10, 100, 10., M_PI, 0.}; + shapeConfig.boundValues = {10, 100, 10., std::numbers::pi, 0.}; shapeConfig.transform = Acts::Transform3{Acts::Transform3::Identity()}.pretranslate( Acts::Vector3(0., 0., -800.)); @@ -222,9 +223,9 @@ BOOST_AUTO_TEST_CASE(BarrelVolumeWithSurfaces) { Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, - Acts::AxisBoundaryType::Closed, -M_PI, - M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning( + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 32u, 1u)}; auto barrelBuilder = std::make_shared( @@ -232,7 +233,7 @@ BOOST_AUTO_TEST_CASE(BarrelVolumeWithSurfaces) { Acts::Logging::VERBOSE)); Acts::Experimental::VolumeStructureBuilder::Config shapeConfig; - shapeConfig.boundValues = {60., 80., 800., M_PI, 0.}; + shapeConfig.boundValues = {60., 80., 800., std::numbers::pi, 0.}; shapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder; auto shapeBuilder = diff --git a/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp index a0741ca8136..d1368653f23 100644 --- a/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -206,7 +207,7 @@ BOOST_AUTO_TEST_CASE(ClosedCylinderGridZPhi) { // z-phi Axes & Grid Axis axisZ(AxisBound, -200., 200., 3); - Axis axisPhi(AxisClosed, -M_PI, M_PI, 6); + Axis axisPhi(AxisClosed, -std::numbers::pi, std::numbers::pi, 6); Grid gridZPhi(Type>, axisZ, axisPhi); Svg::GridConverter::Options cOptions; @@ -285,7 +286,7 @@ BOOST_AUTO_TEST_CASE(ClosedDiscGridRPhi) { // r-phi Axes & Grid Axis axisR(AxisBound, 100., 400., 3); - Axis axisPhi(AxisClosed, -M_PI, M_PI, 4); + Axis axisPhi(AxisClosed, -std::numbers::pi, std::numbers::pi, 4); Grid gridRPhi(Type>, axisR, axisPhi); Svg::GridConverter::Options cOptions; diff --git a/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp index 6f2c78620e9..f7f7e247bbb 100644 --- a/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp @@ -20,6 +20,7 @@ #include "Acts/Utilities/Grid.hpp" #include "Acts/Utilities/GridAxisGenerators.hpp" +#include #include using namespace Acts; @@ -77,7 +78,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { IndexedSurfacesGenerator irSurfaces{rSurfaces, {}, {BinningValue::binPhi}}; - GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; + GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi}, + 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -102,7 +104,8 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { IndexedSurfacesGenerator irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {BinningValue::binPhi}}; - GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; + GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi}, + 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -129,7 +132,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::VarBoundEqClosed aGenerator{ - {24., 74., 110.}, {-M_PI, M_PI}, 44u}; + {24., 74., 110.}, {-std::numbers::pi, std::numbers::pi}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -161,7 +164,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ - {24., 152}, 8u, {-M_PI, M_PI}, 88u}; + {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -194,7 +197,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}, {2u, 4u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ - {24., 152}, 8u, {-M_PI, M_PI}, 88u}; + {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator); @@ -216,7 +219,7 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { surfaces, {}, {BinningValue::binZ, BinningValue::binPhi}, {1u, 1u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ - {-500., 500}, 28, {-M_PI, M_PI}, 52u}; + {-500., 500}, 28, {-std::numbers::pi, std::numbers::pi}, 52u}; PolyhedronReferenceGenerator<1u, true> rGenerator; auto indexedCylinder = icSurfaces(tContext, aGenerator, rGenerator); diff --git a/Tests/UnitTests/Plugins/ActSVG/LayerSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/LayerSvgConverterTests.cpp index ff4afc789b6..de022263c73 100644 --- a/Tests/UnitTests/Plugins/ActSVG/LayerSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/LayerSvgConverterTests.cpp @@ -24,6 +24,7 @@ #include #include +#include #include BOOST_AUTO_TEST_SUITE(ActSvg) @@ -52,7 +53,7 @@ std::shared_ptr generateDiscLayer(Acts::ActsScalar rInner, setupTools(); unsigned int fullSegments = 4 * quarterSegments; std::vector> moduleSurfaces; - Acts::ActsScalar phiStep = 2 * M_PI / fullSegments; + Acts::ActsScalar phiStep = 2 * std::numbers::pi / fullSegments; Acts::ActsScalar rStep = (rOuter - rInner) / nRings; // Reserve & fill moduleSurfaces.reserve(fullSegments * nRings); @@ -83,16 +84,16 @@ std::shared_ptr generateDiscLayer(Acts::ActsScalar rInner, Acts::ActsScalar yHalf = rStep * 0.5125; Acts::ActsScalar xHalfMin = - 1.15 * (rInner + ir * rStep) * M_PI / fullSegments; + 1.15 * (rInner + ir * rStep) * std::numbers::pi / fullSegments; Acts::ActsScalar xHalfMax = - 1.15 * (rInner + (ir + 1) * rStep) * M_PI / fullSegments; + 1.15 * (rInner + (ir + 1) * rStep) * std::numbers::pi / fullSegments; std::shared_ptr tBounds = std::make_shared(xHalfMin, xHalfMax, yHalf); for (unsigned int is = 0; is < fullSegments; ++is) { // Setting the phi - Acts::ActsScalar cphi = -M_PI + is * phiStep; + Acts::ActsScalar cphi = -std::numbers::pi + is * phiStep; Acts::Vector3 center(radius * std::cos(cphi), radius * std::sin(cphi), (is % 2) * 2 + (ir % 2) * 5); // Local axis system diff --git a/Tests/UnitTests/Plugins/ActSVG/SurfaceSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/SurfaceSvgConverterTests.cpp index 8450453720c..686f7bbb765 100644 --- a/Tests/UnitTests/Plugins/ActSVG/SurfaceSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/SurfaceSvgConverterTests.cpp @@ -21,6 +21,7 @@ #include "Acts/Surfaces/TrapezoidBounds.hpp" #include +#include BOOST_AUTO_TEST_SUITE(ActSvg) @@ -92,7 +93,7 @@ BOOST_AUTO_TEST_CASE(PlanarSurfaces) { runPlanarTests(*trapeozidPlane, planarStyle, "trapezoid"); // Trapezoid case shifted and rotated - Acts::ActsScalar phi = 0.125 * M_PI; + Acts::ActsScalar phi = std::numbers::pi / 8.; Acts::ActsScalar radius = 150.; Acts::Vector3 center(radius * std::cos(phi), radius * std::sin(phi), 0.); @@ -187,8 +188,8 @@ BOOST_AUTO_TEST_CASE(DiscSurfaces) { runPlanarTests(*fullRing, discStyle, "full_ring"); // Sectorial disc case - auto sectoralDiscBounds = - std::make_shared(0., 64., 0.25 * M_PI, 0.5 * M_PI); + auto sectoralDiscBounds = std::make_shared( + 0., 64., std::numbers::pi / 4., std::numbers::pi / 2.); auto sectoralDisc = Acts::Surface::makeShared( transform, sectoralDiscBounds); runPlanarTests(*sectoralDisc, discStyle, "full_disc"); diff --git a/Tests/UnitTests/Plugins/Detray/DetrayGeometryConverterTests.cpp b/Tests/UnitTests/Plugins/Detray/DetrayGeometryConverterTests.cpp index 2ed99f4a68b..96f0f174ce0 100644 --- a/Tests/UnitTests/Plugins/Detray/DetrayGeometryConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Detray/DetrayGeometryConverterTests.cpp @@ -23,6 +23,7 @@ #include "Acts/Utilities/Logger.hpp" #include +#include #include #include @@ -41,7 +42,7 @@ BOOST_AUTO_TEST_SUITE(DetrayConversion) BOOST_AUTO_TEST_CASE(DetrayTransformConversion) { auto transform = Transform3::Identity(); transform.pretranslate(Vector3(1., 2., 3.)); - transform.rotate(Eigen::AngleAxisd(M_PI / 2., Vector3::UnitZ())); + transform.rotate(Eigen::AngleAxisd(std::numbers::pi / 2., Vector3::UnitZ())); detray::io::transform_payload payload = DetrayGeometryConverter::convertTransform(transform); diff --git a/Tests/UnitTests/Plugins/Detray/DetrayMaterialConverterTests.cpp b/Tests/UnitTests/Plugins/Detray/DetrayMaterialConverterTests.cpp index 56507b6c322..1e3f18ea512 100644 --- a/Tests/UnitTests/Plugins/Detray/DetrayMaterialConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Detray/DetrayMaterialConverterTests.cpp @@ -20,6 +20,8 @@ #include "Acts/Utilities/BinUtility.hpp" #include "Acts/Utilities/Logger.hpp" +#include + #include #include @@ -307,8 +309,9 @@ BOOST_AUTO_TEST_CASE(DetrayBinnedMaterialConversionRPhi) { std::vector binEdges = {0., 5., 20.}; Acts::BinUtility binUtility(binEdges, Acts::BinningOption::open, Acts::BinningValue::binR); - binUtility += Acts::BinUtility(2u, -M_PI, M_PI, Acts::BinningOption::closed, - Acts::BinningValue::binPhi); + binUtility += + Acts::BinUtility(2u, -std::numbers::pi, std::numbers::pi, + Acts::BinningOption::closed, Acts::BinningValue::binPhi); std::vector materialSlabs0 = {materialSlab12345, materialSlab678910}; @@ -384,8 +387,9 @@ BOOST_AUTO_TEST_CASE(DetrayBinnedMaterialConversionZPhi) { // Create a binned material in 2 x2 bins in x-y direction Acts::BinUtility binUtility(2u, -1., 1., Acts::BinningOption::open, Acts::BinningValue::binZ); - binUtility += Acts::BinUtility(2u, -M_PI, M_PI, Acts::BinningOption::closed, - Acts::BinningValue::binPhi); + binUtility += + Acts::BinUtility(2u, -std::numbers::pi, std::numbers::pi, + Acts::BinningOption::closed, Acts::BinningValue::binPhi); std::vector materialSlabs0 = {materialSlab12345, materialSlab678910}; diff --git a/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp b/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp index 48cfe29e2fc..45ed254ddd0 100644 --- a/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp +++ b/Tests/UnitTests/Plugins/EDM4hep/ConvertTrackEDM4hepTest.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -40,14 +41,14 @@ BOOST_AUTO_TEST_SUITE(EDM4hepParameterConversion) BOOST_AUTO_TEST_CASE(JacobianRoundtrip) { BoundVector par; - par << 1_mm, 5_mm, 0.1, M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; + par << 1_mm, 5_mm, 0.1, std::numbers::pi / 2. * 0.9, -1 / 1_GeV, 5_ns; BoundMatrix cov; cov.setIdentity(); double Bz = 2_T; - double tanLambda = std::tan(M_PI_2 - par[Acts::eBoundTheta]); + double tanLambda = std::tan(std::numbers::pi / 2. - par[Acts::eBoundTheta]); double omega = par[Acts::eBoundQOverP] / std::sin(par[Acts::eBoundTheta]) * Bz; @@ -67,7 +68,7 @@ BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithPerigee) { auto refSurface = Surface::makeShared(Vector3{50, 30, 20}); BoundVector par; - par << 1_mm, 5_mm, 0, M_PI_2, -1 / 1_GeV, + par << 1_mm, 5_mm, 0, std::numbers::pi / 2., -1 / 1_GeV, 5_ns; // -> perpendicular to perigee and pointing right, should be PCA BoundMatrix cov; @@ -112,7 +113,8 @@ BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithOutPerigee) { .planeSurface(); BoundVector par; - par << 1_mm, 5_mm, M_PI / 4., M_PI_2 * 0.9, -1 / 1_GeV, 5_ns; + par << 1_mm, 5_mm, std::numbers::pi / 4., std::numbers::pi / 2. * 0.9, + -1 / 1_GeV, 5_ns; BoundMatrix cov; cov.setIdentity(); @@ -176,7 +178,7 @@ BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithPerigeeNoCov) { auto refSurface = Surface::makeShared(Vector3{50, 30, 20}); BoundVector par; - par << 1_mm, 5_mm, 0, M_PI_2, -1 / 1_GeV, + par << 1_mm, 5_mm, 0, std::numbers::pi / 2., -1 / 1_GeV, 5_ns; // -> perpendicular to perigee and pointing right, should be PCA BoundTrackParameters boundPar{refSurface, par, std::nullopt, @@ -211,7 +213,8 @@ BOOST_AUTO_TEST_CASE(ConvertTrackParametersToEdm4hepWithOutPerigeeNoCov) { .planeSurface(); BoundVector par; - par << 1_mm, 5_mm, M_PI / 4., M_PI_2, -1 / 1_GeV, 5_ns; + par << 1_mm, 5_mm, std::numbers::pi / 4., std::numbers::pi / 2., -1 / 1_GeV, + 5_ns; BoundTrackParameters boundPar{refSurface, par, std::nullopt, ParticleHypothesis::pion()}; @@ -274,7 +277,8 @@ BOOST_AUTO_TEST_CASE(RoundTripTests) { std::uniform_real_distribution r(0, 1); std::uniform_int_distribution nTracks(2, 20); std::uniform_int_distribution nTs(1, 20); - std::uniform_real_distribution phiDist(-M_PI, M_PI); + std::uniform_real_distribution phiDist(-std::numbers::pi, + std::numbers::pi); std::uniform_real_distribution etaDist(-4, 4); std::uniform_real_distribution ptDist(1_MeV, 10_GeV); std::uniform_real_distribution qDist(0., 1.); diff --git a/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp b/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp index c748921b4d0..e0064b02a09 100644 --- a/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp +++ b/Tests/UnitTests/Plugins/Geant4/Geant4ConvertersTests.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -61,8 +62,9 @@ BOOST_AUTO_TEST_CASE(Geant4AlgebraConversion) { } BOOST_AUTO_TEST_CASE(Geant4CylinderConversion) { - G4Tubs cylinder("Cylinder", 399., 401., 800., -M_PI * CLHEP::radian, - 2 * M_PI * CLHEP::radian); + G4Tubs cylinder("Cylinder", 399., 401., 800., + -std::numbers::pi * CLHEP::radian, + 2 * std::numbers::pi * CLHEP::radian); auto [bounds, thickness] = Acts::Geant4ShapeConverter{}.cylinderBounds(cylinder); CHECK_CLOSE_ABS(bounds->get(Acts::CylinderBounds::BoundValues::eR), 400., @@ -70,30 +72,30 @@ BOOST_AUTO_TEST_CASE(Geant4CylinderConversion) { CHECK_CLOSE_ABS(bounds->get(Acts::CylinderBounds::BoundValues::eHalfLengthZ), 800., 10e-10); CHECK_CLOSE_ABS( - bounds->get(Acts::CylinderBounds::BoundValues::eHalfPhiSector), M_PI, - 10e-10); + bounds->get(Acts::CylinderBounds::BoundValues::eHalfPhiSector), + std::numbers::pi, 10e-10); CHECK_CLOSE_ABS(bounds->get(Acts::CylinderBounds::BoundValues::eAveragePhi), 0., 10e-10); CHECK_CLOSE_ABS(thickness, 2., 10e-10); } BOOST_AUTO_TEST_CASE(Geant4RadialConversion) { - G4Tubs disc("disc", 40., 400., 2., -M_PI * CLHEP::radian, - 2 * M_PI * CLHEP::radian); + G4Tubs disc("disc", 40., 400., 2., -std::numbers::pi * CLHEP::radian, + 2 * std::numbers::pi * CLHEP::radian); auto [bounds, thickness] = Acts::Geant4ShapeConverter{}.radialBounds(disc); CHECK_CLOSE_ABS(bounds->get(Acts::RadialBounds::BoundValues::eMinR), 40., 10e-10); CHECK_CLOSE_ABS(bounds->get(Acts::RadialBounds::BoundValues::eMaxR), 400., 10e-10); CHECK_CLOSE_ABS(bounds->get(Acts::RadialBounds::BoundValues::eHalfPhiSector), - M_PI, 10e-10); + std::numbers::pi, 10e-10); CHECK_CLOSE_ABS(bounds->get(Acts::RadialBounds::BoundValues::eAveragePhi), 0., 10e-10); CHECK_CLOSE_ABS(thickness, 4., 10e-10); } BOOST_AUTO_TEST_CASE(Geant4LineConversion) { - G4Tubs line("line", 0., 20., 400., 0., 2 * M_PI); + G4Tubs line("line", 0., 20., 400., 0., 2 * std::numbers::pi); auto bounds = Acts::Geant4ShapeConverter{}.lineBounds(line); CHECK_CLOSE_ABS(bounds->get(Acts::LineBounds::BoundValues::eR), 20., 10e-10); CHECK_CLOSE_ABS(bounds->get(Acts::LineBounds::BoundValues::eHalfLengthZ), @@ -281,7 +283,8 @@ BOOST_AUTO_TEST_CASE(Geant4CylVPhysConversion) { Acts::ActsScalar halfLengthZ = 200; G4Tubs* g4Tube = new G4Tubs("Tube", radius, radius + thickness, halfLengthZ, - -M_PI * CLHEP::radian, 2 * M_PI * CLHEP::radian); + -std::numbers::pi * CLHEP::radian, + 2 * std::numbers::pi * CLHEP::radian); G4RotationMatrix* g4Rot = new G4RotationMatrix({0., 0., 1.}, 0.); G4LogicalVolume* g4TubeLog = @@ -324,7 +327,8 @@ BOOST_AUTO_TEST_CASE(Geant4VDiscVPhysConversion) { Acts::ActsScalar thickness = 2.; G4Tubs* g4Tube = new G4Tubs("Disc", innerRadius, outerRadius, 0.5 * thickness, - -M_PI * CLHEP::radian, 2 * M_PI * CLHEP::radian); + -std::numbers::pi * CLHEP::radian, + 2 * std::numbers::pi * CLHEP::radian); G4RotationMatrix* g4Rot = new G4RotationMatrix({0., 0., 1.}, 0.); G4LogicalVolume* g4TubeLog = @@ -356,7 +360,8 @@ BOOST_AUTO_TEST_CASE(Geant4LineVPhysConversion) { Acts::ActsScalar thickness = 400.; G4Tubs* g4Tube = new G4Tubs("Line", innerRadius, outerRadius, 0.5 * thickness, - -M_PI * CLHEP::radian, 2 * M_PI * CLHEP::radian); + -std::numbers::pi * CLHEP::radian, + 2 * std::numbers::pi * CLHEP::radian); G4RotationMatrix* g4Rot = new G4RotationMatrix({0., 0., 1.}, 0.); G4LogicalVolume* g4TubeLog = diff --git a/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp b/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp index f2149bacfe8..e4e2b9043c1 100644 --- a/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp +++ b/Tests/UnitTests/Plugins/Geant4/Geant4DetectorSurfaceFactoryTests.cpp @@ -15,6 +15,7 @@ #include "Acts/Visualization/ObjVisualization3D.hpp" #include +#include #include #include "G4Box.hh" @@ -67,8 +68,8 @@ BOOST_AUTO_TEST_CASE(Geant4DetecturSurfaceFactory_Cylinder) { G4LogicalVolume* worldLV = new G4LogicalVolume(worldS, nullptr, "World"); G4Tubs* cylinderS = - new G4Tubs("cylinder", 99, 100, 100, -M_PI * CLHEP::radian, - 2 * M_PI * CLHEP::radian); + new G4Tubs("cylinder", 99, 100, 100, -std::numbers::pi * CLHEP::radian, + 2 * std::numbers::pi * CLHEP::radian); G4LogicalVolume* cylinderLV = new G4LogicalVolume(cylinderS, nullptr, "World"); @@ -108,7 +109,7 @@ BOOST_AUTO_TEST_CASE(Geant4DetecturSurfaceFactory_Transforms) { auto vol1S = new G4Box("volume1", 25, 10, 50); auto vol1L = new G4LogicalVolume(vol1S, nullptr, "Volume1"); - G4Transform3D transformVol1(CLHEP::HepRotationX(M_PI / 4), + G4Transform3D transformVol1(CLHEP::HepRotationX(std::numbers::pi / 4.), G4ThreeVector(20, 0, 0)); [[maybe_unused]] auto vol1PV = new G4PVPlacement( @@ -117,7 +118,7 @@ BOOST_AUTO_TEST_CASE(Geant4DetecturSurfaceFactory_Transforms) { auto vol2S = new G4Box("volume2", 25, 10, 50); auto vol2L = new G4LogicalVolume(vol2S, nullptr, "Volume2"); - G4Transform3D transformVol2(CLHEP::HepRotationY(M_PI / 6), + G4Transform3D transformVol2(CLHEP::HepRotationY(std::numbers::pi / 6.), G4ThreeVector(0, 100, 20)); [[maybe_unused]] auto vol2PV = new G4PVPlacement( @@ -126,7 +127,7 @@ BOOST_AUTO_TEST_CASE(Geant4DetecturSurfaceFactory_Transforms) { auto vol3S = new G4Box("volume3", 25, 10, 50); auto vol3L = new G4LogicalVolume(vol3S, nullptr, "Volume3"); - G4Transform3D transformVol3(CLHEP::HepRotationZ(M_PI / 12), + G4Transform3D transformVol3(CLHEP::HepRotationZ(std::numbers::pi / 12.), G4ThreeVector(30, 100, 0)); [[maybe_unused]] auto vol3PV = new G4PVPlacement( diff --git a/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp index a7e25729b7f..2d18bd98a45 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -169,8 +170,8 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; lsConfig.binnings = {Acts::Experimental::ProtoBinning( - Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, - 22u, 1u)}; + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 22u, 1u)}; auto layerBuilder = std::make_shared( @@ -178,7 +179,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { Acts::Logging::VERBOSE)); Acts::Experimental::VolumeStructureBuilder::Config shapeConfig; - shapeConfig.boundValues = {18, 100, 10., M_PI, 0.}; + shapeConfig.boundValues = {18, 100, 10., std::numbers::pi, 0.}; shapeConfig.transform = Acts::Transform3{Acts::Transform3::Identity()}.pretranslate( Acts::Vector3(0., 0., ep)); @@ -203,7 +204,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { // Central barrel Acts::Experimental::VolumeStructureBuilder::Config innerShapeConfig; - innerShapeConfig.boundValues = {18., 60., 700., M_PI, 0.}; + innerShapeConfig.boundValues = {18., 60., 700., std::numbers::pi, 0.}; innerShapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder; auto innerShapeBuilder = @@ -234,9 +235,9 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, - Acts::AxisBoundaryType::Closed, -M_PI, - M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning( + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 32u, 1u)}; auto barrelBuilder = std::make_shared( @@ -244,7 +245,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { Acts::Logging::VERBOSE)); Acts::Experimental::VolumeStructureBuilder::Config shapeConfig; - shapeConfig.boundValues = {60., 80., 700., M_PI, 0.}; + shapeConfig.boundValues = {60., 80., 700., std::numbers::pi, 0.}; shapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder; auto shapeBuilder = @@ -262,7 +263,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { // Outer shape Acts::Experimental::VolumeStructureBuilder::Config outerShapeConfig; - outerShapeConfig.boundValues = {80., 100., 700., M_PI, 0.}; + outerShapeConfig.boundValues = {80., 100., 700., std::numbers::pi, 0.}; outerShapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder; auto outerShapeBuilder = @@ -300,7 +301,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { // Beam Pipe Acts::Experimental::VolumeStructureBuilder::Config bpShapeConfig; - bpShapeConfig.boundValues = {0., 18., 720., M_PI, 0.}; + bpShapeConfig.boundValues = {0., 18., 720., std::numbers::pi, 0.}; bpShapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder; auto bpShapeBuilder = diff --git a/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp index 21405647769..b1701f06128 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -148,8 +149,8 @@ BOOST_AUTO_TEST_CASE(EndcapVolumeWithSurfaces) { lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; lsConfig.binnings = {Acts::Experimental::ProtoBinning( - Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, - 22u, 1u)}; + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 22u, 1u)}; auto layerBuilder = std::make_shared( @@ -157,7 +158,7 @@ BOOST_AUTO_TEST_CASE(EndcapVolumeWithSurfaces) { Acts::Logging::VERBOSE)); Acts::Experimental::VolumeStructureBuilder::Config shapeConfig; - shapeConfig.boundValues = {10, 100, 10., M_PI, 0.}; + shapeConfig.boundValues = {10, 100, 10., std::numbers::pi, 0.}; shapeConfig.transform = Acts::Transform3{Acts::Transform3::Identity()}.pretranslate( Acts::Vector3(0., 0., -800.)); @@ -230,9 +231,9 @@ BOOST_AUTO_TEST_CASE(BarrelVolumeWithSurfaces) { Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, - Acts::AxisBoundaryType::Closed, -M_PI, - M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning( + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, + -std::numbers::pi, std::numbers::pi, 32u, 1u)}; auto barrelBuilder = std::make_shared( @@ -240,7 +241,7 @@ BOOST_AUTO_TEST_CASE(BarrelVolumeWithSurfaces) { Acts::Logging::VERBOSE)); Acts::Experimental::VolumeStructureBuilder::Config shapeConfig; - shapeConfig.boundValues = {60., 80., 800., M_PI, 0.}; + shapeConfig.boundValues = {60., 80., 800., std::numbers::pi, 0.}; shapeConfig.boundsType = Acts::VolumeBounds::BoundsType::eCylinder; auto shapeBuilder = diff --git a/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp index 8f73a12c6b2..cac514a18ac 100644 --- a/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -198,7 +199,8 @@ BOOST_AUTO_TEST_CASE(Grid2DSingleEntryBound) { BOOST_AUTO_TEST_CASE(Grid2DSingleEntryBoundClosed) { using EqBoundEqClosed = Acts::GridAxisGenerators::EqBoundEqClosed; - EqBoundEqClosed eqBoundEqClosed{{-6., 6.}, 3, {-M_PI, M_PI}, 3}; + EqBoundEqClosed eqBoundEqClosed{ + {-6., 6.}, 3, {-std::numbers::pi, std::numbers::pi}, 3}; // Create the grid with the provided axis generator using GridTypeEQBEQC = typename EqBoundEqClosed::template grid_type; diff --git a/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp index b68a2606e61..6647ee69fe4 100644 --- a/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -108,18 +109,20 @@ BOOST_AUTO_TEST_CASE(IndexedSurfaceMaterial2DTests) { using EqEqGrid = EqBoundEqClosed::grid_type; using Point = EqEqGrid::point_t; - EqBoundEqClosed eqeqBound{{-1., 1.}, 2, {-M_PI, M_PI}, 4}; + EqBoundEqClosed eqeqBound{ + {-1., 1.}, 2, {-std::numbers::pi, std::numbers::pi}, 4}; EqEqGrid eqeqGrid{eqeqBound()}; - eqeqGrid.atPosition(Point{-0.5, -M_PI * 0.75}) = 1u; // material 1 - eqeqGrid.atPosition(Point{-0.5, -M_PI * 0.25}) = 1u; // material 1 - eqeqGrid.atPosition(Point{-0.5, M_PI * 0.25}) = 0u; // vacuum - eqeqGrid.atPosition(Point{-0.5, M_PI * 0.75}) = 2u; // material 2 + eqeqGrid.atPosition(Point{-0.5, -std::numbers::pi * 0.75}) = + 1u; // material 1 + eqeqGrid.atPosition(Point{-0.5, -std::numbers::pi / 4.}) = 1u; // material 1 + eqeqGrid.atPosition(Point{-0.5, std::numbers::pi / 4.}) = 0u; // vacuum + eqeqGrid.atPosition(Point{-0.5, std::numbers::pi * 0.75}) = 2u; // material 2 - eqeqGrid.atPosition(Point{0.5, -M_PI * 0.75}) = 0u; // vacuum - eqeqGrid.atPosition(Point{0.5, -M_PI * 0.25}) = 3u; // material 3 - eqeqGrid.atPosition(Point{0.5, M_PI * 0.25}) = 3u; // material 3 - eqeqGrid.atPosition(Point{0.5, M_PI * 0.75}) = 0u; // vacuum + eqeqGrid.atPosition(Point{0.5, -std::numbers::pi * 0.75}) = 0u; // vacuum + eqeqGrid.atPosition(Point{0.5, -std::numbers::pi / 4.}) = 3u; // material 3 + eqeqGrid.atPosition(Point{0.5, std::numbers::pi / 4.}) = 3u; // material 3 + eqeqGrid.atPosition(Point{0.5, std::numbers::pi * 0.75}) = 0u; // vacuum auto boundToGrid = std::make_unique>(); diff --git a/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp index 66cf86092a2..e5fbc8cf797 100644 --- a/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -174,8 +175,9 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::BinningData pixEcBinningR = Acts::BinningData(Acts::open, Acts::BinningValue::binR, 2., 0., 1.); - Acts::BinningData pixEcBinningPhi = Acts::BinningData( - Acts::closed, Acts::BinningValue::binPhi, 30., -M_PI, M_PI); + Acts::BinningData pixEcBinningPhi = + Acts::BinningData(Acts::closed, Acts::BinningValue::binPhi, 30., + -std::numbers::pi, std::numbers::pi); for (auto& cv : pixelNec.container.value().constituentVolumes) { cv.extent.setEnvelope(discLayerEnvelope); @@ -278,8 +280,9 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::BinningData sstripEcBinningR = Acts::BinningData(Acts::open, Acts::BinningValue::binR, 3., 0., 1.); - Acts::BinningData sstripEcBinningPhi = Acts::BinningData( - Acts::closed, Acts::BinningValue::binPhi, 42., -M_PI, M_PI); + Acts::BinningData sstripEcBinningPhi = + Acts::BinningData(Acts::closed, Acts::BinningValue::binPhi, 42., + -std::numbers::pi, std::numbers::pi); Acts::ProtoVolume sstripNec; sstripNec.name = "odd-sstrip-nec"; diff --git a/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp index 08ec49e1bed..24831d53de0 100644 --- a/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,8 @@ BOOST_AUTO_TEST_CASE(BinUtilityRoundTripTests) { BOOST_CHECK(isEqual(reference, test, 0.0001)); // Increase to two dimensions - reference += BinUtility(10., -M_PI, M_PI, closed, BinningValue::binPhi); + reference += BinUtility(10., -std::numbers::pi, std::numbers::pi, closed, + BinningValue::binPhi); nlohmann::json jtwoDimOut; to_json(jtwoDimOut, reference); out.open("BinUtility_2D.json"); diff --git a/Tests/UnitTests/Plugins/Json/VolumeBoundsJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/VolumeBoundsJsonConverterTests.cpp index 25fa9326e79..ff850dcd48b 100644 --- a/Tests/UnitTests/Plugins/Json/VolumeBoundsJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/VolumeBoundsJsonConverterTests.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -56,8 +57,8 @@ BOOST_AUTO_TEST_CASE(Cuboid) { BOOST_AUTO_TEST_CASE(Cylinder) { std::ofstream out("CylinderVolumeBounds.json"); - auto cylinderRef = - std::make_shared(10., 20., 30., M_PI / 4, 0); + auto cylinderRef = std::make_shared( + 10., 20., 30., std::numbers::pi / 4., 0); nlohmann::json cylinderOut = VolumeBoundsJsonConverter::toJson(*cylinderRef); out << cylinderOut.dump(2); out.close(); @@ -78,8 +79,8 @@ BOOST_AUTO_TEST_CASE(Cylinder) { BOOST_AUTO_TEST_CASE(Cone) { std::ofstream out("ConeVolumeBounds.json"); - auto coneRef = std::make_shared(0., 0., 0.45, 0.050, - 0.050, 0., M_PI); + auto coneRef = std::make_shared( + 0., 0., 0.45, 0.050, 0.050, 0., std::numbers::pi); nlohmann::json coneOut = VolumeBoundsJsonConverter::toJson(*coneRef); out << coneOut.dump(2); out.close(); diff --git a/Tests/UnitTests/Plugins/TGeo/TGeoTubeConversionTests.cpp b/Tests/UnitTests/Plugins/TGeo/TGeoTubeConversionTests.cpp index 2f18c391958..180e9eaaa6d 100644 --- a/Tests/UnitTests/Plugins/TGeo/TGeoTubeConversionTests.cpp +++ b/Tests/UnitTests/Plugins/TGeo/TGeoTubeConversionTests.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -119,7 +120,7 @@ BOOST_AUTO_TEST_CASE(TGeoTube_to_CylinderSurface) { double mphi = boundsSegment->get(CylinderBounds::eAveragePhi); CHECK_CLOSE_ABS(bR, 10.5, s_epsilon); CHECK_CLOSE_ABS(bhZ, hz, s_epsilon); - CHECK_CLOSE_ABS(hphi, 0.25 * M_PI, s_epsilon); + CHECK_CLOSE_ABS(hphi, std::numbers::pi / 4., s_epsilon); CHECK_CLOSE_ABS(mphi, 0., s_epsilon); GeometryView3D::drawSurface(objVis, *cylinderSegment, tgContext); GeometryView3D::drawArrowForward( @@ -215,7 +216,7 @@ BOOST_AUTO_TEST_CASE(TGeoTube_to_DiscSurface) { double mphi = boundsSegment->get(RadialBounds::eAveragePhi); CHECK_CLOSE_ABS(bminr, rmin, s_epsilon); CHECK_CLOSE_ABS(bmaxr, rmax, s_epsilon); - CHECK_CLOSE_ABS(hphi, 0.25 * M_PI, s_epsilon); + CHECK_CLOSE_ABS(hphi, std::numbers::pi / 4., s_epsilon); CHECK_CLOSE_ABS(mphi, 0., s_epsilon); GeometryView3D::drawSurface(objVis, *discSegment, tgContext); GeometryView3D::drawArrowForward(objVis, center, From 54d61d4d28c540c260ff3da7c6262671f52eec14 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:45:33 +0100 Subject: [PATCH 4/5] ci: Add check for mathematical constants (no macros) (#3774) The firstly intended clang tidy check `modernize-use-std-numbers` is not suited for us: - it doesn't flag macros like `M_PI` - it flags values in our tables that get close to constants, which have a different basis. benefit would have been to detect cases like `static_cast(std::numbers::pi)` instead of `std::numbers::pi_v` or usages of `std::sqrt(2.)` instead of `std::numbers::sqrt2`. The updated test now checks for the classical `M_*` macros that could be accidentally used. blocked: - https://github.com/acts-project/acts/pull/3781 --- .github/workflows/checks.yml | 10 +++ .pre-commit-config.yaml | 8 +++ CI/check_math_macros.py | 120 +++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100755 CI/check_math_macros.py diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5686d842b66..edd31d051a4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -116,6 +116,16 @@ jobs: - name: Check run: > CI/check_spelling + math_macros: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Check + run: > + CI/check_math_macros.py . --exclude "thirdparty/*" missing_includes: runs-on: ubuntu-latest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76af4847b7f..68c78341c5d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -93,3 +93,11 @@ repos: name: Leftover conflict markers language: system entry: git diff --staged --check + + - repo: local + hooks: + - id: math_macros + name: math_macros + language: system + entry: CI/check_math_macros.py + files: \.(cpp|hpp|ipp|cu|cuh)$ diff --git a/CI/check_math_macros.py b/CI/check_math_macros.py new file mode 100755 index 00000000000..29da233372e --- /dev/null +++ b/CI/check_math_macros.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 + +from pathlib import Path +import os +import argparse +from fnmatch import fnmatch +import re +import sys + + +math_constants = [ + ("M_PI", "std::numbers::pi"), + ("M_PI_2", "std::numbers::pi / 2."), + ("M_PI_4", "std::numbers::pi / 4."), + ("M_1_PI", "std::numbers::inv_pi"), + ("M_2_PI", "2. * std::numbers::inv_pi"), + ("M_2_SQRTPI", "2. * std::numbers::inv_sqrtpi"), + ("M_E", "std::numbers::e"), + ("M_LOG2E", "std::numbers::log2e"), + ("M_LOG10E", "std::numbers::log10e"), + ("M_LN2", "std::numbers::ln2"), + ("M_LN10", "std::numbers::ln10"), + ("M_SQRT2", "std::numbers::sqrt2"), + ("M_SQRT1_2", "1. / std::numbers::sqrt2"), + ("M_SQRT3", "std::numbers::sqrt3"), + ("M_INV_SQRT3", "std::numbers::inv_sqrt3"), + ("M_EGAMMA", "std::numbers::egamma"), + ("M_PHI", "std::numbers::phi"), +] + + +github = "GITHUB_ACTIONS" in os.environ + + +def handle_file( + file: Path, fix: bool, math_const: tuple[str, str] +) -> list[tuple[int, str]]: + ex = re.compile(rf"(? 0: + changed_lines.append((i, oline)) + + if fix and len(changed_lines) > 0: + file.write_text("\n".join(lines) + "\n") + + return changed_lines + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("input", nargs="+") + p.add_argument("--fix", action="store_true", help="Attempt to fix M_* macros.") + p.add_argument("--exclude", "-e", action="append", default=[]) + + args = p.parse_args() + + exit_code = 0 + + inputs = [] + + if len(args.input) == 1 and os.path.isdir(args.input[0]): + # walk over all files + for root, _, files in os.walk(args.input[0]): + root = Path(root) + for filename in files: + # get the full path of the file + filepath = root / filename + if filepath.suffix not in ( + ".hpp", + ".cpp", + ".ipp", + ".h", + ".C", + ".c", + ".cu", + ".cuh", + ): + continue + + if any([fnmatch(str(filepath), e) for e in args.exclude]): + continue + + inputs.append(filepath) + else: + for file in args.input: + inputs.append(Path(file)) + + for filepath in inputs: + for math_const in math_constants: + changed_lines = handle_file( + file=filepath, fix=args.fix, math_const=math_const + ) + if len(changed_lines) > 0: + exit_code = 1 + print() + print(filepath) + for i, oline in changed_lines: + print(f"{i}: {oline}") + + if github: + print( + f"::error file={filepath},line={i+1},title=Do not use macro {math_const[0]}::Replace {math_const[0]} with std::{math_const[1]}" + ) + + if exit_code == 1 and github: + print(f"::info You will need in each flagged file #include ") + + return exit_code + + +if "__main__" == __name__: + sys.exit(main()) From bf3faa3b248d53c4537ad9f49026f6dc144b777d Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:46:49 +0100 Subject: [PATCH 5/5] refactor(gx2f): pull out material counting (#3839) Pulling out, as suggested in https://github.com/acts-project/acts/pull/3726/files#r1835623388 --- .../TrackFitting/GlobalChiSquareFitter.hpp | 84 ++++++++++++------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp index c5fb8483aa7..867b161201c 100644 --- a/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp +++ b/Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp @@ -392,10 +392,8 @@ void addMeasurementToGx2fSums(Gx2fSystem& extendedSystem, } // Create an extended Jacobian. This one contains only eBoundSize rows, - // because the rest is irrelevant. We fill it in the next steps + // because the rest is irrelevant. We fill it in the next steps. // TODO make dimsExtendedParams template with unrolling - - // We create an empty Jacobian and fill it in the next steps Eigen::MatrixXd extendedJacobian = Eigen::MatrixXd::Zero(eBoundSize, extendedSystem.nDims()); @@ -566,10 +564,11 @@ void addMaterialToGx2fSums( /// /// @tparam track_proxy_t The type of the track proxy /// -/// @param track A mutable track proxy to operate on +/// @param track A constant track proxy to inspect /// @param extendedSystem All parameters of the current equation system /// @param multipleScattering Flag to consider multiple scattering in the calculation -/// @param scatteringMap Map of geometry identifiers to scattering properties, containing all scattering angles and covariances +/// @param scatteringMap Map of geometry identifiers to scattering properties, +/// containing scattering angles and validation status /// @param geoIdVector A vector to store geometry identifiers for tracking processed elements /// @param logger A logger instance template @@ -650,6 +649,51 @@ void fillGx2fSystem( } } +/// @brief Count the valid material states in a track for scattering calculations. +/// +/// This function counts the valid material surfaces encountered in a track +/// by examining each track state. The count is based on the presence of +/// material flags and the availability of scattering information for each +/// surface. +/// +/// @tparam track_proxy_t The type of the track proxy +/// +/// @param track A constant track proxy to inspect +/// @param scatteringMap Map of geometry identifiers to scattering properties, +/// containing scattering angles and validation status +/// @param logger A logger instance +template +std::size_t countMaterialStates( + const track_proxy_t track, + const std::unordered_map& + scatteringMap, + const Logger& logger) { + std::size_t nMaterialSurfaces = 0; + ACTS_DEBUG("Count the valid material surfaces."); + for (const auto& trackState : track.trackStates()) { + const auto typeFlags = trackState.typeFlags(); + const bool stateHasMaterial = typeFlags.test(TrackStateFlag::MaterialFlag); + + if (!stateHasMaterial) { + continue; + } + + // Get and store geoId for the current material surface + const GeometryIdentifier geoId = trackState.referenceSurface().geometryId(); + + const auto scatteringMapId = scatteringMap.find(geoId); + assert(scatteringMapId != scatteringMap.end() && + "No scattering angles found for material surface."); + if (!scatteringMapId->second.materialIsValid()) { + continue; + } + + nMaterialSurfaces++; + } + + return nMaterialSurfaces; +} + /// @brief Calculate and update the covariance of the fitted parameters /// /// This function calculates the covariance of the fitted parameters using @@ -1303,32 +1347,10 @@ class Gx2Fitter { // Count the material surfaces, to set up the system. In the multiple // scattering case, we need to extend our system. - std::size_t nMaterialSurfaces = 0; - if (multipleScattering) { - ACTS_DEBUG("Count the valid material surfaces."); - for (const auto& trackState : track.trackStates()) { - const auto typeFlags = trackState.typeFlags(); - const bool stateHasMaterial = - typeFlags.test(TrackStateFlag::MaterialFlag); - - if (!stateHasMaterial) { - continue; - } - - // Get and store geoId for the current material surface - const GeometryIdentifier geoId = - trackState.referenceSurface().geometryId(); - - const auto scatteringMapId = scatteringMap.find(geoId); - assert(scatteringMapId != scatteringMap.end() && - "No scattering angles found for material surface."); - if (!scatteringMapId->second.materialIsValid()) { - continue; - } - - nMaterialSurfaces++; - } - } + const std::size_t nMaterialSurfaces = + multipleScattering + ? countMaterialStates(track, scatteringMap, *m_addToSumLogger) + : 0u; // We need 6 dimensions for the bound parameters and 2 * nMaterialSurfaces // dimensions for the scattering angles.