![]() |
![]() |
#include <DQMMessageLogger.h>
Public Member Functions | |
void | analyze (const edm::Event &, const edm::EventSetup &) |
Get the analysis. | |
void | beginJob () |
Inizialize parameters for histo binning. | |
DQMMessageLogger (const edm::ParameterSet &) | |
Constructor. | |
void | endJob () |
Save the histos. | |
virtual | ~DQMMessageLogger () |
Destructor. | |
Private Attributes | |
MonitorElement * | categories_errors |
std::vector< std::string > | categories_vector |
MonitorElement * | categories_warnings |
std::map< std::string, int > | categoryMap |
std::string | directoryName |
std::string | metname |
std::map< std::string, int > | moduleMap |
MonitorElement * | modules_errors |
MonitorElement * | modules_warnings |
DQMStore * | theDbe |
MonitorElement * | total_errors |
MonitorElement * | total_warnings |
Definition at line 18 of file DQMMessageLogger.h.
DQMMessageLogger::DQMMessageLogger | ( | const edm::ParameterSet & | parameters | ) |
Constructor.
Definition at line 34 of file DQMMessageLogger.cc.
References edm::ParameterSet::getParameter(), and NULL.
{ // the services theDbe = NULL; categories_errors = NULL; categories_warnings = NULL; modules_errors = NULL; modules_warnings = NULL; total_errors = NULL; total_warnings = NULL; //Get from cfg file categories_vector = parameters.getParameter< vector<string> >("Categories"); directoryName = parameters.getParameter<string>("Directory"); }
DQMMessageLogger::~DQMMessageLogger | ( | ) | [virtual] |
Destructor.
Definition at line 52 of file DQMMessageLogger.cc.
{
// Should the pointers be deleted?
}
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 category(), ExpressReco_HICollisions_FallBack::e, ExpressReco_HICollisions_FallBack::errors, edm::Event::getByLabel(), edm::ELseverityLevel::getLevel(), i, edm::HandleBase::isValid(), LogTrace, metname, n, NULL, pos, and asciidump::s.
{ LogTrace(metname)<<"[DQMMessageLogger] Analysis of event # "; // Take the ErrorSummaryEntry container Handle<std::vector<edm::ErrorSummaryEntry> > errors; iEvent.getByLabel("logErrorHarvester",errors); // Check that errors is valid if(!errors.isValid()){ return; } // Compare severity level of error with ELseveritylevel instance el : "-e" should be the lowest error ELseverityLevel el("-e"); // Find the total number of errors in iEvent if(errors->size()==0){ if(total_errors!=NULL){ total_errors->Fill(0); } if(total_warnings!=NULL){ total_warnings->Fill(0); } }else{ int e = 0; int w = 0; for (int i=0, n=errors->size(); i<n; i++){ if((*errors)[i].severity.getLevel() < el.getLevel()){ w+= (*errors)[i].count; }else{ e+= (*errors)[i].count; } } if(total_errors!=NULL){ total_errors->Fill(e); } if(total_warnings!=NULL){ total_warnings->Fill(w); } } for(int i=0, n=errors->size(); i< n ; i++){ //cout << "Severity for error/warning: " << (*errors)[i].severity << " " <<(*errors)[i].module << endl; if(errors->size()>0){ // IF THIS IS AN ERROR on the ELseverityLevel SCALE, FILL ERROR HISTS if((*errors)[i].severity.getLevel() >= el.getLevel()){ if(categories_errors!=NULL){ map<string,int>::const_iterator it = categoryMap.find((*errors)[i].category); if (it!=categoryMap.end()){ // FILL THE RIGHT BIN categories_errors->Fill((*it).second - 1, (*errors)[i].count); } } if(modules_errors!=NULL){ // remove the first part of the module string, what is before ":" string s = (*errors)[i].module; size_t pos = s.find(':'); string s_temp = s.substr(pos+1,s.size()); map<string,int>::const_iterator it = moduleMap.find(s_temp); if(it!=moduleMap.end()){ // FILL THE RIGHT BIN modules_errors->Fill((*it).second - 1, (*errors)[i].count); } } // IF ONLY WARNING, FILL WARNING HISTS }else{ if(categories_warnings!=NULL){ map<string,int>::const_iterator it = categoryMap.find((*errors)[i].category); if (it!=categoryMap.end()){ // FILL THE RIGHT BIN categories_warnings->Fill((*it).second - 1, (*errors)[i].count); } } if(modules_warnings!=NULL){ // remove the first part of the module string, what is before ":" string s = (*errors)[i].module; size_t pos = s.find(':'); string s_temp = s.substr(pos+1,s.size()); map<string,int>::const_iterator it = moduleMap.find(s_temp); if(it!=moduleMap.end()){ // FILL THE RIGHT BIN modules_warnings->Fill((*it).second - 1, (*errors)[i].count); } } } } } }
void DQMMessageLogger::beginJob | ( | void | ) | [virtual] |
Inizialize parameters for histo binning.
Reimplemented from edm::EDAnalyzer.
Definition at line 57 of file DQMMessageLogger.cc.
References ExpressReco_HICollisions_FallBack::e, i, gen::k, LogTrace, metname, ExpressReco_HICollisions_FallBack::nbins, NULL, cmsCodeRules::cppFunctionSkipper::operator, dbtoconf::out, and asciidump::s.
{ metname = "errorAnalyzer"; // MAKE CATEGORYMAP USING INPUT FROM CFG FILE for(unsigned int i=0; i<categories_vector.size(); i++){ categoryMap.insert(pair<string,int>(categories_vector[i],i+1)); } // MAKE MODULEMAP typedef Service<edm::service::TriggerNamesService> TNS; typedef vector<std::string> stringvec; TNS tns; stringvec const& trigpaths = tns->getTrigPaths(); for (stringvec::const_iterator i = trigpaths.begin(), e =trigpaths.end() ; i != e; ++i){ stringvec strings = tns->getTrigPathModules(*i); for(unsigned int k=0; k<strings.size(); ++k){ moduleMap.insert(pair<string,int>(strings[k],moduleMap.size()+1)); } } // BOOK THE HISTOGRAMS LogTrace(metname)<<"[DQMMessageLogger] Parameters initialization"; theDbe = Service<DQMStore>().operator->(); if(theDbe!=NULL){ if(moduleMap.size()!=0){ theDbe->setCurrentFolder(directoryName + "/Errors"); modules_errors = theDbe->book1D("modules_errors", "Errors per module", moduleMap.size(), 0, moduleMap.size()); theDbe->setCurrentFolder(directoryName + "/Warnings"); modules_warnings = theDbe->book1D("modules_warnings","Warnings per module",moduleMap.size(),0,moduleMap.size()); for(map<string,int>::const_iterator it = moduleMap.begin(); it!=moduleMap.end();++it){ modules_errors->setBinLabel((*it).second,(*it).first); modules_warnings->setBinLabel((*it).second,(*it).first); } modules_errors->getTH1()->GetXaxis()->LabelsOption("v"); modules_warnings->getTH1()->GetXaxis()->LabelsOption("v"); } if(categoryMap.size()!=0){ theDbe->setCurrentFolder(directoryName + "/Errors"); categories_errors = theDbe->book1D("categories_errors", "Errors per category", categoryMap.size(), 0, categoryMap.size()); theDbe->setCurrentFolder(directoryName +"/Warnings"); categories_warnings = theDbe->book1D("categories_warnings", "Warnings per category", categoryMap.size(), 0, categoryMap.size()); for(map<string,int>::const_iterator it = categoryMap.begin(); it!=categoryMap.end();++it){ categories_errors->setBinLabel((*it).second,(*it).first); categories_warnings->setBinLabel((*it).second,(*it).first); } categories_warnings->getTH1()->GetXaxis()->LabelsOption("v"); categories_errors->getTH1()->GetXaxis()->LabelsOption("v"); } // HOW MANY BINS SHOULD THE ERROR HIST HAVE? int nbins = 10; total_warnings = theDbe->book1D("total warnings","Total warnings per event",nbins,0,nbins); theDbe->setCurrentFolder(directoryName + "/Errors"); total_errors = theDbe->book1D("total_errors", "Total errors per event", nbins, 0, nbins); for(int i=0; i<nbins; ++i){ stringstream out; out<< i; string s = out.str(); total_errors->setBinLabel(i+1,s); total_warnings->setBinLabel(i+1,s); } } }
void DQMMessageLogger::endJob | ( | void | ) | [virtual] |
Save the histos.
Reimplemented from edm::EDAnalyzer.
Definition at line 240 of file DQMMessageLogger.cc.
Definition at line 52 of file DQMMessageLogger.h.
std::vector<std::string> DQMMessageLogger::categories_vector [private] |
Definition at line 48 of file DQMMessageLogger.h.
Definition at line 53 of file DQMMessageLogger.h.
std::map<std::string,int> DQMMessageLogger::categoryMap [private] |
Definition at line 46 of file DQMMessageLogger.h.
std::string DQMMessageLogger::directoryName [private] |
Definition at line 49 of file DQMMessageLogger.h.
std::string DQMMessageLogger::metname [private] |
Definition at line 43 of file DQMMessageLogger.h.
std::map<std::string,int> DQMMessageLogger::moduleMap [private] |
Definition at line 45 of file DQMMessageLogger.h.
MonitorElement* DQMMessageLogger::modules_errors [private] |
Definition at line 54 of file DQMMessageLogger.h.
MonitorElement* DQMMessageLogger::modules_warnings [private] |
Definition at line 55 of file DQMMessageLogger.h.
DQMStore* DQMMessageLogger::theDbe [private] |
Definition at line 41 of file DQMMessageLogger.h.
MonitorElement* DQMMessageLogger::total_errors [private] |
Definition at line 56 of file DQMMessageLogger.h.
MonitorElement* DQMMessageLogger::total_warnings [private] |
Definition at line 57 of file DQMMessageLogger.h.