Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HGCal] Shrinking Layer Clustering internal data structures - backport to 11_1_X #30757

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -174,6 +178,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