From 744748c92079413ccc773183c78516b171ab8737 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Wed, 23 Oct 2024 17:03:42 +0200 Subject: [PATCH 01/16] Core --- .../ScoreBasedAmbiguityResolution.hpp | 5 ++-- Core/include/Acts/Definitions/Units.hpp | 4 ++- .../Acts/EventData/TrackParameterHelpers.hpp | 6 ++-- .../Acts/EventData/TransformationHelpers.hpp | 7 +++-- .../EventData/detail/CalculateResiduals.hpp | 3 +- .../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 | 8 +++--- .../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 ++++++++++--------- .../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 | 21 +++++++------- .../Acts/Visualization/EventDataView3D.hpp | 5 ++-- Core/src/Detector/VolumeStructureBuilder.cpp | 4 ++- .../detail/CylindricalDetectorHelper.cpp | 9 ++++-- .../Detector/detail/SupportSurfacesHelper.cpp | 11 ++++---- 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 +++-- 57 files changed, 285 insertions(+), 192 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/TrackParameterHelpers.hpp b/Core/include/Acts/EventData/TrackParameterHelpers.hpp index cd68b5ae6a4..0d14d39fd7f 100644 --- a/Core/include/Acts/EventData/TrackParameterHelpers.hpp +++ b/Core/include/Acts/EventData/TrackParameterHelpers.hpp @@ -12,6 +12,8 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Utilities/detail/periodic.hpp" +#include + namespace Acts { /// Normalize the bound parameter angles @@ -36,8 +38,8 @@ inline BoundVector normalizeBoundParameters(const BoundVector& boundParams) { inline BoundVector subtractBoundParameters(const BoundVector& lhs, const BoundVector& rhs) { BoundVector result = lhs - rhs; - result[eBoundPhi] = - detail::difference_periodic(lhs[eBoundPhi], rhs[eBoundPhi], 2 * M_PI); + result[eBoundPhi] = detail::difference_periodic( + lhs[eBoundPhi], rhs[eBoundPhi], 2 * std::numbers::pi); return result; } 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/CalculateResiduals.hpp b/Core/include/Acts/EventData/detail/CalculateResiduals.hpp index 33d800d16e6..7d473786179 100644 --- a/Core/include/Acts/EventData/detail/CalculateResiduals.hpp +++ b/Core/include/Acts/EventData/detail/CalculateResiduals.hpp @@ -12,6 +12,7 @@ #include "Acts/Utilities/detail/periodic.hpp" #include +#include #include @@ -55,7 +56,7 @@ inline void calculateResiduals(BoundIndices size, if (fullIndex == eBoundPhi) { residuals[i] = difference_periodic( measured[i], reference[fullIndex], - static_cast(2 * M_PI)); + static_cast(2 * std::numbers::pi)); } else { residuals[i] = measured[i] - reference[fullIndex]; } 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..63005e1d758 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(0.5 * std::numbers::pi, Vector3::UnitY()) * + AngleAxis3(0.5 * std::numbers::pi, Vector3::UnitZ()) * + Transform3::Identity(); +static const Transform3 s_planeZX = + AngleAxis3(-0.5 * std::numbers::pi, Vector3::UnitX()) * + AngleAxis3(-0.5 * std::numbers::pi, Vector3::UnitZ()) * + Transform3::Identity(); /// @class VolumeBounds /// diff --git a/Core/include/Acts/Propagator/RiddersPropagator.ipp b/Core/include/Acts/Propagator/RiddersPropagator.ipp index cef7c79bd4f..06aa11aedb2 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)) < + 0.5 * std::numbers::pi) { 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 91f5f3f64e4..91e52bd49e2 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 @@ -58,7 +58,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(); @@ -391,10 +391,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 4410f1c125b..56885d10bf8 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp @@ -70,10 +70,10 @@ 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). - // 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 + // depends on min_pt, magnetic field: 2*std::numbers::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 // cover the full phi-range of minPT), leave this at 1. int phiBinDeflectionCoverage = 1; // maximum number of phi bins diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp index 523d470eae5..4ccf137237b 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 @@ -87,16 +88,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/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..23a6fc28fc1 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 = 0.5 * std::numbers::pi - 0.5 * opening_angle; 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 / 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..d779aa72b0d 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 < 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..7c46410d784 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) { Acts::ActsScalar new_deltaZfrom = rMiddle[isLessFrom] / std::tan(angleZfrom) / zBinLength; nearZFrom = static_cast(std::max( @@ -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) { 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,8 @@ 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, 2 * std::numbers::pi); if (std::abs(deltaPhiBC) > m_cfg.maxPhideviation) { continue; } @@ -333,7 +334,7 @@ bool Acts::SingleSeedVertexFinder::tripletValidationAndUpdate( 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); + detail::difference_periodic(alpha1, alpha2, 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..7bd622de06d 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,7 @@ 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 + (iphi + 0.5) * 2 * dHalfPhi; ActsScalar cosPhi = std::cos(phi); ActsScalar sinPhi = std::sin(phi); ActsScalar planeX = planeR * cosPhi; @@ -271,10 +272,10 @@ 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 + (iphi + 0.5) * 2 * dHalfPhi; auto sTransform = Transform3( Translation3(hR * std::cos(phi), hR * std::sin(phi), zPosition) * - AngleAxis3(phi - 0.5 * M_PI, zAxis)); + AngleAxis3(phi - 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..4e0e2c045fa 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 27123d29ec0..a97be80013e 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 130c8381536..5f48aa95787 100644 --- a/Core/src/TrackFinding/MeasurementSelector.cpp +++ b/Core/src/TrackFinding/MeasurementSelector.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace Acts { @@ -116,7 +117,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; } From d50e0e1525ee8fb311bf9ef5814ad4299e985088 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 24 Oct 2024 10:27:03 +0200 Subject: [PATCH 02/16] Examples --- .../ScoreBasedAmbiguityResolutionAlgorithm.hpp | 5 +++-- .../Generators/ParametricParticleGenerator.hpp | 7 ++++--- .../ActsExamples/Generators/VertexGenerators.hpp | 5 +++-- .../Algorithms/Geometry/src/VolumeAssociationTest.cpp | 4 +++- .../MaterialMapping/MappingMaterialDecorator.hpp | 9 +++++---- .../ActsExamples/MaterialMapping/MaterialValidation.hpp | 5 ++++- .../Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp | 9 +++++---- .../GenericDetector/src/BuildGenericDetector.cpp | 9 +++++---- .../src/MockupSectorBuilder.cpp | 7 ++++--- Examples/Io/Csv/src/CsvSeedWriter.cpp | 5 +++-- Examples/Io/Root/src/RootTrackParameterWriter.cpp | 3 ++- Examples/Io/Root/src/RootTrackStatesWriter.cpp | 3 ++- Examples/Io/Root/src/RootTrackSummaryWriter.cpp | 6 ++++-- Examples/Io/Root/src/VertexNTupleWriter.cpp | 5 +++-- Examples/Python/src/Geometry.cpp | 3 ++- Examples/Scripts/MaterialMapping/materialComposition.C | 5 +++-- Examples/Scripts/TrackingPerformance/TrackSummary.cpp | 8 +++++--- .../Scripts/TrackingPerformance/trackSummaryAnalysis.C | 3 ++- Examples/Scripts/momentumDistributions.C | 4 +++- 19 files changed, 65 insertions(+), 40 deletions(-) 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 a7d9bfe3e08..dc89ac0c5c2 100644 --- a/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.hpp +++ b/Examples/Algorithms/Generators/ActsExamples/Generators/ParametricParticleGenerator.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include namespace ActsExamples { @@ -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/src/GbtsSeedingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp index 385a3db7ec1..e273eacd6b7 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..20b8cec575e 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,9 @@ 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; + double sectorAngle = std::numbers::pi; - auto halfPhi = M_PI / mCfg.NumberOfSectors; + double halfPhi = std::numbers::pi / mCfg.NumberOfSectors; if (mCfg.NumberOfSectors == 1) { halfPhi = (phiB - phiA) / 2; @@ -223,7 +224,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 96dd04b07a4..41f1e501e3a 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,9 @@ ActsExamples::ProcessCode ActsExamples::CsvSeedWriter::writeT( float truthPhi = phi(truthUnitDir); float truthEta = std::atanh(std::cos(theta(truthUnitDir))); float dEta = fabs(truthEta - seedEta); - float dPhi = fabs(truthPhi - seedPhi) < M_PI + float dPhi = fabs(truthPhi - seedPhi) < std::numbers::pi_v ? fabs(truthPhi - seedPhi) - : fabs(truthPhi - seedPhi) - M_PI; + : fabs(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; From 577359ca4b6630b47da4801bffe106ba4b5e1483 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 24 Oct 2024 10:33:16 +0200 Subject: [PATCH 03/16] Fatras --- .../Physics/ElectroMagnetic/PhotonConversion.hpp | 5 +++-- .../ActsFatras/Physics/ElectroMagnetic/Scattering.hpp | 5 +++-- .../Physics/ElectroMagnetic/detail/GaussianMixture.hpp | 3 ++- .../Physics/ElectroMagnetic/detail/GeneralMixture.hpp | 3 ++- .../ActsFatras/Physics/ElectroMagnetic/detail/Highland.hpp | 4 +++- .../Physics/NuclearInteraction/NuclearInteraction.hpp | 7 ++++--- Fatras/src/Digitization/PlanarSurfaceMask.cpp | 3 ++- Fatras/src/Physics/BetheHeitler.cpp | 3 ++- 8 files changed, 21 insertions(+), 12 deletions(-) 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 dea8a0ae334..18324c177a7 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.; From 620e0733d4dfb09a328b75e8f4e08ee66b749577 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 24 Oct 2024 10:46:52 +0200 Subject: [PATCH 04/16] Plugins --- Core/src/Geometry/TrapezoidVolumeBounds.cpp | 2 +- .../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 +++++++----- 17 files changed, 90 insertions(+), 55 deletions(-) diff --git a/Core/src/Geometry/TrapezoidVolumeBounds.cpp b/Core/src/Geometry/TrapezoidVolumeBounds.cpp index 4e0e2c045fa..96d682a35dc 100644 --- a/Core/src/Geometry/TrapezoidVolumeBounds.cpp +++ b/Core/src/Geometry/TrapezoidVolumeBounds.cpp @@ -127,7 +127,7 @@ void TrapezoidVolumeBounds::buildSurfaceBounds() { get(eHalfLengthXnegY), get(eHalfLengthXposY), get(eHalfLengthY)); m_faceAlphaRectangleBounds = std::make_shared( - get(eHalfLengthY) / cos(get(eAlpha) - std::numbers::pi / 2., + get(eHalfLengthY) / cos(get(eAlpha) - std::numbers::pi / 2.), get(eHalfLengthZ)); m_faceBetaRectangleBounds = std::make_shared( 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 ce4f4d5525a..7db63d87d71 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 " From 2f3ef6af7df6bc0de5ea5e285d940b9fb35151a9 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 24 Oct 2024 11:07:12 +0200 Subject: [PATCH 05/16] Tests --- Tests/Benchmarks/RayFrustumBenchmark.cpp | 19 +-- Tests/Benchmarks/SolenoidFieldBenchmark.cpp | 4 +- .../SurfaceIntersectionBenchmark.cpp | 8 +- .../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 | 33 ++--- .../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 | 3 +- .../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/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 | 9 +- .../Core/Propagator/PropagatorTests.cpp | 39 +++--- .../Core/Seeding/BinnedGroupTest.cpp | 5 +- .../UnitTests/Core/Seeding/PathSeederTest.cpp | 4 +- .../Core/Surfaces/AlignmentHelperTests.cpp | 7 +- .../Core/Surfaces/ConeBoundsTests.cpp | 103 ++++++++------- .../Core/Surfaces/ConeSurfaceTests.cpp | 105 ++++++++-------- .../Core/Surfaces/CylinderBoundsTests.cpp | 71 ++++++----- .../Core/Surfaces/CylinderSurfaceTests.cpp | 114 +++++++++-------- .../Core/Surfaces/DiscSurfaceTests.cpp | 119 ++++++++++-------- .../Core/Surfaces/EllipseBoundsTests.cpp | 76 +++++------ .../Core/Surfaces/LineSurfaceTests.cpp | 3 +- .../Core/Surfaces/PlaneSurfaceTests.cpp | 10 +- .../Core/Surfaces/RadialBoundsTests.cpp | 62 +++++---- .../Core/Surfaces/SurfaceArrayTests.cpp | 24 ++-- .../Surfaces/SurfaceIntersectionTests.cpp | 3 +- .../SurfaceLocalToGlobalRoundtripTests.cpp | 12 +- .../Core/Surfaces/VerticesHelperTests.cpp | 18 ++- .../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 | 110 ++++++++-------- .../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 ++++++++----- .../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 +- 110 files changed, 1343 insertions(+), 1009 deletions(-) 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/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..0e9c232afc4 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,10 @@ 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 == -std::numbers::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 +103,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 +130,10 @@ 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 == -std::numbers::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 +153,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 +175,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 +199,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 +222,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 +247,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 +268,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 +282,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 +303,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..20bab89c4b6 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; 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 514da1ddd74..25fa1f56727 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 @@ -131,7 +132,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; @@ -316,7 +318,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/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 b9842b55420..1758443c673 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 @@ -429,8 +430,8 @@ 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])[eBoundTheta] = -M_PI_2; + std::get(cmps[0])[eBoundTheta] = std::numbers::pi / 2.; + std::get(cmps[1])[eBoundTheta] = -std::numbers::pi / 2.; std::get(cmps[0])[eBoundQOverP] = 1.0; std::get(cmps[1])[eBoundQOverP] = 1.0; @@ -540,8 +541,8 @@ 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])[eBoundTheta] = -M_PI_2; + std::get(cmps[0])[eBoundTheta] = std::numbers::pi / 2.; + 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/AlignmentHelperTests.cpp b/Tests/UnitTests/Core/Surfaces/AlignmentHelperTests.cpp index 437db0f30cf..3688d49a28b 100644 --- a/Tests/UnitTests/Core/Surfaces/AlignmentHelperTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/AlignmentHelperTests.cpp @@ -14,6 +14,7 @@ #include #include +#include #include namespace Acts::Test { @@ -23,9 +24,9 @@ namespace Acts::Test { BOOST_AUTO_TEST_CASE(alignment_helper_test) { // (a) Test with non-identity rotation matrix // Rotation angle parameters - const double alpha = M_PI; - const double beta = 0; - const double gamma = M_PI / 2; + const double alpha = std::numbers::pi; + const double beta = 0.; + const double gamma = std::numbers::pi / 2.; // rotation around x axis AngleAxis3 rotX(alpha, Vector3(1., 0., 0.)); // rotation around y axis diff --git a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp index 887a14391c5..02ee3639482 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp @@ -17,43 +17,53 @@ #include #include #include +#include #include #include -/* Note on nomenclature: - alpha = cone opening half angle - z is the axis of symmetry - zmin, zmax define limits for truncated cone - phi is clock angle around cone, with x axis corresponding to phi=0 - Cone segments may be defined with the avphi (central position of segment) and - halfphi (extent in phi of cone segment either side of the avphi) - Local coords are z, rphi -*/ +// Note on nomenclature: +// - alpha = cone opening half angle +// - z is the axis of symmetry +// - zmin, zmax define limits for truncated cone +// - phi is clock angle around cone, with x axis corresponding to phi=0 +// - Cone segments may be defined with the avphi (central position of segment) +// and halfphi (extent in phi of cone segment either side of the avphi) +// - Local coords are z, rphi + namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) -/// Unit test for creating compliant/non-compliant ConeBounds object +const double alpha = std::numbers::pi / 8.; +const double zMin = 3.; +const double zMax = 6.; +const double halfPhi = std::numbers::pi / 4.; +const double averagePhi = 0.; +const bool symmetric = false; + +// Unit test for creating compliant/non-compliant ConeBounds object BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) { // test default construction // ConeBounds defaultConstructedConeBounds; // deleted - double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0), - averagePhi(0.); - const bool symmetric(false); + BOOST_TEST_CHECKPOINT("Four parameter constructor (last two at default)"); ConeBounds defaultConeBounds(alpha, symmetric); BOOST_CHECK_EQUAL(defaultConeBounds.type(), SurfaceBounds::eCone); + BOOST_TEST_CHECKPOINT("Four parameter constructor"); ConeBounds fourParameterConstructed(alpha, symmetric, halfPhi, averagePhi); BOOST_CHECK_EQUAL(fourParameterConstructed.type(), SurfaceBounds::eCone); + BOOST_TEST_CHECKPOINT("Five parameter constructor (last two at default)"); ConeBounds defaulted5ParamConeBounds(alpha, zMin, zMax); BOOST_CHECK_EQUAL(defaulted5ParamConeBounds.type(), SurfaceBounds::eCone); + BOOST_TEST_CHECKPOINT("Five parameter constructor)"); ConeBounds fiveParamConstructedConeBounds(alpha, zMin, zMax, halfPhi, averagePhi); BOOST_CHECK_EQUAL(fiveParamConstructedConeBounds.type(), SurfaceBounds::eCone); + BOOST_TEST_CHECKPOINT("Copy constructor"); ConeBounds copyConstructedConeBounds(fiveParamConstructedConeBounds); BOOST_CHECK_EQUAL(copyConstructedConeBounds, fiveParamConstructedConeBounds); @@ -61,73 +71,72 @@ BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) { // Streaning and recreation test BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) { - double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0), - averagePhi(0.); - // const bool symmetric(false); ConeBounds original(alpha, zMin, zMax, halfPhi, averagePhi); auto valvector = original.values(); std::array values{}; std::copy_n(valvector.begin(), ConeBounds::eSize, values.begin()); ConeBounds recreated(values); + BOOST_CHECK_EQUAL(recreated, original); } // Unit tests for AnnulusBounds exception throwing BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { - double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0), - averagePhi(0.); - // Exception for opening angle smaller 0 BOOST_CHECK_THROW(ConeBounds(-alpha, zMin, zMax, halfPhi, averagePhi), std::logic_error); - // Exception for opening angle bigger M_PI - BOOST_CHECK_THROW(ConeBounds(M_PI, zMin, zMax, halfPhi, averagePhi), - std::logic_error); + + // Exception for opening angle bigger std::numbers::pi + BOOST_CHECK_THROW( + ConeBounds(std::numbers::pi, zMin, zMax, halfPhi, averagePhi), + std::logic_error); + // Exception for swapped zMin and zMax BOOST_CHECK_THROW(ConeBounds(alpha, zMax, zMin, halfPhi, averagePhi), std::logic_error); + // Exception for negative half sector phi BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, -halfPhi, averagePhi), std::logic_error); + // Exception for out of range phi positioning - BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, halfPhi, 2 * M_PI), - std::logic_error); + BOOST_CHECK_THROW( + ConeBounds(alpha, zMin, zMax, halfPhi, 2 * std::numbers::pi), + std::logic_error); } -/// Unit tests for properties of ConeBounds object +// Unit tests for properties of ConeBounds object BOOST_AUTO_TEST_CASE(ConeBoundsProperties) { - double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0), - averagePhi(0.); - // const bool symmetric(false); const Vector2 origin(0, 0); const Vector2 somewhere(4., 4.); ConeBounds coneBoundsObject(alpha, zMin, zMax, halfPhi, averagePhi); - // - /// test for type (redundant) + + // test for type (redundant) BOOST_CHECK_EQUAL(coneBoundsObject.type(), SurfaceBounds::eCone); - // - /// test for inside + + // test for inside BOOST_CHECK(!coneBoundsObject.inside(origin)); - // - /// test for r + + // test for r CHECK_CLOSE_REL(coneBoundsObject.r(zMin), zMin * std::tan(alpha), 1e-6); - // - /// test for tanAlpha + + // test for tanAlpha CHECK_CLOSE_REL(coneBoundsObject.tanAlpha(), std::tan(alpha), 1e-6); - // - /// test for alpha + + // test for alpha CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eAlpha), alpha, 1e-6); - // - /// test for minZ + + // test for minZ CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMinZ), zMin, 1e-6); - // - /// test for maxZ + + // test for maxZ CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMaxZ), zMax, 1e-6); - // - /// test for averagePhi + + // test for averagePhi CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eHalfPhiSector), halfPhi, 1e-6); - /// test for dump + + // test for dump boost::test_tools::output_test_stream dumpOuput; coneBoundsObject.toStream(dumpOuput); BOOST_CHECK(dumpOuput.is_equal( @@ -137,12 +146,10 @@ BOOST_AUTO_TEST_CASE(ConeBoundsProperties) { // Unit test for testing ConeBounds assignment BOOST_AUTO_TEST_CASE(ConeBoundsAssignment) { - double alpha(M_PI / 8.0), zMin(3.), zMax(6.), halfPhi(M_PI / 4.0), - averagePhi(0.); - // const bool symmetric(false); ConeBounds originalConeBounds(alpha, zMin, zMax, halfPhi, averagePhi); ConeBounds assignedConeBounds(0.1, 2.3, 4.5, 1.2, 2.1); assignedConeBounds = originalConeBounds; + BOOST_CHECK_EQUAL(assignedConeBounds, originalConeBounds); } diff --git a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp index e994d2dbc5a..18fa0e93410 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace Acts::Test { @@ -38,11 +39,14 @@ BOOST_AUTO_TEST_SUITE(ConeSurfaces) BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { // ConeSurface default constructor is deleted // - /// Constructor with transform, alpha and symmetry - /// indicator - double alpha{M_PI / 8.}, halfPhiSector{M_PI / 16.}, zMin{1.0}, zMax{10.}; - bool symmetric(false); - Translation3 translation{0., 1., 2.}; + // Constructor with transform, alpha and symmetry indicator + const double alpha = std::numbers::pi / 8.; + const double halfPhiSector = std::numbers::pi / 16.; + const double zMin = 1.; + const double zMax = 10.; + const bool symmetric = false; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); BOOST_CHECK_EQUAL( Surface::makeShared(Transform3::Identity(), alpha, symmetric) @@ -51,60 +55,60 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, alpha, symmetric)->type(), Surface::Cone); - // - /// Constructor with transform pointer, alpha,z min and max, halfPhiSector + + // Constructor with transform pointer, alpha,z min and max, halfPhiSector BOOST_CHECK_EQUAL(Surface::makeShared(pTransform, alpha, zMin, zMax, halfPhiSector) ->type(), Surface::Cone); - /// Constructor with transform and ConeBounds pointer - // ConeBounds (double alpha, double zmin, double zmax, double halfphi=M_PI, - // double avphi=0.) + // Constructor with transform and ConeBounds pointer + // ConeBounds (double alpha, double zmin, double zmax, double + // halfphi=std::numbers::pi, double avphi=0.) auto pConeBounds = std::make_shared(alpha, zMin, zMax, halfPhiSector, 0.); BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, pConeBounds)->type(), Surface::Cone); - // - // - /// Copy constructor + + // Copy constructor auto coneSurfaceObject = Surface::makeShared(pTransform, alpha, symmetric); auto copiedConeSurface = Surface::makeShared(*coneSurfaceObject); BOOST_CHECK_EQUAL(copiedConeSurface->type(), Surface::Cone); BOOST_CHECK(*copiedConeSurface == *coneSurfaceObject); - // - /// Copied and transformed + + // Copied and transformed auto copiedTransformedConeSurface = Surface::makeShared( tgContext, *coneSurfaceObject, pTransform); BOOST_CHECK_EQUAL(copiedTransformedConeSurface->type(), Surface::Cone); - /// Construct with nullptr bounds + // Construct with nullptr bounds BOOST_CHECK_THROW(auto nullBounds = Surface::makeShared( Transform3::Identity(), nullptr), AssertionFailureException); } -// + /// Unit test for testing ConeSurface properties BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { /// Test clone method - double alpha{M_PI / 8.} /*,halfPhiSector{M_PI/16.}, zMin{1.0}, zMax{10.}*/; - bool symmetric(false); - Translation3 translation{0., 1., 2.}; + const double alpha = std::numbers::pi / 8.; + const bool symmetric = false; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); auto coneSurfaceObject = Surface::makeShared(pTransform, alpha, symmetric); - // + /// Test type (redundant) BOOST_CHECK_EQUAL(coneSurfaceObject->type(), Surface::Cone); - // + /// Test binningPosition Vector3 binningPosition{0., 1., 2.}; CHECK_CLOSE_ABS( coneSurfaceObject->binningPosition(tgContext, BinningValue::binPhi), binningPosition, 1e-6); - // + /// Test referenceFrame Vector3 globalPosition{2.0, 2.0, 2.0}; Vector3 momentum{1.e6, 1.e6, 1.e6}; @@ -114,45 +118,45 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { CHECK_CLOSE_OR_SMALL( coneSurfaceObject->referenceFrame(tgContext, globalPosition, momentum), expectedFrame, 1e-6, 1e-9); - // + /// Test normal, given 3D position Vector3 origin{0., 0., 0.}; Vector3 normal3D = {0., -1., 0.}; CHECK_CLOSE_ABS(coneSurfaceObject->normal(tgContext, origin), normal3D, 1e-6); - // + /// Test normal given 2D rphi position - Vector2 positionPiBy2(1.0, M_PI / 2.); + Vector2 positionPiBy2(1., std::numbers::pi / 2.); Vector3 normalAtPiBy2{0.0312768, 0.92335, -0.382683}; CHECK_CLOSE_OR_SMALL(coneSurfaceObject->normal(tgContext, positionPiBy2), normalAtPiBy2, 1e-2, 1e-9); - // + /// Test rotational symmetry axis Vector3 symmetryAxis{0., 0., 1.}; CHECK_CLOSE_ABS(coneSurfaceObject->rotSymmetryAxis(tgContext), symmetryAxis, 1e-6); - // + /// Test bounds BOOST_CHECK_EQUAL(coneSurfaceObject->bounds().type(), SurfaceBounds::eCone); - // + /// Test localToGlobal - Vector2 localPosition{1.0, M_PI / 2.0}; + Vector2 localPosition{1., std::numbers::pi / 2.}; globalPosition = coneSurfaceObject->localToGlobal(tgContext, localPosition, momentum); // std::cout<globalToLocal(tgContext, globalPosition, momentum) .value(); // std::cout<isOnSurface( @@ -164,11 +168,11 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { CHECK_CLOSE_REL(coneSurfaceObject->pathCorrection(tgContext, offSurface, momentum.normalized()), 0.40218866453252877, 0.01); - // + /// Test name BOOST_CHECK_EQUAL(coneSurfaceObject->name(), std::string("Acts::ConeSurface")); - // + /// Test dump // TODO 2017-04-12 msmk: check how to correctly check output // boost::test_tools::output_test_stream dumpOuput; @@ -185,19 +189,20 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { } BOOST_AUTO_TEST_CASE(ConeSurfaceEqualityOperators) { - double alpha{M_PI / 8.} /*, halfPhiSector{M_PI/16.}, zMin{1.0}, zMax{10.}*/; - bool symmetric(false); - Translation3 translation{0., 1., 2.}; + const double alpha = std::numbers::pi / 8.; + const bool symmetric = false; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); auto coneSurfaceObject = Surface::makeShared(pTransform, alpha, symmetric); - // + auto coneSurfaceObject2 = Surface::makeShared(pTransform, alpha, symmetric); - // + /// Test equality operator BOOST_CHECK(*coneSurfaceObject == *coneSurfaceObject2); - // + BOOST_TEST_CHECKPOINT( "Create and then assign a ConeSurface object to the existing one"); /// Test assignment @@ -209,9 +214,11 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceEqualityOperators) { } BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { - double alpha{M_PI / 8.}, zMin{0.}, zMax{10.}; - - Translation3 translation{0., 0., 0.}; + const double alpha = std::numbers::pi / 8.; + const double halfPhiSector = std::numbers::pi / 8.; // != pi/16 + const double zMin = 0.; // != 1. + const double zMax = 10.; + const Translation3 translation{0., 0., 0.}; // != {0., 1., 2.} // Testing a Full cone auto pTransform = Transform3(translation); @@ -238,7 +245,6 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { s_onSurfaceTolerance); // Now a sector - double halfPhiSector = M_PI / 8.; pConeBounds = std::make_shared(alpha, zMin, zMax, halfPhiSector, 0.); pCone = Surface::makeShared(pTransform, pConeBounds); @@ -256,9 +262,10 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { /// Unit test for testing ConeSurface alignment derivatives BOOST_AUTO_TEST_CASE(ConeSurfaceAlignment) { - double alpha{M_PI / 8.}; - bool symmetric(false); - Translation3 translation{0., 1., 2.}; + const double alpha = std::numbers::pi / 8.; + const bool symmetric = false; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); auto coneSurfaceObject = Surface::makeShared(pTransform, alpha, symmetric); @@ -279,7 +286,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceAlignment) { globalPosition); // Check if the result is as expected ActsMatrix<2, 3> expLoc3DToLocBound = ActsMatrix<2, 3>::Zero(); - expLoc3DToLocBound << -1, 0, M_PI / 2. * std::tan(alpha), 0, 0, 1; + expLoc3DToLocBound << -1, 0, std::numbers::pi / 2. * std::tan(alpha), 0, 0, 1; CHECK_CLOSE_ABS(loc3DToLocBound, expLoc3DToLocBound, 1e-10); } diff --git a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp index 88636494152..71192421737 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -29,18 +30,25 @@ BOOST_AUTO_TEST_SUITE(Surfaces) BOOST_AUTO_TEST_CASE(CylinderBoundsConstruction) { /// test default construction // CylinderBounds defaultConstructedCylinderBounds; // deleted - double radius(0.5), halfz(10.), halfphi(M_PI / 2.0), averagePhi(M_PI / 2.0), - minBevelZ(-M_PI / 4), maxBevelZ(M_PI / 6); + const double radius = 0.5; + const double halfz = 10.; + const double halfphi = std::numbers::pi / 2.; + const double averagePhi = std::numbers::pi / 2.; + const double bevelMinZ = -std::numbers::pi / 4.; + const double bevelMaxZ = std::numbers::pi / 6.; + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz).type(), SurfaceBounds::eCylinder); BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, halfphi).type(), SurfaceBounds::eCylinder); BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, halfphi, averagePhi).type(), SurfaceBounds::eCylinder); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, M_PI, 0., minBevelZ).type(), - SurfaceBounds::eCylinder); BOOST_CHECK_EQUAL( - CylinderBounds(radius, halfz, M_PI, 0., minBevelZ, maxBevelZ).type(), + CylinderBounds(radius, halfz, std::numbers::pi, 0., bevelMinZ).type(), + SurfaceBounds::eCylinder); + BOOST_CHECK_EQUAL( + CylinderBounds(radius, halfz, std::numbers::pi, 0., bevelMinZ, bevelMaxZ) + .type(), SurfaceBounds::eCylinder); // /// test copy construction; @@ -52,7 +60,9 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsConstruction) { BOOST_AUTO_TEST_CASE(CylinderBoundsRecreation) { /// test default construction // CylinderBounds defaultConstructedCylinderBounds; // deleted - double radius(0.5), halfz(10.); + const double radius = 0.5; + const double halfz = 10.; + // Test construction with radii and default sector auto original = CylinderBounds(radius, halfz); auto valvector = original.values(); @@ -63,7 +73,10 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsRecreation) { } BOOST_AUTO_TEST_CASE(CylinderBoundsException) { - double radius(0.5), halfz(10.), halfphi(M_PI / 2.0), averagePhi(M_PI / 2.0); + const double radius = 0.5; + const double halfz = 10.; + const double halfphi = std::numbers::pi / 2.; + const double averagePhi = std::numbers::pi / 2.; // Negative radius BOOST_CHECK_THROW(CylinderBounds(-radius, halfz, halfphi, averagePhi), @@ -89,26 +102,26 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsException) { /// Unit tests for CylinderBounds properties BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { // CylinderBounds object of radius 0.5 and halfz 20 - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - double halfphi(M_PI / 4.0); - double averagePhi(0.0); - double bevelMinZ(M_PI / 4); - double bevelMaxZ(M_PI / 6); - CylinderBounds cylinderBoundsObject(nominalRadius, nominalHalfLength); - CylinderBounds cylinderBoundsSegment(nominalRadius, nominalHalfLength, - halfphi, averagePhi); - CylinderBounds cylinderBoundsBeveledObject(nominalRadius, nominalHalfLength, - M_PI, 0., bevelMinZ, bevelMaxZ); + const double radius = 0.5; + const double halfz = 20.; // != 10. + const double halfphi = std::numbers::pi / 4.; // != pi/2 + const double averagePhi = 0.; // != pi/2 + const double bevelMinZ = std::numbers::pi / 4.; // != -pi/4 + const double bevelMaxZ = std::numbers::pi / 6.; + + CylinderBounds cylinderBoundsObject(radius, halfz); + CylinderBounds cylinderBoundsSegment(radius, halfz, halfphi, averagePhi); + CylinderBounds cylinderBoundsBeveledObject(radius, halfz, std::numbers::pi, + 0., bevelMinZ, bevelMaxZ); /// test for type() BOOST_CHECK_EQUAL(cylinderBoundsObject.type(), SurfaceBounds::eCylinder); /// test for inside(), 2D coords are r or phi ,z? : needs clarification const Vector2 origin{0., 0.}; - const Vector2 atPiBy2{M_PI / 2., 0.0}; - const Vector2 atPi{M_PI, 0.0}; - const Vector2 beyondEnd{0, 30.0}; + const Vector2 atPiBy2{std::numbers::pi / 2., 0.}; + const Vector2 atPi{std::numbers::pi, 0.}; + const Vector2 beyondEnd{0, 30.}; const Vector2 unitZ{0.0, 1.0}; const Vector2 unitPhi{1.0, 0.0}; const Vector2 withinBevelMin{0.5, -20.012}; @@ -117,6 +130,7 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { BoundaryTolerance::AbsoluteBound(0.1, 0.1); const BoundaryTolerance lessTolerance = BoundaryTolerance::AbsoluteBound(0.01, 0.01); + BOOST_CHECK(cylinderBoundsObject.inside(atPiBy2, tolerance)); BOOST_CHECK(!cylinderBoundsSegment.inside(unitPhi, tolerance)); BOOST_CHECK(cylinderBoundsObject.inside(origin, tolerance)); @@ -128,8 +142,7 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { !cylinderBoundsBeveledObject.inside(outsideBevelMin, lessTolerance)); /// test for r() - CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eR), nominalRadius, - 1e-6); + CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eR), radius, 1e-6); /// test for averagePhi CHECK_CLOSE_OR_SMALL(cylinderBoundsObject.get(CylinderBounds::eAveragePhi), @@ -141,8 +154,8 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { 1e-6); // fail /// test for halflengthZ (NOTE: Naming violation) - CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eHalfLengthZ), - nominalHalfLength, 1e-6); + CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eHalfLengthZ), halfz, + 1e-6); /// test for bevelMinZ/MaxZ CHECK_CLOSE_REL(cylinderBoundsBeveledObject.get(CylinderBounds::eBevelMinZ), @@ -160,11 +173,13 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { } /// Unit test for testing CylinderBounds assignment BOOST_AUTO_TEST_CASE(CylinderBoundsAssignment) { - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - CylinderBounds cylinderBoundsObject(nominalRadius, nominalHalfLength); + const double radius = 0.5; + const double halfz = 20.; // != 10. + + CylinderBounds cylinderBoundsObject(radius, halfz); CylinderBounds assignedCylinderBounds(10.5, 6.6); assignedCylinderBounds = cylinderBoundsObject; + BOOST_CHECK_EQUAL(assignedCylinderBounds.get(CylinderBounds::eR), cylinderBoundsObject.get(CylinderBounds::eR)); BOOST_CHECK_EQUAL(assignedCylinderBounds, cylinderBoundsObject); diff --git a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp index 1bc3b41db06..09ba3895177 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -57,13 +58,16 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceConstruction) { // CylinderSurface default constructor is deleted // /// Constructor with transform, radius and halfZ - double radius(1.0), halfZ(10.), halfPhiSector(M_PI / 8.); - Translation3 translation{0., 1., 2.}; + const double radius = 1.; + const double halfZ = 10.; + const double halfPhiSector = std::numbers::pi / 8.; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, radius, halfZ)->type(), Surface::Cylinder); - // + /// Constructor with transform pointer, radius, halfZ and halfPhiSector BOOST_CHECK_EQUAL(Surface::makeShared(pTransform, radius, halfZ, halfPhiSector) @@ -75,8 +79,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceConstruction) { BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, pCylinderBounds)->type(), Surface::Cylinder); - // - // + /// Copy constructor auto cylinderSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); @@ -84,7 +87,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceConstruction) { Surface::makeShared(*cylinderSurfaceObject); BOOST_CHECK_EQUAL(copiedCylinderSurface->type(), Surface::Cylinder); BOOST_CHECK(*copiedCylinderSurface == *cylinderSurfaceObject); - // + /// Copied and transformed auto copiedTransformedCylinderSurface = Surface::makeShared( testContext, *cylinderSurfaceObject, pTransform); @@ -96,33 +99,36 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceConstruction) { Transform3::Identity(), nullptr), AssertionFailureException); } -// + /// Unit test for testing CylinderSurface properties BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { /// Test clone method - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; + const double radius = 1.; + const double halfZ = 10.; + // const double halfPhiSector = std::numbers::pi / 8.; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); auto cylinderSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); - // + /// Test type (redundant) BOOST_CHECK_EQUAL(cylinderSurfaceObject->type(), Surface::Cylinder); - // + /// Test binningPosition Vector3 binningPosition{0., 1., 2.}; CHECK_CLOSE_ABS( cylinderSurfaceObject->binningPosition(testContext, BinningValue::binPhi), binningPosition, 1e-9); - // + /// Test referenceFrame - double rootHalf = std::sqrt(0.5); - Vector3 globalPosition{rootHalf, 1. - rootHalf, 0.}; - Vector3 globalPositionZ{rootHalf, 1. - rootHalf, 2.0}; + const double invSqrt2 = 1. / std::numbers::sqrt2; + Vector3 globalPosition{invSqrt2, 1. - invSqrt2, 0.}; + Vector3 globalPositionZ{invSqrt2, 1. - invSqrt2, 2.0}; Vector3 momentum{15., 15., 15.}; Vector3 momentum2{6.6, -3., 2.}; RotationMatrix3 expectedFrame; - expectedFrame << rootHalf, 0., rootHalf, rootHalf, 0., -rootHalf, 0., 1., 0.; + expectedFrame << invSqrt2, 0., invSqrt2, invSqrt2, 0., -invSqrt2, 0., 1., 0.; // check without shift CHECK_CLOSE_OR_SMALL(cylinderSurfaceObject->referenceFrame( testContext, globalPosition, momentum), @@ -131,53 +137,52 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { CHECK_CLOSE_OR_SMALL(cylinderSurfaceObject->referenceFrame( testContext, globalPositionZ, momentum2), expectedFrame, 1e-6, 1e-9); - // + /// Test normal, given 3D position Vector3 origin{0., 0., 0.}; Vector3 normal3D = {0., -1., 0.}; CHECK_CLOSE_ABS(cylinderSurfaceObject->normal(testContext, origin), normal3D, 1e-9); - Vector3 pos45deg = {rootHalf, 1 + rootHalf, 0.}; - Vector3 pos45degZ = {rootHalf, 1 + rootHalf, 4.}; - Vector3 normal45deg = {rootHalf, rootHalf, 0.}; + Vector3 pos45deg = {invSqrt2, 1 + invSqrt2, 0.}; + Vector3 pos45degZ = {invSqrt2, 1 + invSqrt2, 4.}; + Vector3 normal45deg = {invSqrt2, invSqrt2, 0.}; // test the normal vector CHECK_CLOSE_ABS(cylinderSurfaceObject->normal(testContext, pos45deg), - normal45deg, 1e-6 * rootHalf); + normal45deg, 1e-6 * invSqrt2); // test that the normal vector is independent of z coordinate CHECK_CLOSE_ABS(cylinderSurfaceObject->normal(testContext, pos45degZ), - normal45deg, 1e-6 * rootHalf); - // + normal45deg, 1e-6 * invSqrt2); + /// Test normal given 2D rphi position - Vector2 positionPiBy2(1.0, 0.); + Vector2 positionPiBy2(1., 0.); Vector3 normalAtPiBy2{std::cos(1.), std::sin(1.), 0.}; CHECK_CLOSE_ABS(cylinderSurfaceObject->normal(testContext, positionPiBy2), normalAtPiBy2, 1e-9); - // /// Test rotational symmetry axis Vector3 symmetryAxis{0., 0., 1.}; CHECK_CLOSE_ABS(cylinderSurfaceObject->rotSymmetryAxis(testContext), symmetryAxis, 1e-9); - // + /// Test bounds BOOST_CHECK_EQUAL(cylinderSurfaceObject->bounds().type(), SurfaceBounds::eCylinder); - // + /// Test localToGlobal Vector2 localPosition{0., 0.}; globalPosition = cylinderSurfaceObject->localToGlobal( testContext, localPosition, momentum); Vector3 expectedPosition{1, 1, 2}; BOOST_CHECK_EQUAL(globalPosition, expectedPosition); - // + /// Testing globalToLocal localPosition = cylinderSurfaceObject ->globalToLocal(testContext, globalPosition, momentum) .value(); Vector2 expectedLocalPosition{0., 0.}; BOOST_CHECK_EQUAL(localPosition, expectedLocalPosition); - // + /// Test isOnSurface Vector3 offSurface{100, 1, 2}; BOOST_CHECK(cylinderSurfaceObject->isOnSurface( @@ -188,7 +193,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { testContext, offSurface, momentum, BoundaryTolerance::None())); BOOST_CHECK(!cylinderSurfaceObject->isOnSurface(testContext, offSurface, BoundaryTolerance::None())); - // + /// intersection test Vector3 direction{-1., 0, 0}; auto sfIntersection = cylinderSurfaceObject->intersect( @@ -208,16 +213,15 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { BOOST_CHECK_LT(std::abs(pn), std::abs(pa)); BOOST_CHECK_EQUAL(sfIntersection.object(), cylinderSurfaceObject.get()); - // /// Test pathCorrection CHECK_CLOSE_REL(cylinderSurfaceObject->pathCorrection(testContext, offSurface, momentum.normalized()), - std::sqrt(3.), 0.01); - // + std::numbers::sqrt3, 0.01); + /// Test name BOOST_CHECK_EQUAL(cylinderSurfaceObject->name(), std::string("Acts::CylinderSurface")); - // + /// Test dump boost::test_tools::output_test_stream dumpOutput; std::string expected = @@ -232,18 +236,20 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { } BOOST_AUTO_TEST_CASE(CylinderSurfaceEqualityOperators) { - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; + const double radius = 1.; + const double halfZ = 10.; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); auto cylinderSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); - // + auto cylinderSurfaceObject2 = Surface::makeShared(pTransform, radius, halfZ); - // + /// Test equality operator BOOST_CHECK(*cylinderSurfaceObject == *cylinderSurfaceObject2); - // + BOOST_TEST_CHECKPOINT( "Create and then assign a CylinderSurface object to the existing one"); /// Test assignment @@ -257,8 +263,10 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceEqualityOperators) { /// Unit test for testing CylinderSurface properties BOOST_AUTO_TEST_CASE(CylinderSurfaceExtent) { // Some radius and half length - double radius(1.0), halfZ(10.); - Translation3 translation{0., 0., 2.}; + const double radius = 1.; + const double halfZ = 10.; + const Translation3 translation{0., 0., 2.}; // != {0., 1., 2.} + auto pTransform = Transform3(translation); auto cylinderSurface = Surface::makeShared(pTransform, radius, halfZ); @@ -286,8 +294,10 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceExtent) { /// Unit test for testing CylinderSurface alignment derivatives BOOST_AUTO_TEST_CASE(CylinderSurfaceAlignment) { - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; + const double radius = 1.; + const double halfZ = 10.; + const Translation3 translation{0., 1., 2.}; + auto pTransform = Transform3(translation); auto cylinderSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); @@ -322,8 +332,8 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceBinningPosition) { double halfZ = 330; double averagePhi = 0.1; - auto bounds = - std::make_shared(r, halfZ, M_PI / 8, averagePhi); + auto bounds = std::make_shared(r, halfZ, std::numbers::pi / 8, + averagePhi); auto cylinder = Acts::Surface::makeShared(trf, bounds); Vector3 exp = Vector3{r * std::cos(averagePhi), r * std::sin(averagePhi), 0}; @@ -409,15 +419,15 @@ BOOST_DATA_TEST_CASE(IncompatibleZDirection, // Cylinder with bevel auto cyl4 = Surface::makeShared( - base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm, M_PI, 0, - M_PI / 8.0); + base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm, + std::numbers::pi, 0, std::numbers::pi / 8.); BOOST_CHECK_THROW( cyl->mergedWith(*cyl4, Acts::BinningValue::binZ, false, *logger), SurfaceMergingException); auto cyl5 = Surface::makeShared( - base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm, M_PI, 0, 0, - M_PI / 8.0); + base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm, + std::numbers::pi, 0, 0, std::numbers::pi / 8.); BOOST_CHECK_THROW( cyl->mergedWith(*cyl5, Acts::BinningValue::binZ, false, *logger), SurfaceMergingException); @@ -605,7 +615,7 @@ BOOST_DATA_TEST_CASE(RPhiDirection, BOOST_CHECK_SMALL( detail::difference_periodic(bounds.get(CylinderBounds::eAveragePhi), - a(85_degree), 2 * M_PI), + a(85_degree), 2 * std::numbers::pi), 1e-6); BOOST_CHECK_CLOSE(bounds.get(CylinderBounds::eHalfPhiSector), 55_degree, 0.1); @@ -629,7 +639,7 @@ BOOST_DATA_TEST_CASE(RPhiDirection, BOOST_CHECK_SMALL(detail::difference_periodic( cyl45->bounds().get(CylinderBounds::eAveragePhi), - a(180_degree), 2 * M_PI), + a(180_degree), 2 * std::numbers::pi), 1e-6); BOOST_CHECK_CLOSE(cyl45->bounds().get(CylinderBounds::eHalfPhiSector), 30_degree, 1e-6); @@ -656,7 +666,7 @@ BOOST_DATA_TEST_CASE(RPhiDirection, BOOST_CHECK_SMALL(detail::difference_periodic( cyl67->bounds().get(CylinderBounds::eAveragePhi), - a(180_degree), 2 * M_PI), + a(180_degree), 2 * std::numbers::pi), 1e-6); BOOST_CHECK_CLOSE(cyl67->bounds().get(CylinderBounds::eHalfPhiSector), 180_degree, 1e-6); diff --git a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp index 3012f71217e..ed8a229c340 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -55,28 +56,29 @@ BOOST_AUTO_TEST_SUITE(Surfaces) BOOST_AUTO_TEST_CASE(DiscSurfaceConstruction) { // default constructor is deleted // scaffolding... - double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.); - // + const double rMin = 1.; + const double rMax = 5.; + const double halfPhiSector = std::numbers::pi / 8.; + /// Test DiscSurface constructor with default halfPhiSector BOOST_CHECK_NO_THROW( Surface::makeShared(Transform3::Identity(), rMin, rMax)); - // + /// Test DiscSurface constructor with a transform specified Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); BOOST_CHECK_NO_THROW( Surface::makeShared(pTransform, rMin, rMax, halfPhiSector)); - // + /// Copy constructed DiscSurface auto anotherDiscSurface = Surface::makeShared(pTransform, rMin, rMax, halfPhiSector); // N.B. Just using // BOOST_CHECK_NO_THROW(Surface::makeShared(anotherDiscSurface)) - // tries to call - // the (deleted) default constructor. + // tries to call the (deleted) default constructor. auto copiedSurface = Surface::makeShared(*anotherDiscSurface); BOOST_TEST_MESSAGE("Copy constructed DiscSurface ok"); - // + /// Copied and transformed DiscSurface BOOST_CHECK_NO_THROW(Surface::makeShared( tgContext, *anotherDiscSurface, pTransform)); @@ -90,22 +92,26 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceConstruction) { /// Unit tests of all named methods BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { - Vector3 origin3D{0, 0, 0}; - double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.); + const double rMin = 1.; + const double rMax = 5.; + const double halfPhiSector = std::numbers::pi / 8.; + + const Vector3 origin3D{0, 0, 0}; + auto discSurfaceObject = Surface::makeShared( Transform3::Identity(), rMin, rMax, halfPhiSector); - // + /// Test type BOOST_CHECK_EQUAL(discSurfaceObject->type(), Surface::Disc); - // + /// Test normal, no local position specified Vector3 zAxis{0, 0, 1}; BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext), zAxis); - // + /// Test normal, local position specified Vector2 lpos(2.0, 0.05); BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext, lpos), zAxis); - // + /// Test binningPosition // auto binningPosition= // discSurfaceObject.binningPosition(BinningValue::BinningValue::binRPhi ); @@ -113,32 +119,30 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { BOOST_CHECK_EQUAL( discSurfaceObject->binningPosition(tgContext, BinningValue::binRPhi), origin3D); - // + /// Test bounds BOOST_CHECK_EQUAL(discSurfaceObject->bounds().type(), SurfaceBounds::eDisc); - // + Vector3 ignoredMomentum{0., 0., 0.}; /// Test isOnSurface() Vector3 point3DNotInSector{0.0, 1.2, 0}; Vector3 point3DOnSurface{1.2, 0.0, 0}; - BOOST_CHECK(!discSurfaceObject->isOnSurface( - tgContext, point3DNotInSector, ignoredMomentum, - BoundaryTolerance::None())); // passes - BOOST_CHECK( - !discSurfaceObject->isOnSurface(tgContext, point3DNotInSector, - BoundaryTolerance::None())); // passes + BOOST_CHECK(!discSurfaceObject->isOnSurface(tgContext, point3DNotInSector, + ignoredMomentum, + BoundaryTolerance::None())); + BOOST_CHECK(!discSurfaceObject->isOnSurface(tgContext, point3DNotInSector, + BoundaryTolerance::None())); BOOST_CHECK(discSurfaceObject->isOnSurface( - tgContext, point3DOnSurface, ignoredMomentum, - BoundaryTolerance::None())); // passes - BOOST_CHECK( - discSurfaceObject->isOnSurface(tgContext, point3DOnSurface, - BoundaryTolerance::None())); // passes - // + tgContext, point3DOnSurface, ignoredMomentum, BoundaryTolerance::None())); + BOOST_CHECK(discSurfaceObject->isOnSurface(tgContext, point3DOnSurface, + BoundaryTolerance::None())); + /// Test localToGlobal Vector3 returnedPosition{10.9, 8.7, 6.5}; Vector3 expectedPosition{1.2, 0, 0}; Vector2 rPhiOnDisc{1.2, 0.0}; - Vector2 rPhiNotInSector{1.2, M_PI}; // outside sector at Phi=0, +/- pi/8 + Vector2 rPhiNotInSector{ + 1.2, std::numbers::pi}; // outside sector at Phi=0, +/- pi/8 returnedPosition = discSurfaceObject->localToGlobal(tgContext, rPhiOnDisc, ignoredMomentum); CHECK_CLOSE_ABS(returnedPosition, expectedPosition, 1e-6); @@ -162,51 +166,51 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { discSurfaceObject ->globalToLocal(tgContext, point3DNotInSector, ignoredMomentum) .value(); - // + Vector3 pointOutsideR{0.0, 100., 0}; returnedLocalPosition = discSurfaceObject ->globalToLocal(tgContext, pointOutsideR, ignoredMomentum) .value(); - // + /// Test localPolarToCartesian - Vector2 rPhi1_1{std::sqrt(2.), M_PI / 4.}; + Vector2 rPhi1_1{std::numbers::sqrt2, std::numbers::pi / 4.}; Vector2 cartesian1_1{1., 1.}; CHECK_CLOSE_REL(discSurfaceObject->localPolarToCartesian(rPhi1_1), cartesian1_1, 1e-6); - // + /// Test localCartesianToPolar CHECK_CLOSE_REL(discSurfaceObject->localCartesianToPolar(cartesian1_1), rPhi1_1, 1e-6); - // + /// Test localPolarToLocalCartesian CHECK_CLOSE_REL(discSurfaceObject->localPolarToLocalCartesian(rPhi1_1), cartesian1_1, 1e-6); - // + /// Test localCartesianToGlobal Vector3 cartesian3D1_1{1., 1., 0.}; CHECK_CLOSE_ABS( discSurfaceObject->localCartesianToGlobal(tgContext, cartesian1_1), cartesian3D1_1, 1e-6); - // + /// Test globalToLocalCartesian CHECK_CLOSE_REL( discSurfaceObject->globalToLocalCartesian(tgContext, cartesian3D1_1), cartesian1_1, 1e-6); - // + /// Test pathCorrection - double projected3DMomentum = std::sqrt(3.) * 1.e6; + double projected3DMomentum = std::numbers::sqrt3 * 1.e6; Vector3 momentum{projected3DMomentum, projected3DMomentum, projected3DMomentum}; Vector3 ignoredPosition = discSurfaceObject->center(tgContext); CHECK_CLOSE_REL(discSurfaceObject->pathCorrection(tgContext, ignoredPosition, momentum.normalized()), - std::sqrt(3), 0.01); - // + std::numbers::sqrt3, 0.01); + /// intersection test - Vector3 globalPosition{1.2, 0.0, -10.}; + Vector3 globalPosition{1.2, 0., -10.}; Vector3 direction{0., 0., 1.}; // must be normalised - Vector3 expected{1.2, 0.0, 0.0}; + Vector3 expected{1.2, 0., 0.}; // intersect is a struct of (Vector3) position, pathLength, distance and // (bool) valid, it's contained in a Surface intersection @@ -223,17 +227,18 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { 1e-9); BOOST_CHECK_EQUAL(sfIntersection.object(), discSurfaceObject.get()); - // /// Test name boost::test_tools::output_test_stream nameOuput; nameOuput << discSurfaceObject->name(); BOOST_CHECK(nameOuput.is_equal("Acts::DiscSurface")); } -// + /// Unit test for testing DiscSurface assignment and equality BOOST_AUTO_TEST_CASE(DiscSurfaceAssignment) { - Vector3 origin3D{0, 0, 0}; - double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.); + const double rMin = 1.; + const double rMax = 5.; + const double halfPhiSector = std::numbers::pi / 8.; + auto discSurfaceObject = Surface::makeShared( Transform3::Identity(), rMin, rMax, halfPhiSector); auto assignedDisc = @@ -245,7 +250,8 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceAssignment) { /// Unit test for testing DiscSurface assignment and equality BOOST_AUTO_TEST_CASE(DiscSurfaceExtent) { - double rMin(1.0), rMax(5.0); + const double rMin = 1.; + const double rMax = 5.; auto pDisc = Surface::makeShared(Transform3::Identity(), 0., rMax); @@ -267,9 +273,9 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceExtent) { s_onSurfaceTolerance); CHECK_CLOSE_ABS(rMax, pDiscExtent.max(BinningValue::binY), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-M_PI, pDiscExtent.min(BinningValue::binPhi), + CHECK_CLOSE_ABS(-std::numbers::pi, pDiscExtent.min(BinningValue::binPhi), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(M_PI, pDiscExtent.max(BinningValue::binPhi), + CHECK_CLOSE_ABS(std::numbers::pi, pDiscExtent.max(BinningValue::binPhi), s_onSurfaceTolerance); auto pRing = @@ -298,7 +304,10 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceExtent) { BOOST_AUTO_TEST_CASE(DiscSurfaceAlignment) { Translation3 translation{0., 1., 2.}; Transform3 transform(translation); - double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.); + const double rMin = 1.; + const double rMax = 5.; + const double halfPhiSector = std::numbers::pi / 8.; + auto discSurfaceObject = Surface::makeShared(transform, rMin, rMax, halfPhiSector); @@ -345,7 +354,8 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) { { // Radial Bounds - auto bounds = std::make_shared(minR, maxR, M_PI / 8, 0.1); + auto bounds = + std::make_shared(minR, maxR, std::numbers::pi / 8, 0.1); auto disc = Acts::Surface::makeShared(trf, bounds); Vector3 bp = disc->binningPosition(tgContext, BinningValue::binR); @@ -410,7 +420,8 @@ BOOST_AUTO_TEST_SUITE(DiscSurfaceMerging) namespace { std::shared_ptr makeDisc(const Transform3& transform, double rmin, - double rmax, double halfPhi = M_PI, + double rmax, + double halfPhi = std::numbers::pi, double avgPhi = 0) { return Surface::makeShared( transform, std::make_shared(rmin, rmax, halfPhi, avgPhi)); @@ -657,7 +668,7 @@ BOOST_DATA_TEST_CASE(PhiDirection, BOOST_CHECK_SMALL( detail::difference_periodic(bounds->get(RadialBounds::eAveragePhi), - a(85_degree), 2 * M_PI), + a(85_degree), 2 * std::numbers::pi), 1e-6); BOOST_CHECK_CLOSE(bounds->get(RadialBounds::eHalfPhiSector), 55_degree, 1e-6); @@ -682,7 +693,7 @@ BOOST_DATA_TEST_CASE(PhiDirection, BOOST_CHECK_SMALL( detail::difference_periodic(bounds45->get(RadialBounds::eAveragePhi), - a(180_degree), 2 * M_PI), + a(180_degree), 2 * std::numbers::pi), 1e-6); BOOST_CHECK_CLOSE(bounds45->get(RadialBounds::eHalfPhiSector), 30_degree, 1e-6); @@ -714,7 +725,7 @@ BOOST_DATA_TEST_CASE(PhiDirection, BOOST_REQUIRE_NE(bounds67, nullptr); BOOST_CHECK_SMALL( detail::difference_periodic(bounds67->get(RadialBounds::eAveragePhi), - a(90_degree), 2 * M_PI), + a(90_degree), 2 * std::numbers::pi), 1e-6); BOOST_CHECK_CLOSE(bounds67->get(RadialBounds::eHalfPhiSector), 180_degree, 1e-6); diff --git a/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp index 7d7391428f3..9ce67b66cff 100644 --- a/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -25,10 +26,15 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) +const double innerRx = 10.; +const double innerRy = 15.; +const double phiSector = std::numbers::pi / 2.; +const double averagePhi = 0.; + /// Unit test for creating compliant/non-compliant EllipseBounds object BOOST_AUTO_TEST_CASE(EllipseBoundsConstruction) { - double innerRx(10.), innerRy(15.), outerRx(25.), outerRy(30.), - phiSector(M_PI / 2.), averagePhi(0.); + const double outerRx = 25.; + const double outerRy = 30.; // test default construction // EllipseBounds defaultConstructedEllipseBounds; //deleted @@ -48,9 +54,9 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsConstruction) { // Streaning and recreation test BOOST_AUTO_TEST_CASE(EllipseBoundsRecreation) { - double innerRx(10.), innerRy(15.), outerRx(25.), outerRy(30.), - phiSector(M_PI / 2.), averagePhi(0.); - // const bool symmetric(false); + const double outerRx = 25.; + const double outerRy = 30.; + EllipseBounds original(innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi); auto valvector = original.values(); @@ -62,8 +68,9 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsRecreation) { // Unit tests for AnnulusBounds exception throwing BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { - double innerRx(10.), innerRy(15.), outerRx(25.), outerRy(30.), - phiSector(M_PI / 2.), averagePhi(0.); + const double outerRx = 25.; + const double outerRy = 30.; + // Exception for innerRx < 0 BOOST_CHECK_THROW( EllipseBounds(-innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi), @@ -108,74 +115,73 @@ BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { /// Unit tests for EllipseBounds properties BOOST_AUTO_TEST_CASE(EllipseBoundsProperties) { - double innerRx(10.), outerRx(15.), innerRy(15.), outerRy(20.), averagePhi(0.), - phiSector(M_PI / 2.); + const double outerRx = 15.; // != 25 + const double outerRy = 20.; // != 30 + /// Test clone EllipseBounds ellipseBoundsObject(innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi); - // + /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(ellipseBoundsObject.type(), SurfaceBounds::eEllipse); - // + // clone already tested - // + /// Test distanceToBoundary - Vector2 origin(0., 0.); - Vector2 outsideBy15(0., 30.); - Vector2 inRectangle(17., 11.); - // + Vector2 origin{0., 0.}; + Vector2 outsideBy15{0., 30.}; + Vector2 inRectangle{17., 11.}; + /// Test rMinX BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eInnerRx), innerRx); - // + /// Test rMinY BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eOuterRx), outerRx); - // + /// Test rMaxX BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eInnerRy), innerRy); - // + /// Test rMaxY BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eOuterRy), outerRy); - // + /// Test averagePhi BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eAveragePhi), averagePhi); - // + /// Test vertices // std::vector expectedVertices{{15, 0}, {0, 20}, {-15, 0}, {0, // -20}}; const auto& actualVertices = ellipseBoundsObject.vertices(4); // BOOST_CHECK_EQUAL_COLLECTIONS(actualVertices.cbegin(), - // actualVertices.cend(), - // expectedVertices.cbegin(), - // expectedVertices.cend()); - // + // actualVertices.cend(), expectedVertices.cbegin(), expectedVertices.cend()); + /// Test boundingBox BOOST_CHECK_EQUAL(ellipseBoundsObject.boundingBox(), RectangleBounds(15., 20.)); - // + /// Test halfPhiSector BOOST_CHECK_EQUAL(ellipseBoundsObject.get(EllipseBounds::eHalfPhiSector), - M_PI / 2.); - // + std::numbers::pi / 2.); + /// Test dump boost::test_tools::output_test_stream dumpOuput; ellipseBoundsObject.toStream(dumpOuput); BOOST_CHECK(dumpOuput.is_equal( "Acts::EllipseBounds: (innerRadius0, outerRadius0, innerRadius1, " "outerRadius1, hPhiSector, averagePhi) = (10.0000000, 15.0000000, " - "15.0000000, " - "20.0000000, 0.0000000, 1.5707963, 0.0000000)")); - // + "15.0000000, 20.0000000, 0.0000000, 1.5707963, 0.0000000)")); + /// Test inside BOOST_CHECK( !ellipseBoundsObject.inside(inRectangle, BoundaryTolerance::None())); - // dont understand why this is so: + // don't understand why this is so: BOOST_CHECK( !ellipseBoundsObject.inside(outsideBy15, BoundaryTolerance::None())); } /// Unit test for testing EllipseBounds assignment BOOST_AUTO_TEST_CASE(EllipseBoundsAssignment) { - double innerRx(10.), outerRx(15.), innerRy(15.), outerRy(20.), averagePhi(0.), - phiSector(M_PI / 2.); + const double outerRx = 15.; // != 25 + const double outerRy = 20.; // != 30 + EllipseBounds ellipseBoundsObject(innerRx, outerRx, innerRy, outerRy, averagePhi, phiSector); EllipseBounds similarlyConstructeEllipseBoundsObject( @@ -183,7 +189,7 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsAssignment) { /// Test operator == BOOST_CHECK_EQUAL(ellipseBoundsObject, similarlyConstructeEllipseBoundsObject); - // + /// Test assignment EllipseBounds assignedEllipseBoundsObject(11., 12., 17., 18., 1.); // object, in some sense diff --git a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp index 71dbf0827de..dd1f7ab6d09 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -282,7 +283,7 @@ BOOST_AUTO_TEST_CASE(LineSurfaceTransformRoundTripEtaStability) { for (double eta : etas) { Vector3 pca = {5, 0, 0}; - Vector3 dir = makeDirectionFromPhiEta(M_PI_2, eta); + Vector3 dir = makeDirectionFromPhiEta(std::numbers::pi / 2., eta); Vector3 pos = pca + dir; auto intersection = surface.intersect(tgContext, pos, dir).closest(); diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index ee91782dca2..c6b8506804b 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -224,9 +225,10 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceEqualityOperators) { /// Unit test for testing PlaneSurface extent via Polyhedron representation BOOST_AUTO_TEST_CASE(PlaneSurfaceExtent) { // First test - non-rotated - static const Transform3 planeZX = AngleAxis3(-0.5 * M_PI, Vector3::UnitX()) * - AngleAxis3(-0.5 * M_PI, Vector3::UnitZ()) * - Transform3::Identity(); + static const Transform3 planeZX = + AngleAxis3(-std::numbers::pi / 2., Vector3::UnitX()) * + AngleAxis3(-std::numbers::pi / 2., Vector3::UnitZ()) * + Transform3::Identity(); double rHx = 2.; double rHy = 4.; @@ -309,7 +311,7 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceAlignment) { auto rBounds = std::make_shared(3., 4.); // Test clone method Translation3 translation{0., 1., 2.}; - double rotationAngle = M_PI_2; + const double rotationAngle = std::numbers::pi / 2.; AngleAxis3 rotation(rotationAngle, Vector3::UnitY()); RotationMatrix3 rotationMat = rotation.toRotationMatrix(); diff --git a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp index b95d9674bee..273462142a0 100644 --- a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -24,30 +25,32 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) +const double rMin = 1.; +const double rMax = 5.; +const double halfPhiSector = std::numbers::pi / 8.; +const double avgPhi = 0.1; + /// Unit tests for RadialBounds constrcuctors BOOST_AUTO_TEST_CASE(RadialBoundsConstruction) { - double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0); // test default construction // RadialBounds defaultConstructedRadialBounds; should be deleted - // + /// Test construction with radii and default sector - BOOST_CHECK_EQUAL(RadialBounds(minRadius, maxRadius).type(), - SurfaceBounds::eDisc); - // + BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax).type(), SurfaceBounds::eDisc); + /// Test construction with radii and sector half angle - BOOST_CHECK_EQUAL(RadialBounds(minRadius, maxRadius, halfPhiSector).type(), + BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax, halfPhiSector).type(), SurfaceBounds::eDisc); - // + /// Copy constructor - RadialBounds original(minRadius, maxRadius); + RadialBounds original(rMin, rMax); RadialBounds copied(original); BOOST_CHECK_EQUAL(copied, original); } // Streaning and recreation test BOOST_AUTO_TEST_CASE(RadialBoundsRecreation) { - double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0), avgPhi(0.1); - RadialBounds original(minRadius, maxRadius, halfPhiSector, avgPhi); + RadialBounds original(rMin, rMax, halfPhiSector, avgPhi); // const bool symmetric(false); auto valvector = original.values(); std::array values{}; @@ -58,40 +61,36 @@ BOOST_AUTO_TEST_CASE(RadialBoundsRecreation) { // Streaning and recreation test BOOST_AUTO_TEST_CASE(RadialBoundsException) { - double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0), avgPhi(0.1); - // Negative inner radius - BOOST_CHECK_THROW(RadialBounds(-minRadius, maxRadius, halfPhiSector, avgPhi), + BOOST_CHECK_THROW(RadialBounds(-rMin, rMax, halfPhiSector, avgPhi), std::logic_error); // Negative outer radius - BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, halfPhiSector, avgPhi), + BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, halfPhiSector, avgPhi), std::logic_error); // Negative inner and outer radius - BOOST_CHECK_THROW(RadialBounds(-minRadius, -maxRadius, halfPhiSector, avgPhi), + BOOST_CHECK_THROW(RadialBounds(-rMin, -rMax, halfPhiSector, avgPhi), std::logic_error); // Swapped radii - BOOST_CHECK_THROW(RadialBounds(maxRadius, minRadius, halfPhiSector, avgPhi), + BOOST_CHECK_THROW(RadialBounds(rMax, rMin, halfPhiSector, avgPhi), std::logic_error); // Out of bound phi sector - BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, -5., avgPhi), - std::logic_error); + BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, -5., avgPhi), std::logic_error); // Out of bound phi position - BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, halfPhiSector, 5.), + BOOST_CHECK_THROW(RadialBounds(rMin, -rMax, halfPhiSector, 5.), std::logic_error); } /// Unit tests for RadialBounds properties BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { - double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0); /// Test type() (redundant; already used in constructor confirmation) - RadialBounds radialBoundsObject(minRadius, maxRadius, halfPhiSector); + RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector); BOOST_CHECK_EQUAL(radialBoundsObject.type(), SurfaceBounds::eDisc); - // + /// Test distanceToBoundary Vector2 outside(30., 0.); Vector2 inSurface(2., 0.0); @@ -103,30 +102,29 @@ BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { dumpOuput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, " "hPhiSector, averagePhi) = (1.0000000, " "5.0000000, 0.3926991, 0.0000000)")); - // + /// Test inside BOOST_CHECK(radialBoundsObject.inside(inSurface, BoundaryTolerance::None())); BOOST_CHECK(!radialBoundsObject.inside(outside, BoundaryTolerance::None())); - // + /// Test rMin - BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMinR), minRadius); - // + BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMinR), rMin); + /// Test rMax - BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), maxRadius); - // + BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), rMax); + /// Test averagePhi (should be a redundant method, this is not configurable) BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.0); - // + /// Test halfPhiSector BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eHalfPhiSector), halfPhiSector); } /// Unit test for testing RadialBounds assignment BOOST_AUTO_TEST_CASE(RadialBoundsAssignment) { - double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0); - RadialBounds radialBoundsObject(minRadius, maxRadius, halfPhiSector); + RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector); // operator == not implemented in this class - // + /// Test assignment RadialBounds assignedRadialBoundsObject(10.1, 123.); assignedRadialBoundsObject = radialBoundsObject; diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp index 348b6cceed6..e48d3bcb0f3 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,7 @@ struct SurfaceArrayFixture { 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; @@ -76,11 +77,11 @@ struct SurfaceArrayFixture { } 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; @@ -89,7 +90,7 @@ struct SurfaceArrayFixture { 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 = @@ -112,8 +113,8 @@ struct SurfaceArrayFixture { 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); @@ -136,7 +137,8 @@ struct SurfaceArrayFixture { 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,11 +187,11 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArray_create, SurfaceArrayFixture) { std::vector brlRaw = unpack_shared_vector(brl); draw_surfaces(brl, "SurfaceArray_create_BRL_1.obj"); - Axis phiAxis(-M_PI, M_PI, - 30u); + Axis phiAxis( + -std::numbers::pi, std::numbers::pi, 30u); Axis zAxis(-14, 14, 7u); - double angleShift = 2 * M_PI / 30. / 2.; + double angleShift = 2 * std::numbers::pi / 30. / 2.; auto transform = [angleShift](const Vector3& pos) { return Vector2(phi(pos) + angleShift, pos.z()); }; diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index fed41d3fdde..fda64547085 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -23,6 +23,7 @@ #include #include +#include #include using namespace Acts::UnitLiterals; @@ -169,7 +170,7 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { /// This tests the intersection with cylinders /// and looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { - double alpha = 0.25 * M_PI; + double alpha = std::numbers::pi / 4.; auto testConeIntersection = [&](const Transform3& transform) -> void { // A cone surface ready to use diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp index b1b56b18d59..d399c3ff8cc 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -75,14 +76,17 @@ void runTest(const Surface& surface, double l0, double l1, double phi, // test datasets // local positions -const auto posAngle = bdata::xrange(-M_PI, M_PI, 0.25); +const auto posAngle = bdata::xrange(-std::numbers::pi, std::numbers::pi, 0.25); 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.25); // direction angles -const auto phis = bdata::xrange(-M_PI, M_PI, M_PI_4); -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::xrange(-std::numbers::pi, std::numbers::pi, std::numbers::pi / 4.); +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; // different surfaces // parameters must be chosen such that all possible local positions (as defined diff --git a/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp b/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp index 2b52064cb8d..4a01ef7da87 100644 --- a/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp @@ -12,6 +12,7 @@ #include "Acts/Surfaces/detail/VerticesHelper.hpp" #include +#include #include #include @@ -158,7 +159,8 @@ BOOST_AUTO_TEST_CASE(GenerateSegmentVertices) { vertices = VerticesHelper::segmentVertices( {rx, ry}, minPhi, maxPhi, {}, quarterVertices); expectedVertices = - static_cast((maxPhi - minPhi) / M_PI_2 * quarterVertices) + + static_cast((maxPhi - minPhi) / (std::numbers::pi / 2.) * + quarterVertices) + 2u; BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); @@ -175,7 +177,8 @@ BOOST_AUTO_TEST_CASE(GenerateSegmentVertices) { {rx, ry}, minPhi, maxPhi, {}, quarterVertices); // Extrema will be covered by the segments expectedVertices = - static_cast((maxPhi - minPhi) / M_PI_2 * quarterVertices) + + static_cast((maxPhi - minPhi) / (std::numbers::pi / 2.) * + quarterVertices) + 2u; BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); } @@ -186,7 +189,8 @@ BOOST_AUTO_TEST_CASE(GenerateCircleEllipseVertices) { ActsScalar ro = 10.; // Extreme points in phi - only outer radius - auto vertices = VerticesHelper::circularVertices(ri, ro, 0., M_PI, 1u); + auto vertices = + VerticesHelper::circularVertices(ri, ro, 0., std::numbers::pi, 1u); unsigned int expectedVertices = 5u; BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); @@ -194,21 +198,23 @@ BOOST_AUTO_TEST_CASE(GenerateCircleEllipseVertices) { ri = 3.; // Extreme points in phi - only outer radius - vertices = VerticesHelper::circularVertices(ri, ro, 0., M_PI, 1u); + vertices = VerticesHelper::circularVertices(ri, ro, 0., std::numbers::pi, 1u); expectedVertices = 10u; BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); // Now with 10 bins per sector ri = 0.; - vertices = VerticesHelper::circularVertices(ri, ro, 0., M_PI, 10u); + vertices = + VerticesHelper::circularVertices(ri, ro, 0., std::numbers::pi, 10u); expectedVertices = 41u; // 4 sectors + 1 overlap at (-pi/pi) BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); // Now ellipsiod ActsScalar riy = 4.; ActsScalar roy = 14.; - vertices = VerticesHelper::ellipsoidVertices(ri, riy, ro, roy, 0., M_PI, 10u); + vertices = VerticesHelper::ellipsoidVertices(ri, riy, ro, roy, 0., + std::numbers::pi, 10u); expectedVertices = 41u; // 4 sectors + 1 overlap at (-pi/pi) BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); } diff --git a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp index f149010aef8..ceb5f16806c 100644 --- a/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp +++ b/Tests/UnitTests/Core/TrackFinding/TrackSelectorTests.cpp @@ -21,6 +21,7 @@ #include "Acts/TrackFinding/TrackSelector.hpp" #include +#include using namespace Acts; namespace bdata = boost::unit_test::data; @@ -642,7 +643,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..0ad82ec9707 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 -M_Pi/+std::numbers::pi are checked + // above one module expands over -M_Pi/+std::numbers::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..fd1a43bf601 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); @@ -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 = 0.5 * std::numbers::pi / n * j; Frustum2 + // fr(origin, rot * dir, angle); fr.svg(os, w, w, 2); //} //} @@ -516,66 +518,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 +667,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 +679,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 +696,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 +727,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 +756,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 +785,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 +844,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 +925,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 +934,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 +959,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 +976,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 +1003,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 +1030,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 +1057,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 +1113,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 +1185,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 +1208,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/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 3f4516a5dfd9adf5308ad7e33bcf7a8fcfa263a3 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 24 Oct 2024 16:52:01 +0200 Subject: [PATCH 06/16] other cases --- Core/include/Acts/Geometry/VolumeBounds.hpp | 8 ++++---- Core/include/Acts/Propagator/RiddersPropagator.ipp | 2 +- .../Acts/TrackFitting/BetheHeitlerApprox.hpp | 3 ++- Core/include/Acts/Utilities/Frustum.ipp | 2 +- .../TrackFinding/HoughTransformSeeder.hpp | 9 +++++---- .../Physics/ElectroMagnetic/BetheHeitler.hpp | 5 +++-- .../Acts/Tests/CommonHelpers/BenchmarkTools.hpp | 4 +++- .../CorrectedTransformFreeToBoundTests.cpp | 2 +- .../Core/Material/MaterialValidaterTests.cpp | 3 ++- Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp | 5 +++-- Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp | 2 +- .../Core/Surfaces/SurfaceIntersectionTests.cpp | 3 ++- Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp | 2 +- .../Vertexing/AdaptiveGridTrackDensityTests.cpp | 8 +++++--- .../Vertexing/AdaptiveMultiVertexFinderTests.cpp | 13 +++++++++---- 15 files changed, 43 insertions(+), 28 deletions(-) diff --git a/Core/include/Acts/Geometry/VolumeBounds.hpp b/Core/include/Acts/Geometry/VolumeBounds.hpp index 63005e1d758..28bcc029166 100644 --- a/Core/include/Acts/Geometry/VolumeBounds.hpp +++ b/Core/include/Acts/Geometry/VolumeBounds.hpp @@ -35,12 +35,12 @@ 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 * std::numbers::pi, Vector3::UnitY()) * - AngleAxis3(0.5 * std::numbers::pi, Vector3::UnitZ()) * + AngleAxis3(std::numbers::pi / 2., Vector3::UnitY()) * + AngleAxis3(std::numbers::pi / 2., Vector3::UnitZ()) * Transform3::Identity(); static const Transform3 s_planeZX = - AngleAxis3(-0.5 * std::numbers::pi, Vector3::UnitX()) * - AngleAxis3(-0.5 * std::numbers::pi, Vector3::UnitZ()) * + 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 06aa11aedb2..1b1764a13d7 100644 --- a/Core/include/Acts/Propagator/RiddersPropagator.ipp +++ b/Core/include/Acts/Propagator/RiddersPropagator.ipp @@ -153,7 +153,7 @@ bool Acts::RiddersPropagator::inconsistentDerivativesOnDisc( // 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 * std::numbers::pi) { + std::numbers::pi / 2.) { jumpedAngle = false; break; } diff --git a/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp b/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp index 666ebf6aa23..373f5b11ea6 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::sqrt2; ret[0].mean = std::pow(2, -c); ret[0].var = std::pow(3, -c) - std::pow(4, -c); diff --git a/Core/include/Acts/Utilities/Frustum.ipp b/Core/include/Acts/Utilities/Frustum.ipp index 23a6fc28fc1..0b3a1335181 100644 --- a/Core/include/Acts/Utilities/Frustum.ipp +++ b/Core/include/Acts/Utilities/Frustum.ipp @@ -25,7 +25,7 @@ Acts::Frustum::Frustum(const VertexType& origin, value_type angle = VectorHelpers::phi(dir); Eigen::Rotation2D rot(angle); - value_type normal_angle = 0.5 * std::numbers::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(); 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/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/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/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp b/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp index 20bab89c4b6..ab1d1c1473a 100644 --- a/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp +++ b/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp @@ -82,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/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/Surfaces/LineSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp index dd1f7ab6d09..b4e7373fc7d 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(LineSurfaceAlignment) { line.alignmentToPathDerivative(tgContext, globalPosition, direction); // The expected results AlignmentToPathMatrix expAlignToPath = AlignmentToPathMatrix::Zero(); - const double value = std::sqrt(3) / 2; + const double value = std::numbers::sqrt3 / 2; expAlignToPath << -value, value, 0, -3 * value, -value, 0; // Check if the calculated derivative is as expected CHECK_CLOSE_ABS(alignToPath, expAlignToPath, 1e-10); @@ -241,7 +241,8 @@ BOOST_AUTO_TEST_CASE(LineSurfaceAlignment) { line.localCartesianToBoundLocalDerivative(tgContext, globalPosition); // Check if the result is as expected ActsMatrix<2, 3> expLoc3DToLocBound = ActsMatrix<2, 3>::Zero(); - expLoc3DToLocBound << 1 / std::sqrt(2), 1 / std::sqrt(2), 0, 0, 0, 1; + expLoc3DToLocBound << 1 / std::numbers::sqrt2, 1 / std::numbers::sqrt2, 0, 0, + 0, 1; CHECK_CLOSE_ABS(loc3DToLocBound, expLoc3DToLocBound, 1e-10); } diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index c6b8506804b..63f7b539372 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { /// Test pathCorrection CHECK_CLOSE_REL(planeSurfaceObject->pathCorrection(tgContext, offSurface, momentum.normalized()), - std::sqrt(3), 0.01); + std::numbers::sqrt3, 0.01); // /// Test name BOOST_CHECK_EQUAL(planeSurfaceObject->name(), diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index fda64547085..eda3f6d2db6 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -180,7 +180,8 @@ BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { auto lTransform = transform.linear(); // An onCylinder solution - Vector3 onCone = transform * Vector3(std::sqrt(2.), std::sqrt(2.), 2.); + Vector3 onCone = + transform * Vector3(std::numbers::sqrt2, std::numbers::sqrt2, 2.); Vector3 outCone = transform * Vector3(std::sqrt(4.), std::sqrt(4.), 2.); // Simply along the x axis Vector3 perpXY = lTransform * Vector3(1., -1., 0.).normalized(); diff --git a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp index fd1a43bf601..7be37ef7443 100644 --- a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp +++ b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp @@ -488,7 +488,7 @@ BOOST_AUTO_TEST_CASE(frustum_intersect) { // ActsVector origin = {min + step * i, min + step * // j}; origin.x() *= 1.10; // visual Eigen::Rotation2D // rot(2 * std::numbers::pi / static_cast(n) * i); - // BoundingBoxScalar angle = 0.5 * std::numbers::pi / n * j; Frustum2 + // BoundingBoxScalar angle = std::numbers::pi / 2. / n * j; Frustum2 // fr(origin, rot * dir, angle); fr.svg(os, w, w, 2); //} //} 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); From 27b719f12df2a33702f676f16adde5cf754c943e Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Fri, 25 Oct 2024 10:58:36 +0200 Subject: [PATCH 07/16] missed in conflict --- Core/include/Acts/EventData/TrackParameterHelpers.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Core/include/Acts/EventData/TrackParameterHelpers.hpp b/Core/include/Acts/EventData/TrackParameterHelpers.hpp index 02a7e66afce..c9089ff9ab9 100644 --- a/Core/include/Acts/EventData/TrackParameterHelpers.hpp +++ b/Core/include/Acts/EventData/TrackParameterHelpers.hpp @@ -11,8 +11,6 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Utilities/detail/periodic.hpp" -#include - namespace Acts { /// Normalize the bound parameter angles From 75401b9958901ea79fce3b460c5f463f90660322 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Sun, 27 Oct 2024 12:28:38 +0100 Subject: [PATCH 08/16] update Surface tests --- .../Core/Surfaces/AnnulusBoundsTests.cpp | 17 ++- .../Core/Surfaces/BoundaryToleranceTests.cpp | 7 +- .../Core/Surfaces/ConeBoundsTests.cpp | 45 ++++---- .../Core/Surfaces/ConeSurfaceTests.cpp | 52 +++++---- .../Core/Surfaces/CylinderBoundsTests.cpp | 102 +++++++++--------- .../Core/Surfaces/CylinderSurfaceTests.cpp | 10 +- .../Core/Surfaces/DiamondBoundsTests.cpp | 74 +++++++------ .../Core/Surfaces/DiscSurfaceTests.cpp | 38 ++++--- .../Surfaces/DiscTrapezoidBoundsTests.cpp | 70 ++++++------ .../Core/Surfaces/EllipseBoundsTests.cpp | 25 +++-- .../Core/Surfaces/InfiniteBoundsTests.cpp | 12 +-- .../Core/Surfaces/LineBoundsTests.cpp | 78 +++++++------- .../Core/Surfaces/LineSurfaceTests.cpp | 68 ++++++------ .../Core/Surfaces/PerigeeSurfaceTests.cpp | 24 +++-- .../Core/Surfaces/PlaneSurfaceTests.cpp | 77 +++++++------ .../Core/Surfaces/RadialBoundsTests.cpp | 24 +++-- .../Core/Surfaces/RectangleBoundsTests.cpp | 46 ++++---- .../Core/Surfaces/StrawSurfaceTests.cpp | 42 ++++---- .../Core/Surfaces/SurfaceArrayTests.cpp | 9 +- .../Core/Surfaces/SurfaceBoundsTests.cpp | 7 ++ .../Surfaces/SurfaceIntersectionTests.cpp | 14 +-- .../SurfaceLocalToGlobalRoundtripTests.cpp | 16 +-- Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp | 2 +- .../UnitTests/Core/Surfaces/SurfaceTests.cpp | 42 ++++---- .../Core/Surfaces/TrapezoidBoundsTests.cpp | 59 +++++----- .../Core/Surfaces/VerticesHelperTests.cpp | 2 +- 26 files changed, 501 insertions(+), 461 deletions(-) diff --git a/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp index 9f09fb2c213..60ecc7f84e4 100644 --- a/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp @@ -23,12 +23,12 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) -ActsScalar minRadius = 7.2; -ActsScalar maxRadius = 12.0; -ActsScalar minPhi = 0.74195; -ActsScalar maxPhi = 1.33970; +const ActsScalar minRadius = 7.2; +const ActsScalar maxRadius = 12.0; +const ActsScalar minPhi = 0.74195; +const ActsScalar maxPhi = 1.33970; -Vector2 offset(-2., 2.); +const Vector2 offset(-2., 2.); // Unit tests for AnnulusBounds constructors BOOST_AUTO_TEST_CASE(AnnulusBoundsConstruction) { @@ -60,13 +60,13 @@ BOOST_AUTO_TEST_CASE(AnnulusBoundsExcpetion) { // Exception for swapped radii BOOST_CHECK_THROW(AnnulusBounds(maxRadius, minRadius, minPhi, maxPhi, offset), std::logic_error); - // Exception for out of range min phi + // Exception for out of range min phi BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, -4., maxPhi, offset), std::logic_error); - // Exception for out of range max phi + // Exception for out of range max phi BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, minPhi, 4., offset), std::logic_error); - // Exception for out of range max phi + // Exception for out of range max phi BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, maxPhi, minPhi, offset), std::logic_error); } @@ -76,7 +76,6 @@ BOOST_AUTO_TEST_CASE(AnnulusBoundsProperties) { /// Test construction with radii and default sector AnnulusBounds aBounds(minRadius, maxRadius, minPhi, maxPhi, offset); - // /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(aBounds.type(), SurfaceBounds::eAnnulus); diff --git a/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp b/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp index cd49b409f5b..edc401e9b83 100644 --- a/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp @@ -20,8 +20,6 @@ #include #include -#include "BoundaryToleranceTestsRefs.hpp" - namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) @@ -42,6 +40,7 @@ BOOST_AUTO_TEST_CASE(BoundaryCheckBoxSimple) { BOOST_CHECK( !detail::insideAlignedBox(ll, ur, tolerance, {2, 0}, std::nullopt)); } + // Aligned box w/ tolerance check along first axis BOOST_AUTO_TEST_CASE(BoundaryCheckBoxToleranceLoc0) { boost::execution_monitor em; @@ -73,7 +72,7 @@ BOOST_AUTO_TEST_CASE(BoundaryCheckBoxCovariance) { cov << 1, 0.5, 0.5, 2; Vector2 ll(-1, -1); Vector2 ur(1, 1); - auto tolerance = BoundaryTolerance::Chi2Bound(cov.inverse(), 3.0); + auto tolerance = BoundaryTolerance::Chi2Bound(cov.inverse(), 3.); BOOST_CHECK( detail::insideAlignedBox(ll, ur, tolerance, {0, 0}, std::nullopt)); BOOST_CHECK( @@ -190,7 +189,7 @@ BOOST_AUTO_TEST_CASE(BoundaryCheckDifferentTolerances) { { auto tolerance = - BoundaryTolerance::Chi2Bound(SquareMatrix2::Identity(), 1.0); + BoundaryTolerance::Chi2Bound(SquareMatrix2::Identity(), 1.); BOOST_CHECK( detail::insideAlignedBox(ll, ur, tolerance, {0, 0}, std::nullopt)); BOOST_CHECK( diff --git a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp index 02ee3639482..ba38f5d11c1 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp @@ -24,10 +24,11 @@ // Note on nomenclature: // - alpha = cone opening half angle // - z is the axis of symmetry -// - zmin, zmax define limits for truncated cone +// - zMin, zMax define limits for truncated cone // - phi is clock angle around cone, with x axis corresponding to phi=0 -// - Cone segments may be defined with the avphi (central position of segment) -// and halfphi (extent in phi of cone segment either side of the avphi) +// - Cone segments may be defined with the averagePhi (central position of +// segment) and halfPhi (extent in phi of cone segment either side of the +// averagePhi) // - Local coords are z, rphi namespace Acts::Test { @@ -41,10 +42,10 @@ const double halfPhi = std::numbers::pi / 4.; const double averagePhi = 0.; const bool symmetric = false; -// Unit test for creating compliant/non-compliant ConeBounds object +/// Unit test for creating compliant/non-compliant ConeBounds object BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) { - // test default construction - // ConeBounds defaultConstructedConeBounds; // deleted + /// Test default construction + // default construction is deleted BOOST_TEST_CHECKPOINT("Four parameter constructor (last two at default)"); ConeBounds defaultConeBounds(alpha, symmetric); @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) { BOOST_CHECK_EQUAL(copyConstructedConeBounds, fiveParamConstructedConeBounds); } -// Streaning and recreation test +/// Streaning and recreation test BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) { ConeBounds original(alpha, zMin, zMax, halfPhi, averagePhi); auto valvector = original.values(); @@ -80,7 +81,7 @@ BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) { BOOST_CHECK_EQUAL(recreated, original); } -// Unit tests for AnnulusBounds exception throwing +/// Unit tests for AnnulusBounds exception throwing BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { // Exception for opening angle smaller 0 BOOST_CHECK_THROW(ConeBounds(-alpha, zMin, zMax, halfPhi, averagePhi), @@ -99,47 +100,47 @@ BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, -halfPhi, averagePhi), std::logic_error); - // Exception for out of range phi positioning + // Exception for out of range phi positioning BOOST_CHECK_THROW( ConeBounds(alpha, zMin, zMax, halfPhi, 2 * std::numbers::pi), std::logic_error); } -// Unit tests for properties of ConeBounds object +/// Unit tests for properties of ConeBounds object BOOST_AUTO_TEST_CASE(ConeBoundsProperties) { const Vector2 origin(0, 0); const Vector2 somewhere(4., 4.); ConeBounds coneBoundsObject(alpha, zMin, zMax, halfPhi, averagePhi); - // test for type (redundant) + /// Test for type (redundant) BOOST_CHECK_EQUAL(coneBoundsObject.type(), SurfaceBounds::eCone); - // test for inside + /// Test for inside BOOST_CHECK(!coneBoundsObject.inside(origin)); - // test for r + /// Test for r CHECK_CLOSE_REL(coneBoundsObject.r(zMin), zMin * std::tan(alpha), 1e-6); - // test for tanAlpha + /// Test for tanAlpha CHECK_CLOSE_REL(coneBoundsObject.tanAlpha(), std::tan(alpha), 1e-6); - // test for alpha + /// Test for alpha CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eAlpha), alpha, 1e-6); - // test for minZ + /// Test for minZ CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMinZ), zMin, 1e-6); - // test for maxZ + /// Test for maxZ CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMaxZ), zMax, 1e-6); - // test for averagePhi + /// Test for averagePhi CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eHalfPhiSector), halfPhi, 1e-6); - // test for dump - boost::test_tools::output_test_stream dumpOuput; - coneBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + coneBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, averagePhi) = " "(0.4142136, 3.0000000, 6.0000000, 0.7853982, 0.0000000)")); } diff --git a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp index 18fa0e93410..5d0102653b2 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp @@ -7,6 +7,7 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. #include +#include #include #include "Acts/Definitions/Algebra.hpp" @@ -37,9 +38,10 @@ BOOST_AUTO_TEST_SUITE(ConeSurfaces) /// Unit test for creating compliant/non-compliant ConeSurface object BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { - // ConeSurface default constructor is deleted - // - // Constructor with transform, alpha and symmetry indicator + /// Test default construction + // default construction is deleted + + /// Constructor with transform, alpha and symmetry indicator const double alpha = std::numbers::pi / 8.; const double halfPhiSector = std::numbers::pi / 16.; const double zMin = 1.; @@ -56,34 +58,32 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { Surface::makeShared(pTransform, alpha, symmetric)->type(), Surface::Cone); - // Constructor with transform pointer, alpha,z min and max, halfPhiSector + /// Constructor with transform pointer, alpha,z min and max, halfPhiSector BOOST_CHECK_EQUAL(Surface::makeShared(pTransform, alpha, zMin, zMax, halfPhiSector) ->type(), Surface::Cone); - // Constructor with transform and ConeBounds pointer - // ConeBounds (double alpha, double zmin, double zmax, double - // halfphi=std::numbers::pi, double avphi=0.) + /// Constructor with transform and ConeBounds pointer auto pConeBounds = std::make_shared(alpha, zMin, zMax, halfPhiSector, 0.); BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, pConeBounds)->type(), Surface::Cone); - // Copy constructor + /// Copy constructor auto coneSurfaceObject = Surface::makeShared(pTransform, alpha, symmetric); auto copiedConeSurface = Surface::makeShared(*coneSurfaceObject); BOOST_CHECK_EQUAL(copiedConeSurface->type(), Surface::Cone); BOOST_CHECK(*copiedConeSurface == *coneSurfaceObject); - // Copied and transformed + /// Copied and transformed auto copiedTransformedConeSurface = Surface::makeShared( tgContext, *coneSurfaceObject, pTransform); BOOST_CHECK_EQUAL(copiedTransformedConeSurface->type(), Surface::Cone); - // Construct with nullptr bounds + /// Construct with nullptr bounds BOOST_CHECK_THROW(auto nullBounds = Surface::makeShared( Transform3::Identity(), nullptr), AssertionFailureException); @@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { binningPosition, 1e-6); /// Test referenceFrame - Vector3 globalPosition{2.0, 2.0, 2.0}; + Vector3 globalPosition{2., 2., 2.}; Vector3 momentum{1.e6, 1.e6, 1.e6}; double rootHalf = std::sqrt(0.5); RotationMatrix3 expectedFrame; @@ -143,7 +143,6 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { Vector2 localPosition{1., std::numbers::pi / 2.}; globalPosition = coneSurfaceObject->localToGlobal(tgContext, localPosition, momentum); - // std::cout<globalToLocal(tgContext, globalPosition, momentum) .value(); - // std::cout<toStream(tgContext); + BOOST_CHECK(dumpOutput.is_equal( + "Acts::ConeSurface\n" + " Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n" + " Rotation: colX = (1.000000, 0.000000, 0.000000)\n" + " colY = (0.000000, 1.000000, 0.000000)\n" + " colZ = (0.000000, 0.000000, 1.000000)\n" + " Bounds : Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, " + "averagePhi) = (0.4142136, 0.0000000, inf, 3.1415927, 0.0000000)" + + )); } BOOST_AUTO_TEST_CASE(ConeSurfaceEqualityOperators) { @@ -220,7 +218,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { const double zMax = 10.; const Translation3 translation{0., 0., 0.}; // != {0., 1., 2.} - // Testing a Full cone + /// Testing a Full cone auto pTransform = Transform3(translation); auto pConeBounds = std::make_shared(alpha, zMin, zMax); auto pCone = Surface::makeShared(pTransform, pConeBounds); @@ -244,7 +242,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { CHECK_CLOSE_ABS(rMax, pConeExtent.max(BinningValue::binY), s_onSurfaceTolerance); - // Now a sector + /// Now a sector pConeBounds = std::make_shared(alpha, zMin, zMax, halfPhiSector, 0.); pCone = Surface::makeShared(pTransform, pConeBounds); diff --git a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp index 71192421737..14cafdd045b 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp @@ -28,43 +28,42 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant CylinderBounds object BOOST_AUTO_TEST_CASE(CylinderBoundsConstruction) { - /// test default construction - // CylinderBounds defaultConstructedCylinderBounds; // deleted + /// Test default construction + // default construction is deleted + const double radius = 0.5; - const double halfz = 10.; - const double halfphi = std::numbers::pi / 2.; + const double halfZ = 10.; + const double halfPhi = std::numbers::pi / 2.; const double averagePhi = std::numbers::pi / 2.; const double bevelMinZ = -std::numbers::pi / 4.; const double bevelMaxZ = std::numbers::pi / 6.; - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ).type(), SurfaceBounds::eCylinder); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, halfphi).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ, halfPhi).type(), SurfaceBounds::eCylinder); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, halfphi, averagePhi).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ, halfPhi, averagePhi).type(), SurfaceBounds::eCylinder); BOOST_CHECK_EQUAL( - CylinderBounds(radius, halfz, std::numbers::pi, 0., bevelMinZ).type(), + CylinderBounds(radius, halfZ, std::numbers::pi, 0., bevelMinZ).type(), SurfaceBounds::eCylinder); BOOST_CHECK_EQUAL( - CylinderBounds(radius, halfz, std::numbers::pi, 0., bevelMinZ, bevelMaxZ) + CylinderBounds(radius, halfZ, std::numbers::pi, 0., bevelMinZ, bevelMaxZ) .type(), SurfaceBounds::eCylinder); - // - /// test copy construction; - CylinderBounds cylinderBounds(radius, halfz); + + /// Test copy construction; + CylinderBounds cylinderBounds(radius, halfZ); CylinderBounds copyConstructedCylinderBounds(cylinderBounds); BOOST_CHECK_EQUAL(copyConstructedCylinderBounds, cylinderBounds); } BOOST_AUTO_TEST_CASE(CylinderBoundsRecreation) { - /// test default construction - // CylinderBounds defaultConstructedCylinderBounds; // deleted const double radius = 0.5; - const double halfz = 10.; + const double halfZ = 10.; // Test construction with radii and default sector - auto original = CylinderBounds(radius, halfz); + auto original = CylinderBounds(radius, halfZ); auto valvector = original.values(); std::array values{}; std::copy_n(valvector.begin(), CylinderBounds::eSize, values.begin()); @@ -74,56 +73,56 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsRecreation) { BOOST_AUTO_TEST_CASE(CylinderBoundsException) { const double radius = 0.5; - const double halfz = 10.; - const double halfphi = std::numbers::pi / 2.; + const double halfZ = 10.; + const double halfPhi = std::numbers::pi / 2.; const double averagePhi = std::numbers::pi / 2.; - // Negative radius - BOOST_CHECK_THROW(CylinderBounds(-radius, halfz, halfphi, averagePhi), + /// Negative radius + BOOST_CHECK_THROW(CylinderBounds(-radius, halfZ, halfPhi, averagePhi), std::logic_error); - // Negative half length in z - BOOST_CHECK_THROW(CylinderBounds(radius, -halfz, halfphi, averagePhi), + /// Negative half length in z + BOOST_CHECK_THROW(CylinderBounds(radius, -halfZ, halfPhi, averagePhi), std::logic_error); - // Negative half sector in phi - BOOST_CHECK_THROW(CylinderBounds(radius, halfz, -halfphi, averagePhi), + /// Negative half sector in phi + BOOST_CHECK_THROW(CylinderBounds(radius, halfZ, -halfPhi, averagePhi), std::logic_error); - // Half sector in phi out of bounds - BOOST_CHECK_THROW(CylinderBounds(radius, halfz, 4., averagePhi), + /// Half sector in phi out of bounds + BOOST_CHECK_THROW(CylinderBounds(radius, halfZ, 4., averagePhi), std::logic_error); - // Phi position out of bounds - BOOST_CHECK_THROW(CylinderBounds(radius, halfz, halfphi, 4.), + /// Phi position out of bounds + BOOST_CHECK_THROW(CylinderBounds(radius, halfZ, halfPhi, 4.), std::logic_error); } /// Unit tests for CylinderBounds properties BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { - // CylinderBounds object of radius 0.5 and halfz 20 + // CylinderBounds object of radius 0.5 and halfZ 20 const double radius = 0.5; - const double halfz = 20.; // != 10. - const double halfphi = std::numbers::pi / 4.; // != pi/2 + const double halfZ = 20.; // != 10. + const double halfPhi = std::numbers::pi / 4.; // != pi/2 const double averagePhi = 0.; // != pi/2 const double bevelMinZ = std::numbers::pi / 4.; // != -pi/4 const double bevelMaxZ = std::numbers::pi / 6.; - CylinderBounds cylinderBoundsObject(radius, halfz); - CylinderBounds cylinderBoundsSegment(radius, halfz, halfphi, averagePhi); - CylinderBounds cylinderBoundsBeveledObject(radius, halfz, std::numbers::pi, + CylinderBounds cylinderBoundsObject(radius, halfZ); + CylinderBounds cylinderBoundsSegment(radius, halfZ, halfPhi, averagePhi); + CylinderBounds cylinderBoundsBeveledObject(radius, halfZ, std::numbers::pi, 0., bevelMinZ, bevelMaxZ); - /// test for type() + /// Test for type() BOOST_CHECK_EQUAL(cylinderBoundsObject.type(), SurfaceBounds::eCylinder); - /// test for inside(), 2D coords are r or phi ,z? : needs clarification + /// Test for inside(), 2D coords are r or phi ,z? : needs clarification const Vector2 origin{0., 0.}; const Vector2 atPiBy2{std::numbers::pi / 2., 0.}; const Vector2 atPi{std::numbers::pi, 0.}; const Vector2 beyondEnd{0, 30.}; - const Vector2 unitZ{0.0, 1.0}; - const Vector2 unitPhi{1.0, 0.0}; + const Vector2 unitZ{0., 1.}; + const Vector2 unitPhi{1., 0.}; const Vector2 withinBevelMin{0.5, -20.012}; const Vector2 outsideBevelMin{0.5, -40.}; const BoundaryTolerance tolerance = @@ -141,42 +140,43 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { BOOST_CHECK( !cylinderBoundsBeveledObject.inside(outsideBevelMin, lessTolerance)); - /// test for r() + /// Test for r() CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eR), radius, 1e-6); - /// test for averagePhi + /// Test for averagePhi CHECK_CLOSE_OR_SMALL(cylinderBoundsObject.get(CylinderBounds::eAveragePhi), averagePhi, 1e-6, 1e-6); - /// test for halfPhiSector + /// Test for halfPhiSector CHECK_CLOSE_REL(cylinderBoundsSegment.get(CylinderBounds::eHalfPhiSector), - halfphi, + halfPhi, 1e-6); // fail - /// test for halflengthZ (NOTE: Naming violation) - CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eHalfLengthZ), halfz, + /// Test for halflengthZ (NOTE: Naming violation) + CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eHalfLengthZ), halfZ, 1e-6); - /// test for bevelMinZ/MaxZ + /// Test for bevelMinZ/MaxZ CHECK_CLOSE_REL(cylinderBoundsBeveledObject.get(CylinderBounds::eBevelMinZ), bevelMinZ, 1e-6); CHECK_CLOSE_REL(cylinderBoundsBeveledObject.get(CylinderBounds::eBevelMaxZ), bevelMaxZ, 1e-6); - /// test for dump - boost::test_tools::output_test_stream dumpOuput; - cylinderBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + cylinderBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, " "averagePhi, bevelMinZ, bevelMaxZ) = (0.5000000, 20.0000000, 3.1415927, " "0.0000000, 0.0000000, 0.0000000)")); } + /// Unit test for testing CylinderBounds assignment BOOST_AUTO_TEST_CASE(CylinderBoundsAssignment) { const double radius = 0.5; - const double halfz = 20.; // != 10. + const double halfZ = 20.; // != 10. - CylinderBounds cylinderBoundsObject(radius, halfz); + CylinderBounds cylinderBoundsObject(radius, halfZ); CylinderBounds assignedCylinderBounds(10.5, 6.6); assignedCylinderBounds = cylinderBoundsObject; diff --git a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp index 09ba3895177..4dd6f7f6905 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -55,8 +55,9 @@ GeometryContext testContext = GeometryContext(); BOOST_AUTO_TEST_SUITE(CylinderSurfaces) /// Unit test for creating compliant/non-compliant CylinderSurface object BOOST_AUTO_TEST_CASE(CylinderSurfaceConstruction) { - // CylinderSurface default constructor is deleted - // + /// Test default construction + // default construction is deleted + /// Constructor with transform, radius and halfZ const double radius = 1.; const double halfZ = 10.; @@ -105,7 +106,6 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { /// Test clone method const double radius = 1.; const double halfZ = 10.; - // const double halfPhiSector = std::numbers::pi / 8.; const Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { /// Test referenceFrame const double invSqrt2 = 1. / std::numbers::sqrt2; Vector3 globalPosition{invSqrt2, 1. - invSqrt2, 0.}; - Vector3 globalPositionZ{invSqrt2, 1. - invSqrt2, 2.0}; + Vector3 globalPositionZ{invSqrt2, 1. - invSqrt2, 2.}; Vector3 momentum{15., 15., 15.}; Vector3 momentum2{6.6, -3., 2.}; RotationMatrix3 expectedFrame; @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { BOOST_CHECK(!cylinderSurfaceObject->isOnSurface(testContext, offSurface, BoundaryTolerance::None())); - /// intersection test + /// Intersection test Vector3 direction{-1., 0, 0}; auto sfIntersection = cylinderSurfaceObject->intersect( testContext, offSurface, direction, BoundaryTolerance::Infinite()); diff --git a/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp index ecd5909f932..1869cde057d 100644 --- a/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp @@ -24,22 +24,26 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant DiamondBounds object BOOST_AUTO_TEST_CASE(DiamondBoundsConstruction) { - double minHalfX(10.), midHalfX(20.), maxHalfX(15.), halfY1(5.), halfY2(7.); - // test default construction - // DiamondBounds defaultConstructedDiamondBounds; //deleted - // + /// Test default construction + // default construction is deleted + + const double minHalfX = 10.; + const double midHalfX = 20.; + const double maxHalfX = 15.; + const double halfY1 = 5.; + const double halfY2 = 7.; + /// Test construction with dimensions - // DiamondBounds d(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); BOOST_CHECK_EQUAL( DiamondBounds(minHalfX, midHalfX, maxHalfX, halfY1, halfY2).type(), SurfaceBounds::eDiamond); - // + /// Copy constructor DiamondBounds original(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); DiamondBounds copied(original); BOOST_CHECK_EQUAL(copied.type(), SurfaceBounds::eDiamond); - // invalid inputs + /// Test invalid inputs BOOST_CHECK_THROW( DiamondBounds db(midHalfX, minHalfX, maxHalfX, halfY1, halfY2), std::logic_error); @@ -47,66 +51,66 @@ BOOST_AUTO_TEST_CASE(DiamondBoundsConstruction) { DiamondBounds db(minHalfX, maxHalfX, midHalfX, halfY1, halfY2), std::logic_error); } + /// Unit tests for DiamondBounds properties BOOST_AUTO_TEST_CASE(DiamondBoundsProperties) { - double minHalfX(10.), midHalfX(50.), maxHalfX(30.), halfY1(10.), halfY2(20.); + const double minHalfX = 10.; + const double midHalfX = 50.; // != 20. + const double maxHalfX = 30.; // != 15. + const double halfY1 = 10.; // != 5. + const double halfY2 = 20.; // != 7. + /// Test clone DiamondBounds diamondBoundsObject(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); - // + /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(diamondBoundsObject.type(), SurfaceBounds::eDiamond); - // //redundant test - // + /// Test the half length at negative y BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXnegY), minHalfX); - // + /// Test the half length at the x axis BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXzeroY), midHalfX); - // + /// Test the half length at positive y BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXposY), maxHalfX); - // + /// Test half length into the negative side BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthYneg), halfY1); - // + /// Test half length into the positive side BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthYpos), halfY2); - // + /// Test boundingBox BOOST_CHECK_EQUAL(diamondBoundsObject.boundingBox(), RectangleBounds(Vector2{-50., -10.}, Vector2{50., 20.})); - // - // clone already tested - // + /// Test distanceToBoundary Vector2 origin(0., 0.); Vector2 outsideBy10(0., 30.); Vector2 inRectangle(15., 0.); /// Test dump - // Acts::DiamondBounds: (minHlengthX, medHlengthX, maxHlengthX, hlengthY1, - // hlengthY2 ) = (30.0000000, 10.0000000, 50.0000000, 10.0000000, - // 20.0000000) diamondBoundsObject.toStream(std::cout); - boost::test_tools::output_test_stream dumpOuput; - diamondBoundsObject.toStream(dumpOuput); + boost::test_tools::output_test_stream dumpOutput; + diamondBoundsObject.toStream(dumpOutput); BOOST_CHECK( - dumpOuput.is_equal("Acts::DiamondBounds: (halfXatYneg, halfXatYzero, " - "halfXatYpos, halfYneg, halfYpos) = (10.0000000, " - "50.0000000, 30.0000000, 10.0000000, 20.0000000)")); - // + dumpOutput.is_equal("Acts::DiamondBounds: (halfXatYneg, halfXatYzero, " + "halfXatYpos, halfYneg, halfYpos) = (10.0000000, " + "50.0000000, 30.0000000, 10.0000000, 20.0000000)")); + /// Test inside BOOST_CHECK(diamondBoundsObject.inside(origin, BoundaryTolerance::None())); // dont understand why this is so: BOOST_CHECK( !diamondBoundsObject.inside(outsideBy10, BoundaryTolerance::None())); - // + /// Test vertices (does this need to be implemented in this class?? // auto v=diamondBoundsObject.vertices(); std::vector referenceVertices{ @@ -117,20 +121,28 @@ BOOST_AUTO_TEST_CASE(DiamondBoundsProperties) { referenceVertices.cbegin(), referenceVertices.cend()); } + /// Unit test for testing DiamondBounds assignment BOOST_AUTO_TEST_CASE(DiamondBoundsAssignment) { - double minHalfX(10.), midHalfX(20.), maxHalfX(15.), halfY1(5.), halfY2(7.); + const double minHalfX = 10.; + const double midHalfX = 20.; + const double maxHalfX = 15.; + const double halfY1 = 5.; + const double halfY2 = 7.; + DiamondBounds diamondBoundsObject(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); DiamondBounds similarlyConstructeDiamondBoundsObject( minHalfX, midHalfX, maxHalfX, halfY1, halfY2); + /// Test operator == BOOST_CHECK_EQUAL(diamondBoundsObject, similarlyConstructeDiamondBoundsObject); - // + /// Test assignment DiamondBounds assignedDiamondBoundsObject( 2 * minHalfX, 2 * midHalfX, 2 * maxHalfX, 2 * halfY1, 2 * halfY2); + // object, in some sense assignedDiamondBoundsObject = diamondBoundsObject; BOOST_CHECK_EQUAL(assignedDiamondBoundsObject, diamondBoundsObject); diff --git a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp index ed8a229c340..b5d1eec5f43 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp @@ -54,8 +54,9 @@ auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE); BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit tests for creating DiscSurface object BOOST_AUTO_TEST_CASE(DiscSurfaceConstruction) { - // default constructor is deleted - // scaffolding... + /// Test default construction + // default construction is deleted + const double rMin = 1.; const double rMax = 5.; const double halfPhiSector = std::numbers::pi / 8.; @@ -109,13 +110,10 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext), zAxis); /// Test normal, local position specified - Vector2 lpos(2.0, 0.05); + Vector2 lpos(2., 0.05); BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext, lpos), zAxis); /// Test binningPosition - // auto binningPosition= - // discSurfaceObject.binningPosition(BinningValue::BinningValue::binRPhi ); - // std::cout<binningPosition(tgContext, BinningValue::binRPhi), origin3D); @@ -125,8 +123,8 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { Vector3 ignoredMomentum{0., 0., 0.}; /// Test isOnSurface() - Vector3 point3DNotInSector{0.0, 1.2, 0}; - Vector3 point3DOnSurface{1.2, 0.0, 0}; + Vector3 point3DNotInSector{0., 1.2, 0}; + Vector3 point3DOnSurface{1.2, 0., 0}; BOOST_CHECK(!discSurfaceObject->isOnSurface(tgContext, point3DNotInSector, ignoredMomentum, BoundaryTolerance::None())); @@ -140,21 +138,21 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { /// Test localToGlobal Vector3 returnedPosition{10.9, 8.7, 6.5}; Vector3 expectedPosition{1.2, 0, 0}; - Vector2 rPhiOnDisc{1.2, 0.0}; + Vector2 rPhiOnDisc{1.2, 0.}; Vector2 rPhiNotInSector{ 1.2, std::numbers::pi}; // outside sector at Phi=0, +/- pi/8 returnedPosition = discSurfaceObject->localToGlobal(tgContext, rPhiOnDisc, ignoredMomentum); CHECK_CLOSE_ABS(returnedPosition, expectedPosition, 1e-6); - // + returnedPosition = discSurfaceObject->localToGlobal( tgContext, rPhiNotInSector, ignoredMomentum); Vector3 expectedNonPosition{-1.2, 0, 0}; CHECK_CLOSE_ABS(returnedPosition, expectedNonPosition, 1e-6); - // + /// Test globalToLocal Vector2 returnedLocalPosition{33., 44.}; - Vector2 expectedLocalPosition{1.2, 0.0}; + Vector2 expectedLocalPosition{1.2, 0.}; returnedLocalPosition = discSurfaceObject ->globalToLocal(tgContext, point3DOnSurface, ignoredMomentum) @@ -167,7 +165,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { ->globalToLocal(tgContext, point3DNotInSector, ignoredMomentum) .value(); - Vector3 pointOutsideR{0.0, 100., 0}; + Vector3 pointOutsideR{0., 100., 0}; returnedLocalPosition = discSurfaceObject ->globalToLocal(tgContext, pointOutsideR, ignoredMomentum) @@ -243,7 +241,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceAssignment) { Transform3::Identity(), rMin, rMax, halfPhiSector); auto assignedDisc = Surface::makeShared(Transform3::Identity(), 2.2, 4.4, 0.07); - // + BOOST_CHECK_NO_THROW(*assignedDisc = *discSurfaceObject); BOOST_CHECK((*assignedDisc) == (*discSurfaceObject)); } @@ -339,7 +337,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceAlignment) { globalPosition); // Check if the result is as expected ActsMatrix<2, 3> expLoc3DToLocBound = ActsMatrix<2, 3>::Zero(); - expLoc3DToLocBound << 0, 1, 0, -1.0 / 3, 0, 0; + expLoc3DToLocBound << 0, 1, 0, -1. / 3, 0, 0; CHECK_CLOSE_ABS(loc3DToLocBound, expLoc3DToLocBound, 1e-10); } @@ -419,12 +417,12 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) { BOOST_AUTO_TEST_SUITE(DiscSurfaceMerging) namespace { -std::shared_ptr makeDisc(const Transform3& transform, double rmin, - double rmax, +std::shared_ptr makeDisc(const Transform3& transform, double rMin, + double rMax, double halfPhi = std::numbers::pi, double avgPhi = 0) { return Surface::makeShared( - transform, std::make_shared(rmin, rmax, halfPhi, avgPhi)); + transform, std::make_shared(rMin, rMax, halfPhi, avgPhi)); } } // namespace @@ -809,8 +807,8 @@ BOOST_DATA_TEST_CASE(PhiDirection, // bounds should be equal however BOOST_CHECK_EQUAL(disc76->bounds(), disc67->bounds()); - BOOST_CHECK(!reversed76); // not reversed either because you get the - // ordering you put in + // not reversed either because you get the ordering you put in + BOOST_CHECK(!reversed76); const auto* bounds67 = dynamic_cast(&disc67->bounds()); BOOST_REQUIRE_NE(bounds67, nullptr); diff --git a/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp index 1515ef79292..8f6117ef1b0 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp @@ -24,22 +24,26 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) -/// Unit tests for DiscTrapezoidBounds constrcuctors +const double minHalfX = 1.; +const double maxHalfX = 5.; +const double rMin = 2.; +const double rMax = 6.; +const double averagePhi = 0.; +const double stereo = 0.1; + +/// Unit tests for DiscTrapezoidBounds constructors BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsConstruction) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); - // /// Test construction with dimensions and default stereo BOOST_CHECK_EQUAL( DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, rMax, averagePhi).type(), SurfaceBounds::eDiscTrapezoid); - // + /// Test construction with all dimensions BOOST_CHECK_EQUAL( DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo) .type(), SurfaceBounds::eDiscTrapezoid); - // + /// Copy constructor DiscTrapezoidBounds original(minHalfX, maxHalfX, rMin, rMax, averagePhi); DiscTrapezoidBounds copied(original); @@ -48,9 +52,6 @@ BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsConstruction) { // Streaning and recreation test BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsRecreation) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); - DiscTrapezoidBounds original(minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo); auto valvector = original.values(); @@ -62,9 +63,6 @@ BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsRecreation) { // Unit tests for AnnulusBounds exception throwing BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsExceptions) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); - // Exception for opening neg min half x < 0 BOOST_CHECK_THROW( DiscTrapezoidBounds(-minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo), @@ -103,74 +101,72 @@ BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsExceptions) { /// Unit tests for DiscTrapezoidBounds properties BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsProperties) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), - averagePhi(0.0) /*, stereo(0.1)*/; /// Test clone DiscTrapezoidBounds DiscTrapezoidBoundsObject(minHalfX, maxHalfX, rMin, rMax, averagePhi); - // + /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(DiscTrapezoidBoundsObject.type(), SurfaceBounds::eDiscTrapezoid); - // + /// Test distanceToBoundary Vector2 origin(0., 0.); Vector2 outside(30., 0.); - Vector2 inSurface(2.5, 0.0); - // + Vector2 inSurface(2.5, 0.); + /// Test dump - boost::test_tools::output_test_stream dumpOuput; - DiscTrapezoidBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + boost::test_tools::output_test_stream dumpOutput; + DiscTrapezoidBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::DiscTrapezoidBounds: (innerRadius, outerRadius, halfLengthXminR, " "halfLengthXmaxR, halfLengthY, halfPhiSector, averagePhi, rCenter, " "stereo) = " "(2.0000000, 6.0000000, 1.0000000, 5.0000000, 0.7922870, 0.9851108, " "0.0000000, 2.5243378, 0.0000000)")); - // + /// Test inside BOOST_CHECK( DiscTrapezoidBoundsObject.inside(inSurface, BoundaryTolerance::None())); BOOST_CHECK( !DiscTrapezoidBoundsObject.inside(outside, BoundaryTolerance::None())); - // + /// Test rMin CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rMin(), rMin, 1e-6); - // + /// Test rMax CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rMax(), rMax, 1e-6); - // + /// Test averagePhi CHECK_SMALL(DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eAveragePhi), 1e-9); - // + /// Test rCenter (redundant; not configurable) CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rCenter(), 2.524337798, 1e-6); - // + /// Test halfPhiSector (redundant; not configurable) CHECK_SMALL(DiscTrapezoidBoundsObject.stereo(), 1e-6); - // - /// Test minHalflengthX + + /// Test minHalfLengthX CHECK_CLOSE_REL( DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eHalfLengthXminR), minHalfX, 1e-6); - // - /// Test maxHalflengthX + + /// Test maxHalfLengthX CHECK_CLOSE_REL( DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eHalfLengthXmaxR), maxHalfX, 1e-6); - // - /// Test halflengthY + + /// Test halfLengthY CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.halfLengthY(), 0.792286991, 1e-6); } /// Unit test for testing DiscTrapezoidBounds assignment BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsAssignment) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); DiscTrapezoidBounds DiscTrapezoidBoundsObject(minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo); - // operator == not implemented in this class - // + + /// Test operator == + // not implemented in this class + /// Test assignment DiscTrapezoidBounds assignedDiscTrapezoidBoundsObject(2.1, 6.6, 3.4, 4.2, 0.3, 0.); diff --git a/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp index 9ce67b66cff..0ed78e656f6 100644 --- a/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp @@ -36,15 +36,15 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsConstruction) { const double outerRx = 25.; const double outerRy = 30.; - // test default construction - // EllipseBounds defaultConstructedEllipseBounds; //deleted - // + /// Test default construction + // default construction is deleted + /// Test construction with dimensions BOOST_CHECK_EQUAL( EllipseBounds(innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi) .type(), SurfaceBounds::eEllipse); - // + /// Copy constructor EllipseBounds original(innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi); @@ -75,38 +75,47 @@ BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { BOOST_CHECK_THROW( EllipseBounds(-innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRy < 0 BOOST_CHECK_THROW( EllipseBounds(innerRx, -innerRy, outerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRx < 0 and innerRy < 0 BOOST_CHECK_THROW(EllipseBounds(-innerRx, -innerRy, outerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for opening outerRx <= 0 BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, 0., outerRy, phiSector, averagePhi), std::logic_error); + // Exception for opening outerRy <= 0 BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, outerRx, 0., phiSector, averagePhi), std::logic_error); + // Exception for iouterRx < 0 and outerRy < 0 BOOST_CHECK_THROW(EllipseBounds(innerRx, innerRy, -outerRx, -outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRx > outerRx BOOST_CHECK_THROW( EllipseBounds(outerRx, innerRy, innerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRxy > outerRy BOOST_CHECK_THROW( EllipseBounds(innerRx, outerRy, outerRx, innerRy, phiSector, averagePhi), std::logic_error); + // Exception for negative phiSector BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, outerRx, outerRy, -phiSector, averagePhi), std::logic_error); + // Exception for average phi out of bound BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, outerRx, outerRy, phiSector, 4.), @@ -125,8 +134,6 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsProperties) { /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(ellipseBoundsObject.type(), SurfaceBounds::eEllipse); - // clone already tested - /// Test distanceToBoundary Vector2 origin{0., 0.}; Vector2 outsideBy15{0., 30.}; @@ -163,9 +170,9 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsProperties) { std::numbers::pi / 2.); /// Test dump - boost::test_tools::output_test_stream dumpOuput; - ellipseBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + boost::test_tools::output_test_stream dumpOutput; + ellipseBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::EllipseBounds: (innerRadius0, outerRadius0, innerRadius1, " "outerRadius1, hPhiSector, averagePhi) = (10.0000000, 15.0000000, " "15.0000000, 20.0000000, 0.0000000, 1.5707963, 0.0000000)")); diff --git a/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp index d0097695286..b0c7fa0c94f 100644 --- a/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp @@ -29,19 +29,19 @@ BOOST_AUTO_TEST_CASE(InfiniteBoundsConstruction) { /// Unit tests for InfiniteBounds properties BOOST_AUTO_TEST_CASE(InfiniteBoundsProperties) { InfiniteBounds infiniteBoundsObject; - /// test for type() + /// Test for type() BOOST_CHECK_EQUAL(infiniteBoundsObject.type(), SurfaceBounds::eBoundless); - /// test for inside() + /// Test for inside() const Vector2 anyVector{0., 1.}; const BoundaryTolerance anyTolerance = BoundaryTolerance::None(); BOOST_CHECK(infiniteBoundsObject.inside(anyVector, anyTolerance)); - /// test for dump - boost::test_tools::output_test_stream dumpOuput; - infiniteBoundsObject.toStream(dumpOuput); + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + infiniteBoundsObject.toStream(dumpOutput); BOOST_CHECK( - dumpOuput.is_equal("Acts::InfiniteBounds ... boundless surface\n")); + dumpOutput.is_equal("Acts::InfiniteBounds ... boundless surface\n")); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp index f972529bed0..c8022a9174c 100644 --- a/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp @@ -24,20 +24,24 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant LineBounds object BOOST_AUTO_TEST_CASE(LineBoundsConstruction) { - /// test LineBounds(double, double) - double radius(0.5), halfz(10.); - LineBounds lineBounds(radius, halfz); + const double radius = 0.5; + const double halfZ = 10.; + + /// Test LineBounds(double, double) + LineBounds lineBounds(radius, halfZ); BOOST_CHECK_EQUAL(lineBounds.type(), SurfaceBounds::eLine); - /// test copy construction; + + /// Test copy construction; LineBounds copyConstructedLineBounds(lineBounds); // implicit BOOST_CHECK_EQUAL(copyConstructedLineBounds.type(), SurfaceBounds::eLine); } /// Unit test for testing LineBounds recreation from streaming BOOST_AUTO_TEST_CASE(LineBoundsRecreation) { - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - LineBounds original(nominalRadius, nominalHalfLength); + const double radius = 0.5; + const double halfZ = 20.; // != 10. + + LineBounds original(radius, halfZ); LineBounds recreated(original); auto valvector = original.values(); std::array values{}; @@ -47,45 +51,45 @@ BOOST_AUTO_TEST_CASE(LineBoundsRecreation) { /// Unit test for testing LineBounds exceptions BOOST_AUTO_TEST_CASE(LineBoundsExceptions) { - double nominalRadius{0.5}; - double nominalHalfLength{20.}; + const double radius = 0.5; + const double halfZ = 20.; // != 10. + // Negative radius - BOOST_CHECK_THROW(LineBounds(-nominalRadius, nominalHalfLength), - std::logic_error); + BOOST_CHECK_THROW(LineBounds(-radius, halfZ), std::logic_error); + // Negative half length - BOOST_CHECK_THROW(LineBounds(nominalRadius, -nominalHalfLength), - std::logic_error); + BOOST_CHECK_THROW(LineBounds(radius, -halfZ), std::logic_error); // Negative radius and half length - BOOST_CHECK_THROW(LineBounds(-nominalRadius, -nominalHalfLength), - std::logic_error); + BOOST_CHECK_THROW(LineBounds(-radius, -halfZ), std::logic_error); } /// Unit test for testing LineBounds assignment BOOST_AUTO_TEST_CASE(LineBoundsAssignment) { - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - LineBounds lineBoundsObject(nominalRadius, nominalHalfLength); + const double radius = 0.5; + const double halfZ = 20.; // != 10. + + LineBounds lineBoundsObject(radius, halfZ); LineBounds assignedLineBounds = lineBoundsObject; BOOST_CHECK_EQUAL(assignedLineBounds, lineBoundsObject); } /// Unit tests for LineBounds properties BOOST_AUTO_TEST_CASE(LineBoundsProperties) { - // LineBounds object of radius 0.5 and halfz 20 - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - LineBounds lineBoundsObject(nominalRadius, nominalHalfLength); + const double radius = 0.5; + const double halfZ = 20.; // != 10. - /// test for type() + LineBounds lineBoundsObject(radius, halfZ); + + /// Test for type() BOOST_CHECK_EQUAL(lineBoundsObject.type(), SurfaceBounds::eLine); - /// test for inside() + /// Test for inside() const Vector2 origin{0., 0.}; const Vector2 atRadius{0.5, 10.}; - const Vector2 beyondEnd{0.0, 30.0}; - const Vector2 unitZ{0.0, 1.0}; - const Vector2 unitR{1.0, 0.0}; + const Vector2 beyondEnd{0., 30.}; + const Vector2 unitZ{0., 1.}; + const Vector2 unitR{1., 0.}; const BoundaryTolerance tolerance = BoundaryTolerance::AbsoluteBound(0.1, 0.1); // This fails because the bounds are not inclusive. @@ -94,22 +98,20 @@ BOOST_AUTO_TEST_CASE(LineBoundsProperties) { BOOST_CHECK(lineBoundsObject.inside(unitZ, tolerance)); BOOST_CHECK(!lineBoundsObject.inside(unitR, tolerance)); - /// Test negative redius inside - + /// Test negative radius inside BOOST_CHECK(lineBoundsObject.inside(Vector2{-0.2, 10}, tolerance)); BOOST_CHECK(!lineBoundsObject.inside(Vector2{-0.8, 10}, tolerance)); - /// test for r() - BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eR), nominalRadius); + /// Test for r() + BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eR), radius); - /// test for halflengthZ (NOTE: Naming violation) - BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eHalfLengthZ), - nominalHalfLength); + /// Test for halfLengthZ + BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eHalfLengthZ), halfZ); - /// test for dump - boost::test_tools::output_test_stream dumpOuput; - lineBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + lineBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::LineBounds: (radius, halflengthInZ) = (0.5000000, 20.0000000)")); } diff --git a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp index b4e7373fc7d..0175578a423 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -56,28 +56,34 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant LineSurface object BOOST_AUTO_TEST_CASE(LineSurface_Constructors_test) { - // Default ctor is deleted - // LineSurfaceStub l; - // ctor with translation, radius, halfz + /// Test default construction + // default construction is deleted + Translation3 translation{0., 1., 2.}; Transform3 transform(translation); auto pTransform = Transform3(translation); - const double radius{2.0}, halfz{20.}; - BOOST_CHECK(LineSurfaceStub(pTransform, radius, halfz).constructedOk()); - // ctor with nullptr for LineBounds + const double radius = 2.; + const double halfZ = 20.; + BOOST_CHECK(LineSurfaceStub(pTransform, radius, halfZ).constructedOk()); + + /// ctor with nullptr for LineBounds BOOST_CHECK(LineSurfaceStub(pTransform).constructedOk()); - // ctor with LineBounds - auto pLineBounds = std::make_shared(2., 10.0); + + /// ctor with LineBounds + auto pLineBounds = std::make_shared(2., 10.); BOOST_CHECK(LineSurfaceStub(pTransform, pLineBounds).constructedOk()); - // ctor with LineBounds, detector element, Identifier + + /// ctor with LineBounds, detector element, Identifier auto pMaterial = std::make_shared(makePercentSlab()); DetectorElementStub detElement{pTransform, pLineBounds, 0.2, pMaterial}; BOOST_CHECK(LineSurfaceStub(pLineBounds, detElement).constructedOk()); - LineSurfaceStub lineToCopy(pTransform, 2.0, 20.); - // Copy ctor + LineSurfaceStub lineToCopy(pTransform, 2., 20.); + + /// Copy ctor BOOST_CHECK(LineSurfaceStub(lineToCopy).constructedOk()); - // Copied and transformed ctor + + /// Copied and transformed ctor BOOST_CHECK( LineSurfaceStub(tgContext, lineToCopy, transform).constructedOk()); @@ -95,18 +101,18 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { // binningPosition() Translation3 translation{0., 1., 2.}; Transform3 transform(translation); - LineSurfaceStub line(transform, 2.0, 20.); + LineSurfaceStub line(transform, 2., 20.); Vector3 referencePosition{0., 1., 2.}; CHECK_CLOSE_ABS(referencePosition, line.binningPosition(tgContext, BinningValue::binX), 1e-6); - // + // bounds() - auto pLineBounds = std::make_shared(2., 10.0); + auto pLineBounds = std::make_shared(2., 10.); LineSurfaceStub boundedLine(transform, pLineBounds); const LineBounds& bounds = dynamic_cast(boundedLine.bounds()); - BOOST_CHECK_EQUAL(bounds, LineBounds(2., 10.0)); - // + BOOST_CHECK_EQUAL(bounds, LineBounds(2., 10.)); + // globalToLocal() Vector3 gpos{0., 1., 0.}; const Vector3 mom{20., 0., 0.}; // needs more realistic parameters @@ -114,7 +120,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { line.globalToLocal(tgContext, gpos, mom.normalized()).value(); const Vector2 expectedResult{0, -2}; CHECK_CLOSE_ABS(expectedResult, localPosition, 1e-6); - // + // intersection { const Vector3 direction{0., 1., 2.}; @@ -128,7 +134,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { 1e-6); // need more tests.. BOOST_CHECK_EQUAL(sfIntersection.object(), &line); } - // + // isOnSurface const Vector3 insidePosition{0., 2.5, 0.}; BOOST_CHECK(line.isOnSurface( @@ -137,7 +143,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { const Vector3 outsidePosition{100., 100., 200.}; BOOST_CHECK(!line.isOnSurface(tgContext, outsidePosition, mom, BoundaryTolerance::None())); - // + // localToGlobal Vector3 returnedGlobalPosition{0., 0., 0.}; // Vector2 localPosition{0., 0.}; @@ -146,7 +152,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { line.localToGlobal(tgContext, localPosition, momentum.normalized()); const Vector3 expectedGlobalPosition{0, 1, 0}; CHECK_CLOSE_ABS(returnedGlobalPosition, expectedGlobalPosition, 1e-6); - // + // referenceFrame Vector3 globalPosition{0., 0., 0.}; auto returnedRotationMatrix = @@ -155,42 +161,38 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { double v1 = std::sin(std::atan(2. / 3.)); RotationMatrix3 expectedRotationMatrix; expectedRotationMatrix << -v1, 0., v0, v0, 0., v1, 0., 1., -0.; - // std::cout<(unitXYZ); BOOST_CHECK_EQUAL(Surface::makeShared(unitXYZ)->type(), Surface::Perigee); - // + /// Constructor with transform Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); BOOST_CHECK_EQUAL(Surface::makeShared(pTransform)->type(), Surface::Perigee); - // + /// Copy constructor auto copiedPerigeeSurface = Surface::makeShared(*perigeeSurfaceObject); BOOST_CHECK_EQUAL(copiedPerigeeSurface->type(), Surface::Perigee); BOOST_CHECK(*copiedPerigeeSurface == *perigeeSurfaceObject); - // + /// Copied and transformed auto copiedTransformedPerigeeSurface = Surface::makeShared( tgContext, *perigeeSurfaceObject, pTransform); BOOST_CHECK_EQUAL(copiedTransformedPerigeeSurface->type(), Surface::Perigee); } -// + /// Unit test for testing PerigeeSurface properties BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) { /// Test clone method Vector3 unitXYZ{1., 1., 1.}; auto perigeeSurfaceObject = Surface::makeShared(unitXYZ); - // + /// Test type (redundant) BOOST_CHECK_EQUAL(perigeeSurfaceObject->type(), Surface::Perigee); - // + /// Test name BOOST_CHECK_EQUAL(perigeeSurfaceObject->name(), std::string("Acts::PerigeeSurface")); - // + /// Test dump boost::test_tools::output_test_stream dumpOutput; dumpOutput << perigeeSurfaceObject->toStream(tgContext); @@ -74,15 +75,18 @@ BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) { BOOST_AUTO_TEST_CASE(EqualityOperators) { Vector3 unitXYZ{1., 1., 1.}; - Vector3 invalidPosition{0.0, 0.0, 0.0}; + Vector3 invalidPosition{0., 0., 0.}; auto perigeeSurfaceObject = Surface::makeShared(unitXYZ); auto perigeeSurfaceObject2 = Surface::makeShared(unitXYZ); auto assignedPerigeeSurface = Surface::makeShared(invalidPosition); + /// Test equality operator BOOST_CHECK(*perigeeSurfaceObject == *perigeeSurfaceObject2); + /// Test assignment *assignedPerigeeSurface = *perigeeSurfaceObject; + /// Test equality of assigned to original BOOST_CHECK(*assignedPerigeeSurface == *perigeeSurfaceObject); } diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index 63f7b539372..99d0569b9d2 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -6,7 +6,7 @@ // 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 +#include #include #include "Acts/Definitions/Algebra.hpp" @@ -45,16 +45,20 @@ GeometryContext tgContext = GeometryContext(); BOOST_AUTO_TEST_SUITE(PlaneSurfaces) /// Unit test for creating compliant/non-compliant PlaneSurface object BOOST_AUTO_TEST_CASE(PlaneSurfaceConstruction) { - // PlaneSurface default constructor is deleted + /// Test default construction + // default construction is deleted + // bounds object, rectangle type auto rBounds = std::make_shared(3., 4.); /// Constructor with transform and bounds Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); - // constructor with transform + + /// Constructor with transform BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, rBounds)->type(), Surface::Plane); + /// Copy constructor auto planeSurfaceObject = Surface::makeShared(pTransform, rBounds); @@ -62,7 +66,7 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceConstruction) { Surface::makeShared(*planeSurfaceObject); BOOST_CHECK_EQUAL(copiedPlaneSurface->type(), Surface::Plane); BOOST_CHECK(*copiedPlaneSurface == *planeSurfaceObject); - // + /// Copied and transformed auto copiedTransformedPlaneSurface = Surface::makeShared( tgContext, *planeSurfaceObject, pTransform); @@ -74,11 +78,12 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceConstruction) { auto nullBounds = Surface::makeShared(nullptr, detElem), AssertionFailureException); } -// + /// Unit test for testing PlaneSurface properties BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { // bounds object, rectangle type auto rBounds = std::make_shared(3., 4.); + /// Test clone method Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); @@ -89,17 +94,18 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { auto pTransform2 = Transform3(translation2); auto planeSurfaceObject2 = Surface::makeShared(pTransform2, rBounds); + /// Test type (redundant) BOOST_CHECK_EQUAL(planeSurfaceObject->type(), Surface::Plane); - // + /// Test binningPosition Vector3 binningPosition{0., 1., 2.}; BOOST_CHECK_EQUAL( planeSurfaceObject->binningPosition(tgContext, BinningValue::binX), binningPosition); - // + /// Test referenceFrame - Vector3 arbitraryGlobalPosition{2.0, 2.0, 2.0}; + Vector3 arbitraryGlobalPosition{2., 2., 2.}; Vector3 momentum{1.e6, 1.e6, 1.e6}; RotationMatrix3 expectedFrame; expectedFrame << 1., 0., 0., 0., 1., 0., 0., 0., 1.; @@ -107,11 +113,11 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { CHECK_CLOSE_OR_SMALL(planeSurfaceObject->referenceFrame( tgContext, arbitraryGlobalPosition, momentum), expectedFrame, 1e-6, 1e-9); - // + /// Test normal, given 3D position Vector3 normal3D(0., 0., 1.); BOOST_CHECK_EQUAL(planeSurfaceObject->normal(tgContext), normal3D); - // + /// Test bounds BOOST_CHECK_EQUAL(planeSurfaceObject->bounds().type(), SurfaceBounds::eRectangle); @@ -120,13 +126,12 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { Vector2 localPosition{1.5, 1.7}; Vector3 globalPosition = planeSurfaceObject->localToGlobal(tgContext, localPosition, momentum); - // // expected position is the translated one Vector3 expectedPosition{1.5 + translation.x(), 1.7 + translation.y(), translation.z()}; CHECK_CLOSE_REL(globalPosition, expectedPosition, 1e-2); - // + /// Testing globalToLocal localPosition = planeSurfaceObject->globalToLocal(tgContext, globalPosition, momentum) @@ -159,8 +164,8 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { BoundaryTolerance::None())); BOOST_CHECK(!planeSurfaceObject->isOnSurface(tgContext, offSurface, BoundaryTolerance::None())); - // - // Test intersection + + /// Test intersection Vector3 direction{0., 0., 1.}; auto sfIntersection = planeSurfaceObject ->intersect(tgContext, offSurface, direction, @@ -173,30 +178,30 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { BOOST_CHECK_EQUAL(sfIntersection.pathLength(), expectedIntersect.pathLength()); BOOST_CHECK_EQUAL(sfIntersection.object(), planeSurfaceObject.get()); - // /// Test pathCorrection CHECK_CLOSE_REL(planeSurfaceObject->pathCorrection(tgContext, offSurface, momentum.normalized()), std::numbers::sqrt3, 0.01); - // + /// Test name BOOST_CHECK_EQUAL(planeSurfaceObject->name(), std::string("Acts::PlaneSurface")); - // + /// Test dump - // TODO 2017-04-12 msmk: check how to correctly check output - // boost::test_tools::output_test_stream dumpOuput; - // planeSurfaceObject.toStream(dumpOuput); - // BOOST_CHECK(dumpOuput.is_equal( - // "Acts::PlaneSurface\n" - // " Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n" - // " Rotation: colX = (1.000000, 0.000000, 0.000000)\n" - // " colY = (0.000000, 1.000000, 0.000000)\n" - // " colZ = (0.000000, 0.000000, 1.000000)\n" - // " Bounds : Acts::ConeBounds: (tanAlpha, minZ, maxZ, averagePhi, - // halfPhiSector) = (0.4142136, 0.0000000, inf, 0.0000000, - // 3.1415927)")); + boost::test_tools::output_test_stream dumpOutput; + dumpOutput << planeSurfaceObject->toStream(tgContext); + BOOST_CHECK(dumpOutput.is_equal( + "Acts::PlaneSurface\n" + " Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n" + " Rotation: colX = (1.000000, 0.000000, 0.000000)\n" + " colY = (0.000000, 1.000000, 0.000000)\n" + " colZ = (0.000000, 0.000000, 1.000000)\n" + " Bounds : Acts::RectangleBounds: (hlX, hlY) = (3.0000000, " + "4.0000000)\n" + "(lower left, upper right):\n" + "-3.0000000 -4.0000000\n" + "3.0000000 4.0000000")); } BOOST_AUTO_TEST_CASE(PlaneSurfaceEqualityOperators) { @@ -208,16 +213,18 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceEqualityOperators) { Surface::makeShared(pTransform, rBounds); auto planeSurfaceObject2 = Surface::makeShared(pTransform, rBounds); - // + /// Test equality operator BOOST_CHECK(*planeSurfaceObject == *planeSurfaceObject2); - // + BOOST_TEST_CHECKPOINT( "Create and then assign a PlaneSurface object to the existing one"); + /// Test assignment auto assignedPlaneSurface = Surface::makeShared(Transform3::Identity(), nullptr); *assignedPlaneSurface = *planeSurfaceObject; + /// Test equality of assigned to original BOOST_CHECK(*assignedPlaneSurface == *planeSurfaceObject); } @@ -283,10 +290,10 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceExtent) { } BOOST_AUTO_TEST_CASE(RotatedTrapezoid) { - double shortHalfX{100.}; - double longHalfX{200.}; - double halfY{300.}; - double rotAngle{45._degree}; + const double shortHalfX = 100.; + const double longHalfX = 200.; + const double halfY = 300.; + const double rotAngle = 45._degree; Vector2 edgePoint{longHalfX - 10., halfY}; diff --git a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp index 273462142a0..a25eeb4d352 100644 --- a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp @@ -30,10 +30,10 @@ const double rMax = 5.; const double halfPhiSector = std::numbers::pi / 8.; const double avgPhi = 0.1; -/// Unit tests for RadialBounds constrcuctors +/// Unit tests for RadialBounds constructors BOOST_AUTO_TEST_CASE(RadialBoundsConstruction) { - // test default construction - // RadialBounds defaultConstructedRadialBounds; should be deleted + /// Test default construction + // default construction is deleted /// Test construction with radii and default sector BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax).type(), SurfaceBounds::eDisc); @@ -93,15 +93,15 @@ BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { /// Test distanceToBoundary Vector2 outside(30., 0.); - Vector2 inSurface(2., 0.0); + Vector2 inSurface(2., 0.); /// Test dump - boost::test_tools::output_test_stream dumpOuput; - radialBoundsObject.toStream(dumpOuput); + boost::test_tools::output_test_stream dumpOutput; + radialBoundsObject.toStream(dumpOutput); BOOST_CHECK( - dumpOuput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, " - "hPhiSector, averagePhi) = (1.0000000, " - "5.0000000, 0.3926991, 0.0000000)")); + dumpOutput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, " + "hPhiSector, averagePhi) = (1.0000000, " + "5.0000000, 0.3926991, 0.0000000)")); /// Test inside BOOST_CHECK(radialBoundsObject.inside(inSurface, BoundaryTolerance::None())); @@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), rMax); /// Test averagePhi (should be a redundant method, this is not configurable) - BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.0); + BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.); /// Test halfPhiSector BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eHalfPhiSector), @@ -123,7 +123,9 @@ BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { /// Unit test for testing RadialBounds assignment BOOST_AUTO_TEST_CASE(RadialBoundsAssignment) { RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector); - // operator == not implemented in this class + + /// Test operator == + // not implemented in this class /// Test assignment RadialBounds assignedRadialBoundsObject(10.1, 123.); diff --git a/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp index 53c4df54861..ad310e393cf 100644 --- a/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp @@ -28,30 +28,35 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant RectangleBounds object BOOST_AUTO_TEST_CASE(RectangleBoundsConstruction) { - const double halfX(10.), halfY(5.); + const double halfX = 10.; + const double halfY = 5.; RectangleBounds twentyByTenRectangle(halfX, halfY); BOOST_CHECK_EQUAL(twentyByTenRectangle.type(), Acts::SurfaceBounds::eRectangle); - // + // nonsensical bounds are also permitted, but maybe should not be - const double zeroHalfX(0.), zeroHalfY(0.); - const double infHalfX(inf), infHalfY(inf); - // - // BOOST_TEST_MESSAGE("Initialise with zero dimensions"); + const double zeroHalfX = 0.; + const double zeroHalfY = 0.; + const double infHalfX = inf; + const double infHalfY = inf; + + // Initialise with zero dimensions RectangleBounds zeroDimensionsRectangle(zeroHalfX, zeroHalfY); BOOST_CHECK_EQUAL(zeroDimensionsRectangle.type(), Acts::SurfaceBounds::eRectangle); - // - // BOOST_TEST_MESSAGE("Initialise with infinite dimensions"); + + // Initialise with infinite dimensions RectangleBounds infinite(infHalfX, infHalfY); BOOST_CHECK_EQUAL(infinite.type(), Acts::SurfaceBounds::eRectangle); } /// Recreation BOOST_AUTO_TEST_CASE(RectangleBoundsRecreation) { - const double halfX(10.), halfY(2.); + const double halfX = 10.; + const double halfY = 2.; // != 5. + RectangleBounds original(halfX, halfY); - // const bool symmetric(false); + auto valvector = original.values(); std::array values{}; std::copy_n(valvector.begin(), RectangleBounds::eSize, values.begin()); @@ -61,7 +66,8 @@ BOOST_AUTO_TEST_CASE(RectangleBoundsRecreation) { // Exception tests BOOST_AUTO_TEST_CASE(RadialBoundsException) { - const double halfX(10.), halfY(2.); + const double halfX = 10.; + const double halfY = 2.; // != 5. // Negative x half length BOOST_CHECK_THROW(RectangleBounds(-halfX, halfY), std::logic_error); @@ -73,29 +79,33 @@ BOOST_AUTO_TEST_CASE(RadialBoundsException) { /// Unit test for testing RectangleBounds properties BOOST_TEST_DECORATOR(*boost::unit_test::tolerance(1e-10)) BOOST_AUTO_TEST_CASE(RectangleBoundsProperties) { - const double halfX(10.), halfY(5.); + const double halfX = 10.; + const double halfY = 5.; + RectangleBounds rect(halfX, halfY); - BOOST_CHECK_EQUAL(rect.halfLengthX(), 10.); - BOOST_CHECK_EQUAL(rect.halfLengthY(), 5.); + BOOST_CHECK_EQUAL(rect.halfLengthX(), halfX); + BOOST_CHECK_EQUAL(rect.halfLengthY(), halfY); CHECK_CLOSE_ABS(rect.min(), Vector2(-halfX, -halfY), 1e-6); CHECK_CLOSE_ABS(rect.max(), Vector2(halfX, halfY), 1e-6); const std::vector coords = { - {-10., -5.}, {10., -5.}, {10., 5.}, {-10., 5.}}; + {-halfX, -halfY}, {halfX, -halfY}, {halfX, halfY}, {-halfX, halfY}}; // equality, ensure ordering is ok const auto& rectVertices = rect.vertices(); BOOST_CHECK_EQUAL_COLLECTIONS(coords.cbegin(), coords.cend(), rectVertices.cbegin(), rectVertices.cend()); - const Vector2 pointA{1.0, 1.0}; + const Vector2 pointA{1., 1.}; // distance is signed, from boundary to point. (doesn't seem right, given BoundaryTolerance tolerance = BoundaryTolerance::None(); BOOST_CHECK(rect.inside(pointA, tolerance)); } BOOST_AUTO_TEST_CASE(RectangleBoundsAssignment) { - const double halfX(10.), halfY(2.); + const double halfX = 10.; + const double halfY = 2.; // != 5. + RectangleBounds rectA(halfX, halfY); - RectangleBounds rectB(0.0, 0.0); + RectangleBounds rectB(0., 0.); rectB = rectA; const auto originalVertices = rectA.vertices(); const auto assignedVertices = rectB.vertices(); diff --git a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp index 9756800eed2..2998ad0e799 100644 --- a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp @@ -30,13 +30,17 @@ namespace Acts::Test { GeometryContext tgContext = GeometryContext(); BOOST_AUTO_TEST_SUITE(StrawSurfaces) + +const double radius = 1.; +const double halfZ = 10.; +Translation3 translation{0., 1., 2.}; + /// Unit test for creating compliant/non-compliant StrawSurface object BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) { - // StrawSurface default constructor is deleted - // + /// Test default construction + // default construction is deleted + /// Constructor with transform, radius and halfZ - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); BOOST_CHECK_EQUAL( Surface::makeShared(Transform3::Identity(), radius, halfZ) @@ -45,21 +49,21 @@ BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) { BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, radius, halfZ)->type(), Surface::Straw); - // + /// Constructor with transform and LineBounds pointer auto pLineBounds = std::make_shared(radius, halfZ); BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, pLineBounds)->type(), Surface::Straw); - // + /// Constructor with LineBounds ptr, DetectorElement std::shared_ptr p = std::make_shared(1., 10.); - DetectorElementStub detElement{pTransform, p, 1.0, nullptr}; + DetectorElementStub detElement{pTransform, p, 1., nullptr}; BOOST_CHECK_EQUAL( Surface::makeShared(pLineBounds, detElement)->type(), Surface::Straw); - // + /// Copy constructor auto strawSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); @@ -67,29 +71,27 @@ BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) { Surface::makeShared(*strawSurfaceObject); BOOST_CHECK_EQUAL(copiedStrawSurface->type(), Surface::Straw); BOOST_CHECK(*copiedStrawSurface == *strawSurfaceObject); - // + /// Copied and transformed auto copiedTransformedStrawSurface = Surface::makeShared( tgContext, *strawSurfaceObject, pTransform); BOOST_CHECK_EQUAL(copiedTransformedStrawSurface->type(), Surface::Straw); } -// + /// Unit test for testing StrawSurface properties BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) { /// Test clone method - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); auto strawSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); - // + /// Test type (redundant) BOOST_CHECK_EQUAL(strawSurfaceObject->type(), Surface::Straw); - // + /// Test name BOOST_CHECK_EQUAL(strawSurfaceObject->name(), std::string("Acts::StrawSurface")); - // + /// Test dump boost::test_tools::output_test_stream dumpOutput; dumpOutput << strawSurfaceObject->toStream(tgContext); @@ -103,24 +105,24 @@ BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) { } BOOST_AUTO_TEST_CASE(EqualityOperators) { - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); auto strawSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); - // + auto strawSurfaceObject2 = Surface::makeShared(pTransform, radius, halfZ); - // + /// Test equality operator BOOST_CHECK(*strawSurfaceObject == *strawSurfaceObject2); - // + BOOST_TEST_CHECKPOINT( "Create and then assign a StrawSurface object to the existing one"); + /// Test assignment auto assignedStrawSurface = Surface::makeShared(Transform3::Identity(), 6.6, 33.33); *assignedStrawSurface = *strawSurfaceObject; + /// Test equality of assigned to original BOOST_CHECK(*assignedStrawSurface == *strawSurfaceObject); } diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp index e48d3bcb0f3..2d62f29f4e4 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp @@ -136,7 +136,6 @@ struct SurfaceArrayFixture { 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, std::numbers::pi / 9., w, h); res.insert(res.end(), ring.begin(), ring.end()); @@ -227,7 +226,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArray_create, SurfaceArrayFixture) { SurfaceArray::SurfaceGridLookup>( transform, itransform, std::make_tuple(std::move(phiAxis), std::move(zAxis))); - // do NOT fill, only completebinning + // do NOT fill, only complete binning sl2->completeBinning(tgContext, brlRaw); SurfaceArray sa2(std::move(sl2), brl); sa.toStream(tgContext, std::cout); @@ -241,7 +240,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArray_create, SurfaceArrayFixture) { } BOOST_AUTO_TEST_CASE(SurfaceArray_singleElement) { - double w = 3, h = 4; + const double w = 3; + const double h = 4; auto bounds = std::make_shared(w, h); auto srf = Surface::makeShared(Transform3::Identity(), bounds); @@ -255,7 +255,8 @@ BOOST_AUTO_TEST_CASE(SurfaceArray_singleElement) { } BOOST_AUTO_TEST_CASE(SurfaceArray_manyElementsSingleLookup) { - double w = 3, h = 4; + const double w = 3; + const double h = 4; auto bounds = std::make_shared(w, h); auto srf0 = Surface::makeShared(Transform3::Identity(), bounds); auto srf1 = Surface::makeShared(Transform3::Identity(), bounds); diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp index 3de53a2b628..e150e9a64c9 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp @@ -57,7 +57,9 @@ class SurfaceBoundsStub : public SurfaceBounds { } // namespace Acts namespace Acts::Test { + BOOST_AUTO_TEST_SUITE(Surfaces) + /// Unit test for creating compliant/non-compliant SurfaceBounds object BOOST_AUTO_TEST_CASE(SurfaceBoundsConstruction) { SurfaceBoundsStub u; @@ -65,6 +67,7 @@ BOOST_AUTO_TEST_CASE(SurfaceBoundsConstruction) { SurfaceBoundsStub t(s); SurfaceBoundsStub v(u); } + BOOST_AUTO_TEST_CASE(SurfaceBoundsProperties) { SurfaceBoundsStub surface(5); std::vector reference{0, 1, 2, 3, 4}; @@ -72,6 +75,7 @@ BOOST_AUTO_TEST_CASE(SurfaceBoundsProperties) { BOOST_CHECK_EQUAL_COLLECTIONS(reference.cbegin(), reference.cend(), boundValues.cbegin(), boundValues.cend()); } + /// Unit test for testing SurfaceBounds properties BOOST_AUTO_TEST_CASE(SurfaceBoundsEquality) { SurfaceBoundsStub surface(1); @@ -79,15 +83,18 @@ BOOST_AUTO_TEST_CASE(SurfaceBoundsEquality) { SurfaceBoundsStub differentSurface(2); BOOST_CHECK_EQUAL(surface, copiedSurface); BOOST_CHECK_NE(surface, differentSurface); + SurfaceBoundsStub assignedSurface; assignedSurface = surface; BOOST_CHECK_EQUAL(surface, assignedSurface); + const auto& surfaceboundValues = surface.values(); const auto& assignedboundValues = assignedSurface.values(); BOOST_CHECK_EQUAL_COLLECTIONS( surfaceboundValues.cbegin(), surfaceboundValues.cend(), assignedboundValues.cbegin(), assignedboundValues.cend()); } + BOOST_AUTO_TEST_SUITE_END() } // namespace Acts::Test diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index eda3f6d2db6..e6294fc27ca 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -43,8 +43,8 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// This tests the intersection with cylinders /// and looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { - double radius = 1_m; - double halfZ = 10_m; + const double radius = 1_m; + const double halfZ = 10_m; auto testCylinderIntersection = [&](const Transform3& transform) -> void { // A cylinder created aligned with a provided transform @@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { /// This tests the intersection with cylinders /// and looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { - double alpha = std::numbers::pi / 4.; + const double alpha = std::numbers::pi / 4.; auto testConeIntersection = [&](const Transform3& transform) -> void { // A cone surface ready to use @@ -226,8 +226,8 @@ BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { /// sufficient /// - it looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { - double halfX = 1_m; - double halfY = 10_m; + const double halfX = 1_m; + const double halfY = 10_m; auto testPlanarIntersection = [&](const Transform3& transform) -> void { // A Plane created with a specific transform @@ -325,8 +325,8 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { /// sufficient /// - it looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(LineIntersectionTest) { - double radius = 1_m; - double halfZ = 10_m; + const double radius = 1_m; + const double halfZ = 10_m; auto testLineAppraoch = [&](const Transform3& transform) -> void { // A Plane created with a specific transform diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp index d399c3ff8cc..11c66abf303 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp @@ -77,9 +77,9 @@ void runTest(const Surface& surface, double l0, double l1, double phi, // local positions const auto posAngle = bdata::xrange(-std::numbers::pi, std::numbers::pi, 0.25); -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.25); +const auto posPositiveNonzero = bdata::xrange(0.25, 1., 0.25); +const auto posPositive = bdata::make(0.) + posPositiveNonzero; +const auto posSymmetric = bdata::xrange(-1., 1., 0.25); // direction angles const auto phis = bdata::xrange(-std::numbers::pi, std::numbers::pi, std::numbers::pi / 4.); @@ -97,7 +97,7 @@ const auto cones = bdata::make({ }); const auto cylinders = bdata::make({ Surface::makeShared(Transform3::Identity(), - 10.0 /* radius */, 100 /* half z */), + 10. /* radius */, 100 /* half z */), }); const auto discs = bdata::make({ Surface::makeShared(Transform3::Identity(), 0 /* radius min */, @@ -112,8 +112,8 @@ const auto planes = bdata::make({ CurvilinearSurface(Vector3(3, -4, 5), Vector3::UnitZ()).planeSurface(), }); const auto straws = bdata::make({ - Surface::makeShared(Transform3::Identity(), 2.0 /* radius */, - 200.0 /* half z */), + Surface::makeShared(Transform3::Identity(), 2. /* radius */, + 200. /* half z */), }); } // namespace @@ -127,7 +127,7 @@ BOOST_DATA_TEST_CASE(ConeSurface, // local parameter r*phi has limits that depend on the z position const auto r = lz * surface->bounds().tanAlpha(); // local coordinates are singular at z = 0 -> normalize local phi - runTest(*surface, (0 < lz) ? (r * lphi) : 0.0, lz, phi, theta); + runTest(*surface, (0 < lz) ? (r * lphi) : 0., lz, phi, theta); } BOOST_DATA_TEST_CASE(CylinderSurface, @@ -139,7 +139,7 @@ BOOST_DATA_TEST_CASE(CylinderSurface, BOOST_DATA_TEST_CASE(DiscSurface, discs* posPositive* posAngle* phis* thetas, surface, lr, lphi, phi, theta) { // local coordinates are singular at r = 0 -> normalize local phi - runTest(*surface, lr, (0 < lr) ? lphi : 0.0, phi, theta); + runTest(*surface, lr, (0 < lr) ? lphi : 0., phi, theta); } BOOST_DATA_TEST_CASE( diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp index ce745bec85c..c61508a6d89 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp @@ -78,7 +78,7 @@ class SurfaceStub : public RegularSurface { /// Inherited from GeometryObject base Vector3 binningPosition(const GeometryContext& /*txt*/, BinningValue /*bValue*/) const final { - const Vector3 v{0.0, 0.0, 0.0}; + const Vector3 v{0., 0., 0.}; return v; } diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp index 654bed3b8ff..e4c214b53d8 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp @@ -82,52 +82,60 @@ BOOST_AUTO_TEST_CASE(SurfaceProperties) { std::make_shared(makePercentSlab()); DetectorElementStub detElement{pTransform, pPlanarBound, 0.2, pMaterial}; SurfaceStub surface(detElement); + // associatedDetectorElement BOOST_CHECK_EQUAL(surface.associatedDetectorElement(), &detElement); - // test associatelayer, associatedLayer + + // test associatelayer, associatedLayer surface.associateLayer(*pLayer); BOOST_CHECK_EQUAL(surface.associatedLayer(), pLayer.get()); + // associated Material is not set to the surface // it is set to the detector element surface though BOOST_CHECK_NE(surface.surfaceMaterial(), pMaterial.get()); + // center() CHECK_CLOSE_OR_SMALL(reference, surface.center(tgContext), 1e-6, 1e-9); + // insideBounds - Vector2 localPosition{0.1, 3.0}; + Vector2 localPosition{0.1, 3.}; BOOST_CHECK(surface.insideBounds(localPosition)); Vector2 outside{20., 20.}; BOOST_CHECK(surface.insideBounds( outside)); // should return false, but doesn't because SurfaceStub has // "no bounds" hard-coded Vector3 mom{100., 200., 300.}; + // isOnSurface BOOST_CHECK(surface.isOnSurface(tgContext, reference, mom, BoundaryTolerance::Infinite())); BOOST_CHECK(surface.isOnSurface( tgContext, reference, mom, BoundaryTolerance::None())); // need to improve bounds() + // referenceFrame() RotationMatrix3 unitary; unitary << 1, 0, 0, 0, 1, 0, 0, 0, 1; auto referenceFrame = - surface.referenceFrame(tgContext, Vector3{1, 2, 3}.normalized(), - mom); // need more complex case to test + surface.referenceFrame(tgContext, Vector3{1, 2, 3}.normalized(), mom); BOOST_CHECK_EQUAL(referenceFrame, unitary); + // normal() auto normal = surface.normal(tgContext, Vector3{1, 2, 3}.normalized(), - Vector3::UnitZ()); // needs more - // complex test + Vector3::UnitZ()); Vector3 zero{0., 0., 0.}; BOOST_CHECK_EQUAL(zero, normal); + // pathCorrection is pure virtual + // surfaceMaterial() auto pNewMaterial = std::make_shared(makePercentSlab()); surface.assignSurfaceMaterial(pNewMaterial); - BOOST_CHECK_EQUAL(surface.surfaceMaterial(), - pNewMaterial.get()); // passes ?? - // + BOOST_CHECK_EQUAL(surface.surfaceMaterial(), pNewMaterial.get()); + CHECK_CLOSE_OR_SMALL(surface.transform(tgContext), pTransform, 1e-6, 1e-9); + // type() is pure virtual } @@ -140,6 +148,7 @@ BOOST_AUTO_TEST_CASE(EqualityOperators) { Translation3 translation2{1., 1., 2.}; auto pTransform1 = Transform3(translation1); auto pTransform2 = Transform3(translation2); + // build a planeSurface to be compared auto planeSurface = Surface::makeShared(pTransform1, pPlanarBound); @@ -149,27 +158,20 @@ BOOST_AUTO_TEST_CASE(EqualityOperators) { DetectorElementStub detElement1{pTransform1, pPlanarBound, 0.2, pMaterial}; DetectorElementStub detElement2{pTransform1, pPlanarBound, 0.3, pMaterial}; DetectorElementStub detElement3{pTransform2, pPlanarBound, 0.3, pMaterial}; - // + SurfaceStub surface1(detElement1); SurfaceStub surface2(detElement1); // 1 and 2 are the same SurfaceStub surface3(detElement2); // 3 differs in thickness SurfaceStub surface4(detElement3); // 4 has a different transform and id SurfaceStub surface5(detElement1); surface5.assignSurfaceMaterial(pMaterial); // 5 has non-null surface material - // + BOOST_CHECK(surface1 == surface2); - // - // remove test for the moment, - // surfaces do not have a concept of thickness (only detector elements have) - // only thickness is different here - // - // BOOST_CHECK_NE(surface1, surface3); // will fail - // + BOOST_CHECK(surface1 != surface3); BOOST_CHECK(surface1 != surface4); - // BOOST_CHECK(surface1 != surface5); - // BOOST_CHECK(surface1 != *planeSurface); + // Test the getSharedPtr const auto surfacePtr = Surface::makeShared(detElement1); const auto sharedSurfacePtr = surfacePtr->getSharedPtr(); diff --git a/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp index 35fb2cfb343..0e9f1bba029 100644 --- a/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp @@ -32,13 +32,15 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) +const double minHalfX = 1.; +const double maxHalfX = 6.; +const double halfY = 2.; + /// Unit test for creating compliant/non-compliant TrapezoidBounds object BOOST_AUTO_TEST_CASE(TrapezoidBoundsConstruction) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); - // - // default construction deleted - // TrapezoidBounds defaultConstructedTrapezoidBounds; - // + /// Test default construction + // default construction is deleted + /// Test construction with defining half lengths BOOST_CHECK_EQUAL(TrapezoidBounds(minHalfX, maxHalfX, halfY).type(), SurfaceBounds::eTrapezoid); @@ -50,7 +52,6 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsConstruction) { /// Unit test for creating compliant/non-compliant TrapezoidBounds object BOOST_AUTO_TEST_CASE(TrapezoidBoundsRecreated) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); /// Copy constructor TrapezoidBounds original(minHalfX, maxHalfX, halfY); // const bool symmetric(false); @@ -63,8 +64,6 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsRecreated) { // Exception tests BOOST_AUTO_TEST_CASE(TrapezoidBoundsException) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); - // Negative x at min y BOOST_CHECK_THROW(TrapezoidBounds(-minHalfX, maxHalfX, halfY), std::logic_error); @@ -84,25 +83,23 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsException) { /// Unit tests for TrapezoidBounds properties BOOST_AUTO_TEST_CASE(TrapezoidBoundsProperties) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); - // TrapezoidBounds trapezoidBoundsObject(minHalfX, maxHalfX, halfY); - // + /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(trapezoidBoundsObject.type(), SurfaceBounds::eTrapezoid); - // + /// Test minHalflengthX BOOST_CHECK_EQUAL( trapezoidBoundsObject.get(TrapezoidBounds::eHalfLengthXnegY), minHalfX); - // + /// Test maxHalfLengthX BOOST_CHECK_EQUAL( trapezoidBoundsObject.get(TrapezoidBounds::eHalfLengthXposY), maxHalfX); - // + /// Test halflengthY BOOST_CHECK_EQUAL(trapezoidBoundsObject.get(TrapezoidBounds::eHalfLengthY), halfY); - // + /// Test distanceToBoundary Vector2 outside(30., 0.); Vector2 inRectangle(2., 0.5); @@ -114,24 +111,18 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsProperties) { BOOST_CHECK_EQUAL_COLLECTIONS(actualVertices.cbegin(), actualVertices.cend(), expectedVertices.cbegin(), expectedVertices.cend()); - /** - for (auto i: trapezoidBoundsObject.vertices()){ - std::cout<(-3, 3))) ^ - bdata::xrange(1000) * bdata::make({0.0, 0.1, 0.2, 0.3}), + bdata::xrange(1000) * bdata::make({0., 0.1, 0.2, 0.3}), x, y, index, tol) { (void)index; - double minHalfX(1.), maxHalfX(6.), halfY(2.); + static const TrapezoidBounds trapezoidBoundsObject(minHalfX, maxHalfX, halfY); static const auto vertices = trapezoidBoundsObject.vertices(); BoundaryTolerance tolerance = BoundaryTolerance::None(); - if (tol != 0.0) { + if (tol != 0.) { tolerance = BoundaryTolerance::AbsoluteBound{tol, tol}; } @@ -211,10 +201,11 @@ BOOST_DATA_TEST_CASE( /// Unit test for testing TrapezoidBounds assignment BOOST_AUTO_TEST_CASE(TrapezoidBoundsAssignment) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); TrapezoidBounds trapezoidBoundsObject(minHalfX, maxHalfX, halfY); - // operator == not implemented in this class - // + + /// Test operator == + // not implemented in this class + /// Test assignment TrapezoidBounds assignedTrapezoidBoundsObject(10., 20., 14.2); assignedTrapezoidBoundsObject = trapezoidBoundsObject; diff --git a/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp b/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp index 4a01ef7da87..ecd464b42d7 100644 --- a/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp @@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(GenerateCircleEllipseVertices) { expectedVertices = 41u; // 4 sectors + 1 overlap at (-pi/pi) BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); - // Now ellipsiod + // Now ellipsoid ActsScalar riy = 4.; ActsScalar roy = 14.; vertices = VerticesHelper::ellipsoidVertices(ri, riy, ro, roy, 0., From e8e1c0e9447c4ecf0831f3f1fb5c10bc4172198b Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Sun, 27 Oct 2024 12:40:03 +0100 Subject: [PATCH 09/16] fix --- Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp b/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp index 373f5b11ea6..5d0c5601bea 100644 --- a/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp +++ b/Core/include/Acts/TrackFitting/BetheHeitlerApprox.hpp @@ -87,7 +87,7 @@ struct BetheHeitlerApproxSingleCmp { ret[0].weight = 1.0; - const double c = x / std::numbers::sqrt2; + 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); From 40629454e357a76c7f3c6a39d9084e30170027a2 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Mon, 28 Oct 2024 11:44:57 +0100 Subject: [PATCH 10/16] format after conflict --- Examples/Io/Csv/src/CsvSeedWriter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples/Io/Csv/src/CsvSeedWriter.cpp b/Examples/Io/Csv/src/CsvSeedWriter.cpp index 0331fce5cdc..29dd72ce8df 100644 --- a/Examples/Io/Csv/src/CsvSeedWriter.cpp +++ b/Examples/Io/Csv/src/CsvSeedWriter.cpp @@ -125,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) < std::numbers::pi_v - ? std::abs(truthPhi - seedPhi) - : std::abs(truthPhi - seedPhi) - std::numbers::pi_v; + 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 From 0790c3fbc58a5384dee2e9fa34dc2dad85521f55 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Wed, 30 Oct 2024 08:58:19 +0100 Subject: [PATCH 11/16] fix after conflicts --- Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index b4d68f27374..295efc3b511 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -454,7 +454,7 @@ void test_multi_stepper_surface_status_update() { cmps(2, {0.5, BoundVector::Zero(), std::nullopt}); 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[1])[eBoundTheta] = std::numbers::pi / 2.; std::get(cmps[0])[eBoundQOverP] = 1.0; std::get(cmps[1])[eBoundQOverP] = 1.0; @@ -566,7 +566,7 @@ void test_component_bound_state() { cmps(2, {0.5, BoundVector::Zero(), std::nullopt}); 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[1])[eBoundTheta] = std::numbers::pi / 2.; std::get(cmps[0])[eBoundQOverP] = 1.0; std::get(cmps[1])[eBoundQOverP] = 1.0; From f68182105ebae841d814236c75950d8902ff0563 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 7 Nov 2024 09:47:23 +0100 Subject: [PATCH 12/16] use just pi in comments --- .../Acts/Seeding/detail/CylindricalSpacePointGrid.hpp | 8 ++++---- .../Core/Detector/IndexedSurfacesGeneratorTests.cpp | 6 ++---- Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp | 2 +- Tests/UnitTests/Core/Utilities/BinningDataTests.cpp | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp index 18356afc4a4..dcbe2289ffb 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp @@ -71,10 +71,10 @@ 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*std::numbers::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 + // 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 // cover the full phi-range of minPT), leave this at 1. int phiBinDeflectionCoverage = 1; // maximum number of phi bins diff --git a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp index 0e9c232afc4..f95adbdcb3b 100644 --- a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp @@ -82,8 +82,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { BOOST_CHECK(grid.atPosition(p) == reference); - // Check that surfaces 0, 1, 21 build the bins at phi == -std::numbers::pi + - // epsilon + // Check that surfaces 0, 1, 21 build the bins at phi == -pi + epsilon reference = {0, 1, 21}; p = {-std::numbers::pi + 0.05}; BOOST_CHECK(grid.atPosition(p) == reference); @@ -130,8 +129,7 @@ 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 == -std::numbers::pi + - // epsilon + // Check that surfaces 0, 1, 21 build the bins at phi == -pi + epsilon reference = {0, 1, 21, 22}; p = {-std::numbers::pi + 0.05}; BOOST_CHECK(grid.atPosition(p) == reference); 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/Utilities/BinningDataTests.cpp b/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp index 0ad82ec9707..95de3899f92 100644 --- a/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp @@ -380,8 +380,8 @@ 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/+std::numbers::pi are checked - // above one module expands over -M_Pi/+std::numbers::pi + // 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, From a75005b365eb96153fff1a53dde8843f8aff0358 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 7 Nov 2024 10:39:44 +0100 Subject: [PATCH 13/16] review CarloVarni --- Core/include/Acts/Utilities/Frustum.ipp | 2 +- Core/include/Acts/Utilities/detail/periodic.hpp | 2 +- .../Acts/Vertexing/SingleSeedVertexFinder.ipp | 15 ++++++++------- .../src/Detector/detail/SupportSurfacesHelper.cpp | 9 ++++++--- .../src/MockupSectorBuilder.cpp | 5 +++-- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Core/include/Acts/Utilities/Frustum.ipp b/Core/include/Acts/Utilities/Frustum.ipp index 0b3a1335181..bca40c35464 100644 --- a/Core/include/Acts/Utilities/Frustum.ipp +++ b/Core/include/Acts/Utilities/Frustum.ipp @@ -50,7 +50,7 @@ Acts::Frustum::Frustum(const VertexType& origin, m_normals[0] = ldir; - const value_type phi_sep = 2 * std::numbers::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 d779aa72b0d..a2fdd823b48 100644 --- a/Core/include/Acts/Utilities/detail/periodic.hpp +++ b/Core/include/Acts/Utilities/detail/periodic.hpp @@ -82,7 +82,7 @@ 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 (std::numbers::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 += std::numbers::pi_v; diff --git a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp index 7c46410d784..83b13d37d57 100644 --- a/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/SingleSeedVertexFinder.ipp @@ -195,7 +195,7 @@ Acts::SingleSeedVertexFinder::findTriplets( Acts::ActsScalar angleZfrom = std::atan2(rMiddle[isLessFrom], deltaZfrom) + m_cfg.maxXYZdeviation; std::uint32_t nearZFrom = 0; - if (angleZfrom < std::numbers::pi) { + if (angleZfrom < std::numbers::pi_v) { Acts::ActsScalar new_deltaZfrom = rMiddle[isLessFrom] / std::tan(angleZfrom) / zBinLength; nearZFrom = static_cast(std::max( @@ -218,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; @@ -227,7 +227,7 @@ Acts::SingleSeedVertexFinder::findTriplets( std::atan2(rFarDelta[isMiddleLess], delta2Zfrom) + m_cfg.maxXYZdeviation; std::uint32_t farZFrom = 0; - if (angle2Zfrom < std::numbers::pi) { + if (angle2Zfrom < std::numbers::pi_v) { farZFrom = static_cast(std::max( (rFarDelta[isMiddleLess] / std::tan(angle2Zfrom) / zBinLength) + middleZ, @@ -299,7 +299,8 @@ Acts::SingleSeedVertexFinder::findTriplets( sortedSpacepoints.getSP(2, farPhi, farZ)) { Acts::ActsScalar phiC = farSP.second; Acts::ActsScalar deltaPhiBC = detail::difference_periodic( - phiB, phiC, 2 * std::numbers::pi); + phiB, phiC, + static_cast(2 * std::numbers::pi)); if (std::abs(deltaPhiBC) > m_cfg.maxPhideviation) { continue; } @@ -333,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 * std::numbers::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/src/Detector/detail/SupportSurfacesHelper.cpp b/Core/src/Detector/detail/SupportSurfacesHelper.cpp index 7bd622de06d..62916abe39c 100644 --- a/Core/src/Detector/detail/SupportSurfacesHelper.cpp +++ b/Core/src/Detector/detail/SupportSurfacesHelper.cpp @@ -193,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 = -std::numbers::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; @@ -272,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 = -std::numbers::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 - std::numbers::pi / 2., zAxis)); + AngleAxis3(phi - static_cast(std::numbers::pi / 2.), + zAxis)); // Place it dSupport.push_back( Surface::makeShared(sTransform, sTrapezoid)); diff --git a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp index 20b8cec575e..f6431c5ddbe 100644 --- a/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp +++ b/Examples/Detectors/MuonSpectrometerMockupDetector/src/MockupSectorBuilder.cpp @@ -189,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); - double sectorAngle = std::numbers::pi; + Acts::ActsScalar sectorAngle = std::numbers::pi_v; - double halfPhi = std::numbers::pi / mCfg.NumberOfSectors; + Acts::ActsScalar halfPhi = + std::numbers::pi_v / mCfg.NumberOfSectors; if (mCfg.NumberOfSectors == 1) { halfPhi = (phiB - phiA) / 2; From ff3e994247e3777a5fe16af022bb370455d53bd0 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 7 Nov 2024 11:04:10 +0100 Subject: [PATCH 14/16] cleanup --- .../UnitTests/Core/Utilities/BoundingBoxTest.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp index 7be37ef7443..f3aa6b2de14 100644 --- a/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp +++ b/Tests/UnitTests/Core/Utilities/BoundingBoxTest.cpp @@ -442,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()); @@ -473,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 @@ -498,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; From f6f16b9e114a9ea33003837c8f58a29b2395c137 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Thu, 7 Nov 2024 11:07:11 +0100 Subject: [PATCH 15/16] missed case --- Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index 295efc3b511..3fee9d4b6dd 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -128,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(); From 433f26253986d7e8fdef2221a2ea129cdd4269c7 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Sun, 10 Nov 2024 21:25:01 +0100 Subject: [PATCH 16/16] resolve conflicts --- .../EventData/detail/CalculateResiduals.hpp | 97 ------------------- 1 file 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 7d473786179..00000000000 --- a/Core/include/Acts/EventData/detail/CalculateResiduals.hpp +++ /dev/null @@ -1,97 +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 - -#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 * std::numbers::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