diff --git a/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/TrkMultiComponentStateOnSurface/MultiComponentState.h b/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/TrkMultiComponentStateOnSurface/MultiComponentState.h index b40e8a4f6a7433b117e240258ff98bbbb9c5ff82..62ca563445dec9ab017e9f83877150c6513f04da 100755 --- a/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/TrkMultiComponentStateOnSurface/MultiComponentState.h +++ b/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/TrkMultiComponentStateOnSurface/MultiComponentState.h @@ -31,15 +31,21 @@ namespace Trk { typedef std::vector<ComponentParameters> MultiComponentState; namespace MultiComponentStateHelpers { -/** Clone method */ + +/** create a unique_ptr from input, moves (does not clone) the TrackParameters + */ +std::unique_ptr<MultiComponentState> +toPtr(MultiComponentState&& in); + +/** Clone TrackParameters method */ std::unique_ptr<MultiComponentState> clone(const MultiComponentState& in); -/** Clone with covariance matricies scaled by a factor */ +/** Clone TrackParameters with covariance matricies scaled by a factor */ std::unique_ptr<MultiComponentState> cloneWithScaledError(const MultiComponentState& in, double); -/** Clone with covariance matrix componants scaled by individual factors +/** Clone TrackParameters with covariance matrix components scaled by individual factors This will only work if there are 5 track parameters in each componant */ std::unique_ptr<MultiComponentState> diff --git a/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/src/MultiComponentState.cxx b/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/src/MultiComponentState.cxx index 33b9857d755dc69fd5dbd3b9bbc47e57c13c8860..a4124cd61ace05d5abf24d8599db376ee89de502 100755 --- a/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/src/MultiComponentState.cxx +++ b/Tracking/TrkEvent/TrkMultiComponentStateOnSurface/src/MultiComponentState.cxx @@ -16,6 +16,13 @@ decription : Implementation code for MultiComponentState class #include "TrkParameters/TrackParameters.h" #include "TrkSurfaces/Surface.h" +/** ctor a unique_ptr from input */ +std::unique_ptr<Trk::MultiComponentState> +Trk::MultiComponentStateHelpers::toPtr(MultiComponentState&& in) +{ + return std::make_unique<Trk::MultiComponentState>(std::move(in)); +} + std::unique_ptr<Trk::MultiComponentState> Trk::MultiComponentStateHelpers::clone(const Trk::MultiComponentState& in) { @@ -35,7 +42,7 @@ Trk::MultiComponentStateHelpers::cloneWithScaledError(const Trk::MultiComponentS double errorScaleTheta, double errorScaleQoverP) { - + AmgSymMatrix(5) coefficients; coefficients(0, 0) = (errorScaleLocX * errorScaleLocX); coefficients(1, 1) = (errorScaleLocY * errorScaleLocY); @@ -56,7 +63,7 @@ Trk::MultiComponentStateHelpers::cloneWithScaledError(const Trk::MultiComponentS auto stateWithScaledErrors = std::make_unique<Trk::MultiComponentState>(); stateWithScaledErrors->reserve(in.size()); - + for (const ComponentParameters& component : in) { const Trk::TrackParameters* trackParameters = component.first.get(); const AmgSymMatrix(5)* originalMatrix = trackParameters->covariance(); diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx index 0fb0012e946b42ee4363e00f1052da852dfe7746..0935a410def1b6259648ce879a9bdf9bb136e833 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx @@ -712,7 +712,7 @@ Trk::GaussianSumFitter::makePerigee( new MultiComponentStateOnSurface( nullptr, combinedPerigee.release(), - MultiComponentStateHelpers::clone(stateExtrapolatedToPerigee).release(), + Trk::MultiComponentStateHelpers::toPtr(std::move(stateExtrapolatedToPerigee)).release(), nullptr, nullptr, pattern, @@ -981,7 +981,7 @@ Trk::GaussianSumFitter::stepForwardFit( const Trk::MultiComponentStateOnSurface* multiComponentStateOnSurface = new MultiComponentStateOnSurface( measurement.release(), - MultiComponentStateHelpers::clone(extrapolatedState).release(), + Trk::MultiComponentStateHelpers::toPtr(std::move(extrapolatedState)).release(), fitQuality.release(), nullptr, type); @@ -993,7 +993,7 @@ Trk::GaussianSumFitter::stepForwardFit( const Trk::MultiComponentStateOnSurface* multiComponentStateOnSurface = new MultiComponentStateOnSurface( measurement.release(), - MultiComponentStateHelpers::clone(extrapolatedState).release(), + Trk::MultiComponentStateHelpers::toPtr(std::move(extrapolatedState)).release(), fitQuality.release()); forwardTrajectory.push_back(multiComponentStateOnSurface); } @@ -1206,7 +1206,7 @@ Trk::GaussianSumFitter::fit( continue; } - // Update newly extrapolated state with MeasurementBase measurement + updatedState = m_updator.update(std::move(extrapolatedState), *measurement, fitQuality); if (updatedState.empty()) { @@ -1246,6 +1246,7 @@ Trk::GaussianSumFitter::fit( } Trk::MultiComponentState combinedState2 = combine(*forwardsMultiState, updatedState); + if (combinedState2.empty()) { ATH_MSG_WARNING("Could not combine state from forward fit with " "smoother state... rejecting track!"); @@ -1258,7 +1259,7 @@ Trk::GaussianSumFitter::fit( const Trk::MultiComponentStateOnSurface* combinedStateOnSurface = new MultiComponentStateOnSurface( measurement.release(), - MultiComponentStateHelpers::clone(combinedState2).release(), + Trk::MultiComponentStateHelpers::toPtr(std::move(combinedState2)).release(), combinedFitQuality.release()); smoothedTrajectory->push_back(combinedStateOnSurface); } else {