diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index c946b38cd66..f33bb927f40 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -22,7 +22,7 @@ env: CCACHE_MAXSIZE: 1.25G CCACHE_KEY_SUFFIX: r2 ACTS_LOG_FAILURE_THRESHOLD: WARNING - DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.v4.tar.zst + DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.v5.tar.zst # NOTE this only builds core unittests to reduce the output size. if we # found a way to have Github actions not fail regularly with this job diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 010b7ff8963..2d565795d9f 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -20,6 +20,7 @@ env: CCACHE_DIR: ${{ github.workspace }}/ccache CCACHE_MAXSIZE: 500M CCACHE_KEY_SUFFIX: r2 + DEPENDENCY_TAG: v5 jobs: linux_ubuntu: @@ -28,7 +29,6 @@ jobs: env: INSTALL_DIR: ${{ github.workspace }}/install ACTS_LOG_FAILURE_THRESHOLD: WARNING - DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.v4.tar.zst steps: - uses: actions/checkout@v4 @@ -36,6 +36,9 @@ jobs: submodules: true lfs: true + - name: Set dependencies URL + run: echo "DEPENDENCY_URL=https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.${DEPENDENCY_TAG}.tar.zst" >> $GITHUB_ENV + - name: Install dependencies run: CI/dependencies.sh @@ -114,7 +117,6 @@ jobs: needs: [linux_ubuntu] env: ACTS_SEQUENCER_DISABLE_FPEMON: true - DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.v4.tar.zst steps: - uses: actions/checkout@v4 @@ -122,6 +124,9 @@ jobs: submodules: true lfs: true + - name: Set dependencies URL + run: echo "DEPENDENCY_URL=https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.${DEPENDENCY_TAG}.tar.zst" >> $GITHUB_ENV + - name: Install dependencies run: CI/dependencies.sh @@ -152,7 +157,6 @@ jobs: needs: [linux_ubuntu] env: ACTS_SEQUENCER_DISABLE_FPEMON: true - DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.v4.tar.zst steps: - uses: actions/checkout@v4 @@ -161,6 +165,10 @@ jobs: lfs: true - run: apt-get update && apt-get install -y time + + - name: Set dependencies URL + run: echo "DEPENDENCY_URL=https://acts.web.cern.ch/ACTS/ci/ubuntu-24.04/deps.${DEPENDENCY_TAG}.tar.zst" >> $GITHUB_ENV + - name: Install dependencies run: CI/dependencies.sh @@ -246,13 +254,16 @@ jobs: env: INSTALL_DIR: ${{ github.workspace }}/install ACTS_LOG_FAILURE_THRESHOLD: WARNING - DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-22.04/deps.v4.tar.zst + steps: - uses: actions/checkout@v4 with: submodules: true lfs: true + - name: Set dependencies URL + run: echo "DEPENDENCY_URL=https://acts.web.cern.ch/ACTS/ci/ubuntu-22.04/deps.${DEPENDENCY_TAG}.tar.zst" >> $GITHUB_ENV + - name: Install dependencies run: CI/dependencies.sh @@ -320,7 +331,7 @@ jobs: env: INSTALL_DIR: ${{ github.workspace }}/install_acts ACTS_LOG_FAILURE_THRESHOLD: WARNING - DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/macos-14/deps.v4.tar.zst + steps: - uses: actions/checkout@v4 with: @@ -330,6 +341,9 @@ jobs: - name: Print architecture run: uname -p + - name: Set dependencies URL + run: echo "DEPENDENCY_URL=https://acts.web.cern.ch/ACTS/ci/macos-14/deps.${DEPENDENCY_TAG}.tar.zst" >> $GITHUB_ENV + - name: Install dependencies run: > brew install cmake ninja ccache xerces-c diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a5cbbce542e..4c6a7b166fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ variables: CCACHE_KEY_SUFFIX: r2 CTEST_OUTPUT_ON_FAILURE: 1 - DEPENDENCY_TAG: v4 + DEPENDENCY_TAG: v5 clang_tidy: stage: build diff --git a/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp b/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp index f624cd88aee..38f297764b1 100644 --- a/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp +++ b/Core/include/Acts/EventData/GenericBoundTrackParameters.hpp @@ -9,6 +9,7 @@ #pragma once #include "Acts/Definitions/Tolerance.hpp" +#include "Acts/EventData/TrackParameterHelpers.hpp" #include "Acts/EventData/TransformationHelpers.hpp" #include "Acts/EventData/detail/PrintParameters.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -18,7 +19,6 @@ #include #include #include -#include namespace Acts { @@ -61,7 +61,10 @@ class GenericBoundTrackParameters { m_cov(std::move(cov)), m_surface(std::move(surface)), m_particleHypothesis(std::move(particleHypothesis)) { - assert(m_surface); + // TODO set `validateAngleRange` to `true` after fixing caller code + assert(isBoundVectorValid(m_params, false) && + "Invalid bound parameters vector"); + assert(m_surface != nullptr && "Reference surface must not be null"); normalizePhiTheta(); } diff --git a/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp b/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp index 214aa2e1551..7a2b4b46522 100644 --- a/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp +++ b/Core/include/Acts/EventData/GenericFreeTrackParameters.hpp @@ -11,6 +11,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Common.hpp" #include "Acts/Definitions/TrackParametrization.hpp" +#include "Acts/EventData/TrackParameterHelpers.hpp" #include "Acts/EventData/TrackParametersConcept.hpp" #include "Acts/EventData/TransformationHelpers.hpp" #include "Acts/EventData/detail/PrintParameters.hpp" @@ -18,10 +19,8 @@ #include "Acts/Utilities/UnitVectors.hpp" #include "Acts/Utilities/VectorHelpers.hpp" -#include #include #include -#include namespace Acts { @@ -55,7 +54,9 @@ class GenericFreeTrackParameters { ParticleHypothesis particleHypothesis) : m_params(params), m_cov(std::move(cov)), - m_particleHypothesis(std::move(particleHypothesis)) {} + m_particleHypothesis(std::move(particleHypothesis)) { + assert(isFreeVectorValid(m_params) && "Invalid free parameters vector"); + } /// Construct from four-position, direction, absolute momentum, and charge. /// @@ -78,6 +79,8 @@ class GenericFreeTrackParameters { m_params[eFreeDir1] = dir[eMom1]; m_params[eFreeDir2] = dir[eMom2]; m_params[eFreeQOverP] = qOverP; + + assert(isFreeVectorValid(m_params) && "Invalid free parameters vector"); } /// Construct from four-position, angles, absolute momentum, and charge. @@ -103,6 +106,8 @@ class GenericFreeTrackParameters { m_params[eFreeDir1] = dir[eMom1]; m_params[eFreeDir2] = dir[eMom2]; m_params[eFreeQOverP] = qOverP; + + assert(isFreeVectorValid(m_params) && "Invalid free parameters vector"); } /// Converts a free track parameter with a different hypothesis. diff --git a/Core/include/Acts/EventData/Seed.hpp b/Core/include/Acts/EventData/Seed.hpp index db93b319dcb..f3c6707b2e1 100644 --- a/Core/include/Acts/EventData/Seed.hpp +++ b/Core/include/Acts/EventData/Seed.hpp @@ -14,8 +14,9 @@ namespace Acts { template - requires(N >= 3ul) class Seed { + static_assert(N >= 3ul); + public: using value_type = external_spacepoint_t; static constexpr std::size_t DIM = N; diff --git a/Core/include/Acts/EventData/Seed.ipp b/Core/include/Acts/EventData/Seed.ipp index 74f2c0e4169..e977a3d67d7 100644 --- a/Core/include/Acts/EventData/Seed.ipp +++ b/Core/include/Acts/EventData/Seed.ipp @@ -9,7 +9,6 @@ namespace Acts { template - requires(N >= 3ul) template requires(sizeof...(args_t) == N) && (std::same_as && ...) @@ -17,32 +16,27 @@ Seed::Seed(const args_t&... points) : m_spacepoints({&points...}) {} template - requires(N >= 3ul) void Seed::setVertexZ(float vertex) { m_vertexZ = vertex; } template - requires(N >= 3ul) void Seed::setQuality(float seedQuality) { m_seedQuality = seedQuality; } template - requires(N >= 3ul) const std::array& Seed::sp() const { return m_spacepoints; } template - requires(N >= 3ul) float Seed::z() const { return m_vertexZ; } template - requires(N >= 3ul) float Seed::seedQuality() const { return m_seedQuality; } diff --git a/Core/include/Acts/EventData/TrackParameterHelpers.hpp b/Core/include/Acts/EventData/TrackParameterHelpers.hpp index c9089ff9ab9..df40c934824 100644 --- a/Core/include/Acts/EventData/TrackParameterHelpers.hpp +++ b/Core/include/Acts/EventData/TrackParameterHelpers.hpp @@ -11,8 +11,38 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Utilities/detail/periodic.hpp" +#include + namespace Acts { +/// Check if a bound vector is valid. This checks the following: +/// - All values are finite +/// - (optionally) The phi value is in the range [-pi, pi) +/// - (optionally) The theta value is in the range [0, pi] +/// +/// @param v The bound vector to check +/// @param validateAngleRange If true, the phi and theta values are range checked +/// @param epsilon The epsilon to use for the checks +/// @param maxAbsEta The maximum allowed eta value +/// +/// @return True if the bound vector is valid +bool isBoundVectorValid( + const BoundVector& v, bool validateAngleRange, double epsilon = 1e-6, + double maxAbsEta = std::numeric_limits::infinity()); + +/// Check if a free vector is valid. This checks the following: +/// - All values are finite +/// - Direction is normalized +/// +/// @param v The free vector to check +/// @param epsilon The epsilon to use for the checks +/// @param maxAbsEta The maximum allowed eta value +/// +/// @return True if the free vector is valid +bool isFreeVectorValid( + const FreeVector& v, double epsilon = 1e-6, + double maxAbsEta = std::numeric_limits::infinity()); + /// Normalize the bound parameter angles /// /// @param boundParams The bound parameters to normalize diff --git a/Core/include/Acts/EventData/TrackParametersConcept.hpp b/Core/include/Acts/EventData/TrackParametersConcept.hpp index b39255e5ef7..5e4982545a4 100644 --- a/Core/include/Acts/EventData/TrackParametersConcept.hpp +++ b/Core/include/Acts/EventData/TrackParametersConcept.hpp @@ -12,9 +12,7 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include #include -#include namespace Acts { @@ -68,4 +66,5 @@ concept BoundTrackParametersConcept = { p.position(c) } -> std::same_as; }; }; + } // namespace Acts diff --git a/Core/include/Acts/EventData/detail/GenerateParameters.hpp b/Core/include/Acts/EventData/detail/GenerateParameters.hpp index 023314e2527..1b591dbcd7a 100644 --- a/Core/include/Acts/EventData/detail/GenerateParameters.hpp +++ b/Core/include/Acts/EventData/detail/GenerateParameters.hpp @@ -195,6 +195,10 @@ struct GenerateBoundParametersOptions { GenerateQoverPOptions qOverP; }; +inline BoundVector someBoundParametersA() { + return {0.0, 0.0, 0.0, std::numbers::pi / 2, 1.0, 0.0}; +} + template inline BoundVector generateBoundParameters( generator_t& rng, const GenerateBoundParametersOptions& options) { @@ -242,6 +246,10 @@ struct GenerateFreeParametersOptions { GenerateQoverPOptions qOverP; }; +inline FreeVector someFreeParametersA() { + return {0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0}; +} + template inline FreeVector generateFreeParameters( generator_t& rng, const GenerateFreeParametersOptions& options) { diff --git a/Core/include/Acts/EventData/detail/TestTrackState.hpp b/Core/include/Acts/EventData/detail/TestTrackState.hpp index c1471566c5b..514ae073c2f 100644 --- a/Core/include/Acts/EventData/detail/TestTrackState.hpp +++ b/Core/include/Acts/EventData/detail/TestTrackState.hpp @@ -38,11 +38,11 @@ struct TestTrackState { : surface( CurvilinearSurface(Vector3::Zero(), Vector3::UnitZ()).surface()), // set bogus parameters first since they are not default-constructible - predicted(surface, BoundVector::Zero(), std::nullopt, + predicted(surface, someBoundParametersA(), std::nullopt, ParticleHypothesis::pion()), - filtered(surface, BoundVector::Zero(), std::nullopt, + filtered(surface, someBoundParametersA(), std::nullopt, ParticleHypothesis::pion()), - smoothed(surface, BoundVector::Zero(), std::nullopt, + smoothed(surface, someBoundParametersA(), std::nullopt, ParticleHypothesis::pion()), jacobian(BoundMatrix::Identity()), chi2(std::chi_squared_distribution(measdim)(rng)), diff --git a/Core/include/Acts/Geometry/NavigationPolicyFactory.hpp b/Core/include/Acts/Geometry/NavigationPolicyFactory.hpp index 4d9542af826..ed9acce9aa2 100644 --- a/Core/include/Acts/Geometry/NavigationPolicyFactory.hpp +++ b/Core/include/Acts/Geometry/NavigationPolicyFactory.hpp @@ -54,17 +54,12 @@ class NavigationPolicyFactory { namespace detail { template -concept NavigationPolicyIsolatedFactoryConcept = requires(F f) { - { - f(std::declval(), - std::declval(), std::declval(), - std::declval()...) - } -> std::derived_from; - - requires NavigationPolicyConcept(), - std::declval(), std::declval(), - std::declval()...))>; +concept NavigationPolicyIsolatedFactoryConcept = requires( + F f, const GeometryContext& gctx, const TrackingVolume& volume, + const Logger& logger, Args&&... args) { + { f(gctx, volume, logger, args...) } -> std::derived_from; + + requires NavigationPolicyConcept; requires(std::is_copy_constructible_v && ...); }; @@ -205,7 +200,7 @@ class NavigationPolicyFactoryImpl : public NavigationPolicyFactory { template friend class NavigationPolicyFactoryImpl; - NavigationPolicyFactoryImpl(std::tuple&& factories) + explicit NavigationPolicyFactoryImpl(std::tuple&& factories) : m_factories(std::move(factories)) {} std::tuple m_factories; diff --git a/Core/include/Acts/Geometry/TrackingVolume.hpp b/Core/include/Acts/Geometry/TrackingVolume.hpp index f47f8b440fc..664faa39d46 100644 --- a/Core/include/Acts/Geometry/TrackingVolume.hpp +++ b/Core/include/Acts/Geometry/TrackingVolume.hpp @@ -117,8 +117,8 @@ class TrackingVolume : public Volume { ~TrackingVolume() override; TrackingVolume(const TrackingVolume&) = delete; TrackingVolume& operator=(const TrackingVolume&) = delete; - TrackingVolume(TrackingVolume&&); - TrackingVolume& operator=(TrackingVolume&&); + TrackingVolume(TrackingVolume&&) noexcept; + TrackingVolume& operator=(TrackingVolume&&) noexcept; /// Constructor for a container Volume /// - vacuum filled volume either as a for other tracking volumes diff --git a/Core/include/Acts/Navigation/INavigationPolicy.hpp b/Core/include/Acts/Navigation/INavigationPolicy.hpp index 6794dbdea09..de98f8d26c3 100644 --- a/Core/include/Acts/Navigation/INavigationPolicy.hpp +++ b/Core/include/Acts/Navigation/INavigationPolicy.hpp @@ -42,9 +42,11 @@ class INavigationPolicy { public: /// Noop update function that is suitable as a default for default navigation /// delegates. - static void noopInitializeCandidates(const NavigationArguments& /*unused*/, - AppendOnlyNavigationStream& /*unused*/, - const Logger& /*unused*/) {} + static void noopInitializeCandidates( + const NavigationArguments& /*unused*/, + const AppendOnlyNavigationStream& /*unused*/, const Logger& /*unused*/) { + // This is a noop + } /// Virtual destructor so policies can be held through this base class. virtual ~INavigationPolicy() = default; diff --git a/Core/include/Acts/Navigation/MultiNavigationPolicy.hpp b/Core/include/Acts/Navigation/MultiNavigationPolicy.hpp index c5c8a397aea..e66872fc39e 100644 --- a/Core/include/Acts/Navigation/MultiNavigationPolicy.hpp +++ b/Core/include/Acts/Navigation/MultiNavigationPolicy.hpp @@ -30,7 +30,7 @@ class MultiNavigationPolicy final : public MultiNavigationPolicyBase { public: /// Constructor from a set of child policies. /// @param policies The child policies - MultiNavigationPolicy(Policies&&... policies) + explicit MultiNavigationPolicy(Policies&&... policies) : m_policies{std::move(policies)...} {} /// Implementation of the connection to a navigation delegate. diff --git a/Core/include/Acts/Navigation/SurfaceArrayNavigationPolicy.hpp b/Core/include/Acts/Navigation/SurfaceArrayNavigationPolicy.hpp index 9143cf0087d..731122caff7 100644 --- a/Core/include/Acts/Navigation/SurfaceArrayNavigationPolicy.hpp +++ b/Core/include/Acts/Navigation/SurfaceArrayNavigationPolicy.hpp @@ -60,13 +60,14 @@ class SurfaceArrayNavigationPolicy : public INavigationPolicy { friend std::ostream& operator<<(std::ostream& os, const LayerType& layerType) { switch (layerType) { - case LayerType::Cylinder: + using enum LayerType; + case Cylinder: os << "Cylinder"; break; - case LayerType::Disc: + case Disc: os << "Disc"; break; - case LayerType::Plane: + case Plane: os << "Plane"; break; } diff --git a/Core/include/Acts/Seeding/SeedFinderGbts.ipp b/Core/include/Acts/Seeding/SeedFinderGbts.ipp index 91f5f3f64e4..347ca8e1e13 100644 --- a/Core/include/Acts/Seeding/SeedFinderGbts.ipp +++ b/Core/include/Acts/Seeding/SeedFinderGbts.ipp @@ -159,7 +159,7 @@ void SeedFinderGbts::runGbts_TrackFinder( .m_phiSliceWidth; // the default sliding window along phi if (m_config.m_useEtaBinning) { - deltaPhi = 0.001f + m_maxCurv * std::fabs(rb2 - rb1); + deltaPhi = 0.001f + m_maxCurv * std::abs(rb2 - rb1); } unsigned int first_it = 0; @@ -219,7 +219,7 @@ void SeedFinderGbts::runGbts_TrackFinder( float dz = z2 - z1; float tau = dz / dr; - float ftau = std::fabs(tau); + float ftau = std::abs(tau); if (ftau > 36.0) { continue; } @@ -288,17 +288,18 @@ void SeedFinderGbts::runGbts_TrackFinder( float tau2 = edgeStorage.at(n2_in_idx).m_p[0]; float tau_ratio = tau2 * uat_1 - 1.0f; - if (std::fabs(tau_ratio) > - m_config.cut_tau_ratio_max) { // bad - // match + // bad match + if (std::abs(tau_ratio) > m_config.cut_tau_ratio_max) { continue; } - isGood = true; // good match found + + // good match found + isGood = true; break; } } if (!isGood) { - continue; // no moatch found, skip creating [n1 <- n2] edge + continue; // no match found, skip creating [n1 <- n2] edge } float curv = D * std::sqrt(L2); // signed curvature diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index edd8e0f3074..056b6cc6831 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -226,7 +226,7 @@ bool SeedFinderOrthogonal::validTuple( * Cut: Ensure that the forward angle (z / r) lies within reasonable bounds, * which is to say the absolute value must be smaller than the max cot(θ). */ - if (std::fabs(cotTheta) > m_config.cotThetaMax) { + if (std::abs(cotTheta) > m_config.cotThetaMax) { return false; } diff --git a/Core/include/Acts/Utilities/DelegateChainBuilder.hpp b/Core/include/Acts/Utilities/DelegateChainBuilder.hpp index 6e4f2c89650..a24ab98ddb8 100644 --- a/Core/include/Acts/Utilities/DelegateChainBuilder.hpp +++ b/Core/include/Acts/Utilities/DelegateChainBuilder.hpp @@ -102,7 +102,7 @@ class DelegateChainBuilder, template static constexpr auto invoke(result_ptr result, const tuple_type* payloads, - callable_args... args) { + callable_args&&... args) { const auto& callable = findCallable(); if constexpr (!std::is_same_v, @@ -134,7 +134,7 @@ class DelegateChainBuilder, tuple_type m_payloads{}; - auto dispatch(callable_args... args) const { + auto dispatch(callable_args&&... args) const { if constexpr (std::is_same_v) { invoke(nullptr, &m_payloads, std::forward(args)...); } else { diff --git a/Core/src/EventData/CMakeLists.txt b/Core/src/EventData/CMakeLists.txt index 08a69711378..c425d533649 100644 --- a/Core/src/EventData/CMakeLists.txt +++ b/Core/src/EventData/CMakeLists.txt @@ -8,4 +8,5 @@ target_sources( TrackStatePropMask.cpp VectorMultiTrajectory.cpp VectorTrackContainer.cpp + TrackParameterHelpers.cpp ) diff --git a/Core/src/EventData/TrackParameterHelpers.cpp b/Core/src/EventData/TrackParameterHelpers.cpp new file mode 100644 index 00000000000..9e7ddb40abf --- /dev/null +++ b/Core/src/EventData/TrackParameterHelpers.cpp @@ -0,0 +1,64 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 CERN for the benefit of the ACTS project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#include "Acts/EventData/TrackParameterHelpers.hpp" + +#include "Acts/Utilities/AngleHelpers.hpp" +#include "Acts/Utilities/VectorHelpers.hpp" + +#include + +bool Acts::isBoundVectorValid(const BoundVector& v, bool validateAngleRange, + double epsilon, double maxAbsEta) { + constexpr auto pi = std::numbers::pi_v; + + bool loc0Valid = std::isfinite(v[eBoundLoc0]); + bool loc1Valid = std::isfinite(v[eBoundLoc1]); + bool phiValid = std::isfinite(v[eBoundPhi]); + bool thetaValid = std::isfinite(v[eBoundTheta]); + bool qOverPValid = std::isfinite(v[eBoundQOverP]); + bool timeValid = std::isfinite(v[eBoundTime]); + + if (validateAngleRange) { + phiValid = phiValid && (v[eBoundPhi] + epsilon >= -pi) && + (v[eBoundPhi] - epsilon < pi); + thetaValid = thetaValid && (v[eBoundTheta] + epsilon >= 0) && + (v[eBoundTheta] - epsilon <= pi); + } + + bool etaValid = true; + if (std::isfinite(maxAbsEta)) { + double eta = AngleHelpers::etaFromTheta(v[eBoundTheta]); + etaValid = std::isfinite(eta) && (std::abs(eta) - epsilon <= maxAbsEta); + } + + return loc0Valid && loc1Valid && phiValid && thetaValid && qOverPValid && + timeValid && etaValid; +} + +bool Acts::isFreeVectorValid(const FreeVector& v, double epsilon, + double maxAbsEta) { + bool pos0Valid = std::isfinite(v[eFreePos0]); + bool pos1Valid = std::isfinite(v[eFreePos1]); + bool pos2Valid = std::isfinite(v[eFreePos2]); + bool dir0Valid = std::isfinite(v[eFreeDir0]); + bool dir1Valid = std::isfinite(v[eFreeDir1]); + bool dir2Valid = std::isfinite(v[eFreeDir2]); + bool dirValid = (std::abs(v.segment<3>(eFreeDir0).norm() - 1) - epsilon <= 0); + bool qOverPValid = std::isfinite(v[eFreeQOverP]); + bool timeValid = std::isfinite(v[eFreeTime]); + + bool etaValid = true; + if (std::isfinite(maxAbsEta)) { + double eta = VectorHelpers::eta(v.segment<3>(eFreeDir0)); + etaValid = std::isfinite(eta) && (std::abs(eta) - epsilon <= maxAbsEta); + } + + return pos0Valid && pos1Valid && pos2Valid && dir0Valid && dir1Valid && + dir2Valid && dirValid && qOverPValid && timeValid && etaValid; +} diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index 611904537f0..bbe9b60fc98 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -69,8 +69,8 @@ TrackingVolume::TrackingVolume(const Transform3& transform, {}, volumeName) {} TrackingVolume::~TrackingVolume() = default; -TrackingVolume::TrackingVolume(TrackingVolume&&) = default; -TrackingVolume& TrackingVolume::operator=(TrackingVolume&&) = default; +TrackingVolume::TrackingVolume(TrackingVolume&&) noexcept = default; +TrackingVolume& TrackingVolume::operator=(TrackingVolume&&) noexcept = default; const TrackingVolume* TrackingVolume::lowestTrackingVolume( const GeometryContext& gctx, const Vector3& position, diff --git a/Core/src/MagneticField/BFieldMapUtils.cpp b/Core/src/MagneticField/BFieldMapUtils.cpp index e7216aa3bf9..b5b92191589 100644 --- a/Core/src/MagneticField/BFieldMapUtils.cpp +++ b/Core/src/MagneticField/BFieldMapUtils.cpp @@ -58,8 +58,8 @@ Acts::fieldMapRZ( double zMax = zPos[nBinsZ - 1]; // calculate maxima (add one last bin, because bin value always corresponds to // left boundary) - double stepZ = std::fabs(zMax - zMin) / (nBinsZ - 1); - double stepR = std::fabs(rMax - rMin) / (nBinsR - 1); + double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); + double stepR = std::abs(rMax - rMin) / (nBinsR - 1); rMax += stepR; zMax += stepZ; if (firstQuadrant) { @@ -172,9 +172,9 @@ Acts::fieldMapXYZ( double zMax = zPos[nBinsZ - 1]; // calculate maxima (add one last bin, because bin value always corresponds to // left boundary) - double stepZ = std::fabs(zMax - zMin) / (nBinsZ - 1); - double stepY = std::fabs(yMax - yMin) / (nBinsY - 1); - double stepX = std::fabs(xMax - xMin) / (nBinsX - 1); + double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); + double stepY = std::abs(yMax - yMin) / (nBinsY - 1); + double stepX = std::abs(xMax - xMin) / (nBinsX - 1); xMax += stepX; yMax += stepY; zMax += stepZ; diff --git a/Core/src/Material/MaterialGridHelper.cpp b/Core/src/Material/MaterialGridHelper.cpp index a6d1a90416a..83c7946f77c 100644 --- a/Core/src/Material/MaterialGridHelper.cpp +++ b/Core/src/Material/MaterialGridHelper.cpp @@ -32,8 +32,8 @@ Acts::Grid2D Acts::createGrid(Acts::MaterialGridAxisData gridAxis1, // calculate maxima (add one last bin, because bin value always corresponds // to // left boundary) - double stepAxis1 = std::fabs(maxAxis1 - minAxis1) / (nBinsAxis1 - 1); - double stepAxis2 = std::fabs(maxAxis2 - minAxis2) / (nBinsAxis2 - 1); + double stepAxis1 = std::abs(maxAxis1 - minAxis1) / (nBinsAxis1 - 1); + double stepAxis2 = std::abs(maxAxis2 - minAxis2) / (nBinsAxis2 - 1); maxAxis1 += stepAxis1; maxAxis2 += stepAxis2; @@ -64,11 +64,11 @@ Acts::Grid3D Acts::createGrid(Acts::MaterialGridAxisData gridAxis1, // to // left boundary) double stepAxis1 = - std::fabs(maxAxis1 - minAxis1) / std::max(nBinsAxis1 - 1, std::size_t{1}); + std::abs(maxAxis1 - minAxis1) / std::max(nBinsAxis1 - 1, std::size_t{1}); double stepAxis2 = - std::fabs(maxAxis2 - minAxis2) / std::max(nBinsAxis2 - 1, std::size_t{1}); + std::abs(maxAxis2 - minAxis2) / std::max(nBinsAxis2 - 1, std::size_t{1}); double stepAxis3 = - std::fabs(maxAxis3 - minAxis3) / std::max(nBinsAxis3 - 1, std::size_t{1}); + std::abs(maxAxis3 - minAxis3) / std::max(nBinsAxis3 - 1, std::size_t{1}); maxAxis1 += stepAxis1; maxAxis2 += stepAxis2; maxAxis3 += stepAxis3; diff --git a/Core/src/Material/MaterialMapUtils.cpp b/Core/src/Material/MaterialMapUtils.cpp index a9b04275925..b51b1a3e223 100644 --- a/Core/src/Material/MaterialMapUtils.cpp +++ b/Core/src/Material/MaterialMapUtils.cpp @@ -64,8 +64,8 @@ auto Acts::materialMapperRZ( double zMax = *minMaxZ.second; // calculate maxima (add one last bin, because bin value always corresponds to // left boundary) - double stepZ = std::fabs(zMax - zMin) / (nBinsZ - 1); - double stepR = std::fabs(rMax - rMin) / (nBinsR - 1); + double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); + double stepR = std::abs(rMax - rMin) / (nBinsR - 1); rMax += stepR; zMax += stepZ; @@ -156,9 +156,9 @@ auto Acts::materialMapperXYZ( double zMax = *minMaxZ.second; // calculate maxima (add one last bin, because bin value always corresponds to // left boundary) - double stepZ = std::fabs(zMax - zMin) / (nBinsZ - 1); - double stepY = std::fabs(yMax - yMin) / (nBinsY - 1); - double stepX = std::fabs(xMax - xMin) / (nBinsX - 1); + double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); + double stepY = std::abs(yMax - yMin) / (nBinsY - 1); + double stepX = std::abs(xMax - xMin) / (nBinsX - 1); xMax += stepX; yMax += stepY; zMax += stepZ; diff --git a/Core/src/Navigation/SurfaceArrayNavigationPolicy.cpp b/Core/src/Navigation/SurfaceArrayNavigationPolicy.cpp index f40621fdd06..f60bbbf6839 100644 --- a/Core/src/Navigation/SurfaceArrayNavigationPolicy.cpp +++ b/Core/src/Navigation/SurfaceArrayNavigationPolicy.cpp @@ -45,8 +45,6 @@ SurfaceArrayNavigationPolicy::SurfaceArrayNavigationPolicy( auto [binsPhi, binsZ] = config.bins; m_surfaceArray = sac.surfaceArrayOnCylinder(gctx, std::move(surfaces), binsPhi, binsZ); - // m_surfaces = sac.createCylinderSurfaces(config.bins.first, - // config.bins.second); } else if (config.layerType == LayerType::Plane) { ACTS_ERROR("Plane layers are not yet supported"); throw std::invalid_argument("Plane layers are not yet supported"); diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index 27123d29ec0..64d3e9f547f 100644 --- a/Core/src/Surfaces/CylinderBounds.cpp +++ b/Core/src/Surfaces/CylinderBounds.cpp @@ -69,8 +69,8 @@ bool Acts::CylinderBounds::inside( double localx = lposition[0] > radius ? 2 * radius - lposition[0] : lposition[0]; Vector2 shiftedlposition = shifted(lposition); - if ((std::fabs(shiftedlposition[0]) <= halfPhi && - std::fabs(shiftedlposition[1]) <= halfLengthZ)) { + if ((std::abs(shiftedlposition[0]) <= halfPhi && + std::abs(shiftedlposition[1]) <= halfLengthZ)) { return true; } diff --git a/Core/src/Surfaces/CylinderSurface.cpp b/Core/src/Surfaces/CylinderSurface.cpp index a39dce4a4fa..4b3cd2db7be 100644 --- a/Core/src/Surfaces/CylinderSurface.cpp +++ b/Core/src/Surfaces/CylinderSurface.cpp @@ -180,7 +180,7 @@ double Acts::CylinderSurface::pathCorrection( const Acts::Vector3& direction) const { Vector3 normalT = normal(gctx, position); double cosAlpha = normalT.dot(direction); - return std::fabs(1. / cosAlpha); + return std::abs(1. / cosAlpha); } const Acts::CylinderBounds& Acts::CylinderSurface::bounds() const { diff --git a/Core/src/Utilities/SpacePointUtility.cpp b/Core/src/Utilities/SpacePointUtility.cpp index 4b79fc03cc3..7018db37830 100644 --- a/Core/src/Utilities/SpacePointUtility.cpp +++ b/Core/src/Utilities/SpacePointUtility.cpp @@ -204,8 +204,8 @@ Result SpacePointUtility::calculateStripSPPosition( } // Check if m and n can be resolved in the interval (-1, 1) - if (fabs(spParams.m) <= spParams.limit && - fabs(spParams.n) <= spParams.limit) { + if (std::abs(spParams.m) <= spParams.limit && + std::abs(spParams.n) <= spParams.limit) { return Result::success(); } return Result::failure(m_error); @@ -226,7 +226,7 @@ Result SpacePointUtility::recoverSpacePoint( spParams.limit + stripLengthGapTolerance / spParams.mag_firstBtmToTop; // Check if m is just slightly outside - if (fabs(spParams.m) > spParams.limitExtended) { + if (std::abs(spParams.m) > spParams.limitExtended) { return Result::failure(m_error); } // Calculate n if not performed previously @@ -236,7 +236,7 @@ Result SpacePointUtility::recoverSpacePoint( spParams.secondBtmToTop.dot(spParams.firstBtmToTopXvtxToFirstMid2); } // Check if n is just slightly outside - if (fabs(spParams.n) > spParams.limitExtended) { + if (std::abs(spParams.n) > spParams.limitExtended) { return Result::failure(m_error); } /// The following code considers an overshoot of m and n in the same direction @@ -275,8 +275,8 @@ Result SpacePointUtility::recoverSpacePoint( spParams.n -= (biggerOvershoot / secOnFirstScale); // Check if this recovered the space point - if (fabs(spParams.m) < spParams.limit && - fabs(spParams.n) < spParams.limit) { + if (std::abs(spParams.m) < spParams.limit && + std::abs(spParams.n) < spParams.limit) { return Result::success(); } else { return Result::failure(m_error); @@ -294,8 +294,8 @@ Result SpacePointUtility::recoverSpacePoint( spParams.m += biggerOvershoot; spParams.n += (biggerOvershoot / secOnFirstScale); // Check if this recovered the space point - if (fabs(spParams.m) < spParams.limit && - fabs(spParams.n) < spParams.limit) { + if (std::abs(spParams.m) < spParams.limit && + std::abs(spParams.n) < spParams.limit) { return Result::success(); } } @@ -325,7 +325,7 @@ Result SpacePointUtility::calcPerpendicularProjection( double qr = (spParams.firstBtmToTop).dot(spParams.secondBtmToTop); double denom = spParams.firstBtmToTop.dot(spParams.firstBtmToTop) - qr * qr; // Check for numerical stability - if (fabs(denom) > 1e-6) { + if (std::abs(denom) > 1e-6) { // Return lambda0 return Result::success( (ac.dot(spParams.secondBtmToTop) * qr - diff --git a/Examples/Algorithms/TrackFitting/src/KalmanFitterFunction.cpp b/Examples/Algorithms/TrackFitting/src/KalmanFitterFunction.cpp index 6a5d2e0059b..6f835c5c967 100644 --- a/Examples/Algorithms/TrackFitting/src/KalmanFitterFunction.cpp +++ b/Examples/Algorithms/TrackFitting/src/KalmanFitterFunction.cpp @@ -62,7 +62,7 @@ struct SimpleReverseFilteringLogic { bool doBackwardFiltering( Acts::VectorMultiTrajectory::ConstTrackStateProxy trackState) const { - auto momentum = fabs(1 / trackState.filtered()[Acts::eBoundQOverP]); + auto momentum = std::abs(1 / trackState.filtered()[Acts::eBoundQOverP]); return (momentum <= momentumThreshold); } }; diff --git a/Examples/Io/Csv/src/CsvSeedWriter.cpp b/Examples/Io/Csv/src/CsvSeedWriter.cpp index 96dd04b07a4..fe9d881c24f 100644 --- a/Examples/Io/Csv/src/CsvSeedWriter.cpp +++ b/Examples/Io/Csv/src/CsvSeedWriter.cpp @@ -123,10 +123,10 @@ ActsExamples::ProcessCode ActsExamples::CsvSeedWriter::writeT( // Compute the distance between the truth and estimated directions float truthPhi = phi(truthUnitDir); float truthEta = std::atanh(std::cos(theta(truthUnitDir))); - float dEta = fabs(truthEta - seedEta); - float dPhi = fabs(truthPhi - seedPhi) < M_PI - ? fabs(truthPhi - seedPhi) - : fabs(truthPhi - seedPhi) - M_PI; + float dEta = std::abs(truthEta - seedEta); + float dPhi = std::abs(truthPhi - seedPhi) < M_PI + ? std::abs(truthPhi - seedPhi) + : std::abs(truthPhi - seedPhi) - M_PI; 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/Python/src/Navigation.cpp b/Examples/Python/src/Navigation.cpp index ac2f1a77ef6..733bbe1a151 100644 --- a/Examples/Python/src/Navigation.cpp +++ b/Examples/Python/src/Navigation.cpp @@ -42,7 +42,7 @@ struct AnyNavigationPolicyFactory : public Acts::NavigationPolicyFactory { template , typename... Policies> struct NavigationPolicyFactoryT : public AnyNavigationPolicyFactory { - NavigationPolicyFactoryT(Factory impl) + explicit NavigationPolicyFactoryT(Factory impl) requires(sizeof...(Policies) > 0) : m_impl(std::move(impl)) {} @@ -74,7 +74,7 @@ struct NavigationPolicyFactoryT : public AnyNavigationPolicyFactory { private: template std::unique_ptr add(Args&&... args) { - if constexpr (!((std::is_same_v || ...))) { + if constexpr (!(std::is_same_v || ...)) { auto impl = std::move(m_impl).template add(std::forward(args)...); return std::make_unique< diff --git a/Examples/Scripts/MaterialMapping/Mat_map.C b/Examples/Scripts/MaterialMapping/Mat_map.C index 9f58e605244..60c70fa2339 100644 --- a/Examples/Scripts/MaterialMapping/Mat_map.C +++ b/Examples/Scripts/MaterialMapping/Mat_map.C @@ -57,7 +57,7 @@ void Draw_ratio(TCanvas* c, TProfile* h1, TProfile* h2, TLegend* leg, std::strin h5->SetStats(0); // No statistics on lower plot h5->Divide(h1); - double maxi = min( max( fabs(h5->GetMinimum()-0.1*h5->GetMinimum()),h5->GetMaximum()+0.1*h5->GetMaximum() ), 10. ); + double maxi = min( max( std::abs(h5->GetMinimum()-0.1*h5->GetMinimum()),h5->GetMaximum()+0.1*h5->GetMaximum() ), 10. ); h5->SetMinimum( 0.5 ); // Define Y .. h5->SetMaximum( 1.1 ); // .. range @@ -145,7 +145,7 @@ void Mat_map(std::string Val = "", std::string geantino = "", std::string name = // 2D map for Validation input TCanvas *VM = new TCanvas("VM","Validation Map") ; - Val_file->Draw("mat_y:mat_z","fabs(mat_x)<1"); + Val_file->Draw("mat_y:mat_z","std::abs(mat_x)<1"); eta_0->Draw("Same"); eta_1p->Draw("Same"); @@ -206,7 +206,7 @@ void Mat_map(std::string Val = "", std::string geantino = "", std::string name = // 2D map for Geantino input TCanvas *GM = new TCanvas("GM","Geantino Map") ; - geantino_file->Draw("mat_y:mat_z","fabs(mat_x)<1"); + geantino_file->Draw("mat_y:mat_z","std::abs(mat_x)<1"); eta_0->Draw("Same"); eta_1p->Draw("Same"); diff --git a/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp b/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp index dea8a0ae334..b1066919dc7 100644 --- a/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp +++ b/Fatras/include/ActsFatras/Physics/NuclearInteraction/NuclearInteraction.hpp @@ -41,7 +41,7 @@ struct NuclearInteraction { /// The storage of the parameterisation detail::MultiParticleNuclearInteractionParametrisation multiParticleParameterisation; - /// The number of trials to match momenta and inveriant masses + /// The number of trials to match momenta and invariant masses //~ unsigned int nMatchingTrials = std::numeric_limits::max(); unsigned int nMatchingTrials = 100; unsigned int nMatchingTrialsTotal = 1000; @@ -56,7 +56,7 @@ struct NuclearInteraction { template std::pair generatePathLimits(generator_t& generator, const Particle& particle) const { - // Fast exit: No paramtrization provided + // Fast exit: No parameterisation provided if (multiParticleParameterisation.empty()) { return std::make_pair(std::numeric_limits::infinity(), std::numeric_limits::infinity()); @@ -416,7 +416,7 @@ Acts::ActsDynamicVector NuclearInteraction::sampleInvariantMasses( for (unsigned int i = 0; i < size; i++) { float variance = parametrisation.eigenvaluesInvariantMass[i]; std::normal_distribution dist{ - parametrisation.meanInvariantMass[i], sqrtf(variance)}; + parametrisation.meanInvariantMass[i], std::sqrt(variance)}; parameters[i] = dist(generator); } // Transform to multivariate normal distribution @@ -446,7 +446,7 @@ Acts::ActsDynamicVector NuclearInteraction::sampleMomenta( for (unsigned int i = 0; i < size; i++) { float variance = parametrisation.eigenvaluesMomentum[i]; std::normal_distribution dist{ - parametrisation.meanMomentum[i], sqrtf(variance)}; + parametrisation.meanMomentum[i], std::sqrt(variance)}; parameters[i] = dist(generator); } diff --git a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp index ae80bb1a0c7..848de200db0 100644 --- a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp +++ b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp @@ -429,7 +429,8 @@ std::shared_ptr volumeBuilder_dd4hep( plbConfig.layerIdentification = subDetector.name(); plbConfig.centralLayerRadii = std::vector(1, 0.5 * (rMax + rMin)); plbConfig.centralLayerHalflengthZ = std::vector(1, halfZ); - plbConfig.centralLayerThickness = std::vector(1, fabs(rMax - rMin)); + plbConfig.centralLayerThickness = + std::vector(1, std::abs(rMax - rMin)); plbConfig.centralLayerMaterial = {plMaterial}; auto pcLayerBuilder = std::make_shared( plbConfig, logger.clone(std::string("D2A_PL:") + subDetector.name())); diff --git a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp index 3b85391ab84..c7cffaaf5aa 100644 --- a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp +++ b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp @@ -208,8 +208,8 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::endcapLayers( // create the share disc bounds auto dBounds = std::make_shared( pl.min(Acts::BinningValue::binR), pl.max(Acts::BinningValue::binR)); - double thickness = std::fabs(pl.max(Acts::BinningValue::binZ) - - pl.min(Acts::BinningValue::binZ)); + double thickness = std::abs(pl.max(Acts::BinningValue::binZ) - + pl.min(Acts::BinningValue::binZ)); // Create the layer containing the sensitive surface endcapLayer = DiscLayer::create(transform, dBounds, std::move(sArray), thickness, nullptr, Acts::active); @@ -357,8 +357,8 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::centralLayers( double layerR = (pl.min(Acts::BinningValue::binR) + pl.max(Acts::BinningValue::binR)) * 0.5; - double thickness = std::fabs(pl.max(Acts::BinningValue::binR) - - pl.min(Acts::BinningValue::binR)); + double thickness = std::abs(pl.max(Acts::BinningValue::binR) - + pl.min(Acts::BinningValue::binR)); auto cBounds = std::make_shared(layerR, halfZ); // Create the layer containing the sensitive surface centralLayer = diff --git a/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp b/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp index 6b0642d25e8..11a0f983f1a 100644 --- a/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp +++ b/Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp @@ -47,9 +47,9 @@ Acts::detail::GeoPolygonConverter::operator()( // sort based on the y-coordinate std::ranges::sort(vertices, {}, [](const auto& v) { return v[1]; }); if (nVertices == 4) { - double hlxnegy = fabs(vertices[0][0] - vertices[1][0]) / 2; - double hlxposy = fabs(vertices[2][0] - vertices[3][0]) / 2; - double hly = fabs(vertices[0][1] - vertices[3][1]) / 2; + double hlxnegy = std::abs(vertices[0][0] - vertices[1][0]) / 2; + double hlxposy = std::abs(vertices[2][0] - vertices[3][0]) / 2; + double hly = std::abs(vertices[0][1] - vertices[3][1]) / 2; std::vector halfLengths = {hlxnegy, hlxposy, hly}; // Create the surface @@ -78,10 +78,10 @@ Acts::detail::GeoPolygonConverter::operator()( // Return the detector element and surface return std::make_tuple(detectorElement, surface); } else if (nVertices == 6) { - double hlxnegy = fabs(vertices[0][0] - vertices[1][0]) / 2; - double hlxzeroy = fabs(vertices[2][0] - vertices[3][0]) / 2; - double hlxposy = fabs(vertices[4][0] - vertices[5][0]) / 2; - double hly = fabs(vertices[0][1] - vertices[4][1]) / 2; + double hlxnegy = std::abs(vertices[0][0] - vertices[1][0]) / 2; + double hlxzeroy = std::abs(vertices[2][0] - vertices[3][0]) / 2; + double hlxposy = std::abs(vertices[4][0] - vertices[5][0]) / 2; + double hly = std::abs(vertices[0][1] - vertices[4][1]) / 2; std::vector halfLengths = {hlxnegy, hlxzeroy, hlxposy, hly, hly}; diff --git a/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.hpp b/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.hpp index 12b3137682c..b7e060a1f80 100644 --- a/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.hpp +++ b/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.hpp @@ -318,7 +318,7 @@ inline SPForSeed* AtlasSeedFinder::newSpacePoint( if (m_checketa) { // filter SP outside of eta-range - float z = (fabs(r[2]) + m_zmax); + float z = std::abs(r[2]) + m_zmax; float x = r[0] * m_dzdrmin; float y = r[1] * m_dzdrmin; if ((z * z) < (x * x + y * y)) { diff --git a/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp b/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp index ce4f4d5525a..4b5b5c60875 100644 --- a/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp +++ b/Plugins/Legacy/include/Acts/Seeding/AtlasSeedFinder.ipp @@ -205,7 +205,7 @@ void Acts::Legacy::AtlasSeedFinder::findNext() { /////////////////////////////////////////////////////////////////// template void Acts::Legacy::AtlasSeedFinder::buildFrameWork() { - m_ptmin = fabs(m_ptmin); + m_ptmin = std::abs(m_ptmin); if (m_ptmin < 100.) { m_ptmin = 100.; @@ -218,7 +218,7 @@ void Acts::Legacy::AtlasSeedFinder::buildFrameWork() { m_divermax = m_diversss; } - if (fabs(m_etamin) < .1) { + if (std::abs(m_etamin) < 0.1) { m_etamin = -m_etamax; } m_dzdrmax0 = 1. / tan(2. * atan(exp(-m_etamax))); @@ -227,7 +227,7 @@ void Acts::Legacy::AtlasSeedFinder::buildFrameWork() { // scattering factor. depends on error, forward direction and distance between // SP m_COF = 134 * .05 * 9.; - m_ipt = 1. / fabs(.9 * m_ptmin); + m_ipt = 1. / std::abs(0.9 * m_ptmin); m_ipt2 = m_ipt * m_ipt; m_K = 0.; @@ -646,7 +646,7 @@ void Acts::Legacy::AtlasSeedFinder::production3Sp( } // forward direction of SP duplet float Tz = (Z - (*r)->z()) / dR; - float aTz = fabs(Tz); + float aTz = std::abs(Tz); // why also exclude seeds with small pseudorapidity?? if (aTz < m_dzdrmin || aTz > m_dzdrmax) { continue; @@ -690,7 +690,7 @@ void Acts::Legacy::AtlasSeedFinder::production3Sp( } float Tz = ((*r)->z() - Z) / dR; - float aTz = fabs(Tz); + float aTz = std::abs(Tz); if (aTz < m_dzdrmin || aTz > m_dzdrmax) { continue; @@ -793,14 +793,14 @@ void Acts::Legacy::AtlasSeedFinder::production3Sp( continue; } - float Im = fabs((A - B * R) * R); + float Im = std::abs((A - B * R) * R); if (Im <= imax) { // Add penalty factor dependent on difference between cot(theta) to // the quality Im (previously Impact) float dr = 0; m_R[t] < m_R[b] ? dr = m_R[t] : dr = m_R[b]; - Im += fabs((Tzb - m_Tz[t]) / (dr * sTzb2)); + Im += std::abs((Tzb - m_Tz[t]) / (dr * sTzb2)); // B/sqrt(S2) = 1/helixradius m_CmSp.push_back(std::make_pair(B / sqrt(S2), m_SP[t])); m_SP[t]->setParam(Im); @@ -926,7 +926,7 @@ void Acts::Legacy::AtlasSeedFinder:: } // Compared seeds should have at least deltaRMin distance float Rj = (*j).second->radius(); - if (fabs(Rj - Ri) < m_drmin) { + if (std::abs(Rj - Ri) < m_drmin) { continue; } diff --git a/Tests/UnitTests/Core/EventData/TrackParameterHelpersTests.cpp b/Tests/UnitTests/Core/EventData/TrackParameterHelpersTests.cpp index 0a6f3064594..bba77ff8ef2 100644 --- a/Tests/UnitTests/Core/EventData/TrackParameterHelpersTests.cpp +++ b/Tests/UnitTests/Core/EventData/TrackParameterHelpersTests.cpp @@ -14,6 +14,16 @@ BOOST_AUTO_TEST_SUITE(TrackParameterHelpers) +BOOST_AUTO_TEST_CASE(isBoundVectorValid) { + BOOST_CHECK(!Acts::isBoundVectorValid({1, 2, 3, 4, 5, 6}, true)); + BOOST_CHECK(Acts::isBoundVectorValid({1, 2, 1, 1, 5, 6}, true)); +} + +BOOST_AUTO_TEST_CASE(isFreeVectorValid) { + BOOST_CHECK(!Acts::isFreeVectorValid({1, 2, 3, 4, 5, 6, 7, 8})); + BOOST_CHECK(Acts::isFreeVectorValid({1, 2, 3, 4, 1, 0, 0, 8})); +} + BOOST_AUTO_TEST_CASE(normalizeBoundParameters) { CHECK_CLOSE_OR_SMALL(Acts::normalizeBoundParameters({1, 2, 3, 4, 5, 6}), Acts::BoundVector(1, 2, -0.141593, 2.28319, 5, 6), 1e-3, diff --git a/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp b/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp index 514da1ddd74..dde3a05edba 100644 --- a/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp +++ b/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp @@ -60,10 +60,8 @@ BOOST_AUTO_TEST_CASE(Square_Grid_test) { BOOST_CHECK_EQUAL(Grid.minPosition()[0], bd[0].min); BOOST_CHECK_EQUAL(Grid.minPosition()[1], bd[1].min); - float max1 = - bd[0].max + std::fabs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); - float max2 = - bd[1].max + std::fabs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); + float max1 = bd[0].max + std::abs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); + float max2 = bd[1].max + std::abs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); BOOST_CHECK_EQUAL(Grid.maxPosition()[0], max1); BOOST_CHECK_EQUAL(Grid.maxPosition()[1], max2); @@ -152,10 +150,8 @@ BOOST_AUTO_TEST_CASE(PhiZ_Grid_test) { BOOST_CHECK_EQUAL(Grid.minPosition()[0], bd[0].min); BOOST_CHECK_EQUAL(Grid.minPosition()[1], bd[1].min); - float max1 = - bd[0].max + std::fabs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); - float max2 = - bd[1].max + std::fabs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); + float max1 = bd[0].max + std::abs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); + float max2 = bd[1].max + std::abs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); BOOST_CHECK_EQUAL(Grid.maxPosition()[0], max1); BOOST_CHECK_EQUAL(Grid.maxPosition()[1], max2); @@ -244,12 +240,9 @@ BOOST_AUTO_TEST_CASE(Cubic_Grid_test) { BOOST_CHECK_EQUAL(Grid.minPosition()[1], bd[1].min); BOOST_CHECK_EQUAL(Grid.minPosition()[2], bd[2].min); - float max1 = - bd[0].max + std::fabs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); - float max2 = - bd[1].max + std::fabs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); - float max3 = - bd[2].max + std::fabs(bd[2].max - bd[2].min) / (bd[2].bins() - 1); + float max1 = bd[0].max + std::abs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); + float max2 = bd[1].max + std::abs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); + float max3 = bd[2].max + std::abs(bd[2].max - bd[2].min) / (bd[2].bins() - 1); BOOST_CHECK_EQUAL(Grid.maxPosition()[0], max1); BOOST_CHECK_EQUAL(Grid.maxPosition()[1], max2); @@ -341,12 +334,9 @@ BOOST_AUTO_TEST_CASE(Cylindrical_Grid_test) { BOOST_CHECK_EQUAL(Grid.minPosition()[1], bd[1].min); BOOST_CHECK_EQUAL(Grid.minPosition()[2], bd[2].min); - float max1 = - bd[0].max + std::fabs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); - float max2 = - bd[1].max + std::fabs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); - float max3 = - bd[2].max + std::fabs(bd[2].max - bd[2].min) / (bd[2].bins() - 1); + float max1 = bd[0].max + std::abs(bd[0].max - bd[0].min) / (bd[0].bins() - 1); + float max2 = bd[1].max + std::abs(bd[1].max - bd[1].min) / (bd[1].bins() - 1); + float max3 = bd[2].max + std::abs(bd[2].max - bd[2].min) / (bd[2].bins() - 1); BOOST_CHECK_EQUAL(Grid.maxPosition()[0], max1); BOOST_CHECK_EQUAL(Grid.maxPosition()[1], max2); diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index b9842b55420..e7edefb1f03 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -124,9 +125,30 @@ auto makeDefaultBoundPars(bool cov = true, std::size_t n = 4, return c; }; + // 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); + for (auto i = 0ul; i < n; ++i) { - cmps.push_back({1. / n, ext_pars ? *ext_pars : BoundVector::Random(), - cov ? Opt{make_random_sym_matrix()} : Opt{}}); + BoundVector params = BoundVector::Zero(); + + if (ext_pars) { + params = *ext_pars; + } else { + params[eBoundLoc0] = locDis(gen); + params[eBoundLoc1] = locDis(gen); + params[eBoundPhi] = phiDis(gen); + params[eBoundTheta] = thetaDis(gen); + params[eBoundQOverP] = qOverPDis(gen); + params[eBoundTime] = timeDis(gen); + } + + cmps.push_back( + {1. / n, params, cov ? Opt{make_random_sym_matrix()} : Opt{}}); } auto surface = Acts::CurvilinearSurface(Vector3::Zero(), Vector3{1., 0., 0.}) @@ -430,7 +452,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[1])[eBoundPhi] = M_PI; + std::get(cmps[1])[eBoundTheta] = M_PI_2; std::get(cmps[0])[eBoundQOverP] = 1.0; std::get(cmps[1])[eBoundQOverP] = 1.0; @@ -541,7 +564,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[1])[eBoundPhi] = M_PI; + std::get(cmps[1])[eBoundTheta] = M_PI_2; std::get(cmps[0])[eBoundQOverP] = 1.0; std::get(cmps[1])[eBoundQOverP] = 1.0; @@ -703,18 +727,7 @@ void test_single_component_interface_function() { using MultiState = typename multi_stepper_t::State; using MultiStepper = multi_stepper_t; - std::vector>> - cmps; - for (int i = 0; i < 4; ++i) { - cmps.push_back({0.25, BoundVector::Random(), BoundSquareMatrix::Random()}); - } - - auto surface = - Acts::CurvilinearSurface(Vector3::Zero(), Vector3::Ones().normalized()) - .planeSurface(); - - MultiComponentBoundTrackParameters multi_pars(surface, cmps, - particleHypothesis); + MultiComponentBoundTrackParameters multi_pars = makeDefaultBoundPars(true, 4); MultiState multi_state(geoCtx, magCtx, defaultBField, multi_pars, defaultStepSize); 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/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/BoundaryToleranceTestsRefs.hpp b/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTestsRefs.hpp deleted file mode 100644 index a59053b8273..00000000000 --- a/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTestsRefs.hpp +++ /dev/null @@ -1,216 +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/Algebra.hpp" - -// clang-format off -const std::vector rectVertices = { - {-2.000000, -1.000000}, - {2.000000, -1.000000}, - {2.000000, 1.000000}, - {-2.000000, 1.000000} -}; - -const struct { - double xmin = -2; - double xmax = 2; - double ymin = -1; - double ymax = 1; -} rectDimensions; - -const std::vector rectTestPoints = { - {-3.00, -2.00}, {-3.00, -1.60}, {-3.00, -1.20}, {-3.00, -0.80}, {-3.00, -0.40}, - {-3.00, 0.00}, {-3.00, 0.40}, {-3.00, 0.80}, {-3.00, 1.20}, {-3.00, 1.60}, - {-3.00, 2.00}, {-2.40, -2.00}, {-2.40, -1.60}, {-2.40, -1.20}, {-2.40, -0.80}, - {-2.40, -0.40}, {-2.40, 0.00}, {-2.40, 0.40}, {-2.40, 0.80}, {-2.40, 1.20}, - {-2.40, 1.60}, {-2.40, 2.00}, {-1.80, -2.00}, {-1.80, -1.60}, {-1.80, -1.20}, - {-1.80, -0.80}, {-1.80, -0.40}, {-1.80, 0.00}, {-1.80, 0.40}, {-1.80, 0.80}, - {-1.80, 1.20}, {-1.80, 1.60}, {-1.80, 2.00}, {-1.20, -2.00}, {-1.20, -1.60}, - {-1.20, -1.20}, {-1.20, -0.80}, {-1.20, -0.40}, {-1.20, 0.00}, {-1.20, 0.40}, - {-1.20, 0.80}, {-1.20, 1.20}, {-1.20, 1.60}, {-1.20, 2.00}, {-0.60, -2.00}, - {-0.60, -1.60}, {-0.60, -1.20}, {-0.60, -0.80}, {-0.60, -0.40}, {-0.60, 0.00}, - {-0.60, 0.40}, {-0.60, 0.80}, {-0.60, 1.20}, {-0.60, 1.60}, {-0.60, 2.00}, - {0.00, -2.00}, {0.00, -1.60}, {0.00, -1.20}, {0.00, -0.80}, {0.00, -0.40}, - {0.00, 0.00}, {0.00, 0.40}, {0.00, 0.80}, {0.00, 1.20}, {0.00, 1.60}, - {0.00, 2.00}, {0.60, -2.00}, {0.60, -1.60}, {0.60, -1.20}, {0.60, -0.80}, - {0.60, -0.40}, {0.60, 0.00}, {0.60, 0.40}, {0.60, 0.80}, {0.60, 1.20}, - {0.60, 1.60}, {0.60, 2.00}, {1.20, -2.00}, {1.20, -1.60}, {1.20, -1.20}, - {1.20, -0.80}, {1.20, -0.40}, {1.20, 0.00}, {1.20, 0.40}, {1.20, 0.80}, - {1.20, 1.20}, {1.20, 1.60}, {1.20, 2.00}, {1.80, -2.00}, {1.80, -1.60}, - {1.80, -1.20}, {1.80, -0.80}, {1.80, -0.40}, {1.80, 0.00}, {1.80, 0.40}, - {1.80, 0.80}, {1.80, 1.20}, {1.80, 1.60}, {1.80, 2.00}, {2.40, -2.00}, - {2.40, -1.60}, {2.40, -1.20}, {2.40, -0.80}, {2.40, -0.40}, {2.40, 0.00}, - {2.40, 0.40}, {2.40, 0.80}, {2.40, 1.20}, {2.40, 1.60}, {2.40, 2.00}, - {3.00, -2.00}, {3.00, -1.60}, {3.00, -1.20}, {3.00, -0.80}, {3.00, -0.40}, - {3.00, 0.00}, {3.00, 0.40}, {3.00, 0.80}, {3.00, 1.20}, {3.00, 1.60}, - {3.00, 2.00} -}; -//const std::vector rectClosestPoints = { -// {-2.00, -1.00}, {-2.00, -1.00}, {-2.00, -1.00}, {-2.00, -0.80}, {-2.00, -0.40}, -// {-2.00, 0.00}, {-2.00, 0.40}, {-2.00, 0.80}, {-2.00, 1.00}, {-2.00, 1.00}, -// {-2.00, 1.00}, {-2.00, -1.00}, {-2.00, -1.00}, {-2.00, -1.00}, {-2.00, -0.80}, -// {-2.00, -0.40}, {-2.00, 0.00}, {-2.00, 0.40}, {-2.00, 0.80}, {-2.00, 1.00}, -// {-2.00, 1.00}, {-2.00, 1.00}, {-1.80, -1.00}, {-1.80, -1.00}, {-1.80, -1.00}, -// {-2.00, -0.80}, {-2.00, -0.40}, {-2.00, 0.00}, {-2.00, 0.40}, {-1.80, 1.00}, -// {-1.80, 1.00}, {-1.80, 1.00}, {-1.80, 1.00}, {-1.20, -1.00}, {-1.20, -1.00}, -// {-1.20, -1.00}, {-1.20, -1.00}, {-1.20, -1.00}, {-2.00, 0.00}, {-1.20, 1.00}, -// {-1.20, 1.00}, {-1.20, 1.00}, {-1.20, 1.00}, {-1.20, 1.00}, {-0.60, -1.00}, -// {-0.60, -1.00}, {-0.60, -1.00}, {-0.60, -1.00}, {-0.60, -1.00}, {-0.60, -1.00}, -// {-0.60, 1.00}, {-0.60, 1.00}, {-0.60, 1.00}, {-0.60, 1.00}, {-0.60, 1.00}, -// {0.00, -1.00}, {0.00, -1.00}, {0.00, -1.00}, {0.00, -1.00}, {0.00, -1.00}, -// {0.00, -1.00}, {0.00, 1.00}, {0.00, 1.00}, {0.00, 1.00}, {0.00, 1.00}, -// {0.00, 1.00}, {0.60, -1.00}, {0.60, -1.00}, {0.60, -1.00}, {0.60, -1.00}, -// {0.60, -1.00}, {0.60, -1.00}, {0.60, 1.00}, {0.60, 1.00}, {0.60, 1.00}, -// {0.60, 1.00}, {0.60, 1.00}, {1.20, -1.00}, {1.20, -1.00}, {1.20, -1.00}, -// {1.20, -1.00}, {1.20, -1.00}, {2.00, 0.00}, {1.20, 1.00}, {1.20, 1.00}, -// {1.20, 1.00}, {1.20, 1.00}, {1.20, 1.00}, {1.80, -1.00}, {1.80, -1.00}, -// {1.80, -1.00}, {1.80, -1.00}, {2.00, -0.40}, {2.00, 0.00}, {2.00, 0.40}, -// {1.80, 1.00}, {1.80, 1.00}, {1.80, 1.00}, {1.80, 1.00}, {2.00, -1.00}, -// {2.00, -1.00}, {2.00, -1.00}, {2.00, -0.80}, {2.00, -0.40}, {2.00, 0.00}, -// {2.00, 0.40}, {2.00, 0.80}, {2.00, 1.00}, {2.00, 1.00}, {2.00, 1.00}, -// {2.00, -1.00}, {2.00, -1.00}, {2.00, -1.00}, {2.00, -0.80}, {2.00, -0.40}, -// {2.00, 0.00}, {2.00, 0.40}, {2.00, 0.80}, {2.00, 1.00}, {2.00, 1.00}, -// {2.00, 1.00} -//}; -const std::vector rectDistances = { - 1.4142135623730951, 1.1661903789690602, 1.019803902718557, 1.0, 1.0, 1.0, 1.0, - 1.0, 1.019803902718557, 1.1661903789690602, 1.4142135623730951, - 1.0770329614269007, 0.7211102550927979, 0.4472135954999578, 0.3999999999999999, - 0.3999999999999999, 0.3999999999999999, 0.3999999999999999, 0.3999999999999999, - 0.4472135954999579, 0.7211102550927979, 1.0770329614269007, 1.0, - 0.6000000000000001, 0.19999999999999996, -0.19999999999999996, - -0.19999999999999996, -0.19999999999999996, -0.19999999999999996, - -0.19999999999999973, 0.20000000000000018, 0.6000000000000001, 1.0, 1.0, - 0.6000000000000001, 0.19999999999999996, -0.20000000000000018, - -0.6000000000000001, -0.7999999999999998, -0.5999999999999996, - -0.19999999999999973, 0.20000000000000018, 0.6000000000000001, 1.0, 1.0, - 0.6000000000000001, 0.19999999999999996, -0.20000000000000018, - -0.6000000000000001, -1.0, -0.5999999999999996, -0.19999999999999973, - 0.20000000000000018, 0.6000000000000001, 1.0, 1.0, 0.6000000000000001, - 0.19999999999999996, -0.20000000000000018, -0.6000000000000001, -1.0, - -0.5999999999999996, -0.19999999999999973, 0.20000000000000018, - 0.6000000000000001, 1.0, 1.0, 0.6000000000000001, 0.19999999999999996, - -0.20000000000000018, -0.6000000000000001, -1.0, -0.5999999999999996, - -0.19999999999999973, 0.20000000000000018, 0.6000000000000001, 1.0, 1.0, - 0.6000000000000001, 0.19999999999999996, -0.20000000000000018, - -0.6000000000000001, -0.7999999999999998, -0.5999999999999996, - -0.19999999999999973, 0.20000000000000018, 0.6000000000000001, 1.0, 1.0, - 0.6000000000000001, 0.19999999999999996, -0.20000000000000018, - -0.20000000000000018, -0.20000000000000018, -0.20000000000000018, - -0.19999999999999973, 0.20000000000000018, 0.6000000000000001, 1.0, - 1.0770329614269007, 0.7211102550927977, 0.44721359549995743, - 0.39999999999999947, 0.39999999999999947, 0.39999999999999947, - 0.39999999999999947, 0.39999999999999947, 0.44721359549995754, - 0.7211102550927977, 1.0770329614269007, 1.4142135623730951, 1.1661903789690602, - 1.019803902718557, 1.0, 1.0, 1.0, 1.0, 1.0, 1.019803902718557, - 1.1661903789690602, 1.4142135623730951 -}; - -const std::vector rectShiftedVertices = { - {1.000000, 2.000000}, - {3.000000, 2.000000}, - {3.000000, 4.000000}, - {1.000000, 4.000000} -}; - -const struct { - double xmin = 1; - double xmax = 3; - double ymin = 2; - double ymax = 4; -} rectShiftedDimensions; - -const std::vector rectShiftedTestPoints = { - {0.00, 1.50}, {0.00, 1.80}, {0.00, 2.10}, {0.00, 2.40}, {0.00, 2.70}, - {0.00, 3.00}, {0.00, 3.30}, {0.00, 3.60}, {0.00, 3.90}, {0.00, 4.20}, - {0.00, 4.50}, {0.40, 1.50}, {0.40, 1.80}, {0.40, 2.10}, {0.40, 2.40}, - {0.40, 2.70}, {0.40, 3.00}, {0.40, 3.30}, {0.40, 3.60}, {0.40, 3.90}, - {0.40, 4.20}, {0.40, 4.50}, {0.80, 1.50}, {0.80, 1.80}, {0.80, 2.10}, - {0.80, 2.40}, {0.80, 2.70}, {0.80, 3.00}, {0.80, 3.30}, {0.80, 3.60}, - {0.80, 3.90}, {0.80, 4.20}, {0.80, 4.50}, {1.20, 1.50}, {1.20, 1.80}, - {1.20, 2.10}, {1.20, 2.40}, {1.20, 2.70}, {1.20, 3.00}, {1.20, 3.30}, - {1.20, 3.60}, {1.20, 3.90}, {1.20, 4.20}, {1.20, 4.50}, {1.60, 1.50}, - {1.60, 1.80}, {1.60, 2.10}, {1.60, 2.40}, {1.60, 2.70}, {1.60, 3.00}, - {1.60, 3.30}, {1.60, 3.60}, {1.60, 3.90}, {1.60, 4.20}, {1.60, 4.50}, - {2.00, 1.50}, {2.00, 1.80}, {2.00, 2.10}, {2.00, 2.40}, {2.00, 2.70}, - {2.00, 3.00}, {2.00, 3.30}, {2.00, 3.60}, {2.00, 3.90}, {2.00, 4.20}, - {2.00, 4.50}, {2.40, 1.50}, {2.40, 1.80}, {2.40, 2.10}, {2.40, 2.40}, - {2.40, 2.70}, {2.40, 3.00}, {2.40, 3.30}, {2.40, 3.60}, {2.40, 3.90}, - {2.40, 4.20}, {2.40, 4.50}, {2.80, 1.50}, {2.80, 1.80}, {2.80, 2.10}, - {2.80, 2.40}, {2.80, 2.70}, {2.80, 3.00}, {2.80, 3.30}, {2.80, 3.60}, - {2.80, 3.90}, {2.80, 4.20}, {2.80, 4.50}, {3.20, 1.50}, {3.20, 1.80}, - {3.20, 2.10}, {3.20, 2.40}, {3.20, 2.70}, {3.20, 3.00}, {3.20, 3.30}, - {3.20, 3.60}, {3.20, 3.90}, {3.20, 4.20}, {3.20, 4.50}, {3.60, 1.50}, - {3.60, 1.80}, {3.60, 2.10}, {3.60, 2.40}, {3.60, 2.70}, {3.60, 3.00}, - {3.60, 3.30}, {3.60, 3.60}, {3.60, 3.90}, {3.60, 4.20}, {3.60, 4.50}, - {4.00, 1.50}, {4.00, 1.80}, {4.00, 2.10}, {4.00, 2.40}, {4.00, 2.70}, - {4.00, 3.00}, {4.00, 3.30}, {4.00, 3.60}, {4.00, 3.90}, {4.00, 4.20}, - {4.00, 4.50} -}; -//const std::vector rectShiftedClosestPoints = { -// {1.00, 2.00}, {1.00, 2.00}, {1.00, 2.10}, {1.00, 2.40}, {1.00, 2.70}, -// {1.00, 3.00}, {1.00, 3.30}, {1.00, 3.60}, {1.00, 3.90}, {1.00, 4.00}, -// {1.00, 4.00}, {1.00, 2.00}, {1.00, 2.00}, {1.00, 2.10}, {1.00, 2.40}, -// {1.00, 2.70}, {1.00, 3.00}, {1.00, 3.30}, {1.00, 3.60}, {1.00, 3.90}, -// {1.00, 4.00}, {1.00, 4.00}, {1.00, 2.00}, {1.00, 2.00}, {1.00, 2.10}, -// {1.00, 2.40}, {1.00, 2.70}, {1.00, 3.00}, {1.00, 3.30}, {1.00, 3.60}, -// {1.00, 3.90}, {1.00, 4.00}, {1.00, 4.00}, {1.20, 2.00}, {1.20, 2.00}, -// {1.20, 2.00}, {1.00, 2.40}, {1.00, 2.70}, {1.00, 3.00}, {1.00, 3.30}, -// {1.00, 3.60}, {1.20, 4.00}, {1.20, 4.00}, {1.20, 4.00}, {1.60, 2.00}, -// {1.60, 2.00}, {1.60, 2.00}, {1.60, 2.00}, {1.00, 2.70}, {1.00, 3.00}, -// {1.00, 3.30}, {1.60, 4.00}, {1.60, 4.00}, {1.60, 4.00}, {1.60, 4.00}, -// {2.00, 2.00}, {2.00, 2.00}, {2.00, 2.00}, {2.00, 2.00}, {2.00, 2.00}, -// {2.00, 2.00}, {2.00, 4.00}, {2.00, 4.00}, {2.00, 4.00}, {2.00, 4.00}, -// {2.00, 4.00}, {2.40, 2.00}, {2.40, 2.00}, {2.40, 2.00}, {2.40, 2.00}, -// {3.00, 2.70}, {3.00, 3.00}, {3.00, 3.30}, {2.40, 4.00}, {2.40, 4.00}, -// {2.40, 4.00}, {2.40, 4.00}, {2.80, 2.00}, {2.80, 2.00}, {2.80, 2.00}, -// {3.00, 2.40}, {3.00, 2.70}, {3.00, 3.00}, {3.00, 3.30}, {3.00, 3.60}, -// {2.80, 4.00}, {2.80, 4.00}, {2.80, 4.00}, {3.00, 2.00}, {3.00, 2.00}, -// {3.00, 2.10}, {3.00, 2.40}, {3.00, 2.70}, {3.00, 3.00}, {3.00, 3.30}, -// {3.00, 3.60}, {3.00, 3.90}, {3.00, 4.00}, {3.00, 4.00}, {3.00, 2.00}, -// {3.00, 2.00}, {3.00, 2.10}, {3.00, 2.40}, {3.00, 2.70}, {3.00, 3.00}, -// {3.00, 3.30}, {3.00, 3.60}, {3.00, 3.90}, {3.00, 4.00}, {3.00, 4.00}, -// {3.00, 2.00}, {3.00, 2.00}, {3.00, 2.10}, {3.00, 2.40}, {3.00, 2.70}, -// {3.00, 3.00}, {3.00, 3.30}, {3.00, 3.60}, {3.00, 3.90}, {3.00, 4.00}, -// {3.00, 4.00} -//}; -const std::vector rectShiftedDistances = { - 1.118033988749895, 1.019803902718557, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, - 1.0198039027185568, 1.118033988749895, 0.7810249675906654, 0.6324555320336759, - 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6324555320336757, 0.7810249675906654, - 0.5385164807134504, 0.28284271247461895, 0.19999999999999996, - 0.19999999999999996, 0.19999999999999996, 0.19999999999999996, - 0.19999999999999996, 0.19999999999999996, 0.19999999999999996, - 0.28284271247461845, 0.5385164807134504, 0.5, 0.19999999999999996, - -0.10000000000000009, -0.20000000000000018, -0.20000000000000018, - -0.20000000000000018, -0.20000000000000018, -0.20000000000000018, - -0.10000000000000009, 0.1999999999999993, 0.5, 0.5, 0.19999999999999996, - -0.10000000000000009, -0.3999999999999999, -0.6000000000000001, - -0.6000000000000001, -0.6000000000000001, -0.3999999999999999, - -0.10000000000000009, 0.1999999999999993, 0.5, 0.5, 0.19999999999999996, - -0.10000000000000009, -0.3999999999999999, -0.7000000000000002, -1.0, - -0.7000000000000002, -0.3999999999999999, -0.10000000000000009, - 0.1999999999999993, 0.5, 0.5, 0.19999999999999996, -0.10000000000000009, - -0.3999999999999999, -0.5999999999999996, -0.5999999999999996, - -0.5999999999999996, -0.3999999999999999, -0.10000000000000009, - 0.1999999999999993, 0.5, 0.5, 0.19999999999999996, -0.10000000000000009, - -0.19999999999999973, -0.19999999999999973, -0.19999999999999973, - -0.19999999999999973, -0.19999999999999973, -0.10000000000000009, - 0.1999999999999993, 0.5, 0.5385164807134505, 0.28284271247461906, - 0.20000000000000018, 0.20000000000000018, 0.20000000000000018, - 0.20000000000000018, 0.20000000000000018, 0.20000000000000018, - 0.20000000000000018, 0.2828427124746186, 0.5385164807134505, 0.7810249675906655, - 0.6324555320336759, 0.6000000000000001, 0.6000000000000001, 0.6000000000000001, - 0.6000000000000001, 0.6000000000000001, 0.6000000000000001, 0.6000000000000001, - 0.6324555320336757, 0.7810249675906655, 1.118033988749895, 1.019803902718557, - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0198039027185568, 1.118033988749895 -}; - -// clang-format on diff --git a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp index 887a14391c5..ba38f5d11c1 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp @@ -17,132 +17,140 @@ #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 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 { BOOST_AUTO_TEST_SUITE(Surfaces) +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); + /// Test default construction + // default construction is deleted + 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); } -// Streaning and recreation test +/// 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 +/// 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); + + // 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 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 - 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)")); } // 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..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" @@ -25,6 +26,7 @@ #include #include #include +#include #include namespace Acts::Test { @@ -36,13 +38,17 @@ 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 - double alpha{M_PI / 8.}, halfPhiSector{M_PI / 16.}, zMin{1.0}, zMax{10.}; - bool symmetric(false); - Translation3 translation{0., 1., 2.}; + /// 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.; + 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,7 +57,7 @@ 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 BOOST_CHECK_EQUAL(Surface::makeShared(pTransform, alpha, zMin, zMax, halfPhiSector) @@ -59,22 +65,19 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { Surface::Cone); /// Constructor with transform and ConeBounds pointer - // ConeBounds (double alpha, double zmin, double zmax, double halfphi=M_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 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 auto copiedTransformedConeSurface = Surface::makeShared( tgContext, *coneSurfaceObject, pTransform); @@ -85,28 +88,29 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { 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 globalPosition{2., 2., 2.}; Vector3 momentum{1.e6, 1.e6, 1.e6}; double rootHalf = std::sqrt(0.5); RotationMatrix3 expectedFrame; @@ -114,45 +118,43 @@ 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,40 +166,41 @@ 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; - // coneSurfaceObject.toStream(dumpOuput); - // BOOST_CHECK(dumpOuput.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, averagePhi, - // halfPhiSector) = (0.4142136, 0.0000000, inf, 0.0000000, - // 3.1415927)")); + boost::test_tools::output_test_stream dumpOutput; + dumpOutput << coneSurfaceObject->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) { - 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,11 +212,13 @@ 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 + /// Testing a Full cone auto pTransform = Transform3(translation); auto pConeBounds = std::make_shared(alpha, zMin, zMax); auto pCone = Surface::makeShared(pTransform, pConeBounds); @@ -237,8 +242,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { CHECK_CLOSE_ABS(rMax, pConeExtent.max(BinningValue::binY), s_onSurfaceTolerance); - // Now a sector - double halfPhiSector = M_PI / 8.; + /// Now a sector pConeBounds = std::make_shared(alpha, zMin, zMax, halfPhiSector, 0.); pCone = Surface::makeShared(pTransform, pConeBounds); @@ -256,9 +260,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 +284,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..14cafdd045b 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 @@ -27,34 +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 - double radius(0.5), halfz(10.), halfphi(M_PI / 2.0), averagePhi(M_PI / 2.0), - minBevelZ(-M_PI / 4), maxBevelZ(M_PI / 6); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz).type(), - SurfaceBounds::eCylinder); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, halfphi).type(), + /// 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 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, averagePhi).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ, halfPhi).type(), SurfaceBounds::eCylinder); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, M_PI, 0., minBevelZ).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ, halfPhi, averagePhi).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); - // - /// test copy construction; - CylinderBounds cylinderBounds(radius, halfz); + BOOST_CHECK_EQUAL( + CylinderBounds(radius, halfZ, std::numbers::pi, 0., bevelMinZ, bevelMaxZ) + .type(), + SurfaceBounds::eCylinder); + + /// 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 - 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 original = CylinderBounds(radius, halfZ); auto valvector = original.values(); std::array values{}; std::copy_n(valvector.begin(), CylinderBounds::eSize, values.begin()); @@ -63,60 +72,64 @@ 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), + /// 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 - 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); - - /// test for type() + // 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 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 + /// 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 unitZ{0.0, 1.0}; - const Vector2 unitPhi{1.0, 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., 1.}; + const Vector2 unitPhi{1., 0.}; const Vector2 withinBevelMin{0.5, -20.012}; const Vector2 outsideBevelMin{0.5, -40.}; const BoundaryTolerance tolerance = 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)); @@ -127,44 +140,46 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { BOOST_CHECK( !cylinderBoundsBeveledObject.inside(outsideBevelMin, lessTolerance)); - /// test for r() - CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eR), nominalRadius, - 1e-6); + /// 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), - nominalHalfLength, 1e-6); + /// 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) { - 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..4dd6f7f6905 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 @@ -54,16 +55,20 @@ 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 - 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 +80,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 +88,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 +100,35 @@ 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 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.}; 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,8 +193,8 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { testContext, offSurface, momentum, BoundaryTolerance::None())); 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()); @@ -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/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 3012f71217e..b5d1eec5f43 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 @@ -53,30 +54,32 @@ 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... - double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.); - // + /// Test default construction + // default construction is deleted + + 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,67 +93,66 @@ 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); + 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); - // + /// 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 + Vector3 point3DNotInSector{0., 1.2, 0}; + Vector3 point3DOnSurface{1.2, 0., 0}; + 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 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) @@ -162,51 +164,51 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { discSurfaceObject ->globalToLocal(tgContext, point3DNotInSector, ignoredMomentum) .value(); - // - Vector3 pointOutsideR{0.0, 100., 0}; + + Vector3 pointOutsideR{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,29 +225,31 @@ 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 = Surface::makeShared(Transform3::Identity(), 2.2, 4.4, 0.07); - // + BOOST_CHECK_NO_THROW(*assignedDisc = *discSurfaceObject); BOOST_CHECK((*assignedDisc) == (*discSurfaceObject)); } /// 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 +271,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 +302,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); @@ -330,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); } @@ -345,7 +352,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); @@ -409,11 +417,12 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) { BOOST_AUTO_TEST_SUITE(DiscSurfaceMerging) namespace { -std::shared_ptr makeDisc(const Transform3& transform, double rmin, - double rmax, double halfPhi = M_PI, +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 @@ -657,7 +666,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 +691,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 +723,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); @@ -798,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 7d7391428f3..0ed78e656f6 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,20 +26,25 @@ 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 + // default construction is deleted - // test default construction - // EllipseBounds defaultConstructedEllipseBounds; //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); @@ -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,44 +68,54 @@ 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), 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.), @@ -108,74 +124,71 @@ 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( + 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)")); - // + "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 +196,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/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 71dbf0827de..15d930929af 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -14,6 +14,7 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/ParticleHypothesis.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/EventData/detail/GenerateParameters.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Material/HomogeneousSurfaceMaterial.hpp" #include "Acts/Propagator/Propagator.hpp" @@ -35,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -55,28 +57,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()); @@ -94,18 +102,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 @@ -113,7 +121,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.}; @@ -127,7 +135,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( @@ -136,7 +144,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.}; @@ -145,7 +153,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 = @@ -154,42 +162,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< 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); } @@ -282,7 +287,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(); @@ -339,8 +344,9 @@ BOOST_AUTO_TEST_CASE(LineSurfaceIntersection) { .closest(); CHECK_CLOSE_ABS(intersection.pathLength(), pathLimit, eps); - BoundTrackParameters endParameters{surface, BoundVector::Zero(), std::nullopt, - ParticleHypothesis::pion()}; + BoundTrackParameters endParameters{surface, + detail::Test::someBoundParametersA(), + std::nullopt, ParticleHypothesis::pion()}; { PropagatorOptions options(tgContext, {}); options.direction = Acts::Direction::Forward; diff --git a/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp index b2346434293..3ccf47b4e11 100644 --- a/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp @@ -25,45 +25,46 @@ GeometryContext tgContext = GeometryContext(); BOOST_AUTO_TEST_SUITE(PerigeeSurfaces) /// Unit test for creating compliant/non-compliant PerigeeSurface object BOOST_AUTO_TEST_CASE(PerigeeSurfaceConstruction) { - // PerigeeSurface default constructor is deleted - // + /// Test default construction + // default construction is deleted + /// Constructor with Vector3 Vector3 unitXYZ{1., 1., 1.}; auto perigeeSurfaceObject = Surface::makeShared(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 ee91782dca2..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" @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -44,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); @@ -61,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); @@ -73,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); @@ -88,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.; @@ -106,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); @@ -119,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) @@ -158,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, @@ -172,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::sqrt(3), 0.01); - // + 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) { @@ -207,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); } @@ -224,9 +232,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.; @@ -281,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}; @@ -309,7 +318,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..a25eeb4d352 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) -/// Unit tests for RadialBounds constrcuctors +const double rMin = 1.; +const double rMax = 5.; +const double halfPhiSector = std::numbers::pi / 8.; +const double avgPhi = 0.1; + +/// Unit tests for RadialBounds constructors 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 default construction + // default construction is 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,75 +61,72 @@ 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); + 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())); 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); - // + BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 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); - // operator == not implemented in this class - // + RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector); + + /// Test operator == + // not implemented in this class + /// Test assignment RadialBounds assignedRadialBoundsObject(10.1, 123.); assignedRadialBoundsObject = radialBoundsObject; 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 348b6cceed6..2d62f29f4e4 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); @@ -135,8 +136,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 +186,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()); }; @@ -225,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); @@ -239,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); @@ -253,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 fed41d3fdde..e6294fc27ca 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; @@ -42,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 @@ -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; + const double alpha = std::numbers::pi / 4.; auto testConeIntersection = [&](const Transform3& transform) -> void { // A cone surface ready to use @@ -179,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(); @@ -224,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 @@ -323,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 b1b56b18d59..11c66abf303 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 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 posAngle = bdata::xrange(-std::numbers::pi, std::numbers::pi, 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(-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 @@ -93,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 */, @@ -108,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 @@ -123,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, @@ -135,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 2b52064cb8d..ecd464b42d7 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 + // Now ellipsoid 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/TrackFitting/FitterTestsCommon.hpp b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp index 6692974ef63..269370d4fc4 100644 --- a/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp +++ b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp @@ -77,7 +77,7 @@ struct TestReverseFilteringLogic { template bool operator()(typename traj_t::ConstTrackStateProxy state) const { // can't determine an outlier w/o a measurement or predicted parameters - auto momentum = fabs(1 / state.filtered()[Acts::eBoundQOverP]); + auto momentum = std::abs(1 / state.filtered()[Acts::eBoundQOverP]); std::cout << "momentum : " << momentum << std::endl; return (momentum <= momentumMax); } diff --git a/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp b/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp index c9743e90d7f..279f2c1a739 100644 --- a/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -371,6 +372,9 @@ BOOST_DATA_TEST_CASE(VertexCompatibility4D, IPs* vertices, d0, l0, vx0, vy0, BoundVector paramVecClose = BoundVector::Zero(); paramVecClose[eBoundLoc0] = d0; paramVecClose[eBoundLoc1] = l0; + paramVecClose[eBoundPhi] = 0; + paramVecClose[eBoundTheta] = std::numbers::pi / 2; + paramVecClose[eBoundQOverP] = 0; paramVecClose[eBoundTime] = vt0 + sgnClose * timeDiffClose; BoundVector paramVecFar = paramVecClose; diff --git a/Tests/UnitTests/Core/Vertexing/SingleSeedVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/SingleSeedVertexFinderTests.cpp index 95ba93c0efb..7be7e174e6a 100644 --- a/Tests/UnitTests/Core/Vertexing/SingleSeedVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/SingleSeedVertexFinderTests.cpp @@ -294,10 +294,10 @@ BOOST_AUTO_TEST_CASE(single_seed_vertex_finder_full_planes_test) { double x1 = (D * dirY + sgn * dirX * std::sqrt(r * r * dirR2 - D * D)) / dirR2; double y1 = - (-D * dirX + std::fabs(dirY) * std::sqrt(r * r * dirR2 - D * D)) / + (-D * dirX + std::abs(dirY) * std::sqrt(r * r * dirR2 - D * D)) / dirR2; // how many units from the vertex to the intersection - double zDist = std::fabs((x1 - posX) / dirX); + double zDist = std::abs((x1 - posX) / dirX); // position of the new spacepoint posX = x1; @@ -411,11 +411,11 @@ BOOST_AUTO_TEST_CASE(single_seed_vertex_finder_full_rays_test) { double x1 = (D * dirY + part * sgn * dirX * std::sqrt(r * r * dirR2 - D * D)) / dirR2; - double y1 = (-D * dirX + part * std::fabs(dirY) * - std::sqrt(r * r * dirR2 - D * D)) / + double y1 = (-D * dirX + + part * std::abs(dirY) * std::sqrt(r * r * dirR2 - D * D)) / dirR2; // how many units from the vertex to the intersection - double zDist = std::fabs((x1 - vtxX) / dirX); + double zDist = std::abs((x1 - vtxX) / dirX); // use the same amount of units for distance in Z inputSpacepoints.emplace_back(x1, y1, zDist * dirZ + vtxZ); } diff --git a/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp b/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp index f281c7c1095..033f2c9cb4a 100644 --- a/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp +++ b/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp @@ -101,9 +101,9 @@ GeoGeometry constructGeoModel() { {123, 50}, {-123, 50}, {-153, 0}}; geoDims.tube = {5, 6, 100}; geoDims.trapHls = { - fabs(geoDims.trapVerts[0][0] - geoDims.trapVerts[1][0]) / 2, - fabs(geoDims.trapVerts[2][0] - geoDims.trapVerts[3][0]) / 2, - fabs(geoDims.trapVerts[0][1] - geoDims.trapVerts[2][1]) / 2}; + std::abs(geoDims.trapVerts[0][0] - geoDims.trapVerts[1][0]) / 2, + std::abs(geoDims.trapVerts[2][0] - geoDims.trapVerts[3][0]) / 2, + std::abs(geoDims.trapVerts[0][1] - geoDims.trapVerts[2][1]) / 2}; // create shapes GeoIntrusivePtr boxXY( diff --git a/Tests/UnitTests/Plugins/Json/TrackParametersJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/TrackParametersJsonConverterTests.cpp index 566464a1889..5c0882cb12c 100644 --- a/Tests/UnitTests/Plugins/Json/TrackParametersJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/TrackParametersJsonConverterTests.cpp @@ -8,12 +8,12 @@ #include +#include "Acts/EventData/ParticleHypothesis.hpp" +#include "Acts/EventData/TrackParameters.hpp" #include "Acts/Plugins/Json/TrackParametersJsonConverter.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" -#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" -#include #include #include