Skip to content

Commit

Permalink
Bugfix to keep the kBOX clustering + code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
valsdav committed Jun 14, 2022
1 parent 7e71237 commit 2aec0fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
13 changes: 7 additions & 6 deletions RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down
20 changes: 7 additions & 13 deletions RecoEcal/EgammaCoreTools/src/EcalClustersGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,40 +254,34 @@ DeepSCInputs::FeaturesMap EcalClustersGraph::computeWindowVariables(
std::pair<double, double> 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<const CaloCellGeometry> this_cell;
EcalRecHitCollection::const_iterator rHit;

const std::vector<std::pair<DetId, float>>& detId = cluster->hitsAndFractions();
// Loop over recHits associated with the given SuperCluster
for (std::vector<std::pair<DetId, float>>::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;
Expand Down

0 comments on commit 2aec0fb

Please sign in to comment.