CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <iostream>
10 #include <cassert>
11 #include <cfloat>
12 #include <inttypes.h>
13 
14 static TH1 *
15 checkRootObject(const std::string &name, TObject *tobj, const char *func, int reqdim)
16 {
17  if (! tobj)
18  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
19  " element '%s' because it is not a ROOT object.",
20  func, name.c_str());
21 
22  TH1 *h = static_cast<TH1 *>(tobj);
23  int ndim = h->GetDimension();
24  if (reqdim < 0 || reqdim > ndim)
25  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
26  " element '%s' because it requires %d dimensions; this"
27  " object of type '%s' has %d dimensions",
28  func, name.c_str(), reqdim, typeid(*h).name(), ndim);
29 
30  return h;
31 }
32 
35 {
36  switch (kind)
37  {
38  case DQM_KIND_INT:
39  case DQM_KIND_REAL:
40  case DQM_KIND_STRING:
41  case DQM_KIND_TH1F:
42  case DQM_KIND_TH1S:
43  case DQM_KIND_TH1D:
44  case DQM_KIND_TH2F:
45  case DQM_KIND_TH2S:
46  case DQM_KIND_TH2D:
47  case DQM_KIND_TH3F:
48  case DQM_KIND_TPROFILE:
50  data_.flags &= ~DQMNet::DQM_PROP_TYPE_MASK;
51  data_.flags |= kind;
52  break;
53 
54  default:
55  raiseDQMError("MonitorElement", "cannot initialise monitor element"
56  " to invalid type %d", (int) kind);
57  }
58 
59  return this;
60 }
61 
63 MonitorElement::initialise(Kind kind, TH1 *rootobj)
64 {
65  initialise(kind);
66  switch (kind)
67  {
68  case DQM_KIND_TH1F:
69  assert(dynamic_cast<TH1F *>(rootobj));
70  assert(! reference_ || dynamic_cast<TH1F *>(reference_));
71  object_ = rootobj;
72  break;
73 
74  case DQM_KIND_TH1S:
75  assert(dynamic_cast<TH1S *>(rootobj));
76  assert(! reference_ || dynamic_cast<TH1S *>(reference_));
77  object_ = rootobj;
78  break;
79 
80  case DQM_KIND_TH1D:
81  assert(dynamic_cast<TH1D *>(rootobj));
82  assert(! reference_ || dynamic_cast<TH1D *>(reference_));
83  object_ = rootobj;
84  break;
85 
86  case DQM_KIND_TH2F:
87  assert(dynamic_cast<TH2F *>(rootobj));
88  assert(! reference_ || dynamic_cast<TH2F *>(reference_));
89  object_ = rootobj;
90  break;
91 
92  case DQM_KIND_TH2S:
93  assert(dynamic_cast<TH2S *>(rootobj));
94  assert(! reference_ || dynamic_cast<TH2S *>(reference_));
95  object_ = rootobj;
96  break;
97 
98  case DQM_KIND_TH2D:
99  assert(dynamic_cast<TH2D *>(rootobj));
100  assert(! reference_ || dynamic_cast<TH1D *>(reference_));
101  object_ = rootobj;
102  break;
103 
104  case DQM_KIND_TH3F:
105  assert(dynamic_cast<TH3F *>(rootobj));
106  assert(! reference_ || dynamic_cast<TH3F *>(reference_));
107  object_ = rootobj;
108  break;
109 
110  case DQM_KIND_TPROFILE:
111  assert(dynamic_cast<TProfile *>(rootobj));
112  assert(! reference_ || dynamic_cast<TProfile *>(reference_));
113  object_ = rootobj;
114  break;
115 
116  case DQM_KIND_TPROFILE2D:
117  assert(dynamic_cast<TProfile2D *>(rootobj));
118  assert(! reference_ || dynamic_cast<TProfile2D *>(reference_));
119  object_ = rootobj;
120  break;
121 
122  default:
123  raiseDQMError("MonitorElement", "cannot initialise monitor element"
124  " as a root object with type %d", (int) kind);
125  }
126 
127  if (reference_)
129 
130  return this;
131 }
132 
134 MonitorElement::initialise(Kind kind, const std::string &value)
135 {
136  initialise(kind);
137  if (kind == DQM_KIND_STRING)
138  scalar_.str = value;
139  else
140  raiseDQMError("MonitorElement", "cannot initialise monitor element"
141  " as a string with type %d", (int) kind);
142 
143  return this;
144 }
145 
147  : object_(0),
148  reference_(0),
149  refvalue_(0)
150 {
151  data_.version = 0;
152  data_.dirname = 0;
153  data_.tag = 0;
155  scalar_.num = 0;
156  scalar_.real = 0;
157 }
158 
159 MonitorElement::MonitorElement(const std::string *path, const std::string &name)
160  : object_(0),
161  reference_(0),
162  refvalue_(0)
163 {
164  data_.version = 0;
165  data_.dirname = path;
166  data_.objname = name;
167  data_.tag = 0;
169  scalar_.num = 0;
170  scalar_.real = 0;
171 }
172 
174  : data_(x.data_),
175  scalar_(x.scalar_),
176  object_(x.object_),
177  reference_(x.reference_),
178  refvalue_(x.refvalue_),
179  qreports_(x.qreports_)
180 {
181  if (object_)
182  object_ = static_cast<TH1 *>(object_->Clone());
183 
184  if (refvalue_)
185  refvalue_ = static_cast<TH1 *>(refvalue_->Clone());
186 }
187 
190 {
191  if (this != &x)
192  {
193  delete object_;
194  delete refvalue_;
195 
196  data_ = x.data_;
197  scalar_ = x.scalar_;
198  object_ = x.object_;
200  refvalue_ = x.refvalue_;
201  qreports_ = x.qreports_;
202 
203  if (object_)
204  object_ = static_cast<TH1 *>(object_->Clone());
205 
206  if (refvalue_)
207  refvalue_ = static_cast<TH1 *>(refvalue_->Clone());
208  }
209 
210  return *this;
211 }
212 
214 {
215  delete object_;
216  delete refvalue_;
217 }
218 
220 void
222 {
223  update();
224  if (kind() == DQM_KIND_STRING)
225  scalar_.str = value;
226  else
227  incompatible(__PRETTY_FUNCTION__);
228 }
229 
231 void
233 {
234  update();
235  if (kind() == DQM_KIND_INT)
236  scalar_.num = static_cast<int64_t>(x);
237  else if (kind() == DQM_KIND_REAL)
238  scalar_.real = x;
239  else if (kind() == DQM_KIND_TH1F)
240  accessRootObject(__PRETTY_FUNCTION__, 1)
241  ->Fill(x, 1);
242  else if (kind() == DQM_KIND_TH1S)
243  accessRootObject(__PRETTY_FUNCTION__, 1)
244  ->Fill(x, 1);
245  else if (kind() == DQM_KIND_TH1D)
246  accessRootObject(__PRETTY_FUNCTION__, 1)
247  ->Fill(x, 1);
248  else
249  incompatible(__PRETTY_FUNCTION__);
250 }
251 
253 void
255 {
256  update();
257  if (kind() == DQM_KIND_INT)
258  scalar_.num = static_cast<int64_t>(x);
259  else if (kind() == DQM_KIND_REAL)
260  scalar_.real = static_cast<double>(x);
261  else if (kind() == DQM_KIND_TH1F)
262  accessRootObject(__PRETTY_FUNCTION__, 1)
263  ->Fill(static_cast<double>(x), 1);
264  else if (kind() == DQM_KIND_TH1S)
265  accessRootObject(__PRETTY_FUNCTION__, 1)
266  ->Fill(static_cast<double>(x), 1);
267  else if (kind() == DQM_KIND_TH1D)
268  accessRootObject(__PRETTY_FUNCTION__, 1)
269  ->Fill(static_cast<double>(x), 1);
270  else
271  incompatible(__PRETTY_FUNCTION__);
272 }
273 
275 void
276 MonitorElement::Fill(double x, double yw)
277 {
278  update();
279  if (kind() == DQM_KIND_TH1F)
280  accessRootObject(__PRETTY_FUNCTION__, 1)
281  ->Fill(x, yw);
282  else if (kind() == DQM_KIND_TH1S)
283  accessRootObject(__PRETTY_FUNCTION__, 1)
284  ->Fill(x, yw);
285  else if (kind() == DQM_KIND_TH1D)
286  accessRootObject(__PRETTY_FUNCTION__, 1)
287  ->Fill(x, yw);
288  else if (kind() == DQM_KIND_TH2F)
289  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
290  ->Fill(x, yw, 1);
291  else if (kind() == DQM_KIND_TH2S)
292  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
293  ->Fill(x, yw, 1);
294  else if (kind() == DQM_KIND_TH2D)
295  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
296  ->Fill(x, yw, 1);
297  else if (kind() == DQM_KIND_TPROFILE)
298  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
299  ->Fill(x, yw, 1);
300  else
301  incompatible(__PRETTY_FUNCTION__);
302 }
303 
307 void
308 MonitorElement::ShiftFillLast(double y, double ye, int xscale)
309 {
310  update();
311  if (kind() == DQM_KIND_TH1F
312  || kind() == DQM_KIND_TH1S
313  || kind() == DQM_KIND_TH1D)
314  {
315  int nbins = getNbinsX();
316  int entries = (int)getEntries();
317  // first fill bins from left to right
318  int index = entries + 1 ;
319  int xlow = 2 ; int xup = nbins ;
320  // if more entries than bins then start shifting
321  if ( entries >= nbins )
322  {
323  index = nbins;
324  xlow = entries - nbins + 3 ; xup = entries+1 ;
325  // average first bin
326  double y1 = getBinContent(1);
327  double y2 = getBinContent(2);
328  double y1err = getBinError(1);
329  double y2err = getBinError(2);
330  double N = entries - nbins + 1.;
331  if ( ye == 0. || y1err == 0. || y2err == 0.)
332  {
333  // for errors zero calculate unweighted mean and its error
334  double sum = N*y1 + y2;
335  y1 = sum/(N+1.) ;
336  // FIXME check if correct
337  double s=(N+1.)*(N*y1*y1 + y2*y2) - sum*sum;
338  if (s>=0.)
339  y1err = sqrt(s)/(N+1.);
340  else
341  y1err = 0.;
342  }
343  else
344  {
345  // for errors non-zero calculate weighted mean and its error
346  double denom = (1./y1err + 1./y2err);
347  double mean = (y1/y1err + y2/y2err)/denom;
348  // FIXME check if correct
349  y1err = sqrt(((y1-mean)*(y1-mean)/y1err +
350  (y2-mean)*(y2-mean)/y2err)/denom/2.);
351  y1 = mean; // set y1 to mean for filling below
352  }
353  setBinContent(1,y1);
354  setBinError(1,y1err);
355  // shift remaining bins to the left
356  for ( int i = 3; i <= nbins ; i++)
357  {
360  }
361  }
362  // fill last bin with new values
363  setBinContent(index,y);
364  setBinError(index,ye);
365  // set entries
366  setEntries(entries+1);
367  // set axis labels and reset drawing option
368  char buffer [10];
369  sprintf (buffer, "%d", xlow*xscale);
370  std::string a(buffer); setBinLabel(2,a);
371  sprintf (buffer, "%d", xup*xscale);
372  std::string b(buffer); setBinLabel(nbins,b);
373  setBinLabel(1,"av.");
374  }
375  else
376  incompatible(__PRETTY_FUNCTION__);
377 }
379 void
380 MonitorElement::Fill(double x, double y, double zw)
381 {
382  update();
383  if (kind() == DQM_KIND_TH2F)
384  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
385  ->Fill(x, y, zw);
386  else if (kind() == DQM_KIND_TH2S)
387  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
388  ->Fill(x, y, zw);
389  else if (kind() == DQM_KIND_TH2D)
390  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
391  ->Fill(x, y, zw);
392  else if (kind() == DQM_KIND_TH3F)
393  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
394  ->Fill(x, y, zw, 1);
395  else if (kind() == DQM_KIND_TPROFILE)
396  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 2))
397  ->Fill(x, y, zw);
398  else if (kind() == DQM_KIND_TPROFILE2D)
399  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
400  ->Fill(x, y, zw, 1);
401  else
402  incompatible(__PRETTY_FUNCTION__);
403 }
404 
406 void
407 MonitorElement::Fill(double x, double y, double z, double w)
408 {
409  update();
410  if (kind() == DQM_KIND_TH3F)
411  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
412  ->Fill(x, y, z, w);
413  else if (kind() == DQM_KIND_TPROFILE2D)
414  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
415  ->Fill(x, y, z, w);
416  else
417  incompatible(__PRETTY_FUNCTION__);
418 }
419 
421 void
423 {
424  update();
425  if (kind() == DQM_KIND_INT)
426  scalar_.num = 0;
427  else if (kind() == DQM_KIND_REAL)
428  scalar_.real = 0;
429  else if (kind() == DQM_KIND_STRING)
430  scalar_.str.clear();
431  else
432  return accessRootObject(__PRETTY_FUNCTION__, 1)
433  ->Reset();
434 }
435 
437 void
438 MonitorElement::packScalarData(std::string &into, const char *prefix) const
439 {
440  char buf[64];
441  if (kind() == DQM_KIND_INT)
442  {
443  snprintf(buf, sizeof(buf), "%s%" PRId64, prefix, scalar_.num);
444  into = buf;
445  }
446  else if (kind() == DQM_KIND_REAL)
447  {
448  snprintf(buf, sizeof(buf), "%s%.*g", prefix, DBL_DIG+2, scalar_.real);
449  into = buf;
450  }
451  else if (kind() == DQM_KIND_STRING)
452  {
453  into.reserve(strlen(prefix) + scalar_.str.size());
454  into += prefix;
455  into += scalar_.str;
456  }
457  else
458  incompatible(__PRETTY_FUNCTION__);
459 }
460 
462 void
463 MonitorElement::packQualityData(std::string &into) const
464 {
466 }
467 
470 std::string
472 {
473  std::string result;
474  if (kind() == DQM_KIND_INT)
475  packScalarData(result, "i=");
476  else if (kind() == DQM_KIND_REAL)
477  packScalarData(result, "f=");
478  else if (kind() == DQM_KIND_STRING)
479  packScalarData(result, "s=");
480  else
481  incompatible(__PRETTY_FUNCTION__);
482 
483  return result;
484 }
485 
489 std::string
491 {
492  std::string result;
493  std::string val(valueString());
494  result.reserve(6 + 2*data_.objname.size() + val.size());
495  result += '<'; result += data_.objname; result += '>';
496  result += val;
497  result += '<'; result += '/'; result += data_.objname; result += '>';
498  return result;
499 }
500 
502 std::string
504 {
505  char buf[32];
506  std::string result;
507  size_t len = sprintf(buf, "t=%" PRIu32, data_.tag);
508 
509  result.reserve(6 + 2*data_.objname.size() + len);
510  result += '<'; result += data_.objname; result += '>';
511  result += buf;
512  result += '<'; result += '/'; result += data_.objname; result += '>';
513  return result;
514 }
515 
517 std::string
519 {
520  std::string result;
521 
522  result.reserve(6 + 2*data_.objname.size() + 3);
523  result += '<'; result += data_.objname; result += '>';
524  result += "e=1";
525  result += '<'; result += '/'; result += data_.objname; result += '>';
526  return result;
527 }
528 
529 std::string
531 {
532  char buf[64];
533  std::string result;
534  size_t titlelen = data_.objname.size() + qv.qtname.size() + 1;
535  size_t buflen = sprintf(buf, "qr=st:%d:%.*g:", qv.code, DBL_DIG+2, qv.qtresult);
536 
537  result.reserve(7 + 2*titlelen + buflen + qv.algorithm.size() + qv.message.size());
538  result += '<'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
539  result += buf; result += qv.algorithm; result += ':'; result += qv.message;
540  result += '<'; result += '/'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
541  return result;
542 }
543 
544 const QReport *
545 MonitorElement::getQReport(const std::string &qtname) const
546 {
547  QReport *qr;
548  DQMNet::QValue *qv;
549  const_cast<MonitorElement *>(this)->getQReport(false, qtname, qr, qv);
550  return qr;
551 }
552 
553 std::vector<QReport *>
555 {
556  std::vector<QReport *> result;
557  result.reserve(qreports_.size());
558  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
559  {
560  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
561  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
562  result.push_back(const_cast<QReport *>(&qreports_[i]));
563  }
564  return result;
565 }
566 
567 std::vector<QReport *>
569 {
570  std::vector<QReport *> result;
571  result.reserve(qreports_.size());
572  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
573  if (data_.qreports[i].code == dqm::qstatus::WARNING)
574  {
575  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
576  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
577  result.push_back(const_cast<QReport *>(&qreports_[i]));
578  }
579  return result;
580 }
581 
582 std::vector<QReport *>
584 {
585  std::vector<QReport *> result;
586  result.reserve(qreports_.size());
587  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
588  if (data_.qreports[i].code == dqm::qstatus::ERROR)
589  {
590  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
591  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
592  result.push_back(const_cast<QReport *>(&qreports_[i]));
593  }
594  return result;
595 }
596 
597 std::vector<QReport *>
599 {
600  std::vector<QReport *> result;
601  result.reserve(qreports_.size());
602  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
605  && data_.qreports[i].code != dqm::qstatus::ERROR)
606  {
607  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
608  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
609  result.push_back(const_cast<QReport *>(&qreports_[i]));
610  }
611  return result;
612 }
613 
615 void
617 {
618  assert(qreports_.size() == data_.qreports.size());
619 
620  // Rerun quality tests where the ME or the quality algorithm was modified.
621  bool dirty = wasUpdated();
622  for (size_t i = 0, e = data_.qreports.size(); i < e; ++i)
623  {
625  QReport &qr = qreports_[i];
626  QCriterion *qc = qr.qcriterion_;
627  qr.qvalue_ = &qv;
628 
629  // if (qc && (dirty || qc->wasModified())) // removed for new QTest (abm-090503)
630  if (qc && dirty)
631  {
632  assert(qc->getName() == qv.qtname);
633  std::string oldMessage = qv.message;
634  int oldStatus = qv.code;
635 
636  qc->runTest(this, qr, qv);
637 
638  if (oldStatus != qv.code || oldMessage != qv.message)
639  update();
640  }
641  }
642 
643  // Update QReport statistics.
645 }
646 
647 void
648 MonitorElement::incompatible(const char *func) const
649 {
650  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
651  " element '%s'", func, data_.objname.c_str());
652 }
653 
654 TH1 *
655 MonitorElement::accessRootObject(const char *func, int reqdim) const
656 {
657  if (kind() < DQM_KIND_TH1F)
658  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
659  " element '%s' because it is not a root object",
660  func, data_.objname.c_str());
661 
662  return checkRootObject(data_.objname, object_, func, reqdim);
663 }
664 
665 /*** getter methods (wrapper around ROOT methods) ****/
666 //
668 double
669 MonitorElement::getMean(int axis /* = 1 */) const
670 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
671  ->GetMean(axis); }
672 
675 double
676 MonitorElement::getMeanError(int axis /* = 1 */) const
677 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
678  ->GetMeanError(axis); }
679 
681 double
682 MonitorElement::getRMS(int axis /* = 1 */) const
683 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
684  ->GetRMS(axis); }
685 
687 double
688 MonitorElement::getRMSError(int axis /* = 1 */) const
689 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
690  ->GetRMSError(axis); }
691 
693 int
695 { return accessRootObject(__PRETTY_FUNCTION__, 1)
696  ->GetNbinsX(); }
697 
699 int
701 { return accessRootObject(__PRETTY_FUNCTION__, 2)
702  ->GetNbinsY(); }
703 
705 int
707 { return accessRootObject(__PRETTY_FUNCTION__, 3)
708  ->GetNbinsZ(); }
709 
711 double
713 { return accessRootObject(__PRETTY_FUNCTION__, 1)
714  ->GetBinContent(binx); }
715 
717 double
718 MonitorElement::getBinContent(int binx, int biny) const
719 { return accessRootObject(__PRETTY_FUNCTION__, 2)
720  ->GetBinContent(binx, biny); }
721 
723 double
724 MonitorElement::getBinContent(int binx, int biny, int binz) const
725 { return accessRootObject(__PRETTY_FUNCTION__, 3)
726  ->GetBinContent(binx, biny, binz); }
727 
729 double
731 { return accessRootObject(__PRETTY_FUNCTION__, 1)
732  ->GetBinError(binx); }
733 
735 double
736 MonitorElement::getBinError(int binx, int biny) const
737 { return accessRootObject(__PRETTY_FUNCTION__, 2)
738  ->GetBinError(binx, biny); }
739 
741 double
742 MonitorElement::getBinError(int binx, int biny, int binz) const
743 { return accessRootObject(__PRETTY_FUNCTION__, 3)
744  ->GetBinError(binx, biny, binz); }
745 
747 double
749 { return accessRootObject(__PRETTY_FUNCTION__, 1)
750  ->GetEntries(); }
751 
753 double
755 {
756  if (kind() == DQM_KIND_TPROFILE)
757  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
758  ->GetBinEntries(bin);
759  else if (kind() == DQM_KIND_TPROFILE2D)
760  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
761  ->GetBinEntries(bin);
762  else
763  {
764  incompatible(__PRETTY_FUNCTION__);
765  return 0;
766  }
767 }
768 
770 double
772 {
773  if (kind() == DQM_KIND_TPROFILE)
774  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
775  ->GetYmin();
776  else
777  {
778  incompatible(__PRETTY_FUNCTION__);
779  return 0;
780  }
781 }
782 
784 double
786 {
787  if (kind() == DQM_KIND_TPROFILE)
788  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
789  ->GetYmax();
790  else
791  {
792  incompatible(__PRETTY_FUNCTION__);
793  return 0;
794  }
795 }
796 
798 std::string
799 MonitorElement::getAxisTitle(int axis /* = 1 */) const
800 { return getAxis(__PRETTY_FUNCTION__, axis)
801  ->GetTitle(); }
802 
804 std::string
806 { return accessRootObject(__PRETTY_FUNCTION__, 1)
807  ->GetTitle(); }
808 
809 /*** setter methods (wrapper around ROOT methods) ****/
810 //
812 void
814 {
815  update();
816  accessRootObject(__PRETTY_FUNCTION__, 1)
817  ->SetBinContent(binx, content);
818 }
819 
821 void
822 MonitorElement::setBinContent(int binx, int biny, double content)
823 {
824  update();
825  accessRootObject(__PRETTY_FUNCTION__, 2)
826  ->SetBinContent(binx, biny, content); }
827 
829 void
830 MonitorElement::setBinContent(int binx, int biny, int binz, double content)
831 {
832  update();
833  accessRootObject(__PRETTY_FUNCTION__, 3)
834  ->SetBinContent(binx, biny, binz, content); }
835 
837 void
839 {
840  update();
841  accessRootObject(__PRETTY_FUNCTION__, 1)
842  ->SetBinError(binx, error);
843 }
844 
846 void
847 MonitorElement::setBinError(int binx, int biny, double error)
848 {
849  update();
850  accessRootObject(__PRETTY_FUNCTION__, 2)
851  ->SetBinError(binx, biny, error);
852 }
853 
855 void
856 MonitorElement::setBinError(int binx, int biny, int binz, double error)
857 {
858  update();
859  accessRootObject(__PRETTY_FUNCTION__, 3)
860  ->SetBinError(binx, biny, binz, error);
861 }
862 
864 void
865 MonitorElement::setBinEntries(int bin, double nentries)
866 {
867  update();
868  if (kind() == DQM_KIND_TPROFILE)
869  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
870  ->SetBinEntries(bin, nentries);
871  else if (kind() == DQM_KIND_TPROFILE2D)
872  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
873  ->SetBinEntries(bin, nentries);
874  else
875  incompatible(__PRETTY_FUNCTION__);
876 }
877 
879 void
881 {
882  update();
883  accessRootObject(__PRETTY_FUNCTION__, 1)
884  ->SetEntries(nentries);
885 }
886 
888 void
889 MonitorElement::setBinLabel(int bin, const std::string &label, int axis /* = 1 */)
890 {
891  update();
892  if ( getAxis(__PRETTY_FUNCTION__, axis)->GetNbins() >= bin )
893  {
894  getAxis(__PRETTY_FUNCTION__, axis)
895  ->SetBinLabel(bin, label.c_str());
896  }
897  else
898  {
899  // edm::LogWarning ("MonitorElement")
900  std::cout << "*** MonitorElement: WARNING:"
901  <<"setBinLabel: attempting to set label of non-existent bin number \n";
902  }
903 }
904 
906 void
907 MonitorElement::setAxisRange(double xmin, double xmax, int axis /* = 1 */)
908 {
909  update();
910  getAxis(__PRETTY_FUNCTION__, axis)
911  ->SetRangeUser(xmin, xmax);
912 }
913 
915 void
916 MonitorElement::setAxisTitle(const std::string &title, int axis /* = 1 */)
917 {
918  update();
919  getAxis(__PRETTY_FUNCTION__, axis)
920  ->SetTitle(title.c_str());
921 }
922 
924 void
926 {
927  update();
928  getAxis(__PRETTY_FUNCTION__, axis)
929  ->SetTimeDisplay(value);
930 }
931 
933 void
934 MonitorElement::setAxisTimeFormat(const char *format /* = "" */, int axis /* = 1 */)
935 {
936  update();
937  getAxis(__PRETTY_FUNCTION__, axis)
938  ->SetTimeFormat(format);
939 }
940 
942 void
943 MonitorElement::setAxisTimeOffset(double toffset, const char *option /* ="local" */, int axis /* = 1 */)
944 {
945  update();
946  getAxis(__PRETTY_FUNCTION__, axis)
947  ->SetTimeOffset(toffset, option);
948 }
949 
951 void
952 MonitorElement::setTitle(const std::string &title)
953 {
954  update();
955  accessRootObject(__PRETTY_FUNCTION__, 1)
956  ->SetTitle(title.c_str());
957 }
958 
959 TAxis *
960 MonitorElement::getAxis(const char *func, int axis) const
961 {
962  TH1 *h = accessRootObject(func, axis-1);
963  TAxis *a = 0;
964  if (axis == 1)
965  a = h->GetXaxis();
966  else if (axis == 2)
967  a = h->GetYaxis();
968  else if (axis == 3)
969  a = h->GetZaxis();
970 
971  if (! a)
972  raiseDQMError("MonitorElement", "No such axis %d in monitor element"
973  " '%s' of type '%s'", axis, data_.objname.c_str(),
974  typeid(*h).name());
975 
976  return a;
977 }
978 
979 // ------------ Operations for MEs that are normally never reset ---------
980 
983 void
985 {
986  update();
987 
988  // Create the reference object the first time this is called.
989  // On subsequent calls accumulate the current value to the
990  // reference, and then reset the current value. This way the
991  // future contents will have the reference "subtracted".
992  if (kind() == DQM_KIND_TH1F)
993  {
994  TH1F *orig = static_cast<TH1F *>(object_);
995  TH1F *r = static_cast<TH1F *>(refvalue_);
996  if (! r)
997  {
998  refvalue_ = r = new TH1F((std::string(orig->GetName()) + "_ref").c_str(),
999  orig->GetTitle(),
1000  orig->GetNbinsX(),
1001  orig->GetXaxis()->GetXmin(),
1002  orig->GetXaxis()->GetXmax());
1003  r->SetDirectory(0);
1004  r->Reset();
1005  }
1006 
1007  r->Add(orig);
1008  orig->Reset();
1009  }
1010  else if (kind() == DQM_KIND_TH1S)
1011  {
1012  TH1S *orig = static_cast<TH1S *>(object_);
1013  TH1S *r = static_cast<TH1S *>(refvalue_);
1014  if (! r)
1015  {
1016  refvalue_ = r = new TH1S((std::string(orig->GetName()) + "_ref").c_str(),
1017  orig->GetTitle(),
1018  orig->GetNbinsX(),
1019  orig->GetXaxis()->GetXmin(),
1020  orig->GetXaxis()->GetXmax());
1021  r->SetDirectory(0);
1022  r->Reset();
1023  }
1024 
1025  r->Add(orig);
1026  orig->Reset();
1027  }
1028  else if (kind() == DQM_KIND_TH1D)
1029  {
1030  TH1D *orig = static_cast<TH1D *>(object_);
1031  TH1D *r = static_cast<TH1D *>(refvalue_);
1032  if (! r)
1033  {
1034  refvalue_ = r = new TH1D((std::string(orig->GetName()) + "_ref").c_str(),
1035  orig->GetTitle(),
1036  orig->GetNbinsX(),
1037  orig->GetXaxis()->GetXmin(),
1038  orig->GetXaxis()->GetXmax());
1039  r->SetDirectory(0);
1040  r->Reset();
1041  }
1042 
1043  r->Add(orig);
1044  orig->Reset();
1045  }
1046  else if (kind() == DQM_KIND_TH2F)
1047  {
1048  TH2F *orig = static_cast<TH2F *>(object_);
1049  TH2F *r = static_cast<TH2F *>(refvalue_);
1050  if (! r)
1051  {
1052  refvalue_ = r = new TH2F((std::string(orig->GetName()) + "_ref").c_str(),
1053  orig->GetTitle(),
1054  orig->GetNbinsX(),
1055  orig->GetXaxis()->GetXmin(),
1056  orig->GetXaxis()->GetXmax(),
1057  orig->GetNbinsY(),
1058  orig->GetYaxis()->GetXmin(),
1059  orig->GetYaxis()->GetXmax());
1060  r->SetDirectory(0);
1061  r->Reset();
1062  }
1063 
1064  r->Add(orig);
1065  orig->Reset();
1066  }
1067  else if (kind() == DQM_KIND_TH2S)
1068  {
1069  TH2S *orig = static_cast<TH2S *>(object_);
1070  TH2S *r = static_cast<TH2S *>(refvalue_);
1071  if (! r)
1072  {
1073  refvalue_ = r = new TH2S((std::string(orig->GetName()) + "_ref").c_str(),
1074  orig->GetTitle(),
1075  orig->GetNbinsX(),
1076  orig->GetXaxis()->GetXmin(),
1077  orig->GetXaxis()->GetXmax(),
1078  orig->GetNbinsY(),
1079  orig->GetYaxis()->GetXmin(),
1080  orig->GetYaxis()->GetXmax());
1081  r->SetDirectory(0);
1082  r->Reset();
1083  }
1084 
1085  r->Add(orig);
1086  orig->Reset();
1087  }
1088  else if (kind() == DQM_KIND_TH2D)
1089  {
1090  TH2D *orig = static_cast<TH2D *>(object_);
1091  TH2D *r = static_cast<TH2D *>(refvalue_);
1092  if (! r)
1093  {
1094  refvalue_ = r = new TH2D((std::string(orig->GetName()) + "_ref").c_str(),
1095  orig->GetTitle(),
1096  orig->GetNbinsX(),
1097  orig->GetXaxis()->GetXmin(),
1098  orig->GetXaxis()->GetXmax(),
1099  orig->GetNbinsY(),
1100  orig->GetYaxis()->GetXmin(),
1101  orig->GetYaxis()->GetXmax());
1102  r->SetDirectory(0);
1103  r->Reset();
1104  }
1105 
1106  r->Add(orig);
1107  orig->Reset();
1108  }
1109  else if (kind() == DQM_KIND_TH3F)
1110  {
1111  TH3F *orig = static_cast<TH3F *>(object_);
1112  TH3F *r = static_cast<TH3F *>(refvalue_);
1113  if (! r)
1114  {
1115  refvalue_ = r = new TH3F((std::string(orig->GetName()) + "_ref").c_str(),
1116  orig->GetTitle(),
1117  orig->GetNbinsX(),
1118  orig->GetXaxis()->GetXmin(),
1119  orig->GetXaxis()->GetXmax(),
1120  orig->GetNbinsY(),
1121  orig->GetYaxis()->GetXmin(),
1122  orig->GetYaxis()->GetXmax(),
1123  orig->GetNbinsZ(),
1124  orig->GetZaxis()->GetXmin(),
1125  orig->GetZaxis()->GetXmax());
1126  r->SetDirectory(0);
1127  r->Reset();
1128  }
1129 
1130  r->Add(orig);
1131  orig->Reset();
1132  }
1133  else if (kind() == DQM_KIND_TPROFILE)
1134  {
1135  TProfile *orig = static_cast<TProfile *>(object_);
1136  TProfile *r = static_cast<TProfile *>(refvalue_);
1137  if (! r)
1138  {
1139  refvalue_ = r = new TProfile((std::string(orig->GetName()) + "_ref").c_str(),
1140  orig->GetTitle(),
1141  orig->GetNbinsX(),
1142  orig->GetXaxis()->GetXmin(),
1143  orig->GetXaxis()->GetXmax(),
1144  orig->GetYaxis()->GetXmin(),
1145  orig->GetYaxis()->GetXmax(),
1146  orig->GetErrorOption());
1147  r->SetDirectory(0);
1148  r->Reset();
1149  }
1150 
1151  addProfiles(r, orig, r, 1, 1);
1152  orig->Reset();
1153  }
1154  else if (kind() == DQM_KIND_TPROFILE2D)
1155  {
1156  TProfile2D *orig = static_cast<TProfile2D *>(object_);
1157  TProfile2D *r = static_cast<TProfile2D *>(refvalue_);
1158  if (! r)
1159  {
1160  refvalue_ = r = new TProfile2D((std::string(orig->GetName()) + "_ref").c_str(),
1161  orig->GetTitle(),
1162  orig->GetNbinsX(),
1163  orig->GetXaxis()->GetXmin(),
1164  orig->GetXaxis()->GetXmax(),
1165  orig->GetNbinsY(),
1166  orig->GetYaxis()->GetXmin(),
1167  orig->GetYaxis()->GetXmax(),
1168  orig->GetZaxis()->GetXmin(),
1169  orig->GetZaxis()->GetXmax(),
1170  orig->GetErrorOption());
1171  r->SetDirectory(0);
1172  r->Reset();
1173  }
1174 
1175  addProfiles(r, orig, r, 1, 1);
1176  orig->Reset();
1177  }
1178  else
1179  incompatible(__PRETTY_FUNCTION__);
1180 }
1181 
1183 void
1185 {
1186  if (refvalue_)
1187  {
1188  if (kind() == DQM_KIND_TH1F
1189  || kind() == DQM_KIND_TH1S
1190  || kind() == DQM_KIND_TH1D
1191  || kind() == DQM_KIND_TH2F
1192  || kind() == DQM_KIND_TH2S
1193  || kind() == DQM_KIND_TH2D
1194  || kind() == DQM_KIND_TH3F)
1195  {
1196  TH1 *orig = static_cast<TH1 *>(object_);
1197  orig->Add(refvalue_);
1198  }
1199  else if (kind() == DQM_KIND_TPROFILE)
1200  {
1201  TProfile *orig = static_cast<TProfile *>(object_);
1202  TProfile *r = static_cast<TProfile *>(refvalue_);
1203  addProfiles(orig, r, orig, 1, 1);
1204  }
1205  else if (kind() == DQM_KIND_TPROFILE2D)
1206  {
1207  TProfile2D *orig = static_cast<TProfile2D *>(object_);
1208  TProfile2D *r = static_cast<TProfile2D *>(refvalue_);
1209  addProfiles(orig, r, orig, 1, 1);
1210  }
1211  else
1212  incompatible(__PRETTY_FUNCTION__);
1213 
1214  delete refvalue_;
1215  refvalue_ = 0;
1216  }
1217 }
1218 
1219 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1220 // Can be called with sum = h1 or sum = h2
1221 void
1222 MonitorElement::addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
1223 {
1224  assert(h1);
1225  assert(h2);
1226  assert(sum);
1227 
1228  static const Int_t NUM_STAT = 6;
1229  Double_t stats1[NUM_STAT];
1230  Double_t stats2[NUM_STAT];
1231  Double_t stats3[NUM_STAT];
1232 
1233  bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1234  sum->ResetBit(TH1::kCanRebin);
1235 
1236  for (Int_t i = 0; i < NUM_STAT; ++i)
1237  stats1[i] = stats2[i] = stats3[i] = 0;
1238 
1239  h1->GetStats(stats1);
1240  h2->GetStats(stats2);
1241 
1242  for (Int_t i = 0; i < NUM_STAT; ++i)
1243  stats3[i] = c1*stats1[i] + c2*stats2[i];
1244 
1245  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1246  + c2*TMath::Abs(c2)*stats2[1];
1247 
1248  Double_t entries = c1*h1->GetEntries() + c2* h2->GetEntries();
1249  TArrayD* h1sumw2 = h1->GetSumw2();
1250  TArrayD* h2sumw2 = h2->GetSumw2();
1251  for (Int_t bin = 0, nbin = sum->GetNbinsX()+1; bin <= nbin; ++bin)
1252  {
1253  Double_t entries = c1*h1->GetBinEntries(bin)
1254  + c2*h2->GetBinEntries(bin);
1255  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1256  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1257  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1258  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1259  sum->SetBinContent(bin, content);
1260  sum->SetBinError(bin, error);
1261  sum->SetBinEntries(bin, entries);
1262  }
1263 
1264  sum->SetEntries(entries);
1265  sum->PutStats(stats3);
1266  if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1267 }
1268 
1269 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1270 // Can be called with sum = h1 or sum = h2
1271 void
1272 MonitorElement::addProfiles(TProfile2D *h1, TProfile2D *h2, TProfile2D *sum, float c1, float c2)
1273 {
1274  assert(h1);
1275  assert(h2);
1276  assert(sum);
1277 
1278  static const Int_t NUM_STAT = 9;
1279  Double_t stats1[NUM_STAT];
1280  Double_t stats2[NUM_STAT];
1281  Double_t stats3[NUM_STAT];
1282 
1283  bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1284  sum->ResetBit(TH1::kCanRebin);
1285 
1286  for (Int_t i = 0; i < NUM_STAT; ++i)
1287  stats1[i] = stats2[i] = stats3[i] = 0;
1288 
1289  h1->GetStats(stats1);
1290  h2->GetStats(stats2);
1291 
1292  for (Int_t i = 0; i < NUM_STAT; i++)
1293  stats3[i] = c1*stats1[i] + c2*stats2[i];
1294 
1295  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1296  + c2*TMath::Abs(c2)*stats2[1];
1297 
1298  Double_t entries = c1*h1->GetEntries() + c2*h2->GetEntries();
1299  TArrayD *h1sumw2 = h1->GetSumw2();
1300  TArrayD *h2sumw2 = h2->GetSumw2();
1301  for (Int_t xbin = 0, nxbin = sum->GetNbinsX()+1; xbin <= nxbin; ++xbin)
1302  for (Int_t ybin = 0, nybin = sum->GetNbinsY()+1; ybin <= nybin; ++ybin)
1303  {
1304  Int_t bin = sum->GetBin(xbin, ybin);
1305  Double_t entries = c1*h1->GetBinEntries(bin)
1306  + c2*h2->GetBinEntries(bin);
1307  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1308  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1309  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1310  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1311 
1312  sum->SetBinContent(bin, content);
1313  sum->SetBinError(bin, error);
1314  sum->SetBinEntries(bin, entries);
1315  }
1316  sum->SetEntries(entries);
1317  sum->PutStats(stats3);
1318  if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1319 }
1320 
1321 void
1323 {
1324  // will copy functions only if local-copy and original-object are equal
1325  // (ie. no soft-resetting or accumulating is enabled)
1327  return;
1328 
1329  update();
1330  TList *fromf = from->GetListOfFunctions();
1331  TList *tof = to->GetListOfFunctions();
1332  for (int i = 0, nfuncs = fromf ? fromf->GetSize() : 0; i < nfuncs; ++i)
1333  {
1334  TObject *obj = fromf->At(i);
1335  // not interested in statistics
1336  if (!strcmp(obj->IsA()->GetName(), "TPaveStats"))
1337  continue;
1338 
1339  if (TF1 *fn = dynamic_cast<TF1 *>(obj))
1340  tof->Add(new TF1(*fn));
1341  //else if (dynamic_cast<TPaveStats *>(obj))
1342  // ; // FIXME? tof->Add(new TPaveStats(*stats));
1343  else
1344  raiseDQMError("MonitorElement", "Cannot extract function '%s' of type"
1345  " '%s' from monitor element '%s' for a copy",
1346  obj->GetName(), obj->IsA()->GetName(), data_.objname.c_str());
1347  }
1348 }
1349 
1350 void
1352 {
1353  TH1 *orig = accessRootObject(__PRETTY_FUNCTION__, 1);
1354  if (orig->GetTitle() != from->GetTitle())
1355  orig->SetTitle(from->GetTitle());
1356 
1357  if (!isAccumulateEnabled())
1358  orig->Reset();
1359 
1360  if (isSoftResetEnabled())
1361  {
1362  if (kind() == DQM_KIND_TH1F
1363  || kind() == DQM_KIND_TH1S
1364  || kind() == DQM_KIND_TH1D
1365  || kind() == DQM_KIND_TH2F
1366  || kind() == DQM_KIND_TH2S
1367  || kind() == DQM_KIND_TH2D
1368  || kind() == DQM_KIND_TH3F)
1369  // subtract "reference"
1370  orig->Add(from, refvalue_, 1, -1);
1371  else if (kind() == DQM_KIND_TPROFILE)
1372  // subtract "reference"
1373  addProfiles(static_cast<TProfile *>(from),
1374  static_cast<TProfile *>(refvalue_),
1375  static_cast<TProfile *>(orig),
1376  1, -1);
1377  else if (kind() == DQM_KIND_TPROFILE2D)
1378  // subtract "reference"
1379  addProfiles(static_cast<TProfile2D *>(from),
1380  static_cast<TProfile2D *>(refvalue_),
1381  static_cast<TProfile2D *>(orig),
1382  1, -1);
1383  else
1384  incompatible(__PRETTY_FUNCTION__);
1385  }
1386  else
1387  orig->Add(from);
1388 
1389  copyFunctions(from, orig);
1390 }
1391 
1392 // --- Operations on MEs that are normally reset at end of monitoring cycle ---
1393 void
1394 MonitorElement::getQReport(bool create, const std::string &qtname, QReport *&qr, DQMNet::QValue *&qv)
1395 {
1396  assert(qreports_.size() == data_.qreports.size());
1397 
1398  qr = 0;
1399  qv = 0;
1400 
1401  size_t pos = 0, end = qreports_.size();
1402  while (pos < end && data_.qreports[pos].qtname != qtname)
1403  ++pos;
1404 
1405  if (pos == end && ! create)
1406  return;
1407  else if (pos == end)
1408  {
1409  data_.qreports.push_back(DQMNet::QValue());
1410  qreports_.push_back(QReport(0, 0));
1411 
1412  DQMNet::QValue &q = data_.qreports.back();
1414  q.qtresult = 0;
1415  q.qtname = qtname;
1416  q.message = "NO_MESSAGE_ASSIGNED";
1417  q.algorithm = "UNKNOWN_ALGORITHM";
1418  }
1419 
1420  qr = &qreports_[pos];
1421  qv = &data_.qreports[pos];
1422 }
1423 
1425 void
1427 {
1428  QReport *qr;
1429  DQMNet::QValue *qv;
1430  getQReport(true, desc.qtname, qr, qv);
1431  qr->qcriterion_ = qc;
1432  *qv = desc;
1433  update();
1434 }
1435 
1436 void
1438 {
1439  QReport *qr;
1440  DQMNet::QValue *qv;
1441  getQReport(true, qc->getName(), qr, qv);
1443  qv->message = "NO_MESSAGE_ASSIGNED";
1444  qr->qcriterion_ = qc;
1445  update();
1446 }
1447 
1449 void
1451 {
1452  data_.flags &= ~DQMNet::DQM_PROP_REPORT_ALARM;
1453  for (size_t i = 0, e = data_.qreports.size(); i < e; ++i)
1454  switch (data_.qreports[i].code)
1455  {
1457  break;
1458  case dqm::qstatus::WARNING:
1460  break;
1461  case dqm::qstatus::ERROR:
1463  break;
1464  default:
1466  break;
1467  }
1468 }
1469 
1470 // -------------------------------------------------------------------
1471 TObject *
1473 {
1474  const_cast<MonitorElement *>(this)->update();
1475  return object_;
1476 }
1477 
1478 TH1 *
1480 {
1481  const_cast<MonitorElement *>(this)->update();
1482  return accessRootObject(__PRETTY_FUNCTION__, 0);
1483 }
1484 
1485 TH1F *
1487 {
1488  assert(kind() == DQM_KIND_TH1F);
1489  const_cast<MonitorElement *>(this)->update();
1490  return static_cast<TH1F *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1491 }
1492 
1493 TH1S *
1495 {
1496  assert(kind() == DQM_KIND_TH1S);
1497  const_cast<MonitorElement *>(this)->update();
1498  return static_cast<TH1S *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1499 }
1500 
1501 TH1D *
1503 {
1504  assert(kind() == DQM_KIND_TH1D);
1505  const_cast<MonitorElement *>(this)->update();
1506  return static_cast<TH1D *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1507 }
1508 
1509 TH2F *
1511 {
1512  assert(kind() == DQM_KIND_TH2F);
1513  const_cast<MonitorElement *>(this)->update();
1514  return static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1515 }
1516 
1517 TH2S *
1519 {
1520  assert(kind() == DQM_KIND_TH2S);
1521  const_cast<MonitorElement *>(this)->update();
1522  return static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1523 }
1524 
1525 TH2D *
1527 {
1528  assert(kind() == DQM_KIND_TH2D);
1529  const_cast<MonitorElement *>(this)->update();
1530  return static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1531 }
1532 
1533 TH3F *
1535 {
1536  assert(kind() == DQM_KIND_TH3F);
1537  const_cast<MonitorElement *>(this)->update();
1538  return static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 3));
1539 }
1540 
1541 TProfile *
1543 {
1544  assert(kind() == DQM_KIND_TPROFILE);
1545  const_cast<MonitorElement *>(this)->update();
1546  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1547 }
1548 
1549 TProfile2D *
1551 {
1552  assert(kind() == DQM_KIND_TPROFILE2D);
1553  const_cast<MonitorElement *>(this)->update();
1554  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1555 }
1556 
1557 // -------------------------------------------------------------------
1558 TObject *
1560 {
1561  const_cast<MonitorElement *>(this)->update();
1562  return reference_;
1563 }
1564 
1565 TH1 *
1567 {
1568  const_cast<MonitorElement *>(this)->update();
1569  return checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 0);
1570 }
1571 
1572 TH1F *
1574 {
1575  assert(kind() == DQM_KIND_TH1F);
1576  const_cast<MonitorElement *>(this)->update();
1577  return static_cast<TH1F *>
1578  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1579 }
1580 
1581 TH1S *
1583 {
1584  assert(kind() == DQM_KIND_TH1S);
1585  const_cast<MonitorElement *>(this)->update();
1586  return static_cast<TH1S *>
1587  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1588 }
1589 
1590 TH1D *
1592 {
1593  assert(kind() == DQM_KIND_TH1D);
1594  const_cast<MonitorElement *>(this)->update();
1595  return static_cast<TH1D *>
1596  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1597 }
1598 
1599 TH2F *
1601 {
1602  assert(kind() == DQM_KIND_TH2F);
1603  const_cast<MonitorElement *>(this)->update();
1604  return static_cast<TH2F *>
1605  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1606 }
1607 
1608 TH2S *
1610 {
1611  assert(kind() == DQM_KIND_TH2S);
1612  const_cast<MonitorElement *>(this)->update();
1613  return static_cast<TH2S *>
1614  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1615 }
1616 
1617 TH2D *
1619 {
1620  assert(kind() == DQM_KIND_TH2D);
1621  const_cast<MonitorElement *>(this)->update();
1622  return static_cast<TH2D *>
1623  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1624 }
1625 
1626 TH3F *
1628 {
1629  assert(kind() == DQM_KIND_TH3F);
1630  const_cast<MonitorElement *>(this)->update();
1631  return static_cast<TH3F *>
1632  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 3));
1633 }
1634 
1635 TProfile *
1637 {
1638  assert(kind() == DQM_KIND_TPROFILE);
1639  const_cast<MonitorElement *>(this)->update();
1640  return static_cast<TProfile *>
1641  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1642 }
1643 
1644 TProfile2D *
1646 {
1647  assert(kind() == DQM_KIND_TPROFILE2D);
1648  const_cast<MonitorElement *>(this)->update();
1649  return static_cast<TProfile2D *>
1650  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1651 }
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
int i
Definition: DBlmapReader.cc:9
void incompatible(const char *func) const
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to &lt;qtname&gt; (null pointer if QReport does not exist)
void setBinContent(int binx, double content)
set content of bin (1-D)
QReports qreports
Definition: DQMNet.h:102
TH1 * accessRootObject(const char *func, int reqdim) const
std::string getName(void) const
get name of quality test
Definition: QTest.h:56
void copyFrom(TH1 *from)
MonitorElement * initialise(Kind kind)
std::string algorithm
Definition: DQMNet.h:92
MonitorElement & operator=(const MonitorElement &)
TProfile2D * getTProfile2D(void) const
TH1 * getRefTH1(void) const
uint64_t version
Definition: DQMNet.h:99
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. &lt;name&gt;t=12345&lt;/name&gt;)
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:97
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:98
const std::string * dirname
Definition: DQMNet.h:100
void update(void)
Mark the object updated.
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)
double double double z
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)
list path
Definition: scaleCards.py:51
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)
&quot;Fill&quot; ME method for int64_t
int getNbinsZ(void) const
get # of bins in Z-axis
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
std::string getTitle(void) const
get MonitorElement title
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:38
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
std::string effLabelString(void) const
return label string for the monitor element tag (eg. &lt;name&gt;t=12345&lt;/name&gt;)
bool isAccumulateEnabled(void) const
whether ME contents should be accumulated over multiple monitoring periods; default: false ...
std::string objname
Definition: DQMNet.h:101
std::string valueString(void) const
TH2D * getRefTH2D(void) const
std::string qtname
Definition: DQMNet.h:91
DQMNet::CoreObject data_
TAxis * getAxis(const char *func, int axis) const
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
static std::string from(" from ")
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void setAxisTimeOffset(double toffset, const char *option="local", int axis=1)
set the time offset, if option = &quot;gmt&quot; 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)
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 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:90
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
static const int STATUS_OK
tuple cout
Definition: gather_cfg.py:121
static const uint32_t DQM_PROP_NEW
Definition: DQMNet.h:58
TH2F * getTH2F(void) const
x
Definition: VDTMath.h:216
float qtresult
Definition: DQMNet.h:89
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
SurfaceDeformation * create(int type, const std::vector< double > &params)
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)
T w() const
TH1D * getRefTH1D(void) const
void raiseDQMError(const char *context, const char *fmt,...)
Definition: DQMError.cc:11