From 2aec0fba2878f59f7e7c021538ab01c674f5769e Mon Sep 17 00:00:00 2001 From: Davide Valsecchi Date: Tue, 14 Jun 2022 17:03:08 +0200 Subject: [PATCH] Bugfix to keep the kBOX clustering + code improvements --- .../interface/PFECALSuperClusterAlgo.h | 4 ++-- .../src/PFECALSuperClusterAlgo.cc | 13 ++++++------ .../EgammaCoreTools/src/EcalClustersGraph.cc | 20 +++++++------------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgo.h b/RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgo.h index 46e9e4e9cb17e..b311b99333ad8 100644 --- a/RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgo.h +++ b/RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgo.h @@ -151,9 +151,9 @@ class PFECALSuperClusterAlgo { clustering_type _clustype; energy_weight _eweight; void buildAllSuperClusters(CalibratedClusterPtrVector&, double seedthresh); - void buildAllSuperClustersMustache(CalibratedClusterPtrVector&, double seedthresh); + void buildAllSuperClustersMustacheOrBox(CalibratedClusterPtrVector&, double seedthresh); void buildAllSuperClustersDeepSC(CalibratedClusterPtrVector&, double seedthresh); - void buildSuperClusterMustache(CalibratedClusterPtr&, CalibratedClusterPtrVector&); + void buildSuperClusterMustacheOrBox(CalibratedClusterPtr&, CalibratedClusterPtrVector&); void finalizeSuperCluster(CalibratedClusterPtr& seed, CalibratedClusterPtrVector& clustered, bool isEE); bool verbose_; diff --git a/RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc b/RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc index 6d10a40fbcc4a..15c7a82c9325f 100644 --- a/RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc +++ b/RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc @@ -269,13 +269,14 @@ void PFECALSuperClusterAlgo::run() { } void PFECALSuperClusterAlgo::buildAllSuperClusters(CalibratedClusterPtrVector& clusters, double seedthresh) { - if (_clustype == PFECALSuperClusterAlgo::kMustache) - buildAllSuperClustersMustache(clusters, seedthresh); + if (_clustype == PFECALSuperClusterAlgo::kMustache || _clustype == PFECALSuperClusterAlgo::kBOX) + buildAllSuperClustersMustacheOrBox(clusters, seedthresh); else if (_clustype == PFECALSuperClusterAlgo::kDeepSC) buildAllSuperClustersDeepSC(clusters, seedthresh); } -void PFECALSuperClusterAlgo::buildAllSuperClustersMustache(CalibratedClusterPtrVector& clusters, double seedthresh) { +void PFECALSuperClusterAlgo::buildAllSuperClustersMustacheOrBox(CalibratedClusterPtrVector& clusters, + double seedthresh) { auto seedable = std::bind(isSeed, _1, seedthresh, threshIsET_); // make sure only seeds appear at the front of the list of clusters @@ -286,7 +287,7 @@ void PFECALSuperClusterAlgo::buildAllSuperClustersMustache(CalibratedClusterPtrV // NB: since clusters is sorted in loadClusters any_of has O(1) // timing until you run out of seeds! while (std::any_of(clusters.cbegin(), clusters.cend(), seedable)) { - buildSuperClusterMustache(clusters.front(), clusters); + buildSuperClusterMustacheOrBox(clusters.front(), clusters); } } @@ -323,8 +324,8 @@ void PFECALSuperClusterAlgo::buildAllSuperClustersDeepSC(CalibratedClusterPtrVec } } -void PFECALSuperClusterAlgo::buildSuperClusterMustache(CalibratedClusterPtr& seed, - CalibratedClusterPtrVector& clusters) { +void PFECALSuperClusterAlgo::buildSuperClusterMustacheOrBox(CalibratedClusterPtr& seed, + CalibratedClusterPtrVector& clusters) { CalibratedClusterPtrVector clustered; double etawidthSuperCluster = 0.0; diff --git a/RecoEcal/EgammaCoreTools/src/EcalClustersGraph.cc b/RecoEcal/EgammaCoreTools/src/EcalClustersGraph.cc index 77a4f71baaded..a9fa485603dca 100644 --- a/RecoEcal/EgammaCoreTools/src/EcalClustersGraph.cc +++ b/RecoEcal/EgammaCoreTools/src/EcalClustersGraph.cc @@ -254,8 +254,7 @@ DeepSCInputs::FeaturesMap EcalClustersGraph::computeWindowVariables( std::pair EcalClustersGraph::computeCovariances(const CaloCluster* cluster) { double numeratorEtaWidth = 0; double numeratorPhiWidth = 0; - double clEnergy = cluster->energy(); - double denominator = clEnergy; + double denominator = cluster->energy(); double clEta = cluster->position().eta(); double clPhi = cluster->position().phi(); std::shared_ptr this_cell; @@ -263,31 +262,26 @@ std::pair EcalClustersGraph::computeCovariances(const CaloCluste const std::vector>& detId = cluster->hitsAndFractions(); // Loop over recHits associated with the given SuperCluster - for (std::vector>::const_iterator hit = detId.begin(); hit != detId.end(); ++hit) { + for (const auto& hit : detId) { if (PFLayer::fromCaloID(cluster->caloID()) == PFLayer::ECAL_BARREL) { - rHit = recHitsEB_->find((*hit).first); + rHit = recHitsEB_->find(hit.first); if (rHit == recHitsEB_->end()) { continue; } + this_cell = ebGeom_->getGeometry(rHit->id()); } else if (PFLayer::fromCaloID(cluster->caloID()) == PFLayer::ECAL_ENDCAP) { - rHit = recHitsEE_->find((*hit).first); + rHit = recHitsEE_->find(hit.first); if (rHit == recHitsEE_->end()) { continue; } - } - - if (PFLayer::fromCaloID(cluster->caloID()) == PFLayer::ECAL_BARREL) { - this_cell = ebGeom_->getGeometry(rHit->id()); - } else if (PFLayer::fromCaloID(cluster->caloID()) == PFLayer::ECAL_ENDCAP) { this_cell = eeGeom_->getGeometry(rHit->id()); - } - if (this_cell == nullptr) { + } else { continue; } GlobalPoint position = this_cell->getPosition(); //take into account energy fractions - double energyHit = rHit->energy() * hit->second; + double energyHit = rHit->energy() * hit.second; //form differences double dPhi = deltaPhi(position.phi(), clPhi); double dEta = position.eta() - clEta;