Skip to content

Commit

Permalink
Merge pull request #30753 from felicepantaleo/hgcal_memory_shrinking_…
Browse files Browse the repository at this point in the history
…layerclustering

[HGCal] Shrinking Layer Clustering internal data structures
  • Loading branch information
cmsbuild authored Jul 17, 2020
2 parents 6cfc123 + 0845af3 commit f9f205e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions RecoLocalCalo/HGCalRecProducers/interface/HGCalImagingAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<KDNode>().swap(it);
}
for (unsigned int i = 0; i < minpos_.size(); i++) {
Expand Down
23 changes: 22 additions & 1 deletion RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ 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_.clear();
}

Density getDensity() override;
Expand Down Expand Up @@ -175,6 +179,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<CellsOnLayer> cells_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, const edm::EventSetup&
clusters_sharing(new std::vector<reco::BasicCluster>);
auto density = std::make_unique<Density>();

algo->reset();

algo->getEventSetup(es);

//make a map detid-rechit
Expand Down Expand Up @@ -246,6 +244,7 @@ void HGCalLayerClusterProducer::produce(edm::Event& evt, const edm::EventSetup&
clusterPtrsSharing.push_back(ptr);
}
}
algo->reset();
}

#endif

0 comments on commit f9f205e

Please sign in to comment.