CMS 3D CMS Logo

DQMFEDIntegrityClient.cc
Go to the documentation of this file.
1 /*
2  * \file DQMFEDIntegrityClient.cc
3  * \author M. Marienfeld
4  * Last Update:
5  *
6  * Description: Summing up FED entries from all subdetectors.
7  *
8  */
9 
10 #include <string>
11 #include <vector>
12 
17 
18 //
19 // class declaration
20 //
21 
22 class DQMFEDIntegrityClient : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
23 public:
27  ~DQMFEDIntegrityClient() override = default;
28 
29 protected:
30  void beginJob() override;
31  void beginRun(const edm::Run& r, const edm::EventSetup& c) override;
32 
34  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
35 
36  void beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) override;
37  void endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) override;
38 
39  void endRun(const edm::Run& r, const edm::EventSetup& c) override;
40  void endJob() override;
41 
42 private:
43  void initialize();
44  void fillHistograms();
45 
47 
49 
50  // ---------- member data ----------
51 
52  int NBINS;
53  float XMIN, XMAX;
54  float SummaryContent[10];
55 
59 
63 
70 };
71 
72 // -----------------------------
73 // constructors and destructor
74 // -----------------------------
75 
77  parameters_ = ps;
78  initialize();
79  fillInEventloop = ps.getUntrackedParameter<bool>("fillInEventloop", false);
80  fillOnEndRun = ps.getUntrackedParameter<bool>("fillOnEndRun", false);
81  fillOnEndJob = ps.getUntrackedParameter<bool>("fillOnEndJob", false);
82  fillOnEndLumi = ps.getUntrackedParameter<bool>("fillOnEndLumi", true);
83  moduleName = ps.getUntrackedParameter<std::string>("moduleName", "FED");
84  fedFolderName = ps.getUntrackedParameter<std::string>("fedFolderName", "FEDIntegrity");
85 }
86 
88  // get back-end interface
90 }
91 
93  NBINS = 850;
94  XMIN = 0.;
95  XMAX = 850.;
96 
98 
99  // ----------------------------------------------------------------------------------
100  std::string currentFolder = moduleName + "/" + fedFolderName;
101  dbe_->setCurrentFolder(currentFolder);
102 
103  FedEntries = dbe_->book1D("FedEntries", "FED Entries", NBINS, XMIN, XMAX);
104  FedFatal = dbe_->book1D("FedFatal", "FED Fatal Errors", NBINS, XMIN, XMAX);
105  FedNonFatal = dbe_->book1D("FedNonFatal", "FED Non Fatal Errors", NBINS, XMIN, XMAX);
106 
107  FedEntries->setAxisTitle("", 1);
108  FedFatal->setAxisTitle("", 1);
109  FedNonFatal->setAxisTitle("", 1);
110 
111  FedEntries->setAxisTitle("", 2);
112  FedFatal->setAxisTitle("", 2);
113  FedNonFatal->setAxisTitle("", 2);
114 
115  FedEntries->setBinLabel(11, "PIXEL", 1);
116  FedEntries->setBinLabel(221, "SIST", 1);
117  FedEntries->setBinLabel(606, "EE", 1);
118  FedEntries->setBinLabel(628, "EB", 1);
119  FedEntries->setBinLabel(651, "EE", 1);
120  FedEntries->setBinLabel(550, "ES", 1);
121  FedEntries->setBinLabel(716, "HCAL", 1);
122  FedEntries->setBinLabel(754, "CSC", 1);
123  FedEntries->setBinLabel(772, "DT", 1);
124  FedEntries->setBinLabel(791, "RPC", 1);
125  FedEntries->setBinLabel(804, "L1T", 1);
126 
127  FedFatal->setBinLabel(11, "PIXEL", 1);
128  FedFatal->setBinLabel(221, "SIST", 1);
129  FedFatal->setBinLabel(606, "EE", 1);
130  FedFatal->setBinLabel(628, "EB", 1);
131  FedFatal->setBinLabel(651, "EE", 1);
132  FedFatal->setBinLabel(550, "ES", 1);
133  FedFatal->setBinLabel(716, "HCAL", 1);
134  FedFatal->setBinLabel(754, "CSC", 1);
135  FedFatal->setBinLabel(772, "DT", 1);
136  FedFatal->setBinLabel(791, "RPC", 1);
137  FedFatal->setBinLabel(804, "L1T", 1);
138 
139  FedNonFatal->setBinLabel(11, "PIXEL", 1);
140  FedNonFatal->setBinLabel(221, "SIST", 1);
141  FedNonFatal->setBinLabel(606, "EE", 1);
142  FedNonFatal->setBinLabel(628, "EB", 1);
143  FedNonFatal->setBinLabel(651, "EE", 1);
144  FedNonFatal->setBinLabel(550, "ES", 1);
145  FedNonFatal->setBinLabel(716, "HCAL", 1);
146  FedNonFatal->setBinLabel(754, "CSC", 1);
147  FedNonFatal->setBinLabel(772, "DT", 1);
148  FedNonFatal->setBinLabel(791, "RPC", 1);
149  FedNonFatal->setBinLabel(804, "L1T", 1);
150 
151  //-----------------------------------------------------------------------------------
152  currentFolder = moduleName + "/EventInfo";
153  dbe_->setCurrentFolder(currentFolder);
154 
155  reportSummary = dbe_->bookFloat("reportSummary");
156 
157  int nSubsystems = 10;
158 
159  if (reportSummary)
160  reportSummary->Fill(1.);
161 
162  currentFolder = moduleName + "/EventInfo/reportSummaryContents";
163  dbe_->setCurrentFolder(currentFolder);
164 
165  reportSummaryContent[0] = dbe_->bookFloat("CSC FEDs");
166  reportSummaryContent[1] = dbe_->bookFloat("DT FEDs");
167  reportSummaryContent[2] = dbe_->bookFloat("EB FEDs");
168  reportSummaryContent[3] = dbe_->bookFloat("EE FEDs");
169  reportSummaryContent[4] = dbe_->bookFloat("ES FEDs");
170  reportSummaryContent[5] = dbe_->bookFloat("Hcal FEDs");
171  reportSummaryContent[6] = dbe_->bookFloat("L1T FEDs");
172  reportSummaryContent[7] = dbe_->bookFloat("Pixel FEDs");
173  reportSummaryContent[8] = dbe_->bookFloat("RPC FEDs");
174  reportSummaryContent[9] = dbe_->bookFloat("SiStrip FEDs");
175 
176  // initialize reportSummaryContents to 1
177  for (int i = 0; i < nSubsystems; ++i) {
178  SummaryContent[i] = 1.;
180  }
181 
182  currentFolder = moduleName + "/EventInfo";
183  dbe_->setCurrentFolder(currentFolder);
184 
185  reportSummaryMap = dbe_->book2D("reportSummaryMap", "FED Report Summary Map", 1, 1, 2, 10, 1, 11);
186 
189 
190  reportSummaryMap->setBinLabel(1, " ", 1);
191  reportSummaryMap->setBinLabel(10, "CSC", 2);
192  reportSummaryMap->setBinLabel(9, "DT", 2);
193  reportSummaryMap->setBinLabel(8, "EB", 2);
194  reportSummaryMap->setBinLabel(7, "EE", 2);
195  reportSummaryMap->setBinLabel(6, "ES", 2);
196  reportSummaryMap->setBinLabel(5, "Hcal", 2);
197  reportSummaryMap->setBinLabel(4, "L1T", 2);
198  reportSummaryMap->setBinLabel(3, "Pixel", 2);
199  reportSummaryMap->setBinLabel(2, "RPC", 2);
200  reportSummaryMap->setBinLabel(1, "SiStrip", 2);
201 }
202 
204 
206  if (fillInEventloop)
207  fillHistograms();
208 }
209 
211 
213  if (fillOnEndLumi)
214  fillHistograms();
215 }
216 
218  // FED Entries
219 
220  std::vector<std::string> entries;
221  entries.push_back("CSC/" + fedFolderName + "/FEDEntries");
222  entries.push_back("DT/" + fedFolderName + "/FEDEntries");
223  entries.push_back("EcalBarrel/" + fedFolderName + "/FEDEntries");
224  entries.push_back("EcalEndcap/" + fedFolderName + "/FEDEntries");
225  entries.push_back("EcalPreshower/" + fedFolderName + "/FEDEntries");
226  entries.push_back("Hcal/" + fedFolderName + "/FEDEntries");
227  entries.push_back("L1T/" + fedFolderName + "/FEDEntries");
228  entries.push_back("Pixel/" + fedFolderName + "/FEDEntries");
229  entries.push_back("RPC/" + fedFolderName + "/FEDEntries");
230  entries.push_back("SiStrip/" + fedFolderName + "/FEDEntries");
231 
232  for (auto ent = entries.begin(); ent != entries.end(); ++ent) {
233  if (!(dbe_->get(*ent))) {
234  continue;
235  }
236 
237  MonitorElement* me = dbe_->get(*ent);
238  if (TH1F* rootHisto = me->getTH1F()) {
239  int Nbins = me->getNbinsX();
240  float entry = 0.;
241  int xmin = (int)rootHisto->GetXaxis()->GetXmin();
242  if (*ent == "L1T/" + fedFolderName + "/FEDEntries")
243  xmin = xmin + 800;
244  if (*ent == "DT/" + fedFolderName + "/FEDEntries")
245  xmin = 770; //Real DT FEDIDs are 1369-1371
246 
247  for (int bin = 1; bin <= Nbins; ++bin) {
248  int id = xmin + bin;
249  entry = rootHisto->GetBinContent(bin);
250  if (entry > 0.)
252  }
253  }
254  }
255 
256  // FED Fatal
257 
258  int nSubsystems = 10;
259 
260  std::vector<std::string> fatal;
261  fatal.push_back("CSC/" + fedFolderName + "/FEDFatal");
262  fatal.push_back("DT/" + fedFolderName + "/FEDFatal");
263  fatal.push_back("EcalBarrel/" + fedFolderName + "/FEDFatal");
264  fatal.push_back("EcalEndcap/" + fedFolderName + "/FEDFatal");
265  fatal.push_back("EcalPreshower/" + fedFolderName + "/FEDFatal");
266  fatal.push_back("Hcal/" + fedFolderName + "/FEDFatal");
267  fatal.push_back("L1T/" + fedFolderName + "/FEDFatal");
268  fatal.push_back("Pixel/" + fedFolderName + "/FEDFatal");
269  fatal.push_back("RPC/" + fedFolderName + "/FEDFatal");
270  fatal.push_back("SiStrip/" + fedFolderName + "/FEDFatal");
271 
272  int k = 0, count = 0;
273 
274  float sum = 0.;
275 
276  auto ent = entries.begin();
277  for (auto fat = fatal.begin(); fat != fatal.end(); ++fat) {
278  if (!(dbe_->get(*fat))) {
280  reportSummaryMap->setBinContent(1, nSubsystems - k, -1);
281  k++;
282  ent++;
283  continue;
284  }
285 
286  MonitorElement* me = dbe_->get(*fat);
287  MonitorElement* meNorm = dbe_->get(*ent);
288 
289  float entry = 0.;
290  float norm = 0.;
291 
292  if (TH1F* rootHisto = me->getTH1F()) {
293  if (TH1F* rootHistoNorm = meNorm->getTH1F()) {
294  int Nbins = me->getNbinsX();
295  int xmin = (int)rootHisto->GetXaxis()->GetXmin();
296  if (*fat == "L1T/" + fedFolderName + "/FEDFatal")
297  xmin = xmin + 800;
298  if (*fat == "DT/" + fedFolderName + "/FEDFatal")
299  xmin = 770; //Real DT FED IDs are 1369-1371
300 
301  float binentry = 0.;
302  for (int bin = 1; bin <= Nbins; ++bin) {
303  int id = xmin + bin;
304  binentry = rootHisto->GetBinContent(bin);
305  entry += binentry;
306  norm += rootHistoNorm->GetBinContent(bin);
307  FedFatal->setBinContent(id, binentry);
308  }
309  }
310  }
311 
312  if (norm > 0)
313  SummaryContent[k] = 1.0 - entry / norm;
315  if ((k == 2 || k == 3) // for EE and EB only show yellow when more than 1% errors.
316  && SummaryContent[k] >= 0.95 && SummaryContent[k] < 0.99)
317  SummaryContent[k] = 0.949;
318  reportSummaryMap->setBinContent(1, nSubsystems - k, SummaryContent[k]);
319  sum = sum + SummaryContent[k];
320 
321  k++;
322  ent++;
323  count++;
324  }
325 
326  if (count > 0)
327  reportSummary->Fill(sum / (float)count);
328 
329  // FED Non Fatal
330 
331  std::vector<std::string> nonfatal;
332  nonfatal.push_back("CSC/" + fedFolderName + "/FEDNonFatal");
333  nonfatal.push_back("DT/" + fedFolderName + "/FEDNonFatal");
334  nonfatal.push_back("EcalBarrel/" + fedFolderName + "/FEDNonFatal");
335  nonfatal.push_back("EcalEndcap/" + fedFolderName + "/FEDNonFatal");
336  nonfatal.push_back("EcalPreshower/" + fedFolderName + "/FEDNonFatal");
337  nonfatal.push_back("Hcal/" + fedFolderName + "/FEDNonFatal");
338  nonfatal.push_back("L1T/" + fedFolderName + "/FEDNonFatal");
339  nonfatal.push_back("Pixel/" + fedFolderName + "/FEDNonFatal");
340  nonfatal.push_back("RPC/" + fedFolderName + "/FEDNonFatal");
341  nonfatal.push_back("SiStrip/" + fedFolderName + "/FEDNonFatal");
342 
343  for (auto non = nonfatal.begin(); non != nonfatal.end(); ++non) {
344  if (!(dbe_->get(*non))) {
345  continue;
346  }
347 
348  MonitorElement* me = dbe_->get(*non);
349 
350  if (TH1F* rootHisto = me->getTH1F()) {
351  int Nbins = me->getNbinsX();
352  float entry = 0.;
353  int xmin = (int)rootHisto->GetXaxis()->GetXmin();
354  if (*non == "L1T/" + fedFolderName + "/FEDNonFatal")
355  xmin = xmin + 800;
356 
357  for (int bin = 1; bin <= Nbins; ++bin) {
358  int id = xmin + bin;
359  entry = rootHisto->GetBinContent(bin);
360  if (entry > 0.)
362  }
363  }
364  }
365 }
366 
368  if (fillOnEndRun)
369  fillHistograms();
370 }
371 
373  if (fillOnEndJob)
374  fillHistograms();
375 }
376 
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:646
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
dqm::legacy::DQMStore DQMStore
DQMFEDIntegrityClient(const edm::ParameterSet &)
void endRun(const edm::Run &r, const edm::EventSetup &c) override
MonitorElement * reportSummaryContent[10]
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual 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)
void beginRun(const edm::Run &r, const edm::EventSetup &c) override
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c) override
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual TH1F * getTH1F() const
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
edm::ParameterSet parameters_
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c) override
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
MonitorElement * reportSummary
~DQMFEDIntegrityClient() override=default
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * reportSummaryMap
dqm::legacy::MonitorElement MonitorElement
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)