From 298cbfbb46a4ff293793d5bce303e54fc3d341f7 Mon Sep 17 00:00:00 2001
From: Bastian Schlag <bastian.schlag@cern.ch>
Date: Wed, 25 Mar 2020 16:11:54 +0100
Subject: [PATCH] remove propagator options from HelicalTrackLinearizer config
 and move creation inside linearize method

---
 .../Vertexing/AdaptiveMultiVertexFitter.hpp   |  6 ++--
 .../Vertexing/AdaptiveMultiVertexFitter.ipp   | 13 +++----
 .../Vertexing/FullBilloirVertexFitter.ipp     |  4 ++-
 .../Acts/Vertexing/HelicalTrackLinearizer.hpp | 34 +++++--------------
 .../Acts/Vertexing/HelicalTrackLinearizer.ipp | 10 ++++--
 .../Acts/Vertexing/IterativeVertexFinder.hpp  | 12 ++++---
 .../Acts/Vertexing/IterativeVertexFinder.ipp  | 25 +++++++++-----
 .../Acts/Vertexing/LinearizerConcept.hpp      |  4 ++-
 .../AdaptiveMultiVertexFinderTests.cpp        |  2 +-
 .../AdaptiveMultiVertexFitterTests.cpp        |  4 +--
 .../FullBilloirVertexFitterTests.cpp          | 12 ++-----
 .../Vertexing/IterativeVertexFinderTests.cpp  |  4 +--
 .../KalmanVertexTrackUpdaterTests.cpp         | 26 ++++++++------
 .../Vertexing/KalmanVertexUpdaterTests.cpp    | 20 +++++------
 .../Vertexing/LinearizedTrackFactoryTests.cpp | 22 +++++++-----
 15 files changed, 103 insertions(+), 95 deletions(-)

diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
index 28138de2e..ae53491b8 100644
--- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
+++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp
@@ -264,8 +264,10 @@ class AdaptiveMultiVertexFitter {
   ///
   /// @param state The state object
   /// @param linearizer The track linearizer
-  Result<void> setWeightsAndUpdate(State& state,
-                                   const Linearizer_t& linearizer) const;
+  /// @param vertexingOptions Vertexing options
+  Result<void> setWeightsAndUpdate(
+      State& state, const Linearizer_t& linearizer,
+      const VertexingOptions<input_track_t>& vertexingOptions) const;
 
   /// @brief Collects all compatibility values of the track `trk`
   /// at all vertices it is currently attached to and outputs
diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp
index bec24d78f..dfb2d5f33 100644
--- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp
+++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp
@@ -100,7 +100,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fitImpl(
     // Now after having estimated all compatibilities of all tracks at
     // all vertices, run again over all vertices to set track weights
     // and update the vertex
-    setWeightsAndUpdate(state, linearizer);
+    setWeightsAndUpdate(state, linearizer, vertexingOptions);
     if (!state.annealingState.equilibriumReached) {
       m_cfg.annealingTool.anneal(state.annealingState);
     }
@@ -257,10 +257,10 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::
 }
 
 template <typename input_track_t, typename linearizer_t>
-Acts::Result<void> Acts::AdaptiveMultiVertexFitter<
-    input_track_t, linearizer_t>::setWeightsAndUpdate(State& state,
-                                                      const linearizer_t&
-                                                          linearizer) const {
+Acts::Result<void> Acts::
+    AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::setWeightsAndUpdate(
+        State& state, const linearizer_t& linearizer,
+        const VertexingOptions<input_track_t>& vertexingOptions) const {
   for (auto vtx : state.vertexCollection) {
     VertexInfo<input_track_t>& currentVtxInfo = state.vtxInfoMap[vtx];
 
@@ -279,7 +279,8 @@ Acts::Result<void> Acts::AdaptiveMultiVertexFitter<
                 BoundSymMatrix::Zero() ||
             state.vtxInfoMap[vtx].relinearize) {
           auto result = linearizer.linearizeTrack(
-              m_extractParameters(*trk), state.vtxInfoMap[vtx].oldPosition);
+              m_extractParameters(*trk), state.vtxInfoMap[vtx].oldPosition,
+              vertexingOptions.geoContext, vertexingOptions.magFieldContext);
           if (!result.ok()) {
             return result.error();
           }
diff --git a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp
index 0c7ed4064..f403fc25c 100644
--- a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp
+++ b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp
@@ -114,7 +114,9 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit(
         trackMomenta.push_back(Vector3D(phi, theta, qop));
       }
 
-      auto result = linearizer.linearizeTrack(trackParams, linPoint);
+      auto result = linearizer.linearizeTrack(trackParams, linPoint,
+                                              vertexingOptions.geoContext,
+                                              vertexingOptions.magFieldContext);
       if (result.ok()) {
         const auto& linTrack = *result;
         const auto& parametersAtPCA = linTrack.parametersAtPCA;
diff --git a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp
index d2b6bedc2..c24f7a460 100644
--- a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp
+++ b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.hpp
@@ -42,8 +42,6 @@ namespace Acts {
 template <typename propagator_t,
           typename propagator_options_t = PropagatorOptions<>>
 class HelicalTrackLinearizer {
-  using PropagatorOptions_t = propagator_options_t;
-
  public:
   using Propagator_t = propagator_t;
   using BField_t = typename Propagator_t::Stepper::BField;
@@ -54,40 +52,22 @@ class HelicalTrackLinearizer {
     ///
     /// @param bIn The magnetic field
     /// @param prop The propagator
-    /// @param propOptions The propagator options
-    /// @param doBackwardPropagation Set the propagation direction to backward
-    Config(const BField_t& bIn, std::shared_ptr<Propagator_t> prop,
-           PropagatorOptions_t propOptions, bool doBackwardPropagation = true)
-        : bField(bIn),
-          propagator(std::move(prop)),
-          pOptions(std::move(propOptions)) {
-      if (doBackwardPropagation) {
-        pOptions.direction = backward;
-      }
-    }
+    Config(const BField_t& bIn, std::shared_ptr<Propagator_t> prop)
+        : bField(bIn), propagator(std::move(prop)) {}
 
     /// @brief Config constructor if BField_t == NullBField (no B-Field
     /// provided)
     ///
     /// @param prop The propagator
-    /// @param propOptions The propagator options
-    /// @param doBackwardPropagation Set the propagation direction to backward
     template <typename T = BField_t,
               std::enable_if_t<std::is_same<T, NullBField>::value, int> = 0>
-    Config(std::shared_ptr<Propagator_t> prop, PropagatorOptions_t propOptions,
-           bool doBackwardPropagation = true)
-        : propagator(std::move(prop)), pOptions(std::move(propOptions)) {
-      if (doBackwardPropagation) {
-        pOptions.direction = backward;
-      }
-    }
+    Config(std::shared_ptr<Propagator_t> prop) : propagator(std::move(prop)) {}
 
     // The magnetic field
     BField_t bField;
     // The propagator
     std::shared_ptr<Propagator_t> propagator;
-    // The propagator options
-    PropagatorOptions_t pOptions;
+
     // Minimum q/p value
     double minQoP = 1e-15;
     // Maximum curvature value
@@ -104,10 +84,14 @@ class HelicalTrackLinearizer {
   ///
   /// @param params Parameters to linearize
   /// @param linPoint Linearization point
+  /// @param gctx The geometry context
+  /// @param mctx The magnetic field context
   ///
   /// @return Linearized track
   Result<LinearizedTrack> linearizeTrack(
-      const BoundParameters& params, const SpacePointVector& linPoint) const;
+      const BoundParameters& params, const SpacePointVector& linPoint,
+      const Acts::GeometryContext& gctx,
+      const Acts::MagneticFieldContext& mctx) const;
 
  private:
   /// Configuration object
diff --git a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp
index d1a8e16bb..8d60896de 100644
--- a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp
+++ b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp
@@ -11,16 +11,20 @@
 template <typename propagator_t, typename propagator_options_t>
 Acts::Result<Acts::LinearizedTrack> Acts::
     HelicalTrackLinearizer<propagator_t, propagator_options_t>::linearizeTrack(
-        const BoundParameters& params, const SpacePointVector& linPoint) const {
+        const BoundParameters& params, const SpacePointVector& linPoint,
+        const Acts::GeometryContext& gctx,
+        const Acts::MagneticFieldContext& mctx) const {
   Vector3D linPointPos = VectorHelpers::position(linPoint);
 
   const std::shared_ptr<PerigeeSurface> perigeeSurface =
       Surface::makeShared<PerigeeSurface>(linPointPos);
 
+  propagator_options_t pOptions(gctx, mctx);
+  pOptions.direction = backward;
+
   const BoundParameters* endParams = nullptr;
   // Do the propagation to linPointPos
-  auto result =
-      m_cfg.propagator->propagate(params, *perigeeSurface, m_cfg.pOptions);
+  auto result = m_cfg.propagator->propagate(params, *perigeeSurface, pOptions);
   if (result.ok()) {
     endParams = (*result).endParameters.get();
 
diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp
index 1d3a0b2e6..36983f530 100644
--- a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp
+++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp
@@ -180,9 +180,11 @@ class IterativeVertexFinder {
   /// a given track is to a given vertex
   ///
   /// @param params Track parameters
-  /// @param vertex Vertex
-  Result<double> getCompatibility(const BoundParameters& params,
-                                  const Vertex<InputTrack_t>& vertex) const;
+  /// @param vertex The vertex
+  /// @param vertexingOptions Vertexing options
+  Result<double> getCompatibility(
+      const BoundParameters& params, const Vertex<InputTrack_t>& vertex,
+      const VertexingOptions<InputTrack_t>& vertexingOptions) const;
 
   /// @brief Function that removes used tracks compatible with
   /// current vertex (`myVertex`) from `perigeesToFit` and `seedTracks`
@@ -191,10 +193,12 @@ class IterativeVertexFinder {
   /// @param myVertex Current vertex
   /// @param perigeesToFit Tracks used to fit `myVertex`
   /// @param seedTracks Tracks used for vertex seeding
+  /// @param vertexingOptions Vertexing options
   Result<void> removeUsedCompatibleTracks(
       Vertex<InputTrack_t>& myVertex,
       std::vector<const InputTrack_t*>& perigeesToFit,
-      std::vector<const InputTrack_t*>& seedTracks) const;
+      std::vector<const InputTrack_t*>& seedTracks,
+      const VertexingOptions<InputTrack_t>& vertexingOptions) const;
 
   /// @brief Function that fills vector with tracks compatible with seed vertex
   ///
diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp b/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp
index b67b17e5c..729dd830c 100644
--- a/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp
+++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp
@@ -109,7 +109,8 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find(
       }  // end reassignTracksAfterFirstFit case
          // still good vertex? might have changed in the meanwhile
       if (isGoodVertex) {
-        removeUsedCompatibleTracks(currentVertex, perigeesToFit, seedTracks);
+        removeUsedCompatibleTracks(currentVertex, perigeesToFit, seedTracks,
+                                   vertexingOptions);
 
         ACTS_DEBUG(
             "Number of seed tracks after removal of compatible tracks "
@@ -127,7 +128,7 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find(
         removeAllTracks(perigeesToFitSplitVertex, seedTracks);
       } else {
         removeUsedCompatibleTracks(currentSplitVertex, perigeesToFitSplitVertex,
-                                   seedTracks);
+                                   seedTracks, vertexingOptions);
       }
     }
     // Now fill vertex collection with vertex
@@ -196,9 +197,12 @@ void Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::removeAllTracks(
 template <typename vfitter_t, typename sfinder_t>
 Acts::Result<double>
 Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::getCompatibility(
-    const BoundParameters& params, const Vertex<InputTrack_t>& vertex) const {
+    const BoundParameters& params, const Vertex<InputTrack_t>& vertex,
+    const VertexingOptions<InputTrack_t>& vertexingOptions) const {
   // Linearize track
-  auto result = m_cfg.linearizer.linearizeTrack(params, vertex.fullPosition());
+  auto result = m_cfg.linearizer.linearizeTrack(
+      params, vertex.fullPosition(), vertexingOptions.geoContext,
+      vertexingOptions.magFieldContext);
   if (!result.ok()) {
     return result.error();
   }
@@ -230,7 +234,8 @@ Acts::Result<void>
 Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::removeUsedCompatibleTracks(
     Vertex<InputTrack_t>& myVertex,
     std::vector<const InputTrack_t*>& perigeesToFit,
-    std::vector<const InputTrack_t*>& seedTracks) const {
+    std::vector<const InputTrack_t*>& seedTracks,
+    const VertexingOptions<InputTrack_t>& vertexingOptions) const {
   std::vector<TrackAtVertex<InputTrack_t>> tracksAtVertex = myVertex.tracks();
 
   for (const auto& trackAtVtx : tracksAtVertex) {
@@ -274,8 +279,8 @@ Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::removeUsedCompatibleTracks(
 
   for (const auto& myPerigeeToFit : perigeesToFit) {
     // calculate chi2 w.r.t. last fitted vertex
-    auto result =
-        getCompatibility(m_extractParameters(*myPerigeeToFit), myVertex);
+    auto result = getCompatibility(m_extractParameters(*myPerigeeToFit),
+                                   myVertex, vertexingOptions);
 
     if (!result.ok()) {
       return result.error();
@@ -416,13 +421,15 @@ Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::reassignTracksToNewVertex(
           m_extractParameters(*(tracksIter->originalParams));
 
       // compute compatibility
-      auto resultNew = getCompatibility(trackPerigee, currentVertex);
+      auto resultNew =
+          getCompatibility(trackPerigee, currentVertex, vertexingOptions);
       if (!resultNew.ok()) {
         return Result<bool>::failure(resultNew.error());
       }
       double chi2NewVtx = *resultNew;
 
-      auto resultOld = getCompatibility(trackPerigee, vertexIt);
+      auto resultOld =
+          getCompatibility(trackPerigee, vertexIt, vertexingOptions);
       if (!resultOld.ok()) {
         return Result<bool>::failure(resultOld.error());
       }
diff --git a/Core/include/Acts/Vertexing/LinearizerConcept.hpp b/Core/include/Acts/Vertexing/LinearizerConcept.hpp
index bfa7eeadf..cc17d1f8f 100644
--- a/Core/include/Acts/Vertexing/LinearizerConcept.hpp
+++ b/Core/include/Acts/Vertexing/LinearizerConcept.hpp
@@ -31,7 +31,9 @@ namespace concept {
 
          constexpr static bool linTrack_exists = has_method<const S, Result<LinearizedTrack>,
          linTrack_t, const BoundParameters&,
-                     const SpacePointVector&>;
+                     const SpacePointVector&,
+                     const Acts::GeometryContext&,
+                      const Acts::MagneticFieldContext&>;
   
         static_assert(linTrack_exists, "linearizeTrack method not found");
 
diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp
index 7cd3ee8c9..f6980479c 100644
--- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp
+++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp
@@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) {
   fitterCfg.annealingTool = annealingUtility;
 
   // Linearizer for BoundParameters type test
-  Linearizer::Config ltConfig(bField, propagator, pOptions);
+  Linearizer::Config ltConfig(bField, propagator);
   Linearizer linearizer(ltConfig);
 
   // Test smoothing
diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp
index 6d238d134..886e8b6fc 100644
--- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp
+++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) {
       ip3dEst);
 
   // Linearizer for BoundParameters type test
-  Linearizer::Config ltConfig(bField, propagator, pOptions);
+  Linearizer::Config ltConfig(bField, propagator);
   Linearizer linearizer(ltConfig);
 
   // Test smoothing
@@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) {
   fitterCfg.annealingTool = annealingUtility;
 
   // Linearizer for BoundParameters type test
-  Linearizer::Config ltConfig(bField, propagator, pOptions);
+  Linearizer::Config ltConfig(bField, propagator);
   Linearizer linearizer(ltConfig);
 
   // Test smoothing
diff --git a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp
index e77c0b88d..249cd7554 100644
--- a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp
+++ b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp
@@ -49,9 +49,7 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_empty_input_test) {
   auto propagator =
       std::make_shared<Propagator<EigenStepper<ConstantBField>>>(stepper);
 
-  PropagatorOptions<> pOptions(tgContext, mfContext);
-
-  Linearizer::Config ltConfig(bField, propagator, pOptions);
+  Linearizer::Config ltConfig(bField, propagator);
   Linearizer linearizer(ltConfig);
 
   // Set up Billoir Vertex Fitter
@@ -133,9 +131,7 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_defaulttrack_test) {
   auto propagator =
       std::make_shared<Propagator<EigenStepper<ConstantBField>>>(stepper);
 
-  PropagatorOptions<> pOptions(tgContext, mfContext);
-
-  Linearizer::Config ltConfig(bField, propagator, pOptions);
+  Linearizer::Config ltConfig(bField, propagator);
   Linearizer linearizer(ltConfig);
 
   // Number of events
@@ -267,9 +263,7 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_usertrack_test) {
   auto propagator =
       std::make_shared<Propagator<EigenStepper<ConstantBField>>>(stepper);
 
-  PropagatorOptions<> pOptions(tgContext, mfContext);
-
-  Linearizer::Config ltConfig(bField, propagator, pOptions);
+  Linearizer::Config ltConfig(bField, propagator);
   Linearizer linearizer(ltConfig);
 
   const int nEvents = 10;
diff --git a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp
index 163eefd80..355ddbaad 100644
--- a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp
+++ b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp
@@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) {
     PropagatorOptions<> pOptions(tgContext, mfContext);
 
     // Linearizer for BoundParameters type test
-    Linearizer::Config ltConfig(bField, propagator, pOptions);
+    Linearizer::Config ltConfig(bField, propagator);
     Linearizer linearizer(ltConfig);
 
     using BilloirFitter = FullBilloirVertexFitter<BoundParameters, Linearizer>;
@@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) {
     PropagatorOptions<> pOptions(tgContext, mfContext);
 
     // Linearizer for user defined InputTrack type test
-    Linearizer::Config ltConfigUT(bField, propagator, pOptions);
+    Linearizer::Config ltConfigUT(bField, propagator);
     Linearizer linearizer(ltConfigUT);
 
     // Set up vertex fitter for user track type
diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp
index 864d36741..5662c77f6 100644
--- a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp
+++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp
@@ -30,11 +30,11 @@ namespace Test {
 
 using Covariance = BoundSymMatrix;
 using Propagator = Propagator<EigenStepper<ConstantBField>>;
-using Linearizer_t = HelicalTrackLinearizer<Propagator>;
+using Linearizer = HelicalTrackLinearizer<Propagator>;
 
 // Create a test context
-GeometryContext tgContext = GeometryContext();
-MagneticFieldContext mfContext = MagneticFieldContext();
+GeometryContext geoContext = GeometryContext();
+MagneticFieldContext magFieldContext = MagneticFieldContext();
 
 // Vertex x/y position distribution
 std::uniform_real_distribution<> vXYDist(-0.1_mm, 0.1_mm);
@@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) {
 
   // Set up propagator with void navigator
   auto propagator = std::make_shared<Propagator>(stepper);
-  PropagatorOptions<> pOptions(tgContext, mfContext);
+  PropagatorOptions<> pOptions(geoContext, magFieldContext);
 
   // Set up ImpactPoint3dEstimator, used for comparisons later
   ImpactPoint3dEstimator<BoundParameters, Propagator>::Config ip3dEstConfig(
@@ -90,8 +90,8 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) {
 
   // Set up HelicalTrackLinearizer, needed for linearizing the tracks
   // Linearizer for BoundParameters type test
-  Linearizer_t::Config ltConfig(bField, propagator, pOptions);
-  Linearizer_t linearizer(ltConfig);
+  Linearizer::Config ltConfig(bField, propagator);
+  Linearizer linearizer(ltConfig);
 
   // Create perigee surface at origin
   std::shared_ptr<PerigeeSurface> perigeeSurface =
@@ -129,12 +129,15 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) {
         0., 0., 0., 0., res_ph * res_ph, 0., 0., 0., 0., 0., 0.,
         res_th * res_th, 0., 0., 0., 0., 0., 0., res_qp * res_qp, 0., 0., 0.,
         0., 0., 0., 1.;
-    BoundParameters params(tgContext, std::move(covMat), paramVec,
+    BoundParameters params(geoContext, std::move(covMat), paramVec,
                            perigeeSurface);
 
     // Linearized state of the track
     LinearizedTrack linTrack =
-        linearizer.linearizeTrack(params, SpacePointVector::Zero()).value();
+        linearizer
+            .linearizeTrack(params, SpacePointVector::Zero(), geoContext,
+                            magFieldContext)
+            .value();
 
     // Create TrackAtVertex
     TrackAtVertex<BoundParameters> trkAtVtx(0., params, &params);
@@ -150,15 +153,16 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) {
     Vertex<BoundParameters> vtx(vtxPos);
 
     // Update trkAtVertex with assumption of originating from vtx
-    KalmanVertexTrackUpdater::update<BoundParameters>(tgContext, trkAtVtx, vtx);
+    KalmanVertexTrackUpdater::update<BoundParameters>(geoContext, trkAtVtx,
+                                                      vtx);
 
     // The old distance
     double oldDistance =
-        ip3dEst.calculateDistance(tgContext, fittedParamsCopy, vtxPos).value();
+        ip3dEst.calculateDistance(geoContext, fittedParamsCopy, vtxPos).value();
 
     // The new distance after update
     double newDistance =
-        ip3dEst.calculateDistance(tgContext, trkAtVtx.fittedParams, vtxPos)
+        ip3dEst.calculateDistance(geoContext, trkAtVtx.fittedParams, vtxPos)
             .value();
     if (debug) {
       std::cout << "Old distance: " << oldDistance << std::endl;
diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp
index 8141369f7..a8ba6b617 100644
--- a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp
+++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp
@@ -29,11 +29,11 @@ namespace Test {
 
 using Covariance = BoundSymMatrix;
 using Propagator = Propagator<EigenStepper<ConstantBField>>;
-using Linearizer_t = HelicalTrackLinearizer<Propagator>;
+using Linearizer = HelicalTrackLinearizer<Propagator>;
 
 // Create a test context
-GeometryContext tgContext = GeometryContext();
-MagneticFieldContext mfContext = MagneticFieldContext();
+GeometryContext geoContext = GeometryContext();
+MagneticFieldContext magFieldContext = MagneticFieldContext();
 
 // Vertex x/y position distribution
 std::uniform_real_distribution<> vXYDist(-0.1_mm, 0.1_mm);
@@ -81,12 +81,9 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_Updater) {
   // Set up propagator with void navigator
   auto propagator = std::make_shared<Propagator>(stepper);
 
-  // Set up LinearizedTrackFactory, needed for linearizing the tracks
-  PropagatorOptions<> pOptions(tgContext, mfContext);
-
   // Linearizer for BoundParameters type test
-  Linearizer_t::Config ltConfig(bField, propagator, pOptions);
-  Linearizer_t linearizer(ltConfig);
+  Linearizer::Config ltConfig(bField, propagator);
+  Linearizer linearizer(ltConfig);
 
   // Create perigee surface at origin
   std::shared_ptr<PerigeeSurface> perigeeSurface =
@@ -126,12 +123,15 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_Updater) {
         0., 0., 0., 0., res_ph * res_ph, 0., 0., 0., 0., 0., 0.,
         res_th * res_th, 0., 0., 0., 0., 0., 0., res_qp * res_qp, 0., 0., 0.,
         0., 0., 0., 1.;
-    BoundParameters params(tgContext, std::move(covMat), paramVec,
+    BoundParameters params(geoContext, std::move(covMat), paramVec,
                            perigeeSurface);
 
     // Linearized state of the track
     LinearizedTrack linTrack =
-        linearizer.linearizeTrack(params, SpacePointVector::Zero()).value();
+        linearizer
+            .linearizeTrack(params, SpacePointVector::Zero(), geoContext,
+                            magFieldContext)
+            .value();
 
     // Create TrackAtVertex
     TrackAtVertex<BoundParameters> trkAtVtx(0., params, &params);
diff --git a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp
index 48a9cae8f..33b84d5cc 100644
--- a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp
+++ b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp
@@ -32,7 +32,7 @@ using Linearizer =
     HelicalTrackLinearizer<Propagator<EigenStepper<ConstantBField>>>;
 
 // Create a test context
-GeometryContext tgContext = GeometryContext();
+GeometryContext geoContext = GeometryContext();
 MagneticFieldContext mfContext = MagneticFieldContext();
 
 // Vertex x/y position distribution
@@ -79,7 +79,6 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_test) {
   auto propagator =
       std::make_shared<Propagator<EigenStepper<ConstantBField>>>(stepper);
 
-  PropagatorOptions<> pOptions(tgContext, mfContext);
   // Create perigee surface
   std::shared_ptr<PerigeeSurface> perigeeSurface =
       Surface::makeShared<PerigeeSurface>(Vector3D(0., 0., 0.));
@@ -120,11 +119,11 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_test) {
     covMat << resD0 * resD0, 0., 0., 0., 0., 0., 0., resZ0 * resZ0, 0., 0., 0.,
         0., 0., 0., resPh * resPh, 0., 0., 0., 0., 0., 0., resTh * resTh, 0.,
         0., 0., 0., 0., 0., resQp * resQp, 0., 0., 0., 0., 0., 0., 1.;
-    tracks.push_back(BoundParameters(tgContext, std::move(covMat), paramVec,
+    tracks.push_back(BoundParameters(geoContext, std::move(covMat), paramVec,
                                      perigeeSurface));
   }
 
-  Linearizer::Config ltConfig(bField, propagator, pOptions);
+  Linearizer::Config ltConfig(bField, propagator);
   Linearizer linFactory(ltConfig);
 
   BoundVector vecBoundZero = BoundVector::Zero();
@@ -136,7 +135,10 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_test) {
 
   for (const BoundParameters& parameters : tracks) {
     LinearizedTrack linTrack =
-        linFactory.linearizeTrack(parameters, SpacePointVector::Zero()).value();
+        linFactory
+            .linearizeTrack(parameters, SpacePointVector::Zero(), geoContext,
+                            mfContext)
+            .value();
 
     BOOST_CHECK_NE(linTrack.parametersAtPCA, vecBoundZero);
     BOOST_CHECK_NE(linTrack.covarianceAtPCA, matBoundZero);
@@ -166,7 +168,6 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_straightline_test) {
   // Set up propagator with void navigator
   auto propagator = std::make_shared<Propagator<StraightLineStepper>>(stepper);
 
-  PropagatorOptions<> pOptions(tgContext, mfContext);
   // Create perigee surface
   std::shared_ptr<PerigeeSurface> perigeeSurface =
       Surface::makeShared<PerigeeSurface>(Vector3D(0., 0., 0.));
@@ -207,13 +208,13 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_straightline_test) {
     covMat << resD0 * resD0, 0., 0., 0., 0., 0., 0., resZ0 * resZ0, 0., 0., 0.,
         0., 0., 0., resPh * resPh, 0., 0., 0., 0., 0., 0., resTh * resTh, 0.,
         0., 0., 0., 0., 0., resQp * resQp, 0., 0., 0., 0., 0., 0., 1.;
-    tracks.push_back(BoundParameters(tgContext, std::move(covMat), paramVec,
+    tracks.push_back(BoundParameters(geoContext, std::move(covMat), paramVec,
                                      perigeeSurface));
   }
 
   // Set up helical track linearizer for the case of a non-existing
   // magnetic field, which results in the extreme case of a straight line
-  LinearizerStraightLine::Config ltConfig(propagator, pOptions);
+  LinearizerStraightLine::Config ltConfig(propagator);
   LinearizerStraightLine linFactory(ltConfig);
 
   BoundVector vecBoundZero = BoundVector::Zero();
@@ -225,7 +226,10 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_straightline_test) {
 
   for (const BoundParameters& parameters : tracks) {
     LinearizedTrack linTrack =
-        linFactory.linearizeTrack(parameters, SpacePointVector::Zero()).value();
+        linFactory
+            .linearizeTrack(parameters, SpacePointVector::Zero(), geoContext,
+                            mfContext)
+            .value();
 
     BOOST_CHECK_NE(linTrack.parametersAtPCA, vecBoundZero);
     BOOST_CHECK_NE(linTrack.covarianceAtPCA, matBoundZero);
-- 
GitLab