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 
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_.run = 0;
154  data_.lumi = 0;
155  data_.streamId = 0;
156  data_.moduleId = 0;
157  data_.tag = 0;
159  scalar_.num = 0;
160  scalar_.real = 0;
161 }
162 
164  const std::string &name,
165  uint32_t run /* = 0 */,
166  uint32_t streamId /* = 0 */,
167  uint32_t moduleId /* = 0 */)
168  : object_(0),
169  reference_(0),
170  refvalue_(0)
171 {
172  data_.version = 0;
173  data_.run = run;
174  data_.lumi = 0;
177  data_.dirname = path;
178  data_.objname = name;
179  data_.tag = 0;
181  scalar_.num = 0;
182  scalar_.real = 0;
183 }
184 
186  : data_(x.data_),
187  scalar_(x.scalar_),
188  object_(x.object_),
189  reference_(x.reference_),
190  refvalue_(x.refvalue_),
191  qreports_(x.qreports_)
192 {
193  if (object_)
194  object_ = static_cast<TH1 *>(object_->Clone());
195 
196  if (refvalue_)
197  refvalue_ = static_cast<TH1 *>(refvalue_->Clone());
198 }
199 
202 {
203  if (this != &x)
204  {
205  delete object_;
206  delete refvalue_;
207 
208  data_ = x.data_;
209  scalar_ = x.scalar_;
210  object_ = x.object_;
212  refvalue_ = x.refvalue_;
213  qreports_ = x.qreports_;
214 
215  if (object_)
216  object_ = static_cast<TH1 *>(object_->Clone());
217 
218  if (refvalue_)
219  refvalue_ = static_cast<TH1 *>(refvalue_->Clone());
220  }
221 
222  return *this;
223 }
224 
226 {
227  delete object_;
228  delete refvalue_;
229 }
230 
232 void
234 {
235  update();
236  if (kind() == DQM_KIND_STRING)
237  scalar_.str = value;
238  else
239  incompatible(__PRETTY_FUNCTION__);
240 }
241 
243 void
245 {
246  update();
247  if (kind() == DQM_KIND_INT)
248  scalar_.num = static_cast<int64_t>(x);
249  else if (kind() == DQM_KIND_REAL)
250  scalar_.real = x;
251  else if (kind() == DQM_KIND_TH1F)
252  accessRootObject(__PRETTY_FUNCTION__, 1)
253  ->Fill(x, 1);
254  else if (kind() == DQM_KIND_TH1S)
255  accessRootObject(__PRETTY_FUNCTION__, 1)
256  ->Fill(x, 1);
257  else if (kind() == DQM_KIND_TH1D)
258  accessRootObject(__PRETTY_FUNCTION__, 1)
259  ->Fill(x, 1);
260  else
261  incompatible(__PRETTY_FUNCTION__);
262 }
263 
265 void
267 {
268  update();
269  if (kind() == DQM_KIND_INT)
270  scalar_.num = static_cast<int64_t>(x);
271  else if (kind() == DQM_KIND_REAL)
272  scalar_.real = static_cast<double>(x);
273  else if (kind() == DQM_KIND_TH1F)
274  accessRootObject(__PRETTY_FUNCTION__, 1)
275  ->Fill(static_cast<double>(x), 1);
276  else if (kind() == DQM_KIND_TH1S)
277  accessRootObject(__PRETTY_FUNCTION__, 1)
278  ->Fill(static_cast<double>(x), 1);
279  else if (kind() == DQM_KIND_TH1D)
280  accessRootObject(__PRETTY_FUNCTION__, 1)
281  ->Fill(static_cast<double>(x), 1);
282  else
283  incompatible(__PRETTY_FUNCTION__);
284 }
285 
287 void
288 MonitorElement::Fill(double x, double yw)
289 {
290  update();
291  if (kind() == DQM_KIND_TH1F)
292  accessRootObject(__PRETTY_FUNCTION__, 1)
293  ->Fill(x, yw);
294  else if (kind() == DQM_KIND_TH1S)
295  accessRootObject(__PRETTY_FUNCTION__, 1)
296  ->Fill(x, yw);
297  else if (kind() == DQM_KIND_TH1D)
298  accessRootObject(__PRETTY_FUNCTION__, 1)
299  ->Fill(x, yw);
300  else if (kind() == DQM_KIND_TH2F)
301  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
302  ->Fill(x, yw, 1);
303  else if (kind() == DQM_KIND_TH2S)
304  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
305  ->Fill(x, yw, 1);
306  else if (kind() == DQM_KIND_TH2D)
307  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
308  ->Fill(x, yw, 1);
309  else if (kind() == DQM_KIND_TPROFILE)
310  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
311  ->Fill(x, yw, 1);
312  else
313  incompatible(__PRETTY_FUNCTION__);
314 }
315 
319 void
320 MonitorElement::ShiftFillLast(double y, double ye, int xscale)
321 {
322  update();
323  if (kind() == DQM_KIND_TH1F
324  || kind() == DQM_KIND_TH1S
325  || kind() == DQM_KIND_TH1D)
326  {
327  int nbins = getNbinsX();
328  int entries = (int)getEntries();
329  // first fill bins from left to right
330  int index = entries + 1 ;
331  int xlow = 2 ; int xup = nbins ;
332  // if more entries than bins then start shifting
333  if ( entries >= nbins )
334  {
335  index = nbins;
336  xlow = entries - nbins + 3 ; xup = entries+1 ;
337  // average first bin
338  double y1 = getBinContent(1);
339  double y2 = getBinContent(2);
340  double y1err = getBinError(1);
341  double y2err = getBinError(2);
342  double N = entries - nbins + 1.;
343  if ( ye == 0. || y1err == 0. || y2err == 0.)
344  {
345  // for errors zero calculate unweighted mean and its error
346  double sum = N*y1 + y2;
347  y1 = sum/(N+1.) ;
348  // FIXME check if correct
349  double s=(N+1.)*(N*y1*y1 + y2*y2) - sum*sum;
350  if (s>=0.)
351  y1err = sqrt(s)/(N+1.);
352  else
353  y1err = 0.;
354  }
355  else
356  {
357  // for errors non-zero calculate weighted mean and its error
358  double denom = (1./y1err + 1./y2err);
359  double mean = (y1/y1err + y2/y2err)/denom;
360  // FIXME check if correct
361  y1err = sqrt(((y1-mean)*(y1-mean)/y1err +
362  (y2-mean)*(y2-mean)/y2err)/denom/2.);
363  y1 = mean; // set y1 to mean for filling below
364  }
365  setBinContent(1,y1);
366  setBinError(1,y1err);
367  // shift remaining bins to the left
368  for ( int i = 3; i <= nbins ; i++)
369  {
372  }
373  }
374  // fill last bin with new values
375  setBinContent(index,y);
376  setBinError(index,ye);
377  // set entries
378  setEntries(entries+1);
379  // set axis labels and reset drawing option
380  char buffer [10];
381  sprintf (buffer, "%d", xlow*xscale);
382  std::string a(buffer); setBinLabel(2,a);
383  sprintf (buffer, "%d", xup*xscale);
384  std::string b(buffer); setBinLabel(nbins,b);
385  setBinLabel(1,"av.");
386  }
387  else
388  incompatible(__PRETTY_FUNCTION__);
389 }
391 void
392 MonitorElement::Fill(double x, double y, double zw)
393 {
394  update();
395  if (kind() == DQM_KIND_TH2F)
396  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
397  ->Fill(x, y, zw);
398  else if (kind() == DQM_KIND_TH2S)
399  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
400  ->Fill(x, y, zw);
401  else if (kind() == DQM_KIND_TH2D)
402  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
403  ->Fill(x, y, zw);
404  else if (kind() == DQM_KIND_TH3F)
405  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
406  ->Fill(x, y, zw, 1);
407  else if (kind() == DQM_KIND_TPROFILE)
408  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 2))
409  ->Fill(x, y, zw);
410  else if (kind() == DQM_KIND_TPROFILE2D)
411  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
412  ->Fill(x, y, zw, 1);
413  else
414  incompatible(__PRETTY_FUNCTION__);
415 }
416 
418 void
419 MonitorElement::Fill(double x, double y, double z, double w)
420 {
421  update();
422  if (kind() == DQM_KIND_TH3F)
423  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
424  ->Fill(x, y, z, w);
425  else if (kind() == DQM_KIND_TPROFILE2D)
426  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
427  ->Fill(x, y, z, w);
428  else
429  incompatible(__PRETTY_FUNCTION__);
430 }
431 
433 void
435 {
436  update();
437  if (kind() == DQM_KIND_INT)
438  scalar_.num = 0;
439  else if (kind() == DQM_KIND_REAL)
440  scalar_.real = 0;
441  else if (kind() == DQM_KIND_STRING)
442  scalar_.str.clear();
443  else
444  return accessRootObject(__PRETTY_FUNCTION__, 1)
445  ->Reset();
446 }
447 
449 void
451 {
452  char buf[64];
453  if (kind() == DQM_KIND_INT)
454  {
455  snprintf(buf, sizeof(buf), "%s%" PRId64, prefix, scalar_.num);
456  into = buf;
457  }
458  else if (kind() == DQM_KIND_REAL)
459  {
460  snprintf(buf, sizeof(buf), "%s%.*g", prefix, DBL_DIG+2, scalar_.real);
461  into = buf;
462  }
463  else if (kind() == DQM_KIND_STRING)
464  {
465  into.reserve(strlen(prefix) + scalar_.str.size());
466  into += prefix;
467  into += scalar_.str;
468  }
469  else
470  incompatible(__PRETTY_FUNCTION__);
471 }
472 
474 void
476 {
478 }
479 
484 {
486  if (kind() == DQM_KIND_INT)
487  packScalarData(result, "i=");
488  else if (kind() == DQM_KIND_REAL)
489  packScalarData(result, "f=");
490  else if (kind() == DQM_KIND_STRING)
491  packScalarData(result, "s=");
492  else
493  incompatible(__PRETTY_FUNCTION__);
494 
495  return result;
496 }
497 
503 {
505  std::string val(valueString());
506  result.reserve(6 + 2*data_.objname.size() + val.size());
507  result += '<'; result += data_.objname; result += '>';
508  result += val;
509  result += '<'; result += '/'; result += data_.objname; result += '>';
510  return result;
511 }
512 
516 {
517  char buf[32];
519  size_t len = sprintf(buf, "t=%" PRIu32, data_.tag);
520 
521  result.reserve(6 + 2*data_.objname.size() + len);
522  result += '<'; result += data_.objname; result += '>';
523  result += buf;
524  result += '<'; result += '/'; result += data_.objname; result += '>';
525  return result;
526 }
527 
531 {
533 
534  result.reserve(6 + 2*data_.objname.size() + 3);
535  result += '<'; result += data_.objname; result += '>';
536  result += "e=1";
537  result += '<'; result += '/'; result += data_.objname; result += '>';
538  return result;
539 }
540 
543 {
544  char buf[64];
546  size_t titlelen = data_.objname.size() + qv.qtname.size() + 1;
547  size_t buflen = sprintf(buf, "qr=st:%d:%.*g:", qv.code, DBL_DIG+2, qv.qtresult);
548 
549  result.reserve(7 + 2*titlelen + buflen + qv.algorithm.size() + qv.message.size());
550  result += '<'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
551  result += buf; result += qv.algorithm; result += ':'; result += qv.message;
552  result += '<'; result += '/'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
553  return result;
554 }
555 
556 const QReport *
558 {
559  QReport *qr;
560  DQMNet::QValue *qv;
561  const_cast<MonitorElement *>(this)->getQReport(false, qtname, qr, qv);
562  return qr;
563 }
564 
565 std::vector<QReport *>
567 {
568  std::vector<QReport *> result;
569  result.reserve(qreports_.size());
570  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
571  {
572  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
573  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
574  result.push_back(const_cast<QReport *>(&qreports_[i]));
575  }
576  return result;
577 }
578 
579 std::vector<QReport *>
581 {
582  std::vector<QReport *> result;
583  result.reserve(qreports_.size());
584  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
585  if (data_.qreports[i].code == dqm::qstatus::WARNING)
586  {
587  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
588  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
589  result.push_back(const_cast<QReport *>(&qreports_[i]));
590  }
591  return result;
592 }
593 
594 std::vector<QReport *>
596 {
597  std::vector<QReport *> result;
598  result.reserve(qreports_.size());
599  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
600  if (data_.qreports[i].code == dqm::qstatus::ERROR)
601  {
602  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
603  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
604  result.push_back(const_cast<QReport *>(&qreports_[i]));
605  }
606  return result;
607 }
608 
609 std::vector<QReport *>
611 {
612  std::vector<QReport *> result;
613  result.reserve(qreports_.size());
614  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
617  && data_.qreports[i].code != dqm::qstatus::ERROR)
618  {
619  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
620  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
621  result.push_back(const_cast<QReport *>(&qreports_[i]));
622  }
623  return result;
624 }
625 
627 void
629 {
630  assert(qreports_.size() == data_.qreports.size());
631 
632  // Rerun quality tests where the ME or the quality algorithm was modified.
633  bool dirty = wasUpdated();
634  for (size_t i = 0, e = data_.qreports.size(); i < e; ++i)
635  {
637  QReport &qr = qreports_[i];
638  QCriterion *qc = qr.qcriterion_;
639  qr.qvalue_ = &qv;
640 
641  // if (qc && (dirty || qc->wasModified())) // removed for new QTest (abm-090503)
642  if (qc && dirty)
643  {
644  assert(qc->getName() == qv.qtname);
645  std::string oldMessage = qv.message;
646  int oldStatus = qv.code;
647 
648  qc->runTest(this, qr, qv);
649 
650  if (oldStatus != qv.code || oldMessage != qv.message)
651  update();
652  }
653  }
654 
655  // Update QReport statistics.
657 }
658 
659 void
660 MonitorElement::incompatible(const char *func) const
661 {
662  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
663  " element '%s'", func, data_.objname.c_str());
664 }
665 
666 TH1 *
667 MonitorElement::accessRootObject(const char *func, int reqdim) const
668 {
669  if (kind() < DQM_KIND_TH1F)
670  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
671  " element '%s' because it is not a root object",
672  func, data_.objname.c_str());
673 
674  return checkRootObject(data_.objname, object_, func, reqdim);
675 }
676 
677 /*** getter methods (wrapper around ROOT methods) ****/
678 //
680 double
681 MonitorElement::getMean(int axis /* = 1 */) const
682 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
683  ->GetMean(axis); }
684 
687 double
688 MonitorElement::getMeanError(int axis /* = 1 */) const
689 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
690  ->GetMeanError(axis); }
691 
693 double
694 MonitorElement::getRMS(int axis /* = 1 */) const
695 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
696  ->GetRMS(axis); }
697 
699 double
700 MonitorElement::getRMSError(int axis /* = 1 */) const
701 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
702  ->GetRMSError(axis); }
703 
705 int
707 { return accessRootObject(__PRETTY_FUNCTION__, 1)
708  ->GetNbinsX(); }
709 
711 int
713 { return accessRootObject(__PRETTY_FUNCTION__, 2)
714  ->GetNbinsY(); }
715 
717 int
719 { return accessRootObject(__PRETTY_FUNCTION__, 3)
720  ->GetNbinsZ(); }
721 
723 double
725 { return accessRootObject(__PRETTY_FUNCTION__, 1)
726  ->GetBinContent(binx); }
727 
729 double
730 MonitorElement::getBinContent(int binx, int biny) const
731 { return accessRootObject(__PRETTY_FUNCTION__, 2)
732  ->GetBinContent(binx, biny); }
733 
735 double
736 MonitorElement::getBinContent(int binx, int biny, int binz) const
737 { return accessRootObject(__PRETTY_FUNCTION__, 3)
738  ->GetBinContent(binx, biny, binz); }
739 
741 double
743 { return accessRootObject(__PRETTY_FUNCTION__, 1)
744  ->GetBinError(binx); }
745 
747 double
748 MonitorElement::getBinError(int binx, int biny) const
749 { return accessRootObject(__PRETTY_FUNCTION__, 2)
750  ->GetBinError(binx, biny); }
751 
753 double
754 MonitorElement::getBinError(int binx, int biny, int binz) const
755 { return accessRootObject(__PRETTY_FUNCTION__, 3)
756  ->GetBinError(binx, biny, binz); }
757 
759 double
761 { return accessRootObject(__PRETTY_FUNCTION__, 1)
762  ->GetEntries(); }
763 
765 double
767 {
768  if (kind() == DQM_KIND_TPROFILE)
769  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
770  ->GetBinEntries(bin);
771  else if (kind() == DQM_KIND_TPROFILE2D)
772  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
773  ->GetBinEntries(bin);
774  else
775  {
776  incompatible(__PRETTY_FUNCTION__);
777  return 0;
778  }
779 }
780 
782 double
784 {
785  if (kind() == DQM_KIND_TPROFILE)
786  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
787  ->GetYmin();
788  else
789  {
790  incompatible(__PRETTY_FUNCTION__);
791  return 0;
792  }
793 }
794 
796 double
798 {
799  if (kind() == DQM_KIND_TPROFILE)
800  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
801  ->GetYmax();
802  else
803  {
804  incompatible(__PRETTY_FUNCTION__);
805  return 0;
806  }
807 }
808 
811 MonitorElement::getAxisTitle(int axis /* = 1 */) const
812 { return getAxis(__PRETTY_FUNCTION__, axis)
813  ->GetTitle(); }
814 
818 { return accessRootObject(__PRETTY_FUNCTION__, 1)
819  ->GetTitle(); }
820 
821 /*** setter methods (wrapper around ROOT methods) ****/
822 //
824 void
826 {
827  update();
828  accessRootObject(__PRETTY_FUNCTION__, 1)
829  ->SetBinContent(binx, content);
830 }
831 
833 void
834 MonitorElement::setBinContent(int binx, int biny, double content)
835 {
836  update();
837  accessRootObject(__PRETTY_FUNCTION__, 2)
838  ->SetBinContent(binx, biny, content); }
839 
841 void
842 MonitorElement::setBinContent(int binx, int biny, int binz, double content)
843 {
844  update();
845  accessRootObject(__PRETTY_FUNCTION__, 3)
846  ->SetBinContent(binx, biny, binz, content); }
847 
849 void
851 {
852  update();
853  accessRootObject(__PRETTY_FUNCTION__, 1)
854  ->SetBinError(binx, error);
855 }
856 
858 void
859 MonitorElement::setBinError(int binx, int biny, double error)
860 {
861  update();
862  accessRootObject(__PRETTY_FUNCTION__, 2)
863  ->SetBinError(binx, biny, error);
864 }
865 
867 void
868 MonitorElement::setBinError(int binx, int biny, int binz, double error)
869 {
870  update();
871  accessRootObject(__PRETTY_FUNCTION__, 3)
872  ->SetBinError(binx, biny, binz, error);
873 }
874 
876 void
877 MonitorElement::setBinEntries(int bin, double nentries)
878 {
879  update();
880  if (kind() == DQM_KIND_TPROFILE)
881  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
882  ->SetBinEntries(bin, nentries);
883  else if (kind() == DQM_KIND_TPROFILE2D)
884  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
885  ->SetBinEntries(bin, nentries);
886  else
887  incompatible(__PRETTY_FUNCTION__);
888 }
889 
891 void
893 {
894  update();
895  accessRootObject(__PRETTY_FUNCTION__, 1)
896  ->SetEntries(nentries);
897 }
898 
900 void
901 MonitorElement::setBinLabel(int bin, const std::string &label, int axis /* = 1 */)
902 {
903  update();
904  if ( getAxis(__PRETTY_FUNCTION__, axis)->GetNbins() >= bin )
905  {
906  getAxis(__PRETTY_FUNCTION__, axis)
907  ->SetBinLabel(bin, label.c_str());
908  }
909  else
910  {
911  // edm::LogWarning ("MonitorElement")
912  std::cout << "*** MonitorElement: WARNING:"
913  <<"setBinLabel: attempting to set label of non-existent bin number \n";
914  }
915 }
916 
918 void
919 MonitorElement::setAxisRange(double xmin, double xmax, int axis /* = 1 */)
920 {
921  update();
922  getAxis(__PRETTY_FUNCTION__, axis)
923  ->SetRangeUser(xmin, xmax);
924 }
925 
927 void
928 MonitorElement::setAxisTitle(const std::string &title, int axis /* = 1 */)
929 {
930  update();
931  getAxis(__PRETTY_FUNCTION__, axis)
932  ->SetTitle(title.c_str());
933 }
934 
936 void
938 {
939  update();
940  getAxis(__PRETTY_FUNCTION__, axis)
941  ->SetTimeDisplay(value);
942 }
943 
945 void
946 MonitorElement::setAxisTimeFormat(const char *format /* = "" */, int axis /* = 1 */)
947 {
948  update();
949  getAxis(__PRETTY_FUNCTION__, axis)
950  ->SetTimeFormat(format);
951 }
952 
954 void
955 MonitorElement::setAxisTimeOffset(double toffset, const char *option /* ="local" */, int axis /* = 1 */)
956 {
957  update();
958  getAxis(__PRETTY_FUNCTION__, axis)
959  ->SetTimeOffset(toffset, option);
960 }
961 
963 void
965 {
966  update();
967  accessRootObject(__PRETTY_FUNCTION__, 1)
968  ->SetTitle(title.c_str());
969 }
970 
971 TAxis *
972 MonitorElement::getAxis(const char *func, int axis) const
973 {
974  TH1 *h = accessRootObject(func, axis-1);
975  TAxis *a = 0;
976  if (axis == 1)
977  a = h->GetXaxis();
978  else if (axis == 2)
979  a = h->GetYaxis();
980  else if (axis == 3)
981  a = h->GetZaxis();
982 
983  if (! a)
984  raiseDQMError("MonitorElement", "No such axis %d in monitor element"
985  " '%s' of type '%s'", axis, data_.objname.c_str(),
986  typeid(*h).name());
987 
988  return a;
989 }
990 
991 // ------------ Operations for MEs that are normally never reset ---------
992 
995 void
997 {
998  update();
999 
1000  // Create the reference object the first time this is called.
1001  // On subsequent calls accumulate the current value to the
1002  // reference, and then reset the current value. This way the
1003  // future contents will have the reference "subtracted".
1004  if (kind() == DQM_KIND_TH1F)
1005  {
1006  TH1F *orig = static_cast<TH1F *>(object_);
1007  TH1F *r = static_cast<TH1F *>(refvalue_);
1008  if (! r)
1009  {
1010  refvalue_ = r = new TH1F((std::string(orig->GetName()) + "_ref").c_str(),
1011  orig->GetTitle(),
1012  orig->GetNbinsX(),
1013  orig->GetXaxis()->GetXmin(),
1014  orig->GetXaxis()->GetXmax());
1015  r->SetDirectory(0);
1016  r->Reset();
1017  }
1018 
1019  r->Add(orig);
1020  orig->Reset();
1021  }
1022  else if (kind() == DQM_KIND_TH1S)
1023  {
1024  TH1S *orig = static_cast<TH1S *>(object_);
1025  TH1S *r = static_cast<TH1S *>(refvalue_);
1026  if (! r)
1027  {
1028  refvalue_ = r = new TH1S((std::string(orig->GetName()) + "_ref").c_str(),
1029  orig->GetTitle(),
1030  orig->GetNbinsX(),
1031  orig->GetXaxis()->GetXmin(),
1032  orig->GetXaxis()->GetXmax());
1033  r->SetDirectory(0);
1034  r->Reset();
1035  }
1036 
1037  r->Add(orig);
1038  orig->Reset();
1039  }
1040  else if (kind() == DQM_KIND_TH1D)
1041  {
1042  TH1D *orig = static_cast<TH1D *>(object_);
1043  TH1D *r = static_cast<TH1D *>(refvalue_);
1044  if (! r)
1045  {
1046  refvalue_ = r = new TH1D((std::string(orig->GetName()) + "_ref").c_str(),
1047  orig->GetTitle(),
1048  orig->GetNbinsX(),
1049  orig->GetXaxis()->GetXmin(),
1050  orig->GetXaxis()->GetXmax());
1051  r->SetDirectory(0);
1052  r->Reset();
1053  }
1054 
1055  r->Add(orig);
1056  orig->Reset();
1057  }
1058  else if (kind() == DQM_KIND_TH2F)
1059  {
1060  TH2F *orig = static_cast<TH2F *>(object_);
1061  TH2F *r = static_cast<TH2F *>(refvalue_);
1062  if (! r)
1063  {
1064  refvalue_ = r = new TH2F((std::string(orig->GetName()) + "_ref").c_str(),
1065  orig->GetTitle(),
1066  orig->GetNbinsX(),
1067  orig->GetXaxis()->GetXmin(),
1068  orig->GetXaxis()->GetXmax(),
1069  orig->GetNbinsY(),
1070  orig->GetYaxis()->GetXmin(),
1071  orig->GetYaxis()->GetXmax());
1072  r->SetDirectory(0);
1073  r->Reset();
1074  }
1075 
1076  r->Add(orig);
1077  orig->Reset();
1078  }
1079  else if (kind() == DQM_KIND_TH2S)
1080  {
1081  TH2S *orig = static_cast<TH2S *>(object_);
1082  TH2S *r = static_cast<TH2S *>(refvalue_);
1083  if (! r)
1084  {
1085  refvalue_ = r = new TH2S((std::string(orig->GetName()) + "_ref").c_str(),
1086  orig->GetTitle(),
1087  orig->GetNbinsX(),
1088  orig->GetXaxis()->GetXmin(),
1089  orig->GetXaxis()->GetXmax(),
1090  orig->GetNbinsY(),
1091  orig->GetYaxis()->GetXmin(),
1092  orig->GetYaxis()->GetXmax());
1093  r->SetDirectory(0);
1094  r->Reset();
1095  }
1096 
1097  r->Add(orig);
1098  orig->Reset();
1099  }
1100  else if (kind() == DQM_KIND_TH2D)
1101  {
1102  TH2D *orig = static_cast<TH2D *>(object_);
1103  TH2D *r = static_cast<TH2D *>(refvalue_);
1104  if (! r)
1105  {
1106  refvalue_ = r = new TH2D((std::string(orig->GetName()) + "_ref").c_str(),
1107  orig->GetTitle(),
1108  orig->GetNbinsX(),
1109  orig->GetXaxis()->GetXmin(),
1110  orig->GetXaxis()->GetXmax(),
1111  orig->GetNbinsY(),
1112  orig->GetYaxis()->GetXmin(),
1113  orig->GetYaxis()->GetXmax());
1114  r->SetDirectory(0);
1115  r->Reset();
1116  }
1117 
1118  r->Add(orig);
1119  orig->Reset();
1120  }
1121  else if (kind() == DQM_KIND_TH3F)
1122  {
1123  TH3F *orig = static_cast<TH3F *>(object_);
1124  TH3F *r = static_cast<TH3F *>(refvalue_);
1125  if (! r)
1126  {
1127  refvalue_ = r = new TH3F((std::string(orig->GetName()) + "_ref").c_str(),
1128  orig->GetTitle(),
1129  orig->GetNbinsX(),
1130  orig->GetXaxis()->GetXmin(),
1131  orig->GetXaxis()->GetXmax(),
1132  orig->GetNbinsY(),
1133  orig->GetYaxis()->GetXmin(),
1134  orig->GetYaxis()->GetXmax(),
1135  orig->GetNbinsZ(),
1136  orig->GetZaxis()->GetXmin(),
1137  orig->GetZaxis()->GetXmax());
1138  r->SetDirectory(0);
1139  r->Reset();
1140  }
1141 
1142  r->Add(orig);
1143  orig->Reset();
1144  }
1145  else if (kind() == DQM_KIND_TPROFILE)
1146  {
1147  TProfile *orig = static_cast<TProfile *>(object_);
1148  TProfile *r = static_cast<TProfile *>(refvalue_);
1149  if (! r)
1150  {
1151  refvalue_ = r = new TProfile((std::string(orig->GetName()) + "_ref").c_str(),
1152  orig->GetTitle(),
1153  orig->GetNbinsX(),
1154  orig->GetXaxis()->GetXmin(),
1155  orig->GetXaxis()->GetXmax(),
1156  orig->GetYaxis()->GetXmin(),
1157  orig->GetYaxis()->GetXmax(),
1158  orig->GetErrorOption());
1159  r->SetDirectory(0);
1160  r->Reset();
1161  }
1162 
1163  addProfiles(r, orig, r, 1, 1);
1164  orig->Reset();
1165  }
1166  else if (kind() == DQM_KIND_TPROFILE2D)
1167  {
1168  TProfile2D *orig = static_cast<TProfile2D *>(object_);
1169  TProfile2D *r = static_cast<TProfile2D *>(refvalue_);
1170  if (! r)
1171  {
1172  refvalue_ = r = new TProfile2D((std::string(orig->GetName()) + "_ref").c_str(),
1173  orig->GetTitle(),
1174  orig->GetNbinsX(),
1175  orig->GetXaxis()->GetXmin(),
1176  orig->GetXaxis()->GetXmax(),
1177  orig->GetNbinsY(),
1178  orig->GetYaxis()->GetXmin(),
1179  orig->GetYaxis()->GetXmax(),
1180  orig->GetZaxis()->GetXmin(),
1181  orig->GetZaxis()->GetXmax(),
1182  orig->GetErrorOption());
1183  r->SetDirectory(0);
1184  r->Reset();
1185  }
1186 
1187  addProfiles(r, orig, r, 1, 1);
1188  orig->Reset();
1189  }
1190  else
1191  incompatible(__PRETTY_FUNCTION__);
1192 }
1193 
1195 void
1197 {
1198  if (refvalue_)
1199  {
1200  if (kind() == DQM_KIND_TH1F
1201  || kind() == DQM_KIND_TH1S
1202  || kind() == DQM_KIND_TH1D
1203  || kind() == DQM_KIND_TH2F
1204  || kind() == DQM_KIND_TH2S
1205  || kind() == DQM_KIND_TH2D
1206  || kind() == DQM_KIND_TH3F)
1207  {
1208  TH1 *orig = static_cast<TH1 *>(object_);
1209  orig->Add(refvalue_);
1210  }
1211  else if (kind() == DQM_KIND_TPROFILE)
1212  {
1213  TProfile *orig = static_cast<TProfile *>(object_);
1214  TProfile *r = static_cast<TProfile *>(refvalue_);
1215  addProfiles(orig, r, orig, 1, 1);
1216  }
1217  else if (kind() == DQM_KIND_TPROFILE2D)
1218  {
1219  TProfile2D *orig = static_cast<TProfile2D *>(object_);
1220  TProfile2D *r = static_cast<TProfile2D *>(refvalue_);
1221  addProfiles(orig, r, orig, 1, 1);
1222  }
1223  else
1224  incompatible(__PRETTY_FUNCTION__);
1225 
1226  delete refvalue_;
1227  refvalue_ = 0;
1228  }
1229 }
1230 
1231 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1232 // Can be called with sum = h1 or sum = h2
1233 void
1234 MonitorElement::addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
1235 {
1236  assert(h1);
1237  assert(h2);
1238  assert(sum);
1239 
1240  static const Int_t NUM_STAT = 6;
1241  Double_t stats1[NUM_STAT];
1242  Double_t stats2[NUM_STAT];
1243  Double_t stats3[NUM_STAT];
1244 
1245  bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1246  sum->ResetBit(TH1::kCanRebin);
1247 
1248  for (Int_t i = 0; i < NUM_STAT; ++i)
1249  stats1[i] = stats2[i] = stats3[i] = 0;
1250 
1251  h1->GetStats(stats1);
1252  h2->GetStats(stats2);
1253 
1254  for (Int_t i = 0; i < NUM_STAT; ++i)
1255  stats3[i] = c1*stats1[i] + c2*stats2[i];
1256 
1257  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1258  + c2*TMath::Abs(c2)*stats2[1];
1259 
1260  Double_t entries = c1*h1->GetEntries() + c2* h2->GetEntries();
1261  TArrayD* h1sumw2 = h1->GetSumw2();
1262  TArrayD* h2sumw2 = h2->GetSumw2();
1263  for (Int_t bin = 0, nbin = sum->GetNbinsX()+1; bin <= nbin; ++bin)
1264  {
1265  Double_t entries = c1*h1->GetBinEntries(bin)
1266  + c2*h2->GetBinEntries(bin);
1267  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1268  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1269  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1270  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1271  sum->SetBinContent(bin, content);
1272  sum->SetBinError(bin, error);
1273  sum->SetBinEntries(bin, entries);
1274  }
1275 
1276  sum->SetEntries(entries);
1277  sum->PutStats(stats3);
1278  if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1279 }
1280 
1281 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1282 // Can be called with sum = h1 or sum = h2
1283 void
1284 MonitorElement::addProfiles(TProfile2D *h1, TProfile2D *h2, TProfile2D *sum, float c1, float c2)
1285 {
1286  assert(h1);
1287  assert(h2);
1288  assert(sum);
1289 
1290  static const Int_t NUM_STAT = 9;
1291  Double_t stats1[NUM_STAT];
1292  Double_t stats2[NUM_STAT];
1293  Double_t stats3[NUM_STAT];
1294 
1295  bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1296  sum->ResetBit(TH1::kCanRebin);
1297 
1298  for (Int_t i = 0; i < NUM_STAT; ++i)
1299  stats1[i] = stats2[i] = stats3[i] = 0;
1300 
1301  h1->GetStats(stats1);
1302  h2->GetStats(stats2);
1303 
1304  for (Int_t i = 0; i < NUM_STAT; i++)
1305  stats3[i] = c1*stats1[i] + c2*stats2[i];
1306 
1307  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1308  + c2*TMath::Abs(c2)*stats2[1];
1309 
1310  Double_t entries = c1*h1->GetEntries() + c2*h2->GetEntries();
1311  TArrayD *h1sumw2 = h1->GetSumw2();
1312  TArrayD *h2sumw2 = h2->GetSumw2();
1313  for (Int_t xbin = 0, nxbin = sum->GetNbinsX()+1; xbin <= nxbin; ++xbin)
1314  for (Int_t ybin = 0, nybin = sum->GetNbinsY()+1; ybin <= nybin; ++ybin)
1315  {
1316  Int_t bin = sum->GetBin(xbin, ybin);
1317  Double_t entries = c1*h1->GetBinEntries(bin)
1318  + c2*h2->GetBinEntries(bin);
1319  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1320  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1321  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1322  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1323 
1324  sum->SetBinContent(bin, content);
1325  sum->SetBinError(bin, error);
1326  sum->SetBinEntries(bin, entries);
1327  }
1328  sum->SetEntries(entries);
1329  sum->PutStats(stats3);
1330  if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1331 }
1332 
1333 void
1335 {
1336  // will copy functions only if local-copy and original-object are equal
1337  // (ie. no soft-resetting or accumulating is enabled)
1339  return;
1340 
1341  update();
1342  TList *fromf = from->GetListOfFunctions();
1343  TList *tof = to->GetListOfFunctions();
1344  for (int i = 0, nfuncs = fromf ? fromf->GetSize() : 0; i < nfuncs; ++i)
1345  {
1346  TObject *obj = fromf->At(i);
1347  // not interested in statistics
1348  if (!strcmp(obj->IsA()->GetName(), "TPaveStats"))
1349  continue;
1350 
1351  if (TF1 *fn = dynamic_cast<TF1 *>(obj))
1352  tof->Add(new TF1(*fn));
1353  //else if (dynamic_cast<TPaveStats *>(obj))
1354  // ; // FIXME? tof->Add(new TPaveStats(*stats));
1355  else
1356  raiseDQMError("MonitorElement", "Cannot extract function '%s' of type"
1357  " '%s' from monitor element '%s' for a copy",
1358  obj->GetName(), obj->IsA()->GetName(), data_.objname.c_str());
1359  }
1360 }
1361 
1362 void
1364 {
1365  TH1 *orig = accessRootObject(__PRETTY_FUNCTION__, 1);
1366  if (orig->GetTitle() != from->GetTitle())
1367  orig->SetTitle(from->GetTitle());
1368 
1369  if (!isAccumulateEnabled())
1370  orig->Reset();
1371 
1372  if (isSoftResetEnabled())
1373  {
1374  if (kind() == DQM_KIND_TH1F
1375  || kind() == DQM_KIND_TH1S
1376  || kind() == DQM_KIND_TH1D
1377  || kind() == DQM_KIND_TH2F
1378  || kind() == DQM_KIND_TH2S
1379  || kind() == DQM_KIND_TH2D
1380  || kind() == DQM_KIND_TH3F)
1381  // subtract "reference"
1382  orig->Add(from, refvalue_, 1, -1);
1383  else if (kind() == DQM_KIND_TPROFILE)
1384  // subtract "reference"
1385  addProfiles(static_cast<TProfile *>(from),
1386  static_cast<TProfile *>(refvalue_),
1387  static_cast<TProfile *>(orig),
1388  1, -1);
1389  else if (kind() == DQM_KIND_TPROFILE2D)
1390  // subtract "reference"
1391  addProfiles(static_cast<TProfile2D *>(from),
1392  static_cast<TProfile2D *>(refvalue_),
1393  static_cast<TProfile2D *>(orig),
1394  1, -1);
1395  else
1396  incompatible(__PRETTY_FUNCTION__);
1397  }
1398  else
1399  orig->Add(from);
1400 
1401  copyFunctions(from, orig);
1402 }
1403 
1404 // --- Operations on MEs that are normally reset at end of monitoring cycle ---
1405 void
1407 {
1408  assert(qreports_.size() == data_.qreports.size());
1409 
1410  qr = 0;
1411  qv = 0;
1412 
1413  size_t pos = 0, end = qreports_.size();
1414  while (pos < end && data_.qreports[pos].qtname != qtname)
1415  ++pos;
1416 
1417  if (pos == end && ! create)
1418  return;
1419  else if (pos == end)
1420  {
1421  data_.qreports.push_back(DQMNet::QValue());
1422  qreports_.push_back(QReport(0, 0));
1423 
1424  DQMNet::QValue &q = data_.qreports.back();
1426  q.qtresult = 0;
1427  q.qtname = qtname;
1428  q.message = "NO_MESSAGE_ASSIGNED";
1429  q.algorithm = "UNKNOWN_ALGORITHM";
1430  }
1431 
1432  qr = &qreports_[pos];
1433  qv = &data_.qreports[pos];
1434 }
1435 
1437 void
1439 {
1440  QReport *qr;
1441  DQMNet::QValue *qv;
1442  getQReport(true, desc.qtname, qr, qv);
1443  qr->qcriterion_ = qc;
1444  *qv = desc;
1445  update();
1446 }
1447 
1448 void
1450 {
1451  QReport *qr;
1452  DQMNet::QValue *qv;
1453  getQReport(true, qc->getName(), qr, qv);
1455  qv->message = "NO_MESSAGE_ASSIGNED";
1456  qr->qcriterion_ = qc;
1457  update();
1458 }
1459 
1461 void
1463 {
1464  data_.flags &= ~DQMNet::DQM_PROP_REPORT_ALARM;
1465  for (size_t i = 0, e = data_.qreports.size(); i < e; ++i)
1466  switch (data_.qreports[i].code)
1467  {
1469  break;
1470  case dqm::qstatus::WARNING:
1472  break;
1473  case dqm::qstatus::ERROR:
1475  break;
1476  default:
1478  break;
1479  }
1480 }
1481 
1482 // -------------------------------------------------------------------
1483 TObject *
1485 {
1486  const_cast<MonitorElement *>(this)->update();
1487  return object_;
1488 }
1489 
1490 TH1 *
1492 {
1493  const_cast<MonitorElement *>(this)->update();
1494  return accessRootObject(__PRETTY_FUNCTION__, 0);
1495 }
1496 
1497 TH1F *
1499 {
1500  assert(kind() == DQM_KIND_TH1F);
1501  const_cast<MonitorElement *>(this)->update();
1502  return static_cast<TH1F *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1503 }
1504 
1505 TH1S *
1507 {
1508  assert(kind() == DQM_KIND_TH1S);
1509  const_cast<MonitorElement *>(this)->update();
1510  return static_cast<TH1S *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1511 }
1512 
1513 TH1D *
1515 {
1516  assert(kind() == DQM_KIND_TH1D);
1517  const_cast<MonitorElement *>(this)->update();
1518  return static_cast<TH1D *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1519 }
1520 
1521 TH2F *
1523 {
1524  assert(kind() == DQM_KIND_TH2F);
1525  const_cast<MonitorElement *>(this)->update();
1526  return static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1527 }
1528 
1529 TH2S *
1531 {
1532  assert(kind() == DQM_KIND_TH2S);
1533  const_cast<MonitorElement *>(this)->update();
1534  return static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1535 }
1536 
1537 TH2D *
1539 {
1540  assert(kind() == DQM_KIND_TH2D);
1541  const_cast<MonitorElement *>(this)->update();
1542  return static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1543 }
1544 
1545 TH3F *
1547 {
1548  assert(kind() == DQM_KIND_TH3F);
1549  const_cast<MonitorElement *>(this)->update();
1550  return static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 3));
1551 }
1552 
1553 TProfile *
1555 {
1556  assert(kind() == DQM_KIND_TPROFILE);
1557  const_cast<MonitorElement *>(this)->update();
1558  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1559 }
1560 
1561 TProfile2D *
1563 {
1564  assert(kind() == DQM_KIND_TPROFILE2D);
1565  const_cast<MonitorElement *>(this)->update();
1566  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1567 }
1568 
1569 // -------------------------------------------------------------------
1570 TObject *
1572 {
1573  const_cast<MonitorElement *>(this)->update();
1574  return reference_;
1575 }
1576 
1577 TH1 *
1579 {
1580  const_cast<MonitorElement *>(this)->update();
1581  return checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 0);
1582 }
1583 
1584 TH1F *
1586 {
1587  assert(kind() == DQM_KIND_TH1F);
1588  const_cast<MonitorElement *>(this)->update();
1589  return static_cast<TH1F *>
1590  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1591 }
1592 
1593 TH1S *
1595 {
1596  assert(kind() == DQM_KIND_TH1S);
1597  const_cast<MonitorElement *>(this)->update();
1598  return static_cast<TH1S *>
1599  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1600 }
1601 
1602 TH1D *
1604 {
1605  assert(kind() == DQM_KIND_TH1D);
1606  const_cast<MonitorElement *>(this)->update();
1607  return static_cast<TH1D *>
1608  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1609 }
1610 
1611 TH2F *
1613 {
1614  assert(kind() == DQM_KIND_TH2F);
1615  const_cast<MonitorElement *>(this)->update();
1616  return static_cast<TH2F *>
1617  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1618 }
1619 
1620 TH2S *
1622 {
1623  assert(kind() == DQM_KIND_TH2S);
1624  const_cast<MonitorElement *>(this)->update();
1625  return static_cast<TH2S *>
1626  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1627 }
1628 
1629 TH2D *
1631 {
1632  assert(kind() == DQM_KIND_TH2D);
1633  const_cast<MonitorElement *>(this)->update();
1634  return static_cast<TH2D *>
1635  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1636 }
1637 
1638 TH3F *
1640 {
1641  assert(kind() == DQM_KIND_TH3F);
1642  const_cast<MonitorElement *>(this)->update();
1643  return static_cast<TH3F *>
1644  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 3));
1645 }
1646 
1647 TProfile *
1649 {
1650  assert(kind() == DQM_KIND_TPROFILE);
1651  const_cast<MonitorElement *>(this)->update();
1652  return static_cast<TProfile *>
1653  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1654 }
1655 
1656 TProfile2D *
1658 {
1659  assert(kind() == DQM_KIND_TPROFILE2D);
1660  const_cast<MonitorElement *>(this)->update();
1661  return static_cast<TProfile2D *>
1662  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1663 }
1664 
1665 // Local Variables:
1666 // show-trailing-whitespace: t
1667 // truncate-lines: t
1668 // End:
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
uint32_t moduleId
Definition: DQMNet.h:103
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:106
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: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
auto zw(V v) -> Vec2< typenamestd::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:36
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:104
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)
uint32_t run
Definition: DQMNet.h:100
float float float 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)
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:48
uint32_t lumi
Definition: DQMNet.h:101
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
#define end
Definition: vmac.h:37
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 ...
const uint32_t streamId(void) const
std::string objname
Definition: DQMNet.h:105
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
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 = &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)
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:90
static const int STATUS_OK
const uint32_t run(void) const
tuple cout
Definition: gather_cfg.py:121
T w() const
static const uint32_t DQM_PROP_NEW
Definition: DQMNet.h:58
Definition: DDAxes.h:10
TH2F * getTH2F(void) const
uint32_t streamId
Definition: DQMNet.h:102
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)
TH1D * getRefTH1D(void) const
void raiseDQMError(const char *context, const char *fmt,...)
Definition: DQMError.cc:11