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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) 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
 
edm::EDGetTokenT< std::vector
< edm::ErrorSummaryEntry > > 
errorSummary_
 
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
 
- 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::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 19 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(), edm::ParameterSet::getUntrackedParameter(), NULL, and AlCaHLTBitMon_QueryRunRegistry::string.

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  errorSummary_ = consumes<std::vector<edm::ErrorSummaryEntry> >(parameters.getUntrackedParameter<std::string>("errorSummary","logErrorHarvester"));
50 
51 
52 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * total_warnings
edm::EDGetTokenT< std::vector< edm::ErrorSummaryEntry > > errorSummary_
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 54 of file DQMMessageLogger.cc.

54  {
55  // Should the pointers be deleted?
56 }

Member Function Documentation

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

Get the analysis.

Implements edm::EDAnalyzer.

Definition at line 144 of file DQMMessageLogger.cc.

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

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

Inizialize parameters for histo binning.

Reimplemented from edm::EDAnalyzer.

Definition at line 59 of file DQMMessageLogger.cc.

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

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

Save the histos.

Reimplemented from edm::EDAnalyzer.

Definition at line 280 of file DQMMessageLogger.cc.

References LogTrace, and metname.

280  {
281  LogTrace(metname)<<"[DQMMessageLogger] EndJob";
282 
283 }
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 246 of file DQMMessageLogger.cc.

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

Member Data Documentation

MonitorElement* DQMMessageLogger::categories_errors
private

Definition at line 60 of file DQMMessageLogger.h.

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

Definition at line 55 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::categories_warnings
private

Definition at line 61 of file DQMMessageLogger.h.

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

Definition at line 53 of file DQMMessageLogger.h.

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

Definition at line 51 of file DQMMessageLogger.h.

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

Definition at line 52 of file DQMMessageLogger.h.

std::string DQMMessageLogger::directoryName
private

Definition at line 56 of file DQMMessageLogger.h.

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

Definition at line 57 of file DQMMessageLogger.h.

std::string DQMMessageLogger::metname
private

Definition at line 48 of file DQMMessageLogger.h.

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

Definition at line 50 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::modules_errors
private

Definition at line 62 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::modules_warnings
private

Definition at line 63 of file DQMMessageLogger.h.

DQMStore* DQMMessageLogger::theDbe
private

Definition at line 46 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::total_errors
private

Definition at line 64 of file DQMMessageLogger.h.

MonitorElement* DQMMessageLogger::total_warnings
private

Definition at line 65 of file DQMMessageLogger.h.