CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DQMMessageLogger Class Reference

#include <DQMMessageLogger.h>

Inheritance diagram for DQMMessageLogger:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 Get the analysis. More...
 
 DQMMessageLogger (const edm::ParameterSet &)
 Constructor. More...
 
 ~DQMMessageLogger () override
 Destructor. More...
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Protected Member Functions

void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 

Private Attributes

MonitorElementcategories_errors
 
std::vector< std::string > categories_vector
 
MonitorElementcategories_warnings
 
std::map< std::string, int > categoryECount
 
std::map< std::string, int > categoryMap
 
std::map< std::string, int > categoryWCount
 
std::string directoryName
 
edm::EDGetTokenT< std::vector
< edm::ErrorSummaryEntry > > 
errorSummary_
 
std::string metname
 
std::map< std::string, int > moduleMap
 
MonitorElementmodules_errors
 
MonitorElementmodules_warnings
 
MonitorElementtotal_errors
 
MonitorElementtotal_warnings
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr
< DQMEDAnalyzerGlobalCache
initializeGlobalCache (edm::ParameterSet const &)
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 17 of file DQMMessageLogger.h.

Constructor & Destructor Documentation

DQMMessageLogger::DQMMessageLogger ( const edm::ParameterSet parameters)

Constructor.

Definition at line 29 of file DQMMessageLogger.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

29  {
30  categories_errors = nullptr;
31  categories_warnings = nullptr;
32  modules_errors = nullptr;
33  modules_warnings = nullptr;
34  total_errors = nullptr;
35  total_warnings = nullptr;
36 
37  //Get from cfg file
38  categories_vector = parameters.getParameter<vector<string> >("Categories");
39  directoryName = parameters.getParameter<string>("Directory");
40  errorSummary_ = consumes<std::vector<edm::ErrorSummaryEntry> >(
41  parameters.getUntrackedParameter<std::string>("errorSummary", "logErrorHarvester"));
42 }
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * total_warnings
edm::EDGetTokenT< std::vector< edm::ErrorSummaryEntry > > errorSummary_
MonitorElement * total_errors
MonitorElement * modules_warnings
MonitorElement * categories_errors
std::string directoryName
std::vector< std::string > categories_vector
MonitorElement * modules_errors
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MonitorElement * categories_warnings
DQMMessageLogger::~DQMMessageLogger ( )
override

Destructor.

Definition at line 44 of file DQMMessageLogger.cc.

44  {
45  // Should the pointers be deleted?
46 }

Member Function Documentation

void DQMMessageLogger::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Get the analysis.

Reimplemented from DQMEDAnalyzer.

Definition at line 119 of file DQMMessageLogger.cc.

References category, alignCSCRings::e, edm::Event::getByToken(), edm::ELseverityLevel::getLevel(), mps_fire::i, edm::HandleBase::isValid(), LogTrace, metname, dqmiodumpmetadata::n, alignCSCRings::s, and w().

119  {
120  LogTrace(metname) << "[DQMMessageLogger] Analysis of event # ";
121 
122  // Take the ErrorSummaryEntry container
124  iEvent.getByToken(errorSummary_, errors);
125  // Check that errors is valid
126  if (!errors.isValid()) {
127  return;
128  }
129  // Compare severity level of error with ELseveritylevel instance el : "-e" should be the lowest error
130  ELseverityLevel el(ELseverityLevel::ELsev_error);
131 
132  // Find the total number of errors in iEvent
133  if (errors->empty()) {
134  if (total_errors != nullptr) {
135  total_errors->Fill(0);
136  }
137  if (total_warnings != nullptr) {
138  total_warnings->Fill(0);
139  }
140  } else {
141  int e = 0;
142  int w = 0;
143  for (int i = 0, n = errors->size(); i < n; i++) {
144  if ((*errors)[i].severity.getLevel() < el.getLevel()) {
145  w += (*errors)[i].count;
146  } else {
147  e += (*errors)[i].count;
148  }
149  }
150  if (total_errors != nullptr) {
151  total_errors->Fill(e);
152  }
153  if (total_warnings != nullptr) {
154  total_warnings->Fill(w);
155  }
156  }
157 
158  for (int i = 0, n = errors->size(); i < n; i++) {
159  //cout << "Severity for error/warning: " << (*errors)[i].severity << " " <<(*errors)[i].module << endl;
160 
161  if (!errors->empty()) {
162  // IF THIS IS AN ERROR on the ELseverityLevel SCALE, FILL ERROR HISTS
163  if ((*errors)[i].severity.getLevel() >= el.getLevel()) {
164  if (categories_errors != nullptr) {
165  auto it = categoryMap.find((*errors)[i].category);
166  if (it != categoryMap.end()) {
167  // FILL THE RIGHT BIN
168  categories_errors->Fill((*it).second - 1, (*errors)[i].count);
169  }
170  }
171  // if (categoryECount.size()<=40)
172  // categoryECount[(*errors)[i].category]+=(*errors)[i].count;
173 
174  if (modules_errors != nullptr) {
175  // remove the first part of the module string, what is before ":"
176  string s = (*errors)[i].module;
177  size_t pos = s.find(':');
178  string s_temp = s.substr(pos + 1, s.size());
179  auto it = moduleMap.find(s_temp);
180  if (it != moduleMap.end()) {
181  // FILL THE RIGHT BIN
182  modules_errors->Fill((*it).second - 1, (*errors)[i].count);
183  }
184  }
185  // IF ONLY WARNING, FILL WARNING HISTS
186  } else {
187  if (categories_warnings != nullptr) {
188  auto it = categoryMap.find((*errors)[i].category);
189  if (it != categoryMap.end()) {
190  // FILL THE RIGHT BIN
191  categories_warnings->Fill((*it).second - 1, (*errors)[i].count);
192  }
193  }
194 
195  // if (categoryWCount.size()<=40)
196  // categoryWCount[(*errors)[i].category]+=(*errors)[i].count;
197 
198  if (modules_warnings != nullptr) {
199  // remove the first part of the module string, what is before ":"
200  string s = (*errors)[i].module;
201  size_t pos = s.find(':');
202  string s_temp = s.substr(pos + 1, s.size());
203  auto it = moduleMap.find(s_temp);
204  if (it != moduleMap.end()) {
205  // FILL THE RIGHT BIN
206  modules_warnings->Fill((*it).second - 1, (*errors)[i].count);
207  }
208  }
209  }
210  }
211  }
212 }
std::map< std::string, int > categoryMap
std::string metname
MonitorElement * total_warnings
static const char category[]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< std::vector< edm::ErrorSummaryEntry > > errorSummary_
MonitorElement * total_errors
MonitorElement * modules_warnings
MonitorElement * categories_errors
#define LogTrace(id)
void Fill(long long x)
std::map< std::string, int > moduleMap
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * modules_errors
MonitorElement * categories_warnings
T w() const
void DQMMessageLogger::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 48 of file DQMMessageLogger.cc.

References dqm::implementation::IBooker::book1D(), mps_fire::i, isotrackApplyRegressor::k, LogTrace, metname, hlt_dqm_clientPB-live_cfg::nbins, submitPVResolutionJobs::out, alignCSCRings::s, dqm::impl::MonitorElement::setBinLabel(), dqm::implementation::NavigatorBase::setCurrentFolder(), and edm::tns().

48  {
49  metname = "errorAnalyzer";
50 
51  // MAKE CATEGORYMAP USING INPUT FROM CFG FILE
52  for (unsigned int i = 0; i < categories_vector.size(); i++) {
53  categoryMap.insert(pair<string, int>(categories_vector[i], i + 1));
54  }
55 
56  // MAKE MODULEMAP
58  using stringvec = vector<std::string>;
59  TNS tns;
60  stringvec const& trigpaths = tns->getTrigPaths();
61 
62  for (auto const& trigpath : trigpaths) {
63  stringvec strings = tns->getTrigPathModules(trigpath);
64 
65  for (auto& k : strings) {
66  moduleMap.insert(pair<string, int>(k, moduleMap.size() + 1));
67  }
68  }
69 
70  // BOOK THE HISTOGRAMS
71  LogTrace(metname) << "[DQMMessageLogger] Parameters initialization";
72 
73  if (!moduleMap.empty()) {
74  ibooker.setCurrentFolder(directoryName + "/Errors");
75  modules_errors = ibooker.book1D("modules_errors", "Errors per module", moduleMap.size(), 0, moduleMap.size());
76  ibooker.setCurrentFolder(directoryName + "/Warnings");
77 
78  modules_warnings = ibooker.book1D("modules_warnings", "Warnings per module", moduleMap.size(), 0, moduleMap.size());
79 
80  for (auto it = moduleMap.begin(); it != moduleMap.end(); ++it) {
81  modules_errors->setBinLabel((*it).second, (*it).first);
82  modules_warnings->setBinLabel((*it).second, (*it).first);
83  }
84  modules_errors->getTH1()->GetXaxis()->LabelsOption("v");
85  modules_warnings->getTH1()->GetXaxis()->LabelsOption("v");
86  }
87 
88  if (!categoryMap.empty()) {
89  ibooker.setCurrentFolder(directoryName + "/Errors");
91  ibooker.book1D("categories_errors", "Errors per category", categoryMap.size(), 0, categoryMap.size());
92  ibooker.setCurrentFolder(directoryName + "/Warnings");
94  ibooker.book1D("categories_warnings", "Warnings per category", categoryMap.size(), 0, categoryMap.size());
95 
96  for (auto it = categoryMap.begin(); it != categoryMap.end(); ++it) {
97  categories_errors->setBinLabel((*it).second, (*it).first);
98  categories_warnings->setBinLabel((*it).second, (*it).first);
99  }
100  categories_warnings->getTH1()->GetXaxis()->LabelsOption("v");
101  categories_errors->getTH1()->GetXaxis()->LabelsOption("v");
102  }
103 
104  // HOW MANY BINS SHOULD THE ERROR HIST HAVE?
105  int nbins = 11;
106  total_warnings = ibooker.book1D("total_warnings", "Total warnings per event", nbins, -0.5, nbins + 0.5);
107  ibooker.setCurrentFolder(directoryName + "/Errors");
108  total_errors = ibooker.book1D("total_errors", "Total errors per event", nbins, -0.5, nbins + 0.5);
109 
110  for (int i = 0; i < nbins; ++i) {
111  stringstream out;
112  out << i;
113  string s = out.str();
114  total_errors->setBinLabel(i + 1, s);
115  total_warnings->setBinLabel(i + 1, s);
116  }
117 }
std::map< std::string, int > categoryMap
pathNames_ & tns()), endPathNames_(&tns.getEndPaths()), wantSummary_(tns.wantSummary()
Definition: Schedule.cc:691
std::string metname
MonitorElement * total_warnings
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
MonitorElement * total_errors
MonitorElement * modules_warnings
MonitorElement * categories_errors
#define LogTrace(id)
std::string directoryName
std::map< std::string, int > moduleMap
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::vector< std::string > categories_vector
MonitorElement * modules_errors
MonitorElement * categories_warnings
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98

Member Data Documentation

MonitorElement* DQMMessageLogger::categories_errors
private

Definition at line 47 of file DQMMessageLogger.h.

std::vector<std::string> DQMMessageLogger::categories_vector
private

Definition at line 42 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::categories_warnings
private

Definition at line 48 of file DQMMessageLogger.h.

std::map<std::string, int> DQMMessageLogger::categoryECount
private

Definition at line 40 of file DQMMessageLogger.h.

std::map<std::string, int> DQMMessageLogger::categoryMap
private

Definition at line 38 of file DQMMessageLogger.h.

std::map<std::string, int> DQMMessageLogger::categoryWCount
private

Definition at line 39 of file DQMMessageLogger.h.

std::string DQMMessageLogger::directoryName
private

Definition at line 43 of file DQMMessageLogger.h.

edm::EDGetTokenT<std::vector<edm::ErrorSummaryEntry> > DQMMessageLogger::errorSummary_
private

Definition at line 44 of file DQMMessageLogger.h.

std::string DQMMessageLogger::metname
private

Definition at line 35 of file DQMMessageLogger.h.

std::map<std::string, int> DQMMessageLogger::moduleMap
private

Definition at line 37 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::modules_errors
private

Definition at line 49 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::modules_warnings
private

Definition at line 50 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::total_errors
private

Definition at line 51 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::total_warnings
private

Definition at line 52 of file DQMMessageLogger.h.