Skip to content

Commit

Permalink
refactor!: move AMVF and IVF config explicitly (#2509)
Browse files Browse the repository at this point in the history
Title says it all!

Might be breaking as now `config` must be moved in the parent scope.

It might be better to not move the `config` and pass it as a const reference, not sure though.
  • Loading branch information
felix-russo authored Nov 6, 2023
1 parent cc2f639 commit 178a798
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class AdaptiveMultiVertexFinder {
template <
typename T = InputTrack_t,
std::enable_if_t<std::is_same<T, BoundTrackParameters>::value, int> = 0>
AdaptiveMultiVertexFinder(Config& cfg,
AdaptiveMultiVertexFinder(Config cfg,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFinder",
Logging::INFO))
Expand All @@ -185,7 +185,7 @@ class AdaptiveMultiVertexFinder {
/// object
/// @param logger The logging instance
AdaptiveMultiVertexFinder(
Config& cfg, std::function<BoundTrackParameters(InputTrack_t)> func,
Config cfg, std::function<BoundTrackParameters(InputTrack_t)> func,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFinder", Logging::INFO))
: m_cfg(std::move(cfg)),
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class AdaptiveMultiVertexFitter {
template <
typename T = InputTrack_t,
std::enable_if_t<std::is_same<T, BoundTrackParameters>::value, int> = 0>
AdaptiveMultiVertexFitter(Config& cfg,
AdaptiveMultiVertexFitter(Config cfg,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFitter",
Logging::INFO))
Expand All @@ -163,7 +163,7 @@ class AdaptiveMultiVertexFitter {
/// object
/// @param logger The logging instance
AdaptiveMultiVertexFitter(
Config& cfg, std::function<BoundTrackParameters(InputTrack_t)> func,
Config cfg, std::function<BoundTrackParameters(InputTrack_t)> func,
std::unique_ptr<const Logger> logger =
getDefaultLogger("AdaptiveMultiVertexFitter", Logging::INFO))
: m_cfg(std::move(cfg)),
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/Vertexing/IterativeVertexFinder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class IterativeVertexFinder {
template <
typename T = InputTrack_t,
std::enable_if_t<std::is_same<T, BoundTrackParameters>::value, int> = 0>
IterativeVertexFinder(Config& cfg,
IterativeVertexFinder(Config cfg,
std::unique_ptr<const Logger> logger = getDefaultLogger(
"IterativeVertexFinder", Logging::INFO))
: m_cfg(std::move(cfg)),
Expand All @@ -156,7 +156,7 @@ class IterativeVertexFinder {
/// @param func Function extracting BoundTrackParameters from InputTrack_t
/// object
/// @param logger The logging instance
IterativeVertexFinder(Config& cfg,
IterativeVertexFinder(Config cfg,
std::function<BoundTrackParameters(InputTrack_t)> func,
std::unique_ptr<const Logger> logger = getDefaultLogger(
"IterativeVertexFinder", Logging::INFO))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ActsExamples::AdaptiveMultiVertexFinderAlgorithm::executeAfterSeederChoice(
fitterCfg.annealingTool = annealingUtility;
fitterCfg.minWeight = 0.001;
fitterCfg.doSmoothing = true;
Fitter fitter(fitterCfg, logger().cloneWithSuffix("AMVFitter"));
Fitter fitter(std::move(fitterCfg), logger().cloneWithSuffix("AMVFitter"));

typename Finder::Config finderConfig(std::move(fitter), seedFinder,
ipEstimator, std::move(linearizer),
Expand All @@ -113,7 +113,7 @@ ActsExamples::AdaptiveMultiVertexFinderAlgorithm::executeAfterSeederChoice(
finderConfig.maxIterations = 200;

// Instantiate the finder
Finder finder(finderConfig, logger().cloneWithSuffix("AMVFinder"));
Finder finder(std::move(finderConfig), logger().cloneWithSuffix("AMVFinder"));

// retrieve input tracks and convert into the expected format

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ActsExamples::ProcessCode ActsExamples::IterativeVertexFinderAlgorithm::execute(
std::move(seeder), ipEst);
finderCfg.maxVertices = 200;
finderCfg.reassignTracksAfterFirstFit = false;
Finder finder(finderCfg, logger().cloneWithSuffix("Finder"));
Finder finder(std::move(finderCfg), logger().cloneWithSuffix("Finder"));
Finder::State state(*m_cfg.bField, ctx.magFieldContext);
Options finderOpts(ctx.geoContext, ctx.magFieldContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) {
Finder::Config finderConfig(std::move(fitter), seedFinder, ipEstimator,
std::move(linearizer), bField);

Finder finder(finderConfig);
Finder finder(std::move(finderConfig));
Finder::State state;

auto csvData = readTracksAndVertexCSV(toolString);
Expand Down Expand Up @@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_usertype_test) {
std::move(linearizer), bField);
Finder::State state;

Finder finder(finderConfig, extractParameters);
Finder finder(std::move(finderConfig), extractParameters);

auto csvData = readTracksAndVertexCSV(toolString);
auto tracks = std::get<TracksData>(csvData);
Expand Down Expand Up @@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_grid_seed_finder_test) {
Finder::Config finderConfig(std::move(fitter), seedFinder, ipEst,
std::move(linearizer), bField);

Finder finder(finderConfig);
Finder finder(std::move(finderConfig));
Finder::State state;

auto csvData = readTracksAndVertexCSV(toolString);
Expand Down Expand Up @@ -569,7 +569,7 @@ BOOST_AUTO_TEST_CASE(
Finder::Config finderConfig(std::move(fitter), seedFinder, ipEst,
std::move(linearizer), bField);

Finder finder(finderConfig);
Finder finder(std::move(finderConfig));
Finder::State state;

auto csvData = readTracksAndVertexCSV(toolString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) {
// Test smoothing
fitterCfg.doSmoothing = true;

AdaptiveMultiVertexFitter<BoundTrackParameters, Linearizer> fitter(fitterCfg);
AdaptiveMultiVertexFitter<BoundTrackParameters, Linearizer> fitter(
std::move(fitterCfg));

// Create positions of three vertices, two of which (1 and 2) are
// close to one another and will share a common track later
Expand Down Expand Up @@ -378,7 +379,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) {
// Test smoothing
// fitterCfg.doSmoothing = true;

AdaptiveMultiVertexFitter<BoundTrackParameters, Linearizer> fitter(fitterCfg);
AdaptiveMultiVertexFitter<BoundTrackParameters, Linearizer> fitter(
std::move(fitterCfg));

// Create first vector of tracks
Vector3 pos1a(0.5_mm, -0.5_mm, 2.4_mm);
Expand Down
6 changes: 3 additions & 3 deletions Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) {

cfg.reassignTracksAfterFirstFit = true;

VertexFinder finder(cfg);
VertexFinder finder(std::move(cfg));
VertexFinder::State state(*bField, magFieldContext);

// Vector to be filled with all tracks in current event
Expand Down Expand Up @@ -389,7 +389,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) {
ipEstimator);
cfg.reassignTracksAfterFirstFit = true;

VertexFinder finder(cfg, extractParameters);
VertexFinder finder(std::move(cfg), extractParameters);
VertexFinder::State state(*bField, magFieldContext);

// Same for user track type tracks
Expand Down Expand Up @@ -602,7 +602,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_athena_reference) {
cfg.maximumChi2cutForSeeding = 49;
cfg.significanceCutSeeding = 12;

VertexFinder finder(cfg);
VertexFinder finder(std::move(cfg));
VertexFinder::State state(*bField, magFieldContext);

auto csvData = readTracksAndVertexCSV(toolString);
Expand Down

0 comments on commit 178a798

Please sign in to comment.