CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GEMDQMHarvester.cc
Go to the documentation of this file.
10 
11 //DQM services
16 
17 #include <TH2F.h>
18 #include <TFile.h>
19 #include <TDirectoryFile.h>
20 #include <TKey.h>
21 
22 using namespace edm;
23 
24 class GEMDQMHarvester : public DQMEDHarvester {
25 public:
27  ~GEMDQMHarvester() override{};
28  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
29 
30  typedef std::tuple<int, int> IdChamber;
31  typedef std::tuple<int, int, int> IdVFAT;
32  typedef struct PreStatusInfo {
34  int nLumiEnd;
35  int nStatus;
36  } StatusInfo;
37 
38  class NumStatus {
39  public:
40  NumStatus(Float_t fNumTotal = 0,
41  Float_t fNumOcc = 0,
42  Float_t fNumErrVFAT = 0,
43  Float_t fNumWarnVFAT = 0,
44  Float_t fNumErrOH = 0,
45  Float_t fNumWarnOH = 0,
46  Float_t fNumErrAMC = 0,
47  Float_t fNumWarnAMC = 0,
48  Float_t fNumErrAMC13 = 0)
49  : fNumTotal_(fNumTotal),
50  fNumOcc_(fNumOcc),
51  fNumErrVFAT_(fNumErrVFAT),
52  fNumWarnVFAT_(fNumWarnVFAT),
53  fNumErrOH_(fNumErrOH),
54  fNumWarnOH_(fNumWarnOH),
55  fNumErrAMC_(fNumErrAMC),
56  fNumWarnAMC_(fNumWarnAMC),
57  fNumErrAMC13_(fNumErrAMC13) {}
58  float fNumTotal_;
59  float fNumOcc_;
60  float fNumErrVFAT_;
62  float fNumErrOH_;
63  float fNumWarnOH_;
64  float fNumErrAMC_;
65  float fNumWarnAMC_;
67  };
68 
69 protected:
70  void dqmEndLuminosityBlock(DQMStore::IBooker &,
72  edm::LuminosityBlock const &iLumi,
73  edm::EventSetup const &) override;
74  void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override{}; // Cannot use; it is called after dqmSaver
75 
76  void drawSummaryHistogram(edm::Service<DQMStore> &store, Int_t nLumiCurr);
77  void createTableWatchingSummary();
78  void copyLabels(MonitorElement *h2Src, MonitorElement *h2Dst);
79  void createSummaryHist(edm::Service<DQMStore> &store,
80  MonitorElement *h2Src,
81  MonitorElement *&h2Sum,
82  std::vector<std::string> &listLayers,
83  std::map<std::string, int> &mapIdxLayer,
84  std::map<int, int> &mapNumChPerChamber);
85  void createSummaryVFAT(edm::Service<DQMStore> &store,
86  MonitorElement *h2Src,
87  std::string strSuffix,
88  MonitorElement *&h2Sum);
89  Float_t refineSummaryHistogram(std::string strName,
90  MonitorElement *h2Sum,
91  MonitorElement *h2SrcOcc,
92  MonitorElement *h2SrcStatusA,
93  MonitorElement *h2SrcStatusE,
94  MonitorElement *h2SrcStatusW,
95  MonitorElement *h2SrcStatusEVFAT,
96  MonitorElement *h2SrcStatusWVFAT,
97  MonitorElement *h2SrcStatusEOH,
98  MonitorElement *h2SrcStatusWOH,
99  MonitorElement *h2SrcStatusEAMC,
100  MonitorElement *h2SrcStatusWAMC,
101  MonitorElement *h2SrcStatusEAMC13,
102  Int_t nLumiCurr);
103  Int_t refineSummaryVFAT(std::string strName,
104  MonitorElement *h2Sum,
105  MonitorElement *h2SrcOcc,
106  MonitorElement *h2SrcStatusE,
107  MonitorElement *h2SrcStatusW,
108  Int_t nLumiCurr,
109  Int_t nIdxLayer);
110  Int_t assessOneBin(
111  std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn);
112 
113  Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus);
114  Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr, NumStatus numStatus);
115  Int_t UpdateStatusChamber(std::vector<StatusInfo> &listStatus,
116  NumStatus &numStatus,
117  Int_t nLumiCurr,
118  NumStatus numStatusNew);
119  void createLumiFuncHist(edm::Service<DQMStore> &store, std::string strSuffix, Int_t nIdxLayer, Int_t nLumiCurr);
120 
121  Float_t fCutErr_, fCutLowErr_, fCutWarn_;
122 
123  const std::string strDirSummary_ = "GEM/EventInfo";
124  const std::string strDirRecHit_ = "GEM/RecHits";
125  const std::string strDirStatus_ = "GEM/DAQStatus";
126 
127  const Int_t nCodeFine_ = 1;
128  const Int_t nCodeError_ = 2;
129  const Int_t nCodeWarning_ = 3;
130  const Int_t nCodeLowError_ = 4;
131 
132  const Int_t nBitWarnVFAT_ = 7;
133  const Int_t nBitErrVFAT_ = 6;
134  const Int_t nBitWarnOH_ = 5;
135  const Int_t nBitErrOH_ = 4;
136  const Int_t nBitWarnAMC_ = 3;
137  const Int_t nBitErrAMC_ = 2;
138  const Int_t nBitErrAMC13_ = 1;
139  const Int_t nBitOcc_ = 0;
140 
141  const Int_t nNumVFATs_ = 24;
142 
143  const Int_t nMaxLumi_ = 6000; // From DQMServices/Components/plugins/DQMProvInfo.h
144  //const Int_t nResolutionLumi_ = 5;
146 
147  typedef std::vector<std::vector<Float_t>> TableStatusOcc;
148  typedef std::vector<std::vector<Int_t>> TableStatusNum;
149 
150  std::map<IdChamber, std::vector<StatusInfo>> mapStatusChambersSummary_;
151  std::map<IdVFAT, std::vector<StatusInfo>> mapStatusVFATsSummary_;
152  std::map<IdChamber, NumStatus> mapNumStatusChambersSummary_;
153  std::map<IdVFAT, NumStatus> mapNumStatusVFATsSummary_;
154 
155  std::vector<std::string> listLayer_;
156  std::map<std::string, int> mapIdxLayer_; // All indices in the following objects start at 1
157  std::map<int, int> mapNumChPerChamber_;
158  std::map<int, MonitorElement *> mapHistLumiFunc_;
160 };
161 
163  fCutErr_ = cfg.getParameter<double>("cutErr");
164  fCutLowErr_ = cfg.getParameter<double>("cutLowErr");
165  fCutWarn_ = cfg.getParameter<double>("cutWarn");
166  nResolutionLumi_ = cfg.getParameter<int>("resolutionLumi");
167  bIsStatusChambersInit_ = false;
168 }
169 
172  desc.add<double>("cutErr", 0.05);
173  desc.add<double>("cutLowErr", 0.00);
174  desc.add<double>("cutWarn", 0.05);
175  desc.add<int>("resolutionLumi", 1);
176  descriptions.add("GEMDQMHarvester", desc);
177 }
178 
181  edm::LuminosityBlock const &iLumi,
182  edm::EventSetup const &) {
184  Int_t nLumiCurr = iLumi.id().luminosityBlock();
185  drawSummaryHistogram(store, nLumiCurr);
186 }
187 
189  Float_t fReportSummary = -1.0;
190 
191  std::string strSrcDigiOcc = "GEM/Digis/summaryOccDigi";
192  std::string strSrcStatusA = "GEM/DAQStatus/chamberAllStatus";
193  std::string strSrcStatusE = "GEM/DAQStatus/chamberErrors";
194  std::string strSrcStatusW = "GEM/DAQStatus/chamberWarnings";
195  std::string strSrcStatusEVFAT = "GEM/DAQStatus/chamberVFATErrors";
196  std::string strSrcStatusWVFAT = "GEM/DAQStatus/chamberVFATWarnings";
197  std::string strSrcStatusEOH = "GEM/DAQStatus/chamberOHErrors";
198  std::string strSrcStatusWOH = "GEM/DAQStatus/chamberOHWarnings";
199  std::string strSrcStatusEAMC = "GEM/DAQStatus/chamberAMCErrors";
200  std::string strSrcStatusWAMC = "GEM/DAQStatus/chamberAMCWarnings";
201  std::string strSrcStatusEAMC13 = "GEM/DAQStatus/chamberAMC13Errors";
202 
203  std::string strSrcVFATOcc = "GEM/Digis/det";
204  std::string strSrcVFATStatusW = "GEM/DAQStatus/vfat_statusWarnSum";
205  std::string strSrcVFATStatusE = "GEM/DAQStatus/vfat_statusErrSum";
206 
207  store->setCurrentFolder(strDirSummary_);
208 
209  MonitorElement *h2SrcDigiOcc = store->get(strSrcDigiOcc);
210  MonitorElement *h2SrcStatusA = store->get(strSrcStatusA);
211  MonitorElement *h2SrcStatusE = store->get(strSrcStatusE);
212  MonitorElement *h2SrcStatusW = store->get(strSrcStatusW);
213  MonitorElement *h2SrcStatusEVFAT = store->get(strSrcStatusEVFAT);
214  MonitorElement *h2SrcStatusWVFAT = store->get(strSrcStatusWVFAT);
215  MonitorElement *h2SrcStatusEOH = store->get(strSrcStatusEOH);
216  MonitorElement *h2SrcStatusWOH = store->get(strSrcStatusWOH);
217  MonitorElement *h2SrcStatusEAMC = store->get(strSrcStatusEAMC);
218  MonitorElement *h2SrcStatusWAMC = store->get(strSrcStatusWAMC);
219  MonitorElement *h2SrcStatusEAMC13 = store->get(strSrcStatusEAMC13);
220 
221  std::string strTitleSummary = "summary";
222 
223  if (h2SrcDigiOcc != nullptr && h2SrcStatusA != nullptr && h2SrcStatusE != nullptr && h2SrcStatusW != nullptr &&
224  h2SrcStatusEVFAT != nullptr && h2SrcStatusWVFAT != nullptr && h2SrcStatusEOH != nullptr &&
225  h2SrcStatusWOH != nullptr && h2SrcStatusEAMC != nullptr && h2SrcStatusWAMC != nullptr &&
226  h2SrcStatusEAMC13 != nullptr) {
227  MonitorElement *h2Sum = nullptr;
228  createSummaryHist(store, h2SrcStatusEOH, h2Sum, listLayer_, mapIdxLayer_, mapNumChPerChamber_);
229  createTableWatchingSummary();
230  fReportSummary = refineSummaryHistogram(strTitleSummary,
231  h2Sum,
232  h2SrcDigiOcc,
233  h2SrcStatusA,
234  h2SrcStatusE,
235  h2SrcStatusW,
236  h2SrcStatusEVFAT,
237  h2SrcStatusWVFAT,
238  h2SrcStatusEOH,
239  h2SrcStatusWOH,
240  h2SrcStatusEAMC,
241  h2SrcStatusWAMC,
242  h2SrcStatusEAMC13,
243  nLumiCurr);
244 
245  for (const auto &strSuffix : listLayer_) {
246  auto nIdxLayer = mapIdxLayer_[strSuffix];
247  MonitorElement *h2SrcVFATOcc = store->get(strSrcVFATOcc + strSuffix);
248  MonitorElement *h2SrcVFATStatusW = store->get(strSrcVFATStatusW + strSuffix);
249  MonitorElement *h2SrcVFATStatusE = store->get(strSrcVFATStatusE + strSuffix);
250  if (h2SrcVFATOcc == nullptr || h2SrcVFATStatusW == nullptr || h2SrcVFATStatusE == nullptr)
251  continue;
252 
253  MonitorElement *h2SumVFAT = nullptr;
254  createSummaryVFAT(store, h2SrcVFATStatusE, strSuffix, h2SumVFAT);
255  refineSummaryVFAT(strSuffix, h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatusE, h2SrcVFATStatusW, nLumiCurr, nIdxLayer);
256  TString strNewTitle = h2SrcVFATStatusE->getTitle();
257  h2SumVFAT->setTitle((const char *)strNewTitle.ReplaceAll("errors", "errors/warnings"));
258  h2SumVFAT->setXTitle(h2SrcVFATStatusE->getAxisTitle(1));
259  h2SumVFAT->setYTitle(h2SrcVFATStatusE->getAxisTitle(2));
260 
261  createLumiFuncHist(store, strSuffix, nIdxLayer, nLumiCurr);
262  }
263  }
264 
265  store->bookFloat("reportSummary")->Fill(fReportSummary);
266 }
267 
269  if (bIsStatusChambersInit_)
270  return;
271 
272  for (const auto &[nIdxLayer, nNumCh] : mapNumChPerChamber_) {
273  for (Int_t i = 1; i <= nNumCh; i++) {
274  mapStatusChambersSummary_[{nIdxLayer, i}] = std::vector<StatusInfo>();
275  mapNumStatusChambersSummary_[{nIdxLayer, i}] = NumStatus();
276  for (Int_t j = 1; j <= nNumVFATs_; j++) {
277  mapStatusVFATsSummary_[{nIdxLayer, i, j}] = std::vector<StatusInfo>();
278  mapNumStatusVFATsSummary_[{nIdxLayer, i, j}] = NumStatus();
279  }
280  }
281  }
282 
283  bIsStatusChambersInit_ = true;
284 }
285 
287  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
288 
289  for (Int_t i = 1; i <= nBinX; i++) {
290  h2Dst->setBinLabel(i, h2Src->getTH2F()->GetXaxis()->GetBinLabel(i), 1);
291  }
292  for (Int_t i = 1; i <= nBinY; i++) {
293  h2Dst->setBinLabel(i, h2Src->getTH2F()->GetYaxis()->GetBinLabel(i), 2);
294  }
295  h2Dst->setTitle(h2Src->getTitle());
296  h2Dst->setXTitle(h2Src->getAxisTitle(1));
297  h2Dst->setYTitle(h2Src->getAxisTitle(2));
298 }
299 
301  MonitorElement *h2Src,
302  MonitorElement *&h2Sum,
303  std::vector<std::string> &listLayers,
304  std::map<std::string, int> &mapIdxLayer,
305  std::map<int, int> &mapNumChPerChamber) {
306  //store->setCurrentFolder(strDirSummary_);
307 
308  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
309  h2Sum = store->book2D("reportSummaryMap", "", nBinX, 0.5, nBinX + 0.5, nBinY, 0.5, nBinY + 0.5);
310  h2Sum->setTitle("Summary plot");
311  h2Sum->setXTitle("Chamber");
312  h2Sum->setYTitle("Layer");
313 
314  listLayers.clear();
315  mapIdxLayer.clear();
316  mapNumChPerChamber.clear();
317 
318  for (Int_t i = 1; i <= nBinX; i++)
319  h2Sum->setBinLabel(i, h2Src->getTH2F()->GetXaxis()->GetBinLabel(i), 1);
320  for (Int_t i = 1; i <= nBinY; i++) {
321  std::string strLabelFull = h2Src->getTH2F()->GetYaxis()->GetBinLabel(i);
322  Int_t nBinXActual = (Int_t)(h2Src->getBinContent(0, i) + 0.5);
323  auto nPos = strLabelFull.find(';');
324  auto strLabel = strLabelFull.substr(0, nPos);
325  auto strLayer = strLabelFull.substr(nPos + 1);
326  listLayers.push_back(strLabelFull.substr(nPos + 1));
327  h2Sum->setBinLabel(i, strLabel, 2);
328  mapIdxLayer[strLayer] = i;
329  mapNumChPerChamber[i] = nBinXActual;
330  }
331 }
332 
334  MonitorElement *h2Src,
335  std::string strSuffix,
336  MonitorElement *&h2Sum) {
337  //store->setCurrentFolder(strDirStatus_);
338  //store->setCurrentFolder(strDirSummary_);
339 
340  Int_t nBinX = h2Src->getNbinsX(), nBinY = h2Src->getNbinsY();
341  h2Sum = store->book2D("vfat_statusSummary" + strSuffix, "", nBinX, 0.5, nBinX + 0.5, nBinY, -0.5, nBinY - 0.5);
342  copyLabels(h2Src, h2Sum);
343 }
344 
346  std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn) {
347  if (fNumErr > fCutErr_ * fAll) // The error status criterion
348  return nCodeError_;
349  else if (fNumErr > fCutLowErr_ * fAll) // The low-error status criterion
350  return nCodeLowError_;
351  else if (fNumWarn > fCutWarn_ * fAll) // The warning status criterion
352  return nCodeWarning_;
353  else if (fNumOcc > 0)
354  return nCodeFine_;
355 
356  return 0;
357 }
358 
359 // FIXME: Need more study about how to summarize
361  MonitorElement *h2Sum,
362  MonitorElement *h2SrcOcc,
363  MonitorElement *h2SrcStatusA,
364  MonitorElement *h2SrcStatusE,
365  MonitorElement *h2SrcStatusW,
366  MonitorElement *h2SrcStatusEVFAT,
367  MonitorElement *h2SrcStatusWVFAT,
368  MonitorElement *h2SrcStatusEOH,
369  MonitorElement *h2SrcStatusWOH,
370  MonitorElement *h2SrcStatusEAMC,
371  MonitorElement *h2SrcStatusWAMC,
372  MonitorElement *h2SrcStatusEAMC13,
373  Int_t nLumiCurr) {
374  Int_t nBinY = h2Sum->getNbinsY();
375  Int_t nAllBin = 0, nFineBin = 0;
376  for (Int_t j = 1; j <= nBinY; j++) {
377  Int_t nBinX = (Int_t)(h2SrcOcc->getBinContent(0, j) + 0.5);
378  h2Sum->setBinContent(0, j, nBinX);
379  for (Int_t i = 1; i <= nBinX; i++) {
380  Float_t fOcc = h2SrcOcc->getBinContent(i, j);
381  Float_t fStatusAll = h2SrcStatusA->getBinContent(i, j);
382  Float_t fStatusErr = h2SrcStatusE->getBinContent(i, j);
383  Float_t fStatusWarn = h2SrcStatusW->getBinContent(i, j);
384  Float_t fStatusErrVFAT = h2SrcStatusEVFAT->getBinContent(i, j);
385  Float_t fStatusWarnVFAT = h2SrcStatusWVFAT->getBinContent(i, j);
386  Float_t fStatusErrOH = h2SrcStatusEOH->getBinContent(i, j);
387  Float_t fStatusWarnOH = h2SrcStatusWOH->getBinContent(i, j);
388  Float_t fStatusErrAMC = h2SrcStatusEAMC->getBinContent(i, j);
389  Float_t fStatusWarnAMC = h2SrcStatusWAMC->getBinContent(i, j);
390  Float_t fStatusErrAMC13 = h2SrcStatusEAMC13->getBinContent(i, j);
391  NumStatus numStatus(fStatusAll,
392  fOcc,
393  fStatusErrVFAT,
394  fStatusWarnVFAT,
395  fStatusErrOH,
396  fStatusWarnOH,
397  fStatusErrAMC,
398  fStatusWarnAMC,
399  fStatusErrAMC13);
400  UpdateStatusChamber(j, i, nLumiCurr, numStatus);
401 
402  Int_t nRes = assessOneBin(strName, i, j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
403  if (nRes == 1)
404  nFineBin++;
405 
406  h2Sum->setBinContent(i, j, (Float_t)nRes);
407  nAllBin++;
408  }
409  }
410 
411  return ((Float_t)nFineBin) / nAllBin;
412 }
413 
415  MonitorElement *h2Sum,
416  MonitorElement *h2SrcOcc,
417  MonitorElement *h2SrcStatusE,
418  MonitorElement *h2SrcStatusW,
419  Int_t nLumiCurr,
420  Int_t nIdxLayer) {
421  Int_t nBinY = h2Sum->getNbinsY();
422  for (Int_t j = 1; j <= nBinY; j++) {
423  Int_t nBinX = h2Sum->getNbinsX();
424  for (Int_t i = 1; i <= nBinX; i++) {
425  Float_t fOcc = h2SrcOcc->getBinContent(i, j);
426  Float_t fStatusErr = h2SrcStatusE->getBinContent(i, j);
427  Float_t fStatusWarn = h2SrcStatusW->getBinContent(i, j);
428  Float_t fStatusAll = fOcc + fStatusErr + fStatusWarn;
429  NumStatus numStatus(fStatusAll, fOcc, fStatusErr, fStatusWarn, 0, 0, 0, 0, 0);
430  UpdateStatusChamber(nIdxLayer, i, j, nLumiCurr, numStatus);
431 
432  Int_t nRes = assessOneBin(strName, i, j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
433  h2Sum->setBinContent(i, j, (Float_t)nRes);
434  }
435  }
436 
437  return 0;
438 }
439 
440 Int_t GEMDQMHarvester::UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus) {
441  if (!bIsStatusChambersInit_)
442  return 0;
443  if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
444  return 0;
445  auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
446  auto &numStatusPrev = mapNumStatusChambersSummary_[{nIdxLayer, nIdxCh}];
447  return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
448 }
449 
451  Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr, NumStatus numStatus) {
452  if (!bIsStatusChambersInit_)
453  return 0;
454  if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
455  return 0;
456  if (0 >= nIdxVFAT || nIdxVFAT > nNumVFATs_)
457  return 0;
458  auto &listStatus = mapStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
459  auto &numStatusPrev = mapNumStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
460  return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
461 }
462 
463 Int_t GEMDQMHarvester::UpdateStatusChamber(std::vector<StatusInfo> &listStatus,
464  NumStatus &numStatus,
465  Int_t nLumiCurr,
466  NumStatus numStatusNew) {
467  // First of all, the current lumi section will be assessed, of which the result will be stored in nStatus
468  Int_t nStatus = 0;
469 
470  Float_t fNumAddErrVFAT = numStatusNew.fNumErrVFAT_ - numStatus.fNumErrVFAT_;
471  Float_t fNumAddWarnVFAT = numStatusNew.fNumWarnVFAT_ - numStatus.fNumWarnVFAT_;
472  Float_t fNumAddErrOH = numStatusNew.fNumErrOH_ - numStatus.fNumErrOH_;
473  Float_t fNumAddWarnOH = numStatusNew.fNumWarnOH_ - numStatus.fNumWarnOH_;
474  Float_t fNumAddErrAMC = numStatusNew.fNumErrAMC_ - numStatus.fNumErrAMC_;
475  Float_t fNumAddWarnAMC = numStatusNew.fNumWarnAMC_ - numStatus.fNumWarnAMC_;
476  Float_t fNumAddErrAMC13 = numStatusNew.fNumErrAMC13_ - numStatus.fNumErrAMC13_;
477 
478  numStatus.fNumTotal_ = numStatusNew.fNumTotal_;
479  numStatus.fNumOcc_ = numStatusNew.fNumOcc_;
480  numStatus.fNumErrVFAT_ = numStatusNew.fNumErrVFAT_;
481  numStatus.fNumWarnVFAT_ = numStatusNew.fNumWarnVFAT_;
482  numStatus.fNumErrOH_ = numStatusNew.fNumErrOH_;
483  numStatus.fNumWarnOH_ = numStatusNew.fNumWarnOH_;
484  numStatus.fNumErrAMC_ = numStatusNew.fNumErrAMC_;
485  numStatus.fNumWarnAMC_ = numStatusNew.fNumWarnAMC_;
486  numStatus.fNumErrAMC13_ = numStatusNew.fNumErrAMC13_;
487 
488  nStatus = (numStatusNew.fNumOcc_ > 0 ? 1 << nBitOcc_ : 0) | (fNumAddErrAMC13 > 0 ? 1 << nBitErrAMC13_ : 0) |
489  (fNumAddErrAMC > 0 ? 1 << nBitErrAMC_ : 0) | (fNumAddWarnAMC > 0 ? 1 << nBitWarnAMC_ : 0) |
490  (fNumAddErrOH > 0 ? 1 << nBitErrOH_ : 0) | (fNumAddWarnOH > 0 ? 1 << nBitWarnOH_ : 0) |
491  (fNumAddErrVFAT > 0 ? 1 << nBitErrVFAT_ : 0) | (fNumAddWarnVFAT > 0 ? 1 << nBitWarnVFAT_ : 0);
492 
493  // Only used in the next if statement; See statusLast
494  StatusInfo statusNew;
495  statusNew.nLumiStart = nLumiCurr;
496  statusNew.nLumiEnd = nLumiCurr;
497  statusNew.nStatus = nStatus;
498 
499  if (listStatus.empty()) {
500  listStatus.push_back(statusNew);
501  } else {
502  auto &statusLastPre = listStatus.back();
503  if (statusLastPre.nStatus == nStatus) {
504  statusLastPre.nLumiEnd = nLumiCurr;
505  } else {
506  listStatus.push_back(statusNew);
507  }
508  }
509 
510  return 0;
511 }
512 
514  std::string strSuffix,
515  Int_t nIdxLayer,
516  Int_t nLumiCurr) {
517  auto &nNumCh = mapNumChPerChamber_[nIdxLayer];
518 
519  MonitorElement *h2Summary;
520 
521  //Int_t nLumiCurrLowRes = ( ( nLumiCurr - 1 ) / nResolutionLumi_ ) * nResolutionLumi_;
522  Int_t nNumBinLumi = ((nLumiCurr - 1) / nResolutionLumi_) + 1;
523  Int_t nMaxBin = 0;
524 
525  // Creating or Summoning the corresponding histogram
526  if (mapHistLumiFunc_.find(nIdxLayer) == mapHistLumiFunc_.end()) {
527  store->setCurrentFolder(strDirSummary_);
528  h2Summary = store->book2S("chamberStatus_inLumi" + strSuffix,
529  "Chamber status on lumi-block " + strSuffix.substr(1),
530  nMaxLumi_ / nResolutionLumi_,
531  1.0,
532  (Float_t)(nMaxLumi_ + 1),
533  //nNumBinLumi, 1.0, (Float_t)( nLumiCurr + 1 ),
534  nNumCh,
535  0.5,
536  nNumCh + 0.5);
537  mapHistLumiFunc_[nIdxLayer] = h2Summary;
538 
539  h2Summary->setXTitle("Luminosity block");
540  h2Summary->setYTitle("Chamber");
541  for (Int_t i = 1; i <= nNumCh; i++) {
542  h2Summary->setBinLabel(i, Form("%i", i), 2);
543  }
544  } else {
545  h2Summary = mapHistLumiFunc_[nIdxLayer];
546  }
547 
548  for (Int_t nIdxCh = 1; nIdxCh <= nNumCh; nIdxCh++) {
549  auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
550 
551  Int_t nIdxStatus = 0;
552  for (Int_t nIdxLumi = 0; nIdxLumi < nNumBinLumi; nIdxLumi++) {
553  // Lumis covered by these values (nLumiStart <=, <= nLumiEnd) are counted for the current bin
554  Int_t nLumiStart = 1 + nIdxLumi * nResolutionLumi_;
555  Int_t nLumiEnd = (1 + nIdxLumi) * nResolutionLumi_;
556  if (nLumiEnd > nLumiCurr)
557  nLumiEnd = nLumiCurr;
558 
559  Int_t nStatusSum = 0;
560  while (true) { // No worries, nIdxStatus must increase and reach at listStatus.size()
561  // True: It was too past so that
562  // the lumi range of listStatus[ nIdxStatus ] is out of the coverage of the current bin
563  if (listStatus[nIdxStatus].nLumiEnd < nLumiStart) {
564  nIdxStatus++;
565  if (nIdxStatus >= (int)listStatus.size()) {
566  break; // For safety
567  }
568  continue;
569  }
570 
571  nStatusSum = listStatus[nIdxStatus].nStatus;
572 
573  // True: This is the last item of listStatus which is covered by the current bin
574  if (nIdxStatus + 1 >= (int)listStatus.size() || listStatus[nIdxStatus].nLumiEnd >= nLumiEnd) {
575  break;
576  }
577 
578  nIdxStatus++;
579  if (nIdxStatus >= (int)listStatus.size()) {
580  break; // For safety
581  }
582  }
583 
584  h2Summary->setBinContent(nIdxLumi + 1, nIdxCh, nStatusSum);
585  if (nMaxBin < nIdxLumi + 1)
586  nMaxBin = nIdxLumi + 1;
587  }
588  }
589 
590  for (Int_t nX = 1; nX <= nMaxBin; nX++) {
591  h2Summary->setBinContent(nX, 0, 1);
592  }
593 }
594 
LuminosityBlockID id() const
virtual std::string getTitle() const
get MonitorElement title
virtual void setTitle(const std::string &title)
set (ie. change) histogram/profile title
std::map< std::string, int > mapIdxLayer_
virtual TH2F * getTH2F() const
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
tuple cfg
Definition: looper.py:296
void createSummaryVFAT(edm::Service< DQMStore > &store, MonitorElement *h2Src, std::string strSuffix, MonitorElement *&h2Sum)
MonitorElement * book2S(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:219
virtual int getNbinsY() const
get # of bins in Y-axis
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
~GEMDQMHarvester() override
virtual std::string getAxisTitle(int axis=1) const
get x-, y- or z-axis title (axis=1, 2, 3 respectively)
void copyLabels(MonitorElement *h2Src, MonitorElement *h2Dst)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &iLumi, edm::EventSetup const &) override
std::map< IdChamber, std::vector< StatusInfo > > mapStatusChambersSummary_
std::map< IdVFAT, NumStatus > mapNumStatusVFATsSummary_
void createTableWatchingSummary()
std::vector< std::string > listLayer_
void Fill(long long x)
std::map< IdVFAT, std::vector< StatusInfo > > mapStatusVFATsSummary_
void drawSummaryHistogram(edm::Service< DQMStore > &store, Int_t nLumiCurr)
virtual void setXTitle(std::string const &title)
virtual int getNbinsX() const
get # of bins in X-axis
std::tuple< int, int > IdChamber
std::vector< std::vector< Float_t > > TableStatusOcc
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Bool_t bIsStatusChambersInit_
NumStatus(Float_t fNumTotal=0, Float_t fNumOcc=0, Float_t fNumErrVFAT=0, Float_t fNumWarnVFAT=0, Float_t fNumErrOH=0, Float_t fNumWarnOH=0, Float_t fNumErrAMC=0, Float_t fNumWarnAMC=0, Float_t fNumErrAMC13=0)
std::map< int, MonitorElement * > mapHistLumiFunc_
Int_t assessOneBin(std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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)
virtual double getBinContent(int binx) const
get content of bin (1-D)
void createSummaryHist(edm::Service< DQMStore > &store, MonitorElement *h2Src, MonitorElement *&h2Sum, std::vector< std::string > &listLayers, std::map< std::string, int > &mapIdxLayer, std::map< int, int > &mapNumChPerChamber)
virtual void setYTitle(std::string const &title)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
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:177
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
GEMDQMHarvester(const edm::ParameterSet &)
LuminosityBlockNumber_t luminosityBlock() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus)
std::map< IdChamber, NumStatus > mapNumStatusChambersSummary_
std::vector< std::vector< Int_t > > TableStatusNum
Int_t refineSummaryVFAT(std::string strName, MonitorElement *h2Sum, MonitorElement *h2SrcOcc, MonitorElement *h2SrcStatusE, MonitorElement *h2SrcStatusW, Int_t nLumiCurr, Int_t nIdxLayer)
Float_t refineSummaryHistogram(std::string strName, MonitorElement *h2Sum, MonitorElement *h2SrcOcc, MonitorElement *h2SrcStatusA, MonitorElement *h2SrcStatusE, MonitorElement *h2SrcStatusW, MonitorElement *h2SrcStatusEVFAT, MonitorElement *h2SrcStatusWVFAT, MonitorElement *h2SrcStatusEOH, MonitorElement *h2SrcStatusWOH, MonitorElement *h2SrcStatusEAMC, MonitorElement *h2SrcStatusWAMC, MonitorElement *h2SrcStatusEAMC13, Int_t nLumiCurr)
std::map< int, int > mapNumChPerChamber_
void createLumiFuncHist(edm::Service< DQMStore > &store, std::string strSuffix, Int_t nIdxLayer, Int_t nLumiCurr)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::tuple< int, int, int > IdVFAT
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override