CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
DQMMessageLogger Class Reference
Inheritance diagram for DQMMessageLogger:

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 Get the analysis. More...
 
 DQMMessageLogger (const edm::ParameterSet &)
 Constructor. More...
 
 ~DQMMessageLogger () override=default
 Destructor. More...
 

Protected Member Functions

void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 

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
 

Detailed Description

Definition at line 29 of file DQMMessageLogger.cc.

Constructor & Destructor Documentation

◆ DQMMessageLogger()

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

Constructor.

Definition at line 67 of file DQMMessageLogger.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

67  {
68  categories_errors = nullptr;
69  categories_warnings = nullptr;
70  modules_errors = nullptr;
71  modules_warnings = nullptr;
72  total_errors = nullptr;
73  total_warnings = nullptr;
74 
75  //Get from cfg file
76  categories_vector = parameters.getParameter<vector<string> >("Categories");
77  directoryName = parameters.getParameter<string>("Directory");
78  errorSummary_ = consumes<std::vector<edm::ErrorSummaryEntry> >(
79  parameters.getUntrackedParameter<std::string>("errorSummary", "logErrorHarvester"));
80 }
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
MonitorElement * categories_warnings

◆ ~DQMMessageLogger()

DQMMessageLogger::~DQMMessageLogger ( )
overridedefault

Destructor.

Member Function Documentation

◆ analyze()

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

Get the analysis.

Definition at line 153 of file DQMMessageLogger.cc.

References taus_updatedMVAIds_cff::category, MillePedeFileConverter_cfg::e, debug_messages_cfi::errors, edm::ELseverityLevel::getLevel(), mps_fire::i, iEvent, LogTrace, metname, dqmiodumpmetadata::n, alignCSCRings::s, and w().

153  {
154  LogTrace(metname) << "[DQMMessageLogger] Analysis of event # ";
155 
156  // Take the ErrorSummaryEntry container
158  iEvent.getByToken(errorSummary_, errors);
159  // Check that errors is valid
160  if (!errors.isValid()) {
161  return;
162  }
163  // Compare severity level of error with ELseveritylevel instance el : "-e" should be the lowest error
164  ELseverityLevel el(ELseverityLevel::ELsev_error);
165 
166  // Find the total number of errors in iEvent
167  if (errors->empty()) {
168  if (total_errors != nullptr) {
169  total_errors->Fill(0);
170  }
171  if (total_warnings != nullptr) {
172  total_warnings->Fill(0);
173  }
174  } else {
175  int e = 0;
176  int w = 0;
177  for (int i = 0, n = errors->size(); i < n; i++) {
178  if ((*errors)[i].severity.getLevel() < el.getLevel()) {
179  w += (*errors)[i].count;
180  } else {
181  e += (*errors)[i].count;
182  }
183  }
184  if (total_errors != nullptr) {
185  total_errors->Fill(e);
186  }
187  if (total_warnings != nullptr) {
189  }
190  }
191 
192  for (int i = 0, n = errors->size(); i < n; i++) {
193  //cout << "Severity for error/warning: " << (*errors)[i].severity << " " <<(*errors)[i].module << endl;
194 
195  if (!errors->empty()) {
196  // IF THIS IS AN ERROR on the ELseverityLevel SCALE, FILL ERROR HISTS
197  if ((*errors)[i].severity.getLevel() >= el.getLevel()) {
198  if (categories_errors != nullptr) {
199  auto it = categoryMap.find((*errors)[i].category);
200  if (it != categoryMap.end()) {
201  // FILL THE RIGHT BIN
202  categories_errors->Fill((*it).second - 1, (*errors)[i].count);
203  }
204  }
205  // if (categoryECount.size()<=40)
206  // categoryECount[(*errors)[i].category]+=(*errors)[i].count;
207 
208  if (modules_errors != nullptr) {
209  // remove the first part of the module string, what is before ":"
210  string s = (*errors)[i].module;
211  size_t pos = s.find(':');
212  string s_temp = s.substr(pos + 1, s.size());
213  auto it = moduleMap.find(s_temp);
214  if (it != moduleMap.end()) {
215  // FILL THE RIGHT BIN
216  modules_errors->Fill((*it).second - 1, (*errors)[i].count);
217  }
218  }
219  // IF ONLY WARNING, FILL WARNING HISTS
220  } else {
221  if (categories_warnings != nullptr) {
222  auto it = categoryMap.find((*errors)[i].category);
223  if (it != categoryMap.end()) {
224  // FILL THE RIGHT BIN
225  categories_warnings->Fill((*it).second - 1, (*errors)[i].count);
226  }
227  }
228 
229  // if (categoryWCount.size()<=40)
230  // categoryWCount[(*errors)[i].category]+=(*errors)[i].count;
231 
232  if (modules_warnings != nullptr) {
233  // remove the first part of the module string, what is before ":"
234  string s = (*errors)[i].module;
235  size_t pos = s.find(':');
236  string s_temp = s.substr(pos + 1, s.size());
237  auto it = moduleMap.find(s_temp);
238  if (it != moduleMap.end()) {
239  // FILL THE RIGHT BIN
240  modules_warnings->Fill((*it).second - 1, (*errors)[i].count);
241  }
242  }
243  }
244  }
245  }
246 }
std::map< std::string, int > categoryMap
MonitorElement * total_warnings
T w() const
edm::EDGetTokenT< std::vector< edm::ErrorSummaryEntry > > errorSummary_
MonitorElement * total_errors
MonitorElement * modules_warnings
MonitorElement * categories_errors
#define LogTrace(id)
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:224
std::map< std::string, int > moduleMap
MonitorElement * modules_errors
MonitorElement * categories_warnings
Definition: errors.py:1

◆ bookHistograms()

void DQMMessageLogger::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprotected

Definition at line 82 of file DQMMessageLogger.cc.

References dqm::implementation::IBooker::book1D(), mps_fire::i, dqmdumpme::k, LogTrace, metname, LaserClient_cfi::nbins, MillePedeFileConverter_cfg::out, alignCSCRings::s, dqm::impl::MonitorElement::setBinLabel(), dqm::implementation::NavigatorBase::setCurrentFolder(), and nano_cff::strings.

82  {
83  metname = "errorAnalyzer";
84 
85  // MAKE CATEGORYMAP USING INPUT FROM CFG FILE
86  for (unsigned int i = 0; i < categories_vector.size(); i++) {
87  categoryMap.insert(pair<string, int>(categories_vector[i], i + 1));
88  }
89 
90  // MAKE MODULEMAP
92  using stringvec = vector<std::string>;
93  TNS tns;
94  stringvec const &trigpaths = tns->getTrigPaths();
95 
96  for (auto const &trigpath : trigpaths) {
97  stringvec strings = tns->getTrigPathModules(trigpath);
98 
99  for (auto &k : strings) {
100  moduleMap.insert(pair<string, int>(k, moduleMap.size() + 1));
101  }
102  }
103 
104  // BOOK THE HISTOGRAMS
105  LogTrace(metname) << "[DQMMessageLogger] Parameters initialization";
106 
107  if (!moduleMap.empty()) {
108  ibooker.setCurrentFolder(directoryName + "/Errors");
109  modules_errors = ibooker.book1D("modules_errors", "Errors per module", moduleMap.size(), 0, moduleMap.size());
110  ibooker.setCurrentFolder(directoryName + "/Warnings");
111 
112  modules_warnings = ibooker.book1D("modules_warnings", "Warnings per module", moduleMap.size(), 0, moduleMap.size());
113 
114  for (auto it = moduleMap.begin(); it != moduleMap.end(); ++it) {
115  modules_errors->setBinLabel((*it).second, (*it).first);
116  modules_warnings->setBinLabel((*it).second, (*it).first);
117  }
118  modules_errors->getTH1()->GetXaxis()->LabelsOption("v");
119  modules_warnings->getTH1()->GetXaxis()->LabelsOption("v");
120  }
121 
122  if (!categoryMap.empty()) {
123  ibooker.setCurrentFolder(directoryName + "/Errors");
125  ibooker.book1D("categories_errors", "Errors per category", categoryMap.size(), 0, categoryMap.size());
126  ibooker.setCurrentFolder(directoryName + "/Warnings");
128  ibooker.book1D("categories_warnings", "Warnings per category", categoryMap.size(), 0, categoryMap.size());
129 
130  for (auto it = categoryMap.begin(); it != categoryMap.end(); ++it) {
131  categories_errors->setBinLabel((*it).second, (*it).first);
132  categories_warnings->setBinLabel((*it).second, (*it).first);
133  }
134  categories_warnings->getTH1()->GetXaxis()->LabelsOption("v");
135  categories_errors->getTH1()->GetXaxis()->LabelsOption("v");
136  }
137 
138  // HOW MANY BINS SHOULD THE ERROR HIST HAVE?
139  int nbins = 11;
140  total_warnings = ibooker.book1D("total_warnings", "Total warnings per event", nbins, -0.5, nbins + 0.5);
141  ibooker.setCurrentFolder(directoryName + "/Errors");
142  total_errors = ibooker.book1D("total_errors", "Total errors per event", nbins, -0.5, nbins + 0.5);
143 
144  for (int i = 0; i < nbins; ++i) {
145  stringstream out;
146  out << i;
147  string s = out.str();
148  total_errors->setBinLabel(i + 1, s);
149  total_warnings->setBinLabel(i + 1, s);
150  }
151 }
std::map< std::string, int > categoryMap
MonitorElement * total_warnings
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
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
virtual TH1 * getTH1() const
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

◆ categories_errors

MonitorElement* DQMMessageLogger::categories_errors
private

Definition at line 59 of file DQMMessageLogger.cc.

◆ categories_vector

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

Definition at line 54 of file DQMMessageLogger.cc.

◆ categories_warnings

MonitorElement* DQMMessageLogger::categories_warnings
private

Definition at line 60 of file DQMMessageLogger.cc.

◆ categoryECount

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

Definition at line 52 of file DQMMessageLogger.cc.

◆ categoryMap

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

Definition at line 50 of file DQMMessageLogger.cc.

◆ categoryWCount

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

Definition at line 51 of file DQMMessageLogger.cc.

◆ directoryName

std::string DQMMessageLogger::directoryName
private

Definition at line 55 of file DQMMessageLogger.cc.

◆ errorSummary_

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

Definition at line 56 of file DQMMessageLogger.cc.

◆ metname

std::string DQMMessageLogger::metname
private

Definition at line 47 of file DQMMessageLogger.cc.

◆ moduleMap

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

Definition at line 49 of file DQMMessageLogger.cc.

◆ modules_errors

MonitorElement* DQMMessageLogger::modules_errors
private

Definition at line 61 of file DQMMessageLogger.cc.

◆ modules_warnings

MonitorElement* DQMMessageLogger::modules_warnings
private

Definition at line 62 of file DQMMessageLogger.cc.

◆ total_errors

MonitorElement* DQMMessageLogger::total_errors
private

Definition at line 63 of file DQMMessageLogger.cc.

◆ total_warnings

MonitorElement* DQMMessageLogger::total_warnings
private

Definition at line 64 of file DQMMessageLogger.cc.