diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h index f4f520e8dc5b569f76068f78afb78ce00fb19ff7..2e57ce8ad6b12e5fb18aa5a6de6b1a01a5beda9b 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/TrkGaussianSumFilter/GaussianSumFitter.h @@ -141,7 +141,7 @@ private: Trk::SmoothedTrajectory& smoothedTrajectory) const; /** Forward GSF fit using PrepRawData */ - std::unique_ptr<ForwardTrajectory> fitPRD( + ForwardTrajectory fitPRD( const EventContext& ctx, IMultiStateExtrapolator::Cache&, const PrepRawDataSet&, @@ -149,7 +149,7 @@ private: const ParticleHypothesis particleHypothesis = nonInteracting) const; /** Forward GSF fit using MeasurementSet */ - std::unique_ptr<ForwardTrajectory> fitMeasurements( + ForwardTrajectory fitMeasurements( const EventContext& ctx, IMultiStateExtrapolator::Cache&, const MeasurementSet&, @@ -160,7 +160,7 @@ private: bool stepForwardFit( const EventContext& ctx, IMultiStateExtrapolator::Cache&, - ForwardTrajectory*, + ForwardTrajectory&, const PrepRawData*, const MeasurementBase*, const Surface&, diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx index 4ee702529de0e9409e9ea18633e40fa9a21aa760..0fb0012e946b42ee4363e00f1052da852dfe7746 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx @@ -281,21 +281,20 @@ Trk::GaussianSumFitter::fit( Trk::IMultiStateExtrapolator::Cache extrapolatorCache; // Perform GSF forwards fit - std::unique_ptr<ForwardTrajectory> forwardTrajectory = - fitPRD(ctx, - extrapolatorCache, - sortedPrepRawDataSet, - estimatedParametersNearOrigin, - particleHypothesis); - - if (!forwardTrajectory || forwardTrajectory->empty()) { + ForwardTrajectory forwardTrajectory = fitPRD(ctx, + extrapolatorCache, + sortedPrepRawDataSet, + estimatedParametersNearOrigin, + particleHypothesis); + + if (forwardTrajectory.empty()) { ++m_ForwardFailure; return nullptr; } // Perform GSF smoother operation std::unique_ptr<SmoothedTrajectory> smoothedTrajectory = - fit(ctx, extrapolatorCache, *forwardTrajectory, particleHypothesis); + fit(ctx, extrapolatorCache, forwardTrajectory, particleHypothesis); // Protect against failed smoother fit if (!smoothedTrajectory) { @@ -415,19 +414,14 @@ Trk::GaussianSumFitter::fit( Trk::IMultiStateExtrapolator::Cache extrapolatorCache; // Perform GSF forwards fit - new memory allocated in forwards fitter - std::unique_ptr<ForwardTrajectory> forwardTrajectory = + ForwardTrajectory forwardTrajectory = fitMeasurements(ctx, extrapolatorCache, sortedMeasurementSet, estimatedParametersNearOrigin, particleHypothesis); - if (!forwardTrajectory) { - ++m_ForwardFailure; - return nullptr; - } - - if (forwardTrajectory->empty()) { + if (forwardTrajectory.empty()) { ++m_ForwardFailure; return nullptr; } @@ -435,7 +429,7 @@ Trk::GaussianSumFitter::fit( // Perform GSF smoother operation std::unique_ptr<SmoothedTrajectory> smoothedTrajectory = - fit(ctx, extrapolatorCache, *forwardTrajectory, particleHypothesis, ccot); + fit(ctx, extrapolatorCache, forwardTrajectory, particleHypothesis, ccot); // Protect against failed smoother fit if (!smoothedTrajectory) { @@ -757,7 +751,7 @@ Trk::GaussianSumFitter::buildFitQuality( /* * Forwards fit on a set of PrepRawData */ -std::unique_ptr<Trk::ForwardTrajectory> +Trk::ForwardTrajectory Trk::GaussianSumFitter::fitPRD( const EventContext& ctx, Trk::IMultiStateExtrapolator::Cache& extrapolatorCache, @@ -790,7 +784,7 @@ Trk::GaussianSumFitter::fitPRD( } // Create new trajectory - auto forwardTrajectory = std::make_unique<Trk::ForwardTrajectory>(); + Trk::ForwardTrajectory forwardTrajectory{}; // Prepare the multi-component state. For starting guess this has single // component, weight 1 @@ -820,7 +814,7 @@ Trk::GaussianSumFitter::fitPRD( bool stepIsValid = stepForwardFit( ctx, extrapolatorCache, - forwardTrajectory.get(), + forwardTrajectory, *prepRawData, nullptr, (*prepRawData)->detectorElement()->surface((*prepRawData)->identify()), @@ -828,7 +822,7 @@ Trk::GaussianSumFitter::fitPRD( configuredParticleHypothesis); if (!stepIsValid) { - return nullptr; + return Trk::ForwardTrajectory{}; } } return forwardTrajectory; @@ -837,7 +831,7 @@ Trk::GaussianSumFitter::fitPRD( /* * Forwards fit on a set of Measurements */ -std::unique_ptr<Trk::ForwardTrajectory> +Trk::ForwardTrajectory Trk::GaussianSumFitter::fitMeasurements( const EventContext& ctx, Trk::IMultiStateExtrapolator::Cache& extrapolatorCache, @@ -846,14 +840,9 @@ Trk::GaussianSumFitter::fitMeasurements( const Trk::ParticleHypothesis particleHypothesis) const { - if (!m_extrapolator) { - ATH_MSG_ERROR("The extrapolator is not configured... Exiting!"); - return nullptr; - } - if (inputMeasurementSet.empty()) { ATH_MSG_ERROR("Input MeasurementSet is empty... Exiting!"); - return nullptr; + return Trk::ForwardTrajectory{}; } // Configure for forwards filtering material effects overide @@ -865,9 +854,7 @@ Trk::GaussianSumFitter::fitMeasurements( configuredParticleHypothesis = particleHypothesis; } - // This memory should be freed by the fitter / smoother master method - auto forwardTrajectory = std::make_unique<Trk::ForwardTrajectory>(); - + Trk::ForwardTrajectory forwardTrajectory{}; // Prepare the multi-component state. For starting guess this has single // component, weight 1 const AmgVector(5)& par = estimatedTrackParametersNearOrigin.parameters(); @@ -895,7 +882,7 @@ Trk::GaussianSumFitter::fitMeasurements( bool stepIsValid = stepForwardFit(ctx, extrapolatorCache, - forwardTrajectory.get(), + forwardTrajectory, nullptr, *measurement, (*measurement)->associatedSurface(), @@ -903,7 +890,7 @@ Trk::GaussianSumFitter::fitMeasurements( configuredParticleHypothesis); if (!stepIsValid) { - return nullptr; + return Trk::ForwardTrajectory{}; } } return forwardTrajectory; @@ -916,7 +903,7 @@ bool Trk::GaussianSumFitter::stepForwardFit( const EventContext& ctx, Trk::IMultiStateExtrapolator::Cache& extrapolatorCache, - ForwardTrajectory* forwardTrajectory, + ForwardTrajectory& forwardTrajectory, const Trk::PrepRawData* originalPrepRawData, const Trk::MeasurementBase* originalMeasurement, const Trk::Surface& surface, @@ -936,11 +923,6 @@ Trk::GaussianSumFitter::stepForwardFit( return false; } - // Protect against ForwardTrajectory not defined - if (!forwardTrajectory) { - ATH_MSG_WARNING("ForwardTrajectory object is not defined... Exiting!"); - return false; - } // Extrapolate multi-component state to the next measurement surface Trk::MultiComponentState extrapolatedState = m_extrapolator->extrapolate(ctx, @@ -1004,7 +986,7 @@ Trk::GaussianSumFitter::stepForwardFit( nullptr, type); - forwardTrajectory->push_back(multiComponentStateOnSurface); + forwardTrajectory.push_back(multiComponentStateOnSurface); // Clean up objects associated with removed measurement updatedState = std::move(extrapolatedState); } else { @@ -1013,7 +995,7 @@ Trk::GaussianSumFitter::stepForwardFit( measurement.release(), MultiComponentStateHelpers::clone(extrapolatedState).release(), fitQuality.release()); - forwardTrajectory->push_back(multiComponentStateOnSurface); + forwardTrajectory.push_back(multiComponentStateOnSurface); } return true; } diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx index d7bc79f5af500ef36fdba7eebb532250065cca06..1b8dc6a944c0c7b91411faa99f83e8eefebc3057 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GsfExtrapolator.cxx @@ -2,14 +2,12 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -/********************************************************************************* - GsfExtrapolator.cxx - description - ----------------------------------- -begin : Tuesday 25th January 2005 -author : amorley,anastopoulos -email : amorley@cern.ch -decription : Implementation code for GsfExtrapolator class -*********************************************************************************/ +/** + * @file GsfExtrapolator.cxx + * @date Tuesday 25th January 2005 + * @author Anthony Morley, Christos Anastopoulos + * @brief Implementation code for GsfExtrapolator class + */ #include "TrkGaussianSumFilter/GsfExtrapolator.h"