CMS 3D CMS Logo

DQMMessageLoggerClient.cc
Go to the documentation of this file.
3 #include <string>
4 #include <vector>
5 
6 using namespace std;
7 using namespace edm;
8 
9 // -----------------------------
10 // constructors and destructor
11 // -----------------------------
12 
14  parameters = ps;
15  theDbe = nullptr;
16  modulesErrorsFound = nullptr;
17  modulesWarningsFound = nullptr;
18  categoriesWarningsFound = nullptr;
19  categoriesErrorsFound = nullptr;
20  directoryName = parameters.getParameter<string>("Directory");
21 }
22 
24 
26  //LogTrace(metname)<<"[DQMMessageLoggerClient] Parameters initialization";
27  theDbe = Service<DQMStore>().operator->();
28 
29  if (theDbe != nullptr) {
30  theDbe->setCurrentFolder(directoryName);
31  }
32 }
33 
35 
37 
39  // directoryName should be the same as for DQMMessageLogger
40  //theDbe->setCurrentFolder(directoryName);
41  /*
42  cout << theDbe->pwd() << endl;
43  vector<string> vec = theDbe->getSubdirs();
44  for(int i=0; i<vec.size(); i++){
45  cout << vec[i] << endl;
46  }
47  */
48  theDbe->goUp();
49 
50  vector<string> entries;
51  entries.push_back(directoryName + "/Warnings/modules_warnings");
52  entries.push_back(directoryName + "/Errors/modules_errors");
53  entries.push_back(directoryName + "/Warnings/categories_warnings");
54  entries.push_back(directoryName + "/Errors/categories_errors");
55 
56  int mel = 0;
57 
58  for (auto ent = entries.begin(); ent != entries.end(); ++ent) {
59  mel++;
60  //RESET VECTORS
61  binContent.clear();
62  binLabel.clear();
63 
64  // RETURN ME
65 
66  MonitorElement* me = theDbe->get(*ent);
67  // GET TH1F
68  if (theDbe->get(*ent)) {
69  if (TH1* rootHisto = me->getTH1()) {
70  int nonzeros = 0;
71  int Nbins = me->getNbinsX();
72 
73  // LOOP OVER TH1F
74  for (int bin = 1; bin <= Nbins; ++bin) {
75  if (rootHisto->GetBinContent(bin) > 0) {
76  nonzeros++;
77  binContent.push_back(rootHisto->GetBinContent(bin));
78  binLabel.emplace_back(rootHisto->GetXaxis()->GetBinLabel(bin));
79  }
80  }
81 
82  switch (mel) {
83  case 1:
84  theDbe->setCurrentFolder(directoryName + "/Warnings");
85  modulesWarningsFound = theDbe->get(directoryName + "/Warnings/modulesWarningsFound");
86  if (nonzeros > 0) {
87  modulesWarningsFound = theDbe->book1D(
88  "modulesWarningsFound", "Warnings per module", binContent.size(), 0, binContent.size());
89  } else {
90  modulesWarningsFound = theDbe->book1D("modulesWarningsFound", "Warnings per module", 1, 0, 1);
91  modulesWarningsFound->setBinLabel(1, "Module name");
92  }
93  for (int i = 0; i < nonzeros; ++i) {
94  if (modulesWarningsFound != nullptr) {
95  //gPad->SetBottomMargin(2);
96  //cout << binContent[i] <<" "<<binLabel[i] << endl;
97  modulesWarningsFound->setBinContent(i + 1, binContent[i]);
98  modulesWarningsFound->setBinLabel(i + 1, binLabel[i]);
99  }
100  }
101  if (nonzeros > 4)
102  modulesWarningsFound->getTH1()->GetXaxis()->LabelsOption("v");
103  break;
104  case 2:
105  theDbe->setCurrentFolder(directoryName + "/Errors");
106  modulesErrorsFound = theDbe->get(directoryName + "/Errors/modulesErrorsFound");
107  if (nonzeros > 0) {
108  modulesErrorsFound =
109  theDbe->book1D("modulesErrorsFound", "Errors per module", binContent.size(), 0, binContent.size());
110  } else {
111  modulesErrorsFound = theDbe->book1D("modulesErrorsFound", "Errors per module", 1, 0, 1);
112  modulesErrorsFound->setBinLabel(1, "Module name");
113  }
114  for (int i = 0; i < nonzeros; ++i) {
115  if (modulesErrorsFound != nullptr) {
116  //gPad->SetBottomMargin(2);
117  modulesErrorsFound->setBinContent(i + 1, binContent[i]);
118  modulesErrorsFound->setBinLabel(i + 1, binLabel[i]);
119  }
120  }
121  if (nonzeros > 4)
122  modulesErrorsFound->getTH1()->GetXaxis()->LabelsOption("v");
123  break;
124  case 3:
125  theDbe->setCurrentFolder(directoryName + "/Warnings");
126  categoriesWarningsFound = theDbe->get(directoryName + "/Warnings/categoriesWarningsFound");
127  if (nonzeros > 0) {
128  categoriesWarningsFound = theDbe->book1D(
129  "categoriesWarningsFound", "Warnings per category", binContent.size(), 0, binContent.size());
130  } else {
131  categoriesWarningsFound = theDbe->book1D("categoriesWarningsFound", "Warnings per category", 1, 0, 1);
132  categoriesWarningsFound->setBinLabel(1, "Category name");
133  }
134  for (int i = 0; i < nonzeros; ++i) {
135  if (categoriesWarningsFound != nullptr) {
136  //gPad->SetBottomMargin(2);
137  //cout << binContent[i] <<" " <<binLabel[i] << endl;
138  categoriesWarningsFound->setBinContent(i + 1, binContent[i]);
139  categoriesWarningsFound->setBinLabel(i + 1, binLabel[i]);
140  }
141  }
142  if (nonzeros > 4)
143  categoriesWarningsFound->getTH1()->GetXaxis()->LabelsOption("v");
144  break;
145  case 4:
146  theDbe->setCurrentFolder(directoryName + "/Errors");
147  categoriesErrorsFound = theDbe->get(directoryName + "/Errors/categoriesErrorsFound");
148  if (nonzeros > 0) {
149  categoriesErrorsFound = theDbe->book1D(
150  "categoriesErrorsFound", "Errors per category", binContent.size(), 0, binContent.size());
151  } else {
152  categoriesErrorsFound = theDbe->book1D("categoriesErrorsFound", "Errors per category", 1, 0, 1);
153  categoriesErrorsFound->setBinLabel(1, "Category name");
154  }
155  for (int i = 0; i < nonzeros; ++i) {
156  if (categoriesErrorsFound != nullptr) {
157  //gPad->SetBottomMargin(2);
158  categoriesErrorsFound->setBinContent(i + 1, binContent[i]);
159  categoriesErrorsFound->setBinLabel(i + 1, binLabel[i]);
160  }
161  }
162  if (nonzeros > 4)
163  categoriesErrorsFound->getTH1()->GetXaxis()->LabelsOption("v");
164  break;
165  }
166  }
167  }
168  }
169 }
170 
172 
174  //LogTrace(metname)<<"[DQMMessageLoggerClient] EndJob";
175 }
DQMMessageLoggerClient::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: DQMMessageLoggerClient.cc:171
mps_fire.i
i
Definition: mps_fire.py:355
DQMMessageLoggerClient.h
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
RPCNoise_cfi.fillHistograms
fillHistograms
Definition: RPCNoise_cfi.py:8
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
Service.h
DQMMessageLoggerClient::beginJob
void beginJob() override
Definition: DQMMessageLoggerClient.cc:25
edm::ParameterSet
Definition: ParameterSet.h:36
DQMMessageLoggerClient::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DQMMessageLoggerClient.cc:34
SiStripMonitorCluster_cfi.Nbins
Nbins
Definition: SiStripMonitorCluster_cfi.py:32
DQMMessageLoggerClient::DQMMessageLoggerClient
DQMMessageLoggerClient(const edm::ParameterSet &)
Definition: DQMMessageLoggerClient.cc:13
edm::Service
Definition: Service.h:30
edm::EventSetup
Definition: EventSetup.h:57
DQMMessageLoggerClient::fillHistograms
void fillHistograms()
Definition: DQMMessageLoggerClient.cc:38
alignCSCRings.r
r
Definition: alignCSCRings.py:93
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
DQMMessageLoggerClient::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: DQMMessageLoggerClient.cc:36
DQMMessageLoggerClient::endJob
void endJob() override
Definition: DQMMessageLoggerClient.cc:173
std
Definition: JetResolutionObject.h:76
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
edm::Event
Definition: Event.h:73
DQMMessageLoggerClient::~DQMMessageLoggerClient
~DQMMessageLoggerClient() override
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37