Skip to content

Commit

Permalink
refactor!: Remove input_track_t template parameters (acts-project#2880
Browse files Browse the repository at this point in the history
)

This PR should completely remove the use of `input_track_t`.

Part of:
- acts-project#2842 

Blocked by:
- acts-project#2878
  • Loading branch information
paulgessinger authored and LaraCalic committed Feb 10, 2024
1 parent 30795bb commit f496bb0
Show file tree
Hide file tree
Showing 36 changed files with 206 additions and 461 deletions.
38 changes: 3 additions & 35 deletions Core/include/Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace Acts {
/// @tparam vfitter_t Vertex fitter type
template <typename vfitter_t = DummyVertexFitter<>>
class AdaptiveGridDensityVertexFinder {
using InputTrack_t = typename vfitter_t::InputTrack_t;
using GridDensity = AdaptiveGridTrackDensity;

public:
Expand Down Expand Up @@ -95,45 +94,16 @@ class AdaptiveGridDensityVertexFinder {
const VertexingOptions& vertexingOptions,
State& state) const;

/// @brief Constructor used if InputTrack_t type == BoundTrackParameters
/// @brief Constructor for user-defined InputTrack type
///
/// @param cfg Configuration object
template <
typename T = InputTrack_t,
std::enable_if_t<std::is_same<T, BoundTrackParameters>::value, int> = 0>
AdaptiveGridDensityVertexFinder(const Config& cfg)
: m_cfg(cfg), m_extractParameters([](const InputTrack& params) {
return *params.as<BoundTrackParameters>();
}) {}

/// @brief Default constructor used if InputTrack_t type ==
/// BoundTrackParameters
template <
typename T = InputTrack_t,
std::enable_if_t<std::is_same<T, BoundTrackParameters>::value, int> = 0>
AdaptiveGridDensityVertexFinder()
: m_extractParameters([](T params) { return params; }) {}

/// @brief Constructor for user-defined InputTrack_t type =!
/// BoundTrackParameters
///
/// @param cfg Configuration object
/// @param func Function extracting BoundTrackParameters from InputTrack_t
/// object
/// @param func Function extracting BoundTrackParameters from InputTrack
/// object
AdaptiveGridDensityVertexFinder(
const Config& cfg,
const std::function<BoundTrackParameters(const InputTrack&)>& func)
: m_cfg(cfg), m_extractParameters(func) {}

/// @brief Constructor for user-defined InputTrack_t type =!
/// BoundTrackParameters with default Config object
///
/// @param func Function extracting BoundTrackParameters from InputTrack_t
/// object
AdaptiveGridDensityVertexFinder(
const std::function<BoundTrackParameters(const InputTrack&)>& func)
: m_extractParameters(func) {}

private:
/// @brief Checks if a track passes the selection criteria for seeding
///
Expand All @@ -146,8 +116,6 @@ class AdaptiveGridDensityVertexFinder {
const Config m_cfg;

/// @brief Function to extract track parameters,
/// InputTrack_t objects are BoundTrackParameters by default, function to be
/// overwritten to return BoundTrackParameters for other InputTrack_t objects.
std::function<BoundTrackParameters(const InputTrack&)> m_extractParameters;
};

Expand Down
29 changes: 4 additions & 25 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace Acts {
template <typename vfitter_t, typename sfinder_t>
class AdaptiveMultiVertexFinder {
using Propagator_t = typename vfitter_t::Propagator_t;
using InputTrack_t = typename vfitter_t::InputTrack_t;
using Linearizer_t = typename vfitter_t::Linearizer_t;
using FitterState_t = typename vfitter_t::State;
using SeedFinderState_t = typename sfinder_t::State;
Expand All @@ -59,8 +58,8 @@ class AdaptiveMultiVertexFinder {
/// @param lin Track linearizer
/// @param bIn Input magnetic field
Config(vfitter_t fitter, sfinder_t sfinder,
ImpactPointEstimator<InputTrack_t, Propagator_t> ipEst,
Linearizer_t lin, std::shared_ptr<const MagneticFieldProvider> bIn)
ImpactPointEstimator<Propagator_t> ipEst, Linearizer_t lin,
std::shared_ptr<const MagneticFieldProvider> bIn)
: vertexFitter(std::move(fitter)),
seedFinder(std::move(sfinder)),
ipEstimator(std::move(ipEst)),
Expand All @@ -74,7 +73,7 @@ class AdaptiveMultiVertexFinder {
sfinder_t seedFinder;

// ImpactPointEstimator
ImpactPointEstimator<InputTrack_t, Propagator_t> ipEstimator;
ImpactPointEstimator<Propagator_t> ipEstimator;

// Track linearizer
Linearizer_t linearizer;
Expand Down Expand Up @@ -168,29 +167,11 @@ class AdaptiveMultiVertexFinder {
/// State struct for fulfilling interface
struct State {};

/// @brief Constructor used if InputTrack_t type == BoundTrackParameters
///
/// @param cfg Configuration object
/// @param logger The logging instance
template <
typename T = InputTrack_t,
std::enable_if_t<std::is_same<T, BoundTrackParameters>::value, int> = 0>
AdaptiveMultiVertexFinder(Config cfg,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFinder",
Logging::INFO))
: m_cfg(std::move(cfg)),
m_extractParameters([](const InputTrack& params) {
return *params.as<BoundTrackParameters>();
}),
m_logger(std::move(logger)) {}

/// @brief Constructor for user-defined InputTrack_t type !=
/// BoundTrackParameters
///
/// @param cfg Configuration object
/// @param func Function extracting BoundTrackParameters from InputTrack_t
/// object
/// @param func Function extracting BoundTrackParameters from InputTrack
/// @param logger The logging instance
AdaptiveMultiVertexFinder(
Config cfg, std::function<BoundTrackParameters(const InputTrack&)> func,
Expand Down Expand Up @@ -219,8 +200,6 @@ class AdaptiveMultiVertexFinder {
Config m_cfg;

/// @brief Function to extract track parameters,
/// InputTrack_t objects are BoundTrackParameters by default, function to be
/// overwritten to return BoundTrackParameters for other InputTrack_t objects.
std::function<BoundTrackParameters(const InputTrack&)> m_extractParameters;

/// Logging instance
Expand Down
23 changes: 2 additions & 21 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,18 @@ namespace Acts {
///
///////////////////////////////////////////////////////////////////////////
///
/// @tparam input_track_t Track object type
/// @tparam linearizer_t Track linearizer type
template <typename input_track_t, typename linearizer_t>
template <typename linearizer_t>
class AdaptiveMultiVertexFitter {
static_assert(LinearizerConcept<linearizer_t>,
"Linearizer does not fulfill linearizer concept.");

public:
using InputTrack_t = input_track_t;
using Propagator_t = typename linearizer_t::Propagator_t;
using Linearizer_t = linearizer_t;

private:
using IPEstimator = ImpactPointEstimator<InputTrack_t, Propagator_t>;
using IPEstimator = ImpactPointEstimator<Propagator_t>;

public:
/// @brief The fitter state
Expand Down Expand Up @@ -153,23 +151,6 @@ class AdaptiveMultiVertexFitter {
bool useTime{false};
};

/// @brief Constructor used if InputTrack_t type == BoundTrackParameters
///
/// @param cfg Configuration object
/// @param logger The logging instance
template <
typename T = InputTrack_t,
std::enable_if_t<std::is_same<T, BoundTrackParameters>::value, int> = 0>
AdaptiveMultiVertexFitter(Config cfg,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFitter",
Logging::INFO))
: m_cfg(std::move(cfg)),
m_extractParameters([](const InputTrack& params) {
return *params.as<BoundTrackParameters>();
}),
m_logger(std::move(logger)) {}

/// @brief Constructor for user-defined InputTrack_t type !=
/// BoundTrackParameters
///
Expand Down
72 changes: 32 additions & 40 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
#include "Acts/Vertexing/KalmanVertexUpdater.hpp"
#include "Acts/Vertexing/VertexingError.hpp"

template <typename input_track_t, typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fit(
template <typename linearizer_t>
Acts::Result<void> Acts::AdaptiveMultiVertexFitter<linearizer_t>::fit(
State& state, const linearizer_t& linearizer,
const VertexingOptions& vertexingOptions) const {
// Reset annealing tool
Expand Down Expand Up @@ -116,9 +115,8 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fit(
return {};
}

template <typename input_track_t, typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::addVtxToFit(
template <typename linearizer_t>
Acts::Result<void> Acts::AdaptiveMultiVertexFitter<linearizer_t>::addVtxToFit(
State& state, Vertex& newVertex, const linearizer_t& linearizer,
const VertexingOptions& vertexingOptions) const {
if (state.vtxInfoMap[&newVertex].trackLinks.empty()) {
Expand Down Expand Up @@ -191,17 +189,16 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::addVtxToFit(
return {};
}

template <typename input_track_t, typename linearizer_t>
bool Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::
isAlreadyInList(Vertex* vtx, const std::vector<Vertex*>& vertices) const {
template <typename linearizer_t>
bool Acts::AdaptiveMultiVertexFitter<linearizer_t>::isAlreadyInList(
Vertex* vtx, const std::vector<Vertex*>& vertices) const {
return std::find(vertices.begin(), vertices.end(), vtx) != vertices.end();
}

template <typename input_track_t, typename linearizer_t>
Acts::Result<void> Acts::
AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::prepareVertexForFit(
State& state, Vertex* vtx,
const VertexingOptions& vertexingOptions) const {
template <typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<linearizer_t>::prepareVertexForFit(
State& state, Vertex* vtx, const VertexingOptions& vertexingOptions) const {
// Vertex info object
auto& vtxInfo = state.vtxInfoMap[vtx];
// Vertex seed position
Expand All @@ -221,12 +218,10 @@ Acts::Result<void> Acts::
return {};
}

template <typename input_track_t, typename linearizer_t>
Acts::Result<void> Acts::AdaptiveMultiVertexFitter<
input_track_t,
linearizer_t>::setAllVertexCompatibilities(State& state, Vertex* vtx,
const VertexingOptions&
vertexingOptions) const {
template <typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<linearizer_t>::setAllVertexCompatibilities(
State& state, Vertex* vtx, const VertexingOptions& vertexingOptions) const {
VertexInfo& vtxInfo = state.vtxInfoMap[vtx];

// Loop over all tracks that are associated with vtx and estimate their
Expand Down Expand Up @@ -265,11 +260,11 @@ Acts::Result<void> Acts::AdaptiveMultiVertexFitter<
return {};
}

template <typename input_track_t, typename linearizer_t>
Acts::Result<void> Acts::
AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::setWeightsAndUpdate(
State& state, const linearizer_t& linearizer,
const VertexingOptions& vertexingOptions) const {
template <typename linearizer_t>
Acts::Result<void>
Acts::AdaptiveMultiVertexFitter<linearizer_t>::setWeightsAndUpdate(
State& state, const linearizer_t& linearizer,
const VertexingOptions& vertexingOptions) const {
for (auto vtx : state.vertexCollection) {
VertexInfo& vtxInfo = state.vtxInfoMap[vtx];

Expand Down Expand Up @@ -308,11 +303,9 @@ Acts::Result<void> Acts::
// corresponds to the number of fitted vertex dimensions (i.e., 3 if we
// only fit spatial coordinates and 4 if we also fit time).
if (m_cfg.useTime) {
KalmanVertexUpdater::updateVertexWithTrack<input_track_t, 4>(
*vtx, trkAtVtx);
KalmanVertexUpdater::updateVertexWithTrack<4>(*vtx, trkAtVtx);
} else {
KalmanVertexUpdater::updateVertexWithTrack<input_track_t, 3>(
*vtx, trkAtVtx);
KalmanVertexUpdater::updateVertexWithTrack<3>(*vtx, trkAtVtx);
}
} else {
ACTS_VERBOSE("Track weight too low. Skip track.");
Expand All @@ -324,9 +317,8 @@ Acts::Result<void> Acts::
return {};
}

template <typename input_track_t, typename linearizer_t>
std::vector<double>
Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::
template <typename linearizer_t>
std::vector<double> Acts::AdaptiveMultiVertexFitter<linearizer_t>::
collectTrackToVertexCompatibilities(State& state,
const InputTrack& trk) const {
// Compatibilities of trk wrt all of its associated vertices
Expand All @@ -350,9 +342,9 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::
return trkToVtxCompatibilities;
}

template <typename input_track_t, typename linearizer_t>
bool Acts::AdaptiveMultiVertexFitter<
input_track_t, linearizer_t>::checkSmallShift(State& state) const {
template <typename linearizer_t>
bool Acts::AdaptiveMultiVertexFitter<linearizer_t>::checkSmallShift(
State& state) const {
for (auto* vtx : state.vertexCollection) {
Vector3 diff =
state.vtxInfoMap[vtx].oldPosition.template head<3>() - vtx->position();
Expand All @@ -365,9 +357,9 @@ bool Acts::AdaptiveMultiVertexFitter<
return true;
}

template <typename input_track_t, typename linearizer_t>
void Acts::AdaptiveMultiVertexFitter<
input_track_t, linearizer_t>::doVertexSmoothing(State& state) const {
template <typename linearizer_t>
void Acts::AdaptiveMultiVertexFitter<linearizer_t>::doVertexSmoothing(
State& state) const {
for (const auto vtx : state.vertexCollection) {
for (const auto& trk : state.vtxInfoMap[vtx].trackLinks) {
auto& trkAtVtx = state.tracksAtVerticesMap.at(std::make_pair(trk, vtx));
Expand All @@ -384,8 +376,8 @@ void Acts::AdaptiveMultiVertexFitter<
}
}

template <typename input_track_t, typename linearizer_t>
void Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::logDebugData(
template <typename linearizer_t>
void Acts::AdaptiveMultiVertexFitter<linearizer_t>::logDebugData(
const State& state, const Acts::GeometryContext& geoContext) const {
ACTS_DEBUG("Encountered an error when fitting the following "
<< state.vertexCollection.size() << " vertices:");
Expand Down
6 changes: 2 additions & 4 deletions Core/include/Acts/Vertexing/DummyVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@ class DummyTrackLinearizer;
/// @brief Dummy vertex fitter class, only to be used
/// for ensuring interfaces where a vertex fitter type is
/// required but no fitter is actually needed
template <typename input_track_t = BoundTrackParameters,
typename linearizer_t = DummyTrackLinearizer>
template <typename linearizer_t = DummyTrackLinearizer>
class DummyVertexFitter {
public:
using InputTrack_t = input_track_t;
using Linearizer_t = linearizer_t;
using Propagator_t = void;

// Do not allow an instance creation
DummyVertexFitter() = delete;

/// @brief Dummy fit method
Result<Vertex> fit(const std::vector<input_track_t>&, const linearizer_t&,
Result<Vertex> fit(const std::vector<InputTrack>&, const linearizer_t&,
const VertexingOptions&) const;
};

Expand Down
Loading

0 comments on commit f496bb0

Please sign in to comment.