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