Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion Core/include/Acts/Propagator/SurfaceCollector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "Acts/EventData/BoundTrackParameters.hpp"
#include "Acts/Propagator/PropagatorState.hpp"
#include "Acts/Surfaces/Surface.hpp"

Expand Down Expand Up @@ -37,7 +38,7 @@ struct SurfaceSelector {
///
/// @param surface is the test surface
/// @return true if surface meets selection criteria
bool operator()(const Acts::Surface& surface) const {
bool operator()(const Surface& surface) const {
if (selectSensitive && surface.isSensitive()) {
return true;
}
Expand Down Expand Up @@ -126,4 +127,58 @@ struct SurfaceCollector {
}
};

/// Collector of the bound track parameters. Every time when the
/// propagator reaches a surface, and the surface passes the selection,
/// the @ref BoundTrackParameters are recorded on this surface.
/// @tparam Selector: Any surface selector class implementation
/// to select the parameters on surface for record
template <typename Selector = SurfaceSelector>
struct BoundParameterRecorder {
/// The selector used for this surface
Selector selector;

/// Type alias for collector result type
using result_type = std::vector<BoundTrackParameters>;

/// Collector action for the ActionList of the Propagator
/// It checks if the propagator state has a current surface,
/// in which case the action is performed:
/// - it records the bound track parameters
///
/// @tparam propagator_state_t is the type of Propagator state
/// @tparam stepper_t Type of the stepper used for the propagation
/// @tparam navigator_t Type of the navigator used for the propagation
///
/// @param [in,out] state is the mutable stepper state object
/// @param [in] stepper The stepper in use
/// @param [in] navigator The navigator in use
/// @param [in,out] result is the mutable result object
/// @param logger a logger instance
/// @return Result indicating success or failure
template <typename propagator_state_t, typename stepper_t,
typename navigator_t>
Result<void> act(propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, result_type& result,
const Logger& logger) const {
if (state.stage == PropagatorStage::postPropagation) {
return {};
}

auto currentSurface = navigator.currentSurface(state.navigation);

// The current surface has been assigned by the navigator
if (currentSurface && selector(*currentSurface)) {
auto res = stepper.boundState(state.stepping, *currentSurface);
if (res.ok()) {
result.emplace_back(std::get<0>(*res));
}

// Screen output
ACTS_VERBOSE("Collect surface " << currentSurface->geometryId());
}

return {};
}
};

} // namespace Acts
28 changes: 27 additions & 1 deletion Tests/IntegrationTests/NavigatorConsistency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const double Bz = 2_T;
auto bField = std::make_shared<ConstantBField>(Vector3{0, 0, Bz});

using TestSurfaceCollector = SurfaceCollector<SurfaceSelector>;
using ParamRecorder = BoundParameterRecorder<SurfaceSelector>;

std::vector<GeometryIdentifier> collectRelevantGeoIds(
const TestSurfaceCollector::result_type& surfaceHits) {
Expand Down Expand Up @@ -74,7 +75,7 @@ void runSelfConsistencyTest(const propagator_t& prop,
const BoundTrackParameters& start,
const Logger& logger) {
// Actor list
using ActorList = ActorList<TestSurfaceCollector>;
using ActorList = ActorList<TestSurfaceCollector, ParamRecorder>;
using Options = typename propagator_t::template Options<ActorList>;

// forward surface test
Expand All @@ -88,10 +89,35 @@ void runSelfConsistencyTest(const propagator_t& prop,
fwdSurfaceCollector.selector.selectMaterial = true;
fwdSurfaceCollector.selector.selectPassive = true;

auto& paramRecorder = fwdOptions.actorList.template get<ParamRecorder>();
paramRecorder.selector.selectSensitive = true;
paramRecorder.selector.selectMaterial = true;
paramRecorder.selector.selectPassive = true;

ACTS_DEBUG(">>> Forward Propagation : start.");
auto fwdResult = prop.propagate(start, fwdOptions).value();
auto fwdSurfaceHits =
fwdResult.template get<TestSurfaceCollector::result_type>().collected;

auto fwdTrackRecords = fwdResult.template get<ParamRecorder::result_type>();

BOOST_CHECK_EQUAL(fwdTrackRecords.size(), fwdSurfaceHits.size());
for (const auto& boundPars :
fwdResult.template get<ParamRecorder::result_type>()) {
BOOST_CHECK_EQUAL(boundPars.particleHypothesis(),
start.particleHypothesis());
BOOST_CHECK_EQUAL(boundPars.covariance().has_value(),
start.covariance().has_value());
BOOST_CHECK_EQUAL(
std::ranges::any_of(
fwdSurfaceHits,
[&](const Acts::SurfaceHit& hit) {
return hit.surface ==
boundPars.referenceSurface().getSharedPtr().get();
}),
true);
}

auto fwdSurfaces = collectRelevantGeoIds(
fwdResult.template get<TestSurfaceCollector::result_type>());

Expand Down
Loading