From 6ec2b12513fdf8c604229b4c2254b0b3db826e87 Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Fri, 22 Sep 2023 22:17:57 +0200 Subject: [PATCH] Prevent using getByToken on EcalRawData when skipped and not consumed --- DQM/EcalMonitorTasks/interface/EcalDQMonitorTask.h | 10 +++++++++- DQM/EcalMonitorTasks/plugins/EcalDQMonitorTask.cc | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/DQM/EcalMonitorTasks/interface/EcalDQMonitorTask.h b/DQM/EcalMonitorTasks/interface/EcalDQMonitorTask.h index 0dce5fe264334..b9e753f30a0dc 100644 --- a/DQM/EcalMonitorTasks/interface/EcalDQMonitorTask.h +++ b/DQM/EcalMonitorTasks/interface/EcalDQMonitorTask.h @@ -46,8 +46,16 @@ class EcalDQMonitorTask : public DQMOneEDAnalyzer> schedule_; // schedule of collections to run + std::vector skipCollections_; // list of collections to explicitly remove from schedule - bool allowMissingCollections_; // when true, skip missing collections and log as warning + // note: skipping a collection here will result in + // EcalDQMonitorTask not consuming it, which may lead the + // module producing the collection to not run at all + + bool allowMissingCollections_; // when true (default), skip missing collections and log as warning + // note: collections skipped by the parameter skipCollections will + // bypass this check and not issue warnings + int processedEvents_; /* TASK TIME PROFILING */ diff --git a/DQM/EcalMonitorTasks/plugins/EcalDQMonitorTask.cc b/DQM/EcalMonitorTasks/plugins/EcalDQMonitorTask.cc index b873b19ef1ce1..c52e862b2b23d 100644 --- a/DQM/EcalMonitorTasks/plugins/EcalDQMonitorTask.cc +++ b/DQM/EcalMonitorTasks/plugins/EcalDQMonitorTask.cc @@ -160,8 +160,15 @@ void EcalDQMonitorTask::analyze(edm::Event const& _evt, edm::EventSetup const& _ std::set enabledTasks; + bool eventTypeFiltering(false); edm::Handle dcchsHndl; - if (_evt.getByToken(collectionTokens_[ecaldqm::kEcalRawData], dcchsHndl)) { + + if (std::find(skipCollections_.begin(), skipCollections_.end(), "EcalRawData") != skipCollections_.end()) { + if (verbosity_ > 2) + edm::LogInfo("EcalDQM") << "EcalRawDataCollection is being skipped. No event-type filtering will be applied"; + + } else if (_evt.getByToken(collectionTokens_[ecaldqm::kEcalRawData], dcchsHndl)) { + eventTypeFiltering = true; // determine event type (called run type in DCCHeader for some reason) for each FED std::stringstream ss; if (verbosity_ > 2) @@ -194,9 +201,11 @@ void EcalDQMonitorTask::analyze(edm::Event const& _evt, edm::EventSetup const& _ return; } else { edm::LogWarning("EcalDQM") << "EcalRawDataCollection does not exist. No event-type filtering will be applied"; - executeOnWorkers_([&enabledTasks](ecaldqm::DQWorker* worker) { enabledTasks.insert(worker); }, ""); } + if (!eventTypeFiltering) + executeOnWorkers_([&enabledTasks](ecaldqm::DQWorker* worker) { enabledTasks.insert(worker); }, ""); + ++processedEvents_; // start event processing