From 577e12d2ad08d84486241817b20baa49a5c80af3 Mon Sep 17 00:00:00 2001 From: Bastian Schlag <bastian.schlag@cern.ch> Date: Mon, 16 Mar 2020 11:22:20 +0100 Subject: [PATCH 1/6] update AnnealingUtility implementation --- Core/src/Utilities/AnnealingUtility.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Core/src/Utilities/AnnealingUtility.cpp b/Core/src/Utilities/AnnealingUtility.cpp index 635f51bb6..3e339515b 100644 --- a/Core/src/Utilities/AnnealingUtility.cpp +++ b/Core/src/Utilities/AnnealingUtility.cpp @@ -15,7 +15,7 @@ /// /// @return exp(-1./2. * chi2 / temp) static double gaussFunc(double chi2, double temp) { - return std::exp(-1. / 2. * chi2 / temp); + return std::exp(-chi2 / (2. * temp)); } void AnnealingUtility::anneal(State& state) const { @@ -31,20 +31,20 @@ double AnnealingUtility::getWeight(State& state, double chi2, const double currentTemp = m_cfg.setOfTemperatures[state.currentTemperatureIndex]; - double allWeights = 0.; - for (auto val : allChi2) { - allWeights += gaussFunc(val, currentTemp); - } + double base = gaussFunc(1., currentTemp); + + double denom = std::pow(base, m_cfg.cutOff - chi2); - double actualWeight = gaussFunc(chi2, currentTemp); + for (double val : allChi2) { + denom += std::pow(base, val - chi2); + } - return actualWeight / (gaussFunc(m_cfg.cutOff, currentTemp) + allWeights); + return 1. / denom; } double AnnealingUtility::getWeight(State& state, double chi2) const { const double currentTemp = m_cfg.setOfTemperatures[state.currentTemperatureIndex]; - return gaussFunc(chi2, currentTemp) / - (gaussFunc(m_cfg.cutOff, currentTemp) + gaussFunc(chi2, currentTemp)); + return 1. / (1. + gaussFunc(m_cfg.cutOff - chi2, currentTemp)); } -- GitLab From 0ad92bfe584ba7417c5097d2d2fe1c55e28fabbc Mon Sep 17 00:00:00 2001 From: Bastian Schlag <bastian.schlag@cern.ch> Date: Wed, 25 Mar 2020 13:43:50 +0100 Subject: [PATCH 2/6] merge VertexFitterOptions and VertexFinderOptions to VertexingOptions --- .../Vertexing/AdaptiveMultiVertexFinder.hpp | 17 ++++--- .../Vertexing/AdaptiveMultiVertexFinder.ipp | 24 +++++----- .../Vertexing/AdaptiveMultiVertexFitter.hpp | 18 ++++---- .../Vertexing/AdaptiveMultiVertexFitter.ipp | 20 ++++----- .../Acts/Vertexing/DummyVertexFitter.hpp | 4 +- .../Vertexing/FullBilloirVertexFitter.hpp | 6 +-- .../Vertexing/FullBilloirVertexFitter.ipp | 35 ++++++++------- .../Acts/Vertexing/IterativeVertexFinder.hpp | 18 ++++---- .../Acts/Vertexing/IterativeVertexFinder.ipp | 41 +++++++---------- .../Vertexing/TrackDensityVertexFinder.hpp | 6 +-- .../Vertexing/TrackDensityVertexFinder.ipp | 6 +-- .../Acts/Vertexing/VertexFinderConcept.hpp | 4 +- .../Acts/Vertexing/VertexFitterConcept.hpp | 4 +- .../Acts/Vertexing/VertexFitterOptions.hpp | 44 ------------------- ...FinderOptions.hpp => VertexingOptions.hpp} | 8 ++-- .../Acts/Vertexing/ZScanVertexFinder.hpp | 6 +-- .../Acts/Vertexing/ZScanVertexFinder.ipp | 16 +++---- .../AdaptiveMultiVertexFinderTests.cpp | 8 ++-- .../AdaptiveMultiVertexFitterTests.cpp | 10 ++--- .../FullBilloirVertexFitterTests.cpp | 16 +++---- .../Vertexing/IterativeVertexFinderTests.cpp | 8 ++-- .../TrackDensityVertexFinderTests.cpp | 22 +++++----- .../Core/Vertexing/ZScanVertexFinderTests.cpp | 8 ++-- 23 files changed, 147 insertions(+), 202 deletions(-) delete mode 100644 Core/include/Acts/Vertexing/VertexFitterOptions.hpp rename Core/include/Acts/Vertexing/{VertexFinderOptions.hpp => VertexingOptions.hpp} (91%) diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp index 1ef31dd6a..65337fc60 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp @@ -15,8 +15,7 @@ #include "Acts/Utilities/Units.hpp" #include "Acts/Vertexing/AMVFInfo.hpp" #include "Acts/Vertexing/TrackToVertexIPEstimator.hpp" -#include "Acts/Vertexing/VertexFinderOptions.hpp" -#include "Acts/Vertexing/VertexFitterOptions.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" namespace Acts { /// @class AdaptiveMultiVertexFinder @@ -68,7 +67,7 @@ class AdaptiveMultiVertexFinder { // Track linearizer Linearizer_t linearizer; - // Use a beam spot constraint, vertexConstraint in VertexFinderOptions + // Use a beam spot constraint, vertexConstraint in VertexingOptions // has to be set in this case bool useBeamSpotConstraint = true; @@ -189,12 +188,12 @@ class AdaptiveMultiVertexFinder { /// multi-vertex finding /// /// @param allTracks Input track collection - /// @param vFinderOptions Vertex finder options + /// @param vertexingOptions Vertexing options /// /// @return Vector of all reconstructed vertices Result<std::vector<Vertex<InputTrack_t>>> find( const std::vector<const InputTrack_t*>& allTracks, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; private: /// Configuration object @@ -218,13 +217,13 @@ class AdaptiveMultiVertexFinder { /// /// @param trackVector All tracks to be used for seeding /// @param currentConstraint Vertex constraint - /// @param vFinderOptions Vertex finder options + /// @param vertexingOptions Vertexing options /// /// @return The seed vertex Result<Vertex<InputTrack_t>> doSeeding( const std::vector<const InputTrack_t*>& trackVector, Vertex<InputTrack_t>& currentConstraint, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Estimates delta Z between a track and a vertex position /// @@ -354,13 +353,13 @@ class AdaptiveMultiVertexFinder { /// @param allVerticesPtr Vector containing the actual addresses /// @param fitterState The current vertex fitter state /// @param oldFitterState The old vertex fitter state - /// @param vFitterOptions The vertex fitter options + /// @param vertexingOptions Vertexing options Result<void> deleteLastVertex( Vertex<InputTrack_t>& vtx, std::vector<std::unique_ptr<Vertex<InputTrack_t>>>& allVertices, std::vector<Vertex<InputTrack_t>*>& allVerticesPtr, FitterState_t& fitterState, FitterState_t& oldFitterState, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Prepares the output vector of vertices /// diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp index a3dd9dd6a..ff2610e51 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp @@ -11,7 +11,7 @@ template <typename vfitter_t, typename sfinder_t> auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find( const std::vector<const InputTrack_t*>& allTracks, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<std::vector<Vertex<InputTrack_t>>> { if (allTracks.empty()) { return VertexingError::EmptyInput; @@ -22,11 +22,6 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find( // Seed tracks std::vector<const InputTrack_t*> seedTracks = allTracks; - // Construct the vertex fitter options from vertex finder options - VertexFitterOptions<InputTrack_t> vFitterOptions( - vFinderOptions.geoContext, vFinderOptions.magFieldContext, - vFinderOptions.vertexConstraint); - FitterState_t fitterState; std::vector<std::unique_ptr<Vertex<InputTrack_t>>> allVertices; @@ -47,9 +42,10 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find( } else { allTracks = seedTracks; } - Vertex<InputTrack_t> currentConstraint = vFinderOptions.vertexConstraint; + Vertex<InputTrack_t> currentConstraint = vertexingOptions.vertexConstraint; // Retrieve seed vertex from all remaining seedTracks - auto seedResult = doSeeding(seedTracks, currentConstraint, vFinderOptions); + auto seedResult = + doSeeding(seedTracks, currentConstraint, vertexingOptions); if (!seedResult.ok()) { return seedResult.error(); } @@ -84,7 +80,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find( // Perform the fit auto fitResult = m_cfg.vertexFitter.addVtxToFit( - fitterState, vtxCandidate, m_cfg.linearizer, vFitterOptions); + fitterState, vtxCandidate, m_cfg.linearizer, vertexingOptions); if (!fitResult.ok()) { return fitResult.error(); } @@ -118,7 +114,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find( if (not keepVertex) { auto deleteVertexResult = deleteLastVertex(vtxCandidate, allVertices, allVerticesPtr, - fitterState, oldFitterState, vFitterOptions); + fitterState, oldFitterState, vertexingOptions); if (not deleteVertexResult.ok()) { return deleteVertexResult.error(); } @@ -133,9 +129,9 @@ template <typename vfitter_t, typename sfinder_t> auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::doSeeding( const std::vector<const InputTrack_t*>& trackVector, Vertex<InputTrack_t>& currentConstraint, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<Vertex<InputTrack_t>> { - VertexFinderOptions<InputTrack_t> seedOptions = vFinderOptions; + VertexingOptions<InputTrack_t> seedOptions = vertexingOptions; seedOptions.vertexConstraint = currentConstraint; // Run seed finder auto seedResult = m_cfg.seedFinder.find(trackVector, seedOptions); @@ -517,7 +513,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::deleteLastVertex( std::vector<std::unique_ptr<Vertex<InputTrack_t>>>& allVertices, std::vector<Vertex<InputTrack_t>*>& allVerticesPtr, FitterState_t& fitterState, FitterState_t& oldFitterState, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<void> { allVertices.pop_back(); allVerticesPtr.pop_back(); @@ -542,7 +538,7 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::deleteLastVertex( // Do the fit with removed vertex auto fitResult = m_cfg.vertexFitter.fit(fitterState, allVerticesPtr, - m_cfg.linearizer, vFitterOptions); + m_cfg.linearizer, vertexingOptions); if (!fitResult.ok()) { return fitResult.error(); } diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp index dc7c03bcc..28138de2e 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp @@ -18,7 +18,7 @@ #include "Acts/Vertexing/LinearizerConcept.hpp" #include "Acts/Vertexing/TrackAtVertex.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFitterOptions.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" #include <functional> @@ -162,13 +162,13 @@ class AdaptiveMultiVertexFitter { /// @param state The state object /// @param verticesToFit Vector containing all vertices to be fitted /// @param linearizer The track linearizer - /// @param vFitterOptions Vertex fitter options + /// @param vertexingOptions Vertexing options /// /// @return Result<void> object Result<void> fit( State& state, const std::vector<Vertex<InputTrack_t>*>& verticesToFit, const Linearizer_t& linearizer, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Adds new vertex to an existing multi-vertex fit /// and fits everything together (by invoking the fit_impl method): @@ -190,13 +190,13 @@ class AdaptiveMultiVertexFitter { /// @param state The state object /// @param newVertex New vertex to be added to fit /// @param linearizer The track linearizer - /// @param vFitterOptions Vertex fitter options + /// @param vertexingOptions Vertexing options /// /// @return Result<void> object Result<void> addVtxToFit( State& state, Vertex<InputTrack_t>& newVertex, const Linearizer_t& linearizer, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; private: /// Configuration object @@ -220,12 +220,12 @@ class AdaptiveMultiVertexFitter { /// /// @param state The state object /// @param linearizer The track linearizer - /// @param vFitterOptions Vertex fitter options + /// @param vertexingOptions Vertexing options /// /// @return Result<void> object Result<void> fitImpl( State& state, const Linearizer_t& linearizer, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Tests if vertex is already in list of vertices or not /// @@ -244,10 +244,10 @@ class AdaptiveMultiVertexFitter { /// with different vertices /// /// @param vtx The vertex object - /// @param vFitterOptions Vertex fitter options + /// @param vertexingOptions Vertexing options Result<void> prepareVertexForFit( State& state, Vertex<InputTrack_t>* vtx, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Sets vertexCompatibility for all TrackAtVertex objects /// at current vertex diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp index 4cdfd4732..bec24d78f 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp @@ -15,12 +15,12 @@ Acts::Result<void> Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fit( State& state, const std::vector<Vertex<input_track_t>*>& verticesToFit, const linearizer_t& linearizer, - const VertexFitterOptions<input_track_t>& vFitterOptions) const { + const VertexingOptions<input_track_t>& vertexingOptions) const { // Set all vertices to fit in the current state state.vertexCollection = verticesToFit; // Perform fit on all vertices simultaneously - auto fitRes = fitImpl(state, linearizer, vFitterOptions); + auto fitRes = fitImpl(state, linearizer, vertexingOptions); if (!fitRes.ok()) { return fitRes.error(); @@ -33,8 +33,8 @@ template <typename input_track_t, typename linearizer_t> Acts::Result<void> Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fitImpl( State& state, const linearizer_t& linearizer, - const VertexFitterOptions<input_track_t>& vFitterOptions) const { - auto& geoContext = vFitterOptions.geoContext; + const VertexingOptions<input_track_t>& vertexingOptions) const { + auto& geoContext = vertexingOptions.geoContext; // Reset annealing tool state.annealingState = AnnealingUtility::State(); @@ -71,7 +71,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fitImpl( // Relinearization needed, distance too big currentVtxInfo.relinearize = true; // Prepare for fit with new vertex position - prepareVertexForFit(state, currentVtx, vFitterOptions); + prepareVertexForFit(state, currentVtx, vertexingOptions); } // Determine if constraint vertex exist if (state.vtxInfoMap[currentVtx].constraintVertex.fullCovariance() != @@ -123,7 +123,7 @@ Acts::Result<void> Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::addVtxToFit( State& state, Vertex<input_track_t>& newVertex, const linearizer_t& linearizer, - const VertexFitterOptions<input_track_t>& vFitterOptions) const { + const VertexingOptions<input_track_t>& vertexingOptions) const { if (state.vtxInfoMap[&newVertex].trackLinks.empty()) { return VertexingError::EmptyInput; } @@ -132,7 +132,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::addVtxToFit( // Prepares vtx and tracks for fast estimation method of their // compatibility with vertex - auto res = prepareVertexForFit(state, &newVertex, vFitterOptions); + auto res = prepareVertexForFit(state, &newVertex, vertexingOptions); if (!res.ok()) { return res.error(); } @@ -178,7 +178,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::addVtxToFit( state.vertexCollection = verticesToFit; // Perform fit on all added vertices - auto fitRes = fitImpl(state, linearizer, vFitterOptions); + auto fitRes = fitImpl(state, linearizer, vertexingOptions); if (!fitRes.ok()) { return fitRes.error(); } @@ -199,12 +199,12 @@ template <typename input_track_t, typename linearizer_t> Acts::Result<void> Acts:: AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::prepareVertexForFit( State& state, Vertex<input_track_t>* vtx, - const VertexFitterOptions<input_track_t>& vFitterOptions) const { + const VertexingOptions<input_track_t>& vertexingOptions) const { // The current vertex info object auto& currentVtxInfo = state.vtxInfoMap[vtx]; // The seed position const Vector3D& seedPos = currentVtxInfo.seedPosition.template head<3>(); - auto& geoContext = vFitterOptions.geoContext; + auto& geoContext = vertexingOptions.geoContext; // Loop over all tracks at current vertex for (const auto& trk : currentVtxInfo.trackLinks) { diff --git a/Core/include/Acts/Vertexing/DummyVertexFitter.hpp b/Core/include/Acts/Vertexing/DummyVertexFitter.hpp index 2e4170db3..810536bed 100644 --- a/Core/include/Acts/Vertexing/DummyVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/DummyVertexFitter.hpp @@ -11,7 +11,7 @@ #include "Acts/EventData/TrackParameters.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFitterOptions.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" namespace Acts { @@ -36,7 +36,7 @@ class DummyVertexFitter { /// @brief Dummy fit method Result<Vertex<input_track_t>> fit( const std::vector<input_track_t>&, const linearizer_t&, - const VertexFitterOptions<input_track_t>&) const; + const VertexingOptions<input_track_t>&) const; }; } // namespace Acts diff --git a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp index b7aee51db..0e08121c3 100644 --- a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.hpp @@ -13,7 +13,7 @@ #include "Acts/Vertexing/HelicalTrackLinearizer.hpp" #include "Acts/Vertexing/LinearizerConcept.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFitterOptions.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" namespace Acts { /// @class FullBilloirVertexFitter @@ -65,13 +65,13 @@ class FullBilloirVertexFitter { /// /// @param paramVector Vector of track objects to fit vertex to /// @param linearizer The track linearizer - /// @param vFitterOptions Vertex fitter options + /// @param vertexingOptions Vertexing options /// /// @return Fitted vertex Result<Vertex<input_track_t>> fit( const std::vector<const input_track_t*>& paramVector, const linearizer_t& linearizer, - const VertexFitterOptions<input_track_t>& vFitterOptions) const; + const VertexingOptions<input_track_t>& vertexingOptions) const; private: /// Configuration object diff --git a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp index 5c65f5543..0c7ed4064 100644 --- a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp @@ -65,7 +65,7 @@ Acts::Result<Acts::Vertex<input_track_t>> Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( const std::vector<const input_track_t*>& paramVector, const linearizer_t& linearizer, - const VertexFitterOptions<input_track_t>& vFitterOptions) const { + const VertexingOptions<input_track_t>& vertexingOptions) const { double chi2 = std::numeric_limits<double>::max(); double newChi2 = 0; unsigned int nTracks = paramVector.size(); @@ -84,7 +84,7 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( // Determine if we do contraint fit or not by checking if an // invertible non-zero constraint vertex covariance is given bool isConstraintFit = false; - if (vFitterOptions.vertexConstraint.covariance().determinant() != 0) { + if (vertexingOptions.vertexConstraint.covariance().determinant() != 0) { isConstraintFit = true; ndf += 3; } @@ -93,7 +93,7 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( std::vector<Vector3D> trackMomenta; - SpacePointVector linPoint(vFitterOptions.vertexConstraint.fullPosition()); + SpacePointVector linPoint(vertexingOptions.vertexConstraint.fullPosition()); Vertex<input_track_t> fittedVertex; @@ -197,15 +197,15 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( SpacePointVector posInBilloirFrame; // this will be 0 for first iteration but != 0 from second on posInBilloirFrame[0] = - vFitterOptions.vertexConstraint.position()[0] - linPoint[0]; + vertexingOptions.vertexConstraint.position()[0] - linPoint[0]; posInBilloirFrame[1] = - vFitterOptions.vertexConstraint.position()[1] - linPoint[1]; + vertexingOptions.vertexConstraint.position()[1] - linPoint[1]; posInBilloirFrame[2] = - vFitterOptions.vertexConstraint.position()[2] - linPoint[2]; + vertexingOptions.vertexConstraint.position()[2] - linPoint[2]; - Vdel += vFitterOptions.vertexConstraint.fullCovariance().inverse() * + Vdel += vertexingOptions.vertexConstraint.fullCovariance().inverse() * posInBilloirFrame; - VwgtMat += vFitterOptions.vertexConstraint.fullCovariance().inverse(); + VwgtMat += vertexingOptions.vertexConstraint.fullCovariance().inverse(); } // cov(deltaV) = VwgtMat^-1 @@ -288,15 +288,18 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( // last term will also be 0 again but only in the first iteration // = calc. vtx in billoir frame - ( isConstraintFit pos. in billoir // frame ) - deltaTrk[0] = deltaV[0] - (vFitterOptions.vertexConstraint.position()[0] - - linPoint[0]); - deltaTrk[1] = deltaV[1] - (vFitterOptions.vertexConstraint.position()[1] - - linPoint[1]); - deltaTrk[2] = deltaV[2] - (vFitterOptions.vertexConstraint.position()[2] - - linPoint[2]); + deltaTrk[0] = + deltaV[0] - + (vertexingOptions.vertexConstraint.position()[0] - linPoint[0]); + deltaTrk[1] = + deltaV[1] - + (vertexingOptions.vertexConstraint.position()[1] - linPoint[1]); + deltaTrk[2] = + deltaV[2] - + (vertexingOptions.vertexConstraint.position()[2] - linPoint[2]); newChi2 += (deltaTrk.transpose()) - .dot(vFitterOptions.vertexConstraint.covariance().inverse() * + .dot(vertexingOptions.vertexConstraint.covariance().inverse() * deltaTrk); } @@ -328,7 +331,7 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( paramVec << 0., 0., trackMomenta[iTrack](0), trackMomenta[iTrack](1), trackMomenta[iTrack](2), 0.; - BoundParameters refittedParams(vFitterOptions.geoContext, + BoundParameters refittedParams(vertexingOptions.geoContext, covDeltaPmat[iTrack], paramVec, perigee); TrackAtVertex<input_track_t> trackVx(bTrack.chi2, refittedParams, diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp index 9ba61ed22..1d3a0b2e6 100644 --- a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp @@ -17,8 +17,8 @@ #include "Acts/Vertexing/HelicalTrackLinearizer.hpp" #include "Acts/Vertexing/ImpactPoint3dEstimator.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFinderOptions.hpp" #include "Acts/Vertexing/VertexFitterConcept.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" #include "Acts/Vertexing/ZScanVertexFinder.hpp" namespace Acts { @@ -137,12 +137,12 @@ class IterativeVertexFinder { /// @brief Finds vertices corresponding to input trackVector /// /// @param trackVector Input tracks - /// @param vFinderOptions Vertex finder options + /// @param vertexingOptions Vertexing options /// /// @return Collection of vertices found by finder Result<std::vector<Vertex<InputTrack_t>>> find( const std::vector<const InputTrack_t*>& trackVector, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; private: /// Configuration object @@ -164,10 +164,10 @@ class IterativeVertexFinder { /// @brief Method that calls seed finder to retrieve a vertex seed /// /// @param seedTracks Seeding tracks - /// @param vFinderOptions Vertex finder options + /// @param vertexingOptions Vertexing options Result<Vertex<InputTrack_t>> getVertexSeed( const std::vector<const InputTrack_t*>& seedTracks, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Removes all tracks in perigeesToFit from seedTracks /// @@ -202,13 +202,13 @@ class IterativeVertexFinder { /// @param seedVertex Seed vertex /// @param perigeesToFitOut Perigees to fit /// @param perigeesToFitSplitVertexOut Perigees to fit split vertex - /// @param vFinderOptions Vertex finder options + /// @param vertexingOptions Vertexing options Result<void> fillPerigeesToFit( const std::vector<const InputTrack_t*>& perigeeList, const Vertex<InputTrack_t>& seedVertex, std::vector<const InputTrack_t*>& perigeesToFitOut, std::vector<const InputTrack_t*>& perigeesToFitSplitVertexOut, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Function that reassigns tracks from other vertices /// to the current vertex if they are more compatible @@ -218,7 +218,7 @@ class IterativeVertexFinder { /// @param perigeesToFit Perigees to fit vector /// @param seedTracks Seed tracks vector /// @param origTracks Vector of original track objects - /// @param vFitterOptions Vertex fitter options + /// @param vertexingOptions Vertexing options /// /// @return Bool if currentVertex is still a good vertex Result<bool> reassignTracksToNewVertex( @@ -227,7 +227,7 @@ class IterativeVertexFinder { std::vector<const InputTrack_t*>& perigeesToFit, std::vector<const InputTrack_t*>& seedTracks, const std::vector<const InputTrack_t*>& origTracks, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Counts all tracks that are significant for a vertex /// diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp b/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp index 83b16e07e..b67b17e5c 100644 --- a/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.ipp @@ -6,23 +6,16 @@ // 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/VertexFitterOptions.hpp" - template <typename vfitter_t, typename sfinder_t> auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( const std::vector<const InputTrack_t*>& trackVector, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<std::vector<Vertex<InputTrack_t>>> { // Original tracks const std::vector<const InputTrack_t*>& origTracks = trackVector; // Tracks for seeding std::vector<const InputTrack_t*> seedTracks = trackVector; - // Construct the vertex fitter options from vertex finder options - VertexFitterOptions<InputTrack_t> vFitterOptions( - vFinderOptions.geoContext, vFinderOptions.magFieldContext, - vFinderOptions.vertexConstraint); - // List of vertices to be filled below std::vector<Vertex<InputTrack_t>> vertexCollection; @@ -30,7 +23,7 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( // begin iterating while (seedTracks.size() > 1 && nInterations < m_cfg.maxVertices) { /// Begin seeding - auto seedRes = getVertexSeed(seedTracks, vFinderOptions); + auto seedRes = getVertexSeed(seedTracks, vertexingOptions); if (!seedRes.ok()) { return seedRes.error(); } @@ -45,7 +38,7 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( // Fill vector with tracks to fit, only compatible with seed: auto res = fillPerigeesToFit(seedTracks, seedVertex, perigeesToFit, - perigeesToFitSplitVertex, vFinderOptions); + perigeesToFitSplitVertex, vertexingOptions); if (!res.ok()) { return res.error(); @@ -59,7 +52,7 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( if (m_cfg.useBeamConstraint && !perigeesToFit.empty()) { auto fitResult = m_cfg.vertexFitter.fit(perigeesToFit, m_cfg.linearizer, - vFitterOptions); + vertexingOptions); if (fitResult.ok()) { currentVertex = std::move(*fitResult); } else { @@ -67,7 +60,7 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( } } else if (!m_cfg.useBeamConstraint && perigeesToFit.size() > 1) { auto fitResult = m_cfg.vertexFitter.fit(perigeesToFit, m_cfg.linearizer, - vFitterOptions); + vertexingOptions); if (fitResult.ok()) { currentVertex = std::move(*fitResult); } else { @@ -75,8 +68,8 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( } } if (m_cfg.createSplitVertices && perigeesToFitSplitVertex.size() > 1) { - auto fitResult = m_cfg.vertexFitter.fit(perigeesToFitSplitVertex, - m_cfg.linearizer, vFitterOptions); + auto fitResult = m_cfg.vertexFitter.fit( + perigeesToFitSplitVertex, m_cfg.linearizer, vertexingOptions); if (fitResult.ok()) { currentSplitVertex = std::move(*fitResult); } else { @@ -107,7 +100,7 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( auto result = reassignTracksToNewVertex(vertexCollection, currentVertex, perigeesToFit, seedTracks, - origTracks, vFitterOptions); + origTracks, vertexingOptions); if (!result.ok()) { return result.error(); } @@ -155,9 +148,9 @@ auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::find( template <typename vfitter_t, typename sfinder_t> auto Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::getVertexSeed( const std::vector<const InputTrack_t*>& seedTracks, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<Vertex<InputTrack_t>> { - auto res = m_cfg.seedFinder.find(seedTracks, vFinderOptions); + auto res = m_cfg.seedFinder.find(seedTracks, vertexingOptions); if (res.ok()) { auto vertexCollection = *res; if (vertexCollection.empty()) { @@ -331,7 +324,7 @@ Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::fillPerigeesToFit( const Vertex<InputTrack_t>& seedVertex, std::vector<const InputTrack_t*>& perigeesToFitOut, std::vector<const InputTrack_t*>& perigeesToFitSplitVertexOut, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const { + const VertexingOptions<InputTrack_t>& vertexingOptions) const { int numberOfTracks = perigeeList.size(); // Count how many tracks are used for fit @@ -360,7 +353,7 @@ Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::fillPerigeesToFit( // check first that distance is not too large const BoundParameters& sTrackParams = m_extractParameters(*sTrack); auto distanceRes = m_cfg.ipEst.calculateDistance( - vFinderOptions.geoContext, sTrackParams, seedVertex.position()); + vertexingOptions.geoContext, sTrackParams, seedVertex.position()); if (!distanceRes.ok()) { return distanceRes.error(); } @@ -400,7 +393,7 @@ Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::reassignTracksToNewVertex( std::vector<const InputTrack_t*>& perigeesToFit, std::vector<const InputTrack_t*>& seedTracks, const std::vector<const InputTrack_t*>& origTracks, - const VertexFitterOptions<InputTrack_t>& vFitterOptions) const { + const VertexingOptions<InputTrack_t>& vertexingOptions) const { int numberOfAddedTracks = 0; // iterate over all vertices and check if tracks need to be reassigned @@ -478,16 +471,16 @@ Acts::IterativeVertexFinder<vfitter_t, sfinder_t>::reassignTracksToNewVertex( // later currentVertex = Vertex<InputTrack_t>(); if (m_cfg.useBeamConstraint && !perigeesToFit.empty()) { - auto fitResult = - m_cfg.vertexFitter.fit(perigeesToFit, m_cfg.linearizer, vFitterOptions); + auto fitResult = m_cfg.vertexFitter.fit(perigeesToFit, m_cfg.linearizer, + vertexingOptions); if (fitResult.ok()) { currentVertex = std::move(*fitResult); } else { return Result<bool>::success(false); } } else if (!m_cfg.useBeamConstraint && perigeesToFit.size() > 1) { - auto fitResult = - m_cfg.vertexFitter.fit(perigeesToFit, m_cfg.linearizer, vFitterOptions); + auto fitResult = m_cfg.vertexFitter.fit(perigeesToFit, m_cfg.linearizer, + vertexingOptions); if (fitResult.ok()) { currentVertex = std::move(*fitResult); } else { diff --git a/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp b/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp index f85b29662..5f3265224 100644 --- a/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/TrackDensityVertexFinder.hpp @@ -13,8 +13,8 @@ #include "Acts/Utilities/Result.hpp" #include "Acts/Vertexing/GaussianTrackDensity.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFinderOptions.hpp" #include "Acts/Vertexing/VertexFitterConcept.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" namespace Acts { @@ -51,13 +51,13 @@ class TrackDensityVertexFinder { /// @brief Function that finds single vertex candidate /// /// @param trackVector Input track collection - /// @param vFinderOptions Vertex finder options + /// @param vertexingOptions Vertexing options /// /// @return Vector of vertices, filled with a single /// vertex (for consistent interfaces) Result<std::vector<Vertex<InputTrack_t>>> find( const std::vector<const InputTrack_t*>& trackVector, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Constructor used if InputTrack_t type == BoundParameters /// diff --git a/Core/include/Acts/Vertexing/TrackDensityVertexFinder.ipp b/Core/include/Acts/Vertexing/TrackDensityVertexFinder.ipp index ed26c5631..b24c1016b 100644 --- a/Core/include/Acts/Vertexing/TrackDensityVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/TrackDensityVertexFinder.ipp @@ -9,7 +9,7 @@ template <typename vfitter_t, typename track_density_t> auto Acts::TrackDensityVertexFinder<vfitter_t, track_density_t>::find( const std::vector<const InputTrack_t*>& trackVector, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<std::vector<Vertex<InputTrack_t>>> { typename track_density_t::State densityState; @@ -30,11 +30,11 @@ auto Acts::TrackDensityVertexFinder<vfitter_t, track_density_t>::find( // Calculate seed position // Note: constraint position is (0,0,0) if no constraint provided Vector3D seedPos = - vFinderOptions.vertexConstraint.position() + Vector3D(0., 0., z); + vertexingOptions.vertexConstraint.position() + Vector3D(0., 0., z); Vertex<InputTrack_t> returnVertex = Vertex<InputTrack_t>(seedPos); - ActsSymMatrixD<3> seedCov = vFinderOptions.vertexConstraint.covariance(); + ActsSymMatrixD<3> seedCov = vertexingOptions.vertexConstraint.covariance(); // Check if a constraint is provided and set the new z position constraint if (seedCov != ActsSymMatrixD<3>::Zero() && std::isnormal(zAndWidth.second)) { diff --git a/Core/include/Acts/Vertexing/VertexFinderConcept.hpp b/Core/include/Acts/Vertexing/VertexFinderConcept.hpp index 57e57ecca..11e0bbec4 100644 --- a/Core/include/Acts/Vertexing/VertexFinderConcept.hpp +++ b/Core/include/Acts/Vertexing/VertexFinderConcept.hpp @@ -12,7 +12,7 @@ #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/TypeTraits.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFinderOptions.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" namespace Acts { @@ -27,7 +27,7 @@ namespace concept { constexpr static bool find_exists = has_method<const S, Result<std::vector<Vertex<typename S::InputTrack_t>>>, find_t, const std::vector<const typename S::InputTrack_t*>&, - const VertexFinderOptions<typename S::InputTrack_t>&>; + const VertexingOptions<typename S::InputTrack_t>&>; static_assert(find_exists, "find method not found"); constexpr static bool value = require<find_exists>; diff --git a/Core/include/Acts/Vertexing/VertexFitterConcept.hpp b/Core/include/Acts/Vertexing/VertexFitterConcept.hpp index 9164c714d..af9529afa 100644 --- a/Core/include/Acts/Vertexing/VertexFitterConcept.hpp +++ b/Core/include/Acts/Vertexing/VertexFitterConcept.hpp @@ -12,7 +12,7 @@ #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/TypeTraits.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFitterOptions.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" namespace Acts { @@ -35,7 +35,7 @@ namespace concept { fit_t, const std::vector<const typename S::InputTrack_t*>&, const typename S::Linearizer_t&, - const VertexFitterOptions<typename S::InputTrack_t>&>; + const VertexingOptions<typename S::InputTrack_t>&>; static_assert(fit_exists, "fit method not found"); constexpr static bool track_exists = exists<track_t, S>; diff --git a/Core/include/Acts/Vertexing/VertexFitterOptions.hpp b/Core/include/Acts/Vertexing/VertexFitterOptions.hpp deleted file mode 100644 index ad354dd09..000000000 --- a/Core/include/Acts/Vertexing/VertexFitterOptions.hpp +++ /dev/null @@ -1,44 +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/Geometry/GeometryContext.hpp" -#include "Acts/MagneticField/MagneticFieldContext.hpp" -#include "Acts/Vertexing/Vertex.hpp" - -namespace Acts { - -/// @brief Vertex Fitter Options -/// -template <typename input_track_t> -struct VertexFitterOptions { - /// Default contstructor is deleted - VertexFitterOptions() = delete; - - /// VertexFitterOptions with context - /// - /// @param gctx The goemetry context for this fit - /// @param mctx The magnetic context for this fit - /// @param vconstr The pointing contraint to a vertex - VertexFitterOptions( - std::reference_wrapper<const GeometryContext> gctx, - std::reference_wrapper<const MagneticFieldContext> mctx, - const Vertex<input_track_t>& vconstr = Vertex<input_track_t>()) - - : geoContext(gctx), magFieldContext(mctx), vertexConstraint(vconstr) {} - - /// Context object for the geometry - std::reference_wrapper<const GeometryContext> geoContext; - /// Context object for the magnetic field - std::reference_wrapper<const MagneticFieldContext> magFieldContext; - /// The vertex constraint for the fitting - Vertex<input_track_t> vertexConstraint; -}; - -} // namespace Acts diff --git a/Core/include/Acts/Vertexing/VertexFinderOptions.hpp b/Core/include/Acts/Vertexing/VertexingOptions.hpp similarity index 91% rename from Core/include/Acts/Vertexing/VertexFinderOptions.hpp rename to Core/include/Acts/Vertexing/VertexingOptions.hpp index 5c0340771..bff6d97a3 100644 --- a/Core/include/Acts/Vertexing/VertexFinderOptions.hpp +++ b/Core/include/Acts/Vertexing/VertexingOptions.hpp @@ -17,16 +17,16 @@ namespace Acts { /// @brief Vertex Finder Options /// template <typename input_track_t> -struct VertexFinderOptions { +struct VertexingOptions { /// Default contstructor is deleted - VertexFinderOptions() = delete; + VertexingOptions() = delete; - /// VertexFinderOptions with context + /// VertexingOptions with context /// /// @param gctx The goemetry context for this fit /// @param mctx The magnetic context for this fit /// @param vconstr The pointing contraint to a vertex - VertexFinderOptions( + VertexingOptions( std::reference_wrapper<const GeometryContext> gctx, std::reference_wrapper<const MagneticFieldContext> mctx, const Vertex<input_track_t>& vconstr = Vertex<input_track_t>()) diff --git a/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp b/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp index e738d705d..4d2812db8 100644 --- a/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/ZScanVertexFinder.hpp @@ -18,8 +18,8 @@ #include "Acts/Vertexing/FsmwMode1dFinder.hpp" #include "Acts/Vertexing/TrackToVertexIPEstimator.hpp" #include "Acts/Vertexing/Vertex.hpp" -#include "Acts/Vertexing/VertexFinderOptions.hpp" #include "Acts/Vertexing/VertexFitterConcept.hpp" +#include "Acts/Vertexing/VertexingOptions.hpp" namespace Acts { @@ -103,13 +103,13 @@ class ZScanVertexFinder { /// using a Half Sample Mode algorithm /// /// @param trackVector Input track collection - /// @param vFinderOptions Vertex finder options + /// @param vertexingOptions Vertexing options /// /// @return Vector of vertices, filled with a single /// vertex (for consistent interfaces) Result<std::vector<Vertex<InputTrack_t>>> find( const std::vector<const InputTrack_t*>& trackVector, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const; + const VertexingOptions<InputTrack_t>& vertexingOptions) const; private: Config m_cfg; diff --git a/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp b/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp index f15579ec2..7344f7d2a 100644 --- a/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp @@ -9,11 +9,11 @@ template <typename vfitter_t> auto Acts::ZScanVertexFinder<vfitter_t>::find( const std::vector<const InputTrack_t*>& trackVector, - const VertexFinderOptions<InputTrack_t>& vFinderOptions) const + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<std::vector<Vertex<InputTrack_t>>> { // Determine if we use constraint or not bool useConstraint = false; - if (vFinderOptions.vertexConstraint.fullCovariance().determinant() != 0) { + if (vertexingOptions.vertexConstraint.fullCovariance().determinant() != 0) { useConstraint = true; } @@ -29,9 +29,9 @@ auto Acts::ZScanVertexFinder<vfitter_t>::find( std::pair<double, double> z0AndWeight; ImpactParametersAndSigma ipas; if (useConstraint && - vFinderOptions.vertexConstraint.covariance()(0, 0) != 0) { + vertexingOptions.vertexConstraint.covariance()(0, 0) != 0) { auto estRes = - m_cfg.ipEstimator.estimate(params, vFinderOptions.vertexConstraint); + m_cfg.ipEstimator.estimate(params, vertexingOptions.vertexConstraint); if (estRes.ok()) { ipas = *estRes; } else { @@ -42,7 +42,7 @@ auto Acts::ZScanVertexFinder<vfitter_t>::find( if (ipas.sigmad0 > 0) { // calculate z0 z0AndWeight.first = - ipas.IPz0 + vFinderOptions.vertexConstraint.position().z(); + ipas.IPz0 + vertexingOptions.vertexConstraint.position().z(); // calculate chi2 of IP double chi2IP = std::pow(ipas.IPd0 / ipas.sigmad0, 2); @@ -96,9 +96,9 @@ auto Acts::ZScanVertexFinder<vfitter_t>::find( } // constraint x()/y() equals 0 if no constraint - SpacePointVector output(vFinderOptions.vertexConstraint.position().x(), - vFinderOptions.vertexConstraint.position().y(), - ZResult, vFinderOptions.vertexConstraint.time()); + SpacePointVector output(vertexingOptions.vertexConstraint.position().x(), + vertexingOptions.vertexConstraint.position().y(), + ZResult, vertexingOptions.vertexConstraint.time()); Vertex<InputTrack_t> vtxResult = Vertex<InputTrack_t>(output); // Vector to be filled with one single vertex diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp index 105c59607..7cd3ee8c9 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp @@ -53,8 +53,6 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { PropagatorOptions<> pOptions(tgContext, mfContext); pOptions.direction = backward; - VertexFitterOptions<BoundParameters> fitterOptions(tgContext, mfContext); - // IP 3D Estimator using IPEstimator = ImpactPoint3dEstimator<BoundParameters, Propagator>; @@ -122,7 +120,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { tracksPtr.push_back(&trk); } - VertexFinderOptions<BoundParameters> finderOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); Vector3D constraintPos{0._mm, 0._mm, 0_mm}; ActsSymMatrixD<3> constraintCov; @@ -133,9 +131,9 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { constraintVtx.setPosition(constraintPos); constraintVtx.setCovariance(constraintCov); - finderOptions.vertexConstraint = constraintVtx; + vertexingOptions.vertexConstraint = constraintVtx; - auto findResult = finder.find(tracksPtr, finderOptions); + auto findResult = finder.find(tracksPtr, vertexingOptions); if (!findResult.ok()) { std::cout << findResult.error().message() << std::endl; diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp index dffb8fc63..6d238d134 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) { auto propagator = std::make_shared<Propagator>(stepper); PropagatorOptions<> pOptions(tgContext, mfContext); - VertexFitterOptions<BoundParameters> fitterOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); // IP 3D Estimator using IPEstimator = ImpactPoint3dEstimator<BoundParameters, Propagator>; @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) { std::vector<Vertex<BoundParameters>> seedListCopy = vtxList; auto res1 = - fitter.addVtxToFit(state, vtxList.at(0), linearizer, fitterOptions); + fitter.addVtxToFit(state, vtxList.at(0), linearizer, vertexingOptions); if (debugMode) { std::cout << "Tracks linked to each vertex AFTER fit: " << std::endl; int c = 0; @@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) { seedListCopy.at(1).fullPosition(), 1_mm); auto res2 = - fitter.addVtxToFit(state, vtxList.at(2), linearizer, fitterOptions); + fitter.addVtxToFit(state, vtxList.at(2), linearizer, vertexingOptions); BOOST_CHECK(res2.ok()); // Now also the third vertex should have been modified and fitted @@ -323,7 +323,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) { auto propagator = std::make_shared<Propagator>(stepper); PropagatorOptions<> pOptions(tgContext, mfContext); - VertexFitterOptions<BoundParameters> fitterOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); // IP 3D Estimator using IPEstimator = ImpactPoint3dEstimator<BoundParameters, Propagator>; @@ -483,7 +483,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) { state.addVertexToMultiMap(vtx2); // Fit vertices - fitter.fit(state, vtxList, linearizer, fitterOptions); + fitter.fit(state, vtxList, linearizer, vertexingOptions); auto vtx1Pos = state.vertexCollection.at(0)->position(); auto vtx1Cov = state.vertexCollection.at(0)->covariance(); diff --git a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp index cf4c79332..e77c0b88d 100644 --- a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp @@ -72,8 +72,8 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_empty_input_test) { const std::vector<const BoundParameters*> emptyVector; - VertexFitterOptions<BoundParameters> vfOptions(tgContext, mfContext, - myConstraint); + VertexingOptions<BoundParameters> vfOptions(tgContext, mfContext, + myConstraint); Vertex<BoundParameters> fittedVertex = billoirFitter.fit(emptyVector, linearizer, vfOptions).value(); @@ -159,10 +159,10 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_defaulttrack_test) { myCovMat(3, 3) = 30.; myConstraint.setFullCovariance(std::move(myCovMat)); myConstraint.setFullPosition(SpacePointVector(0, 0, 0, 0)); - VertexFitterOptions<BoundParameters> vfOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vfOptions(tgContext, mfContext); - VertexFitterOptions<BoundParameters> vfOptionsConstr(tgContext, mfContext, - myConstraint); + VertexingOptions<BoundParameters> vfOptionsConstr(tgContext, mfContext, + myConstraint); // Create position of vertex and perigee surface double x = vXYDist(gen); double y = vXYDist(gen); @@ -298,10 +298,10 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_usertrack_test) { myConstraint.setFullCovariance(std::move(myCovMat)); myConstraint.setFullPosition(SpacePointVector(0, 0, 0, 0)); - VertexFitterOptions<InputTrack> vfOptions(tgContext, mfContext); + VertexingOptions<InputTrack> vfOptions(tgContext, mfContext); - VertexFitterOptions<InputTrack> vfOptionsConstr(tgContext, mfContext, - myConstraint); + VertexingOptions<InputTrack> vfOptionsConstr(tgContext, mfContext, + myConstraint); // Create position of vertex and perigee surface double x = vXYDist(gen); diff --git a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp index 99bf17eec..163eefd80 100644 --- a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp @@ -231,10 +231,10 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { tracksPtr.push_back(trk.get()); } - VertexFinderOptions<BoundParameters> vFinderOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); // find vertices - auto res = finder.find(tracksPtr, vFinderOptions); + auto res = finder.find(tracksPtr, vertexingOptions); BOOST_CHECK(res.ok()); @@ -454,10 +454,10 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { tracksPtr.push_back(trk.get()); } - VertexFinderOptions<InputTrack> vFinderOptionsUT(tgContext, mfContext); + VertexingOptions<InputTrack> vertexingOptionsUT(tgContext, mfContext); // find vertices - auto res = finder.find(tracksPtr, vFinderOptionsUT); + auto res = finder.find(tracksPtr, vertexingOptionsUT); BOOST_CHECK(res.ok()); diff --git a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp index 607b77daa..ea6d61771 100644 --- a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_test) { Vector3D pos1c{1.2_mm, 1.3_mm, -7_mm}; Vector3D mom1c{300_MeV, 1000_MeV, 100_MeV}; - VertexFinderOptions<BoundParameters> vFinderOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); TrackDensityVertexFinder<DummyVertexFitter<>, GaussianTrackDensity> finder; @@ -68,8 +68,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_test) { std::vector<const BoundParameters*> vec1 = {¶ms1a, ¶ms1b, ¶ms1c}; std::vector<const BoundParameters*> vec2 = {¶ms1c, ¶ms1a, ¶ms1b}; - auto res1 = finder.find(vec1, vFinderOptions); - auto res2 = finder.find(vec2, vFinderOptions); + auto res1 = finder.find(vec1, vertexingOptions); + auto res2 = finder.find(vec2, vertexingOptions); if (!res1.ok()) { std::cout << res1.error().message() << std::endl; @@ -106,7 +106,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_constr_test) { double const expectedZResult = -13.013; // Finder options - VertexFinderOptions<BoundParameters> vFinderOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); // Create constraint for seed finding Vector3D constraintPos{1.7_mm, 1.3_mm, -6_mm}; @@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_constr_test) { Vertex<BoundParameters> vertexConstraint(constraintPos); vertexConstraint.setCovariance(constrCov); - vFinderOptions.vertexConstraint = vertexConstraint; + vertexingOptions.vertexConstraint = vertexConstraint; TrackDensityVertexFinder<DummyVertexFitter<>, GaussianTrackDensity> finder; @@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_constr_test) { // Vector of track parameters std::vector<const BoundParameters*> vec1 = {¶ms1a, ¶ms1b, ¶ms1c}; - auto res = finder.find(vec1, vFinderOptions); + auto res = finder.find(vec1, vertexingOptions); if (!res.ok()) { std::cout << res.error().message() << std::endl; @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_random_test) { std::shared_ptr<PerigeeSurface> perigeeSurface = Surface::makeShared<PerigeeSurface>(pos0); - VertexFinderOptions<BoundParameters> vFinderOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); TrackDensityVertexFinder<DummyVertexFitter<>, GaussianTrackDensity> finder; @@ -218,7 +218,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_random_test) { trackPtrVec.push_back(&trk); } - auto res3 = finder.find(trackPtrVec, vFinderOptions); + auto res3 = finder.find(trackPtrVec, vertexingOptions); if (!res3.ok()) { std::cout << res3.error().message() << std::endl; } @@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_usertrack_test) { double const expectedZResult = -13.013; // Finder options - VertexFinderOptions<InputTrack> vFinderOptions(tgContext, mfContext); + VertexingOptions<InputTrack> vertexingOptions(tgContext, mfContext); // Create constraint for seed finding Vector3D constraintPos{1.7_mm, 1.3_mm, -6_mm}; @@ -269,7 +269,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_usertrack_test) { Vertex<InputTrack> vertexConstraint(constraintPos); vertexConstraint.setCovariance(constrCov); - vFinderOptions.vertexConstraint = vertexConstraint; + vertexingOptions.vertexConstraint = vertexConstraint; std::function<BoundParameters(InputTrack)> extractParameters = [](InputTrack params) { return params.parameters(); }; @@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_usertrack_test) { // Vector of track parameters std::vector<const InputTrack*> vec1 = {¶ms1a, ¶ms1b, ¶ms1c}; - auto res = finder.find(vec1, vFinderOptions); + auto res = finder.find(vec1, vertexingOptions); if (!res.ok()) { std::cout << res.error().message() << std::endl; diff --git a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp index c92a86641..4143b9116 100644 --- a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp @@ -153,9 +153,9 @@ BOOST_AUTO_TEST_CASE(zscan_finder_test) { VertexFinder finder(std::move(cfg)); - VertexFinderOptions<BoundParameters> vFinderOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); - auto res = finder.find(tracksPtr, vFinderOptions); + auto res = finder.find(tracksPtr, vertexingOptions); BOOST_CHECK(res.ok()); @@ -278,9 +278,9 @@ BOOST_AUTO_TEST_CASE(zscan_finder_usertrack_test) { VertexFinder finder(std::move(cfg), extractParameters); - VertexFinderOptions<InputTrack> vFinderOptions(tgContext, mfContext); + VertexingOptions<InputTrack> vertexingOptions(tgContext, mfContext); - auto res = finder.find(tracksPtr, vFinderOptions); + auto res = finder.find(tracksPtr, vertexingOptions); BOOST_CHECK(res.ok()); -- GitLab 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 3/6] 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, ¶ms); @@ -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, ¶ms); 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 From 1d4128f21cddb61e701fb15bd8593e1bfaeaae03 Mon Sep 17 00:00:00 2001 From: Bastian Schlag <bastian.schlag@cern.ch> Date: Wed, 25 Mar 2020 16:57:03 +0100 Subject: [PATCH 4/6] remove propagator options from IP estimator configs and create before propagation call --- .../Vertexing/AdaptiveMultiVertexFinder.hpp | 18 +++++-- .../Vertexing/AdaptiveMultiVertexFinder.ipp | 49 ++++++++++++------- .../Vertexing/AdaptiveMultiVertexFitter.hpp | 6 +-- .../Vertexing/AdaptiveMultiVertexFitter.ipp | 16 +++--- .../Acts/Vertexing/HelicalTrackLinearizer.ipp | 1 + .../Acts/Vertexing/ImpactPoint3dEstimator.hpp | 30 +++--------- .../Acts/Vertexing/ImpactPoint3dEstimator.ipp | 8 ++- .../Vertexing/TrackToVertexIPEstimator.hpp | 21 +++----- .../Vertexing/TrackToVertexIPEstimator.ipp | 12 +++-- .../Acts/Vertexing/ZScanVertexFinder.ipp | 5 +- .../AdaptiveMultiVertexFinderTests.cpp | 13 +++-- .../AdaptiveMultiVertexFitterTests.cpp | 36 +++++++------- .../FullBilloirVertexFitterTests.cpp | 20 ++++---- .../Vertexing/ImpactPoint3dEstimatorTests.cpp | 41 +++++++--------- .../Vertexing/IterativeVertexFinderTests.cpp | 28 +++++------ .../KalmanVertexTrackUpdaterTests.cpp | 3 +- .../Vertexing/LinearizedTrackFactoryTests.cpp | 6 +-- .../TrackDensityVertexFinderTests.cpp | 35 +++++++------ .../TrackToVertexIPEstimatorTests.cpp | 15 +++--- .../Core/Vertexing/ZScanVertexFinderTests.cpp | 19 ++++--- 20 files changed, 193 insertions(+), 189 deletions(-) diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp index 65337fc60..0ae7a5ca1 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.hpp @@ -238,19 +238,23 @@ class AdaptiveMultiVertexFinder { /// /// @param track The track /// @param vtx The vertex + /// @param vertexingOptions Vertexing options /// /// @return The IP significance - Result<double> getIPSignificance(const InputTrack_t* track, - const Vertex<InputTrack_t>& vtx) const; + Result<double> getIPSignificance( + const InputTrack_t* track, const Vertex<InputTrack_t>& vtx, + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Adds compatible track to vertex candidate /// /// @param tracks The tracks /// @param vtx The vertex candidate /// @param[out] fitterState The vertex fitter state + /// @param vertexingOptions Vertexing options Result<void> addCompatibleTracksToVertex( const std::vector<const InputTrack_t*>& tracks, Vertex<InputTrack_t>& vtx, - FitterState_t& fitterState) const; + FitterState_t& fitterState, + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Method that tries to recover from cases where no tracks /// were added to the vertex candidate after seeding @@ -261,13 +265,15 @@ class AdaptiveMultiVertexFinder { /// @param[out] vtx The vertex candidate /// @param currentConstraint Vertex constraint /// @param[out] fitterState The vertex fitter state + /// @param vertexingOptions Vertexing options /// /// return True if recovery was successful, false otherwise Result<bool> canRecoverFromNoCompatibleTracks( const std::vector<const InputTrack_t*>& allTracks, const std::vector<const InputTrack_t*>& seedTracks, Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint, - FitterState_t& fitterState) const; + FitterState_t& fitterState, + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Method that tries to prepare the vertex for the fit /// @@ -277,13 +283,15 @@ class AdaptiveMultiVertexFinder { /// @param[out] vtx The vertex candidate /// @param currentConstraint Vertex constraint /// @param[out] fitterState The vertex fitter state + /// @param vertexingOptions Vertexing options /// /// @return True if preparation was successful, false otherwise Result<bool> canPrepareVertexForFit( const std::vector<const InputTrack_t*>& allTracks, const std::vector<const InputTrack_t*>& seedTracks, Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint, - FitterState_t& fitterState) const; + FitterState_t& fitterState, + const VertexingOptions<InputTrack_t>& vertexingOptions) const; /// @brief Method that checks if vertex is a good vertex and if /// compatible tracks are available diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp index ff2610e51..1653da108 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFinder.ipp @@ -63,8 +63,9 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::find( allVerticesPtr.pop_back(); break; } - auto prepResult = canPrepareVertexForFit( - allTracks, seedTracks, vtxCandidate, currentConstraint, fitterState); + auto prepResult = canPrepareVertexForFit(allTracks, seedTracks, + vtxCandidate, currentConstraint, + fitterState, vertexingOptions); if (!prepResult.ok()) { return prepResult.error(); @@ -180,7 +181,8 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::estimateDeltaZ( template <typename vfitter_t, typename sfinder_t> auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::getIPSignificance( - const InputTrack_t* track, const Vertex<InputTrack_t>& vtx) const + const InputTrack_t* track, const Vertex<InputTrack_t>& vtx, + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<double> { // TODO: In original implementation the covariance of the given vertex is set // to zero. I did the same here now, but consider removing this and just @@ -192,7 +194,9 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::getIPSignificance( newVtx.setFullCovariance(SpacePointSymMatrix::Zero()); } - auto estRes = m_cfg.ipEstimator.estimate(*track, newVtx); + auto estRes = + m_cfg.ipEstimator.estimate(*track, newVtx, vertexingOptions.geoContext, + vertexingOptions.magFieldContext); if (!estRes.ok()) { return estRes.error(); } @@ -210,12 +214,13 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>::getIPSignificance( template <typename vfitter_t, typename sfinder_t> auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>:: - addCompatibleTracksToVertex(const std::vector<const InputTrack_t*>& tracks, - Vertex<InputTrack_t>& vtx, - FitterState_t& fitterState) const + addCompatibleTracksToVertex( + const std::vector<const InputTrack_t*>& tracks, + Vertex<InputTrack_t>& vtx, FitterState_t& fitterState, + const VertexingOptions<InputTrack_t>& vertexingOptions) const -> Result<void> { for (const auto& trk : tracks) { - auto sigRes = getIPSignificance(trk, vtx); + auto sigRes = getIPSignificance(trk, vtx, vertexingOptions); if (!sigRes.ok()) { return sigRes.error(); } @@ -243,7 +248,9 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>:: const std::vector<const InputTrack_t*>& seedTracks, Vertex<InputTrack_t>& vtx, const Vertex<InputTrack_t>& currentConstraint, - FitterState_t& fitterState) const -> Result<bool> { + FitterState_t& fitterState, + const VertexingOptions<InputTrack_t>& vertexingOptions) const + -> Result<bool> { // Recover from cases where no compatible tracks to vertex // candidate were found // TODO: This is for now how it's done in athena... this look a bit @@ -271,7 +278,8 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>:: VertexInfo<InputTrack_t>(currentConstraint, vtx.fullPosition()); // Try to add compatible track with adapted vertex position - auto res = addCompatibleTracksToVertex(allTracks, vtx, fitterState); + auto res = addCompatibleTracksToVertex(allTracks, vtx, fitterState, + vertexingOptions); if (!res.ok()) { return Result<bool>::failure(res.error()); } @@ -294,24 +302,29 @@ auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>:: template <typename vfitter_t, typename sfinder_t> auto Acts::AdaptiveMultiVertexFinder<vfitter_t, sfinder_t>:: - canPrepareVertexForFit(const std::vector<const InputTrack_t*>& allTracks, - const std::vector<const InputTrack_t*>& seedTracks, - Vertex<InputTrack_t>& vtx, - const Vertex<InputTrack_t>& currentConstraint, - FitterState_t& fitterState) const -> Result<bool> { + canPrepareVertexForFit( + const std::vector<const InputTrack_t*>& allTracks, + const std::vector<const InputTrack_t*>& seedTracks, + Vertex<InputTrack_t>& vtx, + const Vertex<InputTrack_t>& currentConstraint, + FitterState_t& fitterState, + const VertexingOptions<InputTrack_t>& vertexingOptions) const + -> Result<bool> { // Add vertex info to fitter state fitterState.vtxInfoMap[&vtx] = VertexInfo<InputTrack_t>(currentConstraint, vtx.fullPosition()); // Add all compatible tracks to vertex - auto resComp = addCompatibleTracksToVertex(allTracks, vtx, fitterState); + auto resComp = addCompatibleTracksToVertex(allTracks, vtx, fitterState, + vertexingOptions); if (!resComp.ok()) { return Result<bool>::failure(resComp.error()); } // Try to recover from cases where adding compatible track was not possible - auto resRec = canRecoverFromNoCompatibleTracks( - allTracks, seedTracks, vtx, currentConstraint, fitterState); + auto resRec = canRecoverFromNoCompatibleTracks(allTracks, seedTracks, vtx, + currentConstraint, fitterState, + vertexingOptions); if (!resRec.ok()) { return Result<bool>::failure(resRec.error()); } diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp index ae53491b8..eaafee956 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.hpp @@ -253,11 +253,11 @@ class AdaptiveMultiVertexFitter { /// at current vertex /// /// @param state The state object - /// @param geoContext The geometry context /// @param currentVtx Current vertex + /// @param vertexingOptions Vertexing options Result<void> setAllVertexCompatibilities( - State& state, const GeometryContext& geoContext, - Vertex<InputTrack_t>* currentVtx) const; + State& state, Vertex<InputTrack_t>* currentVtx, + const VertexingOptions<input_track_t>& vertexingOptions) const; /// @brief Sets weights to the track according to Eq.(5.46) in Ref.(1) /// and updates the vertices by calling the VertexUpdater diff --git a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp index dfb2d5f33..053b9ed08 100644 --- a/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/AdaptiveMultiVertexFitter.ipp @@ -94,7 +94,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>::fitImpl( // Set vertexCompatibility for all TrackAtVertex objects // at current vertex - setAllVertexCompatibilities(state, geoContext, currentVtx); + setAllVertexCompatibilities(state, currentVtx, vertexingOptions); } // End loop over vertex collection // Now after having estimated all compatibilities of all tracks at @@ -204,12 +204,12 @@ Acts::Result<void> Acts:: auto& currentVtxInfo = state.vtxInfoMap[vtx]; // The seed position const Vector3D& seedPos = currentVtxInfo.seedPosition.template head<3>(); - auto& geoContext = vertexingOptions.geoContext; // Loop over all tracks at current vertex for (const auto& trk : currentVtxInfo.trackLinks) { auto res = m_cfg.ipEst.getParamsAtClosestApproach( - geoContext, m_extractParameters(*trk), seedPos); + vertexingOptions.geoContext, vertexingOptions.magFieldContext, + m_extractParameters(*trk), seedPos); if (!res.ok()) { return res.error(); } @@ -222,8 +222,9 @@ Acts::Result<void> Acts:: template <typename input_track_t, typename linearizer_t> Acts::Result<void> Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>:: - setAllVertexCompatibilities(State& state, const GeometryContext& geoContext, - Vertex<input_track_t>* currentVtx) const { + setAllVertexCompatibilities( + State& state, Vertex<input_track_t>* currentVtx, + const VertexingOptions<input_track_t>& vertexingOptions) const { VertexInfo<input_track_t>& currentVtxInfo = state.vtxInfoMap[currentVtx]; // Loop over tracks at current vertex and @@ -236,7 +237,8 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>:: if (currentVtxInfo.ip3dParams.find(trk) == currentVtxInfo.ip3dParams.end()) { auto res = m_cfg.ipEst.getParamsAtClosestApproach( - geoContext, m_extractParameters(*trk), + vertexingOptions.geoContext, vertexingOptions.magFieldContext, + m_extractParameters(*trk), VectorHelpers::position(currentVtxInfo.linPoint)); if (!res.ok()) { return res.error(); @@ -246,7 +248,7 @@ Acts::AdaptiveMultiVertexFitter<input_track_t, linearizer_t>:: } // Set compatibility with current vertex auto compRes = m_cfg.ipEst.getVertexCompatibility( - geoContext, &(currentVtxInfo.ip3dParams.at(trk)), + vertexingOptions.geoContext, &(currentVtxInfo.ip3dParams.at(trk)), VectorHelpers::position(currentVtxInfo.oldPosition)); if (!compRes.ok()) { return compRes.error(); diff --git a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp index 8d60896de..4f75c4c95 100644 --- a/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp +++ b/Core/include/Acts/Vertexing/HelicalTrackLinearizer.ipp @@ -19,6 +19,7 @@ Acts::Result<Acts::LinearizedTrack> Acts:: const std::shared_ptr<PerigeeSurface> perigeeSurface = Surface::makeShared<PerigeeSurface>(linPointPos); + // Create propagator options propagator_options_t pOptions(gctx, mctx); pOptions.direction = backward; diff --git a/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.hpp b/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.hpp index 943f9adec..f2358e7b6 100644 --- a/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.hpp +++ b/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.hpp @@ -34,40 +34,21 @@ class ImpactPoint3dEstimator { /// /// @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, - propagator_options_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, propagator_options_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)) {} /// Magnetic field BField_t bField; /// Propagator std::shared_ptr<propagator_t> propagator; - // The propagator options - propagator_options_t pOptions; /// Max. number of iterations in Newton method int maxIterations = 20; /// Desired precision in deltaPhi in Newton method @@ -103,13 +84,14 @@ class ImpactPoint3dEstimator { /// given reference point (vertex). /// /// @param gctx The geometry context + /// @param mctx The magnetic field context /// @param trkParams Track parameters /// @param vtxPos Reference position (vertex) /// /// @return New track params Result<std::unique_ptr<const BoundParameters>> getParamsAtClosestApproach( - const GeometryContext& gctx, const BoundParameters& trkParams, - const Vector3D& vtxPos) const; + const GeometryContext& gctx, const Acts::MagneticFieldContext& mctx, + const BoundParameters& trkParams, const Vector3D& vtxPos) const; /// @brief Estimates the compatibility of a /// track to a vertex position based on the 3d diff --git a/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.ipp b/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.ipp index 3ed468085..d3b1cf6e1 100644 --- a/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.ipp +++ b/Core/include/Acts/Vertexing/ImpactPoint3dEstimator.ipp @@ -38,6 +38,7 @@ Acts::Result<std::unique_ptr<const Acts::BoundParameters>> Acts::ImpactPoint3dEstimator<input_track_t, propagator_t, propagator_options_t>:: getParamsAtClosestApproach(const GeometryContext& gctx, + const Acts::MagneticFieldContext& mctx, const BoundParameters& trkParams, const Vector3D& vtxPos) const { Vector3D deltaR; @@ -70,9 +71,12 @@ Acts::ImpactPoint3dEstimator<input_track_t, propagator_t, Surface::makeShared<PlaneSurface>( std::make_shared<Transform3D>(thePlane)); + // Create propagator options + propagator_options_t pOptions(gctx, mctx); + pOptions.direction = backward; + // Do the propagation to linPointPos - auto result = - m_cfg.propagator->propagate(trkParams, *planeSurface, m_cfg.pOptions); + auto result = m_cfg.propagator->propagate(trkParams, *planeSurface, pOptions); if (result.ok()) { return std::move((*result).endParameters); } else { diff --git a/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.hpp b/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.hpp index 8c34eea4d..2666a51c6 100644 --- a/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.hpp +++ b/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.hpp @@ -39,22 +39,11 @@ class TrackToVertexIPEstimator { public: /// @brief Configuration struct /// - /// @param p The propagator - /// @param propOptions The propagator options - /// @param doBackwardPropagation Set the propagation direction to backward + /// @param prop The propagator struct Config { - Config(std::shared_ptr<propagator_t> p, - const propagator_options_t& propOptions, - bool doBackwardPropagation = true) - : propagator(std::move(p)), pOptions(propOptions) { - if (doBackwardPropagation) { - pOptions.direction = backward; - } - } + Config(std::shared_ptr<propagator_t> prop) : propagator(std::move(prop)) {} std::shared_ptr<propagator_t> propagator; - - propagator_options_t pOptions; }; /// @brief Default constructor @@ -77,8 +66,12 @@ class TrackToVertexIPEstimator { /// /// @param track Track to estimate IP from /// @param vtx Vertex the track belongs to + /// @param gctx The geometry context + /// @param mctx The magnetic field context Result<ImpactParametersAndSigma> estimate( - const BoundParameters& track, const Vertex<input_track_t>& vtx) const; + const BoundParameters& track, const Vertex<input_track_t>& vtx, + const GeometryContext& gctx, + const Acts::MagneticFieldContext& mctx) const; private: /// Config diff --git a/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.ipp b/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.ipp index 3d3989b21..853dcedcf 100644 --- a/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.ipp +++ b/Core/include/Acts/Vertexing/TrackToVertexIPEstimator.ipp @@ -13,7 +13,10 @@ template <typename input_track_t, typename propagator_t, Acts::Result<Acts::ImpactParametersAndSigma> Acts::TrackToVertexIPEstimator< input_track_t, propagator_t, propagator_options_t>::estimate(const BoundParameters& track, - const Vertex<input_track_t>& vtx) const { + const Vertex<input_track_t>& vtx, + const GeometryContext& gctx, + const Acts::MagneticFieldContext& mctx) + const { // estimating the d0 and its significance by propagating the trajectory state // towards // the vertex position. By this time the vertex should NOT contain this @@ -21,9 +24,12 @@ Acts::Result<Acts::ImpactParametersAndSigma> Acts::TrackToVertexIPEstimator< const std::shared_ptr<PerigeeSurface> perigeeSurface = Surface::makeShared<PerigeeSurface>(vtx.position()); + // Create propagator options + propagator_options_t pOptions(gctx, mctx); + pOptions.direction = backward; + // Do the propagation to linPoint - auto result = - m_cfg.propagator->propagate(track, *perigeeSurface, m_cfg.pOptions); + auto result = m_cfg.propagator->propagate(track, *perigeeSurface, pOptions); if (!result.ok()) { return result.error(); diff --git a/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp b/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp index 7344f7d2a..491253247 100644 --- a/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp +++ b/Core/include/Acts/Vertexing/ZScanVertexFinder.ipp @@ -30,8 +30,9 @@ auto Acts::ZScanVertexFinder<vfitter_t>::find( ImpactParametersAndSigma ipas; if (useConstraint && vertexingOptions.vertexConstraint.covariance()(0, 0) != 0) { - auto estRes = - m_cfg.ipEstimator.estimate(params, vertexingOptions.vertexConstraint); + auto estRes = m_cfg.ipEstimator.estimate( + params, vertexingOptions.vertexConstraint, + vertexingOptions.geoContext, vertexingOptions.magFieldContext); if (estRes.ok()) { ipas = *estRes; } else { diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp index f6980479c..2aa5af3c5 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFinderTests.cpp @@ -35,8 +35,8 @@ using Propagator = Propagator<EigenStepper<ConstantBField>>; using Linearizer = HelicalTrackLinearizer<Propagator>; // Create a test context -GeometryContext tgContext = GeometryContext(); -MagneticFieldContext mfContext = MagneticFieldContext(); +GeometryContext geoContext = GeometryContext(); +MagneticFieldContext magFieldContext = MagneticFieldContext(); BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { // Set debug mode @@ -50,13 +50,11 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); - pOptions.direction = backward; // IP 3D Estimator using IPEstimator = ImpactPoint3dEstimator<BoundParameters, Propagator>; - IPEstimator::Config ip3dEstCfg(bField, propagator, pOptions, false); + IPEstimator::Config ip3dEstCfg(bField, propagator); IPEstimator ip3dEst(ip3dEstCfg); std::vector<double> temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0}; @@ -84,7 +82,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { using IPEstimater = TrackToVertexIPEstimator<BoundParameters, Propagator>; - IPEstimater::Config ipEstCfg(propagator, pOptions); + IPEstimater::Config ipEstCfg(propagator); // Create TrackToVertexIPEstimator IPEstimater ipEst(ipEstCfg); @@ -120,7 +118,8 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_finder_test) { tracksPtr.push_back(&trk); } - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); Vector3D constraintPos{0._mm, 0._mm, 0_mm}; ActsSymMatrixD<3> constraintCov; diff --git a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp index 886e8b6fc..b8f385ba6 100644 --- a/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/AdaptiveMultiVertexFitterTests.cpp @@ -30,8 +30,8 @@ using Propagator = Propagator<EigenStepper<ConstantBField>>; 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); @@ -75,14 +75,14 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); // IP 3D Estimator using IPEstimator = ImpactPoint3dEstimator<BoundParameters, Propagator>; - IPEstimator::Config ip3dEstCfg(bField, propagator, pOptions); + IPEstimator::Config ip3dEstCfg(bField, propagator); IPEstimator ip3dEst(ip3dEstCfg); AdaptiveMultiVertexFitter<BoundParameters, Linearizer>::Config fitterCfg( @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test) { std::shared_ptr<PerigeeSurface> perigeeSurface = Surface::makeShared<PerigeeSurface>(vtxPosVec[vtxIdx]); - allTracks.push_back(BoundParameters(tgContext, std::move(covMat), paramVec, + allTracks.push_back(BoundParameters(geoContext, std::move(covMat), paramVec, perigeeSurface)); } @@ -321,14 +321,14 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); // IP 3D Estimator using IPEstimator = ImpactPoint3dEstimator<BoundParameters, Propagator>; - IPEstimator::Config ip3dEstCfg(bField, propagator, pOptions, false); + IPEstimator::Config ip3dEstCfg(bField, propagator); IPEstimator ip3dEst(ip3dEstCfg); std::vector<double> temperatures(1, 3.); @@ -373,22 +373,22 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) { std::vector<BoundParameters> params1; params1.push_back( - BoundParameters(tgContext, covMat1, pos1a, mom1a, 1, 0, + BoundParameters(geoContext, covMat1, pos1a, mom1a, 1, 0, Surface::makeShared<PerigeeSurface>(pos1a))); params1.push_back( - BoundParameters(tgContext, covMat1, pos1b, mom1b, -1, 0, + BoundParameters(geoContext, covMat1, pos1b, mom1b, -1, 0, Surface::makeShared<PerigeeSurface>(pos1b))); params1.push_back( - BoundParameters(tgContext, covMat1, pos1c, mom1c, 1, 0, + BoundParameters(geoContext, covMat1, pos1c, mom1c, 1, 0, Surface::makeShared<PerigeeSurface>(pos1c))); params1.push_back( - BoundParameters(tgContext, covMat1, pos1d, mom1d, -1, 0, + BoundParameters(geoContext, covMat1, pos1d, mom1d, -1, 0, Surface::makeShared<PerigeeSurface>(pos1d))); params1.push_back( - BoundParameters(tgContext, covMat1, pos1e, mom1e, 1, 0, + BoundParameters(geoContext, covMat1, pos1e, mom1e, 1, 0, Surface::makeShared<PerigeeSurface>(pos1e))); params1.push_back( - BoundParameters(tgContext, covMat1, pos1f, mom1f, -1, 0, + BoundParameters(geoContext, covMat1, pos1f, mom1f, -1, 0, Surface::makeShared<PerigeeSurface>(pos1f))); // Create second vector of tracks @@ -404,13 +404,13 @@ BOOST_AUTO_TEST_CASE(adaptive_multi_vertex_fitter_test_athena) { std::vector<BoundParameters> params2; params2.push_back( - BoundParameters(tgContext, covMat2, pos2a, mom2a, 1, 0, + BoundParameters(geoContext, covMat2, pos2a, mom2a, 1, 0, Surface::makeShared<PerigeeSurface>(pos2a))); params2.push_back( - BoundParameters(tgContext, covMat2, pos2b, mom2b, -1, 0, + BoundParameters(geoContext, covMat2, pos2b, mom2b, -1, 0, Surface::makeShared<PerigeeSurface>(pos2b))); params2.push_back( - BoundParameters(tgContext, covMat2, pos2c, mom2c, -1, 0, + BoundParameters(geoContext, covMat2, pos2c, mom2c, -1, 0, Surface::makeShared<PerigeeSurface>(pos2c))); std::vector<Vertex<BoundParameters>*> vtxList; diff --git a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp index 249cd7554..8239c0035 100644 --- a/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/FullBilloirVertexFitterTests.cpp @@ -33,8 +33,8 @@ using Linearizer = HelicalTrackLinearizer<Propagator<EigenStepper<ConstantBField>>>; // Create a test context -GeometryContext tgContext = GeometryContext(); -MagneticFieldContext mfContext = MagneticFieldContext(); +GeometryContext geoContext = GeometryContext(); +MagneticFieldContext magFieldContext = MagneticFieldContext(); /// @brief Unit test for FullBilloirVertexFitter /// @@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_empty_input_test) { const std::vector<const BoundParameters*> emptyVector; - VertexingOptions<BoundParameters> vfOptions(tgContext, mfContext, + VertexingOptions<BoundParameters> vfOptions(geoContext, magFieldContext, myConstraint); Vertex<BoundParameters> fittedVertex = @@ -155,10 +155,10 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_defaulttrack_test) { myCovMat(3, 3) = 30.; myConstraint.setFullCovariance(std::move(myCovMat)); myConstraint.setFullPosition(SpacePointVector(0, 0, 0, 0)); - VertexingOptions<BoundParameters> vfOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vfOptions(geoContext, magFieldContext); - VertexingOptions<BoundParameters> vfOptionsConstr(tgContext, mfContext, - myConstraint); + VertexingOptions<BoundParameters> vfOptionsConstr( + geoContext, magFieldContext, myConstraint); // Create position of vertex and perigee surface double x = vXYDist(gen); double y = vXYDist(gen); @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_defaulttrack_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)); } @@ -292,9 +292,9 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_usertrack_test) { myConstraint.setFullCovariance(std::move(myCovMat)); myConstraint.setFullPosition(SpacePointVector(0, 0, 0, 0)); - VertexingOptions<InputTrack> vfOptions(tgContext, mfContext); + VertexingOptions<InputTrack> vfOptions(geoContext, magFieldContext); - VertexingOptions<InputTrack> vfOptionsConstr(tgContext, mfContext, + VertexingOptions<InputTrack> vfOptionsConstr(geoContext, magFieldContext, myConstraint); // Create position of vertex and perigee surface @@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE(billoir_vertex_fitter_usertrack_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(InputTrack(BoundParameters(tgContext, std::move(covMat), + tracks.push_back(InputTrack(BoundParameters(geoContext, std::move(covMat), paramVec, perigeeSurface))); } diff --git a/Tests/UnitTests/Core/Vertexing/ImpactPoint3dEstimatorTests.cpp b/Tests/UnitTests/Core/Vertexing/ImpactPoint3dEstimatorTests.cpp index b1dd2458c..e39f70034 100644 --- a/Tests/UnitTests/Core/Vertexing/ImpactPoint3dEstimatorTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ImpactPoint3dEstimatorTests.cpp @@ -28,8 +28,8 @@ namespace Test { using Covariance = BoundSymMatrix; using Propagator = Propagator<EigenStepper<ConstantBField>>; // Create a test context -GeometryContext tgContext = GeometryContext(); -MagneticFieldContext mfContext = MagneticFieldContext(); +GeometryContext geoContext = GeometryContext(); +MagneticFieldContext magFieldContext = MagneticFieldContext(); // Track d0 distribution std::uniform_real_distribution<> d0Dist(-0.01_mm, 0.01_mm); @@ -70,11 +70,10 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_params_distance_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); // Set up the ImpactPoint3dEstimator ImpactPoint3dEstimator<BoundParameters, Propagator>::Config ipEstCfg( - bField, propagator, pOptions); + bField, propagator); ImpactPoint3dEstimator<BoundParameters, Propagator> ipEstimator(ipEstCfg); @@ -117,7 +116,7 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_params_distance_test) { Surface::makeShared<PerigeeSurface>(refPosition); // Creating the track - BoundParameters myTrack(tgContext, std::move(covMat), paramVec, + BoundParameters myTrack(geoContext, std::move(covMat), paramVec, perigeeSurface); // Distance in transverse plane @@ -125,7 +124,7 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_params_distance_test) { // Estimate 3D distance auto distanceRes = - ipEstimator.calculateDistance(tgContext, myTrack, refPosition); + ipEstimator.calculateDistance(geoContext, myTrack, refPosition); BOOST_CHECK(distanceRes.ok()); double distance = *distanceRes; @@ -140,8 +139,8 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_params_distance_test) { << std::endl; } - auto res = - ipEstimator.getParamsAtClosestApproach(tgContext, myTrack, refPosition); + auto res = ipEstimator.getParamsAtClosestApproach( + geoContext, magFieldContext, myTrack, refPosition); BOOST_CHECK(res.ok()); @@ -190,11 +189,10 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_compatibility_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); // Set up the ImpactPoint3dEstimator ImpactPoint3dEstimator<BoundParameters, Propagator>::Config ipEstCfg( - bField, propagator, pOptions); + bField, propagator); ImpactPoint3dEstimator<BoundParameters, Propagator> ipEstimator(ipEstCfg); @@ -240,25 +238,25 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_compatibility_test) { Surface::makeShared<PerigeeSurface>(refPosition); // Creating the track - BoundParameters myTrack(tgContext, std::move(covMat), paramVec, + BoundParameters myTrack(geoContext, std::move(covMat), paramVec, perigeeSurface); // Estimate 3D distance auto distanceRes = - ipEstimator.calculateDistance(tgContext, myTrack, refPosition); + ipEstimator.calculateDistance(geoContext, myTrack, refPosition); BOOST_CHECK(distanceRes.ok()); distancesList.push_back(*distanceRes); - auto res = - ipEstimator.getParamsAtClosestApproach(tgContext, myTrack, refPosition); + auto res = ipEstimator.getParamsAtClosestApproach( + geoContext, magFieldContext, myTrack, refPosition); BOOST_CHECK(res.ok()); BoundParameters params = std::move(**res); auto compRes = - ipEstimator.getVertexCompatibility(tgContext, ¶ms, refPosition); + ipEstimator.getVertexCompatibility(geoContext, ¶ms, refPosition); BOOST_CHECK(compRes.ok()); @@ -310,11 +308,10 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_athena_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); // Set up the ImpactPoint3dEstimator ImpactPoint3dEstimator<BoundParameters, Propagator>::Config ipEstCfg( - bField, propagator, pOptions); + bField, propagator); ImpactPoint3dEstimator<BoundParameters, Propagator> ipEstimator(ipEstCfg); @@ -329,9 +326,9 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_athena_test) { Surface::makeShared<PerigeeSurface>(pos1); // Some fixed track parameter values - BoundParameters params1(tgContext, covMat, pos1, mom1, 1, 0, perigeeSurface); + BoundParameters params1(geoContext, covMat, pos1, mom1, 1, 0, perigeeSurface); - auto res1 = ipEstimator.calculateDistance(tgContext, params1, vtxPos); + auto res1 = ipEstimator.calculateDistance(geoContext, params1, vtxPos); BOOST_CHECK(res1.ok()); double distance = (*res1); @@ -339,11 +336,11 @@ BOOST_AUTO_TEST_CASE(impactpoint_3d_estimator_athena_test) { const double result = 3.10391_mm; CHECK_CLOSE_ABS(distance, result, 0.00001_mm); - auto res2 = - ipEstimator.getParamsAtClosestApproach(tgContext, params1, vtxPos); + auto res2 = ipEstimator.getParamsAtClosestApproach( + geoContext, magFieldContext, params1, vtxPos); BOOST_CHECK(res2.ok()); BoundParameters endParams = std::move(**res2); - Vector3D surfaceCenter = endParams.referenceSurface().center(tgContext); + Vector3D surfaceCenter = endParams.referenceSurface().center(geoContext); BOOST_CHECK_EQUAL(surfaceCenter, vtxPos); } diff --git a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp index 355ddbaad..0d2addda7 100644 --- a/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/IterativeVertexFinderTests.cpp @@ -37,8 +37,8 @@ using Propagator = Propagator<EigenStepper<ConstantBField>>; 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); @@ -102,8 +102,6 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); - // Linearizer for BoundParameters type test Linearizer::Config ltConfig(bField, propagator); Linearizer linearizer(ltConfig); @@ -117,7 +115,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { // Set up all seed finder related things TrackToVertexIPEstimator<BoundParameters, Propagator>::Config ipEstCfg( - propagator, pOptions); + propagator); TrackToVertexIPEstimator<BoundParameters, Propagator> ipEst(ipEstCfg); using ZScanSeedFinder = ZScanVertexFinder<BilloirFitter>; @@ -139,7 +137,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { using ImpactPointEstimator = ImpactPoint3dEstimator<BoundParameters, Propagator>; - ImpactPointEstimator::Config ip3dEstCfg(bField, propagator, pOptions); + ImpactPointEstimator::Config ip3dEstCfg(bField, propagator); ImpactPointEstimator ip3dEst(ip3dEstCfg); VertexFinder::Config cfg(std::move(bFitter), std::move(linearizer), @@ -210,7 +208,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { 0., 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.; - auto params = BoundParameters(tgContext, std::move(covMat), paramVec, + auto params = BoundParameters(geoContext, std::move(covMat), paramVec, perigeeSurface); tracks.push_back(std::make_unique<BoundParameters>(params)); @@ -231,7 +229,8 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test) { tracksPtr.push_back(trk.get()); } - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); // find vertices auto res = finder.find(tracksPtr, vertexingOptions); @@ -326,8 +325,6 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); - // Linearizer for user defined InputTrack type test Linearizer::Config ltConfigUT(bField, propagator); Linearizer linearizer(ltConfigUT); @@ -347,7 +344,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { // Set up all seed finder related things TrackToVertexIPEstimator<InputTrack, Propagator>::Config ipEstCfg( - propagator, pOptions); + propagator); TrackToVertexIPEstimator<InputTrack, Propagator> ipEst(ipEstCfg); using ZScanSeedFinder = ZScanVertexFinder<BilloirFitter>; @@ -358,7 +355,7 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { // IP 3D Estimator using ImpactPointEstimator = ImpactPoint3dEstimator<InputTrack, Propagator>; - ImpactPointEstimator::Config ip3dEstCfg(bField, propagator, pOptions); + ImpactPointEstimator::Config ip3dEstCfg(bField, propagator); ImpactPointEstimator ip3dEst(ip3dEstCfg); // Vertex Finder @@ -431,8 +428,8 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { 0., 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.; - auto paramsUT = InputTrack(BoundParameters(tgContext, std::move(covMat), - paramVec, perigeeSurface)); + auto paramsUT = InputTrack(BoundParameters( + geoContext, std::move(covMat), paramVec, perigeeSurface)); tracks.push_back(std::make_unique<InputTrack>(paramsUT)); @@ -454,7 +451,8 @@ BOOST_AUTO_TEST_CASE(iterative_finder_test_user_track_type) { tracksPtr.push_back(trk.get()); } - VertexingOptions<InputTrack> vertexingOptionsUT(tgContext, mfContext); + VertexingOptions<InputTrack> vertexingOptionsUT(geoContext, + magFieldContext); // find vertices auto res = finder.find(tracksPtr, vertexingOptionsUT); diff --git a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp index 5662c77f6..211ea49e8 100644 --- a/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/KalmanVertexTrackUpdaterTests.cpp @@ -80,11 +80,10 @@ BOOST_AUTO_TEST_CASE(Kalman_Vertex_TrackUpdater) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(geoContext, magFieldContext); // Set up ImpactPoint3dEstimator, used for comparisons later ImpactPoint3dEstimator<BoundParameters, Propagator>::Config ip3dEstConfig( - bField, propagator, pOptions); + bField, propagator); ImpactPoint3dEstimator<BoundParameters, Propagator> ip3dEst(ip3dEstConfig); diff --git a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp index 33b84d5cc..c450d6bf7 100644 --- a/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/LinearizedTrackFactoryTests.cpp @@ -33,7 +33,7 @@ using Linearizer = // Create a test context GeometryContext geoContext = GeometryContext(); -MagneticFieldContext mfContext = MagneticFieldContext(); +MagneticFieldContext magFieldContext = MagneticFieldContext(); // Vertex x/y position distribution std::uniform_real_distribution<> vXYDist(-0.1_mm, 0.1_mm); @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_test) { LinearizedTrack linTrack = linFactory .linearizeTrack(parameters, SpacePointVector::Zero(), geoContext, - mfContext) + magFieldContext) .value(); BOOST_CHECK_NE(linTrack.parametersAtPCA, vecBoundZero); @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(linearized_track_factory_straightline_test) { LinearizedTrack linTrack = linFactory .linearizeTrack(parameters, SpacePointVector::Zero(), geoContext, - mfContext) + magFieldContext) .value(); BOOST_CHECK_NE(linTrack.parametersAtPCA, vecBoundZero); diff --git a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp index ea6d61771..513c35cd7 100644 --- a/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/TrackDensityVertexFinderTests.cpp @@ -29,8 +29,8 @@ namespace Test { using Covariance = BoundSymMatrix; // Create a test context -GeometryContext tgContext = GeometryContext(); -MagneticFieldContext mfContext = MagneticFieldContext(); +GeometryContext geoContext = GeometryContext(); +MagneticFieldContext magFieldContext = MagneticFieldContext(); /// /// @brief Unit test for TrackDensityVertexFinder using same configuration @@ -47,7 +47,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_test) { Vector3D pos1c{1.2_mm, 1.3_mm, -7_mm}; Vector3D mom1c{300_MeV, 1000_MeV, 100_MeV}; - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); TrackDensityVertexFinder<DummyVertexFitter<>, GaussianTrackDensity> finder; @@ -57,11 +58,11 @@ BOOST_AUTO_TEST_CASE(track_density_finder_test) { Surface::makeShared<PerigeeSurface>(pos0); // Test finder for some fixed track parameter values - BoundParameters params1a(tgContext, covMat, pos1a, mom1a, 1, 0, + BoundParameters params1a(geoContext, covMat, pos1a, mom1a, 1, 0, perigeeSurface); - BoundParameters params1b(tgContext, covMat, pos1b, mom1b, -1, 0, + BoundParameters params1b(geoContext, covMat, pos1b, mom1b, -1, 0, perigeeSurface); - BoundParameters params1c(tgContext, covMat, pos1c, mom1c, -1, 0, + BoundParameters params1c(geoContext, covMat, pos1c, mom1c, -1, 0, perigeeSurface); // Vectors of track parameters in different orders @@ -106,7 +107,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_constr_test) { double const expectedZResult = -13.013; // Finder options - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); // Create constraint for seed finding Vector3D constraintPos{1.7_mm, 1.3_mm, -6_mm}; @@ -125,11 +127,11 @@ BOOST_AUTO_TEST_CASE(track_density_finder_constr_test) { Surface::makeShared<PerigeeSurface>(pos0); // Test finder for some fixed track parameter values - BoundParameters params1a(tgContext, covMat, pos1a, mom1a, 1, 0, + BoundParameters params1a(geoContext, covMat, pos1a, mom1a, 1, 0, perigeeSurface); - BoundParameters params1b(tgContext, covMat, pos1b, mom1b, -1, 0, + BoundParameters params1b(geoContext, covMat, pos1b, mom1b, -1, 0, perigeeSurface); - BoundParameters params1c(tgContext, covMat, pos1c, mom1c, -1, 0, + BoundParameters params1c(geoContext, covMat, pos1c, mom1c, -1, 0, perigeeSurface); // Vector of track parameters @@ -179,7 +181,8 @@ BOOST_AUTO_TEST_CASE(track_density_finder_random_test) { std::shared_ptr<PerigeeSurface> perigeeSurface = Surface::makeShared<PerigeeSurface>(pos0); - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); TrackDensityVertexFinder<DummyVertexFitter<>, GaussianTrackDensity> finder; @@ -209,7 +212,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_random_test) { Vector3D mom(pt * std::cos(phi), pt * std::sin(phi), pt * std::sinh(eta)); double charge = etaDist(gen) > 0 ? 1 : -1; - trackVec.push_back(BoundParameters(tgContext, covMat, pos, mom, charge, 0, + trackVec.push_back(BoundParameters(geoContext, covMat, pos, mom, charge, 0, perigeeSurface)); } @@ -260,7 +263,7 @@ BOOST_AUTO_TEST_CASE(track_density_finder_usertrack_test) { double const expectedZResult = -13.013; // Finder options - VertexingOptions<InputTrack> vertexingOptions(tgContext, mfContext); + VertexingOptions<InputTrack> vertexingOptions(geoContext, magFieldContext); // Create constraint for seed finding Vector3D constraintPos{1.7_mm, 1.3_mm, -6_mm}; @@ -284,11 +287,11 @@ BOOST_AUTO_TEST_CASE(track_density_finder_usertrack_test) { // Test finder for some fixed track parameter values InputTrack params1a( - BoundParameters(tgContext, covMat, pos1a, mom1a, 1, 0, perigeeSurface)); + BoundParameters(geoContext, covMat, pos1a, mom1a, 1, 0, perigeeSurface)); InputTrack params1b( - BoundParameters(tgContext, covMat, pos1b, mom1b, -1, 0, perigeeSurface)); + BoundParameters(geoContext, covMat, pos1b, mom1b, -1, 0, perigeeSurface)); InputTrack params1c( - BoundParameters(tgContext, covMat, pos1c, mom1c, -1, 0, perigeeSurface)); + BoundParameters(geoContext, covMat, pos1c, mom1c, -1, 0, perigeeSurface)); // Vector of track parameters std::vector<const InputTrack*> vec1 = {¶ms1a, ¶ms1b, ¶ms1c}; diff --git a/Tests/UnitTests/Core/Vertexing/TrackToVertexIPEstimatorTests.cpp b/Tests/UnitTests/Core/Vertexing/TrackToVertexIPEstimatorTests.cpp index 9e99cc163..377ce1214 100644 --- a/Tests/UnitTests/Core/Vertexing/TrackToVertexIPEstimatorTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/TrackToVertexIPEstimatorTests.cpp @@ -30,8 +30,8 @@ namespace Test { using Covariance = BoundSymMatrix; // 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); @@ -79,8 +79,6 @@ BOOST_AUTO_TEST_CASE(track_to_vertex_ip_estimator_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.)); @@ -111,7 +109,7 @@ BOOST_AUTO_TEST_CASE(track_to_vertex_ip_estimator_test) { TrackToVertexIPEstimator<BoundParameters, Propagator<EigenStepper<ConstantBField>>>; - IPEst_t::Config ipEstCfg(propagator, pOptions); + IPEst_t::Config ipEstCfg(propagator); // Create TrackToVertexIPEstimator IPEst_t ipEst(ipEstCfg); @@ -140,12 +138,13 @@ BOOST_AUTO_TEST_CASE(track_to_vertex_ip_estimator_test) { 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.; - BoundParameters track = - BoundParameters(tgContext, std::move(covMat), paramVec, perigeeSurface); + BoundParameters track = BoundParameters(geoContext, std::move(covMat), + paramVec, perigeeSurface); // Check if IP are retrieved ImpactParametersAndSigma output = - ipEst.estimate(track, myConstraint).value(); + ipEst.estimate(track, myConstraint, geoContext, magFieldContext) + .value(); BOOST_CHECK_NE(output.IPd0, 0.); BOOST_CHECK_NE(output.IPz0, 0.); } diff --git a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp index 4143b9116..f0c991b3d 100644 --- a/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp +++ b/Tests/UnitTests/Core/Vertexing/ZScanVertexFinderTests.cpp @@ -36,8 +36,8 @@ using Propagator = Propagator<EigenStepper<ConstantBField>>; using Linearizer_t = 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); @@ -84,7 +84,6 @@ BOOST_AUTO_TEST_CASE(zscan_finder_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); typedef FullBilloirVertexFitter<BoundParameters, Linearizer_t> BilloirFitter; @@ -131,7 +130,7 @@ BOOST_AUTO_TEST_CASE(zscan_finder_test) { 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)); } @@ -146,14 +145,15 @@ BOOST_AUTO_TEST_CASE(zscan_finder_test) { "Vertex finder does not fulfill vertex finder concept."); TrackToVertexIPEstimator<BoundParameters, Propagator>::Config ipEstCfg( - propagator, pOptions); + propagator); TrackToVertexIPEstimator<BoundParameters, Propagator> ipEst(ipEstCfg); VertexFinder::Config cfg(std::move(ipEst)); VertexFinder finder(std::move(cfg)); - VertexingOptions<BoundParameters> vertexingOptions(tgContext, mfContext); + VertexingOptions<BoundParameters> vertexingOptions(geoContext, + magFieldContext); auto res = finder.find(tracksPtr, vertexingOptions); @@ -205,7 +205,6 @@ BOOST_AUTO_TEST_CASE(zscan_finder_usertrack_test) { // Set up propagator with void navigator auto propagator = std::make_shared<Propagator>(stepper); - PropagatorOptions<> pOptions(tgContext, mfContext); typedef FullBilloirVertexFitter<InputTrack, Linearizer_t> BilloirFitter; @@ -251,7 +250,7 @@ BOOST_AUTO_TEST_CASE(zscan_finder_usertrack_test) { 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(InputTrack(BoundParameters(tgContext, std::move(covMat), + tracks.push_back(InputTrack(BoundParameters(geoContext, std::move(covMat), paramVec, perigeeSurface))); } @@ -266,7 +265,7 @@ BOOST_AUTO_TEST_CASE(zscan_finder_usertrack_test) { "Vertex finder does not fulfill vertex finder concept."); TrackToVertexIPEstimator<InputTrack, Propagator>::Config ipEstCfg( - propagator, pOptions); + propagator); TrackToVertexIPEstimator<InputTrack, Propagator> ipEst(ipEstCfg); VertexFinder::Config cfg(std::move(ipEst)); @@ -278,7 +277,7 @@ BOOST_AUTO_TEST_CASE(zscan_finder_usertrack_test) { VertexFinder finder(std::move(cfg), extractParameters); - VertexingOptions<InputTrack> vertexingOptions(tgContext, mfContext); + VertexingOptions<InputTrack> vertexingOptions(geoContext, magFieldContext); auto res = finder.find(tracksPtr, vertexingOptions); -- GitLab From e8a2b3dedc3f22567c23daf87bf3b58e2bd5f18e Mon Sep 17 00:00:00 2001 From: Bastian Schlag <bastian.schlag@cern.ch> Date: Wed, 25 Mar 2020 17:22:45 +0100 Subject: [PATCH 5/6] update FullBilloirVertexFitter to correctly initialize all variables --- .../Vertexing/FullBilloirVertexFitter.ipp | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp index f403fc25c..5ee028ada 100644 --- a/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp +++ b/Core/include/Acts/Vertexing/FullBilloirVertexFitter.ipp @@ -196,14 +196,9 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( billoirVertex.Amat - billoirVertex.BCBmat; // VwgtMat = Amat-sum{BiMat*Ci^-1*BiMat^T} if (isConstraintFit) { - SpacePointVector posInBilloirFrame; // this will be 0 for first iteration but != 0 from second on - posInBilloirFrame[0] = - vertexingOptions.vertexConstraint.position()[0] - linPoint[0]; - posInBilloirFrame[1] = - vertexingOptions.vertexConstraint.position()[1] - linPoint[1]; - posInBilloirFrame[2] = - vertexingOptions.vertexConstraint.position()[2] - linPoint[2]; + SpacePointVector posInBilloirFrame = + vertexingOptions.vertexConstraint.fullPosition() - linPoint; Vdel += vertexingOptions.vertexConstraint.fullCovariance().inverse() * posInBilloirFrame; @@ -225,9 +220,7 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( (bTrack.CiInv) * (bTrack.UiVec - bTrack.BiMat.transpose() * deltaV); // update track momenta - trackMomenta[iTrack][0] += deltaP[0]; - trackMomenta[iTrack][1] += deltaP[1]; - trackMomenta[iTrack][2] += deltaP[2]; + trackMomenta[iTrack] += deltaP; // correct for 2PI / PI periodicity auto correctedPhiTheta = detail::ensureThetaBounds( @@ -286,23 +279,19 @@ Acts::FullBilloirVertexFitter<input_track_t, linearizer_t>::fit( } if (isConstraintFit) { - Vector3D deltaTrk; // last term will also be 0 again but only in the first iteration // = calc. vtx in billoir frame - ( isConstraintFit pos. in billoir // frame ) - deltaTrk[0] = - deltaV[0] - - (vertexingOptions.vertexConstraint.position()[0] - linPoint[0]); - deltaTrk[1] = - deltaV[1] - - (vertexingOptions.vertexConstraint.position()[1] - linPoint[1]); - deltaTrk[2] = - deltaV[2] - - (vertexingOptions.vertexConstraint.position()[2] - linPoint[2]); + + SpacePointVector deltaTrk = + deltaV - + (vertexingOptions.vertexConstraint.fullPosition() - linPoint); + newChi2 += (deltaTrk.transpose()) - .dot(vertexingOptions.vertexConstraint.covariance().inverse() * - deltaTrk); + .dot( + vertexingOptions.vertexConstraint.fullCovariance().inverse() * + deltaTrk); } if (!std::isnormal(newChi2)) { -- GitLab From 4b62273aaf9fcda308be1a327f12e72d47b5fca6 Mon Sep 17 00:00:00 2001 From: Bastian Schlag <bastian.schlag@cern.ch> Date: Wed, 25 Mar 2020 17:33:37 +0000 Subject: [PATCH 6/6] Apply suggestion to Core/include/Acts/Vertexing/LinearizerConcept.hpp --- Core/include/Acts/Vertexing/LinearizerConcept.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/Vertexing/LinearizerConcept.hpp b/Core/include/Acts/Vertexing/LinearizerConcept.hpp index cc17d1f8f..62c571aee 100644 --- a/Core/include/Acts/Vertexing/LinearizerConcept.hpp +++ b/Core/include/Acts/Vertexing/LinearizerConcept.hpp @@ -33,7 +33,7 @@ namespace concept { linTrack_t, const BoundParameters&, const SpacePointVector&, const Acts::GeometryContext&, - const Acts::MagneticFieldContext&>; + const Acts::MagneticFieldContext&>; static_assert(linTrack_exists, "linearizeTrack method not found"); -- GitLab