Skip to content

Commit

Permalink
refactor: Large GSF refactoring (#1629)
Browse files Browse the repository at this point in the history
This is a major refactoring of the GSF. It changes the propagation structure, and the way the GSF records states to the `MultiTrajectory`. It also removes the smoothing code, since it is not really useful at the moment, as the component states are not exported anyways.

should be merged after #1609 and #1627 and #1628 

We should add performance monitoring in this or a later PR

Fixes #1666
  • Loading branch information
benjaminhuth committed Nov 11, 2022
1 parent 90a81f4 commit 8fae9ef
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 653 deletions.
15 changes: 4 additions & 11 deletions Core/include/Acts/Propagator/MultiEigenStepperLoop.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ Result<double> MultiEigenStepperLoop<E, R, A>::step(
const auto& logger = state.options.logger;
State& stepping = state.stepping;

// It is not possible to remove components from the vector, since the
// GSF actor relies on the fact that the ordering and number of
// components does not change
auto invalidateComponent = [](auto& cmp) {
cmp.status = Intersection3D::Status::missed;
cmp.weight = 0.0;
cmp.state.pars.template segment<3>(eFreeDir0) = Vector3::Zero();
};

// Lambda for reweighting the components
auto reweight = [](auto& cmps) {
ActsScalar sumOfWeights = 0.0;
Expand All @@ -147,10 +138,11 @@ Result<double> MultiEigenStepperLoop<E, R, A>::step(
m_stepLimitAfterFirstComponentOnSurface) {
for (auto& cmp : stepping.components) {
if (cmp.status != Intersection3D::Status::onSurface) {
invalidateComponent(cmp);
cmp.status = Intersection3D::Status::missed;
}
}

removeMissedComponents(stepping);
reweight(stepping.components);

ACTS_VERBOSE("Stepper performed "
Expand Down Expand Up @@ -194,12 +186,13 @@ Result<double> MultiEigenStepperLoop<E, R, A>::step(
accumulatedPathLength += component.weight * results.back()->value();
} else {
++errorSteps;
invalidateComponent(component);
component.status = Intersection3D::Status::missed;
}
}

// Since we have invalidated some components, we need to reweight
if (errorSteps > 0) {
removeMissedComponents(stepping);
reweight(stepping.components);
}

Expand Down
27 changes: 27 additions & 0 deletions Core/include/Acts/Propagator/MultiStepperAborters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ namespace Acts {
struct MultiStepperSurfaceReached {
MultiStepperSurfaceReached() = default;

/// If this is set, we are also happy if the mean of the components is on the
/// surface. How the averaging is performed depends on the stepper
/// implementation
bool averageOnSurface = true;

/// A configurable tolerance within which distance to the intersection we
/// consider the surface as reached. Has no effect if averageOnSurface is
/// false
double averageOnSurfaceTolerance = 0.2;

/// boolean operator for abort condition without using the result
///
/// @tparam propagator_state_t Type of the propagator state
Expand All @@ -40,6 +50,7 @@ struct MultiStepperSurfaceReached {
template <typename propagator_state_t, typename stepper_t>
bool operator()(propagator_state_t& state, const stepper_t& stepper,
const Surface& targetSurface) const {
const auto& logger = state.options.logger;
bool reached = true;
const auto oldCurrentSurface = state.navigation.currentSurface;

Expand All @@ -52,6 +63,22 @@ struct MultiStepperSurfaceReached {
}
}

// However, if mean of all is on surface, we are happy as well
if (averageOnSurface) {
const auto sIntersection = targetSurface.intersect(
state.geoContext, stepper.position(state.stepping),
state.stepping.navDir * stepper.direction(state.stepping), true);

if (sIntersection.intersection.status ==
Intersection3D::Status::onSurface or
sIntersection.intersection.pathLength < averageOnSurfaceTolerance) {
ACTS_VERBOSE("Reached target in average mode");
state.navigation.currentSurface = &targetSurface;
state.navigation.targetReached = true;
return true;
}
}

// These values are changed by the single component aborters but must be
// reset if not all components are on the target
if (!reached) {
Expand Down

0 comments on commit 8fae9ef

Please sign in to comment.