CMS 3D CMS Logo

DQMMessageLogger.cc
Go to the documentation of this file.
1 
2 
3 #include "DQMMessageLogger.h"
23 #include "TPad.h"
24 #include <cmath>
25 
26 using namespace std;
27 using namespace edm;
28 
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 }
43 
45  // Should the pointers be deleted?
46 }
47 
48 void DQMMessageLogger::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
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");
90  categories_errors =
91  ibooker.book1D("categories_errors", "Errors per category", categoryMap.size(), 0, categoryMap.size());
92  ibooker.setCurrentFolder(directoryName + "/Warnings");
93  categories_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 }
118 
119 void DQMMessageLogger::analyze(const Event& iEvent, const EventSetup& iSetup) {
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 }
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
Handle.h
DQMMessageLogger.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
Handle.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
TriggerNamesService.h
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
ELseverityLevel.h
pos
Definition: PixelAliasList.h:18
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
Algorithms.h
DQMStore.h
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
nano_cff.strings
strings
Definition: nano_cff.py:26
MakerMacros.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
errors
Definition: errors.py:1
Service.h
w
const double w
Definition: UKUtility.cc:23
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
dqm::impl::MonitorElement::setBinLabel
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)
Definition: MonitorElement.cc:771
edm::EventSetup
Definition: EventSetup.h:58
DQMMessageLogger::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DQMMessageLogger.cc:48
Registry.h
DQMMessageLogger::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Get the analysis.
Definition: DQMMessageLogger.cc:119
std
Definition: JetResolutionObject.h:76
edm::ELseverityLevel
Definition: ELseverityLevel.h:26
edm::ELseverityLevel::getLevel
constexpr int getLevel() const noexcept
Definition: ELseverityLevel.h:65
ErrorSummaryEntry.h
Frameworkfwd.h
Event.h
DQMMessageLogger::DQMMessageLogger
DQMMessageLogger(const edm::ParameterSet &)
Constructor.
Definition: DQMMessageLogger.cc:29
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
DQMMessageLogger::~DQMMessageLogger
~DQMMessageLogger() override
Destructor.
Definition: DQMMessageLogger.cc:44
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
edm::Event
Definition: Event.h:73
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54