CMS 3D CMS Logo

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