CMS 3D CMS Logo

MonitorElement.cc
Go to the documentation of this file.
1 #define __STDC_FORMAT_MACROS 1
2 #define DQM_ROOT_METHODS 1
6 #include "TClass.h"
7 #include "TMath.h"
8 #include "TList.h"
9 #include "THashList.h"
10 #include <iostream>
11 #include <cassert>
12 #include <cfloat>
13 #include <cinttypes>
14 
15 #if !WITHOUT_CMS_FRAMEWORK
17 #endif
18 
19 static TH1 *
20 checkRootObject(const std::string &name, TObject *tobj, const char *func, int reqdim)
21 {
22  if (! tobj)
23  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
24  " element '%s' because it is not a ROOT object.",
25  func, name.c_str());
26 
27  auto *h = static_cast<TH1 *>(tobj);
28  int ndim = h->GetDimension();
29  if (reqdim < 0 || reqdim > ndim)
30  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
31  " element '%s' because it requires %d dimensions; this"
32  " object of type '%s' has %d dimensions",
33  func, name.c_str(), reqdim, typeid(*h).name(), ndim);
34 
35  return h;
36 }
37 
40 {
41  switch (kind)
42  {
43  case DQM_KIND_INT:
44  case DQM_KIND_REAL:
45  case DQM_KIND_STRING:
46  case DQM_KIND_TH1F:
47  case DQM_KIND_TH1S:
48  case DQM_KIND_TH1D:
49  case DQM_KIND_TH2F:
50  case DQM_KIND_TH2S:
51  case DQM_KIND_TH2D:
52  case DQM_KIND_TH3F:
53  case DQM_KIND_TPROFILE:
55  data_.flags &= ~DQMNet::DQM_PROP_TYPE_MASK;
56  data_.flags |= kind;
57  break;
58 
59  default:
60  raiseDQMError("MonitorElement", "cannot initialise monitor element"
61  " to invalid type %d", (int) kind);
62  }
63 
64  return this;
65 }
66 
69 {
70  initialise(kind);
71  switch (kind)
72  {
73  case DQM_KIND_TH1F:
74  assert(dynamic_cast<TH1F *>(rootobj));
75  assert(! reference_ || dynamic_cast<TH1F *>(reference_));
76  object_ = rootobj;
77  break;
78 
79  case DQM_KIND_TH1S:
80  assert(dynamic_cast<TH1S *>(rootobj));
81  assert(! reference_ || dynamic_cast<TH1S *>(reference_));
82  object_ = rootobj;
83  break;
84 
85  case DQM_KIND_TH1D:
86  assert(dynamic_cast<TH1D *>(rootobj));
87  assert(! reference_ || dynamic_cast<TH1D *>(reference_));
88  object_ = rootobj;
89  break;
90 
91  case DQM_KIND_TH2F:
92  assert(dynamic_cast<TH2F *>(rootobj));
93  assert(! reference_ || dynamic_cast<TH2F *>(reference_));
94  object_ = rootobj;
95  break;
96 
97  case DQM_KIND_TH2S:
98  assert(dynamic_cast<TH2S *>(rootobj));
99  assert(! reference_ || dynamic_cast<TH2S *>(reference_));
100  object_ = rootobj;
101  break;
102 
103  case DQM_KIND_TH2D:
104  assert(dynamic_cast<TH2D *>(rootobj));
105  assert(! reference_ || dynamic_cast<TH1D *>(reference_));
106  object_ = rootobj;
107  break;
108 
109  case DQM_KIND_TH3F:
110  assert(dynamic_cast<TH3F *>(rootobj));
111  assert(! reference_ || dynamic_cast<TH3F *>(reference_));
112  object_ = rootobj;
113  break;
114 
115  case DQM_KIND_TPROFILE:
116  assert(dynamic_cast<TProfile *>(rootobj));
117  assert(! reference_ || dynamic_cast<TProfile *>(reference_));
118  object_ = rootobj;
119  break;
120 
121  case DQM_KIND_TPROFILE2D:
122  assert(dynamic_cast<TProfile2D *>(rootobj));
123  assert(! reference_ || dynamic_cast<TProfile2D *>(reference_));
124  object_ = rootobj;
125  break;
126 
127  default:
128  raiseDQMError("MonitorElement", "cannot initialise monitor element"
129  " as a root object with type %d", (int) kind);
130  }
131 
132  if (reference_)
134 
135  return this;
136 }
137 
140 {
141  initialise(kind);
142  if (kind == DQM_KIND_STRING)
143  scalar_.str = value;
144  else
145  raiseDQMError("MonitorElement", "cannot initialise monitor element"
146  " as a string with type %d", (int) kind);
147 
148  return this;
149 }
150 
152  : object_(nullptr),
155 {
156  data_.version = 0;
157  data_.dirname = nullptr;
158  data_.run = 0;
159  data_.lumi = 0;
160  data_.streamId = 0;
161  data_.moduleId = 0;
162  data_.tag = 0;
164  scalar_.num = 0;
165  scalar_.real = 0;
166 }
167 
169  const std::string &name)
170  : object_(nullptr),
173 {
174  data_.version = 0;
175  data_.run = 0;
176  data_.lumi = 0;
177  data_.streamId = 0;
178  data_.moduleId = 0;
179  data_.dirname = path;
180  data_.objname = name;
181  data_.tag = 0;
183  scalar_.num = 0;
184  scalar_.real = 0;
185 }
186 
188  const std::string &name,
189  uint32_t run,
190  uint32_t moduleId)
191  : object_(nullptr),
194 {
195  data_.version = 0;
196  data_.run = run;
197  data_.lumi = 0;
198  data_.streamId = 0;
200  data_.dirname = path;
201  data_.objname = name;
202  data_.tag = 0;
204  scalar_.num = 0;
205  scalar_.real = 0;
206 }
207 
209  : data_(x.data_),
210  scalar_(x.scalar_),
211  object_(nullptr),
215 {
216 }
217 
220 {
221  if (x.object_)
222  object_ = static_cast<TH1 *>(x.object_->Clone());
223 
224  if (x.refvalue_)
225  refvalue_ = static_cast<TH1 *>(x.refvalue_->Clone());
226 }
227 
230 {
231  object_ = o.object_;
232  refvalue_ = o.refvalue_;
233 
234  o.object_ = nullptr;
235  o.refvalue_ = nullptr;
236 }
237 
239 {
240  delete object_;
241  delete refvalue_;
242 }
243 
244 //utility function to check the consistency of the axis labels
245 //taken from TH1::CheckBinLabels which is not public
246 bool
247 MonitorElement::CheckBinLabels(const TAxis* a1, const TAxis * a2)
248 {
249  // check that axis have same labels
250  THashList *l1 = (const_cast<TAxis*>(a1))->GetLabels();
251  THashList *l2 = (const_cast<TAxis*>(a2))->GetLabels();
252 
253  if (!l1 && !l2 )
254  return true;
255  if (!l1 || !l2 ) {
256  return false;
257  }
258  // check now labels sizes are the same
259  if (l1->GetSize() != l2->GetSize() ) {
260  return false;
261  }
262  for (int i = 1; i <= a1->GetNbins(); ++i) {
263  TString label1 = a1->GetBinLabel(i);
264  TString label2 = a2->GetBinLabel(i);
265  if (label1 != label2) {
266  return false;
267  }
268  }
269  return true;
270 }
271 
273 void
275 {
276  update();
277  if (kind() == DQM_KIND_STRING)
278  scalar_.str = value;
279  else
280  incompatible(__PRETTY_FUNCTION__);
281 }
282 
284 void
286 {
287  update();
288  if (kind() == DQM_KIND_INT)
289  scalar_.num = static_cast<int64_t>(x);
290  else if (kind() == DQM_KIND_REAL)
291  scalar_.real = x;
292  else if (kind() == DQM_KIND_TH1F)
293  accessRootObject(__PRETTY_FUNCTION__, 1)
294  ->Fill(x, 1);
295  else if (kind() == DQM_KIND_TH1S)
296  accessRootObject(__PRETTY_FUNCTION__, 1)
297  ->Fill(x, 1);
298  else if (kind() == DQM_KIND_TH1D)
299  accessRootObject(__PRETTY_FUNCTION__, 1)
300  ->Fill(x, 1);
301  else
302  incompatible(__PRETTY_FUNCTION__);
303 }
304 
306 void
308 {
309  update();
310  if (kind() == DQM_KIND_INT)
311  scalar_.num = static_cast<int64_t>(x);
312  else if (kind() == DQM_KIND_REAL)
313  scalar_.real = static_cast<double>(x);
314  else if (kind() == DQM_KIND_TH1F)
315  accessRootObject(__PRETTY_FUNCTION__, 1)
316  ->Fill(static_cast<double>(x), 1);
317  else if (kind() == DQM_KIND_TH1S)
318  accessRootObject(__PRETTY_FUNCTION__, 1)
319  ->Fill(static_cast<double>(x), 1);
320  else if (kind() == DQM_KIND_TH1D)
321  accessRootObject(__PRETTY_FUNCTION__, 1)
322  ->Fill(static_cast<double>(x), 1);
323  else
324  incompatible(__PRETTY_FUNCTION__);
325 }
326 
328 void
329 MonitorElement::Fill(double x, double yw)
330 {
331  update();
332  if (kind() == DQM_KIND_TH1F)
333  accessRootObject(__PRETTY_FUNCTION__, 1)
334  ->Fill(x, yw);
335  else if (kind() == DQM_KIND_TH1S)
336  accessRootObject(__PRETTY_FUNCTION__, 1)
337  ->Fill(x, yw);
338  else if (kind() == DQM_KIND_TH1D)
339  accessRootObject(__PRETTY_FUNCTION__, 1)
340  ->Fill(x, yw);
341  else if (kind() == DQM_KIND_TH2F)
342  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
343  ->Fill(x, yw, 1);
344  else if (kind() == DQM_KIND_TH2S)
345  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
346  ->Fill(x, yw, 1);
347  else if (kind() == DQM_KIND_TH2D)
348  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
349  ->Fill(x, yw, 1);
350  else if (kind() == DQM_KIND_TPROFILE)
351  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
352  ->Fill(x, yw, 1);
353  else
354  incompatible(__PRETTY_FUNCTION__);
355 }
356 
360 void
361 MonitorElement::ShiftFillLast(double y, double ye, int xscale)
362 {
363  update();
364  if (kind() == DQM_KIND_TH1F
365  || kind() == DQM_KIND_TH1S
366  || kind() == DQM_KIND_TH1D)
367  {
368  int nbins = getNbinsX();
369  auto entries = (int)getEntries();
370  // first fill bins from left to right
371  int index = entries + 1 ;
372  int xlow = 2 ; int xup = nbins ;
373  // if more entries than bins then start shifting
374  if ( entries >= nbins )
375  {
376  index = nbins;
377  xlow = entries - nbins + 3 ; xup = entries+1 ;
378  // average first bin
379  double y1 = getBinContent(1);
380  double y2 = getBinContent(2);
381  double y1err = getBinError(1);
382  double y2err = getBinError(2);
383  double N = entries - nbins + 1.;
384  if ( ye == 0. || y1err == 0. || y2err == 0.)
385  {
386  // for errors zero calculate unweighted mean and its error
387  double sum = N*y1 + y2;
388  y1 = sum/(N+1.) ;
389  // FIXME check if correct
390  double s=(N+1.)*(N*y1*y1 + y2*y2) - sum*sum;
391  if (s>=0.)
392  y1err = sqrt(s)/(N+1.);
393  else
394  y1err = 0.;
395  }
396  else
397  {
398  // for errors non-zero calculate weighted mean and its error
399  double denom = (1./y1err + 1./y2err);
400  double mean = (y1/y1err + y2/y2err)/denom;
401  // FIXME check if correct
402  y1err = sqrt(((y1-mean)*(y1-mean)/y1err +
403  (y2-mean)*(y2-mean)/y2err)/denom/2.);
404  y1 = mean; // set y1 to mean for filling below
405  }
406  setBinContent(1,y1);
407  setBinError(1,y1err);
408  // shift remaining bins to the left
409  for ( int i = 3; i <= nbins ; i++)
410  {
413  }
414  }
415  // fill last bin with new values
416  setBinContent(index,y);
417  setBinError(index,ye);
418  // set entries
419  setEntries(entries+1);
420  // set axis labels and reset drawing option
421  char buffer [10];
422  sprintf (buffer, "%d", xlow*xscale);
423  std::string a(buffer); setBinLabel(2,a);
424  sprintf (buffer, "%d", xup*xscale);
425  std::string b(buffer); setBinLabel(nbins,b);
426  setBinLabel(1,"av.");
427  }
428  else
429  incompatible(__PRETTY_FUNCTION__);
430 }
432 void
433 MonitorElement::Fill(double x, double y, double zw)
434 {
435  update();
436  if (kind() == DQM_KIND_TH2F)
437  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
438  ->Fill(x, y, zw);
439  else if (kind() == DQM_KIND_TH2S)
440  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
441  ->Fill(x, y, zw);
442  else if (kind() == DQM_KIND_TH2D)
443  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
444  ->Fill(x, y, zw);
445  else if (kind() == DQM_KIND_TH3F)
446  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
447  ->Fill(x, y, zw, 1);
448  else if (kind() == DQM_KIND_TPROFILE)
449  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 2))
450  ->Fill(x, y, zw);
451  else if (kind() == DQM_KIND_TPROFILE2D)
452  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
453  ->Fill(x, y, zw, 1);
454  else
455  incompatible(__PRETTY_FUNCTION__);
456 }
457 
459 void
460 MonitorElement::Fill(double x, double y, double z, double w)
461 {
462  update();
463  if (kind() == DQM_KIND_TH3F)
464  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
465  ->Fill(x, y, z, w);
466  else if (kind() == DQM_KIND_TPROFILE2D)
467  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
468  ->Fill(x, y, z, w);
469  else
470  incompatible(__PRETTY_FUNCTION__);
471 }
472 
474 void
476 {
477  update();
478  if (kind() == DQM_KIND_INT)
479  scalar_.num = 0;
480  else if (kind() == DQM_KIND_REAL)
481  scalar_.real = 0;
482  else if (kind() == DQM_KIND_STRING)
483  scalar_.str.clear();
484  else
485  return accessRootObject(__PRETTY_FUNCTION__, 1)
486  ->Reset();
487 }
488 
490 void
492 {
493  char buf[64];
494  if (kind() == DQM_KIND_INT)
495  {
496  snprintf(buf, sizeof(buf), "%s%" PRId64, prefix, scalar_.num);
497  into = buf;
498  }
499  else if (kind() == DQM_KIND_REAL)
500  {
501  snprintf(buf, sizeof(buf), "%s%.*g", prefix, DBL_DIG+2, scalar_.real);
502  into = buf;
503  }
504  else if (kind() == DQM_KIND_STRING)
505  {
506  into.reserve(strlen(prefix) + scalar_.str.size());
507  into += prefix;
508  into += scalar_.str;
509  }
510  else
511  incompatible(__PRETTY_FUNCTION__);
512 }
513 
515 void
517 {
519 }
520 
525 {
527  if (kind() == DQM_KIND_INT)
528  packScalarData(result, "i=");
529  else if (kind() == DQM_KIND_REAL)
530  packScalarData(result, "f=");
531  else if (kind() == DQM_KIND_STRING)
532  packScalarData(result, "s=");
533  else
534  incompatible(__PRETTY_FUNCTION__);
535 
536  return result;
537 }
538 
544 {
547  result.reserve(6 + 2*data_.objname.size() + val.size());
548  result += '<'; result += data_.objname; result += '>';
549  result += val;
550  result += '<'; result += '/'; result += data_.objname; result += '>';
551  return result;
552 }
553 
557 {
558  char buf[32];
560  size_t len = sprintf(buf, "t=%" PRIu32, data_.tag);
561 
562  result.reserve(6 + 2*data_.objname.size() + len);
563  result += '<'; result += data_.objname; result += '>';
564  result += buf;
565  result += '<'; result += '/'; result += data_.objname; result += '>';
566  return result;
567 }
568 
572 {
574 
575  result.reserve(6 + 2*data_.objname.size() + 3);
576  result += '<'; result += data_.objname; result += '>';
577  result += "e=1";
578  result += '<'; result += '/'; result += data_.objname; result += '>';
579  return result;
580 }
581 
584 {
585  char buf[64];
587  size_t titlelen = data_.objname.size() + qv.qtname.size() + 1;
588  size_t buflen = sprintf(buf, "qr=st:%d:%.*g:", qv.code, DBL_DIG+2, qv.qtresult);
589 
590  result.reserve(7 + 2*titlelen + buflen + qv.algorithm.size() + qv.message.size());
591  result += '<'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
592  result += buf; result += qv.algorithm; result += ':'; result += qv.message;
593  result += '<'; result += '/'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
594  return result;
595 }
596 
597 const QReport *
599 {
600  QReport *qr;
601  DQMNet::QValue *qv;
602  const_cast<MonitorElement *>(this)->getQReport(false, qtname, qr, qv);
603  return qr;
604 }
605 
606 std::vector<QReport *>
608 {
609  std::vector<QReport *> result;
610  result.reserve(qreports_.size());
611  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
612  {
613  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
614  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
615  result.push_back(const_cast<QReport *>(&qreports_[i]));
616  }
617  return result;
618 }
619 
620 std::vector<QReport *>
622 {
623  std::vector<QReport *> result;
624  result.reserve(qreports_.size());
625  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
626  if (data_.qreports[i].code == dqm::qstatus::WARNING)
627  {
628  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
629  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
630  result.push_back(const_cast<QReport *>(&qreports_[i]));
631  }
632  return result;
633 }
634 
635 std::vector<QReport *>
637 {
638  std::vector<QReport *> result;
639  result.reserve(qreports_.size());
640  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
641  if (data_.qreports[i].code == dqm::qstatus::ERROR)
642  {
643  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
644  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
645  result.push_back(const_cast<QReport *>(&qreports_[i]));
646  }
647  return result;
648 }
649 
650 std::vector<QReport *>
652 {
653  std::vector<QReport *> result;
654  result.reserve(qreports_.size());
655  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
658  && data_.qreports[i].code != dqm::qstatus::ERROR)
659  {
660  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
661  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
662  result.push_back(const_cast<QReport *>(&qreports_[i]));
663  }
664  return result;
665 }
666 
668 void
670 {
671  assert(qreports_.size() == data_.qreports.size());
672 
673  // Rerun quality tests where the ME or the quality algorithm was modified.
674  bool dirty = wasUpdated();
675  for (size_t i = 0, e = data_.qreports.size(); i < e; ++i)
676  {
678  QReport &qr = qreports_[i];
679  QCriterion *qc = qr.qcriterion_;
680  qr.qvalue_ = &qv;
681 
682  // if (qc && (dirty || qc->wasModified())) // removed for new QTest (abm-090503)
683  if (qc && dirty)
684  {
685  assert(qc->getName() == qv.qtname);
686  std::string oldMessage = qv.message;
687  int oldStatus = qv.code;
688 
689  qc->runTest(this, qr, qv);
690 
691  if (oldStatus != qv.code || oldMessage != qv.message)
692  update();
693  }
694  }
695 
696  // Update QReport statistics.
698 }
699 
700 void
702 {
703  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
704  " element '%s'", func, data_.objname.c_str());
705 }
706 
707 TH1 *
708 MonitorElement::accessRootObject(const char *func, int reqdim) const
709 {
710  if (kind() < DQM_KIND_TH1F)
711  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
712  " element '%s' because it is not a root object",
713  func, data_.objname.c_str());
714 
715  return checkRootObject(data_.objname, object_, func, reqdim);
716 }
717 
718 /*** getter methods (wrapper around ROOT methods) ****/
719 //
721 double
722 MonitorElement::getMean(int axis /* = 1 */) const
723 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
724  ->GetMean(axis); }
725 
728 double
729 MonitorElement::getMeanError(int axis /* = 1 */) const
730 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
731  ->GetMeanError(axis); }
732 
734 double
735 MonitorElement::getRMS(int axis /* = 1 */) const
736 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
737  ->GetRMS(axis); }
738 
740 double
741 MonitorElement::getRMSError(int axis /* = 1 */) const
742 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
743  ->GetRMSError(axis); }
744 
746 int
748 { return accessRootObject(__PRETTY_FUNCTION__, 1)
749  ->GetNbinsX(); }
750 
752 int
754 { return accessRootObject(__PRETTY_FUNCTION__, 2)
755  ->GetNbinsY(); }
756 
758 int
760 { return accessRootObject(__PRETTY_FUNCTION__, 3)
761  ->GetNbinsZ(); }
762 
764 double
766 { return accessRootObject(__PRETTY_FUNCTION__, 1)
767  ->GetBinContent(binx); }
768 
770 double
771 MonitorElement::getBinContent(int binx, int biny) const
772 { return accessRootObject(__PRETTY_FUNCTION__, 2)
773  ->GetBinContent(binx, biny); }
774 
776 double
777 MonitorElement::getBinContent(int binx, int biny, int binz) const
778 { return accessRootObject(__PRETTY_FUNCTION__, 3)
779  ->GetBinContent(binx, biny, binz); }
780 
782 double
784 { return accessRootObject(__PRETTY_FUNCTION__, 1)
785  ->GetBinError(binx); }
786 
788 double
789 MonitorElement::getBinError(int binx, int biny) const
790 { return accessRootObject(__PRETTY_FUNCTION__, 2)
791  ->GetBinError(binx, biny); }
792 
794 double
795 MonitorElement::getBinError(int binx, int biny, int binz) const
796 { return accessRootObject(__PRETTY_FUNCTION__, 3)
797  ->GetBinError(binx, biny, binz); }
798 
800 double
802 { return accessRootObject(__PRETTY_FUNCTION__, 1)
803  ->GetEntries(); }
804 
806 double
808 {
809  if (kind() == DQM_KIND_TPROFILE)
810  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
811  ->GetBinEntries(bin);
812  else if (kind() == DQM_KIND_TPROFILE2D)
813  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
814  ->GetBinEntries(bin);
815  else
816  {
817  incompatible(__PRETTY_FUNCTION__);
818  return 0;
819  }
820 }
821 
823 double
825 {
826  if (kind() == DQM_KIND_TPROFILE)
827  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
828  ->GetYmin();
829  else
830  {
831  incompatible(__PRETTY_FUNCTION__);
832  return 0;
833  }
834 }
835 
837 double
839 {
840  if (kind() == DQM_KIND_TPROFILE)
841  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
842  ->GetYmax();
843  else
844  {
845  incompatible(__PRETTY_FUNCTION__);
846  return 0;
847  }
848 }
849 
852 MonitorElement::getAxisTitle(int axis /* = 1 */) const
853 { return getAxis(__PRETTY_FUNCTION__, axis)
854  ->GetTitle(); }
855 
859 { return accessRootObject(__PRETTY_FUNCTION__, 1)
860  ->GetTitle(); }
861 
862 /*** setter methods (wrapper around ROOT methods) ****/
863 //
865 void
867 {
868  update();
869  accessRootObject(__PRETTY_FUNCTION__, 1)
870  ->SetBinContent(binx, content);
871 }
872 
874 void
875 MonitorElement::setBinContent(int binx, int biny, double content)
876 {
877  update();
878  accessRootObject(__PRETTY_FUNCTION__, 2)
879  ->SetBinContent(binx, biny, content); }
880 
882 void
883 MonitorElement::setBinContent(int binx, int biny, int binz, double content)
884 {
885  update();
886  accessRootObject(__PRETTY_FUNCTION__, 3)
887  ->SetBinContent(binx, biny, binz, content); }
888 
890 void
892 {
893  update();
894  accessRootObject(__PRETTY_FUNCTION__, 1)
895  ->SetBinError(binx, error);
896 }
897 
899 void
900 MonitorElement::setBinError(int binx, int biny, double error)
901 {
902  update();
903  accessRootObject(__PRETTY_FUNCTION__, 2)
904  ->SetBinError(binx, biny, error);
905 }
906 
908 void
909 MonitorElement::setBinError(int binx, int biny, int binz, double error)
910 {
911  update();
912  accessRootObject(__PRETTY_FUNCTION__, 3)
913  ->SetBinError(binx, biny, binz, error);
914 }
915 
917 void
918 MonitorElement::setBinEntries(int bin, double nentries)
919 {
920  update();
921  if (kind() == DQM_KIND_TPROFILE)
922  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
923  ->SetBinEntries(bin, nentries);
924  else if (kind() == DQM_KIND_TPROFILE2D)
925  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
926  ->SetBinEntries(bin, nentries);
927  else
928  incompatible(__PRETTY_FUNCTION__);
929 }
930 
932 void
934 {
935  update();
936  accessRootObject(__PRETTY_FUNCTION__, 1)
937  ->SetEntries(nentries);
938 }
939 
941 void
942 MonitorElement::setBinLabel(int bin, const std::string &label, int axis /* = 1 */)
943 {
944  update();
945  if ( getAxis(__PRETTY_FUNCTION__, axis)->GetNbins() >= bin )
946  {
947  getAxis(__PRETTY_FUNCTION__, axis)
948  ->SetBinLabel(bin, label.c_str());
949  }
950  else
951  {
952 #if WITHOUT_CMS_FRAMEWORK
953  std::cout
954 #else
955  edm::LogWarning("MonitorElement")
956 #endif
957  << "*** MonitorElement: WARNING:"
958  <<"setBinLabel: attempting to set label of non-existent bin number for ME: "<< getFullname() << " \n";
959  }
960 }
961 
963 void
964 MonitorElement::setAxisRange(double xmin, double xmax, int axis /* = 1 */)
965 {
966  update();
967  getAxis(__PRETTY_FUNCTION__, axis)
968  ->SetRangeUser(xmin, xmax);
969 }
970 
972 void
973 MonitorElement::setAxisTitle(const std::string &title, int axis /* = 1 */)
974 {
975  update();
976  getAxis(__PRETTY_FUNCTION__, axis)
977  ->SetTitle(title.c_str());
978 }
979 
981 void
983 {
984  update();
985  getAxis(__PRETTY_FUNCTION__, axis)
986  ->SetTimeDisplay(value);
987 }
988 
990 void
991 MonitorElement::setAxisTimeFormat(const char *format /* = "" */, int axis /* = 1 */)
992 {
993  update();
994  getAxis(__PRETTY_FUNCTION__, axis)
995  ->SetTimeFormat(format);
996 }
997 
999 void
1000 MonitorElement::setAxisTimeOffset(double toffset, const char *option /* ="local" */, int axis /* = 1 */)
1001 {
1002  update();
1003  getAxis(__PRETTY_FUNCTION__, axis)
1004  ->SetTimeOffset(toffset, option);
1005 }
1006 
1008 void
1010 {
1011  update();
1012  accessRootObject(__PRETTY_FUNCTION__, 1)
1013  ->SetTitle(title.c_str());
1014 }
1015 
1016 TAxis *
1017 MonitorElement::getAxis(const char *func, int axis) const
1018 {
1019  TH1 *h = accessRootObject(func, axis-1);
1020  TAxis *a = nullptr;
1021  if (axis == 1)
1022  a = h->GetXaxis();
1023  else if (axis == 2)
1024  a = h->GetYaxis();
1025  else if (axis == 3)
1026  a = h->GetZaxis();
1027 
1028  if (! a)
1029  raiseDQMError("MonitorElement", "No such axis %d in monitor element"
1030  " '%s' of type '%s'", axis, data_.objname.c_str(),
1031  typeid(*h).name());
1032 
1033  return a;
1034 }
1035 
1036 // ------------ Operations for MEs that are normally never reset ---------
1037 
1040 void
1042 {
1043  update();
1044 
1045  // Create the reference object the first time this is called.
1046  // On subsequent calls accumulate the current value to the
1047  // reference, and then reset the current value. This way the
1048  // future contents will have the reference "subtracted".
1049  if (kind() == DQM_KIND_TH1F)
1050  {
1051  auto *orig = static_cast<TH1F *>(object_);
1052  auto *r = static_cast<TH1F *>(refvalue_);
1053  if (! r)
1054  {
1055  refvalue_ = r = (TH1F*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1056  r->SetDirectory(nullptr);
1057  r->Reset();
1058  }
1059 
1060  r->Add(orig);
1061  orig->Reset();
1062  }
1063  else if (kind() == DQM_KIND_TH1S)
1064  {
1065  auto *orig = static_cast<TH1S *>(object_);
1066  auto *r = static_cast<TH1S *>(refvalue_);
1067  if (! r)
1068  {
1069  refvalue_ = r = (TH1S*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1070  r->SetDirectory(nullptr);
1071  r->Reset();
1072  }
1073 
1074  r->Add(orig);
1075  orig->Reset();
1076  }
1077  else if (kind() == DQM_KIND_TH1D)
1078  {
1079  auto *orig = static_cast<TH1D *>(object_);
1080  auto *r = static_cast<TH1D *>(refvalue_);
1081  if (! r)
1082  {
1083  refvalue_ = r = (TH1D*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1084  r->SetDirectory(nullptr);
1085  r->Reset();
1086  }
1087 
1088  r->Add(orig);
1089  orig->Reset();
1090  }
1091  else if (kind() == DQM_KIND_TH2F)
1092  {
1093  auto *orig = static_cast<TH2F *>(object_);
1094  auto *r = static_cast<TH2F *>(refvalue_);
1095  if (! r)
1096  {
1097  refvalue_ = r = (TH2F*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1098  r->SetDirectory(nullptr);
1099  r->Reset();
1100  }
1101 
1102  r->Add(orig);
1103  orig->Reset();
1104  }
1105  else if (kind() == DQM_KIND_TH2S)
1106  {
1107  auto *orig = static_cast<TH2S *>(object_);
1108  auto *r = static_cast<TH2S *>(refvalue_);
1109  if (! r)
1110  {
1111  refvalue_ = r = (TH2S*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1112  r->SetDirectory(nullptr);
1113  r->Reset();
1114  }
1115 
1116  r->Add(orig);
1117  orig->Reset();
1118  }
1119  else if (kind() == DQM_KIND_TH2D)
1120  {
1121  auto *orig = static_cast<TH2D *>(object_);
1122  auto *r = static_cast<TH2D *>(refvalue_);
1123  if (! r)
1124  {
1125  refvalue_ = r = (TH2D*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1126  r->SetDirectory(nullptr);
1127  r->Reset();
1128  }
1129 
1130  r->Add(orig);
1131  orig->Reset();
1132  }
1133  else if (kind() == DQM_KIND_TH3F)
1134  {
1135  auto *orig = static_cast<TH3F *>(object_);
1136  auto *r = static_cast<TH3F *>(refvalue_);
1137  if (! r)
1138  {
1139  refvalue_ = r = (TH3F*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1140  r->SetDirectory(nullptr);
1141  r->Reset();
1142  }
1143 
1144  r->Add(orig);
1145  orig->Reset();
1146  }
1147  else if (kind() == DQM_KIND_TPROFILE)
1148  {
1149  auto *orig = static_cast<TProfile *>(object_);
1150  auto *r = static_cast<TProfile *>(refvalue_);
1151  if (! r)
1152  {
1153  refvalue_ = r = (TProfile*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1154  r->SetDirectory(nullptr);
1155  r->Reset();
1156  }
1157 
1158  addProfiles(r, orig, r, 1, 1);
1159  orig->Reset();
1160  }
1161  else if (kind() == DQM_KIND_TPROFILE2D)
1162  {
1163  auto *orig = static_cast<TProfile2D *>(object_);
1164  auto *r = static_cast<TProfile2D *>(refvalue_);
1165  if (! r)
1166  {
1167  refvalue_ = r = (TProfile2D*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str());
1168  r->SetDirectory(nullptr);
1169  r->Reset();
1170  }
1171 
1172  addProfiles(r, orig, r, 1, 1);
1173  orig->Reset();
1174  }
1175  else
1176  incompatible(__PRETTY_FUNCTION__);
1177 }
1178 
1180 void
1182 {
1183  if (refvalue_)
1184  {
1185  if (kind() == DQM_KIND_TH1F
1186  || kind() == DQM_KIND_TH1S
1187  || kind() == DQM_KIND_TH1D
1188  || kind() == DQM_KIND_TH2F
1189  || kind() == DQM_KIND_TH2S
1190  || kind() == DQM_KIND_TH2D
1191  || kind() == DQM_KIND_TH3F)
1192  {
1193  auto *orig = static_cast<TH1 *>(object_);
1194  orig->Add(refvalue_);
1195  }
1196  else if (kind() == DQM_KIND_TPROFILE)
1197  {
1198  auto *orig = static_cast<TProfile *>(object_);
1199  auto *r = static_cast<TProfile *>(refvalue_);
1200  addProfiles(orig, r, orig, 1, 1);
1201  }
1202  else if (kind() == DQM_KIND_TPROFILE2D)
1203  {
1204  auto *orig = static_cast<TProfile2D *>(object_);
1205  auto *r = static_cast<TProfile2D *>(refvalue_);
1206  addProfiles(orig, r, orig, 1, 1);
1207  }
1208  else
1209  incompatible(__PRETTY_FUNCTION__);
1210 
1211  delete refvalue_;
1212  refvalue_ = nullptr;
1213  }
1214 }
1215 
1216 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1217 // Can be called with sum = h1 or sum = h2
1218 void
1219 MonitorElement::addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
1220 {
1221  assert(h1);
1222  assert(h2);
1223  assert(sum);
1224 
1225  static const Int_t NUM_STAT = 6;
1226  Double_t stats1[NUM_STAT];
1227  Double_t stats2[NUM_STAT];
1228  Double_t stats3[NUM_STAT];
1229 
1230  bool isRebinOn = sum->CanExtendAllAxes();
1231  sum->SetCanExtend(TH1::kNoAxis);
1232 
1233  for (Int_t i = 0; i < NUM_STAT; ++i)
1234  stats1[i] = stats2[i] = stats3[i] = 0;
1235 
1236  h1->GetStats(stats1);
1237  h2->GetStats(stats2);
1238 
1239  for (Int_t i = 0; i < NUM_STAT; ++i)
1240  stats3[i] = c1*stats1[i] + c2*stats2[i];
1241 
1242  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1243  + c2*TMath::Abs(c2)*stats2[1];
1244 
1245  Double_t entries = c1*h1->GetEntries() + c2* h2->GetEntries();
1246  TArrayD* h1sumw2 = h1->GetSumw2();
1247  TArrayD* h2sumw2 = h2->GetSumw2();
1248  for (Int_t bin = 0, nbin = sum->GetNbinsX()+1; bin <= nbin; ++bin)
1249  {
1250  Double_t entries = c1*h1->GetBinEntries(bin)
1251  + c2*h2->GetBinEntries(bin);
1252  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1253  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1254  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1255  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1256  sum->SetBinContent(bin, content);
1257  sum->SetBinError(bin, error);
1258  sum->SetBinEntries(bin, entries);
1259  }
1260 
1261  sum->SetEntries(entries);
1262  sum->PutStats(stats3);
1263  if (isRebinOn) sum->SetCanExtend(TH1::kAllAxes);
1264 }
1265 
1266 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1267 // Can be called with sum = h1 or sum = h2
1268 void
1269 MonitorElement::addProfiles(TProfile2D *h1, TProfile2D *h2, TProfile2D *sum, float c1, float c2)
1270 {
1271  assert(h1);
1272  assert(h2);
1273  assert(sum);
1274 
1275  static const Int_t NUM_STAT = 9;
1276  Double_t stats1[NUM_STAT];
1277  Double_t stats2[NUM_STAT];
1278  Double_t stats3[NUM_STAT];
1279 
1280  bool isRebinOn = sum->CanExtendAllAxes();
1281  sum->SetCanExtend(TH1::kNoAxis);
1282 
1283  for (Int_t i = 0; i < NUM_STAT; ++i)
1284  stats1[i] = stats2[i] = stats3[i] = 0;
1285 
1286  h1->GetStats(stats1);
1287  h2->GetStats(stats2);
1288 
1289  for (Int_t i = 0; i < NUM_STAT; i++)
1290  stats3[i] = c1*stats1[i] + c2*stats2[i];
1291 
1292  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1293  + c2*TMath::Abs(c2)*stats2[1];
1294 
1295  Double_t entries = c1*h1->GetEntries() + c2*h2->GetEntries();
1296  TArrayD *h1sumw2 = h1->GetSumw2();
1297  TArrayD *h2sumw2 = h2->GetSumw2();
1298  for (Int_t xbin = 0, nxbin = sum->GetNbinsX()+1; xbin <= nxbin; ++xbin)
1299  for (Int_t ybin = 0, nybin = sum->GetNbinsY()+1; ybin <= nybin; ++ybin)
1300  {
1301  Int_t bin = sum->GetBin(xbin, ybin);
1302  Double_t entries = c1*h1->GetBinEntries(bin)
1303  + c2*h2->GetBinEntries(bin);
1304  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1305  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1306  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1307  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1308 
1309  sum->SetBinContent(bin, content);
1310  sum->SetBinError(bin, error);
1311  sum->SetBinEntries(bin, entries);
1312  }
1313  sum->SetEntries(entries);
1314  sum->PutStats(stats3);
1315  if (isRebinOn) sum->SetCanExtend(TH1::kAllAxes);
1316 }
1317 
1318 void
1320 {
1321  // will copy functions only if local-copy and original-object are equal
1322  // (ie. no soft-resetting or accumulating is enabled)
1324  return;
1325 
1326  update();
1327  TList *fromf = from->GetListOfFunctions();
1328  TList *tof = to->GetListOfFunctions();
1329  for (int i = 0, nfuncs = fromf ? fromf->GetSize() : 0; i < nfuncs; ++i)
1330  {
1331  TObject *obj = fromf->At(i);
1332  // not interested in statistics
1333  if (!strcmp(obj->IsA()->GetName(), "TPaveStats"))
1334  continue;
1335 
1336  if (auto *fn = dynamic_cast<TF1 *>(obj))
1337  tof->Add(new TF1(*fn));
1338  //else if (dynamic_cast<TPaveStats *>(obj))
1339  // ; // FIXME? tof->Add(new TPaveStats(*stats));
1340  else
1341  raiseDQMError("MonitorElement", "Cannot extract function '%s' of type"
1342  " '%s' from monitor element '%s' for a copy",
1343  obj->GetName(), obj->IsA()->GetName(), data_.objname.c_str());
1344  }
1345 }
1346 
1347 void
1349 {
1350  TH1 *orig = accessRootObject(__PRETTY_FUNCTION__, 1);
1351  if (orig->GetTitle() != from->GetTitle())
1352  orig->SetTitle(from->GetTitle());
1353 
1354  if (!isAccumulateEnabled())
1355  orig->Reset();
1356 
1357  if (isSoftResetEnabled())
1358  {
1359  if (kind() == DQM_KIND_TH1F
1360  || kind() == DQM_KIND_TH1S
1361  || kind() == DQM_KIND_TH1D
1362  || kind() == DQM_KIND_TH2F
1363  || kind() == DQM_KIND_TH2S
1364  || kind() == DQM_KIND_TH2D
1365  || kind() == DQM_KIND_TH3F)
1366  // subtract "reference"
1367  orig->Add(from, refvalue_, 1, -1);
1368  else if (kind() == DQM_KIND_TPROFILE)
1369  // subtract "reference"
1370  addProfiles(static_cast<TProfile *>(from),
1371  static_cast<TProfile *>(refvalue_),
1372  static_cast<TProfile *>(orig),
1373  1, -1);
1374  else if (kind() == DQM_KIND_TPROFILE2D)
1375  // subtract "reference"
1376  addProfiles(static_cast<TProfile2D *>(from),
1377  static_cast<TProfile2D *>(refvalue_),
1378  static_cast<TProfile2D *>(orig),
1379  1, -1);
1380  else
1381  incompatible(__PRETTY_FUNCTION__);
1382  }
1383  else
1384  orig->Add(from);
1385 
1386  copyFunctions(from, orig);
1387 }
1388 
1389 // --- Operations on MEs that are normally reset at end of monitoring cycle ---
1390 void
1392 {
1393  assert(qreports_.size() == data_.qreports.size());
1394 
1395  qr = nullptr;
1396  qv = nullptr;
1397 
1398  size_t pos = 0, end = qreports_.size();
1399  while (pos < end && data_.qreports[pos].qtname != qtname)
1400  ++pos;
1401 
1402  if (pos == end && ! create)
1403  return;
1404  else if (pos == end)
1405  {
1406  data_.qreports.emplace_back();
1407  qreports_.push_back(QReport(nullptr, nullptr));
1408 
1409  DQMNet::QValue &q = data_.qreports.back();
1411  q.qtresult = 0;
1412  q.qtname = qtname;
1413  q.message = "NO_MESSAGE_ASSIGNED";
1414  q.algorithm = "UNKNOWN_ALGORITHM";
1415  }
1416 
1417  qr = &qreports_[pos];
1418  qv = &data_.qreports[pos];
1419 }
1420 
1422 void
1424 {
1425  QReport *qr;
1426  DQMNet::QValue *qv;
1427  getQReport(true, desc.qtname, qr, qv);
1428  qr->qcriterion_ = qc;
1429  *qv = desc;
1430  update();
1431 }
1432 
1433 void
1435 {
1436  QReport *qr;
1437  DQMNet::QValue *qv;
1438  getQReport(true, qc->getName(), qr, qv);
1440  qv->message = "NO_MESSAGE_ASSIGNED";
1441  qr->qcriterion_ = qc;
1442  update();
1443 }
1444 
1446 void
1448 {
1449  data_.flags &= ~DQMNet::DQM_PROP_REPORT_ALARM;
1450  for (auto & qreport : data_.qreports)
1451  switch (qreport.code)
1452  {
1454  break;
1455  case dqm::qstatus::WARNING:
1457  break;
1458  case dqm::qstatus::ERROR:
1460  break;
1461  default:
1463  break;
1464  }
1465 }
1466 
1467 // -------------------------------------------------------------------
1468 TObject *
1470 {
1471  const_cast<MonitorElement *>(this)->update();
1472  return object_;
1473 }
1474 
1475 TH1 *
1477 {
1478  const_cast<MonitorElement *>(this)->update();
1479  return accessRootObject(__PRETTY_FUNCTION__, 0);
1480 }
1481 
1482 TH1F *
1484 {
1485  assert(kind() == DQM_KIND_TH1F);
1486  const_cast<MonitorElement *>(this)->update();
1487  return static_cast<TH1F *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1488 }
1489 
1490 TH1S *
1492 {
1493  assert(kind() == DQM_KIND_TH1S);
1494  const_cast<MonitorElement *>(this)->update();
1495  return static_cast<TH1S *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1496 }
1497 
1498 TH1D *
1500 {
1501  assert(kind() == DQM_KIND_TH1D);
1502  const_cast<MonitorElement *>(this)->update();
1503  return static_cast<TH1D *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1504 }
1505 
1506 TH2F *
1508 {
1509  assert(kind() == DQM_KIND_TH2F);
1510  const_cast<MonitorElement *>(this)->update();
1511  return static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1512 }
1513 
1514 TH2S *
1516 {
1517  assert(kind() == DQM_KIND_TH2S);
1518  const_cast<MonitorElement *>(this)->update();
1519  return static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1520 }
1521 
1522 TH2D *
1524 {
1525  assert(kind() == DQM_KIND_TH2D);
1526  const_cast<MonitorElement *>(this)->update();
1527  return static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1528 }
1529 
1530 TH3F *
1532 {
1533  assert(kind() == DQM_KIND_TH3F);
1534  const_cast<MonitorElement *>(this)->update();
1535  return static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 3));
1536 }
1537 
1538 TProfile *
1540 {
1541  assert(kind() == DQM_KIND_TPROFILE);
1542  const_cast<MonitorElement *>(this)->update();
1543  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1544 }
1545 
1546 TProfile2D *
1548 {
1549  assert(kind() == DQM_KIND_TPROFILE2D);
1550  const_cast<MonitorElement *>(this)->update();
1551  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1552 }
1553 
1554 // -------------------------------------------------------------------
1555 TObject *
1557 {
1558  const_cast<MonitorElement *>(this)->update();
1559  return reference_;
1560 }
1561 
1562 TH1 *
1564 {
1565  const_cast<MonitorElement *>(this)->update();
1566  return checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 0);
1567 }
1568 
1569 TH1F *
1571 {
1572  assert(kind() == DQM_KIND_TH1F);
1573  const_cast<MonitorElement *>(this)->update();
1574  return static_cast<TH1F *>
1575  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1576 }
1577 
1578 TH1S *
1580 {
1581  assert(kind() == DQM_KIND_TH1S);
1582  const_cast<MonitorElement *>(this)->update();
1583  return static_cast<TH1S *>
1584  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1585 }
1586 
1587 TH1D *
1589 {
1590  assert(kind() == DQM_KIND_TH1D);
1591  const_cast<MonitorElement *>(this)->update();
1592  return static_cast<TH1D *>
1593  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1594 }
1595 
1596 TH2F *
1598 {
1599  assert(kind() == DQM_KIND_TH2F);
1600  const_cast<MonitorElement *>(this)->update();
1601  return static_cast<TH2F *>
1602  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1603 }
1604 
1605 TH2S *
1607 {
1608  assert(kind() == DQM_KIND_TH2S);
1609  const_cast<MonitorElement *>(this)->update();
1610  return static_cast<TH2S *>
1611  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1612 }
1613 
1614 TH2D *
1616 {
1617  assert(kind() == DQM_KIND_TH2D);
1618  const_cast<MonitorElement *>(this)->update();
1619  return static_cast<TH2D *>
1620  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1621 }
1622 
1623 TH3F *
1625 {
1626  assert(kind() == DQM_KIND_TH3F);
1627  const_cast<MonitorElement *>(this)->update();
1628  return static_cast<TH3F *>
1629  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 3));
1630 }
1631 
1632 TProfile *
1634 {
1635  assert(kind() == DQM_KIND_TPROFILE);
1636  const_cast<MonitorElement *>(this)->update();
1637  return static_cast<TProfile *>
1638  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1639 }
1640 
1641 TProfile2D *
1643 {
1644  assert(kind() == DQM_KIND_TPROFILE2D);
1645  const_cast<MonitorElement *>(this)->update();
1646  return static_cast<TProfile2D *>
1647  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1648 }
TProfile * getTProfile() const
QCriterion * qcriterion_
Definition: QReport.h:51
static const uint32_t DQM_PROP_REPORT_WARN
Definition: DQMNet.h:48
void incompatible(const char *func) const
uint32_t moduleId
Definition: DQMNet.h:105
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to <qtname> (null pointer if QReport does not exist)
std::string valueString() const
void setBinContent(int binx, double content)
set content of bin (1-D)
QReports qreports
Definition: DQMNet.h:108
TH1 * accessRootObject(const char *func, int reqdim) const
void copyFrom(TH1 *from)
MonitorElement * initialise(Kind kind)
TProfile2D * getTProfile2D() const
std::string algorithm
Definition: DQMNet.h:94
const double w
Definition: UKUtility.cc:23
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int getNbinsZ() const
get # of bins in Z-axis
std::vector< QReport * > getQOthers() const
uint64_t version
Definition: DQMNet.h:101
def create(alignables, pedeDump, additionalData, outputFile, config)
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
void setAxisTimeFormat(const char *format="", int axis=1)
set the format of the time values that are displayed on an axis
std::vector< QReport > qreports_
TH1F * getTH1F() const
TH2S * getTH2S() const
Definition: DQMNet.h:23
TObject * getRootObject() const
bool isSoftResetEnabled() const
whether soft-reset is enabled; default is false
std::string qualityTagString(const DQMNet::QValue &qv) const
std::string getAxisTitle(int axis=1) const
get x-, y- or z-axis title (axis=1, 2, 3 respectively)
uint32_t flags
Definition: DQMNet.h:99
TH1 * getTH1() const
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)
static const int WARNING
TProfile2D * getRefTProfile2D() const
uint32_t tag
Definition: DQMNet.h:100
const std::string * dirname
Definition: DQMNet.h:106
TH1 * getRefTH1() const
#define nullptr
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
TObject * getRefRootObject() const
void disableSoftReset()
reverts action of softReset
uint32_t run
Definition: DQMNet.h:102
TH2S * getRefTH2S() const
double getMeanError(int axis=1) const
void packScalarData(std::string &into, const char *prefix) const
convert scalar data into a string.
bool wasUpdated() const
true if ME was updated in last monitoring cycle
void Fill(long long x)
char const * label
void update()
Mark the object updated.
TH1F * getRefTH1F() const
std::string getTitle() const
get MonitorElement title
void ShiftFillLast(double y, double ye=0., int32_t xscale=1)
static TH1 * checkRootObject(const std::string &name, TObject *tobj, const char *func, int reqdim)
void packQualityData(std::string &into) const
serialise quality report information into a string.
static const uint32_t DQM_PROP_HAS_REFERENCE
Definition: DQMNet.h:54
void setAxisTimeDisplay(int value, int axis=1)
set x-, y-, or z-axis to display time values
void doFill(int64_t x)
"Fill" ME method for int64_t
T sqrt(T t)
Definition: SSEVec.h:18
uint32_t lumi
Definition: DQMNet.h:103
TH1S * getRefTH1S() const
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
T Abs(T a)
Definition: MathUtil.h:49
std::string tagString() const
TH2D * getTH2D() const
TH3F * getRefTH3F() const
static const int DID_NOT_RUN
static const uint32_t DQM_PROP_REPORT_ERROR
Definition: DQMNet.h:47
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
#define end
Definition: vmac.h:39
Definition: value.py:1
static const uint32_t DQM_PROP_REPORT_OTHER
Definition: DQMNet.h:49
void setEntries(double nentries)
set # of entries
void Reset()
reset ME (ie. contents, errors, etc)
std::vector< QReport * > getQErrors() const
get errors from last set of quality tests
void updateQReportStats()
Refresh QReport stats, usually after MEs were read in from a file.
std::string objname
Definition: DQMNet.h:107
TH2F * getTH2F() const
std::string qtname
Definition: DQMNet.h:93
DQMNet::CoreObject data_
bin
set the eta bin as selection string.
TAxis * getAxis(const char *func, int axis) const
const std::string getFullname() const
get full name of ME including Pathname
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
void runQTests()
run all quality tests
double getRMSError(int axis=1) const
get RMS uncertainty of histogram along x, y or z axis(axis=1,2,3 respectively)
double getEntries() const
get # of entries
#define N
Definition: blowfish.cc:9
void setAxisTimeOffset(double toffset, const char *option="local", int axis=1)
set the time offset, if option = "gmt" then the offset is treated as a GMT time
std::string effLabelString() const
return label string for the monitor element tag (eg. <name>t=12345</name>)
TH3F * getTH3F() const
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
virtual float runTest(const MonitorElement *me)
Definition: QTest.cc:28
std::string tagLabelString() const
return label string for the monitor element tag (eg. <name>t=12345</name>)
double b
Definition: hdecay.h:120
TH2D * getRefTH2D() const
static void packQualityData(std::string &into, const QReports &qr)
Definition: DQMNet.cc:177
std::vector< QReport * > getQReports() const
get map of QReports
int getNbinsY() const
get # of bins in Y-axis
double getYmin() const
get min Y value (for profiles)
void copyFunctions(TH1 *from, TH1 *to)
TH2F * getRefTH2F() const
double getBinContent(int binx) const
get content of bin (1-D)
double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
double a
Definition: hdecay.h:121
const uint32_t moduleId() const
DQMNet::QValue * qvalue_
Definition: QReport.h:50
double getBinEntries(int bin) const
get # of bin entries (for profiles)
double getYmax() const
get max Y value (for profiles)
std::string message
Definition: DQMNet.h:92
TH1D * getTH1D() const
std::string getName() const
get name of quality test
Definition: QTest.h:60
static const int STATUS_OK
TH1D * getRefTH1D() const
TH1S * getTH1S() const
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75
int getNbinsX() const
get # of bins in X-axis
static const uint32_t DQM_PROP_NEW
Definition: DQMNet.h:59
uint32_t streamId
Definition: DQMNet.h:104
float qtresult
Definition: DQMNet.h:91
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
TProfile * getRefTProfile() const
void setBinEntries(int bin, double nentries)
set # of bin entries (to be used for profiles)
void addQReport(const DQMNet::QValue &desc, QCriterion *qc)
Add quality report, from DQMStore.
Kind kind() const
Get the type of the monitor element.
std::vector< QReport * > getQWarnings() const
get warnings from last set of quality tests
static const int ERROR
bool isAccumulateEnabled() const
whether ME contents should be accumulated over multiple monitoring periods; default: false ...
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Check the consistency of the axis labels.
const uint32_t run() const
void raiseDQMError(const char *context, const char *fmt,...)
Definition: DQMError.cc:11