diff --git a/Tracking/TrkFitter/TrkGaussianSumFilterUtils/TrkGaussianSumFilterUtils/MultiComponentStateAssembler.h b/Tracking/TrkFitter/TrkGaussianSumFilterUtils/TrkGaussianSumFilterUtils/MultiComponentStateAssembler.h index c55f2901b48405ea1676df7c91a882ce197b7794..5249949c46abbf38c010a9e57ecd6b2a08ec4811 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilterUtils/TrkGaussianSumFilterUtils/MultiComponentStateAssembler.h +++ b/Tracking/TrkFitter/TrkGaussianSumFilterUtils/TrkGaussianSumFilterUtils/MultiComponentStateAssembler.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ /** @@ -39,7 +39,6 @@ struct Cache , invalidWeightSum{ 0 } , minimumValidFraction{ 0.01 } , minimumFractionalWeight{ 1e-09 } - , assemblyDone{ false } { multiComponentState.reserve(72); } @@ -48,19 +47,18 @@ struct Cache double invalidWeightSum; const double minimumValidFraction; const double minimumFractionalWeight; - bool assemblyDone; }; /** Method to add a single set of Trk::ComponentParameters to the cached * Trk::MultiComponentState object under construction */ -bool +void addComponent( MultiComponentStateAssembler::Cache& cache, ComponentParameters&& multiComponentState); /** Method to add a new Trk::MultiComponentState to the cached - * Trk::MultiComponentState o bject under construction */ -bool + * Trk::MultiComponentState object under construction */ +void addMultiState( MultiComponentStateAssembler::Cache& cache, Trk::MultiComponentState&& multiComponentState); @@ -75,4 +73,25 @@ assembledState(MultiComponentStateAssembler::Cache&& cache); } // End Trk namepace +// inline methods +inline void Trk::MultiComponentStateAssembler::addComponent( + Cache& cache, ComponentParameters&& componentParameters) { + + cache.validWeightSum += componentParameters.second; + cache.multiComponentState.emplace_back(std::move(componentParameters.first), + componentParameters.second); +} + +inline void Trk::MultiComponentStateAssembler::addMultiState( + Cache& cache, Trk::MultiComponentState&& multiComponentState) { + + double sumW(0.); + for (auto& component : multiComponentState) { + sumW += component.second; + cache.multiComponentState.emplace_back(std::move(component.first), + component.second); + } + cache.validWeightSum += sumW; +} + #endif diff --git a/Tracking/TrkFitter/TrkGaussianSumFilterUtils/src/MultiComponentStateAssembler.cxx b/Tracking/TrkFitter/TrkGaussianSumFilterUtils/src/MultiComponentStateAssembler.cxx index 264eb8a160017723a91cb64a9f35238c6b47398a..8cb0f7796fd5c36c9b9a08d7b6b6664dfb15ca6e 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilterUtils/src/MultiComponentStateAssembler.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilterUtils/src/MultiComponentStateAssembler.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ /** @@ -86,10 +86,6 @@ prepareStateForAssembly(Cache& cache) validWeightFraction < cache.minimumValidFraction) { return false; } - // Check to see assembly has not already been done - if (cache.assemblyDone) { - return true; - } // Sort Multi-Component State by weights std::sort(cache.multiComponentState.begin(), cache.multiComponentState.end(), @@ -100,7 +96,6 @@ prepareStateForAssembly(Cache& cache) // ordered in descending order // return the 1st element where (element<value) - const double minimumWeight = std::max(cache.minimumFractionalWeight * totalWeight, std::numeric_limits<double>::min()); @@ -125,46 +120,11 @@ prepareStateForAssembly(Cache& cache) return false; } - // Set assembly flag - cache.assemblyDone = true; return true; } } // end anonymous namespace -bool -Trk::MultiComponentStateAssembler::addComponent( - Cache& cache, - ComponentParameters&& componentParameters) -{ - if (cache.assemblyDone) { - return false; - } - cache.validWeightSum += componentParameters.second; - cache.multiComponentState.emplace_back(std::move(componentParameters.first), - componentParameters.second); - return true; -} - -bool -Trk::MultiComponentStateAssembler::addMultiState( - Cache& cache, - Trk::MultiComponentState&& multiComponentState) -{ - if (cache.assemblyDone) { - return false; - } - double sumW(0.); - for (auto& component : multiComponentState) { - sumW += component.second; - cache.multiComponentState.emplace_back(std::move(component.first), - component.second); - } - multiComponentState.clear(); - cache.validWeightSum += sumW; - return true; -} - Trk::MultiComponentState Trk::MultiComponentStateAssembler::assembledState( MultiComponentStateAssembler::Cache&& cache)