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