Skip to content

Commit

Permalink
feat: Add statistics to propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Aug 22, 2024
1 parent ecad6fd commit 5b5a8cd
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 4 deletions.
37 changes: 37 additions & 0 deletions Core/include/Acts/Propagator/NavigatorStatistics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 <cstddef>

namespace Acts {

struct NavigatorStatistics {
std::size_t nRenavigations = 0;

std::size_t nVolumeSwitches = 0;

std::size_t nBoundaryCandidates = 0;
std::size_t nBoundaryHits = 0;
std::size_t nBoundaryDiscards = 0;

std::size_t nLayerCandidates = 0;
std::size_t nLayerHits = 0;
std::size_t nLayerDiscards = 0;

std::size_t nSurfaceCandidates = 0;
std::size_t nSurfaceHits = 0;
std::size_t nSurfaceDiscards = 0;

std::size_t nTotalCandidates = 0;
std::size_t nTotalHits = 0;
std::size_t nTotalDiscards = 0;
};

} // namespace Acts
2 changes: 2 additions & 0 deletions Core/include/Acts/Propagator/Propagator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ void Acts::Propagator<S, N>::moveStateToResult(propagator_state_t& state,

result.steps = state.steps;
result.pathLength = state.pathLength;

result.statistics = state.statistics;
}

template <typename derived_t>
Expand Down
3 changes: 3 additions & 0 deletions Core/include/Acts/Propagator/PropagatorResult.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Propagator/PropagatorStatistics.hpp"
#include "Acts/Utilities/detail/Extendable.hpp"

#include <optional>
Expand Down Expand Up @@ -36,6 +37,8 @@ struct PropagatorResult : private detail::Extendable<result_list...> {

/// Signed distance over which the parameters were propagated
double pathLength = 0.;

PropagatorStatistics statistics;
};

} // namespace Acts
4 changes: 4 additions & 0 deletions Core/include/Acts/Propagator/PropagatorState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Propagator/PropagatorStatistics.hpp"
#include "Acts/Utilities/detail/Extendable.hpp"

#include <functional>
Expand Down Expand Up @@ -72,6 +73,9 @@ struct PropagatorState : private detail::Extendable<extension_state_t...> {

/// Signed distance over which the parameters were propagated
double pathLength = 0.;

/// Statistics of the propagation
PropagatorStatistics statistics;
};

} // namespace Acts
21 changes: 21 additions & 0 deletions Core/include/Acts/Propagator/PropagatorStatistics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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/Propagator/NavigatorStatistics.hpp>
#include <Acts/Propagator/StepperStatistics.hpp>

namespace Acts {

struct PropagatorStatistics {
StepperStatistics stepping;
NavigatorStatistics navigation;
};

} // namespace Acts
24 changes: 24 additions & 0 deletions Core/include/Acts/Propagator/StepperStatistics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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 <cstddef>

namespace Acts {

struct StepperStatistics {
std::size_t nAttemptedSteps = 0;
std::size_t nFailedSteps = 0;
std::size_t nSuccessfulSteps = 0;

double pathLength = 0;
double absolutePathLength = 0;
};

} // namespace Acts
5 changes: 1 addition & 4 deletions Examples/Scripts/Python/propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,5 @@ def runPropagation(trackingGeometry, field, outputDir, s=None, decorators=[]):
os.makedirs(os.getcwd() + "/propagation", exist_ok=True)

runPropagation(
trackingGeometry,
field,
os.getcwd() + "/propagation",
decorators=contextDecorators,
trackingGeometry, field, os.getcwd() + "/propagation", decorators=contextDecorators
).run()

0 comments on commit 5b5a8cd

Please sign in to comment.