Skip to content

Commit

Permalink
remove input_track_t from billoir fitter
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Jan 18, 2024
1 parent fe2b337 commit feab61e
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 130 deletions.
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
31 changes: 4 additions & 27 deletions Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ namespace Acts {
/// https://acts.readthedocs.io/en/latest/white_papers/billoir-covariances.html
/// Author(s) Russo, F
///
/// @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 FullBilloirVertexFitter {
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;

Expand All @@ -71,29 +69,11 @@ class FullBilloirVertexFitter {
int maxIterations = 5;
};

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

/// @brief Constructor for user-defined input_track_t type =!
/// BoundTrackParameters
///
/// @param cfg Configuration object
/// @param func Function extracting BoundTrackParameters from input_track_t
/// object
/// @param func Function extracting BoundTrackParameters from InputTrack
/// object
/// @param logger Logging instance
FullBilloirVertexFitter(
const Config& cfg,
Expand All @@ -120,9 +100,6 @@ class FullBilloirVertexFitter {
Config m_cfg;

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

/// Logging instance
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ struct BilloirVertex {

} // namespace Acts::detail

template <typename input_track_t, typename linearizer_t>
template < typename linearizer_t>
Acts::Result<Acts::Vertex>
Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit(
Acts::FullBilloirVertexFitter<linearizer_t>::fit(
const std::vector<InputTrack>& paramVector, const linearizer_t& linearizer,
const VertexingOptions& vertexingOptions,
State& state) const {
Expand Down
38 changes: 3 additions & 35 deletions Core/include/Acts/Vertexing/GridDensityVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class GridDensityVertexFinder {
// Assert bigger main grid than track grid
static_assert(mainGridSize > trkGridSize);

using InputTrack_t = typename vfitter_t::InputTrack_t;
using GridDensity = GaussianGridTrackDensity<mainGridSize, trkGridSize>;

public:
Expand Down Expand Up @@ -109,45 +108,16 @@ class GridDensityVertexFinder {
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>
GridDensityVertexFinder(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>
GridDensityVertexFinder()
: 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
GridDensityVertexFinder(
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
GridDensityVertexFinder(
const std::function<BoundTrackParameters(const InputTrack&)>& func)
: m_extractParameters(func) {}

private:
/// @brief Checks if a track passes the selection criteria for seeding
///
Expand All @@ -160,8 +130,6 @@ class GridDensityVertexFinder {
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
26 changes: 3 additions & 23 deletions Core/include/Acts/Vertexing/IterativeVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class IterativeVertexFinder {
using Linearizer_t = typename vfitter_t::Linearizer_t;

public:
using InputTrack_t = typename vfitter_t::InputTrack_t;
using IPEstimator = ImpactPointEstimator<Propagator_t>;

/// Configuration struct
Expand Down Expand Up @@ -135,28 +134,11 @@ class IterativeVertexFinder {
typename vfitter_t::State fitterState;
};

/// @brief Constructor used if InputTrack_t type == BoundTrackParameters
/// @brief Constructor for user-defined InputTrack type
///
/// @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>
IterativeVertexFinder(Config cfg,
std::unique_ptr<const Logger> logger = getDefaultLogger(
"IterativeVertexFinder", 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
/// object
/// @param logger The logging instance
IterativeVertexFinder(
Config cfg, std::function<BoundTrackParameters(const InputTrack&)> func,
Expand All @@ -182,8 +164,6 @@ class IterativeVertexFinder {
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;

/// Logging instance
Expand Down
3 changes: 2 additions & 1 deletion Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace KalmanVertexTrackUpdater {
/// @param track Track to update
/// @param vtxPosFull full vertex position
/// @param vtxCovFull full vertex covariance matrix
/// @param nDimVertex number of dimensions of the vertex
/// @param nDimVertex number of dimensions of the vertex. Can be 3 (if we only
/// fit its spatial coordinates) or 4 (if we also fit time).
void update(TrackAtVertexRef track, const Vector4& vtxPosFull,
const SquareMatrix4& vtxCovFull, unsigned int nDimVertex);

Expand Down
1 change: 0 additions & 1 deletion Core/include/Acts/Vertexing/KalmanVertexUpdater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ struct Cache {
/// However, it does not add the track to the TrackAtVertex list. This to be
/// done manually after calling the method.
///
/// @tparam input_track_t Track object type
/// @tparam nDimVertex number of dimensions of the vertex. Can be 3 (if we only
/// fit its spatial coordinates) or 4 (if we also fit time).
///
Expand Down
5 changes: 0 additions & 5 deletions Core/include/Acts/Vertexing/VertexFitterConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ namespace Acts {
namespace Concepts {
namespace VertexFitter {

template <typename T>
using track_t = typename T::InputTrack_t;
template <typename T>
using propagator_t = typename T::Propagator_t;
template <typename T>
Expand All @@ -41,8 +39,6 @@ METHOD_TRAIT(fit_t, fit);
typename S::State&>;
static_assert(fit_exists, "fit method not found");

constexpr static bool track_exists = exists<track_t, S>;
static_assert(track_exists, "Track type not found");
constexpr static bool propagator_exists = exists<propagator_t, S>;
static_assert(propagator_exists, "Propagator type not found");
constexpr static bool linearizer_exists = exists<linearizer_t, S>;
Expand All @@ -51,7 +47,6 @@ METHOD_TRAIT(fit_t, fit);
static_assert(state_exists, "State type not found");

constexpr static bool value = require<fit_exists,
track_exists,
propagator_exists,
linearizer_exists,
state_exists>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class IterativeVertexFinderAlgorithm final : public IAlgorithm {
using Propagator = Acts::Propagator<Acts::EigenStepper<>>;
using IPEstimator = Acts::ImpactPointEstimator<Propagator>;
using Linearizer = Acts::HelicalTrackLinearizer<Propagator>;
using Fitter =
Acts::FullBilloirVertexFitter<Acts::BoundTrackParameters, Linearizer>;
using Fitter = Acts::FullBilloirVertexFitter<Linearizer>;
using Seeder =
Acts::TrackDensityVertexFinder<Fitter, Acts::GaussianTrackDensity>;
using Finder = Acts::IterativeVertexFinder<Fitter, Seeder>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class VertexFitterAlgorithm final : public IAlgorithm {
using Propagator = Acts::Propagator<Acts::EigenStepper<>>;
using PropagatorOptions = Acts::PropagatorOptions<>;
using Linearizer = Acts::HelicalTrackLinearizer<Propagator>;
using VertexFitter =
Acts::FullBilloirVertexFitter<Acts::BoundTrackParameters, Linearizer>;
using VertexFitter = Acts::FullBilloirVertexFitter<Linearizer>;
using VertexFitterOptions = Acts::VertexingOptions;

using VertexCollection = std::vector<Acts::Vertex>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ActsExamples::ProcessCode ActsExamples::IterativeVertexFinderAlgorithm::execute(
stepper, Acts::VoidNavigator{}, logger().cloneWithSuffix("Propagator"));
// Setup the vertex fitter
Fitter::Config vertexFitterCfg;
Fitter vertexFitter(vertexFitterCfg,
Fitter vertexFitter(vertexFitterCfg, Acts::InputTrack::extractParameters,
logger().cloneWithSuffix("FullBilloirVertexFitter"));
// Setup the track linearizer
Linearizer::Config linearizerCfg(m_cfg.bField, propagator);
Expand All @@ -89,7 +89,8 @@ ActsExamples::ProcessCode ActsExamples::IterativeVertexFinderAlgorithm::execute(
std::move(seeder), ipEst);
finderCfg.maxVertices = 200;
finderCfg.reassignTracksAfterFirstFit = false;
Finder finder(std::move(finderCfg), logger().clone());
Finder finder(std::move(finderCfg), Acts::InputTrack::extractParameters,
logger().clone());
Finder::State state(*m_cfg.bField, ctx.magFieldContext);
Options finderOpts(ctx.geoContext, ctx.magFieldContext);

Expand Down
3 changes: 2 additions & 1 deletion Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ ActsExamples::ProcessCode ActsExamples::VertexFitterAlgorithm::execute(
PropagatorOptions propagatorOpts(ctx.geoContext, ctx.magFieldContext);
// Setup the vertex fitter
VertexFitter::Config vertexFitterCfg;
VertexFitter vertexFitter(vertexFitterCfg);
VertexFitter vertexFitter(vertexFitterCfg,
Acts::InputTrack::extractParameters);
VertexFitter::State state(m_cfg.bField->makeCache(ctx.magFieldContext));
// Setup the linearizer
Linearizer::Config ltConfig(m_cfg.bField, propagator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_grid_seed_finder_test) {
SeedFinder::Config seedFinderCfg(250);
seedFinderCfg.cacheGridStateForTrackRemoval = true;

SeedFinder seedFinder(seedFinderCfg);
SeedFinder seedFinder(seedFinderCfg, InputTrack::extractParameters);

using Finder = AdaptiveMultiVertexFinder<Fitter, SeedFinder>;

Expand Down
14 changes: 5 additions & 9 deletions Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_defaulttrack_test) {
customConstraint.setFullPosition(Vector4(0, 0, 0, 0));

// Set up Billoir vertex fitter with default tracks
using VertexFitter =
FullBilloirVertexFitter<BoundTrackParameters, Linearizer>;
using VertexFitter = FullBilloirVertexFitter<Linearizer>;
VertexFitter::Config vertexFitterCfg;
VertexFitter billoirFitter(vertexFitterCfg);
VertexFitter billoirFitter(vertexFitterCfg, InputTrack::extractParameters);
VertexFitter::State state(bField->makeCache(magFieldContext));
// Vertexing options for default tracks
VertexingOptions vfOptions(geoContext, magFieldContext);
Expand All @@ -159,12 +158,9 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_defaulttrack_test) {
};

// Set up Billoir vertex fitter with user-defined input tracks
using CustomVertexFitter =
FullBilloirVertexFitter<InputTrackStub, Linearizer>;
CustomVertexFitter::Config customVertexFitterCfg;
CustomVertexFitter customBilloirFitter(customVertexFitterCfg,
extractParameters);
CustomVertexFitter::State customState(bField->makeCache(magFieldContext));
VertexFitter::Config customVertexFitterCfg;
VertexFitter customBilloirFitter(customVertexFitterCfg, extractParameters);
VertexFitter::State customState(bField->makeCache(magFieldContext));
// Vertexing options for custom tracks
VertexingOptions customVfOptions(geoContext, magFieldContext);
VertexingOptions customVfOptionsConstr(geoContext, magFieldContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_test) {
using Finder1 = GridDensityVertexFinder<mainGridSize, trkGridSize>;
Finder1::Config cfg1;
cfg1.cacheGridStateForTrackRemoval = false;
Finder1 finder1(cfg1);
Finder1 finder1(cfg1, InputTrack::extractParameters);
Finder1::State state1;

// Use custom grid density here with same bin size as Finder1
Expand Down Expand Up @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_track_caching_test) {

Finder1::Config cfg(density);
cfg.cacheGridStateForTrackRemoval = true;
Finder1 finder1(cfg);
Finder1 finder1(cfg, InputTrack::extractParameters);

// Use custom grid density here with same bin size as Finder1
AdaptiveGridTrackDensity::Config adaptiveDensityConfig;
Expand Down Expand Up @@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE(grid_density_vertex_finder_seed_width_test) {
Finder1::Config cfg1;
cfg1.cacheGridStateForTrackRemoval = false;
cfg1.estimateSeedWidth = true;
Finder1 finder1(cfg1);
Finder1 finder1(cfg1, InputTrack::extractParameters);
Finder1::State state1;

// Use custom grid density here with same bin size as Finder1
Expand Down
Loading

0 comments on commit feab61e

Please sign in to comment.