From 7e12b8176f885ce3b6d3697029a015679a749425 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Wed, 23 Jul 2025 17:28:31 +0200 Subject: [PATCH 01/22] Remove needless branching for HGCRecHits. --- .../LCToCPAssociatorByEnergyScoreProducer.cc | 51 ++++++------------- .../LCToCPAssociatorByEnergyScoreProducer.h | 1 - .../LCToSCAssociatorByEnergyScoreProducer.cc | 51 ++++++------------- .../LCToSCAssociatorByEnergyScoreProducer.h | 1 - 4 files changed, 30 insertions(+), 74 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index fd0f88f5839f6..81f82d64b5bf2 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -9,10 +9,7 @@ LCToCPAssociatorByEnergyScoreProducerT::LCToCPAssociatorByEnergySc hardScatterOnly_(ps.getParameter("hardScatterOnly")), hits_label_(ps.getParameter>("hits")) { for (auto &label : hits_label_) { - if constexpr (std::is_same_v) - hgcal_hits_token_.push_back(consumes(label)); - else - hits_token_.push_back(consumes>(label)); + hits_token_.push_back(consumes>(label)); } rhtools_ = std::make_shared(); @@ -32,38 +29,20 @@ void LCToCPAssociatorByEnergyScoreProducerT::produce(edm::StreamID rhtools_->setGeometry(*geom); std::vector hits; - if constexpr (std::is_same_v) { - for (auto &token : hgcal_hits_token_) { - edm::Handle hits_handle; - iEvent.getByToken(token, hits_handle); - - // Check handle validity - if (!hits_handle.isValid()) { - edm::LogWarning("LCToCPAssociatorByEnergyScoreProducerT") - << "HGCAL Hit collection not available for token. Skipping this collection."; - continue; // Skip invalid handle - } - - for (const auto &hit : *hits_handle) { - hits.push_back(&hit); - } - } - } else { - for (auto &token : hits_token_) { - edm::Handle> hits_handle; - iEvent.getByToken(token, hits_handle); - - // Check handle validity - if (!hits_handle.isValid()) { - edm::LogWarning("LCToCPAssociatorByEnergyScoreProducerT") - << "Barrel Hit collection not available for token. Skipping this collection."; - continue; // Skip invalid handle - } - - for (const auto &hit : *hits_handle) { - hits.push_back(&hit); - } - } + for (auto &token : hits_token_) { + edm::Handle> hits_handle; + iEvent.getByToken(token, hits_handle); + + // Check handle validity + if (!hits_handle.isValid()) { + edm::LogWarning("LCToCPAssociatorByEnergyScoreProducer") + << "Hit collection not available for token. Skipping this collection."; + continue; // Skip invalid handle + } + + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } if (hits.empty()) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h index 9fa906dfb60c5..32c933cd0f058 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.h @@ -35,7 +35,6 @@ class LCToCPAssociatorByEnergyScoreProducerT : public edm::global::EDProducer<> const bool hardScatterOnly_; std::shared_ptr rhtools_; std::vector hits_label_; - std::vector> hgcal_hits_token_; std::vector>> hits_token_; }; diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 932438079096d..ebcd9b6b0c3f1 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -9,10 +9,7 @@ LCToSCAssociatorByEnergyScoreProducerT::LCToSCAssociatorByEnergySc hardScatterOnly_(ps.getParameter("hardScatterOnly")), hits_label_(ps.getParameter>("hits")) { for (auto &label : hits_label_) { - if constexpr (std::is_same_v) - hgcal_hits_token_.push_back(consumes(label)); - else - hits_token_.push_back(consumes>(label)); + hits_token_.push_back(consumes>(label)); } rhtools_ = std::make_shared(); @@ -32,38 +29,20 @@ void LCToSCAssociatorByEnergyScoreProducerT::produce(edm::StreamID rhtools_->setGeometry(*geom); std::vector hits; - if constexpr (std::is_same_v) { - for (auto &token : hgcal_hits_token_) { - edm::Handle hits_handle; - iEvent.getByToken(token, hits_handle); - - // Check handle validity - if (!hits_handle.isValid()) { - edm::LogWarning("LCToSCAssociatorByEnergyScoreProducerT") - << "HGCAL Hit collection not available for token. Skipping this collection."; - continue; // Skip invalid handle - } - - for (const auto &hit : *hits_handle) { - hits.push_back(&hit); - } - } - } else { - for (auto &token : hits_token_) { - edm::Handle> hits_handle; - iEvent.getByToken(token, hits_handle); - - // Check handle validity - if (!hits_handle.isValid()) { - edm::LogWarning("LCToSCAssociatorByEnergyScoreProducerT") - << "Barrel Hit collection not available for token. Skipping this collection."; - continue; // Skip invalid handle - } - - for (const auto &hit : *hits_handle) { - hits.push_back(&hit); - } - } + for (auto &token : hits_token_) { + edm::Handle> hits_handle; + iEvent.getByToken(token, hits_handle); + + // Check handle validity + if (!hits_handle.isValid()) { + edm::LogWarning("LCToSCAssociatorByEnergyScoreProducer") + << "Hit collection not available for token. Skipping this collection."; + continue; // Skip invalid handle + } + + for (const auto &hit : *hits_handle) { + hits.push_back(&hit); + } } if (hits.empty()) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h index 229c0107b83a8..b25da3653a586 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.h @@ -35,7 +35,6 @@ class LCToSCAssociatorByEnergyScoreProducerT : public edm::global::EDProducer<> const bool hardScatterOnly_; std::shared_ptr rhtools_; std::vector hits_label_; - std::vector> hgcal_hits_token_; std::vector>> hits_token_; }; From 475a6a3e9dac73aa048a3bd57d264230ef82040f Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 24 Jul 2025 10:44:45 +0200 Subject: [PATCH 02/22] Improve debug message. --- .../LCToCPAssociatorByEnergyScoreProducer.cc | 10 ++++++---- .../plugins/LCToCPAssociatorEDProducer.cc | 13 +++++++++---- .../LCToSCAssociatorByEnergyScoreProducer.cc | 10 ++++++---- .../plugins/LCToSCAssociatorEDProducer.cc | 19 ++++++++++++------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index 81f82d64b5bf2..07f8cce569d05 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -29,14 +29,16 @@ void LCToCPAssociatorByEnergyScoreProducerT::produce(edm::StreamID rhtools_->setGeometry(*geom); std::vector hits; - for (auto &token : hits_token_) { - edm::Handle> hits_handle; - iEvent.getByToken(token, hits_handle); + edm::Handle> hits_handle; + + for (unsigned i=0; i { private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; + edm::InputTag label_lc; + edm::EDGetTokenT CPCollectionToken_; edm::EDGetTokenT LCCollectionToken_; edm::EDGetTokenT> associatorToken_; @@ -57,10 +59,11 @@ LCToCPAssociatorEDProducerT::LCToCPAssociatorEDProducerT(const edm::Par produces>(); produces>(); + label_lc = pset.getParameter("label_lc"); + CPCollectionToken_ = consumes(pset.getParameter("label_cp")); - LCCollectionToken_ = consumes(pset.getParameter("label_lc")); - associatorToken_ = - consumes>(pset.getParameter("associator")); + LCCollectionToken_ = consumes(label_lc); + associatorToken_ = consumes>(pset.getParameter("associator")); } // @@ -95,7 +98,9 @@ void LCToCPAssociatorEDProducerT::produce(edm::StreamID, // Protection against missing cluster collection if (!LCCollection.isValid()) { edm::LogWarning("LCToCPAssociatorEDProducerT") - << "Cluster collection is unavailable. Producing empty associations."; + << "CaloCluster collection with label " + << label_lc + << "is unavailable. Producing empty associations."; // Return empty collections auto emptyRecSimColl = std::make_unique>(); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index ebcd9b6b0c3f1..7dd00a490186a 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -29,14 +29,16 @@ void LCToSCAssociatorByEnergyScoreProducerT::produce(edm::StreamID rhtools_->setGeometry(*geom); std::vector hits; - for (auto &token : hits_token_) { - edm::Handle> hits_handle; - iEvent.getByToken(token, hits_handle); + edm::Handle> hits_handle; + + for (unsigned i=0; i { private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; + edm::InputTag label_lcl; + edm::EDGetTokenT SCCollectionToken_; edm::EDGetTokenT LCCollectionToken_; edm::EDGetTokenT> associatorToken_; @@ -46,10 +48,11 @@ LCToSCAssociatorEDProducerT::LCToSCAssociatorEDProducerT(const edm::Par produces>(); produces>(); + label_lcl = pset.getParameter("label_lcl"); + SCCollectionToken_ = consumes(pset.getParameter("label_scl")); - LCCollectionToken_ = consumes(pset.getParameter("label_lcl")); - associatorToken_ = - consumes>(pset.getParameter("associator")); + LCCollectionToken_ = consumes(label_lcl); + associatorToken_ = consumes>(pset.getParameter("associator")); } // @@ -87,7 +90,9 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, // Protection against missing cluster collection if (!LCCollection.isValid()) { edm::LogWarning("LCToSCAssociatorEDProducerT") - << "Cluster collection is unavailable. Producing empty associations."; + << "CaloCluster collection with label " + << label_lcl + << " is unavailable. Producing empty associations."; // Return empty collections auto emptyRecSimColl = std::make_unique>(); @@ -117,9 +122,9 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, template void LCToSCAssociatorEDProducerT::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.add("label_scl", edm::InputTag("scAssocByEnergyScoreProducer")); - desc.add("label_lcl", edm::InputTag("mix", "MergedCaloTruth")); - desc.add("associator", edm::InputTag("hgcalMergeLayerClusters")); + desc.add("label_scl", edm::InputTag("mix", "MergedCaloTruth")); + desc.add("label_lcl", edm::InputTag("hgcalMergeLayerClusters")); + desc.add("associator", edm::InputTag("scAssocByEnergyScoreProducer")); descriptions.addWithDefaultLabel(desc); } From 0c6926e76e6ad832f5bf9891b4e1f52bda8e9fef Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 24 Jul 2025 12:07:42 +0200 Subject: [PATCH 03/22] Add missing descriptions. --- .../plugins/LCToCPAssociatorEDProducer.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc index f62b32d0a39de..84fd5badea172 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc @@ -10,17 +10,13 @@ // user include files #include "FWCore/Framework/interface/global/EDProducer.h" - #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" - #include "FWCore/Framework/interface/ESHandle.h" - #include "FWCore/ParameterSet/interface/ParameterSet.h" - #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h" - #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h" #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h" #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h" @@ -29,7 +25,6 @@ #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" - #include "FWCore/Utilities/interface/EDGetToken.h" // @@ -44,6 +39,8 @@ class LCToCPAssociatorEDProducerT : public edm::global::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; @@ -125,12 +122,11 @@ void LCToCPAssociatorEDProducerT::produce(edm::StreamID, iEvent.put(std::move(str)); } -template void LCToCPAssociatorEDProducerT::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.add("label_cp", edm::InputTag("cpAssocByEnergyScoreProducer")); - desc.add("label_lc", edm::InputTag("mix", "MergedCaloTruth")); - desc.add("associator", edm::InputTag("hgcalMergeLayerClusters")); + desc.add("label_cp", edm::InputTag("mix", "MergedCaloTruth")); + desc.add("label_lc", edm::InputTag("hgcalMergeLayerClusters")); + desc.add("associator", edm::InputTag("lcAssocByEnergyScoreProducer")); descriptions.addWithDefaultLabel(desc); } From e7dd5481b8a01d6c611be14ba2f047981068a3b9 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Fri, 25 Jul 2025 11:00:07 +0200 Subject: [PATCH 04/22] Remove legacy input parameter and code formats. --- .../LCToCPAssociatorByEnergyScoreProducer.cc | 27 +++++++++---------- .../plugins/LCToCPAssociatorEDProducer.cc | 10 +++---- .../LCToSCAssociatorByEnergyScoreProducer.cc | 27 +++++++++---------- .../plugins/LCToSCAssociatorEDProducer.cc | 10 +++---- .../plugins/BarrelValidator.cc | 6 ----- 5 files changed, 35 insertions(+), 45 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index 07f8cce569d05..f1af04d85c3d4 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -9,7 +9,7 @@ LCToCPAssociatorByEnergyScoreProducerT::LCToCPAssociatorByEnergySc hardScatterOnly_(ps.getParameter("hardScatterOnly")), hits_label_(ps.getParameter>("hits")) { for (auto &label : hits_label_) { - hits_token_.push_back(consumes>(label)); + hits_token_.push_back(consumes>(label)); } rhtools_ = std::make_shared(); @@ -30,21 +30,20 @@ void LCToCPAssociatorByEnergyScoreProducerT::produce(edm::StreamID std::vector hits; edm::Handle> hits_handle; - - for (unsigned i=0; i { static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); - + private: void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; edm::InputTag label_lc; - + edm::EDGetTokenT CPCollectionToken_; edm::EDGetTokenT LCCollectionToken_; edm::EDGetTokenT> associatorToken_; @@ -57,7 +57,7 @@ LCToCPAssociatorEDProducerT::LCToCPAssociatorEDProducerT(const edm::Par produces>(); label_lc = pset.getParameter("label_lc"); - + CPCollectionToken_ = consumes(pset.getParameter("label_cp")); LCCollectionToken_ = consumes(label_lc); associatorToken_ = consumes>(pset.getParameter("associator")); @@ -95,9 +95,7 @@ void LCToCPAssociatorEDProducerT::produce(edm::StreamID, // Protection against missing cluster collection if (!LCCollection.isValid()) { edm::LogWarning("LCToCPAssociatorEDProducerT") - << "CaloCluster collection with label " - << label_lc - << "is unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_lc << " is unavailable. Producing empty associations."; // Return empty collections auto emptyRecSimColl = std::make_unique>(); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 7dd00a490186a..c55de0f0c7d7a 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -9,7 +9,7 @@ LCToSCAssociatorByEnergyScoreProducerT::LCToSCAssociatorByEnergySc hardScatterOnly_(ps.getParameter("hardScatterOnly")), hits_label_(ps.getParameter>("hits")) { for (auto &label : hits_label_) { - hits_token_.push_back(consumes>(label)); + hits_token_.push_back(consumes>(label)); } rhtools_ = std::make_shared(); @@ -30,21 +30,20 @@ void LCToSCAssociatorByEnergyScoreProducerT::produce(edm::StreamID std::vector hits; edm::Handle> hits_handle; - - for (unsigned i=0; i { void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; edm::InputTag label_lcl; - + edm::EDGetTokenT SCCollectionToken_; edm::EDGetTokenT LCCollectionToken_; edm::EDGetTokenT> associatorToken_; @@ -49,7 +49,7 @@ LCToSCAssociatorEDProducerT::LCToSCAssociatorEDProducerT(const edm::Par produces>(); label_lcl = pset.getParameter("label_lcl"); - + SCCollectionToken_ = consumes(pset.getParameter("label_scl")); LCCollectionToken_ = consumes(label_lcl); associatorToken_ = consumes>(pset.getParameter("associator")); @@ -90,9 +90,9 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, // Protection against missing cluster collection if (!LCCollection.isValid()) { edm::LogWarning("LCToSCAssociatorEDProducerT") - << "CaloCluster collection with label " - << label_lcl - << " is unavailable. Producing empty associations."; + << "CaloCluster collection with label " + << label_lcl + << " is unavailable. Producing empty associations."; // Return empty collections auto emptyRecSimColl = std::make_unique>(); diff --git a/Validation/HGCalValidation/plugins/BarrelValidator.cc b/Validation/HGCalValidation/plugins/BarrelValidator.cc index 2da8957dae3a7..a90e9ce55d504 100644 --- a/Validation/HGCalValidation/plugins/BarrelValidator.cc +++ b/Validation/HGCalValidation/plugins/BarrelValidator.cc @@ -513,12 +513,6 @@ void BarrelValidator::fillDescriptions(edm::ConfigurationDescriptions& descripti psd1.add("nintZ", 1100); desc.add("histoProducerAlgoBlock", psd1); } - desc.add>("hgcal_hits", - { - edm::InputTag("HGCalRecHit", "HGCEERecHits"), - edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), - edm::InputTag("HGCalRecHit", "HGCHEBRecHits"), - }); desc.add>("barrel_hits", { edm::InputTag("particleFlowRecHitECAL"), From cb6a676ac1faf668f83353e39f4e78efefce1ebf Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 31 Jul 2025 16:06:54 +0200 Subject: [PATCH 05/22] Update plot folder name. --- Validation/HGCalValidation/plugins/BarrelValidator.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/HGCalValidation/plugins/BarrelValidator.cc b/Validation/HGCalValidation/plugins/BarrelValidator.cc index a90e9ce55d504..99be188e4184c 100644 --- a/Validation/HGCalValidation/plugins/BarrelValidator.cc +++ b/Validation/HGCalValidation/plugins/BarrelValidator.cc @@ -74,7 +74,7 @@ BarrelValidator::BarrelValidator(const edm::ParameterSet& pset) label_SimClustersPlots_(pset.getParameter("label_SimClusters")), label_SimClustersLevel_(pset.getParameter("label_SimClustersLevel")), doLayerClustersPlots_(pset.getUntrackedParameter("doLayerClustersPlots")), - label_layerClustersPlots_(pset.getParameter("label_layerClusterPlots")), + label_layerClustersPlots_(pset.getParameter("label_layerClustersPlots")), label_LCToCPLinking_(pset.getParameter("label_LCToCPLinking")), barrel_hits_label_(pset.getParameter>("barrel_hits")), scToCpMapToken_( @@ -540,7 +540,7 @@ void BarrelValidator::fillDescriptions(edm::ConfigurationDescriptions& descripti desc.add("label_SimClusters", edm::InputTag("SimClusters")); desc.add("label_SimClustersLevel", edm::InputTag("ClusterLevel")); desc.addUntracked("doLayerClustersPlots", true); - desc.add("label_layerClusterPlots", edm::InputTag("hgcalMergeLayerClusters")); + desc.add("label_layerClustersPlots", edm::InputTag("LayerClusters")); desc.add("label_LCToCPLinking", edm::InputTag("LCToCP_association")); desc.add("simClustersToCaloParticlesMap", edm::InputTag("SimClusterToCaloParticleAssociation", "simClusterToCaloParticleMap")); From 8802add600e941162d1a9a35b9b7d15a1f3dbe87 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 31 Jul 2025 16:19:20 +0200 Subject: [PATCH 06/22] Add SC to debug output. --- .../plugins/LCToSCAssociatorEDProducer.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc index 9f18e0e3f7832..adaa718de7d6c 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc @@ -37,6 +37,7 @@ class LCToSCAssociatorEDProducerT : public edm::global::EDProducer<> { void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override; edm::InputTag label_lcl; + edm::InputTag label_scl; edm::EDGetTokenT SCCollectionToken_; edm::EDGetTokenT LCCollectionToken_; @@ -49,9 +50,10 @@ LCToSCAssociatorEDProducerT::LCToSCAssociatorEDProducerT(const edm::Par produces>(); label_lcl = pset.getParameter("label_lcl"); + label_scl = pset.getParameter("label_scl"); - SCCollectionToken_ = consumes(pset.getParameter("label_scl")); LCCollectionToken_ = consumes(label_lcl); + SCCollectionToken_ = consumes(label_scl); associatorToken_ = consumes>(pset.getParameter("associator")); } @@ -87,12 +89,16 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, Handle LCCollection; iEvent.getByToken(LCCollectionToken_, LCCollection); - // Protection against missing cluster collection + // Protection against missing CaloCluster collections if (!LCCollection.isValid()) { edm::LogWarning("LCToSCAssociatorEDProducerT") - << "CaloCluster collection with label " - << label_lcl - << " is unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_lcl << " is unavailable. Producing empty associations."; + } + if (!SCCollection.isValid()) { + edm::LogWarning("LCToSCAssociatorEDProducerT") + << "CaloCluster collection with label " << label_scl << " is unavailable. Producing empty associations."; + } + if (!LCCollection.isValid() || !SCCollection.isValid()) { // Return empty collections auto emptyRecSimColl = std::make_unique>(); From 8fb90656b7a8c70a64e903e0f1533493b2652db5 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 31 Jul 2025 16:30:17 +0200 Subject: [PATCH 07/22] [bugfix] Ensure the hits come from the barrel. --- RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc | 3 ++- .../CaloAnalysis/interface/SimCluster.h | 2 +- .../src/BarrelVHistoProducerAlgo.cc | 18 ++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc index efcb8e14ca139..ac94e87cc0e2a 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc @@ -519,7 +519,8 @@ bool RecHitTools::isScintillatorFine(const DetId& id) const { return false; } } -bool RecHitTools::isBarrel(const DetId& id) const { return (id.det() == DetId::Ecal || id.det() == DetId::Hcal); } +bool RecHitTools::isBarrel(const DetId& id) const { return (id.det() == DetId::Ecal && id.subdetId() == EcalBarrel) || (id.det() == DetId::Hcal && id.subdetId() == HcalBarrel) || (id.det() == DetId::Hcal && id.subdetId() == HcalOuter); } + bool RecHitTools::isOnlySilicon(const unsigned int layer) const { // HFnose TODO bool isonlysilicon = (layer % bhLastLayer_) < bhOffset_; diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index 71f9b367bce63..42a5673d8ebd3 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -198,7 +198,7 @@ class SimCluster { std::vector> result; for (size_t i = 0; i < hits_.size(); ++i) { DetId detid(hits_[i]); - if (detid.subdetId() != EcalBarrel && detid.subdetId() != HcalBarrel && detid.subdetId() != HcalOuter) + if ( ! (detid.det() == DetId::Ecal && detid.subdetId() == EcalBarrel) || (detid.det() == DetId::Hcal && detid.subdetId() == HcalBarrel) || (detid.det() == DetId::Hcal && detid.subdetId() == HcalOuter) ) continue; result.emplace_back(hits_[i], fractions_[i]); } diff --git a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc index 4eec007f41565..a5a35b0ce9d31 100644 --- a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc @@ -798,18 +798,16 @@ void BarrelVHistoProducerAlgo::BarrelVHistoProducerAlgo::fill_simCluster_histos( std::vector occurenceSCinlayer(1000, 0); //[layerid][0 if not added] //loop through hits of the simCluster - for (const auto& hAndF : sc.hits_and_fractions()) { + for (const auto& hAndF : sc.barrel_hits_and_fractions()) { const DetId sh_detid = hAndF.first; - if (recHitTools_->isBarrel(sh_detid)) { - //The layer the cluster belongs to. As mentioned in the mapping above, it takes into account -z and +z. - int layerid = recHitTools_->getLayerWithOffset(sh_detid); - //zside that the current cluster belongs to. - if (occurenceSCinlayer[layerid] == 0) { - tnscpl[layerid]++; - } - occurenceSCinlayer[layerid]++; - } + //The layer the cluster belongs to. As mentioned in the mapping above, it takes into account -z and +z. + int layerid = recHitTools_->getLayerWithOffset(sh_detid); + //zside that the current cluster belongs to. + if (occurenceSCinlayer[layerid] == 0) { + tnscpl[layerid]++; + } + occurenceSCinlayer[layerid]++; } //end of loop through hits } //end of loop through SimClusters of the event From d0687466cfc059339f05a10280b2bfd3651790a9 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 31 Jul 2025 18:26:11 +0200 Subject: [PATCH 08/22] Reduce code duplication when checking isBarrel condition. --- .../LCToCPAssociatorByEnergyScoreImpl.cc | 8 +++--- .../LCToSCAssociatorByEnergyScoreImpl.cc | 4 +-- .../CaloAnalysis/interface/SimCluster.h | 27 ++++++------------- .../src/BarrelVHistoProducerAlgo.cc | 2 +- .../src/HGVHistoProducerAlgo.cc | 6 +++-- 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index 5fb52e52df071..150b7aadbf1c7 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -73,10 +73,10 @@ ticl::association LCToCPAssociatorByEnergyScoreImplT::makeConnecti for (const auto& it_sc : simClusterRefVector) { const SimCluster& simCluster = (*(it_sc)); std::vector> hits_and_fractions; - if constexpr (std::is_same_v) - hits_and_fractions = simCluster.endcap_hits_and_fractions(); - else - hits_and_fractions = simCluster.barrel_hits_and_fractions(); + if constexpr (std::is_same_v) + hits_and_fractions = simCluster.filtered_hits_and_fractions( [this](const DetId& detid) {return !recHitTools_->isBarrel(detid);} ); + else + hits_and_fractions = simCluster.filtered_hits_and_fractions( [this](const DetId& detid) {return recHitTools_->isBarrel(detid);} ); for (const auto& it_haf : hits_and_fractions) { const auto hitid = (it_haf.first); unsigned int cpLayerId = recHitTools_->getLayerWithOffset(hitid); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc index 6044c7f1a7135..11c8597d3ece2 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc @@ -73,9 +73,9 @@ ticl::association LCToSCAssociatorByEnergyScoreImplT::makeConnecti for (const auto& scId : sCIndices) { std::vector> hits_and_fractions = simClusters[scId].hits_and_fractions(); if constexpr (std::is_same_v) - hits_and_fractions = simClusters[scId].endcap_hits_and_fractions(); + hits_and_fractions = simClusters[scId].filtered_hits_and_fractions( [this](const DetId& detid) {return !recHitTools_->isBarrel(detid);} ); else - hits_and_fractions = simClusters[scId].barrel_hits_and_fractions(); + hits_and_fractions = simClusters[scId].filtered_hits_and_fractions( [this](const DetId& detid) {return recHitTools_->isBarrel(detid);} ); for (const auto& it_haf : hits_and_fractions) { const auto hitid = (it_haf.first); unsigned int scLayerId = recHitTools_->getLayer(hitid); diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index 42a5673d8ebd3..d1fb5d9198f1f 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -8,6 +8,7 @@ #include "SimDataFormats/CaloHit/interface/PCaloHit.h" #include "SimDataFormats/Track/interface/SimTrack.h" #include +#include #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" @@ -193,30 +194,18 @@ class SimCluster { return result; } - /** @brief Returns list of rechit IDs and fractions in the barrel for this SimCluster */ - std::vector> barrel_hits_and_fractions() const { + /** @brief Returns filtered list of rechit IDs and fractions for this SimCluster based on a predicate */ + std::vector> filtered_hits_and_fractions(const std::function& predicate) const { std::vector> result; for (size_t i = 0; i < hits_.size(); ++i) { - DetId detid(hits_[i]); - if ( ! (detid.det() == DetId::Ecal && detid.subdetId() == EcalBarrel) || (detid.det() == DetId::Hcal && detid.subdetId() == HcalBarrel) || (detid.det() == DetId::Hcal && detid.subdetId() == HcalOuter) ) - continue; - result.emplace_back(hits_[i], fractions_[i]); + DetId detid(hits_[i]); + if (predicate(detid)) { + result.emplace_back(hits_[i], fractions_[i]); + } } return result; } - - /** @brief Returns list of rechit IDs and fractions in the endcap for this SimCluster */ - std::vector> endcap_hits_and_fractions() const { - std::vector> result; - for (size_t i = 0; i < hits_.size(); ++i) { - DetId detid(hits_[i]); - if (detid.subdetId() == EcalBarrel || detid.subdetId() == HcalBarrel || detid.subdetId() == HcalOuter) - continue; - result.emplace_back(hits_[i], fractions_[i]); - } - return result; - } - + /** @brief Returns list of rechit IDs and energies for this SimCluster */ std::vector> hits_and_energies() const { assert(hits_.size() == energies_.size()); diff --git a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc index a5a35b0ce9d31..66418776c60d8 100644 --- a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc @@ -798,7 +798,7 @@ void BarrelVHistoProducerAlgo::BarrelVHistoProducerAlgo::fill_simCluster_histos( std::vector occurenceSCinlayer(1000, 0); //[layerid][0 if not added] //loop through hits of the simCluster - for (const auto& hAndF : sc.barrel_hits_and_fractions()) { + for (const auto& hAndF : sc.filtered_hits_and_fractions( [this](const DetId& x) {return recHitTools_->isBarrel(x);} )) { const DetId sh_detid = hAndF.first; //The layer the cluster belongs to. As mentioned in the mapping above, it takes into account -z and +z. diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index cf0922149005a..e6b081815dd04 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1492,8 +1492,10 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms for (const auto& sc : caloParticle.simClusters()) { LogDebug("HGCalValidator") << " This sim cluster has " << sc->hits_and_fractions().size() << " simHits and " << sc->energy() << " energy. " << std::endl; - simHits += sc->endcap_hits_and_fractions().size(); - for (auto const& h_and_f : sc->endcap_hits_and_fractions()) { + + auto endcap_hf = sc->filtered_hits_and_fractions( [this](const DetId& detid) {return recHitTools_->isBarrel(detid);} ); + simHits += endcap_hf.size(); + for (auto const& h_and_f : endcap_hf) { const auto hitDetId = h_and_f.first; if (recHitTools_->isBarrel(hitDetId)) continue; From c947738ed80ec33d8ad054fbf022f0bc0ab105e6 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 31 Jul 2025 19:20:41 +0200 Subject: [PATCH 09/22] Reduce memory allocation to what is needed. --- .../src/BarrelVHistoProducerAlgo.cc | 17 +++++++---------- .../HGCalValidation/src/HGVHistoProducerAlgo.cc | 14 ++++++-------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc index 66418776c60d8..9918c073bb51f 100644 --- a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc @@ -789,21 +789,19 @@ void BarrelVHistoProducerAlgo::fill_caloparticle_histos( void BarrelVHistoProducerAlgo::BarrelVHistoProducerAlgo::fill_simCluster_histos( const Histograms& histograms, std::vector const& simClusters, unsigned int layers) const { //To keep track of total num of simClusters per layer - //tnscpl[layerid] - std::vector tnscpl(1000, 0); //tnscpl.clear(); tnscpl.reserve(1000); + std::vector tnscpl(layers, 0); //loop through simClusters for (const auto& sc : simClusters) { //To keep track if we added the simCluster in a specific layer - std::vector occurenceSCinlayer(1000, 0); //[layerid][0 if not added] + std::vector occurenceSCinlayer(layers, 0); //loop through hits of the simCluster for (const auto& hAndF : sc.filtered_hits_and_fractions( [this](const DetId& x) {return recHitTools_->isBarrel(x);} )) { const DetId sh_detid = hAndF.first; - //The layer the cluster belongs to. As mentioned in the mapping above, it takes into account -z and +z. + //The layer the cluster belongs to int layerid = recHitTools_->getLayerWithOffset(sh_detid); - //zside that the current cluster belongs to. if (occurenceSCinlayer[layerid] == 0) { tnscpl[layerid]++; } @@ -1341,8 +1339,7 @@ void BarrelVHistoProducerAlgo::fill_generic_cluster_histos( const ticl::SimToRecoCollectionT& cPOnLayerMap, edm::MultiSpan const& barrelHits) const { //To keep track of total num of layer clusters per layer - //tnlcpl[layerid] - std::vector tnlcpl(1000, 0); //tnlcpl.clear(); tnlcpl.reserve(1000); + std::vector tnlcpl(layers, 0); layerClusters_to_CaloParticles(histograms, clusterHandle, @@ -1357,7 +1354,7 @@ void BarrelVHistoProducerAlgo::fill_generic_cluster_histos( cPOnLayerMap, barrelHits); - std::vector tecpl(1000, 0.0); //tecpl.clear(); tecpl.reserve(1000); + std::vector tecpl(layers, 0.0); // loop through clusters of the event for (const auto& lcId : clusters) { @@ -1368,8 +1365,8 @@ void BarrelVHistoProducerAlgo::fill_generic_cluster_histos( const float lc_en = lcId.energy(); int layerid = recHitTools_->getLayerWithOffset(seedid); //Energy clustered per layer - tecpl[layerid] = tecpl[layerid] + lc_en; - tnlcpl[layerid] = tnlcpl[layerid] + 1; + tecpl[layerid] += lc_en; + tnlcpl[layerid] += 1; } //end of loop through clusters of the event diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index e6b081815dd04..b1c078d4e63b6 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1592,8 +1592,7 @@ void HGVHistoProducerAlgo::fill_simCluster_histos(const Histograms& histograms, //+z: 50->99 //To keep track of total num of simClusters per layer - //tnscpl[layerid] - std::vector tnscpl(1000, 0); //tnscpl.clear(); tnscpl.reserve(1000); + std::vector tnscpl(2 * layers, 0); //To keep track of the total num of clusters per thickness in plus and in minus endcaps std::map tnscpthplus; @@ -1623,7 +1622,7 @@ void HGVHistoProducerAlgo::fill_simCluster_histos(const Histograms& histograms, //For the hits thickness of the layer cluster. double thickness = 0.; //To keep track if we added the simCluster in a specific layer - std::vector occurenceSCinlayer(1000, 0); //[layerid][0 if not added] + std::vector occurenceSCinlayer(2 * layers, 0); //[layerid][0 if not added] //loop through hits of the simCluster for (const auto& hAndF : sc.hits_and_fractions()) { @@ -2233,8 +2232,7 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos( //+z: 52->103 //To keep track of total num of layer clusters per layer - //tnlcpl[layerid] - std::vector tnlcpl(1000, 0); //tnlcpl.clear(); tnlcpl.reserve(1000); + std::vector tnlcpl(2 * layers, 0); //To keep track of the total num of clusters per thickness in plus and in minus endcaps std::map tnlcpthplus; @@ -2265,9 +2263,9 @@ void HGVHistoProducerAlgo::fill_generic_cluster_histos( //To find out the total amount of energy clustered per layer //Initialize with zeros because I see clear gives weird numbers. - std::vector tecpl(1000, 0.0); //tecpl.clear(); tecpl.reserve(1000); + std::vector tecpl(2 * layers, 0.0); //for the longitudinal depth barycenter - std::vector ldbar(1000, 0.0); //ldbar.clear(); ldbar.reserve(1000); + std::vector ldbar(2 * layers, 0.0); // Need to compare with the total amount of energy coming from CaloParticles double caloparteneplus = 0.; @@ -2766,7 +2764,7 @@ void HGVHistoProducerAlgo::fill_trackster_histos( //To keep track of total num of layer clusters per Trackster //tnLcInTstperlaypz[layerid], tnLcInTstperlaymz[layerid] - std::vector tnLcInTstperlay(1000, 0); //+z + std::vector tnLcInTstperlay(2 * layers, 0); //+z //For the layers the Trackster expands to. Will use a set because there would be many //duplicates and then go back to vector for random access, since they say it is faster. From 011c63039ca04429324af0ce6f5033eb7cbe4dce Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 31 Jul 2025 20:22:50 +0200 Subject: [PATCH 10/22] Update label to reflect variable name. --- RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc | 6 +++++- .../plugins/LCToCPAssociatorByEnergyScoreImpl.cc | 10 ++++++---- .../plugins/LCToSCAssociatorByEnergyScoreImpl.cc | 6 ++++-- .../plugins/LCToSCAssociatorEDProducer.cc | 1 - .../CaloAnalysis/interface/SimCluster.h | 13 +++++++------ .../HGCalValidation/plugins/HGCalValidator.cc | 4 ++-- .../python/HLTHGCalPostProcessor_cff.py | 2 +- .../python/HLTHGCalValidator_cff.py | 2 +- .../python/PostProcessorBarrel_cfi.py | 2 +- .../python/PostProcessorHGCAL_cfi.py | 2 +- Validation/HGCalValidation/python/hgcalPlots.py | 2 +- .../scripts/makeHGCalValidationPlots.py | 2 +- .../src/BarrelVHistoProducerAlgo.cc | 15 ++++++++------- .../HGCalValidation/src/HGVHistoProducerAlgo.cc | 3 ++- 14 files changed, 40 insertions(+), 30 deletions(-) diff --git a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc index ac94e87cc0e2a..20ca94a6a0384 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/RecHitTools.cc @@ -519,7 +519,11 @@ bool RecHitTools::isScintillatorFine(const DetId& id) const { return false; } } -bool RecHitTools::isBarrel(const DetId& id) const { return (id.det() == DetId::Ecal && id.subdetId() == EcalBarrel) || (id.det() == DetId::Hcal && id.subdetId() == HcalBarrel) || (id.det() == DetId::Hcal && id.subdetId() == HcalOuter); } +bool RecHitTools::isBarrel(const DetId& id) const { + return (id.det() == DetId::Ecal && id.subdetId() == EcalBarrel) || + (id.det() == DetId::Hcal && id.subdetId() == HcalBarrel) || + (id.det() == DetId::Hcal && id.subdetId() == HcalOuter); +} bool RecHitTools::isOnlySilicon(const unsigned int layer) const { // HFnose TODO diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc index 150b7aadbf1c7..c40d276ed35ec 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreImpl.cc @@ -73,10 +73,12 @@ ticl::association LCToCPAssociatorByEnergyScoreImplT::makeConnecti for (const auto& it_sc : simClusterRefVector) { const SimCluster& simCluster = (*(it_sc)); std::vector> hits_and_fractions; - if constexpr (std::is_same_v) - hits_and_fractions = simCluster.filtered_hits_and_fractions( [this](const DetId& detid) {return !recHitTools_->isBarrel(detid);} ); - else - hits_and_fractions = simCluster.filtered_hits_and_fractions( [this](const DetId& detid) {return recHitTools_->isBarrel(detid);} ); + if constexpr (std::is_same_v) + hits_and_fractions = simCluster.filtered_hits_and_fractions( + [this](const DetId& detid) { return !recHitTools_->isBarrel(detid); }); + else + hits_and_fractions = simCluster.filtered_hits_and_fractions( + [this](const DetId& detid) { return recHitTools_->isBarrel(detid); }); for (const auto& it_haf : hits_and_fractions) { const auto hitid = (it_haf.first); unsigned int cpLayerId = recHitTools_->getLayerWithOffset(hitid); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc index 11c8597d3ece2..7947ba7ad2acc 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreImpl.cc @@ -73,9 +73,11 @@ ticl::association LCToSCAssociatorByEnergyScoreImplT::makeConnecti for (const auto& scId : sCIndices) { std::vector> hits_and_fractions = simClusters[scId].hits_and_fractions(); if constexpr (std::is_same_v) - hits_and_fractions = simClusters[scId].filtered_hits_and_fractions( [this](const DetId& detid) {return !recHitTools_->isBarrel(detid);} ); + hits_and_fractions = simClusters[scId].filtered_hits_and_fractions( + [this](const DetId& detid) { return !recHitTools_->isBarrel(detid); }); else - hits_and_fractions = simClusters[scId].filtered_hits_and_fractions( [this](const DetId& detid) {return recHitTools_->isBarrel(detid);} ); + hits_and_fractions = simClusters[scId].filtered_hits_and_fractions( + [this](const DetId& detid) { return recHitTools_->isBarrel(detid); }); for (const auto& it_haf : hits_and_fractions) { const auto hitid = (it_haf.first); unsigned int scLayerId = recHitTools_->getLayer(hitid); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc index adaa718de7d6c..4c1cc7ce798e0 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc @@ -99,7 +99,6 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, << "CaloCluster collection with label " << label_scl << " is unavailable. Producing empty associations."; } if (!LCCollection.isValid() || !SCCollection.isValid()) { - // Return empty collections auto emptyRecSimColl = std::make_unique>(); auto emptySimRecColl = std::make_unique>(); diff --git a/SimDataFormats/CaloAnalysis/interface/SimCluster.h b/SimDataFormats/CaloAnalysis/interface/SimCluster.h index d1fb5d9198f1f..3d1bb687a7601 100644 --- a/SimDataFormats/CaloAnalysis/interface/SimCluster.h +++ b/SimDataFormats/CaloAnalysis/interface/SimCluster.h @@ -195,17 +195,18 @@ class SimCluster { } /** @brief Returns filtered list of rechit IDs and fractions for this SimCluster based on a predicate */ - std::vector> filtered_hits_and_fractions(const std::function& predicate) const { + std::vector> filtered_hits_and_fractions( + const std::function &predicate) const { std::vector> result; for (size_t i = 0; i < hits_.size(); ++i) { - DetId detid(hits_[i]); - if (predicate(detid)) { - result.emplace_back(hits_[i], fractions_[i]); - } + DetId detid(hits_[i]); + if (predicate(detid)) { + result.emplace_back(hits_[i], fractions_[i]); + } } return result; } - + /** @brief Returns list of rechit IDs and energies for this SimCluster */ std::vector> hits_and_energies() const { assert(hits_.size() == energies_.size()); diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 48f3651937fb3..f4906adbb9a6b 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -84,7 +84,7 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) label_SimClustersPlots_(pset.getParameter("label_SimClusters")), label_SimClustersLevel_(pset.getParameter("label_SimClustersLevel")), doLayerClustersPlots_(pset.getUntrackedParameter("doLayerClustersPlots")), - label_layerClustersPlots_(pset.getParameter("label_layerClusterPlots")), + label_layerClustersPlots_(pset.getParameter("label_layerClustersPlots")), label_LCToCPLinking_(pset.getParameter("label_LCToCPLinking")), doTrackstersPlots_(pset.getUntrackedParameter("doTrackstersPlots")), label_TS_(pset.getParameter("label_TS")), @@ -805,7 +805,7 @@ void HGCalValidator::fillDescriptions(edm::ConfigurationDescriptions& descriptio desc.add("label_SimClusters", edm::InputTag("SimClusters")); desc.add("label_SimClustersLevel", edm::InputTag("ClusterLevel")); desc.addUntracked("doLayerClustersPlots", true); - desc.add("label_layerClusterPlots", edm::InputTag("hgcalMergeLayerClusters")); + desc.add("label_layerClustersPlots", edm::InputTag("hgcalMergeLayerClusters")); desc.add("label_LCToCPLinking", edm::InputTag("LCToCP_association")); desc.addUntracked("doTrackstersPlots", true); desc.add("label_TS", "Morphology"); diff --git a/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py b/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py index c50f6846da9e3..e4c909a6c3d8c 100644 --- a/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py +++ b/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py @@ -14,7 +14,7 @@ hltLcToCP_linking = _hltHgcalValidator.label_LCToCPLinking._InputTag__moduleLabel hltPostProcessorHGCALlayerclusters = _postProcessorHGCALlayerclusters.clone( - subDirs = cms.untracked.vstring(hltPrefix + _hltHgcalValidator.label_layerClusterPlots._InputTag__moduleLabel + '/' + hltLcToCP_linking), + subDirs = cms.untracked.vstring(hltPrefix + _hltHgcalValidator.label_layerClustersPlots._InputTag__moduleLabel + '/' + hltLcToCP_linking), ) hltSubdirsSim = [hltPrefix + _hltHgcalValidator.label_SimClusters._InputTag__moduleLabel + '/'+iteration+'/' for iteration in hltTracksterLabels] diff --git a/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py b/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py index 1b3a6704d87f6..3d39d0a61bcf9 100644 --- a/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py +++ b/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py @@ -21,7 +21,7 @@ hits = cms.VInputTag("hltHGCalRecHit:HGCEERecHits", "hltHGCalRecHit:HGCHEFRecHits", "hltHGCalRecHit:HGCHEBRecHits"), hitMap = cms.InputTag("hltRecHitMapProducer","hgcalRecHitMap"), simTrackstersMap = cms.InputTag("hltTiclSimTracksters"), - label_layerClusterPlots = cms.InputTag("hltHgcalMergeLayerClusters"), + label_layerClustersPlots = cms.InputTag("hltHgcalMergeLayerClusters"), label_lcl = cms.InputTag("hltMergeLayerClusters"), label_simTS = cms.InputTag("hltTiclSimTracksters"), label_simTSFromCP = cms.InputTag("hltTiclSimTracksters","fromCPs"), diff --git a/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py b/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py index f658bccd6af5f..1d4fb3ba20d1f 100644 --- a/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py +++ b/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py @@ -17,7 +17,7 @@ lcToCP_linking = barrelValidator.label_LCToCPLinking._InputTag__moduleLabel postProcessorBarrellayerclusters = DQMEDHarvester('DQMGenericClient', - subDirs = cms.untracked.vstring(prefix + barrelValidator.label_layerClusterPlots._InputTag__moduleLabel + '/' + lcToCP_linking), + subDirs = cms.untracked.vstring(prefix + barrelValidator.label_layerClustersPlots._InputTag__moduleLabel + '/' + lcToCP_linking), efficiency = cms.vstring(eff_layers), resolution = cms.vstring(), cumulativeDists = cms.untracked.vstring(), diff --git a/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py b/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py index 5bfade2d97dc6..52a7c4efbc750 100644 --- a/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py +++ b/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py @@ -22,7 +22,7 @@ lcToCP_linking = hgcalValidator.label_LCToCPLinking._InputTag__moduleLabel postProcessorHGCALlayerclusters = DQMEDHarvester('DQMGenericClient', - subDirs = cms.untracked.vstring(prefix + hgcalValidator.label_layerClusterPlots._InputTag__moduleLabel + '/' + lcToCP_linking), + subDirs = cms.untracked.vstring(prefix + hgcalValidator.label_layerClustersPlots._InputTag__moduleLabel + '/' + lcToCP_linking), efficiency = cms.vstring(eff_layers), resolution = cms.vstring(), cumulativeDists = cms.untracked.vstring(), diff --git a/Validation/HGCalValidation/python/hgcalPlots.py b/Validation/HGCalValidation/python/hgcalPlots.py index 7f50c9843146a..8bad25b55a1a8 100644 --- a/Validation/HGCalValidation/python/hgcalPlots.py +++ b/Validation/HGCalValidation/python/hgcalPlots.py @@ -2397,7 +2397,7 @@ _distancebetseedandmaxcellvsclusterenergy_perthickperlayer_scint_BH_zplus ] -def append_hgcalLayerClustersPlots(collection = hgcalValidator.label_layerClusterPlots._InputTag__moduleLabel, name_collection = layerClustersLabel, extended = False): +def append_hgcalLayerClustersPlots(collection = hgcalValidator.label_layerClustersPlots._InputTag__moduleLabel, name_collection = layerClustersLabel, extended = False): print('extended : ',extended) regions_ClusterLevel = ["General: Cluster Level", "Z-minus: Cluster Level", "Z-plus: Cluster Level"] regions_CellLevel = ["Z-minus: Cell Level", "Z-plus: Cell Level"] diff --git a/Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py b/Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py index 2a5e3889215d5..3e789b04a9f9d 100755 --- a/Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py +++ b/Validation/HGCalValidation/scripts/makeHGCalValidationPlots.py @@ -62,7 +62,7 @@ def main(opts): #layerClusters def plot_LC(): hgclayclus = [hgcalPlots.hgcalLayerClustersPlotter] - hgcalPlots.append_hgcalLayerClustersPlots(hgcalValidator.label_layerClusterPlots._InputTag__moduleLabel, "Layer Clusters", extendedFlag) + hgcalPlots.append_hgcalLayerClustersPlots(hgcalValidator.label_layerClustersPlots._InputTag__moduleLabel, "Layer Clusters", extendedFlag) val.doPlots(hgclayclus, plotterDrawArgs=drawArgs) #simClusters diff --git a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc index 9918c073bb51f..f37e668ed1a0a 100644 --- a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc @@ -797,15 +797,16 @@ void BarrelVHistoProducerAlgo::BarrelVHistoProducerAlgo::fill_simCluster_histos( std::vector occurenceSCinlayer(layers, 0); //loop through hits of the simCluster - for (const auto& hAndF : sc.filtered_hits_and_fractions( [this](const DetId& x) {return recHitTools_->isBarrel(x);} )) { + for (const auto& hAndF : + sc.filtered_hits_and_fractions([this](const DetId& x) { return recHitTools_->isBarrel(x); })) { const DetId sh_detid = hAndF.first; - //The layer the cluster belongs to - int layerid = recHitTools_->getLayerWithOffset(sh_detid); - if (occurenceSCinlayer[layerid] == 0) { - tnscpl[layerid]++; - } - occurenceSCinlayer[layerid]++; + //The layer the cluster belongs to + int layerid = recHitTools_->getLayerWithOffset(sh_detid); + if (occurenceSCinlayer[layerid] == 0) { + tnscpl[layerid]++; + } + occurenceSCinlayer[layerid]++; } //end of loop through hits } //end of loop through SimClusters of the event diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index b1c078d4e63b6..86c29e488c681 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1493,7 +1493,8 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms LogDebug("HGCalValidator") << " This sim cluster has " << sc->hits_and_fractions().size() << " simHits and " << sc->energy() << " energy. " << std::endl; - auto endcap_hf = sc->filtered_hits_and_fractions( [this](const DetId& detid) {return recHitTools_->isBarrel(detid);} ); + auto endcap_hf = + sc->filtered_hits_and_fractions([this](const DetId& detid) { return recHitTools_->isBarrel(detid); }); simHits += endcap_hf.size(); for (auto const& h_and_f : endcap_hf) { const auto hitDetId = h_and_f.first; From 42711a28e948c2cc446e943a1419a4844cb3fd55 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Mon, 4 Aug 2025 17:41:05 +0200 Subject: [PATCH 11/22] Protect modules from missing event collections. --- .../plugins/RecHitMapProducer.cc | 51 ++++++++++--------- .../interface/BarrelValidator.h | 4 +- .../interface/HGCalValidator.h | 2 +- .../plugins/BarrelValidator.cc | 16 ++++-- .../HGCalValidation/plugins/HGCalValidator.cc | 14 +++-- 5 files changed, 49 insertions(+), 38 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc index a7380435bef18..8579f6c87eed8 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc @@ -62,47 +62,48 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event auto hitMapHGCal = std::make_unique(); // Retrieve collections + assert(hgcal_hits_token_.size() == 3); 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())) { - // TODO may be worth to avoid dependency on the order - // of the collections, maybe using a map - edm::MultiSpan rechitSpan; - rechitSpan.add(*ee_hits); - rechitSpan.add(*fh_hits); - rechitSpan.add(*bh_hits); - - for (unsigned int i = 0; i < rechitSpan.size(); ++i) { - const auto recHitDetId = rechitSpan[i].detid(); - hitMapHGCal->emplace(recHitDetId, i); + if (!ee_hits.isValid() || !fh_hits.isValid() || !bh_hits.isValid()) { + edm::LogWarning("HGCalRecHitMapProducer") + << "One or more HGCal hit collections are unavailable. Returning an empty map."; + evt.put(std::move(hitMapHGCal), "hgcalRecHitMap"); + + if (!hgcalOnly_) { + auto hitMapBarrel = std::make_unique(); + evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); } - } else { - edm::LogWarning("HGCalRecHitMapProducer") << "One or more hit collections are unavailable. Returning an empty map."; + + return; } evt.put(std::move(hitMapHGCal), "hgcalRecHitMap"); if (!hgcalOnly_) { auto hitMapBarrel = std::make_unique(); - // Retrieve collections + assert(barrel_hits_token_.size() == 2); const auto& ecal_hits = evt.getHandle(barrel_hits_token_[0]); const auto& hbhe_hits = evt.getHandle(barrel_hits_token_[1]); - if ((ecal_hits.isValid()) && (hbhe_hits.isValid())) { - edm::MultiSpan barrelRechitSpan; - barrelRechitSpan.add(*ecal_hits); - barrelRechitSpan.add(*hbhe_hits); - for (unsigned int i = 0; i < barrelRechitSpan.size(); ++i) { - const auto recHitDetId = barrelRechitSpan[i].detId(); - hitMapBarrel->emplace(recHitDetId, i); - } - } else { - edm::LogWarning("RecHitMapProducer") - << "One or more barrel hit collections are unavailable. Returning an empty map."; + if (!ecal_hits.isValid() || !hbhe_hits.isValid()) { + edm::LogWarning("HGCalRecHitMapProducer") + << "One or more barrel hit collections are unavailable. Returning an empty map."; + evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); + return; } + + edm::MultiSpan barrelRechitSpan; + barrelRechitSpan.add(evt.get(barrel_hits_token_[0])); + barrelRechitSpan.add(evt.get(barrel_hits_token_[1])); + for (unsigned int i = 0; i < barrelRechitSpan.size(); ++i) { + const auto recHitDetId = barrelRechitSpan[i].detId(); + hitMapBarrel->emplace(recHitDetId, i); + } + evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); } } diff --git a/Validation/HGCalValidation/interface/BarrelValidator.h b/Validation/HGCalValidation/interface/BarrelValidator.h index 00ddbc9744c89..eab608800ee0b 100644 --- a/Validation/HGCalValidation/interface/BarrelValidator.h +++ b/Validation/HGCalValidation/interface/BarrelValidator.h @@ -94,8 +94,8 @@ class BarrelValidator : public DQMGlobalEDAnalyzer { std::vector>> associatorMapRtSim; std::unique_ptr histoProducerAlgo_; - std::vector barrel_hits_label_; - std::vector>> barrel_hits_tokens_; + std::vector hits_labels_; + std::vector>> hits_tokens_; edm::EDGetTokenT scToCpMapToken_; private: diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h index be4524105f43d..5ca524986a181 100644 --- a/Validation/HGCalValidation/interface/HGCalValidator.h +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -113,7 +113,7 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { edm::EDGetTokenT> associatorMapSimtR; edm::EDGetTokenT> associatorMapRtSim; std::unique_ptr histoProducerAlgo_; - std::vector hits_label_; + std::vector hits_labels_; std::vector> hits_tokens_; std::unique_ptr candidateVal_; std::vector> tracksterToTracksterAssociatorsTokens_; diff --git a/Validation/HGCalValidation/plugins/BarrelValidator.cc b/Validation/HGCalValidation/plugins/BarrelValidator.cc index 99be188e4184c..1befd7b337294 100644 --- a/Validation/HGCalValidation/plugins/BarrelValidator.cc +++ b/Validation/HGCalValidation/plugins/BarrelValidator.cc @@ -76,15 +76,15 @@ BarrelValidator::BarrelValidator(const edm::ParameterSet& pset) doLayerClustersPlots_(pset.getUntrackedParameter("doLayerClustersPlots")), label_layerClustersPlots_(pset.getParameter("label_layerClustersPlots")), label_LCToCPLinking_(pset.getParameter("label_LCToCPLinking")), - barrel_hits_label_(pset.getParameter>("barrel_hits")), + hits_labels_(pset.getParameter>("hits")), scToCpMapToken_( consumes(pset.getParameter("simClustersToCaloParticlesMap"))) { //In this way we can easily generalize to associations between other objects also. const edm::InputTag& label_cp_effic_tag = pset.getParameter("label_cp_effic"); const edm::InputTag& label_cp_fake_tag = pset.getParameter("label_cp_fake"); - for (auto& label : barrel_hits_label_) { - barrel_hits_tokens_.push_back(consumes>(label)); + for (auto& label : hits_labels_) { + hits_tokens_.push_back(consumes>(label)); } label_cp_effic = consumes>(label_cp_effic_tag); @@ -281,9 +281,15 @@ void BarrelValidator::dqmAnalyze(const edm::Event& event, const std::unordered_map& barrelHitMap = *barrelHitMapHandle; edm::MultiSpan barrelRechitSpan; - for (const auto& token : barrel_hits_tokens_) { + for (const auto& token : hits_tokens_) { Handle> hitsHandle; event.getByToken(token, hitsHandle); + + if (!hitsHandle.isValid()) { + edm::LogWarning("MissingInput") << "Missing " << hits_labels_[i] << " handle."; + return; + } + barrelRechitSpan.add(*hitsHandle); } @@ -513,7 +519,7 @@ void BarrelValidator::fillDescriptions(edm::ConfigurationDescriptions& descripti psd1.add("nintZ", 1100); desc.add("histoProducerAlgoBlock", psd1); } - desc.add>("barrel_hits", + desc.add>("hits", { edm::InputTag("particleFlowRecHitECAL"), edm::InputTag("particleFlowRecHitHBHE"), diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index f4906adbb9a6b..284f8ee6687d8 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -97,7 +97,7 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) label_candidates_(pset.getParameter("ticlCandidates")), cummatbudinxo_(pset.getParameter("cummatbudinxo")), isTICLv5_(pset.getUntrackedParameter("isticlv5")), - hits_label_(pset.getParameter>("hits")), + hits_labels_(pset.getParameter>("hits")), scToCpMapToken_( consumes(pset.getParameter("simClustersToCaloParticlesMap"))), cutTk_(pset.getParameter("cutTk")) { @@ -105,7 +105,7 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) const edm::InputTag& label_cp_effic_tag = pset.getParameter("label_cp_effic"); const edm::InputTag& label_cp_fake_tag = pset.getParameter("label_cp_fake"); - for (auto& label : hits_label_) { + for (auto& label : hits_labels_) { hits_tokens_.push_back(consumes(label)); } label_cp_effic = consumes>(label_cp_effic_tag); @@ -421,8 +421,12 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, for (const auto& token : hits_tokens_) { Handle hitsHandle; event.getByToken(token, hitsHandle); - if (!hitsHandle.isValid()) - continue; + + if (!hitsHandle.isValid()) { + edm::LogWarning("MissingInput") << "Missing " << hits_labels_[i] << " handle."; + return; + } + rechitSpan.add(*hitsHandle); } @@ -577,7 +581,7 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, event.getByToken(label_tstTokens[wml], tracksterHandle); if (!tracksterHandle.isValid()) { - edm::LogWarning("MissinInput") << "Failed to retrieve tracksters for wml index: " << wml; + edm::LogWarning("MissingInput") << "Failed to retrieve tracksters for wml index: " << wml; continue; // Or handle the error as needed } From 0ee409f7304c4a63574d3eb5806c26abbfffac66 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Wed, 6 Aug 2025 16:26:00 +0200 Subject: [PATCH 12/22] Add missing word in debug message. --- DataFormats/Common/interface/ValueMap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataFormats/Common/interface/ValueMap.h b/DataFormats/Common/interface/ValueMap.h index 7de885f872abb..f6045fee43881 100644 --- a/DataFormats/Common/interface/ValueMap.h +++ b/DataFormats/Common/interface/ValueMap.h @@ -89,7 +89,7 @@ namespace edm { void throwFillSize() const { Exception::throwThis(errors::InvalidReference, "ValueMap::Filler: handle and reference " - "collections should the same size\n"); + "collections should have the same size\n"); } void throwFillID(ProductID id) const { Exception e(errors::InvalidReference); From 09683060d5cd30e619b318815710e730d68e5ae6 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Mon, 28 Jul 2025 17:57:17 +0200 Subject: [PATCH 13/22] Add debug error message for missing collection. --- .../plugins/LCToCPAssociatorByEnergyScoreProducer.cc | 2 +- .../plugins/LCToSCAssociatorEDProducer.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index f1af04d85c3d4..358d5e051c6ef 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -37,7 +37,7 @@ void LCToCPAssociatorByEnergyScoreProducerT::produce(edm::StreamID // Check handle validity if (!hits_handle.isValid()) { edm::LogWarning("LCToCPAssociatorByEnergyScoreProducer") - << "Hit collection not available for token \n " << hits_label_[i] << "\nSkipping this collection."; + << "Hit collection not available for token " << hits_label_[i] << "\nSkipping this collection."; continue; // Skip invalid handle } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc index 4c1cc7ce798e0..99301b83ed1c6 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc @@ -98,11 +98,11 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, edm::LogWarning("LCToSCAssociatorEDProducerT") << "CaloCluster collection with label " << label_scl << " is unavailable. Producing empty associations."; } - if (!LCCollection.isValid() || !SCCollection.isValid()) { + // if (!LCCollection.isValid() or !SCCollection.isValid()) { + if (!LCCollection.isValid()) { // Return empty collections auto emptyRecSimColl = std::make_unique>(); auto emptySimRecColl = std::make_unique>(); - iEvent.put(std::move(emptyRecSimColl)); iEvent.put(std::move(emptySimRecColl)); return; From ff6b07222590a4b799ea8f89e80b21f6d0fd7bb2 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Tue, 30 Sep 2025 15:28:36 +0200 Subject: [PATCH 14/22] [bugfix] Invert requirement. --- Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index 86c29e488c681..0962632387326 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1494,7 +1494,7 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms << sc->energy() << " energy. " << std::endl; auto endcap_hf = - sc->filtered_hits_and_fractions([this](const DetId& detid) { return recHitTools_->isBarrel(detid); }); + sc->filtered_hits_and_fractions([this](const DetId& detid) { return !recHitTools_->isBarrel(detid); }); simHits += endcap_hf.size(); for (auto const& h_and_f : endcap_hf) { const auto hitDetId = h_and_f.first; From 805a9527f7ead90c14e65e201f5d5b4e81dcfb70 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Tue, 30 Sep 2025 15:50:33 +0200 Subject: [PATCH 15/22] Exploit isBarrel check in SimCluster collection. --- .../HGCalRecProducers/plugins/RecHitMapProducer.cc | 2 +- Validation/HGCalValidation/plugins/BarrelValidator.cc | 4 ++-- Validation/HGCalValidation/plugins/HGCalValidator.cc | 4 ++-- .../HGCalValidation/src/BarrelVHistoProducerAlgo.cc | 11 +++++++---- .../HGCalValidation/src/HGVHistoProducerAlgo.cc | 10 ++++------ 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc index 8579f6c87eed8..fe244b4fb7863 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc @@ -91,7 +91,7 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event if (!ecal_hits.isValid() || !hbhe_hits.isValid()) { edm::LogWarning("HGCalRecHitMapProducer") - << "One or more barrel hit collections are unavailable. Returning an empty map."; + << "One or more barrel hit collections are unavailable. Returning an empty map."; evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); return; } diff --git a/Validation/HGCalValidation/plugins/BarrelValidator.cc b/Validation/HGCalValidation/plugins/BarrelValidator.cc index 1befd7b337294..02d56fbab9ec6 100644 --- a/Validation/HGCalValidation/plugins/BarrelValidator.cc +++ b/Validation/HGCalValidation/plugins/BarrelValidator.cc @@ -281,9 +281,9 @@ void BarrelValidator::dqmAnalyze(const edm::Event& event, const std::unordered_map& barrelHitMap = *barrelHitMapHandle; edm::MultiSpan barrelRechitSpan; - for (const auto& token : hits_tokens_) { + for (unsigned int i = 0; i < hits_tokens_.size(); ++i) { Handle> hitsHandle; - event.getByToken(token, hitsHandle); + event.getByToken(hits_tokens_[i], hitsHandle); if (!hitsHandle.isValid()) { edm::LogWarning("MissingInput") << "Missing " << hits_labels_[i] << " handle."; diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 284f8ee6687d8..dada1e841c769 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -418,9 +418,9 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, const std::unordered_map& hitMap = *hitMapHandle; edm::MultiSpan rechitSpan; - for (const auto& token : hits_tokens_) { + for (unsigned int i = 0; i < hits_tokens_.size(); ++i) { Handle hitsHandle; - event.getByToken(token, hitsHandle); + event.getByToken(hits_tokens_[i], hitsHandle); if (!hitsHandle.isValid()) { edm::LogWarning("MissingInput") << "Missing " << hits_labels_[i] << " handle."; diff --git a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc index f37e668ed1a0a..aae5b284fb4d3 100644 --- a/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/BarrelVHistoProducerAlgo.cc @@ -700,10 +700,13 @@ void BarrelVHistoProducerAlgo::fill_caloparticle_histos( float hitEnergyWeight_invSum = 0; std::vector> haf_cp; for (const auto& sc : caloParticle.simClusters()) { - LogDebug("BarrelValidator") << " This sim cluster has " << sc->hits_and_fractions().size() << " simHits and " - << sc->energy() << " energy. " << std::endl; - simHits += sc->hits_and_fractions().size(); - for (auto const& h_and_f : sc->hits_and_fractions()) { + auto barrel_hf = sc->filtered_hits_and_fractions([this](const DetId& x) { return recHitTools_->isBarrel(x); }); + + LogDebug("BarrelValidator") << " This sim cluster has " << barrel_hf.size() << " simHits and " << sc->energy() + << " energy. " << std::endl; + + simHits += barrel_hf.size(); + for (auto const& h_and_f : barrel_hf) { const auto hitDetId = h_and_f.first; const int layerId = recHitTools_->getLayerWithOffset(hitDetId); // set to 0 if matched RecHit not found diff --git a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc index 0962632387326..fd05c9106c0e3 100644 --- a/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc +++ b/Validation/HGCalValidation/src/HGVHistoProducerAlgo.cc @@ -1490,16 +1490,14 @@ void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms float hitEnergyWeight_invSum = 0; std::vector> haf_cp; for (const auto& sc : caloParticle.simClusters()) { - LogDebug("HGCalValidator") << " This sim cluster has " << sc->hits_and_fractions().size() << " simHits and " - << sc->energy() << " energy. " << std::endl; + auto endcap_hf = sc->filtered_hits_and_fractions([this](const DetId& x) { return !recHitTools_->isBarrel(x); }); + + LogDebug("HGCalValidator") << " This sim cluster has " << endcap_hf.size() << " simHits and " << sc->energy() + << " energy. " << std::endl; - auto endcap_hf = - sc->filtered_hits_and_fractions([this](const DetId& detid) { return !recHitTools_->isBarrel(detid); }); simHits += endcap_hf.size(); for (auto const& h_and_f : endcap_hf) { const auto hitDetId = h_and_f.first; - if (recHitTools_->isBarrel(hitDetId)) - continue; const int layerId = recHitTools_->getLayerWithOffset(hitDetId) + layers * ((recHitTools_->zside(hitDetId) + 1) >> 1) - 1; // set to 0 if matched RecHit not found From c6f6356588e8644a3133282fd186a838af4b81fa Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Tue, 7 Oct 2025 11:02:31 +0200 Subject: [PATCH 16/22] Simplify if logic. --- .../plugins/LCToSCAssociatorEDProducer.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc index 99301b83ed1c6..9f78728f7b044 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc @@ -89,20 +89,19 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, Handle LCCollection; iEvent.getByToken(LCCollectionToken_, LCCollection); - // Protection against missing CaloCluster collections - if (!LCCollection.isValid()) { - edm::LogWarning("LCToSCAssociatorEDProducerT") - << "CaloCluster collection with label " << label_lcl << " is unavailable. Producing empty associations."; - } + // Protections if (!SCCollection.isValid()) { edm::LogWarning("LCToSCAssociatorEDProducerT") - << "CaloCluster collection with label " << label_scl << " is unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_scl << " is unavailable. Producing empty associations."; } - // if (!LCCollection.isValid() or !SCCollection.isValid()) { if (!LCCollection.isValid()) { + edm::LogWarning("LCToSCAssociatorEDProducer") + << "CaloCluster collection with label\n " << label_lcl << "\nis unavailable. Producing empty associations."; + // Return empty collections - auto emptyRecSimColl = std::make_unique>(); - auto emptySimRecColl = std::make_unique>(); + auto emptyRecSimColl = std::make_unique(); + auto emptySimRecColl = std::make_unique(); + iEvent.put(std::move(emptyRecSimColl)); iEvent.put(std::move(emptySimRecColl)); return; From 27ac1e015ccad30a32acff97d216260be6e7f9d1 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Tue, 7 Oct 2025 16:23:59 +0200 Subject: [PATCH 17/22] Follow recommended token-to-handle implementation. --- .../plugins/LCToCPAssociatorByEnergyScoreProducer.cc | 3 +-- .../plugins/LCToSCAssociatorByEnergyScoreProducer.cc | 3 +-- Validation/HGCalValidation/plugins/HGCalValidator.cc | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index 358d5e051c6ef..d11ec80d8f3e3 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -29,10 +29,9 @@ void LCToCPAssociatorByEnergyScoreProducerT::produce(edm::StreamID rhtools_->setGeometry(*geom); std::vector hits; - edm::Handle> hits_handle; for (unsigned i = 0; i < hits_token_.size(); ++i) { - iEvent.getByToken(hits_token_[i], hits_handle); + auto hits_handle = iEvent.getHandle(hits_token_[i]); // Check handle validity if (!hits_handle.isValid()) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index c55de0f0c7d7a..857f3e02ab9c4 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -29,10 +29,9 @@ void LCToSCAssociatorByEnergyScoreProducerT::produce(edm::StreamID rhtools_->setGeometry(*geom); std::vector hits; - edm::Handle> hits_handle; for (unsigned i = 0; i < hits_token_.size(); ++i) { - iEvent.getByToken(hits_token_[i], hits_handle); + auto hits_handle = iEvent.getHandle(hits_token_[i]); // Check handle validity if (!hits_handle.isValid()) { diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index dada1e841c769..3ef794f0ad8fa 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -419,8 +419,7 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, edm::MultiSpan rechitSpan; for (unsigned int i = 0; i < hits_tokens_.size(); ++i) { - Handle hitsHandle; - event.getByToken(hits_tokens_[i], hitsHandle); + auto hitsHandle = event.getHandle(hits_tokens_[i]); if (!hitsHandle.isValid()) { edm::LogWarning("MissingInput") << "Missing " << hits_labels_[i] << " handle."; From 37d810d34e2c35a2daa3d52f55365c5466c7491d Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Wed, 8 Oct 2025 18:39:02 +0200 Subject: [PATCH 18/22] Replace all label InputTags by strings. --- .../interface/BarrelValidator.h | 4 +-- .../interface/HGCalValidator.h | 4 +-- .../plugins/BarrelValidator.cc | 26 +++++++++---------- .../HGCalValidation/plugins/HGCalValidator.cc | 26 +++++++++---------- .../python/HLTHGCalPostProcessor_cff.py | 6 ++--- .../python/HLTHGCalValidator_cff.py | 2 +- .../python/PostProcessorBarrel_cfi.py | 4 +-- .../python/PostProcessorHGCAL_cfi.py | 6 ++--- .../HGCalValidation/python/hgcalPlots.py | 8 +++--- .../scripts/makeHGCalValidationPlots.py | 4 +-- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Validation/HGCalValidation/interface/BarrelValidator.h b/Validation/HGCalValidation/interface/BarrelValidator.h index eab608800ee0b..c1db75980b72c 100644 --- a/Validation/HGCalValidation/interface/BarrelValidator.h +++ b/Validation/HGCalValidation/interface/BarrelValidator.h @@ -74,9 +74,9 @@ class BarrelValidator : public DQMGlobalEDAnalyzer { const bool doCaloParticlePlots_; const bool doCaloParticleSelection_; const bool doSimClustersPlots_; - edm::InputTag label_SimClustersPlots_, label_SimClustersLevel_; + std::string label_SimClustersPlots_, label_SimClustersLevel_; const bool doLayerClustersPlots_; - edm::InputTag label_layerClustersPlots_, label_LCToCPLinking_; + std::string label_layerClustersPlots_, label_LCToCPLinking_; std::vector label_clustersmask; std::vector> labelToken; diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h index 5ca524986a181..4728ec9dada4c 100644 --- a/Validation/HGCalValidation/interface/HGCalValidator.h +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -85,9 +85,9 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { const bool doCaloParticlePlots_; const bool doCaloParticleSelection_; const bool doSimClustersPlots_; - edm::InputTag label_SimClustersPlots_, label_SimClustersLevel_; + std::string label_SimClustersPlots_, label_SimClustersLevel_; const bool doLayerClustersPlots_; - edm::InputTag label_layerClustersPlots_, label_LCToCPLinking_; + std::string label_layerClustersPlots_, label_LCToCPLinking_; const bool doTrackstersPlots_; std::string label_TS_, label_TSbyHitsCP_, label_TSbyHits_, label_TSbyLCsCP_, label_TSbyLCs_; std::vector label_clustersmask; diff --git a/Validation/HGCalValidation/plugins/BarrelValidator.cc b/Validation/HGCalValidation/plugins/BarrelValidator.cc index 02d56fbab9ec6..288634357536a 100644 --- a/Validation/HGCalValidation/plugins/BarrelValidator.cc +++ b/Validation/HGCalValidation/plugins/BarrelValidator.cc @@ -71,11 +71,11 @@ BarrelValidator::BarrelValidator(const edm::ParameterSet& pset) doCaloParticlePlots_(pset.getUntrackedParameter("doCaloParticlePlots")), doCaloParticleSelection_(pset.getUntrackedParameter("doCaloParticleSelection")), doSimClustersPlots_(pset.getUntrackedParameter("doSimClustersPlots")), - label_SimClustersPlots_(pset.getParameter("label_SimClusters")), - label_SimClustersLevel_(pset.getParameter("label_SimClustersLevel")), + label_SimClustersPlots_(pset.getParameter("label_SimClusters")), + label_SimClustersLevel_(pset.getParameter("label_SimClustersLevel")), doLayerClustersPlots_(pset.getUntrackedParameter("doLayerClustersPlots")), - label_layerClustersPlots_(pset.getParameter("label_layerClustersPlots")), - label_LCToCPLinking_(pset.getParameter("label_LCToCPLinking")), + label_layerClustersPlots_(pset.getParameter("label_layerClustersPlots")), + label_LCToCPLinking_(pset.getParameter("label_LCToCPLinking")), hits_labels_(pset.getParameter>("hits")), scToCpMapToken_( consumes(pset.getParameter("simClustersToCaloParticlesMap"))) { @@ -172,13 +172,13 @@ void BarrelValidator::bookHistograms(DQMStore::IBooker& ibook, //Booking histograms concerning with simClusters if (doSimClustersPlots_) { ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_SimClustersPlots_.label() + "/" + label_SimClustersLevel_.label()); + ibook.setCurrentFolder(dirName_ + label_SimClustersPlots_ + "/" + label_SimClustersLevel_); histoProducerAlgo_->bookSimClusterHistos(ibook, histograms.histoProducerAlgo, totallayers_to_monitor_); for (unsigned int ws = 0; ws < label_clustersmask.size(); ws++) { ibook.cd(); InputTag algo = label_clustersmask[ws]; - string dirName = dirName_ + label_SimClustersPlots_.label() + "/"; + string dirName = dirName_ + label_SimClustersPlots_ + "/"; if (!algo.process().empty()) dirName += algo.process() + "_"; LogDebug("BarrelValidator") << dirName << "\n"; @@ -204,15 +204,15 @@ void BarrelValidator::bookHistograms(DQMStore::IBooker& ibook, //Booking histograms concerning with hgcal layer clusters if (doLayerClustersPlots_) { ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_.label() + "/ClusterLevel"); + ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_ + "/ClusterLevel"); histoProducerAlgo_->bookClusterHistos_ClusterLevel(ibook, histograms.histoProducerAlgo, totallayers_to_monitor_); ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_.label() + "/" + label_LCToCPLinking_.label()); + ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_ + "/" + label_LCToCPLinking_); histoProducerAlgo_->bookClusterHistos_LCtoCP_association( ibook, histograms.histoProducerAlgo, totallayers_to_monitor_); ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_.label() + "/CellLevel"); + ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_ + "/CellLevel"); histoProducerAlgo_->bookClusterHistos_CellLevel(ibook, histograms.histoProducerAlgo, totallayers_to_monitor_); } } @@ -543,11 +543,11 @@ void BarrelValidator::fillDescriptions(edm::ConfigurationDescriptions& descripti desc.addUntracked("doCaloParticlePlots", true); desc.addUntracked("doCaloParticleSelection", true); desc.addUntracked("doSimClustersPlots", true); - desc.add("label_SimClusters", edm::InputTag("SimClusters")); - desc.add("label_SimClustersLevel", edm::InputTag("ClusterLevel")); + desc.add("label_SimClusters", "SimClusters"); + desc.add("label_SimClustersLevel", "ClusterLevel"); desc.addUntracked("doLayerClustersPlots", true); - desc.add("label_layerClustersPlots", edm::InputTag("LayerClusters")); - desc.add("label_LCToCPLinking", edm::InputTag("LCToCP_association")); + desc.add("label_layerClustersPlots", "LayerClusters"); + desc.add("label_LCToCPLinking", "LCToCP_association"); desc.add("simClustersToCaloParticlesMap", edm::InputTag("SimClusterToCaloParticleAssociation", "simClusterToCaloParticleMap")); desc.add("label_cp_effic", edm::InputTag("mix", "MergedCaloTruth")); diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 3ef794f0ad8fa..3b76f3cf77b66 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -81,11 +81,11 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) doCaloParticlePlots_(pset.getUntrackedParameter("doCaloParticlePlots")), doCaloParticleSelection_(pset.getUntrackedParameter("doCaloParticleSelection")), doSimClustersPlots_(pset.getUntrackedParameter("doSimClustersPlots")), - label_SimClustersPlots_(pset.getParameter("label_SimClusters")), - label_SimClustersLevel_(pset.getParameter("label_SimClustersLevel")), + label_SimClustersPlots_(pset.getParameter("label_SimClusters")), + label_SimClustersLevel_(pset.getParameter("label_SimClustersLevel")), doLayerClustersPlots_(pset.getUntrackedParameter("doLayerClustersPlots")), - label_layerClustersPlots_(pset.getParameter("label_layerClustersPlots")), - label_LCToCPLinking_(pset.getParameter("label_LCToCPLinking")), + label_layerClustersPlots_(pset.getParameter("label_layerClustersPlots")), + label_LCToCPLinking_(pset.getParameter("label_LCToCPLinking")), doTrackstersPlots_(pset.getUntrackedParameter("doTrackstersPlots")), label_TS_(pset.getParameter("label_TS")), label_TSbyHitsCP_(pset.getParameter("label_TSbyHitsCP")), @@ -233,14 +233,14 @@ void HGCalValidator::bookHistograms(DQMStore::IBooker& ibook, //Booking histograms concerning with simClusters if (doSimClustersPlots_) { ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_SimClustersPlots_.label() + "/" + label_SimClustersLevel_.label()); + ibook.setCurrentFolder(dirName_ + label_SimClustersPlots_ + "/" + label_SimClustersLevel_); histoProducerAlgo_->bookSimClusterHistos( ibook, histograms.histoProducerAlgo, totallayers_to_monitor_, thicknesses_to_monitor_); for (unsigned int ws = 0; ws < label_clustersmask.size(); ws++) { ibook.cd(); InputTag algo = label_clustersmask[ws]; - string dirName = dirName_ + label_SimClustersPlots_.label() + "/"; + string dirName = dirName_ + label_SimClustersPlots_ + "/"; if (!algo.process().empty()) dirName += algo.process() + "_"; LogDebug("HGCalValidator") << dirName << "\n"; @@ -267,19 +267,19 @@ void HGCalValidator::bookHistograms(DQMStore::IBooker& ibook, //Booking histograms concerning with hgcal layer clusters if (doLayerClustersPlots_) { ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_.label() + "/ClusterLevel"); + ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_ + "/ClusterLevel"); histoProducerAlgo_->bookClusterHistos_ClusterLevel(ibook, histograms.histoProducerAlgo, totallayers_to_monitor_, thicknesses_to_monitor_, cummatbudinxo_.fullPath()); ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_.label() + "/" + label_LCToCPLinking_.label()); + ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_ + "/" + label_LCToCPLinking_); histoProducerAlgo_->bookClusterHistos_LCtoCP_association( ibook, histograms.histoProducerAlgo, totallayers_to_monitor_); ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_.label() + "/CellLevel"); + ibook.setCurrentFolder(dirName_ + label_layerClustersPlots_ + "/CellLevel"); histoProducerAlgo_->bookClusterHistos_CellLevel( ibook, histograms.histoProducerAlgo, totallayers_to_monitor_, thicknesses_to_monitor_); } @@ -805,11 +805,11 @@ void HGCalValidator::fillDescriptions(edm::ConfigurationDescriptions& descriptio desc.addUntracked("doCaloParticlePlots", true); desc.addUntracked("doCaloParticleSelection", true); desc.addUntracked("doSimClustersPlots", true); - desc.add("label_SimClusters", edm::InputTag("SimClusters")); - desc.add("label_SimClustersLevel", edm::InputTag("ClusterLevel")); + desc.add("label_SimClusters", "SimClusters"); + desc.add("label_SimClustersLevel", "ClusterLevel"); desc.addUntracked("doLayerClustersPlots", true); - desc.add("label_layerClustersPlots", edm::InputTag("hgcalMergeLayerClusters")); - desc.add("label_LCToCPLinking", edm::InputTag("LCToCP_association")); + desc.add("label_layerClustersPlots", "LayerClusters"); + desc.add("label_LCToCPLinking", "LCToCP_association"); desc.addUntracked("doTrackstersPlots", true); desc.add("label_TS", "Morphology"); desc.add("label_TSbyHitsCP", "TSbyHits_CP"); diff --git a/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py b/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py index e4c909a6c3d8c..b5dc7722cc8ff 100644 --- a/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py +++ b/Validation/HGCalValidation/python/HLTHGCalPostProcessor_cff.py @@ -12,12 +12,12 @@ hltTracksterLabels = _hltTiclIterLabels.copy() hltTracksterLabels.extend(['hltTiclSimTracksters', 'hltTiclSimTracksters_fromCPs']) -hltLcToCP_linking = _hltHgcalValidator.label_LCToCPLinking._InputTag__moduleLabel +hltLcToCP_linking = _hltHgcalValidator.label_LCToCPLinking.value() hltPostProcessorHGCALlayerclusters = _postProcessorHGCALlayerclusters.clone( - subDirs = cms.untracked.vstring(hltPrefix + _hltHgcalValidator.label_layerClustersPlots._InputTag__moduleLabel + '/' + hltLcToCP_linking), + subDirs = cms.untracked.vstring(hltPrefix + _hltHgcalValidator.label_layerClustersPlots.value() + '/' + hltLcToCP_linking), ) -hltSubdirsSim = [hltPrefix + _hltHgcalValidator.label_SimClusters._InputTag__moduleLabel + '/'+iteration+'/' for iteration in hltTracksterLabels] +hltSubdirsSim = [hltPrefix + _hltHgcalValidator.label_SimClusters.value() + '/'+iteration+'/' for iteration in hltTracksterLabels] hltPostProcessorHGCALsimclusters = _postProcessorHGCALsimclusters.clone( subDirs = cms.untracked.vstring(hltSubdirsSim) ) diff --git a/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py b/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py index 3d39d0a61bcf9..3dc13b11e9729 100644 --- a/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py +++ b/Validation/HGCalValidation/python/HLTHGCalValidator_cff.py @@ -21,7 +21,7 @@ hits = cms.VInputTag("hltHGCalRecHit:HGCEERecHits", "hltHGCalRecHit:HGCHEFRecHits", "hltHGCalRecHit:HGCHEBRecHits"), hitMap = cms.InputTag("hltRecHitMapProducer","hgcalRecHitMap"), simTrackstersMap = cms.InputTag("hltTiclSimTracksters"), - label_layerClustersPlots = cms.InputTag("hltHgcalMergeLayerClusters"), + label_layerClustersPlots = cms.string("hltHgcalMergeLayerClusters"), label_lcl = cms.InputTag("hltMergeLayerClusters"), label_simTS = cms.InputTag("hltTiclSimTracksters"), label_simTSFromCP = cms.InputTag("hltTiclSimTracksters","fromCPs"), diff --git a/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py b/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py index 1d4fb3ba20d1f..173a8a71f43fa 100644 --- a/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py +++ b/Validation/HGCalValidation/python/PostProcessorBarrel_cfi.py @@ -15,9 +15,9 @@ eff_layers.extend(["merge_eta_layer_barrel{} 'LayerCluster Merge Rate vs #eta Layer{}' NumMerge_LayerCluster_Eta_perlayer_barrel{} Denom_LayerCluster_Eta_perlayer_barrel{}".format(i, i, i, i) for i in range(maxlayer)]) eff_layers.extend(["merge_phi_layer_barrel{} 'LayerCluster Merge Rate vs #phi Layer{}' NumMerge_LayerCluster_Phi_perlayer_barrel{} Denom_LayerCluster_Phi_perlayer_barrel{}".format(i, i, i, i) for i in range(maxlayer)]) -lcToCP_linking = barrelValidator.label_LCToCPLinking._InputTag__moduleLabel +lcToCP_linking = barrelValidator.label_LCToCPLinking.value() postProcessorBarrellayerclusters = DQMEDHarvester('DQMGenericClient', - subDirs = cms.untracked.vstring(prefix + barrelValidator.label_layerClustersPlots._InputTag__moduleLabel + '/' + lcToCP_linking), + subDirs = cms.untracked.vstring(prefix + barrelValidator.label_layerClustersPlots.value() + '/' + lcToCP_linking), efficiency = cms.vstring(eff_layers), resolution = cms.vstring(), cumulativeDists = cms.untracked.vstring(), diff --git a/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py b/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py index 52a7c4efbc750..dc4b7f7514905 100644 --- a/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py +++ b/Validation/HGCalValidation/python/PostProcessorHGCAL_cfi.py @@ -20,9 +20,9 @@ eff_layers.extend(["merge_eta_layer{:02d} 'LayerCluster Merge Rate vs #eta Layer{:02d} in z-' NumMerge_LayerCluster_Eta_perlayer{:02d} Denom_LayerCluster_Eta_perlayer{:02d}".format(i, i%maxlayerzm+1, i, i) if (i Date: Wed, 8 Oct 2025 18:39:41 +0200 Subject: [PATCH 19/22] Improve Barrel and HGCal RecHit producer logic. --- .../plugins/RecHitMapProducer.cc | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc index fe244b4fb7863..ac122c61ba1e2 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/RecHitMapProducer.cc @@ -72,30 +72,37 @@ void RecHitMapProducer::produce(edm::StreamID, edm::Event& evt, const edm::Event edm::LogWarning("HGCalRecHitMapProducer") << "One or more HGCal hit collections are unavailable. Returning an empty map."; evt.put(std::move(hitMapHGCal), "hgcalRecHitMap"); - - if (!hgcalOnly_) { - auto hitMapBarrel = std::make_unique(); - evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); + } else { + // TODO may be worth to avoid dependency on the order + // of the collections, maybe using a map + edm::MultiSpan rechitSpan; + rechitSpan.add(*ee_hits); + rechitSpan.add(*fh_hits); + rechitSpan.add(*bh_hits); + + for (unsigned int i = 0; i < rechitSpan.size(); ++i) { + const auto recHitDetId = rechitSpan[i].detid(); + hitMapHGCal->emplace(recHitDetId, i); } - return; + evt.put(std::move(hitMapHGCal), "hgcalRecHitMap"); } - evt.put(std::move(hitMapHGCal), "hgcalRecHitMap"); - if (!hgcalOnly_) { - auto hitMapBarrel = std::make_unique(); + if (hgcalOnly_) { + return; + } - assert(barrel_hits_token_.size() == 2); - const auto& ecal_hits = evt.getHandle(barrel_hits_token_[0]); - const auto& hbhe_hits = evt.getHandle(barrel_hits_token_[1]); + auto hitMapBarrel = std::make_unique(); - if (!ecal_hits.isValid() || !hbhe_hits.isValid()) { - edm::LogWarning("HGCalRecHitMapProducer") - << "One or more barrel hit collections are unavailable. Returning an empty map."; - evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); - return; - } + assert(barrel_hits_token_.size() == 2); + const auto& ecal_hits = evt.getHandle(barrel_hits_token_[0]); + const auto& hbhe_hits = evt.getHandle(barrel_hits_token_[1]); + if (!ecal_hits.isValid() || !hbhe_hits.isValid()) { + edm::LogWarning("HGCalRecHitMapProducer") + << "One or more barrel hit collections are unavailable. Returning an empty map."; + evt.put(std::move(hitMapBarrel), "barrelRecHitMap"); + } else { edm::MultiSpan barrelRechitSpan; barrelRechitSpan.add(evt.get(barrel_hits_token_[0])); barrelRechitSpan.add(evt.get(barrel_hits_token_[1])); From 2c6d1346262cd4742a26ef7667a34b321ae38bfe Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Wed, 8 Oct 2025 19:01:03 +0200 Subject: [PATCH 20/22] Remove superfluous new lines. --- .../plugins/LCToCPAssociatorByEnergyScoreProducer.cc | 2 +- .../plugins/LCToCPAssociatorEDProducer.cc | 2 +- .../plugins/LCToSCAssociatorByEnergyScoreProducer.cc | 4 ++-- .../plugins/LCToSCAssociatorEDProducer.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc index d11ec80d8f3e3..288969190b7e8 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorByEnergyScoreProducer.cc @@ -36,7 +36,7 @@ void LCToCPAssociatorByEnergyScoreProducerT::produce(edm::StreamID // Check handle validity if (!hits_handle.isValid()) { edm::LogWarning("LCToCPAssociatorByEnergyScoreProducer") - << "Hit collection not available for token " << hits_label_[i] << "\nSkipping this collection."; + << "Hit collection not available for token " << hits_label_[i] << ". Skipping this collection."; continue; // Skip invalid handle } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc index 41e6ca7265a6c..f8f06c5dc5df7 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc @@ -95,7 +95,7 @@ void LCToCPAssociatorEDProducerT::produce(edm::StreamID, // Protection against missing cluster collection if (!LCCollection.isValid()) { edm::LogWarning("LCToCPAssociatorEDProducerT") - << "CaloCluster collection with label " << label_lc << " is unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_lc << " is unavailable. Producing empty associations."; // Return empty collections auto emptyRecSimColl = std::make_unique>(); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 857f3e02ab9c4..57a8dcecccb9a 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -31,12 +31,12 @@ void LCToSCAssociatorByEnergyScoreProducerT::produce(edm::StreamID std::vector hits; for (unsigned i = 0; i < hits_token_.size(); ++i) { - auto hits_handle = iEvent.getHandle(hits_token_[i]); + auto hits_handle = iEvent.getHandle(hits_token_[i]); // Check handle validity if (!hits_handle.isValid()) { edm::LogWarning("LCToSCAssociatorByEnergyScoreProducer") - << "Hit collection not available for token \n " << hits_label_[i] << "\nSkipping this collection."; + << "Hit collection not available for token " << hits_label_[i] << ". Skipping this collection."; continue; // Skip invalid handle } diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc index 9f78728f7b044..96895f7ba3f27 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc @@ -96,7 +96,7 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, } if (!LCCollection.isValid()) { edm::LogWarning("LCToSCAssociatorEDProducer") - << "CaloCluster collection with label\n " << label_lcl << "\nis unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_lcl << " is unavailable. Producing empty associations."; // Return empty collections auto emptyRecSimColl = std::make_unique(); From b1e0b22e5226be77d43bc6931e1521cbe50a28d9 Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Thu, 9 Oct 2025 10:41:46 +0200 Subject: [PATCH 21/22] Replace return by continue. --- Validation/HGCalValidation/plugins/BarrelValidator.cc | 2 +- Validation/HGCalValidation/plugins/HGCalValidator.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Validation/HGCalValidation/plugins/BarrelValidator.cc b/Validation/HGCalValidation/plugins/BarrelValidator.cc index 288634357536a..3d73d7c435cc0 100644 --- a/Validation/HGCalValidation/plugins/BarrelValidator.cc +++ b/Validation/HGCalValidation/plugins/BarrelValidator.cc @@ -287,7 +287,7 @@ void BarrelValidator::dqmAnalyze(const edm::Event& event, if (!hitsHandle.isValid()) { edm::LogWarning("MissingInput") << "Missing " << hits_labels_[i] << " handle."; - return; + continue; } barrelRechitSpan.add(*hitsHandle); diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 3b76f3cf77b66..2ed59f9f7cf72 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -423,7 +423,7 @@ void HGCalValidator::dqmAnalyze(const edm::Event& event, if (!hitsHandle.isValid()) { edm::LogWarning("MissingInput") << "Missing " << hits_labels_[i] << " handle."; - return; + continue; } rechitSpan.add(*hitsHandle); From ea8d6258c520b88a043142ebd16cb4f7b4c93c9b Mon Sep 17 00:00:00 2001 From: Bruno Alves Date: Fri, 10 Oct 2025 11:58:09 +0200 Subject: [PATCH 22/22] Rebase onto CMSSW 16. --- .../plugins/LCToCPAssociatorEDProducer.cc | 8 +++++--- .../plugins/LCToSCAssociatorByEnergyScoreProducer.cc | 2 +- .../plugins/LCToSCAssociatorEDProducer.cc | 11 ++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc index f8f06c5dc5df7..1ab593840f0ca 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToCPAssociatorEDProducer.cc @@ -37,7 +37,7 @@ class LCToCPAssociatorEDProducerT : public edm::global::EDProducer<> { explicit LCToCPAssociatorEDProducerT(const edm::ParameterSet &); ~LCToCPAssociatorEDProducerT() override = default; - static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + // static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); @@ -60,7 +60,8 @@ LCToCPAssociatorEDProducerT::LCToCPAssociatorEDProducerT(const edm::Par CPCollectionToken_ = consumes(pset.getParameter("label_cp")); LCCollectionToken_ = consumes(label_lc); - associatorToken_ = consumes>(pset.getParameter("associator")); + associatorToken_ = + consumes>(pset.getParameter("associator")); } // @@ -95,7 +96,7 @@ void LCToCPAssociatorEDProducerT::produce(edm::StreamID, // Protection against missing cluster collection if (!LCCollection.isValid()) { edm::LogWarning("LCToCPAssociatorEDProducerT") - << "CaloCluster collection with label " << label_lc << " is unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_lc << " is unavailable. Producing empty associations."; // Return empty collections auto emptyRecSimColl = std::make_unique>(); @@ -120,6 +121,7 @@ void LCToCPAssociatorEDProducerT::produce(edm::StreamID, iEvent.put(std::move(str)); } +template void LCToCPAssociatorEDProducerT::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; desc.add("label_cp", edm::InputTag("mix", "MergedCaloTruth")); diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc index 57a8dcecccb9a..c3d90da83be95 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorByEnergyScoreProducer.cc @@ -31,7 +31,7 @@ void LCToSCAssociatorByEnergyScoreProducerT::produce(edm::StreamID std::vector hits; for (unsigned i = 0; i < hits_token_.size(); ++i) { - auto hits_handle = iEvent.getHandle(hits_token_[i]); + auto hits_handle = iEvent.getHandle(hits_token_[i]); // Check handle validity if (!hits_handle.isValid()) { diff --git a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc index 96895f7ba3f27..98529bcfd129b 100644 --- a/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc +++ b/SimCalorimetry/HGCalAssociatorProducers/plugins/LCToSCAssociatorEDProducer.cc @@ -54,7 +54,8 @@ LCToSCAssociatorEDProducerT::LCToSCAssociatorEDProducerT(const edm::Par LCCollectionToken_ = consumes(label_lcl); SCCollectionToken_ = consumes(label_scl); - associatorToken_ = consumes>(pset.getParameter("associator")); + associatorToken_ = + consumes>(pset.getParameter("associator")); } // @@ -92,15 +93,15 @@ void LCToSCAssociatorEDProducerT::produce(edm::StreamID, // Protections if (!SCCollection.isValid()) { edm::LogWarning("LCToSCAssociatorEDProducerT") - << "CaloCluster collection with label " << label_scl << " is unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_scl << " is unavailable. Producing empty associations."; } if (!LCCollection.isValid()) { edm::LogWarning("LCToSCAssociatorEDProducer") - << "CaloCluster collection with label " << label_lcl << " is unavailable. Producing empty associations."; + << "CaloCluster collection with label " << label_lcl << " is unavailable. Producing empty associations."; // Return empty collections - auto emptyRecSimColl = std::make_unique(); - auto emptySimRecColl = std::make_unique(); + auto emptyRecSimColl = std::make_unique>(); + auto emptySimRecColl = std::make_unique>(); iEvent.put(std::move(emptyRecSimColl)); iEvent.put(std::move(emptySimRecColl));