Skip to content

Commit

Permalink
Optimize egamma recostruction using MultiVectorManager and RecHitMap
Browse files Browse the repository at this point in the history
  • Loading branch information
felicepantaleo committed Sep 3, 2024
1 parent b16adf4 commit acff6a7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void ElectronSeedProducer::fillDescriptions(edm::ConfigurationDescriptions& desc
psd4.add<edm::InputTag>("HGCEEInput", {"HGCalRecHit", "HGCEERecHits"});
psd4.add<edm::InputTag>("HGCFHInput", {"HGCalRecHit", "HGCHEFRecHits"});
psd4.add<edm::InputTag>("HGCBHInput", {"HGCalRecHit", "HGCHEBRecHits"});
psd4.add<edm::InputTag>("hgcalHitMap", {"recHitMapProducer", "hgcalRecHitMap"});
desc.add<edm::ParameterSetDescription>("HGCalConfig", psd4);

// r/z windows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
endcapSuperClusters = 'particleFlowSuperClusterHGCal',
allowHGCal = True,
)
phase2_hgcal.toModify(
ecalDrivenElectronSeeds.HGCalConfig,
hgcalHitMap = cms.InputTag("recHitMapProducer", "hgcalRecHitMap"),
)

from Configuration.ProcessModifiers.egamma_lowPt_exclusive_cff import egamma_lowPt_exclusive
egamma_lowPt_exclusive.toModify(ecalDrivenElectronSeeds,
Expand Down
5 changes: 5 additions & 0 deletions RecoLocalCalo/HGCalRecAlgos/interface/ClusterTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
#include "DataFormats/CaloRecHit/interface/CaloCluster.h"
#include "DataFormats/ParticleFlowReco/interface/HGCalMultiCluster.h"
#include "CommonTools/RecoAlgos/interface/MultiVectorManager.h"

#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"

Expand Down Expand Up @@ -60,9 +62,12 @@ namespace hgcal {

RecHitTools rhtools_;
const edm::EDGetTokenT<HGCRecHitCollection> eetok, fhtok, bhtok;
const edm::EDGetTokenT<std::unordered_map<DetId, const unsigned int>> hitMapToken_;
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;

const HGCRecHitCollection *eerh_, *fhrh_, *bhrh_;
const std::unordered_map<DetId, const unsigned int> *hitMap_;
MultiVectorManager<HGCRecHit> rechitManager_;
};
} // namespace hgcal

Expand Down
66 changes: 19 additions & 47 deletions RecoLocalCalo/HGCalRecAlgos/src/ClusterTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ ClusterTools::ClusterTools(const edm::ParameterSet& conf, edm::ConsumesCollector
: eetok(sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCEEInput"))),
fhtok(sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCFHInput"))),
bhtok(sumes.consumes<HGCRecHitCollection>(conf.getParameter<edm::InputTag>("HGCBHInput"))),
hitMapToken_(sumes.consumes<std::unordered_map<DetId, const unsigned int>>(
conf.getParameter<edm::InputTag>("hgcalHitMap"))),
caloGeometryToken_{sumes.esConsumes()} {}

void ClusterTools::getEvent(const edm::Event& ev) {
eerh_ = &ev.get(eetok);
fhrh_ = &ev.get(fhtok);
bhrh_ = &ev.get(bhtok);
hitMap_ = &ev.get(hitMapToken_);
rechitManager_.addVector(*eerh_);
rechitManager_.addVector(*fhrh_);
rechitManager_.addVector(*bhrh_);
}

void ClusterTools::getEventSetup(const edm::EventSetup& es) { rhtools_.setGeometry(es.getData(caloGeometryToken_)); }
Expand All @@ -38,57 +44,23 @@ float ClusterTools::getClusterHadronFraction(const reco::CaloCluster& clus) cons
for (const auto& hit : hits) {
const auto& id = hit.first;
const float fraction = hit.second;

if (id.det() == DetId::HGCalEE) {
auto it = std::find(eerh_->begin(), eerh_->end(), id);
if (it != eerh_->end())
energy += it->energy() * fraction;
} else if (id.det() == DetId::HGCalHSi) {
auto it = std::find(fhrh_->begin(), fhrh_->end(), id);
if (it != fhrh_->end()) {
energy += it->energy() * fraction;
energyHad += it->energy() * fraction;
}
} else if (id.det() == DetId::HGCalHSc) {
auto it = std::find(bhrh_->begin(), bhrh_->end(), id);
if (it != bhrh_->end()) {
energy += it->energy() * fraction;
energyHad += it->energy() * fraction;
}
} else if (id.det() == DetId::Forward) {
switch (id.subdetId()) {
case HGCEE: {
auto it = std::find(eerh_->begin(), eerh_->end(), id);
if (it != eerh_->end())
energy += it->energy() * fraction;
break;
}
case HGCHEF: {
auto it = std::find(fhrh_->begin(), fhrh_->end(), id);
if (it != fhrh_->end()) {
energy += it->energy() * fraction;
energyHad += it->energy() * fraction;
}
break;
}
default:
throw cms::Exception("HGCalClusterTools") << " Cluster contains hits that are not from HGCal! " << std::endl;
}
} else if (id.det() == DetId::Hcal && id.subdetId() == HcalEndcap) {
auto it = std::find(bhrh_->begin(), bhrh_->end(), id);
if (it != bhrh_->end()) {
energy += it->energy() * fraction;
energyHad += it->energy() * fraction;
}
} else {
throw cms::Exception("HGCalClusterTools") << " Cluster contains hits that are not from HGCal! " << std::endl;
auto hitIter = hitMap_->find(id.rawId());
if (hitIter == hitMap_->end())
continue;
unsigned int rechitIndex = hitIter->second;
float hitEnergy = rechitManager_[rechitIndex].energy() * fraction;
energy += hitEnergy;
if (id.det() == DetId::HGCalHSi || id.det() == DetId::HGCalHSc ||
(id.det() == DetId::Forward && id.subdetId() == HGCHEF) ||
(id.det() == DetId::Hcal && id.subdetId() == HcalEndcap)) {
energyHad += hitEnergy;
}
}
float fraction = -1.f;
float hadronicFraction = -1.f;
if (energy > 0.f) {
fraction = energyHad / energy;
hadronicFraction = energyHad / energy;
}
return fraction;
return hadronicFraction;
}

math::XYZPoint ClusterTools::getMultiClusterPosition(const reco::HGCalMultiCluster& clu) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void HGCalMultiClusterProducer::fillDescriptions(edm::ConfigurationDescriptions&
5.0,
});
desc.add<edm::InputTag>("HGCBHInput", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
desc.add<edm::InputTag>("hgcalHitMap", {"recHitMapProducer", "hgcalRecHitMap"});
desc.add<edm::InputTag>("HGCLayerClustersSharing", edm::InputTag("hgcalMergeLayerClusters", "sharing"));
desc.add<unsigned int>("minClusters", 3);
descriptions.add("hgcalMultiClusters", desc);
Expand Down

0 comments on commit acff6a7

Please sign in to comment.