From a287b79d886398f04f8129bfa9729db66d0fbafc Mon Sep 17 00:00:00 2001 From: Felice Date: Thu, 16 Jul 2020 18:12:57 +0200 Subject: [PATCH] Shrinking internal data structures after clearing them. --- .../interface/HGCalImagingAlgo.h | 3 +++ .../HGCalRecProducers/plugins/HGCalCLUEAlgo.h | 22 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h index 6d7e2dd900265..ba072a85de7fd 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h @@ -65,9 +65,12 @@ class HGCalImagingAlgo : public HGCalClusteringAlgoBase { // use this if you want to reuse the same cluster object but don't want to accumulate clusters (hardly useful?) void reset() override { clusters_v_.clear(); + clusters_v_.shrink_to_fit(); layerClustersPerLayer_.clear(); + layerClustersPerLayer_.shrink_to_fit(); for (auto &it : points_) { it.clear(); + it.shrink_to_fit(); std::vector().swap(it); } for (unsigned int i = 0; i < minpos_.size(); i++) { diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h index caf5faee1e374..861447e874b0c 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h @@ -63,12 +63,15 @@ class HGCalCLUEAlgoT : public HGCalClusteringAlgoBase { void reset() override { clusters_v_.clear(); + clusters_v_.shrink_to_fit(); for (auto& cl : numberOfClustersPerLayer_) { cl = 0; } - for (auto& cells : cells_) + for (auto& cells : cells_) { cells.clear(); + cells.shrink_to_fit(); + } } Density getDensity() override; @@ -174,6 +177,23 @@ class HGCalCLUEAlgoT : public HGCalClusteringAlgoBase { followers.clear(); isSeed.clear(); } + + void shrink_to_fit() { + detid.shrink_to_fit(); + isSi.shrink_to_fit(); + x.shrink_to_fit(); + y.shrink_to_fit(); + eta.shrink_to_fit(); + phi.shrink_to_fit(); + weight.shrink_to_fit(); + rho.shrink_to_fit(); + delta.shrink_to_fit(); + nearestHigher.shrink_to_fit(); + clusterIndex.shrink_to_fit(); + sigmaNoise.shrink_to_fit(); + followers.shrink_to_fit(); + isSeed.shrink_to_fit(); + } }; std::vector cells_;