From 0938409f40c6e4762dd06ed075f37dd1950694b1 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 24 Apr 2024 15:08:42 +0200 Subject: [PATCH] further operations --- .../plugins/DisplacedRegionSeedingVertexProducer.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/RecoTracker/DisplacedRegionalTracking/plugins/DisplacedRegionSeedingVertexProducer.cc b/RecoTracker/DisplacedRegionalTracking/plugins/DisplacedRegionSeedingVertexProducer.cc index 4658f72e86875..d45d904b9ea67 100644 --- a/RecoTracker/DisplacedRegionalTracking/plugins/DisplacedRegionSeedingVertexProducer.cc +++ b/RecoTracker/DisplacedRegionalTracking/plugins/DisplacedRegionSeedingVertexProducer.cc @@ -160,8 +160,7 @@ void DisplacedRegionSeedingVertexProducer::produce(edm::StreamID streamID, } const auto pseudoROIPred = [](const DisplacedVertexCluster &a) { return !a.valid(); }; - auto remove_it = std::remove_if(pseudoROIs.begin(), pseudoROIs.end(), pseudoROIPred); - pseudoROIs.erase(remove_it, pseudoROIs.end()); + auto remove_invalid = std::remove_if(pseudoROIs.begin(), pseudoROIs.end(), pseudoROIPred); // Remove invalid ROIs. const auto roiPred = [&](const DisplacedVertexCluster &roi) { @@ -175,8 +174,7 @@ void DisplacedRegionSeedingVertexProducer::produce(edm::StreamID streamID, return true; return false; }; - auto remove_it2 = std::remove_if(pseudoROIs.begin(), pseudoROIs.end(), roiPred); - pseudoROIs.erase(remove_it2, pseudoROIs.end()); + auto remove_pred = std::remove_if(pseudoROIs.begin(), remove_invalid, roiPred); auto nearRegionsOfInterest = make_unique >(); auto farRegionsOfInterest = make_unique >(); @@ -184,7 +182,8 @@ void DisplacedRegionSeedingVertexProducer::produce(edm::StreamID streamID, constexpr std::array errorA{{1.0, 0.0, 1.0, 0.0, 0.0, 1.0}}; static const reco::Vertex::Error errorRegion(errorA.begin(), errorA.end(), true, true); - for (const auto &roi : pseudoROIs) { + for (auto it = pseudoROIs.begin(); it != remove_pred; ++it) { + auto const &roi = *it; const auto &x(roi.centerOfMass()); if ((x - bs).rho() < nearThreshold_) nearRegionsOfInterest->emplace_back(reco::Vertex::Point(roi.centerOfMass()), errorRegion);