Skip to content
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
2 changes: 1 addition & 1 deletion RecoEgamma/EgammaTools/python/slimmedEgammaHGC_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from RecoEgamma.EgammaTools.hgcalElectronIDValueMap_cff import hgcalElectronIDValueMap
from PhysicsTools.PatAlgos.PATElectronProducer_cfi import PATElectronProducer
from PhysicsTools.PatAlgos.slimming.slimmedElectrons_cfi import slimmedElectrons
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cff import recHitMapProducer

hgcElectronID = hgcalElectronIDValueMap.clone(
electrons = "cleanedEcalDrivenGsfElectronsHGC",
Expand Down
2 changes: 1 addition & 1 deletion RecoHGCal/TICL/python/customiseForTICLv5_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from RecoLocalCalo.HGCalRecProducers.hgcalLayerClusters_cff import hgcalLayerClustersEE, hgcalLayerClustersHSi, hgcalLayerClustersHSci
from RecoLocalCalo.HGCalRecProducers.hgcalMergeLayerClusters_cfi import hgcalMergeLayerClusters
from RecoTracker.IterativeTracking.iterativeTk_cff import trackdnn_source
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cff import recHitMapProducer
from RecoHGCal.TICL.ticlLayerTileProducer_cfi import ticlLayerTileProducer

from RecoHGCal.TICL.pfTICLProducer_cfi import pfTICLProducer as _pfTICLProducer
Expand Down
2 changes: 1 addition & 1 deletion RecoHGCal/TICL/python/customiseTICLFromReco.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from RecoHGCal.TICL.ticlDumper_cff import ticlDumper
# Validation
from Validation.HGCalValidation.HGCalValidator_cff import *
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cff import recHitMapProducer

# Load DNN ESSource
from RecoTracker.IterativeTracking.iterativeTk_cff import trackdnn_source
Expand Down
2 changes: 1 addition & 1 deletion RecoLocalCalo/Configuration/python/hgcalLocalReco_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHit_cfi import *
from RecoLocalCalo.HGCalRecProducers.HGCalRecHit_cfi import *

from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cff import recHitMapProducer

# patch particle flow clusters for HGC into local reco sequence
# (for now until global reco is going with some sort of clustering)
Expand Down
64 changes: 35 additions & 29 deletions RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,37 @@ class RecHitMapProducer : public edm::global::EDProducer<> {
void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;

private:
const edm::EDGetTokenT<HGCRecHitCollection> hits_ee_token_;
const edm::EDGetTokenT<HGCRecHitCollection> hits_fh_token_;
const edm::EDGetTokenT<HGCRecHitCollection> hits_bh_token_;
const edm::EDGetTokenT<reco::PFRecHitCollection> hits_eb_token_;
const edm::EDGetTokenT<reco::PFRecHitCollection> hits_hb_token_;
const edm::EDGetTokenT<reco::PFRecHitCollection> hits_ho_token_;
std::vector<edm::EDGetTokenT<HGCRecHitCollection>> hgcal_hits_token_;
std::vector<edm::EDGetTokenT<reco::PFRecHitCollection>> barrel_hits_token_;

bool hgcalOnly_;
};

DEFINE_FWK_MODULE(RecHitMapProducer);

using DetIdRecHitMap = std::unordered_map<DetId, const unsigned int>;

RecHitMapProducer::RecHitMapProducer(const edm::ParameterSet& ps)
: hits_ee_token_(consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("EEInput"))),
hits_fh_token_(consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("FHInput"))),
hits_bh_token_(consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("BHInput"))),
hits_eb_token_(consumes<reco::PFRecHitCollection>(ps.getParameter<edm::InputTag>("EBInput"))),
hits_hb_token_(consumes<reco::PFRecHitCollection>(ps.getParameter<edm::InputTag>("HBInput"))) {
RecHitMapProducer::RecHitMapProducer(const edm::ParameterSet& ps) : hgcalOnly_(ps.getParameter<bool>("hgcalOnly")) {
std::vector<edm::InputTag> tags = ps.getParameter<std::vector<edm::InputTag>>("hits");
for (auto& tag : tags) {
if (tag.label().find("HGCalRecHit") != std::string::npos) {
hgcal_hits_token_.push_back(consumes<HGCRecHitCollection>(tag));
} else {
barrel_hits_token_.push_back(consumes<reco::PFRecHitCollection>(tag));
}
}

produces<DetIdRecHitMap>("hgcalRecHitMap");
produces<DetIdRecHitMap>("barrelRecHitMap");
if (!hgcalOnly_)
produces<DetIdRecHitMap>("barrelRecHitMap");
}

void RecHitMapProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("EEInput", {"HGCalRecHit", "HGCEERecHits"});
desc.add<edm::InputTag>("FHInput", {"HGCalRecHit", "HGCHEFRecHits"});
desc.add<edm::InputTag>("BHInput", {"HGCalRecHit", "HGCHEBRecHits"});
desc.add<edm::InputTag>("EBInput", {"particleFlowRecHitECAL", ""});
desc.add<edm::InputTag>("HBInput", {"particleFlowRecHitHBHE", ""});
desc.add<std::vector<edm::InputTag>>("hits",
{edm::InputTag("HGCalRecHit", "HGCEERecHits"),
edm::InputTag("HGCalRecHit", "HGCHEFRecHits"),
edm::InputTag("HGCalRecHit", "HGCHEBRecHits")});
desc.add<bool>("hgcalOnly", true);
descriptions.add("recHitMapProducer", desc);
}
Expand All @@ -60,9 +62,9 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event
auto hitMapHGCal = std::make_unique<DetIdRecHitMap>();

// Retrieve collections
const auto& ee_hits = evt.getHandle(hits_ee_token_);
const auto& fh_hits = evt.getHandle(hits_fh_token_);
const auto& bh_hits = evt.getHandle(hits_bh_token_);
const auto& ee_hits = evt.getHandle(hgcal_hits_token_[0]);
const auto& fh_hits = evt.getHandle(hgcal_hits_token_[1]);
const auto& bh_hits = evt.getHandle(hgcal_hits_token_[2]);

// Check validity of all handles
if (!ee_hits.isValid() || !fh_hits.isValid() || !bh_hits.isValid()) {
Expand All @@ -71,6 +73,8 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event
return;
}

// TODO may be worth to avoid dependency on the order
// of the collections, maybe using a map
MultiVectorManager<HGCRecHit> rechitManager;
rechitManager.addVector(*ee_hits);
rechitManager.addVector(*fh_hits);
Expand All @@ -83,13 +87,15 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event

evt.put(std::move(hitMapHGCal), "hgcalRecHitMap");

auto hitMapBarrel = std::make_unique<DetIdRecHitMap>();
MultiVectorManager<reco::PFRecHit> barrelRechitManager;
barrelRechitManager.addVector(evt.get(hits_eb_token_));
barrelRechitManager.addVector(evt.get(hits_hb_token_));
for (unsigned int i = 0; i < barrelRechitManager.size(); ++i) {
const auto recHitDetId = barrelRechitManager[i].detId();
hitMapBarrel->emplace(recHitDetId, i);
if (!hgcalOnly_) {
auto hitMapBarrel = std::make_unique<DetIdRecHitMap>();
MultiVectorManager<reco::PFRecHit> barrelRechitManager;
barrelRechitManager.addVector(evt.get(barrel_hits_token_[0]));
barrelRechitManager.addVector(evt.get(barrel_hits_token_[1]));
for (unsigned int i = 0; i < barrelRechitManager.size(); ++i) {
const auto recHitDetId = barrelRechitManager[i].detId();
hitMapBarrel->emplace(recHitDetId, i);
}
evt.put(std::move(hitMapBarrel), "barrelRecHitMap");
}
evt.put(std::move(hitMapBarrel), "barrelRecHitMap");
}
14 changes: 14 additions & 0 deletions RecoLocalCalo/HGCalRecProducers/python/recHitMapProducer_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import FWCore.ParameterSet.Config as cms

from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer as recHitMapProducer_

recHitMapProducer = recHitMapProducer_.clone()

hits = ["HGCalRecHit:HGCEERecHits",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a silly comment here, this is somewhat fragile, because the moment the order in the list of entries in the vector gets changed, it will go out of synch with the rest of the validation code (see effects of the other approach 0c8751e in #48517 (comment)).
Perhaps it's worth creating an issue or putting a comment in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment in the RecHitMapProducer.cc. I can also open an issue, if you think it is better that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can also open an issue, if you think it is better that way.

I think it would help to keep it on the radar, thanks.

"HGCalRecHit:HGCHEFRecHits",
"HGCalRecHit:HGCHEBRecHits",
"particleFlowRecHitECAL",
"particleFlowRecHitHBHE"]

from Configuration.ProcessModifiers.ticl_barrel_cff import ticl_barrel
ticl_barrel.toModify(recHitMapProducer, hits = hits, hgcalOnly = False)
12 changes: 5 additions & 7 deletions Validation/Configuration/python/hltHGCalSimValid_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@

from Validation.HGCalValidation.HLT_TICLIterLabels_cff import hltTiclIterLabels as _hltTiclIterLabels

from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cfi import recHitMapProducer as _recHitMapProducer
from RecoLocalCalo.HGCalRecProducers.recHitMapProducer_cff import recHitMapProducer as _recHitMapProducer

hits = ["hltHGCalRecHit:HGCEERecHits", "hltHGCalRecHit:HGCHEFRecHits", "hltHGCalRecHit:HGCHEBRecHits"]
hltRecHitMapProducer = _recHitMapProducer.clone(
BHInput = cms.InputTag("hltHGCalRecHit","HGCHEBRecHits"),
EBInput = cms.InputTag("hltParticleFlowRecHitECALUnseeded"),
EEInput = cms.InputTag("hltHGCalRecHit","HGCEERecHits"),
FHInput = cms.InputTag("hltHGCalRecHit","HGCHEFRecHits"),
HBInput = cms.InputTag("hltParticleFlowRecHitHBHE"),
hgcalOnly = cms.bool(True),
hits = hits,
hgcalOnly = True,
)

hltLcAssocByEnergyScoreProducer = _lcAssocByEnergyScoreProducer.clone(
Expand Down