Skip to content

Commit

Permalink
Merge branch 'main' into cylindervolumes
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 23, 2024
2 parents 2f84c12 + b30f8df commit c75d96b
Show file tree
Hide file tree
Showing 75 changed files with 1,492 additions and 402 deletions.
49 changes: 49 additions & 0 deletions Core/include/Acts/EventData/detail/TrackParametersUtils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#pragma once

#include "Acts/EventData/GenericBoundTrackParameters.hpp"
#include "Acts/EventData/TrackParametersConcept.hpp"

namespace Acts::detail {

/// @brief Shorthand for Bound or Free track parameters
template <class parameters_t>
concept isBoundOrFreeTrackParams =
Acts::FreeTrackParametersConcept<parameters_t> ||
Acts::BoundTrackParametersConcept<parameters_t>;

/// @brief Shorthand for GenericBoundTrackParameters
template <class parameters_t>
concept isGenericBoundTrackParams =
std::same_as<parameters_t, Acts::GenericBoundTrackParameters<
typename parameters_t::ParticleHypothesis>>;

/// @brief Concept that restricts the type of the
/// accumulation grid cell
template <typename grid_t>
concept TrackParamsGrid = requires {
typename grid_t::value_type::first_type;
typename grid_t::value_type::second_type;

requires isBoundOrFreeTrackParams<
typename grid_t::value_type::first_type::element_type>;
requires isBoundOrFreeTrackParams<
typename grid_t::value_type::second_type::element_type>;

requires requires(typename grid_t::value_type val) {
{
val.first
} -> std::same_as<
std::shared_ptr<typename decltype(val.first)::element_type>&>;
{ val.second } -> std::same_as<decltype(val.first)&>;
};
};

} // namespace Acts::detail
16 changes: 8 additions & 8 deletions Core/include/Acts/Geometry/SurfaceArrayCreator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,35 +381,35 @@ class SurfaceArrayCreator {
Axis<AxisType::Equidistant, bdtB> axisB(pAxisB.min, pAxisB.max, pAxisB.nBins);

using SGL = SurfaceArray::SurfaceGridLookup<decltype(axisA), decltype(axisB)>;
ptr = std::unique_ptr<ISGL>(static_cast<ISGL*>(
new SGL(globalToLocal, localToGlobal, std::make_tuple(axisA, axisB), {pAxisA.bValue, pAxisB.bValue})));
ptr = std::make_unique<SGL>(
globalToLocal, localToGlobal, std::pair{axisA, axisB}, std::vector{pAxisA.bValue, pAxisB.bValue});

} else if (pAxisA.bType == equidistant && pAxisB.bType == arbitrary) {

Axis<AxisType::Equidistant, bdtA> axisA(pAxisA.min, pAxisA.max, pAxisA.nBins);
Axis<AxisType::Variable, bdtB> axisB(pAxisB.binEdges);

using SGL = SurfaceArray::SurfaceGridLookup<decltype(axisA), decltype(axisB)>;
ptr = std::unique_ptr<ISGL>(static_cast<ISGL*>(
new SGL(globalToLocal, localToGlobal, std::make_tuple(axisA, axisB), {pAxisA.bValue, pAxisB.bValue})));
ptr = std::make_unique<SGL>(
globalToLocal, localToGlobal, std::pair{axisA, axisB}, std::vector{pAxisA.bValue, pAxisB.bValue});

} else if (pAxisA.bType == arbitrary && pAxisB.bType == equidistant) {

Axis<AxisType::Variable, bdtA> axisA(pAxisA.binEdges);
Axis<AxisType::Equidistant, bdtB> axisB(pAxisB.min, pAxisB.max, pAxisB.nBins);

using SGL = SurfaceArray::SurfaceGridLookup<decltype(axisA), decltype(axisB)>;
ptr = std::unique_ptr<ISGL>(static_cast<ISGL*>(
new SGL(globalToLocal, localToGlobal, std::make_tuple(axisA, axisB), {pAxisA.bValue, pAxisB.bValue})));
ptr = std::make_unique<SGL>(
globalToLocal, localToGlobal, std::pair{axisA, axisB}, std::vector{pAxisA.bValue, pAxisB.bValue});

} else /*if (pAxisA.bType == arbitrary && pAxisB.bType == arbitrary)*/ {

Axis<AxisType::Variable, bdtA> axisA(pAxisA.binEdges);
Axis<AxisType::Variable, bdtB> axisB(pAxisB.binEdges);

using SGL = SurfaceArray::SurfaceGridLookup<decltype(axisA), decltype(axisB)>;
ptr = std::unique_ptr<ISGL>(static_cast<ISGL*>(
new SGL(globalToLocal, localToGlobal, std::make_tuple(axisA, axisB), {pAxisA.bValue, pAxisB.bValue})));
ptr = std::make_unique<SGL>(
globalToLocal, localToGlobal, std::pair{axisA, axisB}, std::vector{pAxisA.bValue, pAxisB.bValue});
}
// clang-format on

Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Navigation/DetectorNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Propagator/AtlasStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<const MagneticFieldProvider> bField)
Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Propagator/DirectNavigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 4 additions & 1 deletion Core/include/Acts/Propagator/EigenStepper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -164,6 +164,9 @@ class EigenStepper {
/// k_i elements of the momenta
std::array<double, 4> kQoP{};
} stepData;

/// Statistics of the stepper
StepperStatistics statistics;
};

/// Constructor requires knowledge of the detector's magnetic field
Expand Down
15 changes: 14 additions & 1 deletion Core/include/Acts/Propagator/EigenStepper.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -259,7 +260,9 @@ Acts::Result<double> Acts::EigenStepper<E>::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();
Expand All @@ -268,6 +271,8 @@ Acts::Result<double> Acts::EigenStepper<E>::step(
break;
}

++state.stepping.statistics.nRejectedSteps;

const double stepSizeScaling = calcStepSizeScaling(errorEstimate);
h *= stepSizeScaling;

Expand Down Expand Up @@ -351,6 +356,14 @@ Acts::Result<double> Acts::EigenStepper<E>::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());
Expand Down
4 changes: 4 additions & 0 deletions Core/include/Acts/Propagator/MultiEigenStepperLoop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -219,6 +220,9 @@ class MultiEigenStepperLoop : public EigenStepper<extension_t> {
/// reached a surface
std::optional<std::size_t> stepCounterAfterFirstComponentOnSurface;

/// The stepper statistics
StepperStatistics statistics;

/// No default constructor is provided
State() = delete;

Expand Down
11 changes: 7 additions & 4 deletions Core/include/Acts/Propagator/Navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -772,8 +777,6 @@ class Navigator {
/// @return boolean return triggers exit to stepper
template <typename propagator_state_t, typename stepper_t>
bool targetLayers(propagator_state_t& state, const stepper_t& stepper) const {
using namespace UnitLiterals;

if (state.navigation.navigationBreak) {
return false;
}
Expand Down
26 changes: 26 additions & 0 deletions Core/include/Acts/Propagator/NavigatorStatistics.hpp
Original file line number Diff line number Diff line change
@@ -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 <cstddef>

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
3 changes: 3 additions & 0 deletions Core/include/Acts/Propagator/Propagator.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ void Acts::Propagator<S, N>::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 <typename derived_t>
Expand Down
4 changes: 4 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,9 @@ struct PropagatorResult : private detail::Extendable<result_list...> {

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

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

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
Loading

0 comments on commit c75d96b

Please sign in to comment.