diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp index 839cb7e07e59185d4bce22ef51754532216e16b8..c96566e97590ead185a1a7d91a657639a2cb23e9 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp @@ -288,6 +288,13 @@ class AdaptiveMultiVertexFitter { /// /// @return False if shift was larger than maxRelativeShift bool checkSmallShift(State& state) const; + + /// @brief Updates tracks for current vertex with knowledge + /// of current vertex position + /// + /// @param state The state object + /// @param geoContext The geometry context + void doVertexSmoothing(State& state, const GeometryContext& geoContext) const; }; } // namespace Acts diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp index bd37552209eec1b5f1bc7bb171990b92c6dbc624..2f6b90fa4db6ff740ab50aac2aafbbf3fc87ae8c 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp @@ -6,8 +6,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +#include "Acts/Vertexing/KalmanVertexTrackUpdater.hpp" #include "Acts/Vertexing/KalmanVertexUpdater.hpp" -#include "Acts/Vertexing/VertexSmoother.hpp" #include "Acts/Vertexing/VertexingError.hpp" template <typename input_track_t, typename linearizer_t> @@ -114,14 +114,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fitImpl( // Check if smoothing is required if (m_cfg.doSmoothing) { - for (auto vtx : state.vertexCollection) { - // Smooth all tracks at vertex `vtx` - auto smoothRes = VertexSmoothing::smoothVertexSequentially<input_track_t>( - geoContext, vtx); - if (!smoothRes.ok()) { - return smoothRes.error(); - } - } + doVertexSmoothing(state, geoContext); } return {}; @@ -298,7 +291,7 @@ Acts::Result<void> Acts::AdaptiveMultiVertexFitter< state.vtxInfoMap[vtx].linPoint = state.vtxInfoMap[vtx].oldPosition; } // Update the vertex with the new track - KalmanVertexUpdater::updateVertexWithTrack<input_track_t>(vtx, + KalmanVertexUpdater::updateVertexWithTrack<input_track_t>(*vtx, trkAtVtx); } else { ACTS_VERBOSE("Track weight too low. Skip track."); @@ -344,3 +337,15 @@ bool Acts::AdaptiveMultiVertexFitter< } return true; } + +template <typename input_track_t, typename linearizer_t> +void Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>:: + doVertexSmoothing(State& state, const GeometryContext& geoContext) const { + for (const auto vtx : state.vertexCollection) { + for (const auto trk : state.vtxInfoMap[vtx].trackLinks) { + KalmanVertexTrackUpdater::update<input_track_t>( + geoContext, state.tracksAtVerticesMap.at(std::make_pair(trk, vtx)), + *vtx); + } + } +} diff --git a/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.hpp b/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.hpp index 6341b48a73c253a947cf953f0a4cac5650ad0eb8..b069b2bb50c6398874a93febd9695959231ae24a 100644 --- a/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.hpp +++ b/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.hpp @@ -26,9 +26,8 @@ namespace KalmanVertexTrackUpdater { /// @param track Track to update /// @param vtx Vertex `track` belongs to template <typename input_track_t> -Result<void> update(const GeometryContext& gctx, - TrackAtVertex<input_track_t>& track, - const Vertex<input_track_t>* vtx); +void update(const GeometryContext& gctx, TrackAtVertex<input_track_t>& track, + const Vertex<input_track_t>& vtx); namespace detail { diff --git a/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.ipp b/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.ipp index 257d147b3e9a132393c29f264a1c2ba29f062fd0..c898142c2ab3b6a0cd79fe7efb465721d8fe9cb5 100644 --- a/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.ipp +++ b/Core/include/Acts/Vertexing/KalmanVertexTrackUpdater.ipp @@ -12,14 +12,10 @@ #include "Acts/Vertexing/VertexingError.hpp" template <typename input_track_t> -Acts::Result<void> Acts::KalmanVertexTrackUpdater::update( - const GeometryContext& gctx, TrackAtVertex<input_track_t>& track, - const Vertex<input_track_t>* vtx) { - if (vtx == nullptr) { - return VertexingError::EmptyInput; - } - - const auto vtxPos = vtx->fullPosition().template head<3>(); +void Acts::KalmanVertexTrackUpdater::update(const GeometryContext& gctx, + TrackAtVertex<input_track_t>& track, + const Vertex<input_track_t>& vtx) { + const auto vtxPos = vtx.fullPosition().template head<3>(); // Get the linearized track const LinearizedTrack& linTrack = track.linearizedState; @@ -27,7 +23,7 @@ Acts::Result<void> Acts::KalmanVertexTrackUpdater::update( // Check if linearized state exists if (linTrack.covarianceAtPCA.determinant() == 0.) { // Track has no linearized state, returning w/o update - return {}; + return; } // Retrieve linTrack information @@ -58,7 +54,7 @@ Acts::Result<void> Acts::KalmanVertexTrackUpdater::update( newTrkParams(ParID_t::eQOP) = newTrkMomentum(2); // qOverP // Vertex covariance and weight matrices - const auto vtxCov = vtx->fullCovariance().template block<3, 3>(0, 0); + const auto vtxCov = vtx.fullCovariance().template block<3, 3>(0, 0); const auto vtxWeight = vtxCov.inverse(); // New track covariance matrix @@ -75,11 +71,11 @@ Acts::Result<void> Acts::KalmanVertexTrackUpdater::update( const auto& reducedVtxWeight = matrixCache.newVertexWeight; // Difference in positions - auto posDiff = vtx->position() - matrixCache.newVertexPos; + auto posDiff = vtx.position() - matrixCache.newVertexPos; // Get smoothed params auto smParams = - trkParams - (residual + posJac * vtx->fullPosition().template head<3>() + + trkParams - (residual + posJac * vtx.fullPosition().template head<3>() + momJac * newTrkMomentum); // New chi2 to be set later @@ -104,7 +100,7 @@ Acts::Result<void> Acts::KalmanVertexTrackUpdater::update( // Create new refitted parameters std::shared_ptr<PerigeeSurface> perigeeSurface = Surface::makeShared<PerigeeSurface>( - VectorHelpers::position(vtx->fullPosition())); + VectorHelpers::position(vtx.fullPosition())); BoundParameters refittedPerigee = BoundParameters( gctx, std::move(fullPerTrackCov), newTrkParams, perigeeSurface); @@ -114,7 +110,7 @@ Acts::Result<void> Acts::KalmanVertexTrackUpdater::update( track.chi2Track = chi2; track.ndf = 2 * track.trackWeight; - return {}; + return; } Acts::BoundMatrix diff --git a/Core/include/Acts/Vertexing/KalmanVertexUpdater.hpp b/Core/include/Acts/Vertexing/KalmanVertexUpdater.hpp index adb667eea59e91951ec77c67dd0145d38c6e903e..e682b5e6ac3d756d2cf4589152b9b242fca2a028 100644 --- a/Core/include/Acts/Vertexing/KalmanVertexUpdater.hpp +++ b/Core/include/Acts/Vertexing/KalmanVertexUpdater.hpp @@ -41,7 +41,7 @@ struct MatrixCache { /// @param vtx Vertex to be updated /// @param trk Track to be used for updating the vertex template <typename input_track_t> -void updateVertexWithTrack(Vertex<input_track_t>* vtx, +void updateVertexWithTrack(Vertex<input_track_t>& vtx, TrackAtVertex<input_track_t>& trk); /// @brief Updates vertex position @@ -54,7 +54,7 @@ void updateVertexWithTrack(Vertex<input_track_t>* vtx, /// /// @return Vertex with updated position and covariance template <typename input_track_t> -void updatePosition(const Acts::Vertex<input_track_t>* vtx, +void updatePosition(const Acts::Vertex<input_track_t>& vtx, const Acts::LinearizedTrack& linTrack, double trackWeight, int sign, MatrixCache& matrixCache); @@ -67,7 +67,7 @@ namespace detail { /// /// @return Chi2 template <typename input_track_t> -double vertexPositionChi2(const Vertex<input_track_t>* oldVtx, +double vertexPositionChi2(const Vertex<input_track_t>& oldVtx, const MatrixCache& matrixCache); /// @brief Calculates chi2 of refitted track parameters @@ -88,7 +88,7 @@ double trackParametersChi2(const LinearizedTrack& linTrack, /// @param trk Track to be added to/removed from vtx /// @param sign +1 (add track) or -1 (remove track) template <typename input_track_t> -void update(Vertex<input_track_t>* vtx, TrackAtVertex<input_track_t>& trk, +void update(Vertex<input_track_t>& vtx, TrackAtVertex<input_track_t>& trk, int sign); } // Namespace detail diff --git a/Core/include/Acts/Vertexing/KalmanVertexUpdater.ipp b/Core/include/Acts/Vertexing/KalmanVertexUpdater.ipp index 64b9e83373a8c6bcc2a547f081f7ffe2d28941c4..aac2e850800cd9cf0e887739d9adf3fb93d00e9f 100644 --- a/Core/include/Acts/Vertexing/KalmanVertexUpdater.ipp +++ b/Core/include/Acts/Vertexing/KalmanVertexUpdater.ipp @@ -11,13 +11,13 @@ template <typename input_track_t> void Acts::KalmanVertexUpdater::updateVertexWithTrack( - Vertex<input_track_t>* vtx, TrackAtVertex<input_track_t>& trk) { + Vertex<input_track_t>& vtx, TrackAtVertex<input_track_t>& trk) { detail::update<input_track_t>(vtx, trk, 1); } template <typename input_track_t> void Acts::KalmanVertexUpdater::detail::update( - Vertex<input_track_t>* vtx, TrackAtVertex<input_track_t>& trk, int sign) { + Vertex<input_track_t>& vtx, TrackAtVertex<input_track_t>& trk, int sign) { double trackWeight = trk.trackWeight; MatrixCache matrixCache; @@ -25,7 +25,7 @@ void Acts::KalmanVertexUpdater::detail::update( updatePosition(vtx, trk.linearizedState, trackWeight, sign, matrixCache); // Get fit quality parameters wrt to old vertex - std::pair fitQuality = vtx->fitQuality(); + std::pair fitQuality = vtx.fitQuality(); double chi2 = fitQuality.first; double ndf = fitQuality.second; @@ -41,9 +41,9 @@ void Acts::KalmanVertexUpdater::detail::update( ndf += sign * trackWeight * 2.; // Updating the vertex - vtx->setPosition(matrixCache.newVertexPos); - vtx->setCovariance(matrixCache.newVertexCov); - vtx->setFitQuality(chi2, ndf); + vtx.setPosition(matrixCache.newVertexPos); + vtx.setCovariance(matrixCache.newVertexCov); + vtx.setFitQuality(chi2, ndf); // Updates track at vertex if already there // by removing it first and adding new one. @@ -61,7 +61,7 @@ void Acts::KalmanVertexUpdater::detail::update( template <typename input_track_t> void Acts::KalmanVertexUpdater::updatePosition( - const Acts::Vertex<input_track_t>* vtx, + const Acts::Vertex<input_track_t>& vtx, const Acts::LinearizedTrack& linTrack, double trackWeight, int sign, MatrixCache& matrixCache) { // Retrieve linTrack information @@ -74,8 +74,8 @@ void Acts::KalmanVertexUpdater::updatePosition( const auto& trkParamWeight = linTrack.weightAtPCA.block<5, 5>(0, 0); // Vertex to be updated - const auto& oldVtxPos = vtx->position(); - matrixCache.oldVertexWeight = (vtx->covariance()).inverse(); + const auto& oldVtxPos = vtx.position(); + matrixCache.oldVertexWeight = (vtx.covariance()).inverse(); // W_k matrix matrixCache.momWeightInv = @@ -101,8 +101,8 @@ void Acts::KalmanVertexUpdater::updatePosition( template <typename input_track_t> double Acts::KalmanVertexUpdater::detail::vertexPositionChi2( - const Vertex<input_track_t>* oldVtx, const MatrixCache& matrixCache) { - auto posDiff = matrixCache.newVertexPos - oldVtx->position(); + const Vertex<input_track_t>& oldVtx, const MatrixCache& matrixCache) { + auto posDiff = matrixCache.newVertexPos - oldVtx.position(); // Calculate and return corresponding chi2 return posDiff.transpose() * (matrixCache.oldVertexWeight * posDiff); diff --git a/Core/include/Acts/Vertexing/VertexSmoother.hpp b/Core/include/Acts/Vertexing/VertexSmoother.hpp deleted file mode 100644 index a2065e1a6279a360393da6819a6d8764cfa76af9..0000000000000000000000000000000000000000 --- a/Core/include/Acts/Vertexing/VertexSmoother.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2019 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include "Acts/Utilities/Result.hpp" -#include "Acts/Vertexing/KalmanVertexTrackUpdater.hpp" -#include "Acts/Vertexing/TrackAtVertex.hpp" -#include "Acts/Vertexing/Vertex.hpp" - -namespace Acts { -namespace VertexSmoothing { - -/// @brief Updates all tracks at vertex -/// with knowledge of the vertex position -/// -/// @param gctx The Geometry Context -/// @param vtx The vertex -/// -/// @tparam input_track_t Track object type -template <typename input_track_t> -static Result<void> smoothVertexSequentially(const GeometryContext& gctx, - Vertex<input_track_t>* vtx) { - if (vtx == nullptr) { - return VertexingError::EmptyInput; - } - - std::vector<TrackAtVertex<input_track_t>> tracks = vtx->tracks(); - for (auto& trk : tracks) { - // update trk - auto res = KalmanVertexTrackUpdater::update<input_track_t>(gctx, trk, vtx); - if (!res.ok()) { - return res.error(); - } - } - - vtx->setTracksAtVertex(tracks); - - return {}; -} - -} // Namespace VertexSmoothing -} // Namespace Acts diff --git a/Tests/UnitTests/Core/Vertexing/CMakeLists.txt b/Tests/UnitTests/Core/Vertexing/CMakeLists.txt index 829ef494cba19b367f321b3d9350fabc10d24d43..e7f49ea2fd78924aba20b0198466e538ba929bdf 100644 --- a/Tests/UnitTests/Core/Vertexing/CMakeLists.txt +++ b/Tests/UnitTests/Core/Vertexing/CMakeLists.txt @@ -7,6 +7,5 @@ add_unittest(LinearizedTrackFactoryTests LinearizedTrackFactoryTests.cpp) add_unittest(AdaptiveMultiVertexFitterTests AdaptiveMultiVertexFitterTests.cpp) add_unittest(AdaptiveMultiVertexFinderTests AdaptiveMultiVertexFinderTests.cpp) add_unittest(TrackToVertexIPEstimatorTests TrackToVertexIPEstimatorTests.cpp) -add_unittest(VertexSmootherTests VertexSmootherTests.cpp) add_unittest(ZScanVertexFinderTests ZScanVertexFinderTests.cpp) add_unittest(TrackDensityVertexFinderTests TrackDensityVertexFinderTests.cpp) \ No newline at end of file diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp index 12ad0af598726a0df5479eeff25238e597f69bd2..864d36741668fdc3416405b890575d40c959fc4f 100644 --- a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp @@ -150,10 +150,7 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) { Vertex<BoundParameters> vtx(vtxPos); // Update trkAtVertex with assumption of originating from vtx - auto res = KalmanVertexTrackUpdater::update<BoundParameters>( - tgContext, trkAtVtx, &vtx); - - BOOST_CHECK(res.ok()); + KalmanVertexTrackUpdater::update<BoundParameters>(tgContext, trkAtVtx, vtx); // The old distance double oldDistance = diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp index 4afde035d09d7a41914158af315144d4ee15c2d0..8141369f751d2b0207f8df7fd2ca49b442d112d7 100644 --- a/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexUpdaterTests.cpp @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_Updater) { vtx.setFullCovariance(SpacePointSymMatrix::Identity() * 0.01); // Update trkAtVertex with assumption of originating from vtx - KalmanVertexUpdater::updateVertexWithTrack<BoundParameters>(&vtx, trkAtVtx); + KalmanVertexUpdater::updateVertexWithTrack<BoundParameters>(vtx, trkAtVtx); if (debug) { std::cout << "Old vertex position: " << vtxPos << std::endl; diff --git a/Tests/UnitTests/Core/Vertexing/VertexSmootherTests.cpp b/Tests/UnitTests/Core/Vertexing/VertexSmootherTests.cpp deleted file mode 100644 index 8970a28a1d731535bf235a7b899b799693b6af94..0000000000000000000000000000000000000000 --- a/Tests/UnitTests/Core/Vertexing/VertexSmootherTests.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2019 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include <boost/test/data/test_case.hpp> -#include <boost/test/tools/output_test_stream.hpp> -#include <boost/test/unit_test.hpp> - -#include <Acts/Vertexing/VertexSmoother.hpp> -#include "Acts/MagneticField/ConstantBField.hpp" -#include "Acts/Propagator/EigenStepper.hpp" -#include "Acts/Propagator/Propagator.hpp" -#include "Acts/Surfaces/PerigeeSurface.hpp" -#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" -#include "Acts/Utilities/Definitions.hpp" -#include "Acts/Utilities/Units.hpp" -#include "Acts/Vertexing/FullBilloirVertexFitter.hpp" -#include "Acts/Vertexing/HelicalTrackLinearizer.hpp" -#include "Acts/Vertexing/Vertex.hpp" - -namespace Acts { -namespace Test { - -using Covariance = BoundSymMatrix; -using Propagator = Propagator<EigenStepper<ConstantBField>>; -using Linearizer_t = HelicalTrackLinearizer<Propagator>; - -// Create a test context -GeometryContext tgContext = GeometryContext(); -MagneticFieldContext mfContext = MagneticFieldContext(); - -// Vertex x/y position distribution -std::uniform_real_distribution<> vXYDist(-0.1 * units::_mm, 0.1 * units::_mm); -// Vertex z position distribution -std::uniform_real_distribution<> vZDist(-20 * units::_mm, 20 * units::_mm); -// Track d0 distribution -std::uniform_real_distribution<> d0Dist(-0.01 * units::_mm, 0.01 * units::_mm); -// Track z0 distribution -std::uniform_real_distribution<> z0Dist(-0.2 * units::_mm, 0.2 * units::_mm); -// Track pT distribution -std::uniform_real_distribution<> pTDist(0.4 * units::_GeV, 10. * units::_GeV); -// Track phi distribution -std::uniform_real_distribution<> phiDist(-M_PI, M_PI); -// Track theta distribution -std::uniform_real_distribution<> thetaDist(1.0, M_PI - 1.0); -// Track charge helper distribution -std::uniform_real_distribution<> qDist(-1, 1); -// Track IP resolution distribution -std::uniform_real_distribution<> resIPDist(0., 100. * units::_um); -// Track angular distribution -std::uniform_real_distribution<> resAngDist(0., 0.1); -// Track q/p resolution distribution -std::uniform_real_distribution<> resQoPDist(-0.1, 0.1); -// Number of tracks distritbution -std::uniform_int_distribution<> nTracksDist(3, 10); - -/// @brief Unit test for VertexSmoother -/// -BOOST_AUTO_TEST_CASE(sequential_vertex_smoother_test) { - bool debugMode = false; - - // Set up RNG - int mySeed = 31415; - std::mt19937 gen(mySeed); - - // Number of tracks - unsigned int nTracks = nTracksDist(gen); - - // Set up constant B-Field - ConstantBField bField(Vector3D(0., 0., 1.) * units::_T); - - // Set up Eigenstepper - EigenStepper<ConstantBField> stepper(bField); - - // 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); - - // Set up Billoir Vertex Fitter - FullBilloirVertexFitter<BoundParameters, Linearizer_t>::Config - vertexFitterCfg; - FullBilloirVertexFitter<BoundParameters, Linearizer_t> billoirFitter( - vertexFitterCfg); - - VertexFitterOptions<BoundParameters> vfOptions(tgContext, mfContext); - - // Now: create some tracks, fit and retrieve vertex using Billoirfitter - // Create position of vertex and perigee surface - double x = vXYDist(gen); - double y = vXYDist(gen); - double z = vZDist(gen); - - SpacePointVector vertexPosition(x, y, z, 0.); - std::shared_ptr<PerigeeSurface> perigeeSurface = - Surface::makeShared<PerigeeSurface>(Vector3D(0., 0., 0.)); - - // Calculate d0 and z0 corresponding to vertex position - double d0V = sqrt(x * x + y * y); - double z0V = z; - - // Start constructing nTracks tracks in the following - std::vector<BoundParameters> tracks; - - // Construct random track emerging from vicinity of vertex position - // Vector to store track objects used for vertex fit - for (unsigned int iTrack = 0; iTrack < nTracks; iTrack++) { - // Construct positive or negative charge randomly - double q = qDist(gen) < 0 ? -1. : 1.; - - // Construct random track parameters - BoundParameters::ParVector_t paramVec; - paramVec << d0V + d0Dist(gen), z0V + z0Dist(gen), phiDist(gen), - thetaDist(gen), q / pTDist(gen), 0.; - - // Fill vector of track objects with simple covariance matrix - Covariance covMat; - - // Resolutions - double resD0 = resIPDist(gen); - double resZ0 = resIPDist(gen); - double resPh = resAngDist(gen); - double resTh = resAngDist(gen); - double resQp = resQoPDist(gen); - - 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, - perigeeSurface)); - } - - std::vector<const BoundParameters*> tracksPtr; - for (const auto& trk : tracks) { - tracksPtr.push_back(&trk); - } - - Vertex<BoundParameters> fittedVertex = - billoirFitter.fit(tracksPtr, linearizer, vfOptions).value(); - - // copy vertex for later comparison - Vertex<BoundParameters> vertexBeforeSmoothing = fittedVertex; - - VertexSmoothing::smoothVertexSequentially<BoundParameters>(tgContext, - &fittedVertex); - - // Billoirfitter does not provide the TracksAtVertex with a linearized - // state, - // hence returns tracks not refitted. However, sizes should match. - BOOST_CHECK_EQUAL(vertexBeforeSmoothing.tracks().size(), - fittedVertex.tracks().size()); - - std::vector<TrackAtVertex<BoundParameters>> tracksWithLinState; - for (auto trackAtVtx : fittedVertex.tracks()) { - BoundParameters fittedParams = trackAtVtx.fittedParams; - - LinearizedTrack linTrack = - linearizer.linearizeTrack(fittedParams, vertexPosition).value(); - trackAtVtx.linearizedState = linTrack; - tracksWithLinState.push_back(trackAtVtx); - } - - // set tracks with linearized state to vertex - fittedVertex.setTracksAtVertex(tracksWithLinState); - VertexSmoothing::smoothVertexSequentially<BoundParameters>(tgContext, - &fittedVertex); - - BOOST_CHECK_EQUAL(vertexBeforeSmoothing.tracks().size(), - fittedVertex.tracks().size()); - - for (unsigned int i = 0; i < fittedVertex.tracks().size(); ++i) { - auto paramOld = vertexBeforeSmoothing.tracks()[i].fittedParams; - auto paramNew = fittedVertex.tracks()[i].fittedParams; - BOOST_CHECK_NE(paramOld, paramNew); - if (debugMode) { - std::cout << "Track %d, old params: " << paramOld << std::endl; - std::cout << "Track %d, new params: " << paramNew << std::endl; - } - } -} - -} // namespace Test -} // namespace Acts