From ecc4d6206f5d169d68fe3f98c14804193f890b99 Mon Sep 17 00:00:00 2001 From: mmusich Date: Thu, 14 Sep 2023 17:37:02 +0200 Subject: [PATCH] add protection against missing input collections in Phase2IT{OT}MonitorCluster --- DQM/SiTrackerPhase2/plugins/Phase2ITMonitorCluster.cc | 6 ++++++ DQM/SiTrackerPhase2/plugins/Phase2OTMonitorCluster.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/DQM/SiTrackerPhase2/plugins/Phase2ITMonitorCluster.cc b/DQM/SiTrackerPhase2/plugins/Phase2ITMonitorCluster.cc index 54d7ab6e8d1d0..f58172a12aa5a 100644 --- a/DQM/SiTrackerPhase2/plugins/Phase2ITMonitorCluster.cc +++ b/DQM/SiTrackerPhase2/plugins/Phase2ITMonitorCluster.cc @@ -102,6 +102,12 @@ void Phase2ITMonitorCluster::dqmBeginRun(const edm::Run& iRun, const edm::EventS void Phase2ITMonitorCluster::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { // Getting the clusters const auto& itPixelClusterHandle = iEvent.getHandle(itPixelClusterToken_); + + if (!itPixelClusterHandle.isValid()) { + edm::LogWarning("Phase2ITMonitorCluster") << "No SiPixelCluster Collection found in the event. Skipping!"; + return; + } + // Number of clusters std::map nClsmap; unsigned int nclusGlobal = 0; diff --git a/DQM/SiTrackerPhase2/plugins/Phase2OTMonitorCluster.cc b/DQM/SiTrackerPhase2/plugins/Phase2OTMonitorCluster.cc index 9c890fe79b52e..8b190388aba3b 100644 --- a/DQM/SiTrackerPhase2/plugins/Phase2OTMonitorCluster.cc +++ b/DQM/SiTrackerPhase2/plugins/Phase2OTMonitorCluster.cc @@ -105,6 +105,12 @@ void Phase2OTMonitorCluster::dqmBeginRun(const edm::Run& iRun, const edm::EventS void Phase2OTMonitorCluster::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { // Getting the clusters const auto& clusterHandle = iEvent.getHandle(clustersToken_); + + if (!clusterHandle.isValid()) { + edm::LogWarning("Phase2OTMonitorCluster") << "No Phase2TrackerCluster1D Collection found in the event. Skipping!"; + return; + } + // Number of clusters std::map nClustersCounter_P; //map of detidkey vs #cls std::map nClustersCounter_S; //map of detidkey vs #cls