From d11da396814ed84635172750c8f3175b61438d73 Mon Sep 17 00:00:00 2001 From: Dominik Smith <smith@th.physik.uni-frankfurt.de> Date: Mon, 30 Oct 2023 15:03:53 +0100 Subject: [PATCH] Merged two std::vector::erase calls in cbm::tof::Clusterizer. Makes the algorithm a bit faster. --- algo/detectors/tof/Clusterizer.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/algo/detectors/tof/Clusterizer.cxx b/algo/detectors/tof/Clusterizer.cxx index b6b89733e5..640481411c 100644 --- a/algo/detectors/tof/Clusterizer.cxx +++ b/algo/detectors/tof/Clusterizer.cxx @@ -231,9 +231,10 @@ namespace cbm::algo::tof ROOT::Math::XYZVector pos(posX, posY, 0.); cluster.add(pos, time, totSum, totSum, i1->second, i2->second); - // remove selected digis from pool - storDigi.erase(i2); - storDigi.erase(i1); + // remove digis at positions i1 and i2 from pool in efficient way (replaces two vector::erase calls). + std::copy(i1 + 1, i2, i1); + std::copy(i2 + 1, storDigi.end(), i2 - 1); + storDigi.resize(storDigi.size() - 2); if (AddNextChan(input, chan, cluster, clustersOut)) { return true; // signal hit was already added -- GitLab