CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMMessageLoggerClient.cc
Go to the documentation of this file.
3 #include <string>
4 #include <vector>
5 
6 
7 using namespace std;
8 using namespace edm;
9 
10 
11 // -----------------------------
12 // constructors and destructor
13 // -----------------------------
14 
16 
17  parameters = ps;
18  theDbe = NULL;
19  modulesErrorsFound = NULL;
20  modulesWarningsFound = NULL;
21  categoriesWarningsFound = NULL;
22  categoriesErrorsFound = NULL;
23  directoryName = parameters.getParameter<string>("Directory");
24 
25 }
26 
27 
29 
30 }
31 
32 
33 
35 
36  //LogTrace(metname)<<"[DQMMessageLoggerClient] Parameters initialization";
37  theDbe = Service<DQMStore>().operator->();
38 
39  if(theDbe!=NULL){
40  theDbe->setCurrentFolder(directoryName);
41  }
42 
43 }
44 
46 }
47 
48 
49 
51 }
52 
54 }
55 
57 }
58 
60 
61 
62  // directoryName should be the same as for DQMMessageLogger
63  //theDbe->setCurrentFolder(directoryName);
64  /*
65  cout << theDbe->pwd() << endl;
66  vector<string> vec = theDbe->getSubdirs();
67  for(int i=0; i<vec.size(); i++){
68  cout << vec[i] << endl;
69  }
70  */
71  theDbe->goUp();
72 
73 
74 
75  vector<string> entries;
76  entries.push_back(directoryName + "/Warnings/modules_warnings");
77  entries.push_back(directoryName + "/Errors/modules_errors");
78  entries.push_back(directoryName + "/Warnings/categories_warnings");
79  entries.push_back(directoryName + "/Errors/categories_errors");
80 
81 
82  int mel = 0;
83 
84  for(vector<string>::const_iterator ent = entries.begin();
85  ent != entries.end(); ++ent) {
86  mel++;
87  //RESET VECTORS
88  binContent.clear();
89  binLabel.clear();
90 
91 
92  // RETURN ME
93 
94 
95  MonitorElement *me = theDbe->get(*ent);
96  // GET TH1F
97  if(theDbe->get(*ent)){
98  if (TH1 *rootHisto = me->getTH1()) {
99  int nonzeros = 0;
100  int Nbins = me->getNbinsX();
101 
102 
103  // LOOP OVER TH1F
104  for(int bin = 1; bin <= Nbins ; ++bin) {
105  if( rootHisto->GetBinContent(bin)>0){
106  nonzeros++;
107  binContent.push_back(rootHisto->GetBinContent(bin));
108  binLabel.push_back(rootHisto->GetXaxis()->GetBinLabel(bin));
109  }
110 
111  }
112 
113  switch(mel){
114  case 1:
115  theDbe->setCurrentFolder(directoryName + "/Warnings");
116  modulesWarningsFound = theDbe->get(directoryName + "/Warnings/modulesWarningsFound");
117  if (modulesWarningsFound) theDbe->removeElement(modulesWarningsFound->getName());
118  if(nonzeros>0){
119  modulesWarningsFound = theDbe->book1D("modulesWarningsFound", "Warnings per module", binContent.size(), 0, binContent.size());
120  }else{
121  modulesWarningsFound = theDbe->book1D("modulesWarningsFound", "Warnings per module", 1, 0, 1);
122  modulesWarningsFound->setBinLabel(1,"Module name");
123  }
124  for (int i=0; i<nonzeros; ++i){
125  if(modulesWarningsFound!=NULL){
126  //gPad->SetBottomMargin(2);
127  //cout << binContent[i] <<" "<<binLabel[i] << endl;
128  modulesWarningsFound->setBinContent(i+1,binContent[i]);
129  modulesWarningsFound->setBinLabel(i+1,binLabel[i]);
130  }
131  }
132  if(nonzeros>4) modulesWarningsFound->getTH1()->GetXaxis()->LabelsOption("v");
133  break;
134  case 2:
135  theDbe->setCurrentFolder(directoryName + "/Errors");
136  modulesErrorsFound = theDbe->get(directoryName + "/Errors/modulesErrorsFound");
137  if (modulesErrorsFound) theDbe->removeElement(modulesErrorsFound->getName());
138  if(nonzeros>0){
139  modulesErrorsFound = theDbe->book1D("modulesErrorsFound", "Errors per module",binContent.size(), 0, binContent.size() );
140  }else{
141  modulesErrorsFound = theDbe->book1D("modulesErrorsFound", "Errors per module",1, 0, 1 );
142  modulesErrorsFound->setBinLabel(1,"Module name");
143  }
144  for (int i=0; i<nonzeros; ++i){
145  if(modulesErrorsFound!=NULL){
146  //gPad->SetBottomMargin(2);
147  modulesErrorsFound->setBinContent(i+1,binContent[i]);
148  modulesErrorsFound->setBinLabel(i+1,binLabel[i]);
149  }
150  }
151  if(nonzeros>4) modulesErrorsFound->getTH1()->GetXaxis()->LabelsOption("v");
152  break;
153  case 3:
154  theDbe->setCurrentFolder(directoryName + "/Warnings");
155  categoriesWarningsFound = theDbe->get(directoryName + "/Warnings/categoriesWarningsFound");
156  if (categoriesWarningsFound) theDbe->removeElement(categoriesWarningsFound->getName());
157  if(nonzeros>0){
158  categoriesWarningsFound = theDbe->book1D("categoriesWarningsFound", "Warnings per category", binContent.size(),0,binContent.size());
159  } else{
160  categoriesWarningsFound = theDbe->book1D("categoriesWarningsFound", "Warnings per category", 1,0,1);
161  categoriesWarningsFound->setBinLabel(1,"Category name");
162  }
163  for (int i=0; i<nonzeros; ++i){
164  if(categoriesWarningsFound!=NULL){
165  //gPad->SetBottomMargin(2);
166  //cout << binContent[i] <<" " <<binLabel[i] << endl;
167  categoriesWarningsFound->setBinContent(i+1,binContent[i]);
168  categoriesWarningsFound->setBinLabel(i+1,binLabel[i]);
169  }
170  }
171  if(nonzeros>4) categoriesWarningsFound->getTH1()->GetXaxis()->LabelsOption("v");
172  break;
173  case 4:
174  theDbe->setCurrentFolder(directoryName + "/Errors");
175  categoriesErrorsFound = theDbe->get(directoryName + "/Errors/categoriesErrorsFound");
176  if (categoriesErrorsFound) theDbe->removeElement(categoriesErrorsFound->getName());
177  if(nonzeros>0){
178  categoriesErrorsFound = theDbe->book1D("categoriesErrorsFound", "Errors per category", binContent.size(),0,binContent.size());
179  }else{
180  categoriesErrorsFound = theDbe->book1D("categoriesErrorsFound", "Errors per category", 1,0,1);
181  categoriesErrorsFound->setBinLabel(1,"Category name");
182  }
183  for (int i=0; i<nonzeros; ++i){
184  if(categoriesErrorsFound!=NULL){
185  //gPad->SetBottomMargin(2);
186  categoriesErrorsFound->setBinContent(i+1,binContent[i]);
187  categoriesErrorsFound->setBinLabel(i+1,binLabel[i]);
188  }
189  }
190  if(nonzeros>4) categoriesErrorsFound->getTH1()->GetXaxis()->LabelsOption("v");
191  break;
192  }
193 
194  }
195  }
196  }
197 }
198 
199 
200 
202  fillHistograms();
203 }
204 
205 
207 
208  //LogTrace(metname)<<"[DQMMessageLoggerClient] EndJob";
209 }
void endRun(const edm::Run &, const edm::EventSetup &)
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
void analyze(const edm::Event &, const edm::EventSetup &)
void beginRun(const edm::Run &, const edm::EventSetup &)
#define NULL
Definition: scimark2.h:8
DQMMessageLoggerClient(const edm::ParameterSet &)
TH1 * getTH1(void) const
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
int getNbinsX(void) const
get # of bins in X-axis
Definition: Run.h:41