From b30f8dfe86e2ed940fac02bbe54efdfe2cddaac0 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Sat, 23 Nov 2024 10:18:35 +0100 Subject: [PATCH] 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; };