From 306ae23993fea1e8fb848228ecee874ca50f3faa Mon Sep 17 00:00:00 2001 From: Pierfrancesco Butti Date: Fri, 22 Nov 2024 19:05:08 +0100 Subject: [PATCH 1/6] fix: Add check on expected measurements on surface before marking as hole (#3892) Check expected measurement during track finding before marking state as hole @andiwand --- Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 35acbc49feb..315dd2379b0 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -739,7 +739,7 @@ class CombinatorialKalmanFilter { slRange = m_sourceLinkAccessor(*surface); hasMeasurements = slRange->first != slRange->second; } - bool isHole = isSensitive && !hasMeasurements; + bool isHole = isSensitive && expectMeasurements && !hasMeasurements; if (isHole) { ACTS_VERBOSE("Detected hole before measurement selection on surface " From b30f8dfe86e2ed940fac02bbe54efdfe2cddaac0 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sat, 23 Nov 2024 10:18:35 +0100 Subject: [PATCH 2/6] feat: Add statistics to propagation (#3450) This is an attempt to centralize statistics about the propagation which includes stepping and navigation. The intention is to monitor these quantities in the CI and to use them as comparison for different stepper / navigator implementations. --- .../Acts/Navigation/DetectorNavigator.hpp | 4 +++ Core/include/Acts/Propagator/AtlasStepper.hpp | 4 +++ .../Acts/Propagator/DirectNavigator.hpp | 4 +++ Core/include/Acts/Propagator/EigenStepper.hpp | 5 ++- Core/include/Acts/Propagator/EigenStepper.ipp | 15 +++++++- .../Acts/Propagator/MultiEigenStepperLoop.hpp | 4 +++ Core/include/Acts/Propagator/Navigator.hpp | 11 +++--- .../Acts/Propagator/NavigatorStatistics.hpp | 26 ++++++++++++++ Core/include/Acts/Propagator/Propagator.ipp | 3 ++ .../Acts/Propagator/PropagatorResult.hpp | 4 +++ .../Acts/Propagator/PropagatorState.hpp | 4 +++ .../Acts/Propagator/PropagatorStatistics.hpp | 26 ++++++++++++++ .../Acts/Propagator/StepperStatistics.hpp | 34 ++++++++++++++++++ .../Acts/Propagator/StraightLineStepper.hpp | 14 +++++++- Core/include/Acts/Propagator/SympyStepper.hpp | 12 ++----- .../Acts/Propagator/TryAllNavigator.hpp | 4 +++ .../include/Acts/Propagator/VoidNavigator.hpp | 4 +++ Core/src/Propagator/SympyStepper.cpp | 12 ++++++- .../Propagation/PropagatorInterface.hpp | 2 ++ .../EventData/PropagationSummary.hpp | 4 +++ .../Io/Root/RootPropagationSummaryWriter.hpp | 19 +++++----- .../Root/src/RootPropagationStepsWriter.cpp | 7 ++-- .../Root/src/RootPropagationSummaryWriter.cpp | 36 +++++++++++-------- Examples/Python/tests/root_file_hashes.txt | 2 +- .../Core/Propagator/SympyStepperTests.cpp | 23 ------------ 25 files changed, 214 insertions(+), 69 deletions(-) create mode 100644 Core/include/Acts/Propagator/NavigatorStatistics.hpp create mode 100644 Core/include/Acts/Propagator/PropagatorStatistics.hpp create mode 100644 Core/include/Acts/Propagator/StepperStatistics.hpp diff --git a/Core/include/Acts/Navigation/DetectorNavigator.hpp b/Core/include/Acts/Navigation/DetectorNavigator.hpp index 61d8525106c..0ffcf1446bc 100644 --- a/Core/include/Acts/Navigation/DetectorNavigator.hpp +++ b/Core/include/Acts/Navigation/DetectorNavigator.hpp @@ -17,6 +17,7 @@ #include "Acts/Geometry/Layer.hpp" #include "Acts/Navigation/NavigationState.hpp" #include "Acts/Propagator/NavigatorOptions.hpp" +#include "Acts/Propagator/NavigatorStatistics.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -68,6 +69,9 @@ class DetectorNavigator { bool targetReached = false; /// Navigation state : a break has been detected bool navigationBreak = false; + + /// Navigation statistics + NavigatorStatistics statistics; }; /// Constructor with configuration object diff --git a/Core/include/Acts/Propagator/AtlasStepper.hpp b/Core/include/Acts/Propagator/AtlasStepper.hpp index f31aadbffab..88cfd39e548 100644 --- a/Core/include/Acts/Propagator/AtlasStepper.hpp +++ b/Core/include/Acts/Propagator/AtlasStepper.hpp @@ -21,6 +21,7 @@ #include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/StepperOptions.hpp" +#include "Acts/Propagator/StepperStatistics.hpp" #include "Acts/Propagator/detail/SteppingHelper.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Intersection.hpp" @@ -305,6 +306,9 @@ class AtlasStepper { /// buffer & formatting for consistent output std::size_t debugPfxWidth = 30; std::size_t debugMsgWidth = 50; + + /// The statistics of the stepper + StepperStatistics statistics; }; explicit AtlasStepper(std::shared_ptr bField) diff --git a/Core/include/Acts/Propagator/DirectNavigator.hpp b/Core/include/Acts/Propagator/DirectNavigator.hpp index eb9db91e71f..3356ab395c4 100644 --- a/Core/include/Acts/Propagator/DirectNavigator.hpp +++ b/Core/include/Acts/Propagator/DirectNavigator.hpp @@ -14,6 +14,7 @@ #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Geometry/TrackingVolume.hpp" #include "Acts/Propagator/NavigatorOptions.hpp" +#include "Acts/Propagator/NavigatorStatistics.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -75,6 +76,9 @@ class DirectNavigator { /// Navigation state - external interface: a break has been detected bool navigationBreak = false; + /// Navigation statistics + NavigatorStatistics statistics; + const Surface* navSurface() const { return options.surfaces.at(surfaceIndex); } diff --git a/Core/include/Acts/Propagator/EigenStepper.hpp b/Core/include/Acts/Propagator/EigenStepper.hpp index fb1062b0c9b..09df3ce3167 100644 --- a/Core/include/Acts/Propagator/EigenStepper.hpp +++ b/Core/include/Acts/Propagator/EigenStepper.hpp @@ -13,7 +13,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Tolerance.hpp" -#include "Acts/Definitions/Units.hpp" #include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp" #include "Acts/Geometry/GeometryContext.hpp" @@ -23,6 +22,7 @@ #include "Acts/Propagator/EigenStepperDefaultExtension.hpp" #include "Acts/Propagator/PropagatorTraits.hpp" #include "Acts/Propagator/StepperOptions.hpp" +#include "Acts/Propagator/StepperStatistics.hpp" #include "Acts/Propagator/detail/SteppingHelper.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" @@ -164,6 +164,9 @@ class EigenStepper { /// k_i elements of the momenta std::array kQoP{}; } stepData; + + /// Statistics of the stepper + StepperStatistics statistics; }; /// Constructor requires knowledge of the detector's magnetic field diff --git a/Core/include/Acts/Propagator/EigenStepper.ipp b/Core/include/Acts/Propagator/EigenStepper.ipp index 84b305ae431..4ee3a41b04a 100644 --- a/Core/include/Acts/Propagator/EigenStepper.ipp +++ b/Core/include/Acts/Propagator/EigenStepper.ipp @@ -6,6 +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 "Acts/Definitions/Direction.hpp" #include "Acts/EventData/TransformationHelpers.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/EigenStepperError.hpp" @@ -259,7 +260,9 @@ Acts::Result Acts::EigenStepper::step( // Select and adjust the appropriate Runge-Kutta step size as given // ATL-SOFT-PUB-2009-001 while (true) { - nStepTrials++; + ++nStepTrials; + ++state.stepping.statistics.nAttemptedSteps; + auto res = tryRungeKuttaStep(h); if (!res.ok()) { return res.error(); @@ -268,6 +271,8 @@ Acts::Result Acts::EigenStepper::step( break; } + ++state.stepping.statistics.nRejectedSteps; + const double stepSizeScaling = calcStepSizeScaling(errorEstimate); h *= stepSizeScaling; @@ -351,6 +356,14 @@ Acts::Result Acts::EigenStepper::step( ++state.stepping.nSteps; state.stepping.nStepTrials += nStepTrials; + ++state.stepping.statistics.nSuccessfulSteps; + if (state.options.direction != + Direction::fromScalarZeroAsPositive(initialH)) { + ++state.stepping.statistics.nReverseSteps; + } + state.stepping.statistics.pathLength += h; + state.stepping.statistics.absolutePathLength += std::abs(h); + const double stepSizeScaling = calcStepSizeScaling(errorEstimate); const double nextAccuracy = std::abs(h * stepSizeScaling); const double previousAccuracy = std::abs(state.stepping.stepSize.accuracy()); diff --git a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp index 1bb4ab8f55a..e21bdb2365e 100644 --- a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp +++ b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp @@ -25,6 +25,7 @@ #include "Acts/Propagator/MultiStepperError.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StepperOptions.hpp" +#include "Acts/Propagator/StepperStatistics.hpp" #include "Acts/Propagator/detail/LoopStepperUtils.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Intersection.hpp" @@ -219,6 +220,9 @@ class MultiEigenStepperLoop : public EigenStepper { /// reached a surface std::optional stepCounterAfterFirstComponentOnSurface; + /// The stepper statistics + StepperStatistics statistics; + /// No default constructor is provided State() = delete; diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index c2a9427257c..a02e0958160 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -8,13 +8,13 @@ #pragma once -#include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Geometry/Layer.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Geometry/TrackingVolume.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/NavigatorOptions.hpp" +#include "Acts/Propagator/NavigatorStatistics.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Logger.hpp" @@ -176,9 +176,12 @@ class Navigator { bool targetReached = false; /// Navigation state : a break has been detected bool navigationBreak = false; - // The navigation stage (@todo: integrate break, target) + /// The navigation stage (@todo: integrate break, target) Stage navigationStage = Stage::undefined; + /// Navigation statistics + NavigatorStatistics statistics; + void reset() { navSurfaces.clear(); navSurfaceIndex = navSurfaces.size(); @@ -427,6 +430,7 @@ class Navigator { << "No targets found, we got lost! Attempt renavigation."); state.navigation.reset(); + ++state.navigation.statistics.nRenavigations; // We might have punched through a boundary and entered another volume // so we have to reinitialize @@ -576,6 +580,7 @@ class Navigator { state.navigation.navBoundaries.clear(); state.navigation.navBoundaryIndex = state.navigation.navBoundaries.size(); + ++state.navigation.statistics.nVolumeSwitches; } } else { // Set the navigation stage back to boundary target @@ -772,8 +777,6 @@ class Navigator { /// @return boolean return triggers exit to stepper template bool targetLayers(propagator_state_t& state, const stepper_t& stepper) const { - using namespace UnitLiterals; - if (state.navigation.navigationBreak) { return false; } diff --git a/Core/include/Acts/Propagator/NavigatorStatistics.hpp b/Core/include/Acts/Propagator/NavigatorStatistics.hpp new file mode 100644 index 00000000000..fd73d36c568 --- /dev/null +++ b/Core/include/Acts/Propagator/NavigatorStatistics.hpp @@ -0,0 +1,26 @@ +// 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 + +namespace Acts { + +/// @struct NavigatorStatistics +/// +/// @brief A struct to hold statistics of the navigator +struct NavigatorStatistics { + /// Number of renavigation attempts + std::size_t nRenavigations = 0; + + /// Number of volume switches + std::size_t nVolumeSwitches = 0; +}; + +} // namespace Acts diff --git a/Core/include/Acts/Propagator/Propagator.ipp b/Core/include/Acts/Propagator/Propagator.ipp index a7c12309bb7..8a7c560a725 100644 --- a/Core/include/Acts/Propagator/Propagator.ipp +++ b/Core/include/Acts/Propagator/Propagator.ipp @@ -341,6 +341,9 @@ void Acts::Propagator::moveStateToResult(propagator_state_t& state, result.steps = state.steps; result.pathLength = state.pathLength; + + result.statistics.stepping = state.stepping.statistics; + result.statistics.navigation = state.navigation.statistics; } template diff --git a/Core/include/Acts/Propagator/PropagatorResult.hpp b/Core/include/Acts/Propagator/PropagatorResult.hpp index 232211b8495..a67543f7b4b 100644 --- a/Core/include/Acts/Propagator/PropagatorResult.hpp +++ b/Core/include/Acts/Propagator/PropagatorResult.hpp @@ -9,6 +9,7 @@ #pragma once #include "Acts/Definitions/TrackParametrization.hpp" +#include "Acts/Propagator/PropagatorStatistics.hpp" #include "Acts/Utilities/detail/Extendable.hpp" #include @@ -36,6 +37,9 @@ struct PropagatorResult : private detail::Extendable { /// Signed distance over which the parameters were propagated double pathLength = 0.; + + /// Propagator statistics + PropagatorStatistics statistics; }; } // namespace Acts diff --git a/Core/include/Acts/Propagator/PropagatorState.hpp b/Core/include/Acts/Propagator/PropagatorState.hpp index 29e1baeeb30..03346cfd57d 100644 --- a/Core/include/Acts/Propagator/PropagatorState.hpp +++ b/Core/include/Acts/Propagator/PropagatorState.hpp @@ -9,6 +9,7 @@ #pragma once #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Propagator/PropagatorStatistics.hpp" #include "Acts/Utilities/detail/Extendable.hpp" #include @@ -72,6 +73,9 @@ struct PropagatorState : private detail::Extendable { /// Signed distance over which the parameters were propagated double pathLength = 0.; + + /// Statistics of the propagation + PropagatorStatistics statistics; }; } // namespace Acts diff --git a/Core/include/Acts/Propagator/PropagatorStatistics.hpp b/Core/include/Acts/Propagator/PropagatorStatistics.hpp new file mode 100644 index 00000000000..843be215bd9 --- /dev/null +++ b/Core/include/Acts/Propagator/PropagatorStatistics.hpp @@ -0,0 +1,26 @@ +// 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 +#include + +namespace Acts { + +/// @struct PropagatorStatistics +/// +/// @brief A struct to hold statistics of the propagator +struct PropagatorStatistics { + /// Statistics of the stepper + StepperStatistics stepping; + /// Statistics of the navigator + NavigatorStatistics navigation; +}; + +} // namespace Acts diff --git a/Core/include/Acts/Propagator/StepperStatistics.hpp b/Core/include/Acts/Propagator/StepperStatistics.hpp new file mode 100644 index 00000000000..64abf5bde00 --- /dev/null +++ b/Core/include/Acts/Propagator/StepperStatistics.hpp @@ -0,0 +1,34 @@ +// 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 + +namespace Acts { + +/// @struct StepperStatistics +/// +/// @brief A struct to hold statistics of the stepper +struct StepperStatistics { + /// Number of attempted steps + std::size_t nAttemptedSteps = 0; + /// Number of rejected steps + std::size_t nRejectedSteps = 0; + /// Number of successful steps + std::size_t nSuccessfulSteps = 0; + /// Number of steps that were reversed + std::size_t nReverseSteps = 0; + + /// Signed sum of the step lengths + double pathLength = 0; + /// Unsigned sum of the step lengths + double absolutePathLength = 0; +}; + +} // namespace Acts diff --git a/Core/include/Acts/Propagator/StraightLineStepper.hpp b/Core/include/Acts/Propagator/StraightLineStepper.hpp index 8ba0d72fe81..18904797fdd 100644 --- a/Core/include/Acts/Propagator/StraightLineStepper.hpp +++ b/Core/include/Acts/Propagator/StraightLineStepper.hpp @@ -23,6 +23,7 @@ #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/PropagatorTraits.hpp" #include "Acts/Propagator/StepperOptions.hpp" +#include "Acts/Propagator/StepperStatistics.hpp" #include "Acts/Propagator/detail/SteppingHelper.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -142,6 +143,9 @@ class StraightLineStepper { // Cache the geometry context of this propagation std::reference_wrapper geoContext; + + /// Statistics of the stepper + StepperStatistics statistics; }; StraightLineStepper() = default; @@ -430,6 +434,7 @@ class StraightLineStepper { Vector3 dir = direction(state.stepping); state.stepping.pars.template segment<3>(eFreePos0) += h * dir; state.stepping.pars[eFreeTime] += h * dtds; + // Propagate the jacobian if (state.stepping.covTransport) { // The step transport matrix in global coordinates @@ -450,7 +455,14 @@ class StraightLineStepper { ++state.stepping.nSteps; ++state.stepping.nStepTrials; - // return h + ++state.stepping.statistics.nAttemptedSteps; + ++state.stepping.statistics.nSuccessfulSteps; + if (state.options.direction != Direction::fromScalarZeroAsPositive(h)) { + ++state.stepping.statistics.nReverseSteps; + } + state.stepping.statistics.pathLength += h; + state.stepping.statistics.absolutePathLength += std::abs(h); + return h; } }; diff --git a/Core/include/Acts/Propagator/SympyStepper.hpp b/Core/include/Acts/Propagator/SympyStepper.hpp index 1e771a53ba7..3b1a2125a41 100644 --- a/Core/include/Acts/Propagator/SympyStepper.hpp +++ b/Core/include/Acts/Propagator/SympyStepper.hpp @@ -22,6 +22,7 @@ #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/PropagatorTraits.hpp" #include "Acts/Propagator/StepperOptions.hpp" +#include "Acts/Propagator/StepperStatistics.hpp" #include "Acts/Propagator/detail/SteppingHelper.hpp" namespace Acts { @@ -132,15 +133,8 @@ class SympyStepper { /// The geometry context std::reference_wrapper geoContext; - /// @brief Storage of magnetic field and the sub steps during a RKN4 step - struct { - /// Magnetic field evaulations - Vector3 B_first, B_middle, B_last; - /// k_i of the RKN4 algorithm - Vector3 k1, k2, k3, k4; - /// k_i elements of the momenta - std::array kQoP{}; - } stepData; + /// Statistics of the stepper + StepperStatistics statistics; }; /// Constructor requires knowledge of the detector's magnetic field diff --git a/Core/include/Acts/Propagator/TryAllNavigator.hpp b/Core/include/Acts/Propagator/TryAllNavigator.hpp index 83d7cbc64a4..09f6fb25e25 100644 --- a/Core/include/Acts/Propagator/TryAllNavigator.hpp +++ b/Core/include/Acts/Propagator/TryAllNavigator.hpp @@ -14,6 +14,7 @@ #include "Acts/Geometry/TrackingVolume.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/NavigatorOptions.hpp" +#include "Acts/Propagator/NavigatorStatistics.hpp" #include "Acts/Propagator/detail/NavigationHelpers.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -86,6 +87,9 @@ class TryAllNavigatorBase { bool targetReached = false; /// If a break has been detected bool navigationBreak = false; + + /// Navigation statistics + NavigatorStatistics statistics; }; /// Constructor with configuration object diff --git a/Core/include/Acts/Propagator/VoidNavigator.hpp b/Core/include/Acts/Propagator/VoidNavigator.hpp index d6732998d4b..6b461f79210 100644 --- a/Core/include/Acts/Propagator/VoidNavigator.hpp +++ b/Core/include/Acts/Propagator/VoidNavigator.hpp @@ -9,6 +9,7 @@ #pragma once #include "Acts/Propagator/NavigatorOptions.hpp" +#include "Acts/Propagator/NavigatorStatistics.hpp" namespace Acts { class Surface; @@ -30,6 +31,9 @@ struct VoidNavigator { /// @brief Nested State struct, minimal requirement struct State { Options options; + + /// Navigation statistics + NavigatorStatistics statistics; }; State makeState(const Options& options) const { diff --git a/Core/src/Propagator/SympyStepper.cpp b/Core/src/Propagator/SympyStepper.cpp index a33e1f567bb..d55c073a851 100644 --- a/Core/src/Propagator/SympyStepper.cpp +++ b/Core/src/Propagator/SympyStepper.cpp @@ -144,7 +144,8 @@ Result SympyStepper::stepImpl( double errorEstimate = 0.; while (true) { - nStepTrials++; + ++nStepTrials; + ++state.statistics.nAttemptedSteps; // For details about the factor 4 see ATL-SOFT-PUB-2009-001 Result res = @@ -164,6 +165,8 @@ Result SympyStepper::stepImpl( break; } + ++state.statistics.nRejectedSteps; + const double stepSizeScaling = calcStepSizeScaling(errorEstimate); h *= stepSizeScaling; @@ -186,6 +189,13 @@ Result SympyStepper::stepImpl( ++state.nSteps; state.nStepTrials += nStepTrials; + ++state.statistics.nSuccessfulSteps; + if (stepDirection != Direction::fromScalarZeroAsPositive(initialH)) { + ++state.statistics.nReverseSteps; + } + state.statistics.pathLength += h; + state.statistics.absolutePathLength += std::abs(h); + const double stepSizeScaling = calcStepSizeScaling(errorEstimate); const double nextAccuracy = std::abs(h * stepSizeScaling); const double previousAccuracy = std::abs(state.stepSize.accuracy()); diff --git a/Examples/Algorithms/Propagation/include/ActsExamples/Propagation/PropagatorInterface.hpp b/Examples/Algorithms/Propagation/include/ActsExamples/Propagation/PropagatorInterface.hpp index 2aa3b2292ac..7f113d47b56 100644 --- a/Examples/Algorithms/Propagation/include/ActsExamples/Propagation/PropagatorInterface.hpp +++ b/Examples/Algorithms/Propagation/include/ActsExamples/Propagation/PropagatorInterface.hpp @@ -117,6 +117,8 @@ class ConcretePropagator : public PropagatorInterface { resultValue.template get(); summary.steps = std::move(steppingResults.steps); + summary.statistics = resultValue.statistics; + // Also set the material recording result - if configured if (cfg.recordMaterialInteractions) { auto materialResult = diff --git a/Examples/Framework/include/ActsExamples/EventData/PropagationSummary.hpp b/Examples/Framework/include/ActsExamples/EventData/PropagationSummary.hpp index aa9a736675f..1d1ef44f499 100644 --- a/Examples/Framework/include/ActsExamples/EventData/PropagationSummary.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/PropagationSummary.hpp @@ -10,6 +10,7 @@ #include "Acts/EventData/TrackParameters.hpp" #include "Acts/Propagator/MaterialInteractor.hpp" +#include "Acts/Propagator/PropagatorStatistics.hpp" #include "Acts/Propagator/detail/SteppingLogger.hpp" #include @@ -34,6 +35,9 @@ struct PropagationSummary { /// Steps std::vector steps; + + /// Propagation statistics + Acts::PropagatorStatistics statistics; }; using PropagationSummaries = std::vector; diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp index c1f6afe9059..f9eea212b12 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp @@ -8,22 +8,18 @@ #pragma once -#include "Acts/Propagator/detail/SteppingLogger.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Framework/WriterT.hpp" #include "ActsExamples/Propagation/PropagationAlgorithm.hpp" -#include #include #include -#include class TFile; class TTree; namespace ActsExamples { -struct AlgorithmContext; /// @class RootPropagationSummaryWriter /// @@ -110,10 +106,17 @@ class RootPropagationSummaryWriter : public WriterT { int m_nMaterials = 0; int m_nPortals = 0; - // steper statistics - int m_nSteps = 0; - int m_nStepTrials = 0; - int m_pathLength = 0; + // stepper statistics + std::size_t m_nAttemptedSteps = 0; + std::size_t m_nRejectedSteps = 0; + std::size_t m_nSuccessfulSteps = 0; + std::size_t m_nReverseSteps = 0; + double m_pathLength = 0; + double m_absolutePathLength = 0; + + // navigator statistics + std::size_t m_nRenavigations = 0; + std::size_t m_nVolumeSwitches = 0; }; } // namespace ActsExamples diff --git a/Examples/Io/Root/src/RootPropagationStepsWriter.cpp b/Examples/Io/Root/src/RootPropagationStepsWriter.cpp index c7866e056eb..643956a6ed1 100644 --- a/Examples/Io/Root/src/RootPropagationStepsWriter.cpp +++ b/Examples/Io/Root/src/RootPropagationStepsWriter.cpp @@ -9,15 +9,12 @@ #include "ActsExamples/Io/Root/RootPropagationStepsWriter.hpp" #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Geometry/GeometryIdentifier.hpp" +#include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/VectorHelpers.hpp" #include "ActsExamples/EventData/PropagationSummary.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" -#include -#include -#include -#include -#include #include #include diff --git a/Examples/Io/Root/src/RootPropagationSummaryWriter.cpp b/Examples/Io/Root/src/RootPropagationSummaryWriter.cpp index 07a1cfa105f..7df19539c57 100644 --- a/Examples/Io/Root/src/RootPropagationSummaryWriter.cpp +++ b/Examples/Io/Root/src/RootPropagationSummaryWriter.cpp @@ -8,19 +8,11 @@ #include "ActsExamples/Io/Root/RootPropagationSummaryWriter.hpp" -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/VectorHelpers.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Propagation/PropagationAlgorithm.hpp" -#include -#include -#include -#include -#include #include -#include #include #include @@ -77,9 +69,15 @@ RootPropagationSummaryWriter::RootPropagationSummaryWriter( m_outputTree->Branch("nMaterials", &m_nMaterials); m_outputTree->Branch("nPortals", &m_nPortals); - m_outputTree->Branch("nSteps", &m_nSteps); - m_outputTree->Branch("nStepTrials", &m_nStepTrials); + m_outputTree->Branch("nAttemptedSteps", &m_nAttemptedSteps); + m_outputTree->Branch("nRejectedSteps", &m_nRejectedSteps); + m_outputTree->Branch("nSuccessfulSteps", &m_nSuccessfulSteps); + m_outputTree->Branch("nReverseSteps", &m_nReverseSteps); m_outputTree->Branch("pathLength", &m_pathLength); + m_outputTree->Branch("absolutePathLength", &m_absolutePathLength); + + m_outputTree->Branch("nRenavigations", &m_nRenavigations); + m_outputTree->Branch("nVolumeSwitches", &m_nVolumeSwitches); } RootPropagationSummaryWriter::~RootPropagationSummaryWriter() { @@ -133,11 +131,6 @@ ProcessCode RootPropagationSummaryWriter::writeT( m_pt = static_cast(startParameters.transverseMomentum()); m_p = static_cast(startParameters.absoluteMomentum()); - // Stepper statistics - m_nSteps = static_cast(summary.steps.size()); - m_nStepTrials = static_cast(summary.nStepTrials); - m_pathLength = static_cast(summary.pathLength); - m_nMaterials = 0; m_nSensitives = 0; m_nPortals = 0; @@ -160,6 +153,19 @@ ProcessCode RootPropagationSummaryWriter::writeT( } } }); + + // Stepper statistics + m_nAttemptedSteps = summary.statistics.stepping.nAttemptedSteps; + m_nRejectedSteps = summary.statistics.stepping.nRejectedSteps; + m_nSuccessfulSteps = summary.statistics.stepping.nSuccessfulSteps; + m_nReverseSteps = summary.statistics.stepping.nReverseSteps; + m_pathLength = summary.statistics.stepping.pathLength; + m_absolutePathLength = summary.statistics.stepping.absolutePathLength; + + // Navigator statistics + m_nRenavigations = summary.statistics.navigation.nRenavigations; + m_nVolumeSwitches = summary.statistics.navigation.nVolumeSwitches; + m_outputTree->Fill(); } diff --git a/Examples/Python/tests/root_file_hashes.txt b/Examples/Python/tests/root_file_hashes.txt index 4674ce1ce2e..666cb676c39 100644 --- a/Examples/Python/tests/root_file_hashes.txt +++ b/Examples/Python/tests/root_file_hashes.txt @@ -16,7 +16,7 @@ test_itk_seeding__estimatedparams.root: fc042037f12a434f2236df7d225b8ca24209b691 test_itk_seeding__performance_seeding.root: 78ebda54cd0f026ba4b7f316724ffd946de56a932735914baf1b7bba9505c29d test_itk_seeding__particles.root: 907ff693262c0db14b12c74b16586cb20d79caf5f03f93b178943e41ed35a1b6 test_itk_seeding__particles_simulation.root: ef0246069aa697019f28a8b270a68de95312cae5f2f2c74848566c3ce4f70363 -test_propagation__propagation_summary.root: 280c1a6fcfe71974ac39587b4afad27a31640bec42ca6537cc92e2d5e09d7ed6 +test_propagation__propagation_summary.root: 400043dfeed9eda16512ec5fd4a1389f94b98565083f06f439c7b7b59e46c544 test_material_recording__geant4_material_tracks.root: c022b9362249b29f57a07926b20644e3ab4ab8ebcf03f773fbf46c446fc1a0a1 test_truth_tracking_gsf[generic]__trackstates_gsf.root: 4df2c69d5dd7d5446a547651e4e962daf17924f5c8617165a93a3223c8ba18fd test_truth_tracking_gsf[generic]__tracksummary_gsf.root: 8c01d139cb865afa1959c62dbca76f3a1fb8b684c57ea4c2968baa6ffedadb6f diff --git a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp index fcdf13e9f8a..7ed2255afdc 100644 --- a/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/SympyStepperTests.cpp @@ -12,52 +12,30 @@ #include "Acts/Definitions/Direction.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" -#include "Acts/EventData/Charge.hpp" #include "Acts/EventData/GenericBoundTrackParameters.hpp" #include "Acts/EventData/GenericCurvilinearTrackParameters.hpp" #include "Acts/EventData/ParticleHypothesis.hpp" #include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/TransformationHelpers.hpp" -#include "Acts/Geometry/BoundarySurfaceT.hpp" -#include "Acts/Geometry/CuboidVolumeBuilder.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Geometry/TrackingGeometry.hpp" -#include "Acts/Geometry/TrackingGeometryBuilder.hpp" -#include "Acts/Geometry/TrackingVolume.hpp" #include "Acts/MagneticField/ConstantBField.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/MagneticField/MagneticFieldProvider.hpp" -#include "Acts/MagneticField/NullBField.hpp" -#include "Acts/Material/HomogeneousSurfaceMaterial.hpp" -#include "Acts/Material/HomogeneousVolumeMaterial.hpp" -#include "Acts/Material/MaterialSlab.hpp" -#include "Acts/Propagator/ActorList.hpp" #include "Acts/Propagator/ConstrainedStep.hpp" -#include "Acts/Propagator/MaterialInteractor.hpp" -#include "Acts/Propagator/Navigator.hpp" -#include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/SympyStepper.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/CurvilinearSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" -#include "Acts/Surfaces/RectangleBounds.hpp" -#include "Acts/Surfaces/Surface.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" -#include "Acts/Tests/CommonHelpers/PredefinedMaterials.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/Result.hpp" -#include "Acts/Utilities/UnitVectors.hpp" #include -#include #include -#include #include -#include #include #include #include -#include #include #include #include @@ -363,7 +341,6 @@ BOOST_AUTO_TEST_CASE(sympy_stepper_test) { state.fieldCache.template as()); copy.geoContext = state.geoContext; - copy.stepData = state.stepData; return copy; }; From be307864cd59c6cee5d1dff755ec2873a6f3662e Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:48:41 +0100 Subject: [PATCH 3/6] refactor!: explicit `isPresent()` in cylinder volume builder (#3796) Breaking: The operator `bool()` is removed from the struct `VolumeConfig`. --- .../Acts/Geometry/CylinderVolumeBuilder.hpp | 66 +++++++++---------- Core/src/Geometry/CylinderVolumeBuilder.cpp | 16 ++--- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp b/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp index 1e09b95e114..4356e26f313 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBuilder.hpp @@ -65,9 +65,9 @@ struct VolumeConfig { /// Adapt to the dimensions of another config in Z /// it will take the maximum/minimum values and just overwrite them /// - /// @param [in] lConfig is the config to which it should be adapded + /// @param [in] lConfig is the config to which it should be adapted void adaptZ(const VolumeConfig& lConfig) { - if (lConfig) { + if (lConfig.present) { zMin = std::min(zMin, lConfig.zMin); zMax = std::max(zMax, lConfig.zMax); } @@ -76,9 +76,9 @@ struct VolumeConfig { /// Adapt to the dimensions of another config in R /// it will take the maximum/minimum values and just overwrite them /// - /// @param [in] lConfig is the config to which it should be adapded + /// @param [in] lConfig is the config to which it should be adapted void adaptR(const VolumeConfig& lConfig) { - if (lConfig) { + if (lConfig.present) { rMin = std::min(rMin, lConfig.rMin); rMax = std::max(rMax, lConfig.rMax); } @@ -87,7 +87,7 @@ struct VolumeConfig { /// Adapt to the dimensions of another config /// it will take the maximum/minimum values and just overwrite them /// - /// @param [in] lConfig is the config to which it should be adapded + /// @param [in] lConfig is the config to which it should be adapted void adapt(const VolumeConfig& lConfig) { adaptZ(lConfig); adaptR(lConfig); @@ -184,9 +184,6 @@ struct VolumeConfig { sl << rMin << ", " << rMax << " / " << zMin << ", " << zMax; return sl.str(); } - - /// Conversion operator to bool - operator bool() const { return present; } }; /// @brief The WrappingSetup that is happening here @@ -222,39 +219,40 @@ struct WrappingConfig { containerVolumeConfig.present = true; std::string wConditionAddon = ""; // if we have more than one config present - if ((nVolumeConfig && cVolumeConfig) || (cVolumeConfig && pVolumeConfig) || - (nVolumeConfig && pVolumeConfig)) { + if ((nVolumeConfig.present && cVolumeConfig.present) || + (cVolumeConfig.present && pVolumeConfig.present) || + (nVolumeConfig.present && pVolumeConfig.present)) { wCondition = Wrapping; wConditionScreen = "grouped to "; } // adapt the new volume config to the existing configs - if (nVolumeConfig) { + if (nVolumeConfig.present) { containerVolumeConfig.adapt(nVolumeConfig); wConditionScreen += "[n]"; } - if (cVolumeConfig) { + if (cVolumeConfig.present) { containerVolumeConfig.adapt(cVolumeConfig); wConditionScreen += "[c]"; } - if (pVolumeConfig) { + if (pVolumeConfig.present) { containerVolumeConfig.adapt(pVolumeConfig); wConditionScreen += "[p]"; } // adapt the external one - if (externalVolumeConfig) { + if (externalVolumeConfig.present) { containerVolumeConfig.adapt(externalVolumeConfig); } // attach the volume configs - if (nVolumeConfig && cVolumeConfig) { + if (nVolumeConfig.present && cVolumeConfig.present) { nVolumeConfig.midPointAttachZ(cVolumeConfig); } - if (cVolumeConfig && pVolumeConfig) { + if (cVolumeConfig.present && pVolumeConfig.present) { cVolumeConfig.midPointAttachZ(pVolumeConfig); } // adapt r afterwards // - easy if no existing volume // - possible if no central volume - if (!existingVolumeConfig || !cVolumeConfig) { + if (!existingVolumeConfig.present || !cVolumeConfig.present) { nVolumeConfig.adaptR(containerVolumeConfig); cVolumeConfig.adaptR(containerVolumeConfig); pVolumeConfig.adaptR(containerVolumeConfig); @@ -265,17 +263,19 @@ struct WrappingConfig { void wrapInsertAttach() { // action is only needed if an existing volume // is present - if (existingVolumeConfig) { + if (existingVolumeConfig.present) { // 0 - simple attachment case - if (!cVolumeConfig) { + if (!cVolumeConfig.present) { // check if it can be easily attached - if (nVolumeConfig && nVolumeConfig.zMax < existingVolumeConfig.zMin) { + if (nVolumeConfig.present && + nVolumeConfig.zMax < existingVolumeConfig.zMin) { nVolumeConfig.attachZ(existingVolumeConfig); // will attach the new volume(s) wCondition = Attaching; wConditionScreen = "[n attached]"; } - if (pVolumeConfig && pVolumeConfig.zMin > existingVolumeConfig.zMax) { + if (pVolumeConfig.present && + pVolumeConfig.zMin > existingVolumeConfig.zMax) { pVolumeConfig.attachZ(existingVolumeConfig); // will attach the new volume(s) wCondition = Attaching; @@ -385,9 +385,9 @@ struct WrappingConfig { fGapVolumeConfig.zMax = existingVolumeConfig.zMin; } else { // adapt lower z boundary - if (nVolumeConfig) { + if (nVolumeConfig.present) { nVolumeConfig.zMin = existingVolumeConfig.zMin; - } else if (cVolumeConfig) { + } else if (cVolumeConfig.present) { cVolumeConfig.zMin = existingVolumeConfig.zMin; } } @@ -399,9 +399,9 @@ struct WrappingConfig { sGapVolumeConfig.zMax = referenceVolume.zMax; } else { // adapt higher z boundary - if (pVolumeConfig) { + if (pVolumeConfig.present) { pVolumeConfig.zMax = existingVolumeConfig.zMax; - } else if (cVolumeConfig) { + } else if (cVolumeConfig.present) { cVolumeConfig.zMax = existingVolumeConfig.zMax; } } @@ -414,31 +414,31 @@ struct WrappingConfig { std::string toString() const { // for screen output std::stringstream sl; - if (containerVolumeConfig) { + if (containerVolumeConfig.present) { sl << "New container built with configuration: " << containerVolumeConfig.toString() << '\n'; } // go through the new ones first - if (nVolumeConfig) { + if (nVolumeConfig.present) { sl << " - n: Negative Endcap, current configuration: " << nVolumeConfig.toString() << '\n'; } - if (cVolumeConfig) { + if (cVolumeConfig.present) { sl << " - c: Barrel, current configuration: " << cVolumeConfig.toString() << '\n'; } - if (pVolumeConfig) { + if (pVolumeConfig.present) { sl << " - p: Negative Endcap, current configuration: " << pVolumeConfig.toString() << '\n'; } - if (existingVolumeConfig) { + if (existingVolumeConfig.present) { sl << "Existing volume with configuration: " << existingVolumeConfig.toString() << '\n'; - if (fGapVolumeConfig) { + if (fGapVolumeConfig.present) { sl << " - g1: First gap volume, configuration : " << fGapVolumeConfig.toString() << '\n'; } - if (sGapVolumeConfig) { + if (sGapVolumeConfig.present) { sl << " - g2: Second gap volume, configuration : " << sGapVolumeConfig.toString() << '\n'; } @@ -452,7 +452,7 @@ struct WrappingConfig { /// @class CylinderVolumeBuilder /// -/// A volume builder to be used for building a concentrical cylindrical volumes +/// A volume builder to be used for building concentric cylinder volumes /// - a) configured volume /// - b) wrapping around a cylindrical/disk layer config /// diff --git a/Core/src/Geometry/CylinderVolumeBuilder.cpp b/Core/src/Geometry/CylinderVolumeBuilder.cpp index 47de379d9be..4f99a77eabd 100644 --- a/Core/src/Geometry/CylinderVolumeBuilder.cpp +++ b/Core/src/Geometry/CylinderVolumeBuilder.cpp @@ -171,7 +171,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( } std::string layerConfiguration = "|"; - if (wConfig.nVolumeConfig) { + if (wConfig.nVolumeConfig.present) { // negative layers are present ACTS_VERBOSE("Negative layers are present: rmin, rmax | zmin, zmax = " << wConfig.nVolumeConfig.toString()); @@ -185,7 +185,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( // add to the string output layerConfiguration += " Negative Endcap |"; } - if (wConfig.cVolumeConfig) { + if (wConfig.cVolumeConfig.present) { // central layers are present ACTS_VERBOSE("Central layers are present: rmin, rmax | zmin, zmax = " << wConfig.cVolumeConfig.toString()); @@ -199,7 +199,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( // add to the string output layerConfiguration += " Barrel |"; } - if (wConfig.pVolumeConfig) { + if (wConfig.pVolumeConfig.present) { // positive layers are present ACTS_VERBOSE("Positive layers are present: rmin, rmax | zmin, zmax = " << wConfig.pVolumeConfig.toString()); @@ -226,7 +226,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( << '\n' << wConfig.toString()); // now let's understand the wrapping if needed - if (wConfig.existingVolumeConfig) { + if (wConfig.existingVolumeConfig.present) { wConfig.wrapInsertAttach(); ACTS_VERBOSE("Configuration after wrapping, insertion, attachment " << '\n' @@ -242,7 +242,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( auto tvHelper = m_cfg.trackingVolumeHelper; // the barrel is always created auto barrel = - wConfig.cVolumeConfig + wConfig.cVolumeConfig.present ? tvHelper->createTrackingVolume( gctx, wConfig.cVolumeConfig.layers, wConfig.cVolumeConfig.volumes, m_cfg.volumeMaterial, @@ -258,7 +258,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( [&](VolumeConfig& centralConfig, VolumeConfig& endcapConfig, const std::string& endcapName) -> MutableTrackingVolumePtr { // No config - no volume - if (!endcapConfig) { + if (!endcapConfig.present) { return nullptr; } // Check for ring layout @@ -478,7 +478,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( if (existingVolumeCp) { // Check if gaps are needed std::vector existingContainer; - if (wConfig.fGapVolumeConfig) { + if (wConfig.fGapVolumeConfig.present) { // create the gap volume auto fGap = tvHelper->createGapTrackingVolume( gctx, wConfig.cVolumeConfig.volumes, m_cfg.volumeMaterial, @@ -489,7 +489,7 @@ Acts::CylinderVolumeBuilder::trackingVolume( existingContainer.push_back(fGap); } existingContainer.push_back(existingVolumeCp); - if (wConfig.sGapVolumeConfig) { + if (wConfig.sGapVolumeConfig.present) { // create the gap volume auto sGap = tvHelper->createGapTrackingVolume( gctx, wConfig.cVolumeConfig.volumes, m_cfg.volumeMaterial, From cafee589c1f1bcbec1e08354127f54dbfe21d321 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sat, 23 Nov 2024 13:17:49 +0100 Subject: [PATCH 4/6] chore: Cleanup some Geant4 Examples code (#3895) Accumulated changes I wanted to branch out from https://github.com/acts-project/acts/pull/3498 - Improve namespaces - Use namespaces in source files - Clean includes --- .../DDG4/DDG4DetectorConstruction.hpp | 10 +- .../Geant4/DetectorConstructionFactory.hpp | 4 +- .../ActsExamples/Geant4/EventStore.hpp | 6 +- .../Geant4/GdmlDetectorConstruction.hpp | 10 +- .../ActsExamples/Geant4/Geant4Manager.hpp | 12 +- .../ActsExamples/Geant4/Geant4Simulation.hpp | 18 +-- .../Geant4/MagneticFieldWrapper.hpp | 4 +- .../Geant4/MaterialPhysicsList.hpp | 5 +- .../Geant4/MaterialSteppingAction.hpp | 4 +- .../Geant4/ParticleKillAction.hpp | 4 +- .../Geant4/ParticleTrackingAction.hpp | 5 +- .../Geant4/PhysicsListFactory.hpp | 4 +- .../ActsExamples/Geant4/RegionCreator.hpp | 6 +- .../Geant4/SensitiveSteppingAction.hpp | 4 +- .../Geant4/SensitiveSurfaceMapper.hpp | 5 +- .../Geant4/SimParticleTranslation.hpp | 4 +- .../Geant4/SteppingActionList.hpp | 11 +- .../GeoModelDetectorConstruction.hpp | 12 +- .../TelescopeG4DetectorConstruction.hpp | 10 +- .../Geant4/src/DDG4DetectorConstruction.cpp | 26 +++-- .../Geant4/src/GdmlDetectorConstruction.cpp | 6 +- .../Algorithms/Geant4/src/Geant4Manager.cpp | 18 +-- .../Geant4/src/Geant4Simulation.cpp | 107 +++++++++--------- .../src/GeoModelDetectorConstruction.cpp | 6 +- .../Geant4/src/MagneticFieldWrapper.cpp | 13 ++- .../Geant4/src/MaterialPhysicsList.cpp | 12 +- .../Geant4/src/MaterialSteppingAction.cpp | 11 +- .../Geant4/src/ParticleKillAction.cpp | 8 +- .../Geant4/src/ParticleTrackingAction.cpp | 23 ++-- .../Geant4/src/PhysicsListFactory.cpp | 4 +- .../Algorithms/Geant4/src/RegionCreator.cpp | 6 +- .../Geant4/src/SensitiveSteppingAction.cpp | 12 +- .../Geant4/src/SensitiveSurfaceMapper.cpp | 18 +-- .../Geant4/src/SimParticleTranslation.cpp | 12 +- .../src/TelescopeG4DetectorConstruction.cpp | 23 ++-- .../Geant4HepMC/EventRecording.hpp | 12 +- .../Geant4HepMC/src/EventRecording.cpp | 38 +++---- Examples/Python/src/Geant4Component.cpp | 48 ++++---- Examples/Python/src/Geant4DD4hepComponent.cpp | 8 +- .../Python/src/Geant4GeoModelComponent.cpp | 8 +- .../Geant4/Geant4DetectorSurfaceFactory.hpp | 2 +- Plugins/Geant4/src/Geant4DetectorElement.cpp | 21 ++-- .../GeoModel/GeoModelDetectorElementITk.hpp | 8 -- .../src/GeoModelDetectorElementITk.cpp | 8 -- .../GeoModelDetectorElementITkTests.cpp | 8 -- 45 files changed, 304 insertions(+), 300 deletions(-) diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp index 529a3725980..54c590ac4d3 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/DDG4/DDG4DetectorConstruction.hpp @@ -31,7 +31,7 @@ class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { public: DDG4DetectorConstruction( std::shared_ptr detector, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); ~DDG4DetectorConstruction() final; /// Convert the stored DD4hep detector to a Geant4 description. @@ -47,7 +47,7 @@ class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { /// The Acts DD4hep detector instance std::shared_ptr m_detector; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// The world volume G4VPhysicalVolume* m_world = nullptr; @@ -56,11 +56,11 @@ class DDG4DetectorConstruction final : public G4VUserDetectorConstruction { }; class DDG4DetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: DDG4DetectorConstructionFactory( std::shared_ptr detector, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); ~DDG4DetectorConstructionFactory() final; std::unique_ptr factorize() const override; @@ -69,7 +69,7 @@ class DDG4DetectorConstructionFactory final /// The Acts DD4hep detector instance std::shared_ptr m_detector; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp index a0f5b3e41cd..16cb2c3eae6 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/DetectorConstructionFactory.hpp @@ -12,7 +12,7 @@ #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// Silly Geant4 will destroy the detector construction after the run manager is /// destructed. This class works around it by factorizing a factory. @@ -23,4 +23,4 @@ class DetectorConstructionFactory { virtual std::unique_ptr factorize() const = 0; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp index a46512ce299..7ca1775b81a 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/EventStore.hpp @@ -21,8 +21,10 @@ #include "G4Types.hh" namespace ActsExamples { - class WhiteBoard; +} + +namespace ActsExamples::Geant4 { /// Common event store for all Geant4 related sub algorithms struct EventStore { @@ -80,4 +82,4 @@ struct EventStore { std::unordered_map subparticleMap; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp index 24924bd7867..69156e94e06 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/GdmlDetectorConstruction.hpp @@ -26,7 +26,7 @@ class GdmlDetectorConstruction final : public G4VUserDetectorConstruction { /// @param regionCreators are the region creators GdmlDetectorConstruction( std::string path, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); /// Read the file and parse it to construct the Geant4 description /// @@ -38,17 +38,17 @@ class GdmlDetectorConstruction final : public G4VUserDetectorConstruction { /// Path to the Gdml file std::string m_path; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// Cached world volume G4VPhysicalVolume* m_world = nullptr; }; class GdmlDetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: GdmlDetectorConstructionFactory( std::string path, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); std::unique_ptr factorize() const override; @@ -56,7 +56,7 @@ class GdmlDetectorConstructionFactory final /// Path to the Gdml file std::string m_path; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp index c3db1c3f2fe..bdf9ab7bb82 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Manager.hpp @@ -18,8 +18,10 @@ class G4VUserPhysicsList; namespace ActsExamples { -class PhysicsListFactory; class Geant4Manager; +namespace Geant4 { +class PhysicsListFactory; +} /// Manages the life time of G4RunManager and G4VUserPhysicsList. /// @@ -75,12 +77,14 @@ class Geant4Manager { /// Registers a named physics list factory to the manager for easy /// instantiation when needed. void registerPhysicsListFactory( - std::string name, std::shared_ptr physicsListFactory); + std::string name, + std::shared_ptr physicsListFactory); std::unique_ptr createPhysicsList( const std::string &name) const; /// Get the current list of physics list factories. - const std::unordered_map> & + const std::unordered_map> & getPhysicsListFactories() const; private: @@ -89,7 +93,7 @@ class Geant4Manager { bool m_created = false; std::weak_ptr m_handle; - std::unordered_map> + std::unordered_map> m_physicsListFactories; }; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp index f735dcd3859..88f526fff4f 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/Geant4Simulation.hpp @@ -39,14 +39,15 @@ class MagneticFieldProvider; class Volume; } // namespace Acts -class G4VUserDetectorConstruction; - namespace ActsExamples { +struct Geant4Handle; +namespace Geant4 { class DetectorConstructionFactory; class SensitiveSurfaceMapper; struct EventStore; -struct Geant4Handle; +class RegionCreator; +} // namespace Geant4 /// Abstracts common Geant4 Acts algorithm behaviour. class Geant4SimulationBase : public IAlgorithm { @@ -61,7 +62,8 @@ class Geant4SimulationBase : public IAlgorithm { /// Detector construction object. /// G4RunManager will take care of deletion - std::shared_ptr detectorConstructionFactory; + std::shared_ptr + detectorConstructionFactory; /// Optional Geant4 instance overwrite. std::shared_ptr geant4Handle; @@ -91,11 +93,11 @@ class Geant4SimulationBase : public IAlgorithm { G4RunManager& runManager() const; - EventStore& eventStore() const; + Geant4::EventStore& eventStore() const; std::unique_ptr m_logger; - std::shared_ptr m_eventStore; + std::shared_ptr m_eventStore; int m_geant4Level{}; @@ -122,8 +124,8 @@ class Geant4Simulation final : public Geant4SimulationBase { std::string outputParticles = "particles_simulated"; /// The ACTS sensitive surfaces in a mapper, used for hit creation - std::shared_ptr sensitiveSurfaceMapper = - nullptr; + std::shared_ptr + sensitiveSurfaceMapper = nullptr; /// The ACTS Magnetic field provider std::shared_ptr magneticField = nullptr; diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp index a73663fb503..7581d5b6cf5 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MagneticFieldWrapper.hpp @@ -18,7 +18,7 @@ namespace Acts { class MagneticFieldProvider; } -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// A magnetic field wrapper for the Acts magnetic field /// to be used with Geant4. @@ -58,4 +58,4 @@ class MagneticFieldWrapper : public G4MagneticField { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp index 9cfb45d0453..924c1b54e59 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialPhysicsList.hpp @@ -12,11 +12,10 @@ #include #include -#include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// @class MaterialPhysicsList /// @@ -57,4 +56,4 @@ class MaterialPhysicsList final : public G4VUserPhysicsList { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp index 8b21c41a7ce..23ccb88764e 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/MaterialSteppingAction.hpp @@ -19,7 +19,7 @@ class G4Step; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// @class MaterialSteppingAction /// @@ -66,4 +66,4 @@ class MaterialSteppingAction final : public G4UserSteppingAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp index 4eb45d4f6ec..fe15a2d185c 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleKillAction.hpp @@ -22,7 +22,7 @@ namespace Acts { class Volume; } // namespace Acts -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// A G4SteppingAction that is called for every step in the simulation process. /// @@ -67,4 +67,4 @@ class ParticleKillAction : public G4UserSteppingAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp index acf07ec75dc..4ff1d413f34 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/ParticleTrackingAction.hpp @@ -9,7 +9,6 @@ #pragma once #include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Geant4/EventStore.hpp" @@ -22,7 +21,7 @@ class G4Track; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// The G4UserTrackingAction that is called for every track in /// the simulation process. @@ -82,4 +81,4 @@ class ParticleTrackingAction : public G4UserTrackingAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp index 6bbc39b4f04..e248beaffd4 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/PhysicsListFactory.hpp @@ -13,7 +13,7 @@ class G4VUserPhysicsList; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// A factory around G4VUserPhysicsList which allows on demand instantiation. class PhysicsListFactory { @@ -36,4 +36,4 @@ class PhysicsListFactoryFunction final : public PhysicsListFactory { Function m_function; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp index b141948ec90..5327e4f37eb 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/RegionCreator.hpp @@ -13,7 +13,7 @@ #include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// Geant4 Region Creator /// @@ -49,7 +49,7 @@ class RegionCreator { Acts::Logging::Level level); /// Construct the region - void Construct(); + void construct(); /// Readonly access to the configuration const Config& config() const { return m_cfg; } @@ -68,4 +68,4 @@ class RegionCreator { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp index 664522349df..d415e77e940 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSteppingAction.hpp @@ -23,7 +23,7 @@ namespace Acts { class Surface; } -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// The G4SteppingAction that is called for every step in /// the simulation process. @@ -83,4 +83,4 @@ class SensitiveSteppingAction : public G4UserSteppingAction { m_surfaceMapping; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp index 60f86d0d4e3..7614635ff93 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SensitiveSurfaceMapper.hpp @@ -12,7 +12,6 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" -#include "Acts/Utilities/GridAccessHelpers.hpp" #include "Acts/Utilities/Logger.hpp" #include @@ -26,7 +25,7 @@ namespace Acts { class Surface; } -namespace ActsExamples { +namespace ActsExamples::Geant4 { struct SensitiveCandidatesBase { /// Get the sensitive surfaces for a given position @@ -148,4 +147,4 @@ class SensitiveSurfaceMapper { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp index 8a20f91ae39..5b43102d812 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SimParticleTranslation.hpp @@ -20,7 +20,7 @@ class G4Event; -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// @class SimParticleTranslation /// @@ -81,4 +81,4 @@ class SimParticleTranslation final : public G4VUserPrimaryGeneratorAction { std::unique_ptr m_logger; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp index b4a6d7e5d68..807417cf1f4 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/Geant4/SteppingActionList.hpp @@ -8,17 +8,12 @@ #pragma once -#include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/EventData/SimHit.hpp" -#include "ActsExamples/EventData/SimParticle.hpp" - #include -#include -#include +#include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { /// Geant4 only allows one user action of each type. This simple wrapper /// dispatches multiple actions to Geant4. @@ -42,4 +37,4 @@ class SteppingActionList : public G4UserSteppingAction { Config m_cfg; }; -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp index a919d2866b0..d3070bbc590 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp @@ -12,8 +12,6 @@ #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" #include "ActsExamples/Geant4/RegionCreator.hpp" -#include - #include class G4VPhysicalVolume; @@ -27,7 +25,7 @@ class GeoModelDetectorConstruction final : public G4VUserDetectorConstruction { /// @param regionCreators are the region creators GeoModelDetectorConstruction( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); /// Read the file and parse it to construct the Geant4 description /// @@ -39,17 +37,17 @@ class GeoModelDetectorConstruction final : public G4VUserDetectorConstruction { /// The GeoModel tree Acts::GeoModelTree m_geoModelTree; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// The world volume G4VPhysicalVolume* m_g4World = nullptr; }; class GeoModelDetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: GeoModelDetectorConstructionFactory( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); std::unique_ptr factorize() const override; @@ -57,7 +55,7 @@ class GeoModelDetectorConstructionFactory final /// The GeoModel tree Acts::GeoModelTree m_geoModelTree; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp b/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp index 66fc363fe53..0d0fc522217 100644 --- a/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp +++ b/Examples/Algorithms/Geant4/include/ActsExamples/TelescopeDetector/TelescopeG4DetectorConstruction.hpp @@ -24,7 +24,7 @@ class TelescopeG4DetectorConstruction final public: TelescopeG4DetectorConstruction( const TelescopeDetector::Config& cfg, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); G4VPhysicalVolume* Construct() final; @@ -32,17 +32,17 @@ class TelescopeG4DetectorConstruction final /// The configuration of the telescope detector TelescopeDetector::Config m_cfg; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; /// The world volume G4VPhysicalVolume* m_world{}; }; class TelescopeG4DetectorConstructionFactory final - : public DetectorConstructionFactory { + : public Geant4::DetectorConstructionFactory { public: TelescopeG4DetectorConstructionFactory( const TelescopeDetector::Config& cfg, - std::vector> regionCreators = {}); + std::vector> regionCreators = {}); std::unique_ptr factorize() const override; @@ -50,7 +50,7 @@ class TelescopeG4DetectorConstructionFactory final /// The configuration of the telescope detector TelescopeDetector::Config m_cfg; /// Region creators - std::vector> m_regionCreators; + std::vector> m_regionCreators; }; } // namespace ActsExamples::Telescope diff --git a/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp index ae6a4609180..2868fbb3a63 100644 --- a/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/DDG4DetectorConstruction.cpp @@ -22,22 +22,23 @@ class G4VPhysicalVolume; -ActsExamples::DDG4DetectorConstruction::DDG4DetectorConstruction( +namespace ActsExamples { + +DDG4DetectorConstruction::DDG4DetectorConstruction( std::shared_ptr detector, - std::vector> regionCreators) + std::vector> regionCreators) : G4VUserDetectorConstruction(), m_detector(std::move(detector)), m_regionCreators(std::move(regionCreators)) {} -ActsExamples::DDG4DetectorConstruction::~DDG4DetectorConstruction() = default; +DDG4DetectorConstruction::~DDG4DetectorConstruction() = default; -dd4hep::Detector& ActsExamples::DDG4DetectorConstruction::dd4hepDetector() - const { +dd4hep::Detector& DDG4DetectorConstruction::dd4hepDetector() const { return m_detector->geometryService->detector(); } // See DD4hep::Simulation::Geant4DetectorConstruction::Construct() -G4VPhysicalVolume* ActsExamples::DDG4DetectorConstruction::Construct() { +G4VPhysicalVolume* DDG4DetectorConstruction::Construct() { if (m_world == nullptr) { dd4hep::sim::Geant4Mapping& g4map = dd4hep::sim::Geant4Mapping::instance(); auto conv = dd4hep::sim::Geant4Converter(dd4hepDetector(), @@ -52,23 +53,24 @@ G4VPhysicalVolume* ActsExamples::DDG4DetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } } return m_world; } -ActsExamples::DDG4DetectorConstructionFactory::DDG4DetectorConstructionFactory( +DDG4DetectorConstructionFactory::DDG4DetectorConstructionFactory( std::shared_ptr detector, - std::vector> regionCreators) + std::vector> regionCreators) : m_detector(std::move(detector)), m_regionCreators(std::move(regionCreators)) {} -ActsExamples::DDG4DetectorConstructionFactory:: - ~DDG4DetectorConstructionFactory() = default; +DDG4DetectorConstructionFactory::~DDG4DetectorConstructionFactory() = default; std::unique_ptr -ActsExamples::DDG4DetectorConstructionFactory::factorize() const { +DDG4DetectorConstructionFactory::factorize() const { return std::make_unique(m_detector, m_regionCreators); } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp index 5a10933bb3f..242597ac175 100644 --- a/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/GdmlDetectorConstruction.cpp @@ -18,7 +18,7 @@ using namespace ActsExamples; GdmlDetectorConstruction::GdmlDetectorConstruction( std::string path, - std::vector> regionCreators) + std::vector> regionCreators) : G4VUserDetectorConstruction(), m_path(std::move(path)), m_regionCreators(std::move(regionCreators)) {} @@ -32,7 +32,7 @@ G4VPhysicalVolume* GdmlDetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } } return m_world; @@ -40,7 +40,7 @@ G4VPhysicalVolume* GdmlDetectorConstruction::Construct() { GdmlDetectorConstructionFactory::GdmlDetectorConstructionFactory( std::string path, - std::vector> regionCreators) + std::vector> regionCreators) : m_path(std::move(path)), m_regionCreators(std::move(regionCreators)) {} std::unique_ptr diff --git a/Examples/Algorithms/Geant4/src/Geant4Manager.cpp b/Examples/Algorithms/Geant4/src/Geant4Manager.cpp index fb981704561..13e7428ac60 100644 --- a/Examples/Algorithms/Geant4/src/Geant4Manager.cpp +++ b/Examples/Algorithms/Geant4/src/Geant4Manager.cpp @@ -109,7 +109,8 @@ std::shared_ptr Geant4Manager::createHandle( } void Geant4Manager::registerPhysicsListFactory( - std::string name, std::shared_ptr physicsListFactory) { + std::string name, + std::shared_ptr physicsListFactory) { if (m_physicsListFactories.contains(name)) { throw std::invalid_argument("name already mapped"); } @@ -126,22 +127,23 @@ std::unique_ptr Geant4Manager::createPhysicsList( return it->second->factorize(); } -const std::unordered_map>& +const std::unordered_map>& Geant4Manager::getPhysicsListFactories() const { return m_physicsListFactories; } Geant4Manager::Geant4Manager() { registerPhysicsListFactory( - "FTFP_BERT", std::make_shared( + "FTFP_BERT", std::make_shared( []() { return std::make_unique(); })); registerPhysicsListFactory( - "FTFP_BERT_ATL", std::make_shared( + "FTFP_BERT_ATL", std::make_shared( []() { return std::make_unique(); })); - registerPhysicsListFactory("MaterialPhysicsList", - std::make_shared([]() { - return std::make_unique(); - })); + registerPhysicsListFactory( + "MaterialPhysicsList", + std::make_shared( + []() { return std::make_unique(); })); } Geant4Manager::~Geant4Manager() = default; diff --git a/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp b/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp index 795ddad78fa..bbc5c533e5c 100644 --- a/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp +++ b/Examples/Algorithms/Geant4/src/Geant4Simulation.cpp @@ -28,7 +28,6 @@ #include "ActsExamples/Geant4/SimParticleTranslation.hpp" #include "ActsExamples/Geant4/SteppingActionList.hpp" -#include #include #include @@ -47,22 +46,24 @@ #include #include -ActsExamples::Geant4SimulationBase::Geant4SimulationBase( - const Config& cfg, std::string name, Acts::Logging::Level level) +namespace ActsExamples { + +Geant4SimulationBase::Geant4SimulationBase(const Config& cfg, std::string name, + Acts::Logging::Level level) : IAlgorithm(std::move(name), level) { if (cfg.inputParticles.empty()) { throw std::invalid_argument("Missing input particle collection"); } - if (!cfg.detectorConstructionFactory) { + if (cfg.detectorConstructionFactory == nullptr) { throw std::invalid_argument("Missing detector construction factory"); } - if (!cfg.randomNumbers) { + if (cfg.randomNumbers == nullptr) { throw std::invalid_argument("Missing random numbers"); } m_logger = Acts::getDefaultLogger("Geant4", level); - m_eventStore = std::make_shared(); + m_eventStore = std::make_shared(); // tweak logging // If we are in VERBOSE mode, set the verbose level in Geant4 to 2. @@ -70,9 +71,9 @@ ActsExamples::Geant4SimulationBase::Geant4SimulationBase( m_geant4Level = logger().level() == Acts::Logging::VERBOSE ? 2 : 0; } -ActsExamples::Geant4SimulationBase::~Geant4SimulationBase() = default; +Geant4SimulationBase::~Geant4SimulationBase() = default; -void ActsExamples::Geant4SimulationBase::commonInitialization() { +void Geant4SimulationBase::commonInitialization() { // Set the detector construction { // Clear detector construction if it exists @@ -89,24 +90,22 @@ void ActsExamples::Geant4SimulationBase::commonInitialization() { m_geant4Instance->tweakLogging(m_geant4Level); } -G4RunManager& ActsExamples::Geant4SimulationBase::runManager() const { +G4RunManager& Geant4SimulationBase::runManager() const { return *m_geant4Instance->runManager.get(); } -ActsExamples::EventStore& ActsExamples::Geant4SimulationBase::eventStore() - const { +Geant4::EventStore& Geant4SimulationBase::eventStore() const { return *m_eventStore; } -ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::initialize() { +ProcessCode Geant4SimulationBase::initialize() { // Initialize the Geant4 run manager runManager().Initialize(); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } -ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::execute( - const ActsExamples::AlgorithmContext& ctx) const { +ProcessCode Geant4SimulationBase::execute(const AlgorithmContext& ctx) const { // Ensure exclusive access to the Geant4 run manager std::lock_guard guard(m_geant4Instance->mutex); @@ -114,7 +113,7 @@ ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::execute( G4Random::setTheSeed(config().randomNumbers->generateSeed(ctx)); // Get and reset event registry state - eventStore() = EventStore{}; + eventStore() = Geant4::EventStore{}; // Register the current event store to the registry // this will allow access from the User*Actions @@ -153,16 +152,15 @@ ActsExamples::ProcessCode ActsExamples::Geant4SimulationBase::execute( "Step merging: max hits per hit: " << eventStore().maxStepsForHit); } - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } -std::shared_ptr -ActsExamples::Geant4SimulationBase::geant4Handle() const { +std::shared_ptr Geant4SimulationBase::geant4Handle() const { return m_geant4Instance; } -ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, - Acts::Logging::Level level) +Geant4Simulation::Geant4Simulation(const Config& cfg, + Acts::Logging::Level level) : Geant4SimulationBase(cfg, "Geant4Simulation", level), m_cfg(cfg) { m_geant4Instance = m_cfg.geant4Handle @@ -180,10 +178,10 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, if (runManager().GetUserPrimaryGeneratorAction() != nullptr) { delete runManager().GetUserPrimaryGeneratorAction(); } - SimParticleTranslation::Config prCfg; + Geant4::SimParticleTranslation::Config prCfg; prCfg.eventStore = m_eventStore; // G4RunManager will take care of deletion - auto primaryGeneratorAction = new SimParticleTranslation( + auto primaryGeneratorAction = new Geant4::SimParticleTranslation( prCfg, m_logger->cloneWithSuffix("SimParticleTranslation")); // Set the primary generator action runManager().SetUserAction(primaryGeneratorAction); @@ -195,48 +193,49 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, if (runManager().GetUserTrackingAction() != nullptr) { delete runManager().GetUserTrackingAction(); } - ParticleTrackingAction::Config trackingCfg; + Geant4::ParticleTrackingAction::Config trackingCfg; trackingCfg.eventStore = m_eventStore; trackingCfg.keepParticlesWithoutHits = cfg.keepParticlesWithoutHits; // G4RunManager will take care of deletion - auto trackingAction = new ParticleTrackingAction( + auto trackingAction = new Geant4::ParticleTrackingAction( trackingCfg, m_logger->cloneWithSuffix("ParticleTracking")); runManager().SetUserAction(trackingAction); } // Stepping actions - SensitiveSteppingAction* sensitiveSteppingActionAccess = nullptr; + Geant4::SensitiveSteppingAction* sensitiveSteppingActionAccess = nullptr; { // Clear stepping action if it exists if (runManager().GetUserSteppingAction() != nullptr) { delete runManager().GetUserSteppingAction(); } - ParticleKillAction::Config particleKillCfg; + Geant4::ParticleKillAction::Config particleKillCfg; particleKillCfg.eventStore = m_eventStore; particleKillCfg.volume = cfg.killVolume; particleKillCfg.maxTime = cfg.killAfterTime; particleKillCfg.secondaries = cfg.killSecondaries; - SensitiveSteppingAction::Config stepCfg; + Geant4::SensitiveSteppingAction::Config stepCfg; stepCfg.eventStore = m_eventStore; stepCfg.charged = true; stepCfg.neutral = cfg.recordHitsOfNeutrals; stepCfg.primary = true; stepCfg.secondary = cfg.recordHitsOfSecondaries; - SteppingActionList::Config steppingCfg; - steppingCfg.actions.push_back(std::make_unique( + Geant4::SteppingActionList::Config steppingCfg; + steppingCfg.actions.push_back(std::make_unique( particleKillCfg, m_logger->cloneWithSuffix("Killer"))); - auto sensitiveSteppingAction = std::make_unique( - stepCfg, m_logger->cloneWithSuffix("SensitiveStepping")); + auto sensitiveSteppingAction = + std::make_unique( + stepCfg, m_logger->cloneWithSuffix("SensitiveStepping")); sensitiveSteppingActionAccess = sensitiveSteppingAction.get(); steppingCfg.actions.push_back(std::move(sensitiveSteppingAction)); // G4RunManager will take care of deletion - auto steppingAction = new SteppingActionList(steppingCfg); + auto steppingAction = new Geant4::SteppingActionList(steppingCfg); runManager().SetUserAction(steppingAction); } @@ -251,9 +250,10 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, if (cfg.magneticField) { ACTS_INFO("Setting ACTS configured field to Geant4."); - MagneticFieldWrapper::Config g4FieldCfg; + Geant4::MagneticFieldWrapper::Config g4FieldCfg; g4FieldCfg.magneticField = cfg.magneticField; - m_magneticField = std::make_unique(g4FieldCfg); + m_magneticField = + std::make_unique(g4FieldCfg); // Set the field or the G4Field manager m_fieldManager = std::make_unique(); @@ -266,7 +266,7 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, // ACTS sensitive surfaces are provided, so hit creation is turned on if (cfg.sensitiveSurfaceMapper != nullptr) { - SensitiveSurfaceMapper::State sState; + Geant4::SensitiveSurfaceMapper::State sState; ACTS_INFO( "Remapping selected volumes from Geant4 to Acts::Surface::GeometryID"); cfg.sensitiveSurfaceMapper->remapSensitiveNames( @@ -288,10 +288,9 @@ ActsExamples::Geant4Simulation::Geant4Simulation(const Config& cfg, m_outputParticles.initialize(cfg.outputParticles); } -ActsExamples::Geant4Simulation::~Geant4Simulation() = default; +Geant4Simulation::~Geant4Simulation() = default; -ActsExamples::ProcessCode ActsExamples::Geant4Simulation::execute( - const ActsExamples::AlgorithmContext& ctx) const { +ProcessCode Geant4Simulation::execute(const AlgorithmContext& ctx) const { auto ret = Geant4SimulationBase::execute(ctx); if (ret != ProcessCode::SUCCESS) { return ret; @@ -313,18 +312,18 @@ ActsExamples::ProcessCode ActsExamples::Geant4Simulation::execute( ctx, SimHitContainer(eventStore().hits.begin(), eventStore().hits.end())); #endif - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } -ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( - const Config& cfg, Acts::Logging::Level level) +Geant4MaterialRecording::Geant4MaterialRecording(const Config& cfg, + Acts::Logging::Level level) : Geant4SimulationBase(cfg, "Geant4Simulation", level), m_cfg(cfg) { auto physicsListName = "MaterialPhysicsList"; m_geant4Instance = m_cfg.geant4Handle ? m_cfg.geant4Handle : Geant4Manager::instance().createHandle( - std::make_unique( + std::make_unique( m_logger->cloneWithSuffix("MaterialPhysicsList")), physicsListName); if (m_geant4Instance->physicsListName != physicsListName) { @@ -340,14 +339,14 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( delete runManager().GetUserPrimaryGeneratorAction(); } - SimParticleTranslation::Config prCfg; + Geant4::SimParticleTranslation::Config prCfg; prCfg.eventStore = m_eventStore; prCfg.forcedPdgCode = 0; prCfg.forcedCharge = 0.; prCfg.forcedMass = 0.; // G4RunManager will take care of deletion - auto primaryGeneratorAction = new SimParticleTranslation( + auto primaryGeneratorAction = new Geant4::SimParticleTranslation( prCfg, m_logger->cloneWithSuffix("SimParticleTranslation")); // Set the primary generator action runManager().SetUserAction(primaryGeneratorAction); @@ -359,11 +358,11 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( if (runManager().GetUserTrackingAction() != nullptr) { delete runManager().GetUserTrackingAction(); } - ParticleTrackingAction::Config trackingCfg; + Geant4::ParticleTrackingAction::Config trackingCfg; trackingCfg.eventStore = m_eventStore; trackingCfg.keepParticlesWithoutHits = true; // G4RunManager will take care of deletion - auto trackingAction = new ParticleTrackingAction( + auto trackingAction = new Geant4::ParticleTrackingAction( trackingCfg, m_logger->cloneWithSuffix("ParticleTracking")); runManager().SetUserAction(trackingAction); } @@ -374,11 +373,11 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( if (runManager().GetUserSteppingAction() != nullptr) { delete runManager().GetUserSteppingAction(); } - MaterialSteppingAction::Config steppingCfg; + Geant4::MaterialSteppingAction::Config steppingCfg; steppingCfg.eventStore = m_eventStore; steppingCfg.excludeMaterials = m_cfg.excludeMaterials; // G4RunManager will take care of deletion - auto steppingAction = new MaterialSteppingAction( + auto steppingAction = new Geant4::MaterialSteppingAction( steppingCfg, m_logger->cloneWithSuffix("MaterialSteppingAction")); runManager().SetUserAction(steppingAction); } @@ -389,10 +388,10 @@ ActsExamples::Geant4MaterialRecording::Geant4MaterialRecording( m_outputMaterialTracks.initialize(cfg.outputMaterialTracks); } -ActsExamples::Geant4MaterialRecording::~Geant4MaterialRecording() = default; +Geant4MaterialRecording::~Geant4MaterialRecording() = default; -ActsExamples::ProcessCode ActsExamples::Geant4MaterialRecording::execute( - const ActsExamples::AlgorithmContext& ctx) const { +ProcessCode Geant4MaterialRecording::execute( + const AlgorithmContext& ctx) const { const auto ret = Geant4SimulationBase::execute(ctx); if (ret != ProcessCode::SUCCESS) { return ret; @@ -402,5 +401,7 @@ ActsExamples::ProcessCode ActsExamples::Geant4MaterialRecording::execute( m_outputMaterialTracks( ctx, decltype(eventStore().materialTracks)(eventStore().materialTracks)); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp index c3ad0eea6de..8d33622714b 100644 --- a/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/GeoModelDetectorConstruction.cpp @@ -21,7 +21,7 @@ using namespace ActsExamples; GeoModelDetectorConstruction::GeoModelDetectorConstruction( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators) + std::vector> regionCreators) : G4VUserDetectorConstruction(), m_geoModelTree(geoModelTree), m_regionCreators(std::move(regionCreators)) { @@ -42,7 +42,7 @@ G4VPhysicalVolume* GeoModelDetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } } return m_g4World; @@ -50,7 +50,7 @@ G4VPhysicalVolume* GeoModelDetectorConstruction::Construct() { GeoModelDetectorConstructionFactory::GeoModelDetectorConstructionFactory( const Acts::GeoModelTree& geoModelTree, - std::vector> regionCreators) + std::vector> regionCreators) : m_geoModelTree(geoModelTree), m_regionCreators(std::move(regionCreators)) {} diff --git a/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp b/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp index 33f15fa6586..757cac35fea 100644 --- a/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp +++ b/Examples/Algorithms/Geant4/src/MagneticFieldWrapper.cpp @@ -12,21 +12,20 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" #include "Acts/MagneticField/MagneticFieldProvider.hpp" -#include "Acts/Utilities/Result.hpp" -#include -#include #include #include #include -ActsExamples::MagneticFieldWrapper::MagneticFieldWrapper( +namespace ActsExamples::Geant4 { + +MagneticFieldWrapper::MagneticFieldWrapper( const Config& cfg, std::unique_ptr logger) : G4MagneticField(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::MagneticFieldWrapper::GetFieldValue(const G4double Point[4], - G4double* Bfield) const { +void MagneticFieldWrapper::GetFieldValue(const G4double Point[4], + G4double* Bfield) const { constexpr double convertLength = CLHEP::mm / Acts::UnitConstants::mm; constexpr double convertField = CLHEP::tesla / Acts::UnitConstants::T; @@ -47,3 +46,5 @@ void ActsExamples::MagneticFieldWrapper::GetFieldValue(const G4double Point[4], Bfield[1] = convertField * field[1]; Bfield[2] = convertField * field[2]; } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp b/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp index d115e9e1794..bc0d228e87d 100644 --- a/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp +++ b/Examples/Algorithms/Geant4/src/MaterialPhysicsList.cpp @@ -15,27 +15,31 @@ #include #include -ActsExamples::MaterialPhysicsList::MaterialPhysicsList( +namespace ActsExamples::Geant4 { + +MaterialPhysicsList::MaterialPhysicsList( std::unique_ptr logger) : G4VUserPhysicsList(), m_logger(std::move(logger)) { defaultCutValue = 1.0 * CLHEP::cm; } -void ActsExamples::MaterialPhysicsList::ConstructParticle() { +void MaterialPhysicsList::ConstructParticle() { ACTS_DEBUG("Construct Geantinos and Charged Geantinos."); G4Geantino::GeantinoDefinition(); G4ChargedGeantino::ChargedGeantinoDefinition(); } -void ActsExamples::MaterialPhysicsList::ConstructProcess() { +void MaterialPhysicsList::ConstructProcess() { ACTS_DEBUG("Adding Transport as single supperted Process."); AddTransportation(); } -void ActsExamples::MaterialPhysicsList::SetCuts() { +void MaterialPhysicsList::SetCuts() { SetCutsWithDefault(); if (verboseLevel > 0) { DumpCutValuesTable(); } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp b/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp index c4f0e6528bd..6773079dcd7 100644 --- a/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp +++ b/Examples/Algorithms/Geant4/src/MaterialSteppingAction.cpp @@ -24,14 +24,15 @@ #include #include -ActsExamples::MaterialSteppingAction::MaterialSteppingAction( +namespace ActsExamples::Geant4 { + +MaterialSteppingAction::MaterialSteppingAction( const Config& cfg, std::unique_ptr logger) : G4UserSteppingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -ActsExamples::MaterialSteppingAction::~MaterialSteppingAction() = default; +MaterialSteppingAction::~MaterialSteppingAction() = default; -void ActsExamples::MaterialSteppingAction::UserSteppingAction( - const G4Step* step) { +void MaterialSteppingAction::UserSteppingAction(const G4Step* step) { // Get the material & check if it is present G4Material* material = step->GetPreStepPoint()->GetMaterial(); if (material == nullptr) { @@ -111,3 +112,5 @@ void ActsExamples::MaterialSteppingAction::UserSteppingAction( mInteraction); } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp b/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp index 5090a74dafa..bbc55390c69 100644 --- a/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp +++ b/Examples/Algorithms/Geant4/src/ParticleKillAction.cpp @@ -23,11 +23,13 @@ #include #include -ActsExamples::ParticleKillAction::ParticleKillAction( +namespace ActsExamples::Geant4 { + +ParticleKillAction::ParticleKillAction( const Config& cfg, std::unique_ptr logger) : G4UserSteppingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::ParticleKillAction::UserSteppingAction(const G4Step* step) { +void ParticleKillAction::UserSteppingAction(const G4Step* step) { constexpr double convertLength = Acts::UnitConstants::mm / CLHEP::mm; constexpr double convertTime = Acts::UnitConstants::ns / CLHEP::ns; @@ -72,3 +74,5 @@ void ActsExamples::ParticleKillAction::UserSteppingAction(const G4Step* step) { } } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp index ba59debc893..886646a3655 100644 --- a/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp +++ b/Examples/Algorithms/Geant4/src/ParticleTrackingAction.cpp @@ -25,12 +25,13 @@ #include #include -ActsExamples::ParticleTrackingAction::ParticleTrackingAction( +namespace ActsExamples::Geant4 { + +ParticleTrackingAction::ParticleTrackingAction( const Config& cfg, std::unique_ptr logger) : G4UserTrackingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::ParticleTrackingAction::PreUserTrackingAction( - const G4Track* aTrack) { +void ParticleTrackingAction::PreUserTrackingAction(const G4Track* aTrack) { // If this is not the case, there are unhandled cases of particle stopping in // the SensitiveSteppingAction // TODO We could also merge the remaining hits to a hit here, but it would be @@ -66,8 +67,7 @@ void ActsExamples::ParticleTrackingAction::PreUserTrackingAction( } } -void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( - const G4Track* aTrack) { +void ParticleTrackingAction::PostUserTrackingAction(const G4Track* aTrack) { // The initial particle maybe was not registered because of a particle ID // collision if (!eventStore().trackIdMapping.contains(aTrack->GetTrackID())) { @@ -83,7 +83,7 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( if (!m_cfg.keepParticlesWithoutHits && !hasHits) { [[maybe_unused]] auto n = eventStore().particlesSimulated.erase( - ActsExamples::SimParticle(barcode, Acts::PdgParticle::eInvalid)); + SimParticle(barcode, Acts::PdgParticle::eInvalid)); assert(n == 1); return; } @@ -107,8 +107,8 @@ void ActsExamples::ParticleTrackingAction::PostUserTrackingAction( } } -ActsExamples::SimParticleState ActsExamples::ParticleTrackingAction::convert( - const G4Track& aTrack, SimBarcode particleId) const { +SimParticleState ParticleTrackingAction::convert(const G4Track& aTrack, + SimBarcode particleId) const { // Unit conversions G4->::ACTS constexpr double convertTime = Acts::UnitConstants::ns / CLHEP::ns; constexpr double convertLength = Acts::UnitConstants::mm / CLHEP::mm; @@ -147,9 +147,8 @@ ActsExamples::SimParticleState ActsExamples::ParticleTrackingAction::convert( return aParticle; } -std::optional -ActsExamples::ParticleTrackingAction::makeParticleId(G4int trackId, - G4int parentId) const { +std::optional ParticleTrackingAction::makeParticleId( + G4int trackId, G4int parentId) const { // We already have this particle registered (it is one of the input particles // or we are making a final particle state) if (eventStore().trackIdMapping.contains(trackId)) { @@ -174,3 +173,5 @@ ActsExamples::ParticleTrackingAction::makeParticleId(G4int trackId, return pid; } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp b/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp index 95866efa188..e1b88971b5b 100644 --- a/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp +++ b/Examples/Algorithms/Geant4/src/PhysicsListFactory.cpp @@ -10,7 +10,7 @@ #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { PhysicsListFactoryFunction::PhysicsListFactoryFunction(Function function) : m_function(std::move(function)) {} @@ -20,4 +20,4 @@ std::unique_ptr PhysicsListFactoryFunction::factorize() return m_function(); } -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/RegionCreator.cpp b/Examples/Algorithms/Geant4/src/RegionCreator.cpp index 4e3384a98b7..c38dcf83078 100644 --- a/Examples/Algorithms/Geant4/src/RegionCreator.cpp +++ b/Examples/Algorithms/Geant4/src/RegionCreator.cpp @@ -13,7 +13,7 @@ #include #include -namespace ActsExamples { +namespace ActsExamples::Geant4 { RegionCreator::RegionCreator(const Config& cfg, std::string name, Acts::Logging::Level level) @@ -21,7 +21,7 @@ RegionCreator::RegionCreator(const Config& cfg, std::string name, m_cfg(cfg), m_logger(Acts::getDefaultLogger(m_name, level)) {} -void RegionCreator::Construct() { +void RegionCreator::construct() { // create a new G4Region G4Region* region = new G4Region(m_name); @@ -68,4 +68,4 @@ void RegionCreator::Construct() { region->SetProductionCuts(cuts); } -} // namespace ActsExamples +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp b/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp index 17df42bdb21..098cce7b3aa 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSteppingAction.cpp @@ -13,7 +13,6 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/MultiIndex.hpp" -#include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/Geant4/EventStore.hpp" #include "ActsExamples/Geant4/SensitiveSurfaceMapper.hpp" #include "ActsFatras/EventData/Barcode.hpp" @@ -33,8 +32,6 @@ #include #include -class G4PrimaryParticle; - #if BOOST_VERSION >= 107800 #include @@ -95,12 +92,13 @@ ActsFatras::Hit hitFromStep(const G4StepPoint* preStepPoint, } } // namespace -ActsExamples::SensitiveSteppingAction::SensitiveSteppingAction( +namespace ActsExamples::Geant4 { + +SensitiveSteppingAction::SensitiveSteppingAction( const Config& cfg, std::unique_ptr logger) : G4UserSteppingAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::SensitiveSteppingAction::UserSteppingAction( - const G4Step* step) { +void SensitiveSteppingAction::UserSteppingAction(const G4Step* step) { // Unit conversions G4->::ACTS static constexpr double convertLength = Acts::UnitConstants::mm / CLHEP::mm; @@ -279,3 +277,5 @@ void ActsExamples::SensitiveSteppingAction::UserSteppingAction( assert(false && "should never reach this"); } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp index 2fd1a924d94..924a898c238 100644 --- a/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp +++ b/Examples/Algorithms/Geant4/src/SensitiveSurfaceMapper.cpp @@ -63,6 +63,7 @@ struct access, Index> { } // namespace boost::geometry::traits namespace { + void writeG4Polyhedron( Acts::IVisualization3D& visualizer, const G4Polyhedron& polyhedron, const Acts::Transform3& trafo = Acts::Transform3::Identity(), @@ -89,10 +90,12 @@ void writeG4Polyhedron( visualizer.face(faces, color); } } + } // namespace -std::vector -ActsExamples::SensitiveCandidates::queryPosition( +namespace ActsExamples::Geant4 { + +std::vector SensitiveCandidates::queryPosition( const Acts::GeometryContext& gctx, const Acts::Vector3& position) const { std::vector surfaces; @@ -119,8 +122,7 @@ ActsExamples::SensitiveCandidates::queryPosition( return surfaces; } -std::vector ActsExamples::SensitiveCandidates::queryAll() - const { +std::vector SensitiveCandidates::queryAll() const { std::vector surfaces; const bool restrictToSensitives = true; @@ -130,11 +132,11 @@ std::vector ActsExamples::SensitiveCandidates::queryAll() return surfaces; } -ActsExamples::SensitiveSurfaceMapper::SensitiveSurfaceMapper( +SensitiveSurfaceMapper::SensitiveSurfaceMapper( const Config& cfg, std::unique_ptr logger) : m_cfg(cfg), m_logger(std::move(logger)) {} -void ActsExamples::SensitiveSurfaceMapper::remapSensitiveNames( +void SensitiveSurfaceMapper::remapSensitiveNames( State& state, const Acts::GeometryContext& gctx, G4VPhysicalVolume* g4PhysicalVolume, const Acts::Transform3& motherTransform) const { @@ -291,7 +293,7 @@ void ActsExamples::SensitiveSurfaceMapper::remapSensitiveNames( state.g4VolumeToSurfaces.insert({g4PhysicalVolume, mappedSurface}); } -bool ActsExamples::SensitiveSurfaceMapper::checkMapping( +bool SensitiveSurfaceMapper::checkMapping( const State& state, const Acts::GeometryContext& gctx, bool writeMissingG4VolsAsObj, bool writeMissingSurfacesAsObj) const { auto allSurfaces = m_cfg.candidateSurfaces->queryAll(); @@ -343,3 +345,5 @@ bool ActsExamples::SensitiveSurfaceMapper::checkMapping( return missing.empty(); } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp b/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp index 8b8156ff3e4..e505edafa76 100644 --- a/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp +++ b/Examples/Algorithms/Geant4/src/SimParticleTranslation.cpp @@ -28,19 +28,17 @@ #include #include -namespace ActsExamples { -class WhiteBoard; -} // namespace ActsExamples +namespace ActsExamples::Geant4 { -ActsExamples::SimParticleTranslation::SimParticleTranslation( +SimParticleTranslation::SimParticleTranslation( const Config& cfg, std::unique_ptr logger) : G4VUserPrimaryGeneratorAction(), m_cfg(cfg), m_logger(std::move(logger)) {} -ActsExamples::SimParticleTranslation::~SimParticleTranslation() = default; +SimParticleTranslation::~SimParticleTranslation() = default; -void ActsExamples::SimParticleTranslation::GeneratePrimaries(G4Event* anEvent) { +void SimParticleTranslation::GeneratePrimaries(G4Event* anEvent) { anEvent->SetEventID(m_eventNr++); unsigned int eventID = anEvent->GetEventID(); @@ -158,3 +156,5 @@ void ActsExamples::SimParticleTranslation::GeneratePrimaries(G4Event* anEvent) { << lastVertex->transpose()); } } + +} // namespace ActsExamples::Geant4 diff --git a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp index 423acf7e2a5..9d309932fbe 100644 --- a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp @@ -26,18 +26,18 @@ #include "G4RunManager.hh" #include "G4SystemOfUnits.hh" -ActsExamples::Telescope::TelescopeG4DetectorConstruction:: - TelescopeG4DetectorConstruction( - const TelescopeDetector::Config& cfg, - std::vector> regionCreators) +namespace ActsExamples { + +Telescope::TelescopeG4DetectorConstruction::TelescopeG4DetectorConstruction( + const TelescopeDetector::Config& cfg, + std::vector> regionCreators) : m_cfg(cfg), m_regionCreators(std::move(regionCreators)) { throw_assert(cfg.surfaceType == static_cast(Telescope::TelescopeSurfaceType::Plane), "only plan is supported right now"); } -G4VPhysicalVolume* -ActsExamples::Telescope::TelescopeG4DetectorConstruction::Construct() { +G4VPhysicalVolume* Telescope::TelescopeG4DetectorConstruction::Construct() { if (m_world != nullptr) { return m_world; } @@ -162,21 +162,22 @@ ActsExamples::Telescope::TelescopeG4DetectorConstruction::Construct() { // Create regions for (const auto& regionCreator : m_regionCreators) { - regionCreator->Construct(); + regionCreator->construct(); } return m_world; } -ActsExamples::Telescope::TelescopeG4DetectorConstructionFactory:: +Telescope::TelescopeG4DetectorConstructionFactory:: TelescopeG4DetectorConstructionFactory( const TelescopeDetector::Config& cfg, - std::vector> regionCreators) + std::vector> regionCreators) : m_cfg(cfg), m_regionCreators(std::move(regionCreators)) {} std::unique_ptr -ActsExamples::Telescope::TelescopeG4DetectorConstructionFactory::factorize() - const { +Telescope::TelescopeG4DetectorConstructionFactory::factorize() const { return std::make_unique(m_cfg, m_regionCreators); } + +} // namespace ActsExamples diff --git a/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp b/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp index 256a82a4471..6f45940182c 100644 --- a/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp +++ b/Examples/Algorithms/Geant4HepMC/include/ActsExamples/Geant4HepMC/EventRecording.hpp @@ -8,8 +8,6 @@ #pragma once -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Propagator/MaterialInteractor.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/DataHandle.hpp" @@ -24,9 +22,12 @@ class G4RunManager; -namespace ActsExamples { - +namespace ActsExamples::Geant4 { class DetectorConstructionFactory; +class RegionCreator; +} // namespace ActsExamples::Geant4 + +namespace ActsExamples { class EventRecording final : public ActsExamples::IAlgorithm { public: @@ -37,7 +38,8 @@ class EventRecording final : public ActsExamples::IAlgorithm { /// The recorded events output std::string outputHepMcTracks = "geant-outcome-tracks"; - std::shared_ptr detectorConstructionFactory; + std::shared_ptr + detectorConstructionFactory; /// random number seed 1 int seed1 = 12345; diff --git a/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp b/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp index e4900f63c05..93c27b0c1c1 100644 --- a/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp +++ b/Examples/Algorithms/Geant4HepMC/src/EventRecording.cpp @@ -11,9 +11,7 @@ #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Framework/WhiteBoard.hpp" #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" -#include "ActsExamples/Geant4/GdmlDetectorConstruction.hpp" -#include #include #include @@ -26,14 +24,15 @@ #include "RunAction.hpp" #include "SteppingAction.hpp" -ActsExamples::EventRecording::~EventRecording() { +namespace ActsExamples { + +EventRecording::~EventRecording() { m_runManager = nullptr; } -ActsExamples::EventRecording::EventRecording( - const ActsExamples::EventRecording::Config& config, - Acts::Logging::Level level) - : ActsExamples::IAlgorithm("EventRecording", level), +EventRecording::EventRecording(const EventRecording::Config& config, + Acts::Logging::Level level) + : IAlgorithm("EventRecording", level), m_cfg(config), m_runManager(std::make_unique()) { if (m_cfg.inputParticles.empty()) { @@ -42,7 +41,7 @@ ActsExamples::EventRecording::EventRecording( if (m_cfg.outputHepMcTracks.empty()) { throw std::invalid_argument("Missing output event collection"); } - if (!m_cfg.detectorConstructionFactory) { + if (m_cfg.detectorConstructionFactory == nullptr) { throw std::invalid_argument("Missing detector construction object"); } @@ -55,19 +54,17 @@ ActsExamples::EventRecording::EventRecording( m_runManager->SetUserInitialization( m_cfg.detectorConstructionFactory->factorize().release()); m_runManager->SetUserInitialization(new FTFP_BERT); - m_runManager->SetUserAction(new ActsExamples::Geant4::HepMC3::RunAction()); + m_runManager->SetUserAction(new Geant4::HepMC3::RunAction()); m_runManager->SetUserAction( - new ActsExamples::Geant4::HepMC3::EventAction(m_cfg.processesCombine)); + new Geant4::HepMC3::EventAction(m_cfg.processesCombine)); m_runManager->SetUserAction( - new ActsExamples::Geant4::HepMC3::PrimaryGeneratorAction(m_cfg.seed1, - m_cfg.seed2)); + new Geant4::HepMC3::PrimaryGeneratorAction(m_cfg.seed1, m_cfg.seed2)); m_runManager->SetUserAction( - new ActsExamples::Geant4::HepMC3::SteppingAction(m_cfg.processesReject)); + new Geant4::HepMC3::SteppingAction(m_cfg.processesReject)); m_runManager->Initialize(); } -ActsExamples::ProcessCode ActsExamples::EventRecording::execute( - const ActsExamples::AlgorithmContext& context) const { +ProcessCode EventRecording::execute(const AlgorithmContext& context) const { // ensure exclusive access to the geant run manager std::lock_guard guard(m_runManagerLock); @@ -80,8 +77,8 @@ ActsExamples::ProcessCode ActsExamples::EventRecording::execute( for (const auto& part : initialParticles) { // Prepare the particle gun - ActsExamples::Geant4::HepMC3::PrimaryGeneratorAction::instance() - ->prepareParticleGun(part); + Geant4::HepMC3::PrimaryGeneratorAction::instance()->prepareParticleGun( + part); // Begin with the simulation m_runManager->BeamOn(1); @@ -92,8 +89,7 @@ ActsExamples::ProcessCode ActsExamples::EventRecording::execute( } // Set event start time - HepMC3::GenEvent event = - ActsExamples::Geant4::HepMC3::EventAction::instance()->event(); + HepMC3::GenEvent event = Geant4::HepMC3::EventAction::instance()->event(); HepMC3::FourVector shift(0., 0., 0., part.time() / Acts::UnitConstants::mm); event.shift_position_by(shift); @@ -174,5 +170,7 @@ ActsExamples::ProcessCode ActsExamples::EventRecording::execute( // Write the recorded material to the event store m_outputEvents(context, std::move(events)); - return ActsExamples::ProcessCode::SUCCESS; + return ProcessCode::SUCCESS; } + +} // namespace ActsExamples diff --git a/Examples/Python/src/Geant4Component.cpp b/Examples/Python/src/Geant4Component.cpp index 1a7edd58e7f..abba9cefe98 100644 --- a/Examples/Python/src/Geant4Component.cpp +++ b/Examples/Python/src/Geant4Component.cpp @@ -16,7 +16,6 @@ #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Surfaces/SurfaceVisitorConcept.hpp" #include "Acts/Utilities/Logger.hpp" -#include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Framework/IContextDecorator.hpp" #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" #include "ActsExamples/Geant4/GdmlDetectorConstruction.hpp" @@ -65,7 +64,8 @@ namespace Acts::Python { void addGeant4HepMC3(Context& ctx); } -struct ExperimentalSensitiveCandidates : public SensitiveCandidatesBase { +struct ExperimentalSensitiveCandidates + : public Geant4::SensitiveCandidatesBase { std::shared_ptr detector; /// Find the sensitive surfaces for a given position @@ -97,8 +97,8 @@ struct ExperimentalSensitiveCandidates : public SensitiveCandidatesBase { }; PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { - py::class_>( + py::class_>( mod, "DetectorConstructionFactory"); py::class_>( @@ -129,14 +129,14 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { } { - using Config = SensitiveSurfaceMapper::Config; - using State = SensitiveSurfaceMapper::State; + using Config = Geant4::SensitiveSurfaceMapper::Config; + using State = Geant4::SensitiveSurfaceMapper::State; auto sm = - py::class_>( + py::class_>( mod, "SensitiveSurfaceMapper") .def(py::init([](const Config& cfg, Acts::Logging::Level level) { - return std::make_shared( + return std::make_shared( cfg, getDefaultLogger("SensitiveSurfaceMapper", level)); })); @@ -155,10 +155,10 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { // Set a new surface finder Config ccfg = cfg; auto candidateSurfaces = - std::make_shared(); + std::make_shared(); candidateSurfaces->trackingGeometry = tGeometry; ccfg.candidateSurfaces = candidateSurfaces; - return std::make_shared( + return std::make_shared( ccfg, getDefaultLogger("SensitiveSurfaceMapper", level)); }); @@ -173,20 +173,21 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { std::make_shared(); candidateSurfaces->detector = detector; ccfg.candidateSurfaces = candidateSurfaces; - return std::make_shared( + return std::make_shared( ccfg, getDefaultLogger("SensitiveSurfaceMapper", level)); }); sm.def( "remapSensitiveNames", - [](SensitiveSurfaceMapper& self, State& state, GeometryContext& gctx, - DetectorConstructionFactory& factory, Transform3& transform) { + [](Geant4::SensitiveSurfaceMapper& self, State& state, + GeometryContext& gctx, Geant4::DetectorConstructionFactory& factory, + Transform3& transform) { return self.remapSensitiveNames( state, gctx, factory.factorize()->Construct(), transform); }, "state"_a, "gctx"_a, "g4physicalVolume"_a, "motherTransform"_a); - sm.def("checkMapping", &SensitiveSurfaceMapper::checkMapping, "state"_a, - "gctx"_a, "writeMappedAsObj"_a, "writeMissingAsObj"_a); + sm.def("checkMapping", &Geant4::SensitiveSurfaceMapper::checkMapping, + "state"_a, "gctx"_a, "writeMappedAsObj"_a, "writeMissingAsObj"_a); } { @@ -237,27 +238,28 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { } { - py::class_>( mod, "GdmlDetectorConstructionFactory") .def(py::init>>(), + std::vector>>(), py::arg("path"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } { py::class_< Telescope::TelescopeG4DetectorConstructionFactory, - DetectorConstructionFactory, + Geant4::DetectorConstructionFactory, std::shared_ptr>( mod, "TelescopeG4DetectorConstructionFactory") .def(py::init>>(), + std::vector>>(), py::arg("cfg"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } { @@ -412,7 +414,7 @@ PYBIND11_MODULE(ActsPythonBindingsGeant4, mod) { } { - using Tool = RegionCreator; + using Tool = Geant4::RegionCreator; using Config = Tool::Config; auto tool = py::class_>(mod, "RegionCreator") .def(py::init(), diff --git a/Examples/Python/src/Geant4DD4hepComponent.cpp b/Examples/Python/src/Geant4DD4hepComponent.cpp index 16ed3b40223..f8dec7d35d1 100644 --- a/Examples/Python/src/Geant4DD4hepComponent.cpp +++ b/Examples/Python/src/Geant4DD4hepComponent.cpp @@ -8,7 +8,6 @@ #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp" #include "ActsExamples/DDG4/DDG4DetectorConstruction.hpp" -#include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Geant4/RegionCreator.hpp" #include @@ -25,12 +24,13 @@ using namespace Acts; PYBIND11_MODULE(ActsPythonBindingsDDG4, m) { py::module_::import("acts.ActsPythonBindingsGeant4"); - py::class_>( m, "DDG4DetectorConstructionFactory") .def(py::init, - std::vector>>(), + std::vector>>(), py::arg("detector"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } diff --git a/Examples/Python/src/Geant4GeoModelComponent.cpp b/Examples/Python/src/Geant4GeoModelComponent.cpp index 80f6f89eec8..d9c372984db 100644 --- a/Examples/Python/src/Geant4GeoModelComponent.cpp +++ b/Examples/Python/src/Geant4GeoModelComponent.cpp @@ -6,7 +6,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -#include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Geant4/DetectorConstructionFactory.hpp" #include "ActsExamples/Geant4/RegionCreator.hpp" #include "ActsExamples/GeoModelG4/GeoModelDetectorConstruction.hpp" @@ -25,12 +24,13 @@ using namespace Acts; PYBIND11_MODULE(ActsPythonBindingsGeoModelG4, m) { py::module_::import("acts.ActsPythonBindingsGeant4"); - py::class_>( m, "GeoModelDetectorConstructionFactory") .def(py::init>>(), + std::vector>>(), py::arg("geoModelTree"), py::arg("regionCreators") = - std::vector>()); + std::vector>()); } diff --git a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp index d06c77412e4..e5868effd19 100644 --- a/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp +++ b/Plugins/Geant4/include/Acts/Plugins/Geant4/Geant4DetectorSurfaceFactory.hpp @@ -9,7 +9,6 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/Common.hpp" #include "Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -91,4 +90,5 @@ class Geant4DetectorSurfaceFactory { void construct(Cache& cache, const G4Transform3D& g4ToGlobal, const G4VPhysicalVolume& g4PhysVol, const Options& option); }; + } // namespace Acts diff --git a/Plugins/Geant4/src/Geant4DetectorElement.cpp b/Plugins/Geant4/src/Geant4DetectorElement.cpp index d5410d3b3de..179b351d50e 100644 --- a/Plugins/Geant4/src/Geant4DetectorElement.cpp +++ b/Plugins/Geant4/src/Geant4DetectorElement.cpp @@ -12,31 +12,36 @@ #include -Acts::Geant4DetectorElement::Geant4DetectorElement( - std::shared_ptr surface, const G4VPhysicalVolume& g4physVol, - const Acts::Transform3& toGlobal, Acts::ActsScalar thickness) +namespace Acts { + +Geant4DetectorElement::Geant4DetectorElement(std::shared_ptr surface, + const G4VPhysicalVolume& g4physVol, + const Transform3& toGlobal, + ActsScalar thickness) : m_surface(std::move(surface)), m_g4physVol(&g4physVol), m_toGlobal(toGlobal), m_thickness(thickness) {} -const Acts::Transform3& Acts::Geant4DetectorElement::transform( +const Transform3& Geant4DetectorElement::transform( const GeometryContext& /*gctx*/) const { return m_toGlobal; } -const Acts::Surface& Acts::Geant4DetectorElement::surface() const { +const Surface& Geant4DetectorElement::surface() const { return *m_surface; } -Acts::Surface& Acts::Geant4DetectorElement::surface() { +Surface& Geant4DetectorElement::surface() { return *m_surface; } -Acts::ActsScalar Acts::Geant4DetectorElement::thickness() const { +ActsScalar Geant4DetectorElement::thickness() const { return m_thickness; } -const G4VPhysicalVolume& Acts::Geant4DetectorElement::g4PhysicalVolume() const { +const G4VPhysicalVolume& Geant4DetectorElement::g4PhysicalVolume() const { return *m_g4physVol; } + +} // namespace Acts diff --git a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp index 31cce3360e9..bbd12562eac 100644 --- a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp +++ b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp @@ -6,14 +6,6 @@ // 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/. -// This file is part of the Acts project. -// -// Copyright (C) 2024 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 http://mozilla.org/MPL/2.0/. - #pragma once #include "Acts/Plugins/GeoModel/GeoModelDetectorElement.hpp" diff --git a/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp b/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp index f671386dec6..1f45a10d391 100644 --- a/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp +++ b/Plugins/GeoModel/src/GeoModelDetectorElementITk.cpp @@ -6,14 +6,6 @@ // 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/. -// This file is part of the Acts project. -// -// Copyright (C) 2024 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 http://mozilla.org/MPL/2.0/. - #include "Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp" #include "Acts/Surfaces/AnnulusBounds.hpp" diff --git a/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp b/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp index 0c945ebb6dd..f3e96e4a6f8 100644 --- a/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp +++ b/Tests/UnitTests/Plugins/GeoModel/GeoModelDetectorElementITkTests.cpp @@ -6,14 +6,6 @@ // 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/. -// This file is part of the Acts project. -// -// Copyright (C) 2024 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 http://mozilla.org/MPL/2.0/. - #include #include "Acts/Plugins/GeoModel/GeoModelDetectorElementITk.hpp" From 195dca3f46b12800f3f2ea408c905fa840be42fe Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sat, 23 Nov 2024 22:54:43 +0100 Subject: [PATCH 5/6] refactor!: Single type/alias for intersection status (#3898) Seems more concise and consistent --- .../Acts/Navigation/DetectorNavigator.hpp | 4 +- .../Acts/Navigation/NavigationStream.hpp | 2 +- Core/include/Acts/Propagator/AtlasStepper.hpp | 2 +- .../Acts/Propagator/DirectNavigator.hpp | 12 ++-- Core/include/Acts/Propagator/EigenStepper.hpp | 2 +- .../Acts/Propagator/MultiEigenStepperLoop.hpp | 12 ++-- .../Acts/Propagator/MultiEigenStepperLoop.ipp | 9 ++- .../Acts/Propagator/MultiStepperAborters.hpp | 8 +-- Core/include/Acts/Propagator/Navigator.hpp | 10 +-- .../Acts/Propagator/StandardAborters.hpp | 2 +- .../Acts/Propagator/StraightLineStepper.hpp | 2 +- Core/include/Acts/Propagator/SympyStepper.hpp | 2 +- .../Acts/Propagator/TryAllNavigator.hpp | 8 +-- .../Acts/Propagator/detail/SteppingHelper.hpp | 10 +-- .../Acts/Surfaces/detail/PlanarHelper.hpp | 6 +- .../Acts/TrackFitting/GaussianSumFitter.hpp | 3 +- .../Acts/TrackFitting/detail/GsfActor.hpp | 31 ++++----- Core/include/Acts/Utilities/Intersection.hpp | 23 +++---- Core/src/Surfaces/ConeSurface.cpp | 16 ++--- Core/src/Surfaces/CylinderSurface.cpp | 22 +++--- Core/src/Surfaces/DiscSurface.cpp | 6 +- Core/src/Surfaces/IntersectionHelper2D.cpp | 18 ++--- Core/src/Surfaces/LineSurface.cpp | 8 +-- Core/src/Surfaces/PlaneSurface.cpp | 4 +- Core/src/Utilities/Intersection.cpp | 2 + .../Core/Propagator/MultiStepperTests.cpp | 20 +++--- .../Core/Propagator/NavigatorTests.cpp | 2 +- .../Core/Surfaces/CylinderSurfaceTests.cpp | 2 +- .../Core/Surfaces/DiscSurfaceTests.cpp | 2 +- .../Core/Surfaces/PlaneSurfaceTests.cpp | 2 +- .../Surfaces/SurfaceIntersectionTests.cpp | 67 +++++++------------ Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp | 2 +- .../Core/Utilities/IntersectionTests.cpp | 55 +++++++-------- 33 files changed, 169 insertions(+), 207 deletions(-) diff --git a/Core/include/Acts/Navigation/DetectorNavigator.hpp b/Core/include/Acts/Navigation/DetectorNavigator.hpp index 0ffcf1446bc..3bc324e187f 100644 --- a/Core/include/Acts/Navigation/DetectorNavigator.hpp +++ b/Core/include/Acts/Navigation/DetectorNavigator.hpp @@ -223,7 +223,7 @@ class DetectorNavigator { ACTS_VERBOSE(volInfo(state) << posInfo(state, stepper) << "surface status is " << surfaceStatus); - if (surfaceStatus == Intersection3D::Status::reachable) { + if (surfaceStatus == IntersectionStatus::reachable) { ACTS_VERBOSE(volInfo(state) << posInfo(state, stepper) << "surface " << surface.center(state.geoContext).transpose() @@ -292,7 +292,7 @@ class DetectorNavigator { state.options.surfaceTolerance, logger()); // Check if we are at a surface - if (surfaceStatus == Intersection3D::Status::onSurface) { + if (surfaceStatus == IntersectionStatus::onSurface) { ACTS_VERBOSE(volInfo(state) << posInfo(state, stepper) << "landed on surface"); diff --git a/Core/include/Acts/Navigation/NavigationStream.hpp b/Core/include/Acts/Navigation/NavigationStream.hpp index 97e154214d7..d579c0d7392 100644 --- a/Core/include/Acts/Navigation/NavigationStream.hpp +++ b/Core/include/Acts/Navigation/NavigationStream.hpp @@ -9,13 +9,13 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Definitions/Tolerance.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/Portal.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Utilities/Intersection.hpp" #include -#include #include namespace Acts { diff --git a/Core/include/Acts/Propagator/AtlasStepper.hpp b/Core/include/Acts/Propagator/AtlasStepper.hpp index 88cfd39e548..50fd78de145 100644 --- a/Core/include/Acts/Propagator/AtlasStepper.hpp +++ b/Core/include/Acts/Propagator/AtlasStepper.hpp @@ -419,7 +419,7 @@ class AtlasStepper { /// @param [in] boundaryTolerance The boundary check for this status update /// @param [in] surfaceTolerance Surface tolerance used for intersection /// @param [in] logger Logger instance to use - Intersection3D::Status updateSurfaceStatus( + IntersectionStatus updateSurfaceStatus( State& state, const Surface& surface, std::uint8_t index, Direction navDir, const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance = s_onSurfaceTolerance, diff --git a/Core/include/Acts/Propagator/DirectNavigator.hpp b/Core/include/Acts/Propagator/DirectNavigator.hpp index 3356ab395c4..d2f66468168 100644 --- a/Core/include/Acts/Propagator/DirectNavigator.hpp +++ b/Core/include/Acts/Propagator/DirectNavigator.hpp @@ -9,20 +9,18 @@ #pragma once #include "Acts/Definitions/Direction.hpp" -#include "Acts/Geometry/BoundarySurfaceT.hpp" +#include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/Layer.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Geometry/TrackingVolume.hpp" +#include "Acts/Propagator/ConstrainedStep.hpp" #include "Acts/Propagator/NavigatorOptions.hpp" #include "Acts/Propagator/NavigatorStatistics.hpp" -#include "Acts/Propagator/Propagator.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Logger.hpp" -#include -#include #include #include #include @@ -259,7 +257,7 @@ class DirectNavigator { state.stepping, surface, index, state.options.direction, BoundaryTolerance::Infinite(), state.options.surfaceTolerance, *m_logger); - if (surfaceStatus == Intersection3D::Status::unreachable) { + if (surfaceStatus == IntersectionStatus::unreachable) { ACTS_VERBOSE( "Surface not reachable anymore, switching to next one in " "sequence"); @@ -313,7 +311,7 @@ class DirectNavigator { state.stepping, surface, index, state.options.direction, BoundaryTolerance::Infinite(), state.options.surfaceTolerance, *m_logger); - if (surfaceStatus == Intersection3D::Status::onSurface) { + if (surfaceStatus == IntersectionStatus::onSurface) { // Set the current surface state.navigation.currentSurface = state.navigation.navSurface(); ACTS_VERBOSE("Current surface set to " @@ -326,7 +324,7 @@ class DirectNavigator { .at(state.navigation.surfaceIndex) ->geometryId()); } - } else if (surfaceStatus == Intersection3D::Status::reachable) { + } else if (surfaceStatus == IntersectionStatus::reachable) { ACTS_VERBOSE("Next surface reachable at distance " << stepper.outputStepSize(state.stepping)); } diff --git a/Core/include/Acts/Propagator/EigenStepper.hpp b/Core/include/Acts/Propagator/EigenStepper.hpp index 09df3ce3167..47f2db687b6 100644 --- a/Core/include/Acts/Propagator/EigenStepper.hpp +++ b/Core/include/Acts/Propagator/EigenStepper.hpp @@ -270,7 +270,7 @@ class EigenStepper { /// @param [in] boundaryTolerance The boundary check for this status update /// @param [in] surfaceTolerance Surface tolerance used for intersection /// @param [in] logger A @c Logger instance - Intersection3D::Status updateSurfaceStatus( + IntersectionStatus updateSurfaceStatus( State& state, const Surface& surface, std::uint8_t index, Direction navDir, const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance = s_onSurfaceTolerance, diff --git a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp index e21bdb2365e..dff30746cf6 100644 --- a/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp +++ b/Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp @@ -197,7 +197,7 @@ class MultiEigenStepperLoop : public EigenStepper { struct Component { SingleState state; ActsScalar weight; - Intersection3D::Status status; + IntersectionStatus status; }; /// Particle hypothesis @@ -255,7 +255,7 @@ class MultiEigenStepperLoop : public EigenStepper { const auto& [weight, singlePars] = multipars[i]; components.push_back( {SingleState(gctx, bfield->makeCache(mctx), singlePars, ssize), - weight, Intersection3D::Status::onSurface}); + weight, IntersectionStatus::onSurface}); } if (std::get<2>(multipars.components().front())) { @@ -398,7 +398,7 @@ class MultiEigenStepperLoop : public EigenStepper { void removeMissedComponents(State& state) const { auto new_end = std::remove_if( state.components.begin(), state.components.end(), [](const auto& cmp) { - return cmp.status == Intersection3D::Status::missed; + return cmp.status == IntersectionStatus::missed; }); state.components.erase(new_end, state.components.end()); @@ -441,7 +441,7 @@ class MultiEigenStepperLoop : public EigenStepper { {SingleState(state.geoContext, SingleStepper::m_bField->makeCache(state.magContext), pars), - weight, Intersection3D::Status::onSurface}); + weight, IntersectionStatus::onSurface}); return ComponentProxy{state.components.back(), state}; } @@ -520,12 +520,12 @@ class MultiEigenStepperLoop : public EigenStepper { /// @param [in] boundaryTolerance The boundary check for this status update /// @param [in] surfaceTolerance Surface tolerance used for intersection /// @param [in] logger A @c Logger instance - Intersection3D::Status updateSurfaceStatus( + IntersectionStatus updateSurfaceStatus( State& state, const Surface& surface, std::uint8_t index, Direction navDir, const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance = s_onSurfaceTolerance, const Logger& logger = getDummyLogger()) const { - using Status = Intersection3D::Status; + using Status = IntersectionStatus; std::array counts = {0, 0, 0}; diff --git a/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp b/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp index fab3e3f0779..67aa98e94bb 100644 --- a/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp +++ b/Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp @@ -93,7 +93,7 @@ template template Result MultiEigenStepperLoop::step( propagator_state_t& state, const navigator_t& navigator) const { - using Status = Acts::Intersection3D::Status; + using Status = Acts::IntersectionStatus; State& stepping = state.stepping; auto& components = stepping.components; @@ -137,10 +137,9 @@ Result MultiEigenStepperLoop::step( // If at least one component is on a surface, we can remove all missed // components before the step. If not, we must keep them for the case that all // components miss and we need to retarget - const auto cmpsOnSurface = - std::count_if(components.cbegin(), components.cend(), [&](auto& cmp) { - return cmp.status == Intersection3D::Status::onSurface; - }); + const auto cmpsOnSurface = std::count_if( + components.cbegin(), components.cend(), + [&](auto& cmp) { return cmp.status == IntersectionStatus::onSurface; }); if (cmpsOnSurface > 0) { removeMissedComponents(stepping); diff --git a/Core/include/Acts/Propagator/MultiStepperAborters.hpp b/Core/include/Acts/Propagator/MultiStepperAborters.hpp index 0e28375df94..e42d3387e2f 100644 --- a/Core/include/Acts/Propagator/MultiStepperAborters.hpp +++ b/Core/include/Acts/Propagator/MultiStepperAborters.hpp @@ -59,12 +59,12 @@ struct MultiStepperSurfaceReached : public SurfaceReached { averageOnSurfaceTolerance) .closest(); - if (sIntersection.status() == Intersection3D::Status::onSurface) { + if (sIntersection.status() == IntersectionStatus::onSurface) { ACTS_VERBOSE( "MultiStepperSurfaceReached aborter | " "Reached target in average mode"); for (auto cmp : stepper.componentIterable(state.stepping)) { - cmp.status() = Intersection3D::Status::onSurface; + cmp.status() = IntersectionStatus::onSurface; } return true; @@ -84,10 +84,10 @@ struct MultiStepperSurfaceReached : public SurfaceReached { if (!SurfaceReached::checkAbort(singleState, singleStepper, navigator, logger)) { - cmp.status() = Acts::Intersection3D::Status::reachable; + cmp.status() = Acts::IntersectionStatus::reachable; reached = false; } else { - cmp.status() = Acts::Intersection3D::Status::onSurface; + cmp.status() = Acts::IntersectionStatus::onSurface; } } diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index a02e0958160..504912b507f 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -649,7 +649,7 @@ class Navigator { auto surfaceStatus = stepper.updateSurfaceStatus( state.stepping, *surface, intersection.index(), state.options.direction, BoundaryTolerance::None(), state.options.surfaceTolerance, logger()); - if (surfaceStatus == Intersection3D::Status::onSurface) { + if (surfaceStatus == IntersectionStatus::onSurface) { ACTS_VERBOSE(volInfo(state) << "Status Surface successfully hit, storing it."); // Set in navigation state, so actors and aborters can access it @@ -725,7 +725,7 @@ class Navigator { state.stepping, *surface, intersection.index(), state.options.direction, boundaryTolerance, state.options.surfaceTolerance, logger()); - if (surfaceStatus == Intersection3D::Status::reachable) { + if (surfaceStatus == IntersectionStatus::reachable) { ACTS_VERBOSE(volInfo(state) << "Surface reachable, step size updated to " << stepper.outputStepSize(state.stepping)); @@ -815,7 +815,7 @@ class Navigator { state.stepping, *layerSurface, intersection.index(), state.options.direction, BoundaryTolerance::None(), state.options.surfaceTolerance, logger()); - if (layerStatus == Intersection3D::Status::reachable) { + if (layerStatus == IntersectionStatus::reachable) { ACTS_VERBOSE(volInfo(state) << "Layer reachable, step size updated to " << stepper.outputStepSize(state.stepping)); return true; @@ -937,7 +937,7 @@ class Navigator { state.stepping, *boundarySurface, intersection.index(), state.options.direction, BoundaryTolerance::None(), state.options.surfaceTolerance, logger()); - if (boundaryStatus == Intersection3D::Status::reachable) { + if (boundaryStatus == IntersectionStatus::reachable) { ACTS_VERBOSE(volInfo(state) << "Boundary reachable, step size updated to " << stepper.outputStepSize(state.stepping)); @@ -1160,7 +1160,7 @@ class Navigator { state.options.direction, BoundaryTolerance::None(), state.options.surfaceTolerance, logger()); // the only advance could have been to the target - if (targetStatus == Intersection3D::Status::onSurface) { + if (targetStatus == IntersectionStatus::onSurface) { // set the target surface state.navigation.currentSurface = state.navigation.targetSurface; ACTS_VERBOSE(volInfo(state) diff --git a/Core/include/Acts/Propagator/StandardAborters.hpp b/Core/include/Acts/Propagator/StandardAborters.hpp index 706b0ce0697..271ebd85239 100644 --- a/Core/include/Acts/Propagator/StandardAborters.hpp +++ b/Core/include/Acts/Propagator/StandardAborters.hpp @@ -118,7 +118,7 @@ struct SurfaceReached { bool reached = false; - if (closest.status() == Intersection3D::Status::onSurface) { + if (closest.status() == IntersectionStatus::onSurface) { const double distance = closest.pathLength(); ACTS_VERBOSE( "SurfaceReached aborter | " diff --git a/Core/include/Acts/Propagator/StraightLineStepper.hpp b/Core/include/Acts/Propagator/StraightLineStepper.hpp index 18904797fdd..59f10b1d980 100644 --- a/Core/include/Acts/Propagator/StraightLineStepper.hpp +++ b/Core/include/Acts/Propagator/StraightLineStepper.hpp @@ -242,7 +242,7 @@ class StraightLineStepper { /// @param [in] boundaryTolerance The boundary check for this status update /// @param [in] surfaceTolerance Surface tolerance used for intersection /// @param [in] logger A logger instance - Intersection3D::Status updateSurfaceStatus( + IntersectionStatus updateSurfaceStatus( State& state, const Surface& surface, std::uint8_t index, Direction navDir, const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance = s_onSurfaceTolerance, diff --git a/Core/include/Acts/Propagator/SympyStepper.hpp b/Core/include/Acts/Propagator/SympyStepper.hpp index 3b1a2125a41..f5773a8a409 100644 --- a/Core/include/Acts/Propagator/SympyStepper.hpp +++ b/Core/include/Acts/Propagator/SympyStepper.hpp @@ -237,7 +237,7 @@ class SympyStepper { /// @param [in] boundaryTolerance The boundary check for this status update /// @param [in] surfaceTolerance Surface tolerance used for intersection /// @param [in] logger A @c Logger instance - Intersection3D::Status updateSurfaceStatus( + IntersectionStatus updateSurfaceStatus( State& state, const Surface& surface, std::uint8_t index, Direction navDir, const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance = s_onSurfaceTolerance, diff --git a/Core/include/Acts/Propagator/TryAllNavigator.hpp b/Core/include/Acts/Propagator/TryAllNavigator.hpp index 09f6fb25e25..7470fa0da0c 100644 --- a/Core/include/Acts/Propagator/TryAllNavigator.hpp +++ b/Core/include/Acts/Propagator/TryAllNavigator.hpp @@ -434,7 +434,7 @@ class TryAllNavigator : public TryAllNavigatorBase { const auto& intersection = candidate.intersection; const Surface& surface = *intersection.object(); - Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus( + IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus( state.stepping, surface, intersection.index(), state.options.direction, BoundaryTolerance::Infinite(), state.options.surfaceTolerance, logger()); @@ -463,7 +463,7 @@ class TryAllNavigator : public TryAllNavigatorBase { const auto& intersection = candidate.intersection; const Surface& surface = *intersection.object(); - Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus( + IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus( state.stepping, surface, intersection.index(), state.options.direction, BoundaryTolerance::None(), state.options.surfaceTolerance, logger()); @@ -788,7 +788,7 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase { const auto& intersection = candidate.intersection; const Surface& surface = *intersection.object(); - Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus( + IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus( state.stepping, surface, intersection.index(), state.options.direction, BoundaryTolerance::Infinite(), state.options.surfaceTolerance, logger()); @@ -815,7 +815,7 @@ class TryAllOverstepNavigator : public TryAllNavigatorBase { const auto& intersection = candidate.intersection; const Surface& surface = *intersection.object(); - Intersection3D::Status surfaceStatus = stepper.updateSurfaceStatus( + IntersectionStatus surfaceStatus = stepper.updateSurfaceStatus( state.stepping, surface, intersection.index(), state.options.direction, BoundaryTolerance::None(), state.options.surfaceTolerance, logger()); diff --git a/Core/include/Acts/Propagator/detail/SteppingHelper.hpp b/Core/include/Acts/Propagator/detail/SteppingHelper.hpp index c78f0ea1f51..c0589d739c7 100644 --- a/Core/include/Acts/Propagator/detail/SteppingHelper.hpp +++ b/Core/include/Acts/Propagator/detail/SteppingHelper.hpp @@ -32,7 +32,7 @@ namespace Acts::detail { /// @param surface [in] The surface provided /// @param boundaryTolerance [in] The boundary check for this status update template -Acts::Intersection3D::Status updateSingleSurfaceStatus( +Acts::IntersectionStatus updateSingleSurfaceStatus( const stepper_t& stepper, typename stepper_t::State& state, const Surface& surface, std::uint8_t index, Direction navDir, const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance, @@ -46,11 +46,11 @@ Acts::Intersection3D::Status updateSingleSurfaceStatus( surfaceTolerance)[index]; // The intersection is on surface already - if (sIntersection.status() == Intersection3D::Status::onSurface) { + if (sIntersection.status() == IntersectionStatus::onSurface) { // Release navigation step size state.stepSize.release(ConstrainedStep::actor); ACTS_VERBOSE("Intersection: state is ON SURFACE"); - return Intersection3D::Status::onSurface; + return IntersectionStatus::onSurface; } const double nearLimit = std::numeric_limits::lowest(); @@ -62,11 +62,11 @@ Acts::Intersection3D::Status updateSingleSurfaceStatus( ACTS_VERBOSE("Surface is reachable"); stepper.updateStepSize(state, sIntersection.pathLength(), ConstrainedStep::actor); - return Intersection3D::Status::reachable; + return IntersectionStatus::reachable; } ACTS_VERBOSE("Surface is NOT reachable"); - return Intersection3D::Status::unreachable; + return IntersectionStatus::unreachable; } /// Update the Step size - single component diff --git a/Core/include/Acts/Surfaces/detail/PlanarHelper.hpp b/Core/include/Acts/Surfaces/detail/PlanarHelper.hpp index f7b21a960aa..99e1803126f 100644 --- a/Core/include/Acts/Surfaces/detail/PlanarHelper.hpp +++ b/Core/include/Acts/Surfaces/detail/PlanarHelper.hpp @@ -35,9 +35,9 @@ inline Intersection3D intersect(const Transform3& transform, // Translate that into a path ActsScalar path = (pnormal.dot((pcenter - position))) / (denom); // Is valid hence either on surface or reachable - Intersection3D::Status status = std::abs(path) < std::abs(tolerance) - ? Intersection3D::Status::onSurface - : Intersection3D::Status::reachable; + IntersectionStatus status = std::abs(path) < std::abs(tolerance) + ? IntersectionStatus::onSurface + : IntersectionStatus::reachable; // Return the intersection return Intersection3D{(position + path * direction), path, status}; } diff --git a/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp b/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp index f6c990a696d..4efcd82e4c4 100644 --- a/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp +++ b/Core/include/Acts/TrackFitting/GaussianSumFitter.hpp @@ -14,6 +14,7 @@ #include "Acts/Propagator/Navigator.hpp" #include "Acts/Propagator/StandardAborters.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" +#include "Acts/TrackFitting/GsfError.hpp" #include "Acts/TrackFitting/GsfOptions.hpp" #include "Acts/TrackFitting/detail/GsfActor.hpp" #include "Acts/Utilities/Helpers.hpp" @@ -217,7 +218,7 @@ struct GaussianSumFitter { .closest() .status(); - if (intersectionStatusStartSurface != Intersection3D::Status::onSurface) { + if (intersectionStatusStartSurface != IntersectionStatus::onSurface) { ACTS_DEBUG( "Surface intersection of start parameters WITH bound-check failed"); } diff --git a/Core/include/Acts/TrackFitting/detail/GsfActor.hpp b/Core/include/Acts/TrackFitting/detail/GsfActor.hpp index 92c5529d319..eeb7636103b 100644 --- a/Core/include/Acts/TrackFitting/detail/GsfActor.hpp +++ b/Core/include/Acts/TrackFitting/detail/GsfActor.hpp @@ -12,14 +12,9 @@ #include "Acts/EventData/MultiComponentTrackParameters.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/MultiTrajectoryHelpers.hpp" -#include "Acts/MagneticField/MagneticFieldProvider.hpp" -#include "Acts/Material/ISurfaceMaterial.hpp" -#include "Acts/Surfaces/CylinderSurface.hpp" +#include "Acts/Propagator/detail/PointwiseMaterialInteraction.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "Acts/TrackFitting/BetheHeitlerApprox.hpp" -#include "Acts/TrackFitting/GsfError.hpp" #include "Acts/TrackFitting/GsfOptions.hpp" -#include "Acts/TrackFitting/KalmanFitter.hpp" #include "Acts/TrackFitting/detail/GsfComponentMerging.hpp" #include "Acts/TrackFitting/detail/GsfUtils.hpp" #include "Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp" @@ -28,7 +23,6 @@ #include #include -#include namespace Acts::detail { @@ -53,8 +47,8 @@ struct GsfResult { std::size_t measurementHoles = 0; std::size_t processedStates = 0; - std::vector visitedSurfaces; - std::vector surfacesVisitedBwdAgain; + std::vector visitedSurfaces; + std::vector surfacesVisitedBwdAgain; /// Statistics about material encounterings Updatable nInvalidBetheHeitler; @@ -74,7 +68,7 @@ struct GsfActor { /// Enforce default construction GsfActor() = default; - using ComponentCache = Acts::GsfComponent; + using ComponentCache = GsfComponent; /// Broadcast the result_type using result_type = GsfResult; @@ -189,7 +183,7 @@ struct GsfActor { // All components must have status "on surface". It is however possible, // that currentSurface is nullptr and all components are "on surface" (e.g., // for surfaces excluded from the navigation) - using Status [[maybe_unused]] = Acts::Intersection3D::Status; + using Status [[maybe_unused]] = IntersectionStatus; assert(std::all_of( stepperComponents.begin(), stepperComponents.end(), [](const auto& cmp) { return cmp.status() == Status::onSurface; })); @@ -484,7 +478,7 @@ struct GsfActor { // we set ignored components to missed, so we can remove them after // the loop if (tmpStates.weights.at(idx) < m_cfg.weightCutoff) { - cmp.status() = Intersection3D::Status::missed; + cmp.status() = IntersectionStatus::missed; continue; } @@ -534,9 +528,9 @@ struct GsfActor { state.geoContext, freeParams.template segment<3>(eFreePos0), freeParams.template segment<3>(eFreeDir0)); cmp.pathAccumulated() = state.stepping.pathAccumulated; - cmp.jacobian() = Acts::BoundMatrix::Identity(); - cmp.derivative() = Acts::FreeVector::Zero(); - cmp.jacTransport() = Acts::FreeMatrix::Identity(); + cmp.jacobian() = BoundMatrix::Identity(); + cmp.derivative() = FreeVector::Zero(); + cmp.jacTransport() = FreeMatrix::Identity(); } } @@ -574,8 +568,7 @@ struct GsfActor { // If at least one component is no outlier, we consider the whole thing // as a measurementState - if (trackStateProxy.typeFlags().test( - Acts::TrackStateFlag::MeasurementFlag)) { + if (trackStateProxy.typeFlags().test(TrackStateFlag::MeasurementFlag)) { is_valid_measurement = true; } @@ -621,7 +614,7 @@ struct GsfActor { stepper.particleHypothesis(state.stepping)); // Return success - return Acts::Result::success(); + return Result::success(); } template & options) { + void setOptions(const GsfOptions& options) { m_cfg.maxComponents = options.maxComponents; m_cfg.extensions = options.extensions; m_cfg.abortOnError = options.abortOnError; diff --git a/Core/include/Acts/Utilities/Intersection.hpp b/Core/include/Acts/Utilities/Intersection.hpp index 6276538ed5e..11adf0bdece 100644 --- a/Core/include/Acts/Utilities/Intersection.hpp +++ b/Core/include/Acts/Utilities/Intersection.hpp @@ -9,7 +9,6 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/Tolerance.hpp" #include "Acts/Utilities/Logger.hpp" #include @@ -47,8 +46,6 @@ class Intersection { public: /// Position type using Position = ActsVector; - /// Status enum - using Status = IntersectionStatus; /// Constructor with arguments /// @@ -56,11 +53,13 @@ class Intersection { /// @param pathLength is the path length to the intersection /// @param status is an enum indicating the status of the intersection constexpr Intersection(const Position& position, double pathLength, - Status status) + IntersectionStatus status) : m_position(position), m_pathLength(pathLength), m_status(status) {} /// Returns whether the intersection was successful or not - constexpr bool isValid() const { return m_status != Status::missed; } + constexpr bool isValid() const { + return m_status != IntersectionStatus::missed; + } /// Returns the position of the interseciton constexpr const Position& position() const { return m_position; } @@ -69,7 +68,7 @@ class Intersection { constexpr ActsScalar pathLength() const { return m_pathLength; } /// Returns the intersection status enum - constexpr Status status() const { return m_status; } + constexpr IntersectionStatus status() const { return m_status; } /// Static factory to creae an invalid instesection constexpr static Intersection invalid() { return Intersection(); } @@ -87,12 +86,12 @@ class Intersection { /// be first. constexpr static bool closestOrder(const Intersection& aIntersection, const Intersection& bIntersection) { - if ((aIntersection.status() == Status::unreachable) && - (bIntersection.status() != Status::unreachable)) { + if ((aIntersection.status() == IntersectionStatus::unreachable) && + (bIntersection.status() != IntersectionStatus::unreachable)) { return false; } - if ((aIntersection.status() != Status::unreachable) && - (bIntersection.status() == Status::unreachable)) { + if ((aIntersection.status() != IntersectionStatus::unreachable) && + (bIntersection.status() == IntersectionStatus::unreachable)) { return true; } // both are reachable or onSurface now @@ -117,7 +116,7 @@ class Intersection { /// Signed path length to the intersection (if valid) ActsScalar m_pathLength = std::numeric_limits::infinity(); /// The Status of the intersection - Status m_status = Status::unreachable; + IntersectionStatus m_status = IntersectionStatus::unreachable; constexpr Intersection() = default; }; @@ -161,7 +160,7 @@ class ObjectIntersection { } /// Returns the status of the interseciton - constexpr Intersection3D::Status status() const { + constexpr IntersectionStatus status() const { return m_intersection.status(); } diff --git a/Core/src/Surfaces/ConeSurface.cpp b/Core/src/Surfaces/ConeSurface.cpp index b6d04e87e06..0ad869f2a4e 100644 --- a/Core/src/Surfaces/ConeSurface.cpp +++ b/Core/src/Surfaces/ConeSurface.cpp @@ -295,23 +295,23 @@ Acts::SurfaceMultiIntersection Acts::ConeSurface::intersect( // Check the validity of the first solution Vector3 solution1 = position + qe.first * direction; - Intersection3D::Status status1 = std::abs(qe.first) < std::abs(tolerance) - ? Intersection3D::Status::onSurface - : Intersection3D::Status::reachable; + IntersectionStatus status1 = std::abs(qe.first) < std::abs(tolerance) + ? IntersectionStatus::onSurface + : IntersectionStatus::reachable; if (!boundaryTolerance.isInfinite() && !isOnSurface(gctx, solution1, direction, boundaryTolerance)) { - status1 = Intersection3D::Status::missed; + status1 = IntersectionStatus::missed; } // Check the validity of the second solution Vector3 solution2 = position + qe.first * direction; - Intersection3D::Status status2 = std::abs(qe.second) < std::abs(tolerance) - ? Intersection3D::Status::onSurface - : Intersection3D::Status::reachable; + IntersectionStatus status2 = std::abs(qe.second) < std::abs(tolerance) + ? IntersectionStatus::onSurface + : IntersectionStatus::reachable; if (!boundaryTolerance.isInfinite() && !isOnSurface(gctx, solution2, direction, boundaryTolerance)) { - status2 = Intersection3D::Status::missed; + status2 = IntersectionStatus::missed; } const auto& tf = transform(gctx); diff --git a/Core/src/Surfaces/CylinderSurface.cpp b/Core/src/Surfaces/CylinderSurface.cpp index 4b3cd2db7be..d34726c2a7f 100644 --- a/Core/src/Surfaces/CylinderSurface.cpp +++ b/Core/src/Surfaces/CylinderSurface.cpp @@ -243,14 +243,13 @@ Acts::SurfaceMultiIntersection Acts::CylinderSurface::intersect( // Check the validity of the first solution Vector3 solution1 = position + qe.first * direction; - Intersection3D::Status status1 = std::abs(qe.first) < std::abs(tolerance) - ? Intersection3D::Status::onSurface - : Intersection3D::Status::reachable; + IntersectionStatus status1 = std::abs(qe.first) < std::abs(tolerance) + ? IntersectionStatus::onSurface + : IntersectionStatus::reachable; // Helper method for boundary check - auto boundaryCheck = - [&](const Vector3& solution, - Intersection3D::Status status) -> Intersection3D::Status { + auto boundaryCheck = [&](const Vector3& solution, + IntersectionStatus status) -> IntersectionStatus { // No check to be done, return current status if (boundaryTolerance.isInfinite()) { return status; @@ -266,12 +265,11 @@ Acts::SurfaceMultiIntersection Acts::CylinderSurface::intersect( double cZ = vecLocal.dot(tMatrix.block<3, 1>(0, 2)); double modifiedTolerance = tolerance + absoluteBound->tolerance1; double hZ = cBounds.get(CylinderBounds::eHalfLengthZ) + modifiedTolerance; - return std::abs(cZ) < std::abs(hZ) ? status - : Intersection3D::Status::missed; + return std::abs(cZ) < std::abs(hZ) ? status : IntersectionStatus::missed; } return isOnSurface(gctx, solution, direction, boundaryTolerance) ? status - : Intersection3D::Status::missed; + : IntersectionStatus::missed; }; // Check first solution for boundary compatibility status1 = boundaryCheck(solution1, status1); @@ -282,9 +280,9 @@ Acts::SurfaceMultiIntersection Acts::CylinderSurface::intersect( } // Check the validity of the second solution Vector3 solution2 = position + qe.second * direction; - Intersection3D::Status status2 = std::abs(qe.second) < std::abs(tolerance) - ? Intersection3D::Status::onSurface - : Intersection3D::Status::reachable; + IntersectionStatus status2 = std::abs(qe.second) < std::abs(tolerance) + ? IntersectionStatus::onSurface + : IntersectionStatus::reachable; // Check first solution for boundary compatibility status2 = boundaryCheck(solution2, status2); Intersection3D second(solution2, qe.second, status2); diff --git a/Core/src/Surfaces/DiscSurface.cpp b/Core/src/Surfaces/DiscSurface.cpp index da1aa2b54bc..9e957346965 100644 --- a/Core/src/Surfaces/DiscSurface.cpp +++ b/Core/src/Surfaces/DiscSurface.cpp @@ -286,7 +286,7 @@ Acts::SurfaceMultiIntersection Acts::DiscSurface::intersect( PlanarHelper::intersect(gctxTransform, position, direction, tolerance); auto status = intersection.status(); // Evaluate boundary check if requested (and reachable) - if (intersection.status() != Intersection3D::Status::unreachable && + if (intersection.status() != IntersectionStatus::unreachable && m_bounds != nullptr && !boundaryTolerance.isInfinite()) { // Built-in local to global for speed reasons const auto& tMatrix = gctxTransform.matrix(); @@ -297,11 +297,11 @@ Acts::SurfaceMultiIntersection Acts::DiscSurface::intersect( double modifiedTolerance = tolerance + absoluteBound->tolerance0; if (!m_bounds->insideRadialBounds(VectorHelpers::perp(lcartesian), modifiedTolerance)) { - status = Intersection3D::Status::missed; + status = IntersectionStatus::missed; } } else if (!insideBounds(localCartesianToPolar(lcartesian), boundaryTolerance)) { - status = Intersection3D::Status::missed; + status = IntersectionStatus::missed; } } return {{Intersection3D(intersection.position(), intersection.pathLength(), diff --git a/Core/src/Surfaces/IntersectionHelper2D.cpp b/Core/src/Surfaces/IntersectionHelper2D.cpp index 1053021034f..c196b1a4131 100644 --- a/Core/src/Surfaces/IntersectionHelper2D.cpp +++ b/Core/src/Surfaces/IntersectionHelper2D.cpp @@ -30,11 +30,11 @@ Acts::Intersection2D Acts::detail::IntersectionHelper2D::intersectSegment( auto d = line.intersectionParameter(Plane::Through(s0, s1)); Vector2 intersection(origin + d * dir); - Intersection2D::Status status = Intersection2D::Status::reachable; + IntersectionStatus status = IntersectionStatus::reachable; if (boundCheck) { auto edgeToSol = intersection - s0; if (edgeToSol.dot(edge) < 0. || edgeToSol.norm() > (edge).norm()) { - status = Intersection2D::Status::unreachable; + status = IntersectionStatus::unreachable; } } return Intersection2D(intersection, d, status); @@ -55,11 +55,11 @@ Acts::detail::IntersectionHelper2D::intersectEllipse(ActsScalar Rx, ActsScalar altD = std::copysign(toAltD.norm(), toAltD.dot(dir)); if (std::abs(solD) < std::abs(altD)) { - return {Intersection2D(sol, solD, Intersection2D::Status::reachable), - Intersection2D(alt, altD, Intersection2D::Status::reachable)}; + return {Intersection2D(sol, solD, IntersectionStatus::reachable), + Intersection2D(alt, altD, IntersectionStatus::reachable)}; } - return {Intersection2D(alt, altD, Intersection2D::Status::reachable), - Intersection2D(sol, solD, Intersection2D::Status::reachable)}; + return {Intersection2D(alt, altD, IntersectionStatus::reachable), + Intersection2D(sol, solD, IntersectionStatus::reachable)}; }; // Special cases first @@ -73,7 +73,7 @@ Acts::detail::IntersectionHelper2D::intersectEllipse(ActsScalar Rx, return createSolution(sol, alt); } else if (std::abs(D) < s_epsilon) { return {Intersection2D(Vector2(solx, 0.), -origin.y(), - Intersection2D::Status::reachable), + IntersectionStatus::reachable), Intersection2D::invalid()}; } return {Intersection2D::invalid(), Intersection2D::invalid()}; @@ -87,7 +87,7 @@ Acts::detail::IntersectionHelper2D::intersectEllipse(ActsScalar Rx, return createSolution(sol, alt); } else if (std::abs(D) < s_epsilon) { return {Intersection2D(Vector2(0., soly), -origin.x(), - Intersection2D::Status::reachable), + IntersectionStatus::reachable), Intersection2D::invalid()}; } return {Intersection2D::invalid(), Intersection2D::invalid()}; @@ -105,7 +105,7 @@ Acts::detail::IntersectionHelper2D::intersectEllipse(ActsScalar Rx, Vector2 sol(x, k * x + d); Vector2 toSolD(sol - origin); ActsScalar solD = std::copysign(toSolD.norm(), toSolD.dot(dir)); - return {Intersection2D(sol, solD, Intersection2D::Status::reachable), + return {Intersection2D(sol, solD, IntersectionStatus::reachable), Intersection2D::invalid()}; } else if (solver.solutions > 1) { ActsScalar x0 = solver.first; diff --git a/Core/src/Surfaces/LineSurface.cpp b/Core/src/Surfaces/LineSurface.cpp index f67fe038aa9..00d1fc6dd17 100644 --- a/Core/src/Surfaces/LineSurface.cpp +++ b/Core/src/Surfaces/LineSurface.cpp @@ -174,9 +174,9 @@ Acts::SurfaceMultiIntersection Acts::LineSurface::intersect( double u = (mab.dot(ea) - mab.dot(eb) * eaTeb) / denom; // Check if we are on the surface already - Intersection3D::Status status = std::abs(u) > std::abs(tolerance) - ? Intersection3D::Status::reachable - : Intersection3D::Status::onSurface; + IntersectionStatus status = std::abs(u) > std::abs(tolerance) + ? IntersectionStatus::reachable + : IntersectionStatus::onSurface; Vector3 result = ma + u * ea; // Evaluate the boundary check if requested // m_bounds == nullptr prevents unnecessary calculations for PerigeeSurface @@ -185,7 +185,7 @@ Acts::SurfaceMultiIntersection Acts::LineSurface::intersect( double cZ = vecLocal.dot(eb); double cR = (vecLocal - cZ * eb).norm(); if (!m_bounds->inside({cR, cZ}, boundaryTolerance)) { - status = Intersection3D::Status::missed; + status = IntersectionStatus::missed; } } diff --git a/Core/src/Surfaces/PlaneSurface.cpp b/Core/src/Surfaces/PlaneSurface.cpp index 658920e6686..db21709a192 100644 --- a/Core/src/Surfaces/PlaneSurface.cpp +++ b/Core/src/Surfaces/PlaneSurface.cpp @@ -168,14 +168,14 @@ Acts::SurfaceMultiIntersection Acts::PlaneSurface::intersect( PlanarHelper::intersect(gctxTransform, position, direction, tolerance); auto status = intersection.status(); // Evaluate boundary check if requested (and reachable) - if (intersection.status() != Intersection3D::Status::unreachable) { + if (intersection.status() != IntersectionStatus::unreachable) { // Built-in local to global for speed reasons const auto& tMatrix = gctxTransform.matrix(); // Create the reference vector in local const Vector3 vecLocal(intersection.position() - tMatrix.block<3, 1>(0, 3)); if (!insideBounds(tMatrix.block<3, 2>(0, 0).transpose() * vecLocal, boundaryTolerance)) { - status = Intersection3D::Status::missed; + status = IntersectionStatus::missed; } } return {{Intersection3D(intersection.position(), intersection.pathLength(), diff --git a/Core/src/Utilities/Intersection.cpp b/Core/src/Utilities/Intersection.cpp index 23378f0b381..8a99870b282 100644 --- a/Core/src/Utilities/Intersection.cpp +++ b/Core/src/Utilities/Intersection.cpp @@ -8,6 +8,8 @@ #include "Acts/Utilities/Intersection.hpp" +#include "Acts/Definitions/Tolerance.hpp" + namespace Acts { bool detail::checkPathLength(double pathLength, double nearLimit, diff --git a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp index 3fee9d4b6dd..a851d7592d9 100644 --- a/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp +++ b/Tests/UnitTests/Core/Propagator/MultiStepperTests.cpp @@ -308,7 +308,7 @@ void test_multi_stepper_vs_eigen_stepper() { SingleStepper single_stepper(defaultBField); for (auto cmp : multi_stepper.componentIterable(multi_state)) { - cmp.status() = Acts::Intersection3D::Status::reachable; + cmp.status() = Acts::IntersectionStatus::reachable; } // Do some steps and check that the results match @@ -483,14 +483,14 @@ void test_multi_stepper_surface_status_update() { multi_state, *right_surface, 0, Direction::Forward, BoundaryTolerance::Infinite()); - BOOST_CHECK_EQUAL(status, Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(status, IntersectionStatus::reachable); auto cmp_iterable = multi_stepper.constComponentIterable(multi_state); auto cmp_1 = *cmp_iterable.begin(); auto cmp_2 = *(++cmp_iterable.begin()); - BOOST_CHECK_EQUAL(cmp_1.status(), Intersection3D::Status::reachable); - BOOST_CHECK_EQUAL(cmp_2.status(), Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(cmp_1.status(), IntersectionStatus::reachable); + BOOST_CHECK_EQUAL(cmp_2.status(), IntersectionStatus::reachable); BOOST_CHECK_EQUAL(cmp_1.cmp.state.stepSize.value(), 1.0); BOOST_CHECK_EQUAL(cmp_2.cmp.state.stepSize.value(), -1.0); @@ -512,14 +512,14 @@ void test_multi_stepper_surface_status_update() { multi_state, *right_surface, 0, Direction::Forward, BoundaryTolerance::Infinite()); - BOOST_CHECK_EQUAL(status, Intersection3D::Status::onSurface); + BOOST_CHECK_EQUAL(status, IntersectionStatus::onSurface); auto cmp_iterable = multi_stepper.constComponentIterable(multi_state); auto cmp_1 = *cmp_iterable.begin(); auto cmp_2 = *(++cmp_iterable.begin()); - BOOST_CHECK_EQUAL(cmp_1.status(), Intersection3D::Status::onSurface); - BOOST_CHECK_EQUAL(cmp_2.status(), Intersection3D::Status::onSurface); + BOOST_CHECK_EQUAL(cmp_1.status(), IntersectionStatus::onSurface); + BOOST_CHECK_EQUAL(cmp_2.status(), IntersectionStatus::onSurface); } // Start surface should be reachable @@ -528,14 +528,14 @@ void test_multi_stepper_surface_status_update() { multi_state, *start_surface, 0, Direction::Forward, BoundaryTolerance::Infinite()); - BOOST_CHECK_EQUAL(status, Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(status, IntersectionStatus::reachable); auto cmp_iterable = multi_stepper.constComponentIterable(multi_state); auto cmp_1 = *cmp_iterable.begin(); auto cmp_2 = *(++cmp_iterable.begin()); - BOOST_CHECK_EQUAL(cmp_1.status(), Intersection3D::Status::reachable); - BOOST_CHECK_EQUAL(cmp_2.status(), Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(cmp_1.status(), IntersectionStatus::reachable); + BOOST_CHECK_EQUAL(cmp_2.status(), IntersectionStatus::reachable); BOOST_CHECK_EQUAL(cmp_1.cmp.state.stepSize.value(), -1.0); BOOST_CHECK_EQUAL(cmp_2.cmp.state.stepSize.value(), 1.0); diff --git a/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp b/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp index b9c6fdf87df..e47589c7c63 100644 --- a/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp +++ b/Tests/UnitTests/Core/Propagator/NavigatorTests.cpp @@ -140,7 +140,7 @@ struct PropagatorState { return s_onSurfaceTolerance; } - Intersection3D::Status updateSurfaceStatus( + IntersectionStatus updateSurfaceStatus( State& state, const Surface& surface, std::uint8_t index, Direction navDir, const BoundaryTolerance& boundaryTolerance, ActsScalar surfaceTolerance, const Logger& logger) const { diff --git a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp index 4dd6f7f6905..152ec791201 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { auto sfIntersection = cylinderSurfaceObject->intersect( testContext, offSurface, direction, BoundaryTolerance::Infinite()); Intersection3D expectedIntersect{Vector3{1, 1, 2}, 99., - Intersection3D::Status::reachable}; + IntersectionStatus::reachable}; BOOST_CHECK(sfIntersection[0].isValid()); CHECK_CLOSE_ABS(sfIntersection[0].position(), expectedIntersect.position(), 1e-9); diff --git a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp index b5d1eec5f43..401b6e5bf12 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { BoundaryTolerance::Infinite()) .closest(); Intersection3D expectedIntersect{Vector3{1.2, 0., 0.}, 10., - Intersection3D::Status::reachable}; + IntersectionStatus::reachable}; BOOST_CHECK(sfIntersection.isValid()); CHECK_CLOSE_ABS(sfIntersection.position(), expectedIntersect.position(), 1e-9); diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index 99d0569b9d2..de2a87483e0 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { BoundaryTolerance::None()) .closest(); Intersection3D expectedIntersect{Vector3{0, 1, 2}, 4., - Intersection3D::Status::reachable}; + IntersectionStatus::reachable}; BOOST_CHECK(sfIntersection.isValid()); BOOST_CHECK_EQUAL(sfIntersection.position(), expectedIntersect.position()); BOOST_CHECK_EQUAL(sfIntersection.pathLength(), diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index e6294fc27ca..0fcabe9ad81 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -71,15 +71,13 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { // Check the validity of the intersection BOOST_CHECK(aIntersection[0].isValid()); // The status of this one should be on surface - BOOST_CHECK_EQUAL(aIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(aIntersection[0].status(), IntersectionStatus::reachable); // The intersection is at 2 meter distance CHECK_CLOSE_ABS(aIntersection[0].pathLength(), -2_m, s_onSurfaceTolerance); // There MUST be a second solution BOOST_CHECK(aIntersection[1].isValid()); // The other intersection MUST be reachable - BOOST_CHECK_EQUAL(aIntersection[1].status(), - Intersection3D::Status::onSurface); + BOOST_CHECK_EQUAL(aIntersection[1].status(), IntersectionStatus::onSurface); // Intersect from the center auto cIntersection = aCylinder->intersect(tgContext, atCenter, alongX, @@ -88,13 +86,11 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { // Check the validity of the intersection BOOST_CHECK(cIntersection[0].isValid()); // The status of this one MUST be reachable - BOOST_CHECK_EQUAL(cIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(cIntersection[0].status(), IntersectionStatus::reachable); // There MUST be a second solution BOOST_CHECK(cIntersection[1].isValid()); // The other intersection MUST be reachable - BOOST_CHECK_EQUAL(cIntersection[1].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(cIntersection[1].status(), IntersectionStatus::reachable); // There MUST be one forward one backwards solution BOOST_CHECK_LT( cIntersection[1].pathLength() * cIntersection[0].pathLength(), 0); @@ -106,13 +102,11 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { // Check the validity of the intersection BOOST_CHECK(oIntersection[0].isValid()); // The status of this one MUST be reachable - BOOST_CHECK_EQUAL(oIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(oIntersection[0].status(), IntersectionStatus::reachable); // There MUST be a second solution BOOST_CHECK(oIntersection[1].isValid()); // The other intersection MUST be reachable - BOOST_CHECK_EQUAL(oIntersection[1].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(oIntersection[1].status(), IntersectionStatus::reachable); // There MUST be one forward one backwards solution BOOST_CHECK_GT( oIntersection[1].pathLength() * oIntersection[0].pathLength(), 0); @@ -133,13 +127,11 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { // This should be the positive one BOOST_CHECK_LT(eIntersection[0].pathLength(), 0.); // The status of this one should be reachable - BOOST_CHECK_EQUAL(eIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(eIntersection[0].status(), IntersectionStatus::reachable); // There MUST be a second solution BOOST_CHECK(eIntersection[1].isValid()); // The other intersection MUST be reachable - BOOST_CHECK_EQUAL(eIntersection[1].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(eIntersection[1].status(), IntersectionStatus::reachable); // And be the negative one BOOST_CHECK_GT(eIntersection[1].pathLength(), 0.); @@ -149,13 +141,11 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { // This should be the negative one BOOST_CHECK_LT(eIntersection[0].pathLength(), 0.); // The status of this one should be reachable - BOOST_CHECK_EQUAL(eIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(eIntersection[0].status(), IntersectionStatus::reachable); // There MUST be a second solution BOOST_CHECK(!eIntersection[1].isValid()); // The other intersection MUST NOT be reachable - BOOST_CHECK_EQUAL(eIntersection[1].status(), - Intersection3D::Status::missed); + BOOST_CHECK_EQUAL(eIntersection[1].status(), IntersectionStatus::missed); // And be the positive one BOOST_CHECK_GT(eIntersection[1].pathLength(), 0.); }; @@ -196,15 +186,13 @@ BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { // Check the validity of the intersection BOOST_CHECK(aIntersection[0].isValid()); // The status of this one should be on surface - BOOST_CHECK_EQUAL(aIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(aIntersection[0].status(), IntersectionStatus::reachable); // The intersection is at 4 mm distance CHECK_CLOSE_ABS(aIntersection[0].pathLength(), -4., s_onSurfaceTolerance); // There MUST be a second solution BOOST_CHECK(aIntersection[1].isValid()); // The other intersection MUST be reachable - BOOST_CHECK_EQUAL(aIntersection[1].status(), - Intersection3D::Status::onSurface); + BOOST_CHECK_EQUAL(aIntersection[1].status(), IntersectionStatus::onSurface); // Intersection from outside without chance of hitting the cylinder auto iIntersection = aCone->intersect(tgContext, outCone, perpXY, @@ -254,8 +242,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { // The intersection MUST be valid BOOST_CHECK(fIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(fIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(fIntersection[0].status(), IntersectionStatus::reachable); // The path length MUST be positive BOOST_CHECK_GT(fIntersection[0].pathLength(), 0.); // The intersection MUST be unique @@ -267,8 +254,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { // The intersection MUST be valid BOOST_CHECK(oIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(oIntersection[0].status(), - Intersection3D::Status::onSurface); + BOOST_CHECK_EQUAL(oIntersection[0].status(), IntersectionStatus::onSurface); // The path length MUST be positive BOOST_CHECK_LT(std::abs(oIntersection[0].pathLength()), s_onSurfaceTolerance); @@ -281,8 +267,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { // The intersection MUST be valid BOOST_CHECK(bIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(bIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(bIntersection[0].status(), IntersectionStatus::reachable); // The path length MUST be negative BOOST_CHECK_LT(bIntersection[0].pathLength(), 0.); // The intersection MUST be unique @@ -294,8 +279,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { // The intersection MUST NOT be valid BOOST_CHECK(!mIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(mIntersection[0].status(), - Intersection3D::Status::missed); + BOOST_CHECK_EQUAL(mIntersection[0].status(), IntersectionStatus::missed); // The path length MUST be negative BOOST_CHECK_GT(mIntersection[0].pathLength(), 0.); // The intersection MUST be unique @@ -308,7 +292,7 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { BOOST_CHECK(!iIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(iIntersection[0].status(), - Intersection3D::Status::unreachable); + IntersectionStatus::unreachable); // The intersection MUST be unique BOOST_CHECK(!iIntersection[1].isValid()); }; @@ -352,8 +336,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { // The intersection MUST be valid BOOST_CHECK(fIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(fIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(fIntersection[0].status(), IntersectionStatus::reachable); // The path length MUST be positive BOOST_CHECK_GT(fIntersection[0].pathLength(), 0.); // The intersection MUST be unique @@ -365,8 +348,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { // The intersection MUST be valid BOOST_CHECK(oIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(oIntersection[0].status(), - Intersection3D::Status::onSurface); + BOOST_CHECK_EQUAL(oIntersection[0].status(), IntersectionStatus::onSurface); // The path length MUST be positive BOOST_CHECK_LT(std::abs(oIntersection[0].pathLength()), s_onSurfaceTolerance); @@ -379,8 +361,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { // The intersection MUST be valid BOOST_CHECK(oIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(oIntersection[0].status(), - Intersection3D::Status::onSurface); + BOOST_CHECK_EQUAL(oIntersection[0].status(), IntersectionStatus::onSurface); // The path length MUST be positive BOOST_CHECK_LT(std::abs(oIntersection[0].pathLength()), s_onSurfaceTolerance); @@ -393,8 +374,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { // The intersection MUST be valid BOOST_CHECK(bIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(bIntersection[0].status(), - Intersection3D::Status::reachable); + BOOST_CHECK_EQUAL(bIntersection[0].status(), IntersectionStatus::reachable); // The path length MUST be negative BOOST_CHECK_LT(bIntersection[0].pathLength(), 0.); // The intersection MUST be unique @@ -406,8 +386,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { // The intersection MUST NOT be valid BOOST_CHECK(!mIntersection[0].isValid()); // The intersection MUST be reachable - BOOST_CHECK_EQUAL(mIntersection[0].status(), - Intersection3D::Status::missed); + BOOST_CHECK_EQUAL(mIntersection[0].status(), IntersectionStatus::missed); // The path length MUST be negative BOOST_CHECK_LT(mIntersection[0].pathLength(), 0.); // The intersection MUST be unique @@ -420,7 +399,7 @@ BOOST_AUTO_TEST_CASE(LineIntersectionTest) { BOOST_CHECK(!iIntersection[0].isValid()); // The intersection MUST be reachable BOOST_CHECK_EQUAL(iIntersection[0].status(), - Intersection3D::Status::unreachable); + IntersectionStatus::unreachable); // The intersection MUST be unique BOOST_CHECK(!iIntersection[1].isValid()); }; diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp index c61508a6d89..72ad444fd8a 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp @@ -89,7 +89,7 @@ class SurfaceStub : public RegularSurface { const BoundaryTolerance& /*boundaryTolerance*/, const ActsScalar /*tolerance*/) const final { Intersection3D stubIntersection(Vector3(20., 0., 0.), 20., - Intersection3D::Status::reachable); + IntersectionStatus::reachable); return SurfaceMultiIntersection( {stubIntersection, Intersection3D::invalid()}, this); } diff --git a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp index 41581b08b8d..bda4cad2da2 100644 --- a/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp +++ b/Tests/UnitTests/Core/Utilities/IntersectionTests.cpp @@ -32,19 +32,15 @@ class Object {}; BOOST_AUTO_TEST_CASE(IntersectionTest) { // a few valid intersections // all positively sortered - Intersection3D fIp(Vector3(0., 1., 0.), 1., - Intersection3D::Status::reachable); - Intersection3D sIp(Vector3(0., 2., 0.), 2., - Intersection3D::Status::reachable); - Intersection3D tIp(Vector3(0., 3., 0.), 3., - Intersection3D::Status::reachable); + Intersection3D fIp(Vector3(0., 1., 0.), 1., IntersectionStatus::reachable); + Intersection3D sIp(Vector3(0., 2., 0.), 2., IntersectionStatus::reachable); + Intersection3D tIp(Vector3(0., 3., 0.), 3., IntersectionStatus::reachable); BOOST_CHECK(fIp.isValid()); BOOST_CHECK(sIp.isValid()); BOOST_CHECK(tIp.isValid()); // a non-valid intersection - Intersection3D nIp(Vector3(3., 3., 0.), 3., - Intersection3D::Status::unreachable); + Intersection3D nIp(Vector3(3., 3., 0.), 3., IntersectionStatus::unreachable); BOOST_CHECK(!nIp.isValid()); std::vector fstpIntersections = {fIp, sIp, tIp}; @@ -82,12 +78,9 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { tfnsnpIntersections[2].pathLength()); /// let's make a bunch of negative solution - Intersection3D fIn(Vector3(0., -1., 0.), -1., - Intersection3D::Status::reachable); - Intersection3D sIn(Vector3(0., -2., 0.), -2., - Intersection3D::Status::reachable); - Intersection3D tIn(Vector3(0., -3., 0.), -3., - Intersection3D::Status::reachable); + Intersection3D fIn(Vector3(0., -1., 0.), -1., IntersectionStatus::reachable); + Intersection3D sIn(Vector3(0., -2., 0.), -2., IntersectionStatus::reachable); + Intersection3D tIn(Vector3(0., -3., 0.), -3., IntersectionStatus::reachable); std::vector tsfnIntersections = {tIn, sIn, fIn}; std::vector fstnIntersections = {fIn, sIn, tIn}; @@ -113,7 +106,7 @@ BOOST_AUTO_TEST_CASE(IntersectionTest) { BOOST_CHECK_EQUAL(pnsolutions[5].pathLength(), 3.); // sort intersections with zero path length - Intersection3D zI(Vector3(0., 0., 0.), 0., Intersection3D::Status::onSurface); + Intersection3D zI(Vector3(0., 0., 0.), 0., IntersectionStatus::onSurface); std::vector tszfpIntersections = {tIp, sIp, zI, fIp}; std::ranges::sort(tszfpIntersections, Intersection3D::pathLengthOrder); @@ -147,25 +140,25 @@ BOOST_AUTO_TEST_CASE(ObjectIntersectionTest) { using PlaneIntersection = ObjectIntersection; - PlaneIntersection int6(Intersection3D(Vector3(6., 0., 0.), 6., - Intersection3D::Status::reachable), - psf6.get()); - PlaneIntersection int7(Intersection3D(Vector3(7., 0., 0.), 7., - Intersection3D::Status::reachable), - psf7.get()); - PlaneIntersection int8(Intersection3D(Vector3(8., 0., 0.), 8., - Intersection3D::Status::reachable), - psf8.get()); - PlaneIntersection int9a(Intersection3D(Vector3(9., 0., 0.), 9., - Intersection3D::Status::reachable), - psf9.get()); + PlaneIntersection int6( + Intersection3D(Vector3(6., 0., 0.), 6., IntersectionStatus::reachable), + psf6.get()); + PlaneIntersection int7( + Intersection3D(Vector3(7., 0., 0.), 7., IntersectionStatus::reachable), + psf7.get()); + PlaneIntersection int8( + Intersection3D(Vector3(8., 0., 0.), 8., IntersectionStatus::reachable), + psf8.get()); + PlaneIntersection int9a( + Intersection3D(Vector3(9., 0., 0.), 9., IntersectionStatus::reachable), + psf9.get()); PlaneIntersection int9b( Intersection3D(Vector3(9., 1., 0.), std::hypot(9., 1.), - Intersection3D::Status::reachable), + IntersectionStatus::reachable), psf9.get()); - PlaneIntersection int10(Intersection3D(Vector3(10., 0., 0.), 10., - Intersection3D::Status::reachable), - psf10.get()); + PlaneIntersection int10( + Intersection3D(Vector3(10., 0., 0.), 10., IntersectionStatus::reachable), + psf10.get()); std::vector firstSet = {int6, int7, int9b, int10}; std::vector secondSet = {int8, int9a, int9b, int10}; From f17f64094e958d8821921e117e06cb00c997844c Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Sun, 24 Nov 2024 09:12:28 +0100 Subject: [PATCH 6/6] fix: boost progress include fails on next boost major release (#3896) Fix for the rare case, that boost will make a major release. --- Examples/Scripts/MaterialMapping/MaterialComposition.cpp | 2 +- Examples/Scripts/TrackingPerformance/TrackSummary.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Scripts/MaterialMapping/MaterialComposition.cpp b/Examples/Scripts/MaterialMapping/MaterialComposition.cpp index 348a4912f29..7e7731af846 100644 --- a/Examples/Scripts/MaterialMapping/MaterialComposition.cpp +++ b/Examples/Scripts/MaterialMapping/MaterialComposition.cpp @@ -24,7 +24,7 @@ #include #define BOOST_AVAILABLE 1 -#if ((BOOST_VERSION / 100) % 1000) <= 71 +#if BOOST_VERSION < 107200 // Boost <=1.71 and lower do not have progress_display.hpp as a replacement yet #include diff --git a/Examples/Scripts/TrackingPerformance/TrackSummary.cpp b/Examples/Scripts/TrackingPerformance/TrackSummary.cpp index deba72311d5..0e806ff0a90 100644 --- a/Examples/Scripts/TrackingPerformance/TrackSummary.cpp +++ b/Examples/Scripts/TrackingPerformance/TrackSummary.cpp @@ -27,7 +27,7 @@ #include #define BOOST_AVAILABLE 1 -#if ((BOOST_VERSION / 100) % 1000) <= 71 +#if BOOST_VERSION < 107200 // Boost <=1.71 and lower do not have progress_display.hpp as a replacement yet #include