Skip to content
Draft
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
87 changes: 87 additions & 0 deletions Core/include/Acts/EventData/MeasurementConcept.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// 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/Definitions/Algebra.hpp"

#include <concepts>
#include <cstdint>
#include <ranges>
#include <type_traits>
#include <utility>

namespace Acts {

namespace detail {

/// The parameter vector type of a measurement like type
/// @tparam T the measurement like type
template <typename T>
using MeasurementParametersType =
std::decay_t<decltype(std::declval<const T&>().parameters())>;

/// The covariance matrix type of a measurement like type
/// @tparam T the measurement like type
template <typename T>
using MeasurementCovarianceType =
std::decay_t<decltype(std::declval<const T&>().covariance())>;

} // namespace detail

/// Requirements on a calibrated measurement expressed in a subspace of a
/// parameter space.
///
/// This is the contract between a track finder and whatever the client uses to
/// represent a calibrated measurement. It is deliberately minimal so that
/// existing measurement proxies satisfy it without a copy.
///
/// The dimension may be known at compile time or only at runtime, see
/// @ref Acts::StaticMeasurementConcept.
///
/// @tparam T the measurement like type
template <typename T>
concept MeasurementConcept = requires(const T& measurement) {
/// The measurement dimension
{ measurement.size() } -> std::integral;
/// The parameters of the parameter space the measurement constrains,
/// exactly `size()` of them
{ measurement.subspaceIndices() } -> std::ranges::sized_range;
/// The measured values
{ measurement.parameters() };
/// The covariance of the measured values
{ measurement.covariance() };

requires std::convertible_to<
std::ranges::range_value_t<decltype(measurement.subspaceIndices())>,
std::uint8_t>;
requires detail::MeasurementParametersType<T>::ColsAtCompileTime == 1;
requires detail::MeasurementParametersType<T>::RowsAtCompileTime ==
detail::MeasurementCovarianceType<T>::RowsAtCompileTime;
};

/// The dimension of a measurement if it is known at compile time,
/// `Eigen::Dynamic` otherwise.
///
/// @tparam measurement_t the measurement type
template <MeasurementConcept measurement_t>
constexpr int MeasurementSizeAtCompileTime =
detail::MeasurementParametersType<measurement_t>::RowsAtCompileTime;

/// A @ref Acts::MeasurementConcept whose dimension is known at compile time.
///
/// Algorithms can use this to skip the runtime dispatch over the measurement
/// dimension.
///
/// @tparam measurement_t the measurement type
template <typename measurement_t>
concept StaticMeasurementConcept =
MeasurementConcept<measurement_t> &&
(MeasurementSizeAtCompileTime<measurement_t> != Eigen::Dynamic);

} // namespace Acts
23 changes: 19 additions & 4 deletions Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <functional>
#include <limits>
#include <memory>
#include <stdexcept>
#include <type_traits>

namespace Acts {
Expand Down Expand Up @@ -616,10 +617,16 @@ class CombinatorialKalmanFilter {
// extend trajectory with measurements associated to the current surface
// which may create extra trajectory branches if more than one
// measurement is selected.
tsRes = extensions.createTrackStates(
state.geoContext, *calibrationContextPtr, surface, boundState,
prevTip, result.trackStateCandidates, *result.trackStates,
logger());
if (extensions.trackStateCreator.connected()) {
tsRes = extensions.trackStateCreator(
state.geoContext, *calibrationContextPtr, surface, boundState,
prevTip, *result.trackStates, logger());
} else {
tsRes = extensions.createTrackStates(
state.geoContext, *calibrationContextPtr, surface, boundState,
prevTip, result.trackStateCandidates, *result.trackStates,
logger());
}
}

if (tsRes.ok() && !(*tsRes).empty()) {
Expand Down Expand Up @@ -1141,6 +1148,14 @@ class CombinatorialKalmanFilter {
Result<std::vector<TrackProxy>> findTracks(
const BoundTrackParameters& initialParameters, const Options& tfOptions,
track_container_t& trackContainer, TrackProxy rootBranch) const {
if (tfOptions.extensions.trackStateCreator.connected() ==
tfOptions.extensions.createTrackStates.connected()) {
throw std::invalid_argument(
"CombinatorialKalmanFilter: exactly one of "
"`extensions.trackStateCreator` and the deprecated "
"`extensions.createTrackStates` has to be connected");
}

// Create the ActorList
using CombinatorialKalmanFilterActor = Actor;
using Actors = ActorList<CombinatorialKalmanFilterActor>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,39 @@ struct CombinatorialKalmanFilterExtensions {
traj_t& trajectory, const Logger& logger)>;

/// The delegate to create new track states.
/// @note a reference implementation can be found in @ref TrackStateCreator
/// which makes uses of @ref MeasurementSelector and SourceLinkAccessor
/// @deprecated Connect @ref trackStateCreator instead. This variant only
/// exists so that clients with their own implementation of this signature
/// keep working; it hands out a scratch buffer for temporary track states,
/// which a creator that does not push all measurements through the track
/// EDM has no use for. No implementation of it ships with ACTS anymore.
TrackStateCreator createTrackStates;

/// @brief Delegate the extension of the trajectory onto the given surface to
/// an external unit.
///
/// Same contract as @ref TrackStateCreator, but without the scratch buffer
/// for temporary track states.
///
/// @param geoContext The current geometry context
/// @param calibrationContext pointer to the current calibration context
/// @param surface the surface at which new track states are to be created
/// @param boundState the current bound state of the trajectory
/// @param prevTip Index pointing at previous trajectory state (i.e. tip)
/// @param trajectory the trajectory to which the new states are to be added
/// @param logger a logger for messages
/// @return indices of new track states which extend the trajectory given by prevTip
using TrackStateCreatorDelegate =
Delegate<Result<CkfTypes::BranchVector<TrackIndexType>>(
const GeometryContext& geoContext,
const CalibrationContext& calibrationContext, const Surface& surface,
const CkfTypes::BoundState& boundState, TrackIndexType prevTip,
traj_t& trajectory, const Logger& logger)>;

/// The delegate to create new track states.
/// @note derive from @ref TrackStateCreatorBase to implement one
/// @note exactly one of this and @ref createTrackStates has to be connected
TrackStateCreatorDelegate trackStateCreator;

// The following options are only relevant if a multi stepper is used

/// Type alias for component reducer delegate function
Expand Down
21 changes: 19 additions & 2 deletions Core/include/Acts/TrackFinding/MeasurementSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Acts/Geometry/GeometryHierarchyMap.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/TrackFinding/CombinatorialKalmanFilterError.hpp"
#include "Acts/Utilities/Diagnostics.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/Result.hpp"

Expand All @@ -26,12 +27,20 @@

namespace Acts {

ACTS_PUSH_IGNORE_DEPRECATED()

/// Selection cuts for associating measurements with predicted track
/// parameters on a surface.
///
/// The default configuration only takes the best matching measurement without a
/// cut on the local chi2.
struct MeasurementSelectorCuts {
///
/// @deprecated Goes away together with @ref MeasurementSelector. A creator
/// derived from @ref TrackStateCreatorBase carries whatever cuts its
/// selection needs.
struct [[deprecated(
"Carry the cuts in a class derived from Acts::TrackStateCreatorBase "
"instead")]] MeasurementSelectorCuts {

Check warning on line 43 in Core/include/Acts/TrackFinding/MeasurementSelector.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=acts-project_acts&issues=AZ_rI9axPN96__WvuG4j&open=AZ_rI9axPN96__WvuG4j&pullRequest=5849
/// bins in |eta| to specify variable selections
std::vector<double> etaBins{};
/// Maximum local chi2 contribution to classify as measurement.
Expand All @@ -51,7 +60,13 @@
/// If there is no compatible measurement, the measurement with the minimum
/// chi2 will be selected and the status will be tagged as an outlier
///
class MeasurementSelector {
/// @deprecated Implement the selection in a @ref TrackStateCreatorBase
/// instead. Selecting on track states forces every measurement on a surface
/// through the track EDM, and the geometry and eta binned cut lookup here is
/// not used by anything ACTS ships.
class [[deprecated(
"Implement the selection in a class derived from "
"Acts::TrackStateCreatorBase instead")]] MeasurementSelector {

Check warning on line 69 in Core/include/Acts/TrackFinding/MeasurementSelector.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=acts-project_acts&issues=AZ_rI9axPN96__WvuG4k&open=AZ_rI9axPN96__WvuG4k&pullRequest=5849
public:
/// Geometry-dependent cut configuration.
///
Expand Down Expand Up @@ -123,6 +138,8 @@
InternalConfig m_config;
};

ACTS_POP_IGNORE_DEPRECATED()

} // namespace Acts

#include "MeasurementSelector.ipp"
4 changes: 4 additions & 0 deletions Core/include/Acts/TrackFinding/MeasurementSelector.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace Acts {

ACTS_PUSH_IGNORE_DEPRECATED()

template <typename traj_t>
Result<
std::pair<typename std::vector<typename traj_t::TrackStateProxy>::iterator,
Expand Down Expand Up @@ -123,4 +125,6 @@ MeasurementSelector::select(
candidates.begin() + std::min(cuts.numMeasurements, passedCandidates)));
}

ACTS_POP_IGNORE_DEPRECATED()

} // namespace Acts
8 changes: 7 additions & 1 deletion Core/include/Acts/TrackFinding/TrackStateCreator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ namespace Acts {
/// may become big. Thus, it is advisable to copy selected tracks and their
/// track states to a separate container after each track finding step.
///
/// @deprecated Derive from @ref TrackStateCreatorBase and connect
/// @ref CombinatorialKalmanFilterExtensions::trackStateCreator instead. This
/// runs its selection on temporary track states, so every measurement on a
/// surface has to pass through the track EDM to be selected on.
///
template <typename source_link_iterator_t, typename track_container_t>
struct TrackStateCreator {
struct [[deprecated("Derive from Acts::TrackStateCreatorBase instead")]]
TrackStateCreator {
/// Type alias for result of track states creation operation
using TrackStatesResult =
Acts::Result<CkfTypes::BranchVector<TrackIndexType>>;
Expand Down
Loading
Loading