From 763d1968cbb87203fc935fd67a5e384ab4dde863 Mon Sep 17 00:00:00 2001 From: Felice Date: Thu, 16 Jul 2020 16:32:16 +0200 Subject: [PATCH 1/3] 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_; From 59d5d8f4e32e48a45dfa6397adcd8fe5b2dc167f Mon Sep 17 00:00:00 2001 From: Felice Date: Fri, 17 Jul 2020 14:59:55 +0200 Subject: [PATCH 2/3] Clearing density map --- RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h index 861447e874b0c..bfca51b3c0384 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h @@ -72,6 +72,7 @@ class HGCalCLUEAlgoT : public HGCalClusteringAlgoBase { cells.clear(); cells.shrink_to_fit(); } + density_.clear(); } Density getDensity() override; From 0845af314dd0fab48af3247c3a426031b63d515a Mon Sep 17 00:00:00 2001 From: Felice Date: Fri, 17 Jul 2020 15:00:51 +0200 Subject: [PATCH 3/3] Reset at the end of produce --- .../HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc index bc5c7d90692b2..fba15664ae202 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalLayerClusterProducer.cc @@ -133,8 +133,6 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, const edm::EventSetup& clusters_sharing(new std::vector); auto density = std::make_unique(); - algo->reset(); - algo->getEventSetup(es); //make a map detid-rechit @@ -246,6 +244,7 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, const edm::EventSetup& clusterPtrsSharing.push_back(ptr); } } + algo->reset(); } #endif