From 1eb2106eb196ac829c25806e871a9a088134c43d Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 18 Jun 2024 14:30:32 +0200 Subject: [PATCH 1/2] DQMEventInfo: add the possibility to register the GlobalTag (as it is done by DQMProvInfo --- .../Components/plugins/DQMEventInfo.cc | 80 ++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/DQMServices/Components/plugins/DQMEventInfo.cc b/DQMServices/Components/plugins/DQMEventInfo.cc index b8c67660bfddf..2cea3a97adf6b 100644 --- a/DQMServices/Components/plugins/DQMEventInfo.cc +++ b/DQMServices/Components/plugins/DQMEventInfo.cc @@ -5,13 +5,15 @@ * */ #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h" -#include "FWCore/Framework/interface/LuminosityBlock.h" -#include "FWCore/Version/interface/GetReleaseVersion.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/Run.h" +#include "FWCore/Framework/interface/LuminosityBlock.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/Run.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Version/interface/GetReleaseVersion.h" #include #include @@ -37,12 +39,19 @@ class DQMEventInfo : public DQMOneEDAnalyzer<> { /// Destructor ~DQMEventInfo() override = default; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + protected: /// Analyze void analyze(const edm::Event& e, const edm::EventSetup& c) override; void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; + void analyzeProvInfo(const edm::Event& e); private: + std::string globalTag_; + bool globalTagRetrieved_; + bool showHLTGlobalTag_; + std::string eventInfoFolder_; std::string subsystemname_; @@ -76,6 +85,7 @@ class DQMEventInfo : public DQMOneEDAnalyzer<> { MonitorElement* processName_; ///DQM "name" of the job (eg, Hcal or DT) MonitorElement* workingDir_; ///Current working directory of the job MonitorElement* cmsswVer_; ///CMSSW version run for this job + MonitorElement* versGlobaltag_; ///GlobalTag name MonitorElement* dqmPatch_; ///DQM patch version for this job MonitorElement* errSummary_; ///Subdetector-specific error summary (float) MonitorElement* errSummaryEtaPhi_; ///Subdetector-specific etaPhi summary (float) @@ -97,6 +107,7 @@ DQMEventInfo::DQMEventInfo(const edm::ParameterSet& ps) { lastAvgTime_ = currentTime_ = stampToReal(now); // read config parms + showHLTGlobalTag_ = ps.getUntrackedParameter("showHLTGlobalTag", false); std::string folder = ps.getUntrackedParameter("eventInfoFolder", "EventInfo"); subsystemname_ = ps.getUntrackedParameter("subSystemFolder", "YourSubsystem"); @@ -104,6 +115,10 @@ DQMEventInfo::DQMEventInfo(const edm::ParameterSet& ps) { evtRateWindow_ = ps.getUntrackedParameter("eventRateWindow", 0.5); if (evtRateWindow_ <= 0.15) evtRateWindow_ = 0.15; + + // Initialization of the global tag + globalTag_ = "MODULE::DEFAULT"; // default + globalTagRetrieved_ = false; // set as soon as retrieved from first event } void DQMEventInfo::bookHistograms(DQMStore::IBooker& ibooker, @@ -150,6 +165,9 @@ void DQMEventInfo::bookHistograms(DQMStore::IBooker& ibooker, free(pwd); cmsswVer_ = ibooker.bookString("CMSSW_Version", edm::getReleaseVersion()); + // Element: Globaltag + versGlobaltag_ = ibooker.bookString("Globaltag", globalTag_); + // Folder to be populated by sub-systems' code std::string subfolder = eventInfoFolder_ + "/reportSummaryContents"; ibooker.setCurrentFolder(subfolder); @@ -207,8 +225,64 @@ void DQMEventInfo::analyze(const edm::Event& e, const edm::EventSetup& c) { lastAvgTime_ = currentTime_; } + analyzeProvInfo(e); + return; } +void DQMEventInfo::analyzeProvInfo(const edm::Event& event) { + // Only trying to retrieve the global tag for the first event we ever + // encounter. + if (!globalTagRetrieved_) { + // Initialize processName to an empty string + std::string processName; + + if (showHLTGlobalTag_) { + // Getting all process names + std::vector pnames; + for (const auto& p : event.processHistory()) { + pnames.push_back(p.processName()); + } + + // Iterate through the process names in reverse to find the last one that contains "HLT" + for (auto it = pnames.rbegin(); it != pnames.rend(); ++it) { + if (it->find("HLT") != std::string::npos) { + processName = *it; + break; // Exit the loop once the last matching process name is found + } + } + + // Print the process name containing "HLT" + if (processName.empty()) { + edm::LogError("DQMEventInfo") << "Could not find any processName containing 'HLT' even if 'showHLTGlobalTag' " + "was chosen.\n Falling back to current processing!" + << std::endl; + processName = event.processHistory()[event.processHistory().size() - 1].processName(); + } + } else { + processName = event.processHistory()[event.processHistory().size() - 1].processName(); + } + + // Getting parameters for that process + edm::ParameterSet ps; + event.getProcessParameterSet(processName, ps); + // Getting the global tag + globalTag_ = ps.getParameterSet("PoolDBESSource@GlobalTag").getParameter("globaltag"); + + versGlobaltag_->Fill(globalTag_); + // Finaly: Setting globalTagRetrieved_ to true, since we got it now + globalTagRetrieved_ = true; + } +} + +void DQMEventInfo::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.addUntracked("showHLTGlobalTag", false); + desc.addUntracked("eventInfoFolder", "EventInfo"); + desc.addUntracked("subSystemFolder", "YourSubsystem"); + desc.addUntracked("eventRateWindow", 0.5); + descriptions.addWithDefaultLabel(desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(DQMEventInfo); From ad77ac57b48e763388f67dcd72c466edb70d561e Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 18 Jun 2024 14:31:20 +0200 Subject: [PATCH 2/2] make dqmEnvHLT and dqmInfoHLTMon show the last HLT processing GlobalTag --- DQMOffline/Trigger/python/DQMOffline_Trigger_cff.py | 9 +++++---- DQMServices/Components/python/DQMEventInfo_cfi.py | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DQMOffline/Trigger/python/DQMOffline_Trigger_cff.py b/DQMOffline/Trigger/python/DQMOffline_Trigger_cff.py index 29f980122932e..7c983ad0e4215 100644 --- a/DQMOffline/Trigger/python/DQMOffline_Trigger_cff.py +++ b/DQMOffline/Trigger/python/DQMOffline_Trigger_cff.py @@ -106,12 +106,13 @@ import DQMServices.Components.DQMEnvironment_cfi dqmEnvHLT = DQMServices.Components.DQMEnvironment_cfi.dqmEnv.clone( - subSystemFolder = 'HLT' -) + subSystemFolder = 'HLT', + showHLTGlobalTag = True) + from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer dqmInfoHLTMon = DQMEDAnalyzer('DQMEventInfo', - subSystemFolder = cms.untracked.string('HLT') -) + subSystemFolder = cms.untracked.string('HLT'), + showHLTGlobalTag = cms.untracked.bool(True)) ################################################################################################### #### SEQUENCES TO BE RUN depending on the input DATAFORMAT ## on MiniAOD diff --git a/DQMServices/Components/python/DQMEventInfo_cfi.py b/DQMServices/Components/python/DQMEventInfo_cfi.py index b5d0f44947d14..c7c25568bbe27 100644 --- a/DQMServices/Components/python/DQMEventInfo_cfi.py +++ b/DQMServices/Components/python/DQMEventInfo_cfi.py @@ -8,6 +8,8 @@ # set the window for eventrate calculation (in minutes) eventRateWindow = cms.untracked.double(0.5), # define folder to store event info (default: EventInfo) - eventInfoFolder = cms.untracked.string('EventInfo') + eventInfoFolder = cms.untracked.string('EventInfo'), + # use the Global Tag of the last (!) HLT processing + showHLTGlobalTag = cms.untracked.bool(True) )