CMS 3D CMS Logo

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

#include <DQMMessageLogger.h>

Inheritance diagram for DQMMessageLogger:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 Get the analysis. More...
 
void beginJob ()
 Inizialize parameters for histo binning. More...
 
 DQMMessageLogger (const edm::ParameterSet &)
 Constructor. More...
 
void endJob ()
 Save the histos. More...
 
void endRun (const edm::Run &r, const edm::EventSetup &c)
 collate categories in summary plots More...
 
virtual ~DQMMessageLogger ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
std::string metname
 
std::map< std::string, int > moduleMap
 
MonitorElementmodules_errors
 
MonitorElementmodules_warnings
 
DQMStoretheDbe
 
MonitorElementtotal_errors
 
MonitorElementtotal_warnings
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 18 of file DQMMessageLogger.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 34 of file DQMMessageLogger.cc.

References edm::ParameterSet::getParameter(), and NULL.

34  {
35 
36  // the services
37  theDbe = NULL;
38 
43  total_errors = NULL;
45 
46  //Get from cfg file
47  categories_vector = parameters.getParameter< vector<string> >("Categories");
48  directoryName = parameters.getParameter<string>("Directory");
49 
50 }
T getParameter(std::string const &) const
MonitorElement * total_warnings
MonitorElement * total_errors
#define NULL
Definition: scimark2.h:8
MonitorElement * modules_warnings
MonitorElement * categories_errors
std::string directoryName
std::vector< std::string > categories_vector
MonitorElement * modules_errors
MonitorElement * categories_warnings
DQMMessageLogger::~DQMMessageLogger ( )
virtual

Destructor.

Definition at line 52 of file DQMMessageLogger.cc.

52  {
53  // Should the pointers be deleted?
54 }

Member Function Documentation

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

Get the analysis.

Implements edm::EDAnalyzer.

Definition at line 142 of file DQMMessageLogger.cc.

References python.rootplot.argparse::category, alignCSCRings::e, benchmark_cfg::errors, edm::Event::getByLabel(), edm::ELseverityLevel::getLevel(), i, edm::HandleBase::isValid(), LogTrace, metname, n, NULL, pos, alignCSCRings::s, and w().

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

Inizialize parameters for histo binning.

Reimplemented from edm::EDAnalyzer.

Definition at line 57 of file DQMMessageLogger.cc.

References alignCSCRings::e, i, gen::k, LogTrace, metname, pileupCalc::nbins, NULL, cppFunctionSkipper::operator, dbtoconf::out, and alignCSCRings::s.

57  {
58 
59  metname = "errorAnalyzer";
60 
61 
62 
63  // MAKE CATEGORYMAP USING INPUT FROM CFG FILE
64  for(unsigned int i=0; i<categories_vector.size(); i++){
65  categoryMap.insert(pair<string,int>(categories_vector[i],i+1));
66  }
67 
68 
69  // MAKE MODULEMAP
71  typedef vector<std::string> stringvec;
72  TNS tns;
73  stringvec const& trigpaths = tns->getTrigPaths();
74 
75 
76  for (stringvec::const_iterator i = trigpaths.begin(), e =trigpaths.end() ; i != e; ++i){
77  stringvec strings = tns->getTrigPathModules(*i);
78 
79  for(unsigned int k=0; k<strings.size(); ++k){
80  moduleMap.insert(pair<string,int>(strings[k],moduleMap.size()+1));
81  }
82  }
83 
84  // BOOK THE HISTOGRAMS
85  LogTrace(metname)<<"[DQMMessageLogger] Parameters initialization";
87  if(theDbe!=NULL){
88 
89 
90 
91  if(moduleMap.size()!=0){
92  theDbe->setCurrentFolder(directoryName + "/Errors");
93  modules_errors = theDbe->book1D("modules_errors", "Errors per module", moduleMap.size(), 0, moduleMap.size());
94  theDbe->setCurrentFolder(directoryName + "/Warnings");
95 
96  modules_warnings = theDbe->book1D("modules_warnings","Warnings per module",moduleMap.size(),0,moduleMap.size());
97 
98  for(map<string,int>::const_iterator it = moduleMap.begin(); it!=moduleMap.end();++it){
99  modules_errors->setBinLabel((*it).second,(*it).first);
100  modules_warnings->setBinLabel((*it).second,(*it).first);
101  }
102  modules_errors->getTH1()->GetXaxis()->LabelsOption("v");
103  modules_warnings->getTH1()->GetXaxis()->LabelsOption("v");
104 
105 
106 
107 
108  }
109 
110  if(categoryMap.size()!=0){
111  theDbe->setCurrentFolder(directoryName + "/Errors");
112  categories_errors = theDbe->book1D("categories_errors", "Errors per category", categoryMap.size(), 0, categoryMap.size());
113  theDbe->setCurrentFolder(directoryName +"/Warnings");
114  categories_warnings = theDbe->book1D("categories_warnings", "Warnings per category", categoryMap.size(), 0, categoryMap.size());
115 
116 
117  for(map<string,int>::const_iterator it = categoryMap.begin(); it!=categoryMap.end();++it){
118  categories_errors->setBinLabel((*it).second,(*it).first);
119  categories_warnings->setBinLabel((*it).second,(*it).first);
120  }
121  categories_warnings->getTH1()->GetXaxis()->LabelsOption("v");
122  categories_errors->getTH1()->GetXaxis()->LabelsOption("v");
123  }
124 
125  // HOW MANY BINS SHOULD THE ERROR HIST HAVE?
126  int nbins = 11;
127  total_warnings = theDbe->book1D("total_warnings","Total warnings per event",nbins,-0.5,nbins+0.5);
128  theDbe->setCurrentFolder(directoryName + "/Errors");
129  total_errors = theDbe->book1D("total_errors", "Total errors per event", nbins, -0.5, nbins+0.5);
130 
131  for(int i=0; i<nbins; ++i){
132  stringstream out;
133  out<< i;
134  string s = out.str();
135  total_errors->setBinLabel(i+1,s);
136  total_warnings->setBinLabel(i+1,s);
137  }
138  }
139 }
int i
Definition: DBlmapReader.cc:9
std::string metname
MonitorElement * total_warnings
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
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)
MonitorElement * total_errors
#define NULL
Definition: scimark2.h:8
MonitorElement * modules_warnings
MonitorElement * categories_errors
std::map< std::string, int > moduleMap
std::map< std::string, int > categoryMap
std::string directoryName
TH1 * getTH1(void) const
#define LogTrace(id)
std::vector< std::string > categories_vector
int k[5][pyjets_maxn]
tuple out
Definition: dbtoconf.py:99
MonitorElement * modules_errors
MonitorElement * categories_warnings
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void DQMMessageLogger::endJob ( void  )
virtual

Save the histos.

Reimplemented from edm::EDAnalyzer.

Definition at line 278 of file DQMMessageLogger.cc.

References LogTrace, and metname.

278  {
279  LogTrace(metname)<<"[DQMMessageLogger] EndJob";
280 
281 }
std::string metname
#define LogTrace(id)
void DQMMessageLogger::endRun ( const edm::Run r,
const edm::EventSetup c 
)
virtual

collate categories in summary plots

Reimplemented from edm::EDAnalyzer.

Definition at line 244 of file DQMMessageLogger.cc.

244  {
245  /*
246  theDbe = Service<DQMStore>().operator->();
247  if(theDbe!=NULL){
248  std::map<std::string,int>::iterator it;
249  uint i=0;
250  theDbe->setCurrentFolder(directoryName + "/Errors");
251  if (categoryECount.empty()){
252  MonitorElement * catECount = theDbe->book1D("categoryCount_errors","Errors per Category",1,0,1);
253  catECount->setBinLabel(1,"No Errors");
254  }else{
255  MonitorElement * catECount = theDbe->book1D("categoryCount_errors","Errors per Category",categoryECount.size(),0,categoryECount.size());
256  for (i=1,it=categoryECount.begin();it!=categoryECount.end();++it,++i){
257  catECount->setBinLabel(i,it->first);
258  catECount->setBinContent(i,it->second);
259  }
260  }
261  theDbe->setCurrentFolder(directoryName + "/Warnings");
262  if (categoryWCount.empty()){
263  MonitorElement * catWCount = theDbe->book1D("categoryCount_warnings","Warnings per Category",categoryWCount.size(),0,categoryWCount.size());
264  catWCount->setBinLabel(1,"No Warnings");
265  }else{
266  MonitorElement * catWCount = theDbe->book1D("categoryCount_warnings","Warnings per Category",categoryWCount.size(),0,categoryWCount.size());
267  for (i=1,it=categoryWCount.begin();it!=categoryWCount.end();++it,++i){
268  catWCount->setBinLabel(i,it->first);
269  catWCount->setBinContent(i,it->second);
270  }
271  }
272  }
273  categoryWCount.clear();
274  categoryECount.clear();
275  */
276 }

Member Data Documentation

MonitorElement* DQMMessageLogger::categories_errors
private

Definition at line 58 of file DQMMessageLogger.h.

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

Definition at line 54 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::categories_warnings
private

Definition at line 59 of file DQMMessageLogger.h.

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

Definition at line 52 of file DQMMessageLogger.h.

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

Definition at line 50 of file DQMMessageLogger.h.

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

Definition at line 51 of file DQMMessageLogger.h.

std::string DQMMessageLogger::directoryName
private

Definition at line 55 of file DQMMessageLogger.h.

std::string DQMMessageLogger::metname
private

Definition at line 47 of file DQMMessageLogger.h.

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

Definition at line 49 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::modules_errors
private

Definition at line 60 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::modules_warnings
private

Definition at line 61 of file DQMMessageLogger.h.

DQMStore* DQMMessageLogger::theDbe
private

Definition at line 45 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::total_errors
private

Definition at line 62 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::total_warnings
private

Definition at line 63 of file DQMMessageLogger.h.