From 55d49ec514d2673aa33fe8ff26c80e92a8651b6d Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 14 Feb 2024 20:18:28 +0100 Subject: [PATCH 1/3] test: Test KF direct navigation (#2922) Since this broke lately without noticing in ACTS but later on in ATHENA we would like to add this to the Python level tests --- Examples/Python/tests/root_file_hashes.txt | 16 ++++++++++++++++ Examples/Python/tests/test_examples.py | 14 +++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Examples/Python/tests/root_file_hashes.txt b/Examples/Python/tests/root_file_hashes.txt index 22e6469cc8a..0afa67afe32 100644 --- a/Examples/Python/tests/root_file_hashes.txt +++ b/Examples/Python/tests/root_file_hashes.txt @@ -85,3 +85,19 @@ test_exatrkx[cpu-torch]__performance_track_finding.root: e0875db5eb3aa6b46ad4baf test_exatrkx[gpu-onnx]__performance_track_finding.root: 4845dc9f62e287e20c80d479e246eb69d01b279964cfdff83543bea0ea9afbed test_exatrkx[gpu-torch]__performance_track_finding.root: e0875db5eb3aa6b46ad4baf846d39b37b68f1efd3436448cc75919b637f8d8d9 test_ML_Ambiguity_Solver__performance_ambiML.root: 284ff5c3a08c0b810938e4ac2f8ba8fe2babb17d4c202b624ed69fff731a9006 +test_truth_tracking_kalman[generic-False-0.0]__trackstates_fitter.root: 26640d70f7fab870e59666b0915569a6f8f82af68c63e5505548ffa9d24a3212 +test_truth_tracking_kalman[generic-False-0.0]__tracksummary_fitter.root: 11b2e2a50343c636fa977175a30220805412d3200e164ae4c3f439fe2087fb88 +test_truth_tracking_kalman[generic-False-1000.0]__trackstates_fitter.root: 476e0dca91e5168f0574b86aea797dc22900fd456b3c3fb24d5f571b4be804fc +test_truth_tracking_kalman[generic-False-1000.0]__tracksummary_fitter.root: fc82abfc4e3016cda806e743a270bf78b6d4cc404cd52145ea1eabed85d32feb +test_truth_tracking_kalman[generic-True-0.0]__trackstates_fitter.root: 26640d70f7fab870e59666b0915569a6f8f82af68c63e5505548ffa9d24a3212 +test_truth_tracking_kalman[generic-True-0.0]__tracksummary_fitter.root: 11b2e2a50343c636fa977175a30220805412d3200e164ae4c3f439fe2087fb88 +test_truth_tracking_kalman[generic-True-1000.0]__trackstates_fitter.root: 476e0dca91e5168f0574b86aea797dc22900fd456b3c3fb24d5f571b4be804fc +test_truth_tracking_kalman[generic-True-1000.0]__tracksummary_fitter.root: fc82abfc4e3016cda806e743a270bf78b6d4cc404cd52145ea1eabed85d32feb +test_truth_tracking_kalman[odd-False-0.0]__trackstates_fitter.root: cad01486e071ffdb614d15934354a1b17f2bfa95dd5d440215f606d8a79afe17 +test_truth_tracking_kalman[odd-False-0.0]__tracksummary_fitter.root: f42d1cd850b78909b07cd6e412ae03c6e1ea8c99a02000892dd957319f0a825c +test_truth_tracking_kalman[odd-False-1000.0]__trackstates_fitter.root: 72c79be1458c4f9c9a1661778c900f0875d257f2d391c4183a698825448919a1 +test_truth_tracking_kalman[odd-False-1000.0]__tracksummary_fitter.root: 3d424dec9b172f253c8c4ffbda470f678fd1081a3d36dcfea517ab0f94995ae4 +test_truth_tracking_kalman[odd-True-0.0]__trackstates_fitter.root: cad01486e071ffdb614d15934354a1b17f2bfa95dd5d440215f606d8a79afe17 +test_truth_tracking_kalman[odd-True-0.0]__tracksummary_fitter.root: f42d1cd850b78909b07cd6e412ae03c6e1ea8c99a02000892dd957319f0a825c +test_truth_tracking_kalman[odd-True-1000.0]__trackstates_fitter.root: 72c79be1458c4f9c9a1661778c900f0875d257f2d391c4183a698825448919a1 +test_truth_tracking_kalman[odd-True-1000.0]__tracksummary_fitter.root: 3d424dec9b172f253c8c4ffbda470f678fd1081a3d36dcfea517ab0f94995ae4 diff --git a/Examples/Python/tests/test_examples.py b/Examples/Python/tests/test_examples.py index 7550c2c90fd..2ae6a651745 100644 --- a/Examples/Python/tests/test_examples.py +++ b/Examples/Python/tests/test_examples.py @@ -537,8 +537,9 @@ def test_event_recording(tmp_path): @pytest.mark.parametrize("revFiltMomThresh", [0 * u.GeV, 1 * u.TeV]) +@pytest.mark.parametrize("directNavigation", [False, True]) def test_truth_tracking_kalman( - tmp_path, assert_root_hash, revFiltMomThresh, detector_config + tmp_path, assert_root_hash, revFiltMomThresh, directNavigation, detector_config ): from truth_tracking_kalman import runTruthTrackingKalman @@ -562,6 +563,7 @@ def test_truth_tracking_kalman( digiConfigFile=detector_config.digiConfigFile, outputDir=tmp_path, reverseFilteringMomThreshold=revFiltMomThresh, + directNavigation=directNavigation, s=seq, ) @@ -577,6 +579,16 @@ def test_truth_tracking_kalman( assert_has_entries(fp, tn) assert_root_hash(fn, fp) + import ROOT + + ROOT.PyConfig.IgnoreCommandLineOptions = True + ROOT.gROOT.SetBatch(True) + rf = ROOT.TFile.Open(str(tmp_path / "tracksummary_fitter.root")) + keys = [k.GetName() for k in rf.GetListOfKeys()] + assert "tracksummary" in keys + for entry in rf.Get("tracksummary"): + assert entry.hasFittedParams + def test_truth_tracking_gsf(tmp_path, assert_root_hash, detector_config): from truth_tracking_gsf import runTruthTrackingGsf From 9eac779e07d8a4a34e94eb4afdb48b3c78a7393f Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Thu, 15 Feb 2024 11:15:41 +0100 Subject: [PATCH 2/3] refactor!: Use BasePropagator interface in vertexing (#2886) This PR untemplates the ImpactParameterEstimator, HelicalTrackLinearizer and NumericalTrackLinearizer Part of: - #2842 Blocked by: - #2881 --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../Vertexing/AdaptiveMultiVertexFinder.hpp | 8 +- .../Vertexing/AdaptiveMultiVertexFitter.hpp | 18 +-- .../Vertexing/AdaptiveMultiVertexFitter.ipp | 2 +- .../Vertexing/FullBilloirVertexFitter.hpp | 10 +- .../Vertexing/FullBilloirVertexFitter.ipp | 2 +- .../Acts/Vertexing/HelicalTrackLinearizer.hpp | 61 +++------ .../Acts/Vertexing/HelicalTrackLinearizer.ipp | 26 ++-- .../Acts/Vertexing/ImpactPointEstimator.hpp | 11 +- .../Acts/Vertexing/ImpactPointEstimator.ipp | 125 ++++++++---------- .../Acts/Vertexing/IterativeVertexFinder.hpp | 18 ++- .../Acts/Vertexing/IterativeVertexFinder.ipp | 2 +- .../Acts/Vertexing/LinearizerConcept.hpp | 18 +-- .../Vertexing/NumericalTrackLinearizer.hpp | 34 ++--- .../Vertexing/NumericalTrackLinearizer.ipp | 27 ++-- .../Acts/Vertexing/VertexFitterConcept.hpp | 5 - .../Acts/Vertexing/ZScanVertexFinder.hpp | 6 +- .../AdaptiveMultiVertexFinderAlgorithm.hpp | 3 +- .../IterativeVertexFinderAlgorithm.hpp | 3 +- .../Vertexing/VertexFitterAlgorithm.hpp | 2 +- .../AdaptiveMultiVertexFinderAlgorithm.cpp | 11 +- .../src/IterativeVertexFinderAlgorithm.cpp | 9 +- .../Vertexing/src/VertexFitterAlgorithm.cpp | 4 +- .../AdaptiveMultiVertexFinderTests.cpp | 42 +++--- .../AdaptiveMultiVertexFitterTests.cpp | 34 +++-- .../FullBilloirVertexFitterTests.cpp | 6 +- .../Vertexing/ImpactPointEstimatorTests.cpp | 4 +- .../Vertexing/IterativeVertexFinderTests.cpp | 35 +++-- .../KalmanVertexTrackUpdaterTests.cpp | 17 +-- .../Vertexing/KalmanVertexUpdaterTests.cpp | 10 +- .../Vertexing/LinearizedTrackFactoryTests.cpp | 51 +++---- .../Core/Vertexing/ZScanVertexFinderTests.cpp | 16 +-- 31 files changed, 267 insertions(+), 353 deletions(-) diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp index 9ccb327eedf..93298f8df88 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp @@ -33,7 +33,6 @@ namespace Acts { /// @tparam sfinder_t Seed finder type template class AdaptiveMultiVertexFinder { - using Propagator_t = typename vfitter_t::Propagator_t; using Linearizer_t = typename vfitter_t::Linearizer_t; using FitterState_t = typename vfitter_t::State; using SeedFinderState_t = typename sfinder_t::State; @@ -57,9 +56,8 @@ class AdaptiveMultiVertexFinder { /// @param ipEst ImpactPointEstimator /// @param lin Track linearizer /// @param bIn Input magnetic field - Config(vfitter_t fitter, sfinder_t sfinder, - ImpactPointEstimator ipEst, Linearizer_t lin, - std::shared_ptr bIn) + Config(vfitter_t fitter, sfinder_t sfinder, ImpactPointEstimator ipEst, + Linearizer_t lin, std::shared_ptr bIn) : vertexFitter(std::move(fitter)), seedFinder(std::move(sfinder)), ipEstimator(std::move(ipEst)), @@ -73,7 +71,7 @@ class AdaptiveMultiVertexFinder { sfinder_t seedFinder; // ImpactPointEstimator - ImpactPointEstimator ipEstimator; + ImpactPointEstimator ipEstimator; // Track linearizer Linearizer_t linearizer; diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp index 3d342204299..eec4cdc9706 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp @@ -10,6 +10,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Utilities/AnnealingUtility.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/Result.hpp" @@ -41,30 +42,23 @@ class AdaptiveMultiVertexFitter { "Linearizer does not fulfill linearizer concept."); public: - using Propagator_t = typename linearizer_t::Propagator_t; using Linearizer_t = linearizer_t; - private: - using IPEstimator = ImpactPointEstimator; - - public: /// @brief The fitter state struct State { State(const MagneticFieldProvider& field, const Acts::MagneticFieldContext& magContext) : ipState(field.makeCache(magContext)), - linearizerState(field.makeCache(magContext)) {} + fieldCache(field.makeCache(magContext)) {} // Vertex collection to be fitted std::vector vertexCollection; // Annealing state AnnealingUtility::State annealingState; - // IPEstimator state - typename IPEstimator::State ipState; + ImpactPointEstimator::State ipState; - // Linearizer state - typename Linearizer_t::State linearizerState; + MagneticFieldProvider::Cache fieldCache; // Map to store vertices information // @TODO Does this have to be a mutable pointer? @@ -115,10 +109,10 @@ class AdaptiveMultiVertexFitter { /// @brief Config constructor /// /// @param est ImpactPointEstimator - Config(IPEstimator est) : ipEst(std::move(est)) {} + Config(ImpactPointEstimator est) : ipEst(std::move(est)) {} // ImpactPointEstimator - IPEstimator ipEst; + ImpactPointEstimator ipEst; /// Annealing tool used for a thermodynamic annealing scheme for the /// track weight factors in such a way that with high temperature values diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp index 7fe98ee58c5..1d721f979cb 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp @@ -291,7 +291,7 @@ Acts::AdaptiveMultiVertexFitter::setWeightsAndUpdate( auto result = linearizer.linearizeTrack( m_cfg.extractParameters(trk), vtxInfo.linPoint[3], *vtxPerigeeSurface, vertexingOptions.geoContext, - vertexingOptions.magFieldContext, state.linearizerState); + vertexingOptions.magFieldContext, state.fieldCache); if (!result.ok()) { return result.error(); } diff --git a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp index 398cf729d26..c826a8d9201 100644 --- a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp @@ -8,6 +8,7 @@ #pragma once +#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Utilities/Logger.hpp" @@ -51,17 +52,16 @@ class FullBilloirVertexFitter { "Linearizer does not fulfill linearizer concept."); public: - using Propagator_t = typename linearizer_t::Propagator_t; using Linearizer_t = linearizer_t; struct State { /// @brief The state constructor /// /// @param fieldCache The magnetic field cache - State(MagneticFieldProvider::Cache fieldCache) - : linearizerState(std::move(fieldCache)) {} - /// The linearizer state - typename Linearizer_t::State linearizerState; + State(MagneticFieldProvider::Cache _fieldCache) + : fieldCache(std::move(_fieldCache)) {} + + MagneticFieldProvider::Cache fieldCache; }; struct Config { diff --git a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp index 0274627afd5..bf1ee167d2d 100644 --- a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp @@ -112,7 +112,7 @@ Acts::Result Acts::FullBilloirVertexFitter::fit( auto result = linearizer.linearizeTrack( trackParams, linPoint[3], *perigeeSurface, vertexingOptions.geoContext, vertexingOptions.magFieldContext, - state.linearizerState); + state.fieldCache); if (!result.ok()) { return result.error(); } diff --git a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp index 5bd7b12b94f..8b855bcfa4e 100644 --- a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp +++ b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp @@ -16,9 +16,12 @@ #include "Acts/MagneticField/NullBField.hpp" #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/Propagator.hpp" +#include "Acts/Utilities/Delegate.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Vertexing/LinearizedTrack.hpp" +#include + namespace Acts { /// @class HelicalTrackLinearizer @@ -38,46 +41,15 @@ namespace Acts { /// This class computes A and B using the analytic formulae of Ref. (1). /// /// Ref. (1) - CERN-THESIS-2010-027, Giacinto Piacquadio (Freiburg U.) -/// -/// @tparam propagator_t Propagator type -/// @tparam propagator_options_t Propagator options type -template > class HelicalTrackLinearizer { public: - using Propagator_t = propagator_t; - - /// State struct - struct State { - /// @brief The state constructor - /// - /// @param fieldCacheIn The magnetic field cache - State(MagneticFieldProvider::Cache fieldCacheIn) - : fieldCache(std::move(fieldCacheIn)) {} - /// Magnetic field cache - MagneticFieldProvider::Cache fieldCache; - }; - /// @brief Configuration struct struct Config { - /// @ Config constructor if magnetic field is present - /// - /// @param bIn The magnetic field - /// @param prop The propagator - Config(std::shared_ptr bIn, - std::shared_ptr prop) - : bField(std::move(bIn)), propagator(std::move(prop)) {} - - /// @brief Config constructor without B field -> uses NullBField - /// - /// @param prop The propagator - Config(std::shared_ptr prop) - : bField{std::make_shared()}, propagator(std::move(prop)) {} - // The magnetic field - std::shared_ptr bField; - // The propagator - std::shared_ptr propagator; + std::shared_ptr bField = + std::make_shared(); + + std::shared_ptr propagator; /// Tolerance determining how close we need to get to the Perigee surface to /// reach it during propagation @@ -91,7 +63,11 @@ class HelicalTrackLinearizer { HelicalTrackLinearizer(const Config& config, std::unique_ptr _logger = getDefaultLogger("HelTrkLinProp", Logging::INFO)) - : m_cfg(config), m_logger{std::move(_logger)} {} + : m_cfg(config), m_logger{std::move(_logger)} { + if (!m_cfg.propagator) { + throw std::invalid_argument("HelicalTrackLinearizer: propagator is null"); + } + } /// @brief Function that linearizes BoundTrackParameters at /// the PCA to a given Perigee surface @@ -103,15 +79,14 @@ class HelicalTrackLinearizer { /// @param perigeeSurface Perigee surface belonging to @p linPoint /// @param gctx Geometry context /// @param mctx Magnetic field context - /// @param state Linearizer state object + /// @param fieldCache Magnetic field cache /// /// @return Linearized track - Result linearizeTrack(const BoundTrackParameters& params, - double linPointTime, - const Surface& perigeeSurface, - const Acts::GeometryContext& gctx, - const Acts::MagneticFieldContext& mctx, - State& state) const; + Result linearizeTrack( + const BoundTrackParameters& params, double linPointTime, + const Surface& perigeeSurface, const Acts::GeometryContext& gctx, + const Acts::MagneticFieldContext& mctx, + MagneticFieldProvider::Cache& fieldCache) const; private: /// Configuration object diff --git a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp index 4ad935192b2..f15e41356e8 100644 --- a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp +++ b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp @@ -9,14 +9,14 @@ #include "Acts/Surfaces/PerigeeSurface.hpp" #include "Acts/Vertexing/LinearizerTrackParameters.hpp" -template -Acts::Result Acts:: - HelicalTrackLinearizer::linearizeTrack( - const BoundTrackParameters& params, double linPointTime, - const Surface& perigeeSurface, const Acts::GeometryContext& gctx, - const Acts::MagneticFieldContext& mctx, State& state) const { +inline Acts::Result +Acts::HelicalTrackLinearizer::linearizeTrack( + const BoundTrackParameters& params, double linPointTime, + const Surface& perigeeSurface, const Acts::GeometryContext& gctx, + const Acts::MagneticFieldContext& mctx, + MagneticFieldProvider::Cache& fieldCache) const { // Create propagator options - propagator_options_t pOptions(gctx, mctx); + PropagatorOptions<> pOptions(gctx, mctx); // Length scale at which we consider to be sufficiently close to the Perigee // surface to skip the propagation. @@ -39,14 +39,15 @@ Acts::Result Acts:: Direction::fromScalarZeroAsPositive(intersection.pathLength()); // Propagate to the PCA of the reference point - auto result = m_cfg.propagator->propagate(params, perigeeSurface, pOptions); - if (!result.ok()) { - return result.error(); + const auto res = + m_cfg.propagator->propagateToSurface(params, perigeeSurface, pOptions); + if (!res.ok()) { + return res.error(); } + const auto& endParams = *res; // Extracting the track parameters at said PCA - this corresponds to the // Perigee representation of the track wrt the reference point - const auto& endParams = *result->endParameters; BoundVector paramsAtPCA = endParams.parameters(); // Extracting the 4D position of the PCA in global coordinates @@ -91,8 +92,7 @@ Acts::Result Acts:: ActsScalar absoluteCharge = params.particleHypothesis().absoluteCharge(); // get the z-component of the B-field at the PCA - auto field = - m_cfg.bField->getField(VectorHelpers::position(pca), state.fieldCache); + auto field = m_cfg.bField->getField(VectorHelpers::position(pca), fieldCache); if (!field.ok()) { return field.error(); } diff --git a/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp b/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp index ae75b9ab8f7..92e77010377 100644 --- a/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp +++ b/Core/include/Acts/Vertexing/ImpactPointEstimator.hpp @@ -43,8 +43,6 @@ struct ImpactParametersAndSigma { /// A description of the underlying mathematics can be found here: /// https://github.com/acts-project/acts/pull/2506 /// TODO: Upload reference at a better place -template > class ImpactPointEstimator { public: /// State struct @@ -64,20 +62,20 @@ class ImpactPointEstimator { /// @param bIn The magnetic field /// @param prop The propagator Config(std::shared_ptr bIn, - std::shared_ptr prop) + std::shared_ptr prop) : bField(std::move(bIn)), propagator(std::move(prop)) {} /// @brief Config constructor without B field -> uses NullBField /// provided) /// /// @param prop The propagator - Config(std::shared_ptr prop) + Config(std::shared_ptr prop) : bField{std::make_shared()}, propagator(std::move(prop)) {} /// Magnetic field std::shared_ptr bField; /// Propagator - std::shared_ptr propagator; + std::shared_ptr propagator; /// Max. number of iterations in Newton method int maxIterations = 20; /// Desired precision of deltaPhi in Newton method @@ -100,6 +98,9 @@ class ImpactPointEstimator { ImpactPointEstimator(const ImpactPointEstimator& other) : m_cfg(other.m_cfg), m_logger(other.logger().clone()) {} + /// Move constructor for impact point estimator + ImpactPointEstimator(ImpactPointEstimator&&) = default; + /// @brief Calculates 3D distance between a track and a vertex /// /// @param gctx The geometry context diff --git a/Core/include/Acts/Vertexing/ImpactPointEstimator.ipp b/Core/include/Acts/Vertexing/ImpactPointEstimator.ipp index 45f09215ccc..cd9dcb3de26 100644 --- a/Core/include/Acts/Vertexing/ImpactPointEstimator.ipp +++ b/Core/include/Acts/Vertexing/ImpactPointEstimator.ipp @@ -11,11 +11,9 @@ #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Vertexing/VertexingError.hpp" -template -Acts::Result Acts:: - ImpactPointEstimator::calculateDistance( - const GeometryContext& gctx, const BoundTrackParameters& trkParams, - const Vector3& vtxPos, State& state) const { +inline Acts::Result Acts::ImpactPointEstimator::calculateDistance( + const GeometryContext& gctx, const BoundTrackParameters& trkParams, + const Vector3& vtxPos, State& state) const { auto res = getDistanceAndMomentum<3>(gctx, trkParams, vtxPos, state); if (!res.ok()) { @@ -26,13 +24,11 @@ Acts::Result Acts:: return res.value().first.norm(); } -template -Acts::Result -Acts::ImpactPointEstimator:: - estimate3DImpactParameters(const GeometryContext& gctx, - const Acts::MagneticFieldContext& mctx, - const BoundTrackParameters& trkParams, - const Vector3& vtxPos, State& state) const { +inline Acts::Result +Acts::ImpactPointEstimator::estimate3DImpactParameters( + const GeometryContext& gctx, const Acts::MagneticFieldContext& mctx, + const BoundTrackParameters& trkParams, const Vector3& vtxPos, + State& state) const { auto res = getDistanceAndMomentum<3>(gctx, trkParams, vtxPos, state); if (!res.ok()) { @@ -85,15 +81,16 @@ Acts::ImpactPointEstimator:: .closest(); // Create propagator options - propagator_options_t pOptions(gctx, mctx); + PropagatorOptions<> pOptions(gctx, mctx); pOptions.direction = Direction::fromScalarZeroAsPositive(intersection.pathLength()); // Propagate to the surface; intersection corresponds to an estimate of the 3D // PCA. If deltaR and momDir were orthogonal the calculation would be exact. - auto result = m_cfg.propagator->propagate(trkParams, *planeSurface, pOptions); + auto result = + m_cfg.propagator->propagateToSurface(trkParams, *planeSurface, pOptions); if (result.ok()) { - return *result->endParameters; + return *result; } else { ACTS_ERROR("Error during propagation in estimate3DImpactParameters."); ACTS_DEBUG( @@ -103,13 +100,10 @@ Acts::ImpactPointEstimator:: } } -template template -Acts::Result -Acts::ImpactPointEstimator:: - getVertexCompatibility(const GeometryContext& gctx, - const BoundTrackParameters* trkParams, - const ActsVector& vertexPos) const { +Acts::Result Acts::ImpactPointEstimator::getVertexCompatibility( + const GeometryContext& gctx, const BoundTrackParameters* trkParams, + const ActsVector& vertexPos) const { static_assert(nDim == 3 || nDim == 4, "The number of dimensions nDim must be either 3 or 4."); @@ -172,13 +166,10 @@ Acts::ImpactPointEstimator:: return residual.dot(weight * residual); } -template -Acts::Result Acts::ImpactPointEstimator< - propagator_t, - propagator_options_t>::performNewtonOptimization(const Vector3& helixCenter, - const Vector3& vtxPos, - double phi, double theta, - double rho) const { +inline Acts::Result +Acts::ImpactPointEstimator::performNewtonOptimization( + const Vector3& helixCenter, const Vector3& vtxPos, double phi, double theta, + double rho) const { double sinPhi = std::sin(phi); double cosPhi = std::cos(phi); @@ -229,13 +220,11 @@ Acts::Result Acts::ImpactPointEstimator< return phi; } -template template Acts::Result, Acts::Vector3>> -Acts::ImpactPointEstimator:: - getDistanceAndMomentum(const GeometryContext& gctx, - const BoundTrackParameters& trkParams, - const ActsVector& vtxPos, State& state) const { +Acts::ImpactPointEstimator::getDistanceAndMomentum( + const GeometryContext& gctx, const BoundTrackParameters& trkParams, + const ActsVector& vtxPos, State& state) const { static_assert(nDim == 3 || nDim == 4, "The number of dimensions nDim must be either 3 or 4."); @@ -366,18 +355,16 @@ Acts::ImpactPointEstimator:: return std::make_pair(deltaR, momDir); } -template -Acts::Result -Acts::ImpactPointEstimator:: - getImpactParameters(const BoundTrackParameters& track, const Vertex& vtx, - const GeometryContext& gctx, - const Acts::MagneticFieldContext& mctx, - bool calculateTimeIP) const { +inline Acts::Result +Acts::ImpactPointEstimator::getImpactParameters( + const BoundTrackParameters& track, const Vertex& vtx, + const GeometryContext& gctx, const Acts::MagneticFieldContext& mctx, + bool calculateTimeIP) const { const std::shared_ptr perigeeSurface = Surface::makeShared(vtx.position()); // Create propagator options - propagator_options_t pOptions(gctx, mctx); + PropagatorOptions<> pOptions(gctx, mctx); auto intersection = perigeeSurface ->intersect(gctx, track.position(gctx), track.direction(), BoundaryCheck(false)) @@ -386,7 +373,8 @@ Acts::ImpactPointEstimator:: Direction::fromScalarZeroAsPositive(intersection.pathLength()); // Do the propagation to linPoint - auto result = m_cfg.propagator->propagate(track, *perigeeSurface, pOptions); + auto result = + m_cfg.propagator->propagateToSurface(track, *perigeeSurface, pOptions); if (!result.ok()) { ACTS_ERROR("Error during propagation in getImpactParameters."); @@ -396,17 +384,16 @@ Acts::ImpactPointEstimator:: return result.error(); } - const auto& propRes = *result; + const auto& params = *result; // Check if the covariance matrix of the Perigee parameters exists - if (!propRes.endParameters->covariance().has_value()) { + if (!params.covariance().has_value()) { return VertexingError::NoCovariance; } // Extract Perigee parameters and corresponding covariance matrix - auto impactParams = propRes.endParameters->impactParameters(); - auto impactParamCovariance = - propRes.endParameters->impactParameterCovariance().value(); + auto impactParams = params.impactParameters(); + auto impactParamCovariance = params.impactParameterCovariance().value(); // Vertex variances // TODO: By looking at sigmaD0 and sigmaZ0 we neglect the offdiagonal terms @@ -451,29 +438,27 @@ Acts::ImpactPointEstimator:: return ipAndSigma; } -template -Acts::Result> -Acts::ImpactPointEstimator:: - getLifetimeSignOfTrack(const BoundTrackParameters& track, const Vertex& vtx, - const Acts::Vector3& direction, - const GeometryContext& gctx, - const MagneticFieldContext& mctx) const { +inline Acts::Result> +Acts::ImpactPointEstimator::getLifetimeSignOfTrack( + const BoundTrackParameters& track, const Vertex& vtx, + const Acts::Vector3& direction, const GeometryContext& gctx, + const MagneticFieldContext& mctx) const { const std::shared_ptr perigeeSurface = Surface::makeShared(vtx.position()); // Create propagator options - propagator_options_t pOptions(gctx, mctx); + PropagatorOptions<> pOptions(gctx, mctx); pOptions.direction = Direction::Backward; // Do the propagation to the perigeee - auto result = m_cfg.propagator->propagate(track, *perigeeSurface, pOptions); + auto result = + m_cfg.propagator->propagateToSurface(track, *perigeeSurface, pOptions); if (!result.ok()) { return result.error(); } - const auto& propRes = *result; - const auto& params = propRes.endParameters->parameters(); + const auto& params = (*result).parameters(); const double d0 = params[BoundIndices::eBoundLoc0]; const double z0 = params[BoundIndices::eBoundLoc1]; const double phi = params[BoundIndices::eBoundPhi]; @@ -493,31 +478,29 @@ Acts::ImpactPointEstimator:: return vszs; } -template -Acts::Result -Acts::ImpactPointEstimator:: - get3DLifetimeSignOfTrack(const BoundTrackParameters& track, - const Vertex& vtx, const Acts::Vector3& direction, - const GeometryContext& gctx, - const MagneticFieldContext& mctx) const { +inline Acts::Result +Acts::ImpactPointEstimator::get3DLifetimeSignOfTrack( + const BoundTrackParameters& track, const Vertex& vtx, + const Acts::Vector3& direction, const GeometryContext& gctx, + const MagneticFieldContext& mctx) const { const std::shared_ptr perigeeSurface = Surface::makeShared(vtx.position()); // Create propagator options - propagator_options_t pOptions(gctx, mctx); + PropagatorOptions<> pOptions(gctx, mctx); pOptions.direction = Direction::Backward; // Do the propagation to the perigeee - auto result = m_cfg.propagator->propagate(track, *perigeeSurface, pOptions); + auto result = + m_cfg.propagator->propagateToSurface(track, *perigeeSurface, pOptions); if (!result.ok()) { return result.error(); } - const auto& propRes = *result; - const auto& params = propRes.endParameters; - const Vector3 trkpos = params->position(gctx); - const Vector3 trkmom = params->momentum(); + const auto& params = *result; + const Vector3 trkpos = params.position(gctx); + const Vector3 trkmom = params.momentum(); double sign = (direction.cross(trkmom)).dot(trkmom.cross(vtx.position() - trkpos)); diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp index 3e80e2846fa..191213a949e 100644 --- a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp @@ -10,6 +10,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Vertexing/FsmwMode1dFinder.hpp" @@ -60,12 +61,9 @@ template class IterativeVertexFinder { static_assert(VertexFitterConcept, "Vertex fitter does not fulfill vertex fitter concept."); - using Propagator_t = typename vfitter_t::Propagator_t; using Linearizer_t = typename vfitter_t::Linearizer_t; public: - using IPEstimator = ImpactPointEstimator; - /// Configuration struct struct Config { /// @brief Config constructor @@ -75,7 +73,7 @@ class IterativeVertexFinder { /// @param sfinder The seed finder /// @param est ImpactPointEstimator Config(vfitter_t fitter, Linearizer_t lin, sfinder_t sfinder, - IPEstimator est) + ImpactPointEstimator est) : vertexFitter(std::move(fitter)), linearizer(std::move(lin)), seedFinder(std::move(sfinder)), @@ -91,7 +89,7 @@ class IterativeVertexFinder { sfinder_t seedFinder; /// ImpactPointEstimator - IPEstimator ipEst; + ImpactPointEstimator ipEst; /// Vertex finder configuration variables. /// Tracks that are within a distance of @@ -127,14 +125,14 @@ class IterativeVertexFinder { State(const MagneticFieldProvider& field, const Acts::MagneticFieldContext& magContext) : ipState(field.makeCache(magContext)), - linearizerState(field.makeCache(magContext)), - fitterState(field.makeCache(magContext)) {} + fitterState(field.makeCache(magContext)), + fieldCache(field.makeCache(magContext)) {} /// The IP estimator state - typename IPEstimator::State ipState; - /// The inearizer state - typename Linearizer_t::State linearizerState; + ImpactPointEstimator::State ipState; /// The fitter state typename vfitter_t::State fitterState; + + MagneticFieldProvider::Cache fieldCache; }; /// @brief Constructor for user-defined InputTrack type diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp b/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp index 2c9c6eb8c7d..19b7ab2900a 100644 --- a/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp @@ -220,7 +220,7 @@ Acts::IterativeVertexFinder::getCompatibility( auto result = m_cfg.linearizer.linearizeTrack( params, vertex.fullPosition()[3], perigeeSurface, vertexingOptions.geoContext, vertexingOptions.magFieldContext, - state.linearizerState); + state.fieldCache); if (!result.ok()) { return result.error(); } diff --git a/Core/include/Acts/Vertexing/LinearizerConcept.hpp b/Core/include/Acts/Vertexing/LinearizerConcept.hpp index 4f86d87c102..4f996a42ecd 100644 --- a/Core/include/Acts/Vertexing/LinearizerConcept.hpp +++ b/Core/include/Acts/Vertexing/LinearizerConcept.hpp @@ -13,6 +13,7 @@ #include "Acts/EventData/TrackParameters.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" +#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/TypeTraits.hpp" #include "Acts/Vertexing/LinearizedTrack.hpp" @@ -22,10 +23,7 @@ namespace Acts { namespace Concepts { namespace Linearizer { -template -using propagator_t = typename T::Propagator_t; -template -using state_t = typename T::State; +// @TODO Remove linearizer concept METHOD_TRAIT(linTrack_t, linearizeTrack); @@ -39,19 +37,11 @@ METHOD_TRAIT(linTrack_t, linearizeTrack); const Surface&, const Acts::GeometryContext&, const Acts::MagneticFieldContext&, - typename S::State&>; + MagneticFieldProvider::Cache&>; static_assert(linTrack_exists, "linearizeTrack method not found"); - constexpr static bool propagator_exists = exists; - static_assert(propagator_exists, "Propagator type not found"); - - constexpr static bool state_exists = exists; - static_assert(state_exists, "State type not found"); - - constexpr static bool value = require; + constexpr static bool value = require; }; // clang-format on diff --git a/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp b/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp index c7e37d384c4..da7e48a237a 100644 --- a/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp +++ b/Core/include/Acts/Vertexing/NumericalTrackLinearizer.hpp @@ -55,25 +55,8 @@ namespace Acts { /// described above. /// /// Ref.(1) - CERN-THESIS-2010-027, Giacinto Piacquadio (Freiburg U.) -/// -/// @tparam propagator_t Propagator type -/// @tparam propagator_options_t Propagator options type -template > class NumericalTrackLinearizer { public: - using Propagator_t = propagator_t; - - /// State struct - struct State { - /// @brief State constructor - /// - /// @param fieldCacheIn Magnetic field cache - State(MagneticFieldProvider::Cache fieldCacheIn) - : fieldCache(std::move(fieldCacheIn)) {} - MagneticFieldProvider::Cache fieldCache; - }; - /// @brief Configuration struct struct Config { /// @ Config constructor if magnetic field is present @@ -81,18 +64,18 @@ class NumericalTrackLinearizer { /// @param bIn The magnetic field /// @param prop The propagator Config(std::shared_ptr bIn, - std::shared_ptr prop) + std::shared_ptr prop) : bField(std::move(bIn)), propagator(std::move(prop)) {} /// @brief Config constructor without B field -> uses NullBField /// /// @param prop Propagator - Config(std::shared_ptr prop) + Config(std::shared_ptr prop) : bField{std::make_shared()}, propagator(std::move(prop)) {} std::shared_ptr bField; - std::shared_ptr propagator; + std::shared_ptr propagator; /// Tolerance determining how close we need to get to a surface to /// reach it during propagation @@ -124,12 +107,11 @@ class NumericalTrackLinearizer { /// @param mctx Magnetic field context /// /// @return Linearized track - Result linearizeTrack(const BoundTrackParameters& params, - double linPointTime, - const Surface& perigeeSurface, - const Acts::GeometryContext& gctx, - const Acts::MagneticFieldContext& mctx, - State& /*state*/) const; + Result linearizeTrack( + const BoundTrackParameters& params, double linPointTime, + const Surface& perigeeSurface, const Acts::GeometryContext& gctx, + const Acts::MagneticFieldContext& mctx, + MagneticFieldProvider::Cache& /*fieldCache*/) const; private: const Config m_cfg; diff --git a/Core/include/Acts/Vertexing/NumericalTrackLinearizer.ipp b/Core/include/Acts/Vertexing/NumericalTrackLinearizer.ipp index 09eb5e0d777..ce40f390827 100644 --- a/Core/include/Acts/Vertexing/NumericalTrackLinearizer.ipp +++ b/Core/include/Acts/Vertexing/NumericalTrackLinearizer.ipp @@ -10,16 +10,14 @@ #include "Acts/Utilities/UnitVectors.hpp" #include "Acts/Vertexing/LinearizerTrackParameters.hpp" -template -Acts::Result -Acts::NumericalTrackLinearizer:: - linearizeTrack(const BoundTrackParameters& params, double linPointTime, - const Surface& perigeeSurface, - const Acts::GeometryContext& gctx, - const Acts::MagneticFieldContext& mctx, - State& /*state*/) const { +inline Acts::Result +Acts::NumericalTrackLinearizer::linearizeTrack( + const BoundTrackParameters& params, double linPointTime, + const Surface& perigeeSurface, const Acts::GeometryContext& gctx, + const Acts::MagneticFieldContext& mctx, + MagneticFieldProvider::Cache& /*fieldCache*/) const { // Create propagator options - propagator_options_t pOptions(gctx, mctx); + PropagatorOptions<> pOptions(gctx, mctx); // Length scale at which we consider to be sufficiently close to the Perigee // surface to skip the propagation. @@ -42,13 +40,14 @@ Acts::NumericalTrackLinearizer:: Direction::fromScalarZeroAsPositive(intersection.pathLength()); // Propagate to the PCA of the reference point - auto result = m_cfg.propagator->propagate(params, perigeeSurface, pOptions); + auto result = + m_cfg.propagator->propagateToSurface(params, perigeeSurface, pOptions); if (!result.ok()) { return result.error(); } // Extracting the Perigee representation of the track wrt the reference point - auto endParams = *result->endParameters; + auto endParams = *result; BoundVector perigeeParams = endParams.parameters(); // Covariance and weight matrix at the PCA to the reference point @@ -124,12 +123,12 @@ Acts::NumericalTrackLinearizer:: Direction::fromScalarZeroAsPositive(intersection.pathLength()); // Propagate to the new PCA and extract Perigee parameters - auto newResult = m_cfg.propagator->propagate(wiggledCurvilinearParams, - perigeeSurface, pOptions); + auto newResult = m_cfg.propagator->propagateToSurface( + wiggledCurvilinearParams, perigeeSurface, pOptions); if (!newResult.ok()) { return newResult.error(); } - newPerigeeParams = (*newResult->endParameters).parameters(); + newPerigeeParams = newResult->parameters(); // Computing the numerical derivatives and filling the Jacobian completeJacobian.array().col(i) = diff --git a/Core/include/Acts/Vertexing/VertexFitterConcept.hpp b/Core/include/Acts/Vertexing/VertexFitterConcept.hpp index 77f0adcc0e6..32a126a0f3f 100644 --- a/Core/include/Acts/Vertexing/VertexFitterConcept.hpp +++ b/Core/include/Acts/Vertexing/VertexFitterConcept.hpp @@ -19,8 +19,6 @@ namespace Acts { namespace Concepts { namespace VertexFitter { -template -using propagator_t = typename T::Propagator_t; template using linearizer_t = typename T::Linearizer_t; template @@ -39,15 +37,12 @@ METHOD_TRAIT(fit_t, fit); typename S::State&>; static_assert(fit_exists, "fit method not found"); - constexpr static bool propagator_exists = exists; - static_assert(propagator_exists, "Propagator type not found"); constexpr static bool linearizer_exists = exists; static_assert(linearizer_exists, "Linearizer type not found"); constexpr static bool state_exists = exists; static_assert(state_exists, "State type not found"); constexpr static bool value = require; }; diff --git a/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp b/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp index 353b9dac595..958a00ee58b 100644 --- a/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp @@ -34,7 +34,6 @@ template class ZScanVertexFinder { static_assert(VertexFitterConcept, "Vertex fitter does not fulfill vertex fitter concept."); - using Propagator_t = typename vfitter_t::Propagator_t; public: /// Configuration struct @@ -42,11 +41,10 @@ class ZScanVertexFinder { /// @brief Finder configuration /// /// @param ipEst ImpactPointEstimator - Config(const ImpactPointEstimator& ipEst) - : ipEstimator(ipEst) {} + Config(const ImpactPointEstimator& ipEst) : ipEstimator(ipEst) {} // ImpactPointEstimator - ImpactPointEstimator ipEstimator; + ImpactPointEstimator ipEstimator; // FsmwMode1dFinder FsmwMode1dFinder mode1dFinder; diff --git a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/AdaptiveMultiVertexFinderAlgorithm.hpp b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/AdaptiveMultiVertexFinderAlgorithm.hpp index 7ee3f1e71f5..f4e135aa11f 100644 --- a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/AdaptiveMultiVertexFinderAlgorithm.hpp +++ b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/AdaptiveMultiVertexFinderAlgorithm.hpp @@ -52,8 +52,7 @@ struct AlgorithmContext; class AdaptiveMultiVertexFinderAlgorithm final : public IAlgorithm { public: using Propagator = Acts::Propagator>; - using IPEstimator = Acts::ImpactPointEstimator; - using Linearizer = Acts::HelicalTrackLinearizer; + using Linearizer = Acts::HelicalTrackLinearizer; using Fitter = Acts::AdaptiveMultiVertexFitter; using Options = Acts::VertexingOptions; diff --git a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/IterativeVertexFinderAlgorithm.hpp b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/IterativeVertexFinderAlgorithm.hpp index b8c699eb8d4..cd664d62af5 100644 --- a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/IterativeVertexFinderAlgorithm.hpp +++ b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/IterativeVertexFinderAlgorithm.hpp @@ -52,8 +52,7 @@ struct AlgorithmContext; class IterativeVertexFinderAlgorithm final : public IAlgorithm { public: using Propagator = Acts::Propagator>; - using IPEstimator = Acts::ImpactPointEstimator; - using Linearizer = Acts::HelicalTrackLinearizer; + using Linearizer = Acts::HelicalTrackLinearizer; using Fitter = Acts::FullBilloirVertexFitter; using Seeder = Acts::TrackDensityVertexFinder; diff --git a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp index 86935e4c778..4ef00347372 100644 --- a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp +++ b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp @@ -47,7 +47,7 @@ class VertexFitterAlgorithm final : public IAlgorithm { public: using Propagator = Acts::Propagator>; using PropagatorOptions = Acts::PropagatorOptions<>; - using Linearizer = Acts::HelicalTrackLinearizer; + using Linearizer = Acts::HelicalTrackLinearizer; using VertexFitter = Acts::FullBilloirVertexFitter; using VertexFitterOptions = Acts::VertexingOptions; diff --git a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp index 50f5fbf8223..a33bb12247d 100644 --- a/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp @@ -19,6 +19,7 @@ #include "Acts/Vertexing/AdaptiveMultiVertexFinder.hpp" #include "Acts/Vertexing/AdaptiveMultiVertexFitter.hpp" #include "Acts/Vertexing/GaussianTrackDensity.hpp" +#include "Acts/Vertexing/ImpactPointEstimator.hpp" #include "Acts/Vertexing/TrackAtVertex.hpp" #include "Acts/Vertexing/Vertex.hpp" #include "Acts/Vertexing/VertexingOptions.hpp" @@ -104,12 +105,14 @@ ActsExamples::AdaptiveMultiVertexFinderAlgorithm::executeAfterSeederChoice( auto propagator = std::make_shared(stepper); // Set up ImpactPointEstimator - IPEstimator::Config ipEstimatorCfg(m_cfg.bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg, - logger().cloneWithSuffix("ImpactPointEstimator")); + Acts::ImpactPointEstimator::Config ipEstimatorCfg(m_cfg.bField, propagator); + Acts::ImpactPointEstimator ipEstimator( + ipEstimatorCfg, logger().cloneWithSuffix("ImpactPointEstimator")); // Set up the helical track linearizer - Linearizer::Config ltConfig(m_cfg.bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = m_cfg.bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig, logger().cloneWithSuffix("HelicalTrackLinearizer")); diff --git a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp index e52608e3738..099b970f66b 100644 --- a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp @@ -79,12 +79,15 @@ ActsExamples::ProcessCode ActsExamples::IterativeVertexFinderAlgorithm::execute( Fitter vertexFitter(vertexFitterCfg, logger().cloneWithSuffix("FullBilloirVertexFitter")); // Setup the track linearizer - Linearizer::Config linearizerCfg(m_cfg.bField, propagator); + Linearizer::Config linearizerCfg; + linearizerCfg.bField = m_cfg.bField; + linearizerCfg.propagator = propagator; Linearizer linearizer(linearizerCfg, logger().cloneWithSuffix("HelicalTrackLinearizer")); // Setup the seed finder - IPEstimator::Config ipEstCfg(m_cfg.bField, propagator); - IPEstimator ipEst(ipEstCfg, logger().cloneWithSuffix("ImpactPointEstimator")); + Acts::ImpactPointEstimator::Config ipEstCfg(m_cfg.bField, propagator); + Acts::ImpactPointEstimator ipEst( + ipEstCfg, logger().cloneWithSuffix("ImpactPointEstimator")); Acts::GaussianTrackDensity::Config densityCfg; densityCfg.extractParameters.connect<&Acts::InputTrack::extractParameters>(); diff --git a/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp index b6ff233fd14..b5419254e33 100644 --- a/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/VertexFitterAlgorithm.cpp @@ -55,7 +55,9 @@ ActsExamples::ProcessCode ActsExamples::VertexFitterAlgorithm::execute( VertexFitter vertexFitter(vertexFitterCfg); VertexFitter::State state(m_cfg.bField->makeCache(ctx.magFieldContext)); // Setup the linearizer - Linearizer::Config ltConfig(m_cfg.bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = m_cfg.bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig, logger().cloneWithSuffix("HelLin")); ACTS_VERBOSE("Read from '" << m_cfg.inputTrackParameters << "'"); diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp index 755135e9d0a..84c790c688b 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp @@ -61,7 +61,7 @@ using namespace Acts::UnitLiterals; using Covariance = BoundSquareMatrix; using Propagator = Acts::Propagator>; -using Linearizer = HelicalTrackLinearizer; +using Linearizer = HelicalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -84,10 +84,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { auto propagator = std::make_shared(stepper); // IP 3D Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstimatorCfg(bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg); + ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); + ImpactPointEstimator ipEstimator(ipEstimatorCfg); std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; AnnealingUtility::Config annealingConfig; @@ -101,7 +99,9 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { fitterCfg.annealingTool = annealingUtility; // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Test smoothing @@ -244,10 +244,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_usertype_test) { }; // IP 3D Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstimatorCfg(bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg); + ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); + ImpactPointEstimator ipEstimator(ipEstimatorCfg); std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; AnnealingUtility::Config annealingConfig; @@ -261,7 +259,9 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_usertype_test) { fitterCfg.annealingTool = annealingUtility; // Linearizer - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Test smoothing @@ -389,10 +389,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_grid_seed_finder_test) { auto propagator = std::make_shared(stepper); // IP Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstCfg(bField, propagator); - IPEstimator ipEst(ipEstCfg); + ImpactPointEstimator::Config ipEstCfg(bField, propagator); + ImpactPointEstimator ipEst(ipEstCfg); std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; AnnealingUtility::Config annealingConfig; @@ -406,7 +404,9 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_grid_seed_finder_test) { fitterCfg.annealingTool = annealingUtility; // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Test smoothing @@ -539,10 +539,8 @@ BOOST_AUTO_TEST_CASE( auto propagator = std::make_shared(stepper); // IP Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstCfg(bField, propagator); - IPEstimator ipEst(ipEstCfg); + ImpactPointEstimator::Config ipEstCfg(bField, propagator); + ImpactPointEstimator ipEst(ipEstCfg); std::vector temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; AnnealingUtility::Config annealingConfig; @@ -556,7 +554,9 @@ BOOST_AUTO_TEST_CASE( fitterCfg.annealingTool = annealingUtility; // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Test smoothing diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp index 8403cadce15..216aef5bcf3 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp @@ -60,7 +60,7 @@ ACTS_LOCAL_LOGGER(Acts::getDefaultLogger("AMVFitterTests", Acts::Logging::INFO)) using Covariance = BoundSquareMatrix; using Propagator = Acts::Propagator>; -using Linearizer = HelicalTrackLinearizer; +using Linearizer = HelicalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -114,15 +114,15 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) { VertexingOptions vertexingOptions(geoContext, magFieldContext); // IP 3D Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ip3dEstCfg(bField, propagator); - IPEstimator ip3dEst(ip3dEstCfg); + ImpactPointEstimator::Config ip3dEstCfg(bField, propagator); + ImpactPointEstimator ip3dEst(ip3dEstCfg); AdaptiveMultiVertexFitter::Config fitterCfg(ip3dEst); // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Test smoothing @@ -334,16 +334,15 @@ BOOST_AUTO_TEST_CASE(time_fitting) { VertexingOptions vertexingOptions(geoContext, magFieldContext); - // IP 3D Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ip3dEstCfg(bField, propagator); - IPEstimator ip3dEst(ip3dEstCfg); + ImpactPointEstimator::Config ip3dEstCfg(bField, propagator); + ImpactPointEstimator ip3dEst(ip3dEstCfg); AdaptiveMultiVertexFitter::Config fitterCfg(ip3dEst); // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Test smoothing @@ -469,11 +468,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) { VertexingOptions vertexingOptions(geoContext, magFieldContext); - // IP 3D Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ip3dEstCfg(bField, propagator); - IPEstimator ip3dEst(ip3dEstCfg); + ImpactPointEstimator::Config ip3dEstCfg(bField, propagator); + ImpactPointEstimator ip3dEst(ip3dEstCfg); std::vector temperatures(1, 3.); AnnealingUtility::Config annealingConfig; @@ -486,7 +482,9 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) { fitterCfg.extractParameters.connect<&InputTrack::extractParameters>(); // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Test smoothing diff --git a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp index 8f24f48577f..5614b7f4f6d 100644 --- a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp @@ -52,7 +52,7 @@ namespace Acts { namespace Test { using Covariance = BoundSquareMatrix; -using Linearizer = HelicalTrackLinearizer>>; +using Linearizer = HelicalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -123,7 +123,9 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_defaulttrack_test) { // Set up propagator with void navigator auto propagator = std::make_shared>>(stepper); - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); // Constraint for vertex fit diff --git a/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp b/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp index bed3a84d8f4..ad4d6b99cb2 100644 --- a/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ImpactPointEstimatorTests.cpp @@ -58,8 +58,8 @@ using MagneticField = Acts::ConstantBField; using StraightPropagator = Acts::Propagator; using Stepper = Acts::EigenStepper<>; using Propagator = Acts::Propagator; -using Estimator = Acts::ImpactPointEstimator; -using StraightLineEstimator = Acts::ImpactPointEstimator; +using Estimator = Acts::ImpactPointEstimator; +using StraightLineEstimator = Acts::ImpactPointEstimator; const Acts::GeometryContext geoContext; const Acts::MagneticFieldContext magFieldContext; diff --git a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp index 4d9503d99fe..3915fbfce90 100644 --- a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp @@ -64,7 +64,7 @@ namespace Test { using Covariance = BoundSquareMatrix; using Propagator = Acts::Propagator>; -using Linearizer = HelicalTrackLinearizer; +using Linearizer = HelicalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -135,7 +135,9 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { auto propagator = std::make_shared(stepper); // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); using BilloirFitter = FullBilloirVertexFitter; @@ -146,11 +148,8 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { BilloirFitter bFitter(vertexFitterCfg); - // Impact point estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstimatorCfg(bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg); + ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); + ImpactPointEstimator ipEstimator(ipEstimatorCfg); using ZScanSeedFinder = ZScanVertexFinder; @@ -354,7 +353,9 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { auto propagator = std::make_shared(stepper); // Linearizer for user defined InputTrackStub type test - Linearizer::Config ltConfigUT(bField, propagator); + Linearizer::Config ltConfigUT; + ltConfigUT.bField = bField; + ltConfigUT.propagator = propagator; Linearizer linearizer(ltConfigUT); // Set up vertex fitter for user track type @@ -372,11 +373,8 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { BilloirFitter bFitter(vertexFitterCfg); - // IP Estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstimatorCfg(bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg); + ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); + ImpactPointEstimator ipEstimator(ipEstimatorCfg); using ZScanSeedFinder = ZScanVertexFinder; ZScanSeedFinder::Config seedFinderCfg(ipEstimator); @@ -561,7 +559,9 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_athena_reference) { auto propagator = std::make_shared(stepper); // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); using BilloirFitter = FullBilloirVertexFitter; @@ -572,11 +572,8 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_athena_reference) { BilloirFitter bFitter(vertexFitterCfg); - // Impact point estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstimatorCfg(bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg); + ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); + ImpactPointEstimator ipEstimator(ipEstimatorCfg); using ZScanSeedFinder = ZScanVertexFinder; diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp index 5a0f208d133..baa2828391c 100644 --- a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp @@ -51,7 +51,7 @@ namespace Test { using Covariance = BoundSquareMatrix; using Propagator = Acts::Propagator>; -using Linearizer = HelicalTrackLinearizer; +using Linearizer = HelicalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -103,16 +103,17 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) { auto propagator = std::make_shared(stepper); // Set up ImpactPointEstimator, used for comparisons later - using IPEstimator = ImpactPointEstimator; - IPEstimator::Config ip3dEstConfig(bField, propagator); - IPEstimator ip3dEst(ip3dEstConfig); - IPEstimator::State state(bField->makeCache(magFieldContext)); + ImpactPointEstimator::Config ip3dEstConfig(bField, propagator); + ImpactPointEstimator ip3dEst(ip3dEstConfig); + ImpactPointEstimator::State state(bField->makeCache(magFieldContext)); // Set up HelicalTrackLinearizer, needed for linearizing the tracks // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); - Linearizer::State linState(bField->makeCache(magFieldContext)); + auto fieldCache = bField->makeCache(magFieldContext); // Create perigee surface at origin std::shared_ptr perigeeSurface = @@ -160,7 +161,7 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) { LinearizedTrack linTrack = linearizer .linearizeTrack(params, 0, *perigee, geoContext, magFieldContext, - linState) + fieldCache) .value(); // Create TrackAtVertex diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp index 9aa8640852f..5dbf8016eae 100644 --- a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp @@ -51,7 +51,7 @@ namespace Test { using Covariance = BoundSquareMatrix; using Propagator = Acts::Propagator>; -using Linearizer = HelicalTrackLinearizer; +using Linearizer = HelicalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -104,9 +104,11 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_Updater) { auto propagator = std::make_shared(stepper); // Linearizer for BoundTrackParameters type test - Linearizer::Config ltConfig(bField, propagator); + Linearizer::Config ltConfig; + ltConfig.bField = bField; + ltConfig.propagator = propagator; Linearizer linearizer(ltConfig); - Linearizer::State state(bField->makeCache(magFieldContext)); + auto fieldCache = bField->makeCache(magFieldContext); // Create perigee surface at origin std::shared_ptr perigeeSurface = @@ -156,7 +158,7 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_Updater) { LinearizedTrack linTrack = linearizer .linearizeTrack(params, 0, *perigee, geoContext, magFieldContext, - state) + fieldCache) .value(); // Create TrackAtVertex diff --git a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp index e8cd7e89475..7ee6e4a3b2b 100644 --- a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp @@ -19,6 +19,7 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/MagneticField/ConstantBField.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" +#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/MagneticField/NullBField.hpp" #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/Propagator.hpp" @@ -51,11 +52,10 @@ using Covariance = BoundSquareMatrix; // (non-zero) constant B-field and a zero B-field. using HelicalPropagator = Propagator>; using StraightPropagator = Propagator; -using AnalyticalLinearizer = HelicalTrackLinearizer; -using StraightAnalyticalLinearizer = HelicalTrackLinearizer; -using NumericalLinearizer = NumericalTrackLinearizer; -using StraightNumericalLinearizer = - NumericalTrackLinearizer; +using AnalyticalLinearizer = HelicalTrackLinearizer; +using StraightAnalyticalLinearizer = HelicalTrackLinearizer; +using NumericalLinearizer = NumericalTrackLinearizer; +using StraightNumericalLinearizer = NumericalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -170,33 +170,35 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_test) { } // Linearizer for constant field and corresponding state - AnalyticalLinearizer::Config linConfig(constField, propagator); + AnalyticalLinearizer::Config linConfig; + linConfig.bField = constField; + linConfig.propagator = propagator; AnalyticalLinearizer linFactory(linConfig); - AnalyticalLinearizer::State linState(constField->makeCache(magFieldContext)); NumericalLinearizer::Config numLinConfig(constField, propagator); NumericalLinearizer numLinFactory(numLinConfig); - NumericalLinearizer::State numLinState( - constField->makeCache(magFieldContext)); // Linearizer for 0 field and corresponding state - StraightAnalyticalLinearizer::Config straightLinConfig(straightPropagator); + StraightAnalyticalLinearizer::Config straightLinConfig; + straightLinConfig.propagator = straightPropagator; StraightAnalyticalLinearizer straightLinFactory(straightLinConfig); - StraightAnalyticalLinearizer::State straightLinState( - zeroField->makeCache(magFieldContext)); StraightNumericalLinearizer::Config numStraightLinConfig(straightPropagator); StraightNumericalLinearizer numStraightLinFactory(numStraightLinConfig); - StraightNumericalLinearizer::State numStraightLinState( - zeroField->makeCache(magFieldContext)); + + MagneticFieldProvider::Cache fieldCache = + constField->makeCache(magFieldContext); + MagneticFieldProvider::Cache zeroFieldCache = + zeroField->makeCache(magFieldContext); // Lambda for comparing outputs of the two linearization methods // We compare the linearization result at the PCA to "linPoint" - auto checkLinearizers = [](auto& lin1, auto& linState1, auto& lin2, - auto& linState2, const BoundTrackParameters& track, - const Vector4& linPoint, - const auto& geometryContext, - const auto& fieldContext) { + auto checkLinearizers = [&fieldCache, &zeroFieldCache]( + auto& lin1, auto& lin2, + const BoundTrackParameters& track, + const Vector4& linPoint, + const auto& geometryContext, + const auto& fieldContext) { // In addition to comparing the output of the linearizers, we check that // they return non-zero quantities BoundVector vecBoundZero = BoundVector::Zero(); @@ -218,11 +220,11 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_test) { const LinearizedTrack linTrack1 = lin1.linearizeTrack(track, linPoint[3], *perigee, geometryContext, - fieldContext, linState1) + fieldContext, fieldCache) .value(); const LinearizedTrack linTrack2 = lin2.linearizeTrack(track, linPoint[3], *perigee, geometryContext, - fieldContext, linState2) + fieldContext, zeroFieldCache) .value(); // There should be no problem here because both linearizers compute @@ -265,12 +267,11 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_test) { // Compare linearizers for all tracks for (const BoundTrackParameters& trk : tracks) { BOOST_TEST_CONTEXT("Linearization in constant magnetic field") { - checkLinearizers(linFactory, linState, numLinFactory, numLinState, trk, - vtxPos, geoContext, magFieldContext); + checkLinearizers(linFactory, numLinFactory, trk, vtxPos, geoContext, + magFieldContext); } BOOST_TEST_CONTEXT("Linearization without magnetic field") { - checkLinearizers(straightLinFactory, straightLinState, - numStraightLinFactory, numStraightLinState, trk, vtxPos, + checkLinearizers(straightLinFactory, numStraightLinFactory, trk, vtxPos, geoContext, magFieldContext); } } diff --git a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp index b188df569a0..be86777e184 100644 --- a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp @@ -55,7 +55,7 @@ namespace Test { using Covariance = BoundSquareMatrix; using Propagator = Acts::Propagator>; -using Linearizer_t = HelicalTrackLinearizer; +using Linearizer_t = HelicalTrackLinearizer; // Create a test context GeometryContext geoContext = GeometryContext(); @@ -167,11 +167,8 @@ BOOST_AUTO_TEST_CASE(zscan_finder_test) { static_assert(VertexFinderConcept, "Vertex finder does not fulfill vertex finder concept."); - // Impact point estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstimatorCfg(bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg); + ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); + ImpactPointEstimator ipEstimator(ipEstimatorCfg); VertexFinder::Config cfg(ipEstimator); cfg.extractParameters.connect<&InputTrack::extractParameters>(); @@ -291,11 +288,8 @@ BOOST_AUTO_TEST_CASE(zscan_finder_usertrack_test) { static_assert(VertexFinderConcept, "Vertex finder does not fulfill vertex finder concept."); - // Impact point estimator - using IPEstimator = ImpactPointEstimator; - - IPEstimator::Config ipEstimatorCfg(bField, propagator); - IPEstimator ipEstimator(ipEstimatorCfg); + ImpactPointEstimator::Config ipEstimatorCfg(bField, propagator); + ImpactPointEstimator ipEstimator(ipEstimatorCfg); VertexFinder::Config cfg(ipEstimator); From fc68c5980b5e052dfd4b69c25d46be42a88f7a5a Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 15 Feb 2024 12:07:29 +0100 Subject: [PATCH 3/3] refactor: Set common initial covariance for vertex fitting (#2947) Values take from https://github.com/acts-project/acts/blob/19464fa0d24f031083ef3ad3108b74f2b5fa5454/Examples/Algorithms/Vertexing/src/AdaptiveMultiVertexFinderAlgorithm.cpp#L137 --- .../ActsExamples/Vertexing/VertexFitterAlgorithm.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp index 4ef00347372..2abbe4aec89 100644 --- a/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp +++ b/Examples/Algorithms/Vertexing/include/ActsExamples/Vertexing/VertexFitterAlgorithm.hpp @@ -68,10 +68,10 @@ class VertexFitterAlgorithm final : public IAlgorithm { Acts::Vector4 constraintPos = Acts::Vector4(0, 0, 0, 0); /// Vertex constraint covariance matrix Acts::SquareMatrix4 constraintCov = - Acts::Vector4(3 * Acts::UnitConstants::mm * Acts::UnitConstants::mm, - 3 * Acts::UnitConstants::mm * Acts::UnitConstants::mm, - 10 * Acts::UnitConstants::mm * Acts::UnitConstants::mm, - 1 * Acts::UnitConstants::ns * Acts::UnitConstants::ns) + Acts::Vector4(1e2 * Acts::UnitConstants::mm * Acts::UnitConstants::mm, + 1e2 * Acts::UnitConstants::mm * Acts::UnitConstants::mm, + 1e2 * Acts::UnitConstants::mm * Acts::UnitConstants::mm, + 1e8 * Acts::UnitConstants::mm * Acts::UnitConstants::mm) .asDiagonal(); };