Skip to content

Commit

Permalink
Shrinking internal data structures after clearing them.
Browse files Browse the repository at this point in the history
  • Loading branch information
felicepantaleo committed Jul 16, 2020
1 parent 0393b55 commit a287b79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
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
22 changes: 21 additions & 1 deletion RecoLocalCalo/HGCalRecProducers/plugins/HGCalCLUEAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<CellsOnLayer> cells_;
Expand Down

0 comments on commit a287b79

Please sign in to comment.