-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Set up HGCAL GPU vs CPU DQM #50974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cmsbuild
merged 1 commit into
cms-sw:master
from
fiemmi:ticl_dqm_GPUvsCPU_CMSSW_17_0_0_pre1
May 30, 2026
Merged
Set up HGCAL GPU vs CPU DQM #50974
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <library file="*.cc" name="DQMHGCAL_plugins"> | ||
| </library> | ||
| <use name="DQMServices/Core"/> | ||
| <use name="FWCore/Framework"/> | ||
| <use name="DataFormats/Candidate"/> | ||
| <use name="DataFormats/CaloRecHit"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| //============================================================================================================================ | ||
| // Class: HGCALGPUvsCPUComparisonHists -------------------------------------------------------------- | ||
| //---------------------------------------------------------------------------------------------------------------------------- | ||
| /**\class HGCALGPUvsCPUComparisonHists HGCALGPUvsCPUComparisonHists.cc DQM/HGCAL/plugins/HGCALGPUvsCPUComparisonHists.cc | ||
| ------------------------------------------------------------------------------------------------------------------------------ | ||
| Description: This class produces histograms to compare GPU- and CPU-based HGCAL reconstruction --- | ||
| ----------------------------------------------------------------------------------------------------------------------------- | ||
| Implementation: --- | ||
| This DQMEDAnalyzer is meant to be used with CMSSW >= 16_1_0 --- | ||
| */ | ||
| //======================================================================================== | ||
| // Authors: Fabio Iemmi (IHEP) --------------------- | ||
| // Created: TUE, 28 Apr 2026 16:05:28 GMT -------------------------------------- | ||
| //======================================================================================== | ||
|
|
||
| #include <string> | ||
| #include <unordered_map> | ||
| #include <utility> | ||
|
|
||
| #include "DataFormats/CaloRecHit/interface/CaloCluster.h" | ||
| #include "DataFormats/CaloRecHit/interface/CaloClusterCollection.h" | ||
| #include "DataFormats/Candidate/interface/Candidate.h" | ||
| #include "DQMServices/Core/interface/DQMEDAnalyzer.h" | ||
| #include "DQMServices/Core/interface/DQMStore.h" | ||
| #include "DQMServices/Core/interface/MonitorElement.h" | ||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
|
|
||
| class HGCALGPUvsCPUComparisonHists : public DQMEDAnalyzer { | ||
| public: | ||
| explicit HGCALGPUvsCPUComparisonHists(const edm::ParameterSet&); | ||
| ~HGCALGPUvsCPUComparisonHists() override = default; | ||
| static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
|
||
| protected: | ||
| void beginJob(const edm::EventSetup& iSetup); | ||
| void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override; | ||
| void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override; | ||
|
|
||
| private: | ||
| const edm::EDGetTokenT<reco::CaloClusterCollection> tokenMonitoredLayerClusters_; | ||
| const edm::EDGetTokenT<reco::CaloClusterCollection> tokenReferenceLayerClusters_; | ||
| const std::string topFolderName_; | ||
| MonitorElement* hLayerCluster_x; | ||
| MonitorElement* hLayerCluster_y; | ||
| MonitorElement* hLayerCluster_z; | ||
| MonitorElement* hLayerCluster_eta; | ||
| MonitorElement* hLayerCluster_phi; | ||
| MonitorElement* hLayerCluster_e; | ||
| MonitorElement* hLayerCluster_nRecHits; | ||
| MonitorElement* hLayerCluster2D_x; | ||
| MonitorElement* hLayerCluster2D_y; | ||
| MonitorElement* hLayerCluster2D_z; | ||
| MonitorElement* hLayerCluster2D_eta; | ||
| MonitorElement* hLayerCluster2D_phi; | ||
| MonitorElement* hLayerCluster2D_e; | ||
| MonitorElement* hLayerCluster2D_nRecHits; | ||
| }; | ||
|
|
||
| HGCALGPUvsCPUComparisonHists::HGCALGPUvsCPUComparisonHists(const edm::ParameterSet& iConfig) | ||
| : tokenMonitoredLayerClusters_( | ||
| consumes<reco::CaloClusterCollection>(iConfig.getParameter<edm::InputTag>("monitoredLayerClusters"))), | ||
| tokenReferenceLayerClusters_( | ||
| consumes<reco::CaloClusterCollection>(iConfig.getParameter<edm::InputTag>("referenceLayerClusters"))), | ||
| topFolderName_(iConfig.getParameter<std::string>("topFolderName")) {} | ||
|
|
||
| void HGCALGPUvsCPUComparisonHists::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
| edm::ParameterSetDescription desc; | ||
| desc.add<edm::InputTag>("monitoredLayerClusters", edm::InputTag("hltMergeLayerClusters")); | ||
| desc.add<edm::InputTag>("referenceLayerClusters", edm::InputTag("hltMergeLayerClustersSerialSync")); | ||
| desc.add<std::string>("topFolderName", "HLT/HeterogeneousComparisons/HGCalMonitoring"); | ||
| descriptions.addWithDefaultLabel(desc); | ||
| } | ||
|
|
||
| void HGCALGPUvsCPUComparisonHists::beginJob(const edm::EventSetup& iSetup) {} | ||
|
|
||
| void HGCALGPUvsCPUComparisonHists::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const&, edm::EventSetup const&) { | ||
| iBooker.setCurrentFolder(topFolderName_); | ||
| //For a given variable x, 1D plots store Delta(x), 2D plots show x_GPU vs x_CPU | ||
| //1D | ||
| hLayerCluster_x = iBooker.book1D("hLayerCluster_x", "hLayerCluster_x", 100, -0.01, 0.01); | ||
| hLayerCluster_y = iBooker.book1D("hLayerCluster_y", "hLayerCluster_y", 100, -0.01, 0.01); | ||
| hLayerCluster_z = iBooker.book1D("hLayerCluster_z", "hLayerCluster_z", 100, -0.01, 0.01); | ||
| hLayerCluster_eta = iBooker.book1D("hLayerCluster_eta", "hLayerCluster_eta", 100, -0.01, 0.01); | ||
| hLayerCluster_phi = iBooker.book1D("hLayerCluster_phi", "hLayerCluster_phi", 100, -0.01, 0.01); | ||
| hLayerCluster_e = iBooker.book1D("hLayerCluster_e", "hLayerCluster_e", 100, -0.01, 0.01); | ||
| hLayerCluster_nRecHits = iBooker.book1D("hLayerCluster_nRecHits", "hLayerCluster_nRecHits", 100, -0.01, 0.01); | ||
| //2D | ||
| hLayerCluster2D_x = iBooker.book2D("hLayerCluster2D_x", "hLayerCluster2D_x", 100, -50, 50, 100, -50, 50); | ||
| hLayerCluster2D_y = iBooker.book2D("hLayerCluster2D_y", "hLayerCluster2D_y", 100, -50, 50, 100, -50, 50); | ||
| hLayerCluster2D_z = iBooker.book2D("hLayerCluster2D_z", "hLayerCluster2D_z", 100, -500, 500, 100, -500, 500); | ||
| hLayerCluster2D_eta = iBooker.book2D("hLayerCluster2D_eta", "hLayerCluster2D_eta", 100, -3.5, 3.5, 100, -3.5, 3.5); | ||
| hLayerCluster2D_phi = iBooker.book2D("hLayerCluster2D_phi", "hLayerCluster2D_phi", 100, -3.5, 3.5, 100, -3.5, 3.5); | ||
| hLayerCluster2D_e = iBooker.book2D("hLayerCluster2D_e", "hLayerCluster2D_e", 100, 0, 30, 100, 0, 30); | ||
| hLayerCluster2D_nRecHits = | ||
| iBooker.book2D("hLayerCluster2D_nRecHits", "hLayerCluster2D_nRecHits", 60, 0, 60, 60, 0, 60); | ||
| } | ||
|
|
||
| void HGCALGPUvsCPUComparisonHists::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
| //Get monitored (GPU) and reference (CPU) LayerCluster collections | ||
| const auto& monitoredHandle = iEvent.getHandle(tokenMonitoredLayerClusters_); | ||
| const auto& referenceHandle = iEvent.getHandle(tokenReferenceLayerClusters_); | ||
| if (!monitoredHandle.isValid() || !referenceHandle.isValid()) { | ||
| edm::LogWarning("HGCALGPUvsCPUComparisonHists") << "Monitored or reference LayerCluster collection is invalid."; | ||
| return; | ||
| } | ||
| const reco::CaloClusterCollection& monitoredLayerClusters = *monitoredHandle; | ||
| const reco::CaloClusterCollection& referenceLayerClusters = *referenceHandle; | ||
|
|
||
| //look for GPU and CPU LayerClusters whose seeds match | ||
| //map LC seeds to LC indices for the reference collection | ||
| std::unordered_map<uint32_t, std::pair<unsigned, bool>> | ||
|
fiemmi marked this conversation as resolved.
|
||
| seedToIdx; //map seed of reference LC to index and wether or not it matches a monitored LC | ||
| seedToIdx.reserve(referenceLayerClusters.size()); | ||
| for (unsigned idx = 0; idx < referenceLayerClusters.size(); idx++) { | ||
| auto [it, inserted] = seedToIdx.try_emplace( | ||
| referenceLayerClusters[idx].seed(), idx, false); //initialze all reference LCs as unmatched | ||
| if (!inserted) { | ||
| edm::LogWarning("HGCALGPUvsCPUComparisonHists") << "Duplicate seed in reference collection."; | ||
| continue; | ||
| } | ||
| } | ||
| //look for matches in the monitored collection and, if any, fill histograms | ||
| for (unsigned i = 0; i < monitoredLayerClusters.size(); i++) { | ||
| const auto& monitored = monitoredLayerClusters[i]; | ||
| auto it = seedToIdx.find(monitored.seed()); | ||
| if (it != seedToIdx.end() && it->second.second == false) { | ||
| it->second.second = true; //establish a match | ||
| const auto& reference = referenceLayerClusters[it->second.first]; | ||
|
|
||
| hLayerCluster_x->Fill(monitored.x() - reference.x()); | ||
| hLayerCluster_y->Fill(monitored.y() - reference.y()); | ||
| hLayerCluster_z->Fill(monitored.z() - reference.z()); | ||
| hLayerCluster_eta->Fill(monitored.eta() - reference.eta()); | ||
| hLayerCluster_phi->Fill(monitored.phi() - reference.phi()); | ||
| hLayerCluster_e->Fill(monitored.energy() - reference.energy()); | ||
| hLayerCluster_nRecHits->Fill(monitored.size() - reference.size()); | ||
|
|
||
| hLayerCluster2D_x->Fill(reference.x(), monitored.x()); | ||
| hLayerCluster2D_y->Fill(reference.y(), monitored.y()); | ||
| hLayerCluster2D_z->Fill(reference.z(), monitored.z()); | ||
| hLayerCluster2D_eta->Fill(reference.eta(), monitored.eta()); | ||
| hLayerCluster2D_phi->Fill(reference.phi(), monitored.phi()); | ||
| hLayerCluster2D_e->Fill(reference.energy(), monitored.energy()); | ||
| hLayerCluster2D_nRecHits->Fill(reference.size(), monitored.size()); | ||
| } else { | ||
| edm::LogWarning("HGCALGPUvsCPUComparisonHists") << "No match or duplicate match to reference collection found."; | ||
| continue; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| DEFINE_FWK_MODULE(HGCALGPUvsCPUComparisonHists); | ||
7 changes: 7 additions & 0 deletions
7
HLTrigger/Configuration/python/HLT_75e33/modules/hltHGCALGPUvsCPUComparison_cfi.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| hltHGCALGPUvsCPUComparisonHists = cms.EDProducer("HGCALGPUvsCPUComparisonHists", | ||
| monitoredLayerClusters = cms.InputTag("hltMergeLayerClusters"), | ||
| referenceLayerClusters = cms.InputTag("hltMergeLayerClustersSerialSync"), | ||
| topFolderName = cms.string('HLT/HeterogeneousComparisons/HGCalMonitoring') | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
HLTrigger/Configuration/python/HLT_75e33/paths/DQM_HGCALHeterogeneousValidation_cfi.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| from ..sequences.HLTBeginSequence_cfi import * | ||
| from ..sequences.HLTDQMHGCALReconstruction_cfi import * | ||
| from .DQM_TRKHeterogeneousValidation_cfi import hltBackend,hltStatusOnGPUFilter | ||
|
|
||
| DQM_HGCALHeterogeneousValidation = cms.Path( | ||
| HLTBeginSequence | ||
| + hltBackend | ||
| + hltStatusOnGPUFilter | ||
| + HLTDQMHGCALReconstruction | ||
| ) |
13 changes: 13 additions & 0 deletions
13
HLTrigger/Configuration/python/HLT_75e33/sequences/HLTDQMHGCALReconstruction_cfi.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| from ..modules.hltHGCALGPUvsCPUComparison_cfi import * | ||
|
|
||
| # Empty sequence as a placeholder to be filled when alpakaValidationHLT is active | ||
| HLTDQMHGCALReconstruction = cms.Sequence() | ||
|
|
||
| from Configuration.ProcessModifiers.alpakaValidationHLT_cff import alpakaValidationHLT | ||
| alpakaValidationHLT.toReplaceWith(HLTDQMHGCALReconstruction, | ||
| cms.Sequence( | ||
| hltHGCALGPUvsCPUComparisonHists | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.