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 
64 MonitorElement::initialise(Kind kind, TH1 *rootobj)
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 void
234 {
235  delete object_;
236  delete reference_;
237  delete refvalue_;
238 
239  object_ = nullptr;
240  reference_ = nullptr;
241  refvalue_ = nullptr;
242 }
243 
244 //utility function to check the consistency of the axis labels
245 //taken from TH1::CheckBinLabels which is not public
246 bool
247 MonitorElement::CheckBinLabels(const TAxis* a1, const TAxis * a2)
248 {
249  // check that axis have same labels
250  THashList *l1 = (const_cast<TAxis*>(a1))->GetLabels();
251  THashList *l2 = (const_cast<TAxis*>(a2))->GetLabels();
252 
253  if (!l1 && !l2 )
254  return true;
255  if (!l1 || !l2 ) {
256  return false;
257  }
258  // check now labels sizes are the same
259  if (l1->GetSize() != l2->GetSize() ) {
260  return false;
261  }
262  for (int i = 1; i <= a1->GetNbins(); ++i) {
263  TString label1 = a1->GetBinLabel(i);
264  TString label2 = a2->GetBinLabel(i);
265  if (label1 != label2) {
266  return false;
267  }
268  }
269  return true;
270 }
271 
273 void
275 {
276  update();
277  if (kind() == DQM_KIND_STRING)
278  scalar_.str = value;
279  else
280  incompatible(__PRETTY_FUNCTION__);
281 }
282 
284 void
286 {
287  update();
288  if (kind() == DQM_KIND_INT)
289  scalar_.num = static_cast<int64_t>(x);
290  else if (kind() == DQM_KIND_REAL)
291  scalar_.real = x;
292  else if (kind() == DQM_KIND_TH1F)
293  accessRootObject(__PRETTY_FUNCTION__, 1)
294  ->Fill(x, 1);
295  else if (kind() == DQM_KIND_TH1S)
296  accessRootObject(__PRETTY_FUNCTION__, 1)
297  ->Fill(x, 1);
298  else if (kind() == DQM_KIND_TH1D)
299  accessRootObject(__PRETTY_FUNCTION__, 1)
300  ->Fill(x, 1);
301  else
302  incompatible(__PRETTY_FUNCTION__);
303 }
304 
306 void
308 {
309  update();
310  if (kind() == DQM_KIND_INT)
311  scalar_.num = static_cast<int64_t>(x);
312  else if (kind() == DQM_KIND_REAL)
313  scalar_.real = static_cast<double>(x);
314  else if (kind() == DQM_KIND_TH1F)
315  accessRootObject(__PRETTY_FUNCTION__, 1)
316  ->Fill(static_cast<double>(x), 1);
317  else if (kind() == DQM_KIND_TH1S)
318  accessRootObject(__PRETTY_FUNCTION__, 1)
319  ->Fill(static_cast<double>(x), 1);
320  else if (kind() == DQM_KIND_TH1D)
321  accessRootObject(__PRETTY_FUNCTION__, 1)
322  ->Fill(static_cast<double>(x), 1);
323  else
324  incompatible(__PRETTY_FUNCTION__);
325 }
326 
328 void
329 MonitorElement::Fill(double x, double yw)
330 {
331  update();
332  if (kind() == DQM_KIND_TH1F)
333  accessRootObject(__PRETTY_FUNCTION__, 1)
334  ->Fill(x, yw);
335  else if (kind() == DQM_KIND_TH1S)
336  accessRootObject(__PRETTY_FUNCTION__, 1)
337  ->Fill(x, yw);
338  else if (kind() == DQM_KIND_TH1D)
339  accessRootObject(__PRETTY_FUNCTION__, 1)
340  ->Fill(x, yw);
341  else if (kind() == DQM_KIND_TH2F)
342  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
343  ->Fill(x, yw, 1);
344  else if (kind() == DQM_KIND_TH2S)
345  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
346  ->Fill(x, yw, 1);
347  else if (kind() == DQM_KIND_TH2D)
348  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
349  ->Fill(x, yw, 1);
350  else if (kind() == DQM_KIND_TPROFILE)
351  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
352  ->Fill(x, yw, 1);
353  else
354  incompatible(__PRETTY_FUNCTION__);
355 }
356 
360 void
361 MonitorElement::ShiftFillLast(double y, double ye, int xscale)
362 {
363  update();
364  if (kind() == DQM_KIND_TH1F
365  || kind() == DQM_KIND_TH1S
366  || kind() == DQM_KIND_TH1D)
367  {
368  int nbins = getNbinsX();
369  int entries = (int)getEntries();
370  // first fill bins from left to right
371  int index = entries + 1 ;
372  int xlow = 2 ; int xup = nbins ;
373  // if more entries than bins then start shifting
374  if ( entries >= nbins )
375  {
376  index = nbins;
377  xlow = entries - nbins + 3 ; xup = entries+1 ;
378  // average first bin
379  double y1 = getBinContent(1);
380  double y2 = getBinContent(2);
381  double y1err = getBinError(1);
382  double y2err = getBinError(2);
383  double N = entries - nbins + 1.;
384  if ( ye == 0. || y1err == 0. || y2err == 0.)
385  {
386  // for errors zero calculate unweighted mean and its error
387  double sum = N*y1 + y2;
388  y1 = sum/(N+1.) ;
389  // FIXME check if correct
390  double s=(N+1.)*(N*y1*y1 + y2*y2) - sum*sum;
391  if (s>=0.)
392  y1err = sqrt(s)/(N+1.);
393  else
394  y1err = 0.;
395  }
396  else
397  {
398  // for errors non-zero calculate weighted mean and its error
399  double denom = (1./y1err + 1./y2err);
400  double mean = (y1/y1err + y2/y2err)/denom;
401  // FIXME check if correct
402  y1err = sqrt(((y1-mean)*(y1-mean)/y1err +
403  (y2-mean)*(y2-mean)/y2err)/denom/2.);
404  y1 = mean; // set y1 to mean for filling below
405  }
406  setBinContent(1,y1);
407  setBinError(1,y1err);
408  // shift remaining bins to the left
409  for ( int i = 3; i <= nbins ; i++)
410  {
413  }
414  }
415  // fill last bin with new values
416  setBinContent(index,y);
417  setBinError(index,ye);
418  // set entries
419  setEntries(entries+1);
420  // set axis labels and reset drawing option
421  char buffer [10];
422  sprintf (buffer, "%d", xlow*xscale);
423  std::string a(buffer); setBinLabel(2,a);
424  sprintf (buffer, "%d", xup*xscale);
425  std::string b(buffer); setBinLabel(nbins,b);
426  setBinLabel(1,"av.");
427  }
428  else
429  incompatible(__PRETTY_FUNCTION__);
430 }
432 void
433 MonitorElement::Fill(double x, double y, double zw)
434 {
435  update();
436  if (kind() == DQM_KIND_TH2F)
437  static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
438  ->Fill(x, y, zw);
439  else if (kind() == DQM_KIND_TH2S)
440  static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
441  ->Fill(x, y, zw);
442  else if (kind() == DQM_KIND_TH2D)
443  static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
444  ->Fill(x, y, zw);
445  else if (kind() == DQM_KIND_TH3F)
446  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
447  ->Fill(x, y, zw, 1);
448  else if (kind() == DQM_KIND_TPROFILE)
449  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 2))
450  ->Fill(x, y, zw);
451  else if (kind() == DQM_KIND_TPROFILE2D)
452  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
453  ->Fill(x, y, zw, 1);
454  else
455  incompatible(__PRETTY_FUNCTION__);
456 }
457 
459 void
460 MonitorElement::Fill(double x, double y, double z, double w)
461 {
462  update();
463  if (kind() == DQM_KIND_TH3F)
464  static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
465  ->Fill(x, y, z, w);
466  else if (kind() == DQM_KIND_TPROFILE2D)
467  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
468  ->Fill(x, y, z, w);
469  else
470  incompatible(__PRETTY_FUNCTION__);
471 }
472 
474 void
476 {
477  update();
478  if (kind() == DQM_KIND_INT)
479  scalar_.num = 0;
480  else if (kind() == DQM_KIND_REAL)
481  scalar_.real = 0;
482  else if (kind() == DQM_KIND_STRING)
483  scalar_.str.clear();
484  else
485  return accessRootObject(__PRETTY_FUNCTION__, 1)
486  ->Reset();
487 }
488 
490 void
492 {
493  char buf[64];
494  if (kind() == DQM_KIND_INT)
495  {
496  snprintf(buf, sizeof(buf), "%s%" PRId64, prefix, scalar_.num);
497  into = buf;
498  }
499  else if (kind() == DQM_KIND_REAL)
500  {
501  snprintf(buf, sizeof(buf), "%s%.*g", prefix, DBL_DIG+2, scalar_.real);
502  into = buf;
503  }
504  else if (kind() == DQM_KIND_STRING)
505  {
506  into.reserve(strlen(prefix) + scalar_.str.size());
507  into += prefix;
508  into += scalar_.str;
509  }
510  else
511  incompatible(__PRETTY_FUNCTION__);
512 }
513 
515 void
517 {
519 }
520 
525 {
527  if (kind() == DQM_KIND_INT)
528  packScalarData(result, "i=");
529  else if (kind() == DQM_KIND_REAL)
530  packScalarData(result, "f=");
531  else if (kind() == DQM_KIND_STRING)
532  packScalarData(result, "s=");
533  else
534  incompatible(__PRETTY_FUNCTION__);
535 
536  return result;
537 }
538 
544 {
546  std::string val(valueString());
547  result.reserve(6 + 2*data_.objname.size() + val.size());
548  result += '<'; result += data_.objname; result += '>';
549  result += val;
550  result += '<'; result += '/'; result += data_.objname; result += '>';
551  return result;
552 }
553 
557 {
558  char buf[32];
560  size_t len = sprintf(buf, "t=%" PRIu32, data_.tag);
561 
562  result.reserve(6 + 2*data_.objname.size() + len);
563  result += '<'; result += data_.objname; result += '>';
564  result += buf;
565  result += '<'; result += '/'; result += data_.objname; result += '>';
566  return result;
567 }
568 
572 {
574 
575  result.reserve(6 + 2*data_.objname.size() + 3);
576  result += '<'; result += data_.objname; result += '>';
577  result += "e=1";
578  result += '<'; result += '/'; result += data_.objname; result += '>';
579  return result;
580 }
581 
584 {
585  char buf[64];
587  size_t titlelen = data_.objname.size() + qv.qtname.size() + 1;
588  size_t buflen = sprintf(buf, "qr=st:%d:%.*g:", qv.code, DBL_DIG+2, qv.qtresult);
589 
590  result.reserve(7 + 2*titlelen + buflen + qv.algorithm.size() + qv.message.size());
591  result += '<'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
592  result += buf; result += qv.algorithm; result += ':'; result += qv.message;
593  result += '<'; result += '/'; result += data_.objname; result += '.'; result += qv.qtname; result += '>';
594  return result;
595 }
596 
597 const QReport *
599 {
600  QReport *qr;
601  DQMNet::QValue *qv;
602  const_cast<MonitorElement *>(this)->getQReport(false, qtname, qr, qv);
603  return qr;
604 }
605 
606 std::vector<QReport *>
608 {
609  std::vector<QReport *> result;
610  result.reserve(qreports_.size());
611  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
612  {
613  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
614  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
615  result.push_back(const_cast<QReport *>(&qreports_[i]));
616  }
617  return result;
618 }
619 
620 std::vector<QReport *>
622 {
623  std::vector<QReport *> result;
624  result.reserve(qreports_.size());
625  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
626  if (data_.qreports[i].code == dqm::qstatus::WARNING)
627  {
628  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
629  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
630  result.push_back(const_cast<QReport *>(&qreports_[i]));
631  }
632  return result;
633 }
634 
635 std::vector<QReport *>
637 {
638  std::vector<QReport *> result;
639  result.reserve(qreports_.size());
640  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
641  if (data_.qreports[i].code == dqm::qstatus::ERROR)
642  {
643  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
644  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
645  result.push_back(const_cast<QReport *>(&qreports_[i]));
646  }
647  return result;
648 }
649 
650 std::vector<QReport *>
652 {
653  std::vector<QReport *> result;
654  result.reserve(qreports_.size());
655  for (size_t i = 0, e = qreports_.size(); i != e; ++i)
658  && data_.qreports[i].code != dqm::qstatus::ERROR)
659  {
660  const_cast<MonitorElement *>(this)->qreports_[i].qvalue_
661  = const_cast<DQMNet::QValue *>(&data_.qreports[i]);
662  result.push_back(const_cast<QReport *>(&qreports_[i]));
663  }
664  return result;
665 }
666 
668 void
670 {
671  assert(qreports_.size() == data_.qreports.size());
672 
673  // Rerun quality tests where the ME or the quality algorithm was modified.
674  bool dirty = wasUpdated();
675  for (size_t i = 0, e = data_.qreports.size(); i < e; ++i)
676  {
678  QReport &qr = qreports_[i];
679  QCriterion *qc = qr.qcriterion_;
680  qr.qvalue_ = &qv;
681 
682  // if (qc && (dirty || qc->wasModified())) // removed for new QTest (abm-090503)
683  if (qc && dirty)
684  {
685  assert(qc->getName() == qv.qtname);
686  std::string oldMessage = qv.message;
687  int oldStatus = qv.code;
688 
689  qc->runTest(this, qr, qv);
690 
691  if (oldStatus != qv.code || oldMessage != qv.message)
692  update();
693  }
694  }
695 
696  // Update QReport statistics.
698 }
699 
700 void
701 MonitorElement::incompatible(const char *func) const
702 {
703  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
704  " element '%s'", func, data_.objname.c_str());
705 }
706 
707 TH1 *
708 MonitorElement::accessRootObject(const char *func, int reqdim) const
709 {
710  if (kind() < DQM_KIND_TH1F)
711  raiseDQMError("MonitorElement", "Method '%s' cannot be invoked on monitor"
712  " element '%s' because it is not a root object",
713  func, data_.objname.c_str());
714 
715  return checkRootObject(data_.objname, object_, func, reqdim);
716 }
717 
718 /*** getter methods (wrapper around ROOT methods) ****/
719 //
721 double
722 MonitorElement::getMean(int axis /* = 1 */) const
723 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
724  ->GetMean(axis); }
725 
728 double
729 MonitorElement::getMeanError(int axis /* = 1 */) const
730 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
731  ->GetMeanError(axis); }
732 
734 double
735 MonitorElement::getRMS(int axis /* = 1 */) const
736 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
737  ->GetRMS(axis); }
738 
740 double
741 MonitorElement::getRMSError(int axis /* = 1 */) const
742 { return accessRootObject(__PRETTY_FUNCTION__, axis-1)
743  ->GetRMSError(axis); }
744 
746 int
748 { return accessRootObject(__PRETTY_FUNCTION__, 1)
749  ->GetNbinsX(); }
750 
752 int
754 { return accessRootObject(__PRETTY_FUNCTION__, 2)
755  ->GetNbinsY(); }
756 
758 int
760 { return accessRootObject(__PRETTY_FUNCTION__, 3)
761  ->GetNbinsZ(); }
762 
764 double
766 { return accessRootObject(__PRETTY_FUNCTION__, 1)
767  ->GetBinContent(binx); }
768 
770 double
771 MonitorElement::getBinContent(int binx, int biny) const
772 { return accessRootObject(__PRETTY_FUNCTION__, 2)
773  ->GetBinContent(binx, biny); }
774 
776 double
777 MonitorElement::getBinContent(int binx, int biny, int binz) const
778 { return accessRootObject(__PRETTY_FUNCTION__, 3)
779  ->GetBinContent(binx, biny, binz); }
780 
782 double
784 { return accessRootObject(__PRETTY_FUNCTION__, 1)
785  ->GetBinError(binx); }
786 
788 double
789 MonitorElement::getBinError(int binx, int biny) const
790 { return accessRootObject(__PRETTY_FUNCTION__, 2)
791  ->GetBinError(binx, biny); }
792 
794 double
795 MonitorElement::getBinError(int binx, int biny, int binz) const
796 { return accessRootObject(__PRETTY_FUNCTION__, 3)
797  ->GetBinError(binx, biny, binz); }
798 
800 double
802 { return accessRootObject(__PRETTY_FUNCTION__, 1)
803  ->GetEntries(); }
804 
806 double
808 {
809  if (kind() == DQM_KIND_TPROFILE)
810  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
811  ->GetBinEntries(bin);
812  else if (kind() == DQM_KIND_TPROFILE2D)
813  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
814  ->GetBinEntries(bin);
815  else
816  {
817  incompatible(__PRETTY_FUNCTION__);
818  return 0;
819  }
820 }
821 
823 double
825 {
826  if (kind() == DQM_KIND_TPROFILE)
827  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
828  ->GetYmin();
829  else
830  {
831  incompatible(__PRETTY_FUNCTION__);
832  return 0;
833  }
834 }
835 
837 double
839 {
840  if (kind() == DQM_KIND_TPROFILE)
841  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
842  ->GetYmax();
843  else
844  {
845  incompatible(__PRETTY_FUNCTION__);
846  return 0;
847  }
848 }
849 
852 MonitorElement::getAxisTitle(int axis /* = 1 */) const
853 { return getAxis(__PRETTY_FUNCTION__, axis)
854  ->GetTitle(); }
855 
859 { return accessRootObject(__PRETTY_FUNCTION__, 1)
860  ->GetTitle(); }
861 
862 /*** setter methods (wrapper around ROOT methods) ****/
863 //
865 void
867 {
868  update();
869  accessRootObject(__PRETTY_FUNCTION__, 1)
870  ->SetBinContent(binx, content);
871 }
872 
874 void
875 MonitorElement::setBinContent(int binx, int biny, double content)
876 {
877  update();
878  accessRootObject(__PRETTY_FUNCTION__, 2)
879  ->SetBinContent(binx, biny, content); }
880 
882 void
883 MonitorElement::setBinContent(int binx, int biny, int binz, double content)
884 {
885  update();
886  accessRootObject(__PRETTY_FUNCTION__, 3)
887  ->SetBinContent(binx, biny, binz, content); }
888 
890 void
892 {
893  update();
894  accessRootObject(__PRETTY_FUNCTION__, 1)
895  ->SetBinError(binx, error);
896 }
897 
899 void
900 MonitorElement::setBinError(int binx, int biny, double error)
901 {
902  update();
903  accessRootObject(__PRETTY_FUNCTION__, 2)
904  ->SetBinError(binx, biny, error);
905 }
906 
908 void
909 MonitorElement::setBinError(int binx, int biny, int binz, double error)
910 {
911  update();
912  accessRootObject(__PRETTY_FUNCTION__, 3)
913  ->SetBinError(binx, biny, binz, error);
914 }
915 
917 void
918 MonitorElement::setBinEntries(int bin, double nentries)
919 {
920  update();
921  if (kind() == DQM_KIND_TPROFILE)
922  static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
923  ->SetBinEntries(bin, nentries);
924  else if (kind() == DQM_KIND_TPROFILE2D)
925  static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 1))
926  ->SetBinEntries(bin, nentries);
927  else
928  incompatible(__PRETTY_FUNCTION__);
929 }
930 
932 void
934 {
935  update();
936  accessRootObject(__PRETTY_FUNCTION__, 1)
937  ->SetEntries(nentries);
938 }
939 
941 void
942 MonitorElement::setBinLabel(int bin, const std::string &label, int axis /* = 1 */)
943 {
944  update();
945  if ( getAxis(__PRETTY_FUNCTION__, axis)->GetNbins() >= bin )
946  {
947  getAxis(__PRETTY_FUNCTION__, axis)
948  ->SetBinLabel(bin, label.c_str());
949  }
950  else
951  {
952  // edm::LogWarning ("MonitorElement")
953  std::cout << "*** MonitorElement: WARNING:"
954  <<"setBinLabel: attempting to set label of non-existent bin number \n";
955  }
956 }
957 
959 void
960 MonitorElement::setAxisRange(double xmin, double xmax, int axis /* = 1 */)
961 {
962  update();
963  getAxis(__PRETTY_FUNCTION__, axis)
964  ->SetRangeUser(xmin, xmax);
965 }
966 
968 void
969 MonitorElement::setAxisTitle(const std::string &title, int axis /* = 1 */)
970 {
971  update();
972  getAxis(__PRETTY_FUNCTION__, axis)
973  ->SetTitle(title.c_str());
974 }
975 
977 void
979 {
980  update();
981  getAxis(__PRETTY_FUNCTION__, axis)
982  ->SetTimeDisplay(value);
983 }
984 
986 void
987 MonitorElement::setAxisTimeFormat(const char *format /* = "" */, int axis /* = 1 */)
988 {
989  update();
990  getAxis(__PRETTY_FUNCTION__, axis)
991  ->SetTimeFormat(format);
992 }
993 
995 void
996 MonitorElement::setAxisTimeOffset(double toffset, const char *option /* ="local" */, int axis /* = 1 */)
997 {
998  update();
999  getAxis(__PRETTY_FUNCTION__, axis)
1000  ->SetTimeOffset(toffset, option);
1001 }
1002 
1004 void
1006 {
1007  update();
1008  accessRootObject(__PRETTY_FUNCTION__, 1)
1009  ->SetTitle(title.c_str());
1010 }
1011 
1012 TAxis *
1013 MonitorElement::getAxis(const char *func, int axis) const
1014 {
1015  TH1 *h = accessRootObject(func, axis-1);
1016  TAxis *a = 0;
1017  if (axis == 1)
1018  a = h->GetXaxis();
1019  else if (axis == 2)
1020  a = h->GetYaxis();
1021  else if (axis == 3)
1022  a = h->GetZaxis();
1023 
1024  if (! a)
1025  raiseDQMError("MonitorElement", "No such axis %d in monitor element"
1026  " '%s' of type '%s'", axis, data_.objname.c_str(),
1027  typeid(*h).name());
1028 
1029  return a;
1030 }
1031 
1032 // ------------ Operations for MEs that are normally never reset ---------
1033 
1036 void
1038 {
1039  update();
1040 
1041  // Create the reference object the first time this is called.
1042  // On subsequent calls accumulate the current value to the
1043  // reference, and then reset the current value. This way the
1044  // future contents will have the reference "subtracted".
1045  if (kind() == DQM_KIND_TH1F)
1046  {
1047  TH1F *orig = static_cast<TH1F *>(object_);
1048  TH1F *r = static_cast<TH1F *>(refvalue_);
1049  if (! r)
1050  {
1051  refvalue_ = r = new TH1F((std::string(orig->GetName()) + "_ref").c_str(),
1052  orig->GetTitle(),
1053  orig->GetNbinsX(),
1054  orig->GetXaxis()->GetXmin(),
1055  orig->GetXaxis()->GetXmax());
1056  r->SetDirectory(0);
1057  r->Reset();
1058  }
1059 
1060  r->Add(orig);
1061  orig->Reset();
1062  }
1063  else if (kind() == DQM_KIND_TH1S)
1064  {
1065  TH1S *orig = static_cast<TH1S *>(object_);
1066  TH1S *r = static_cast<TH1S *>(refvalue_);
1067  if (! r)
1068  {
1069  refvalue_ = r = new TH1S((std::string(orig->GetName()) + "_ref").c_str(),
1070  orig->GetTitle(),
1071  orig->GetNbinsX(),
1072  orig->GetXaxis()->GetXmin(),
1073  orig->GetXaxis()->GetXmax());
1074  r->SetDirectory(0);
1075  r->Reset();
1076  }
1077 
1078  r->Add(orig);
1079  orig->Reset();
1080  }
1081  else if (kind() == DQM_KIND_TH1D)
1082  {
1083  TH1D *orig = static_cast<TH1D *>(object_);
1084  TH1D *r = static_cast<TH1D *>(refvalue_);
1085  if (! r)
1086  {
1087  refvalue_ = r = new TH1D((std::string(orig->GetName()) + "_ref").c_str(),
1088  orig->GetTitle(),
1089  orig->GetNbinsX(),
1090  orig->GetXaxis()->GetXmin(),
1091  orig->GetXaxis()->GetXmax());
1092  r->SetDirectory(0);
1093  r->Reset();
1094  }
1095 
1096  r->Add(orig);
1097  orig->Reset();
1098  }
1099  else if (kind() == DQM_KIND_TH2F)
1100  {
1101  TH2F *orig = static_cast<TH2F *>(object_);
1102  TH2F *r = static_cast<TH2F *>(refvalue_);
1103  if (! r)
1104  {
1105  refvalue_ = r = new TH2F((std::string(orig->GetName()) + "_ref").c_str(),
1106  orig->GetTitle(),
1107  orig->GetNbinsX(),
1108  orig->GetXaxis()->GetXmin(),
1109  orig->GetXaxis()->GetXmax(),
1110  orig->GetNbinsY(),
1111  orig->GetYaxis()->GetXmin(),
1112  orig->GetYaxis()->GetXmax());
1113  r->SetDirectory(0);
1114  r->Reset();
1115  }
1116 
1117  r->Add(orig);
1118  orig->Reset();
1119  }
1120  else if (kind() == DQM_KIND_TH2S)
1121  {
1122  TH2S *orig = static_cast<TH2S *>(object_);
1123  TH2S *r = static_cast<TH2S *>(refvalue_);
1124  if (! r)
1125  {
1126  refvalue_ = r = new TH2S((std::string(orig->GetName()) + "_ref").c_str(),
1127  orig->GetTitle(),
1128  orig->GetNbinsX(),
1129  orig->GetXaxis()->GetXmin(),
1130  orig->GetXaxis()->GetXmax(),
1131  orig->GetNbinsY(),
1132  orig->GetYaxis()->GetXmin(),
1133  orig->GetYaxis()->GetXmax());
1134  r->SetDirectory(0);
1135  r->Reset();
1136  }
1137 
1138  r->Add(orig);
1139  orig->Reset();
1140  }
1141  else if (kind() == DQM_KIND_TH2D)
1142  {
1143  TH2D *orig = static_cast<TH2D *>(object_);
1144  TH2D *r = static_cast<TH2D *>(refvalue_);
1145  if (! r)
1146  {
1147  refvalue_ = r = new TH2D((std::string(orig->GetName()) + "_ref").c_str(),
1148  orig->GetTitle(),
1149  orig->GetNbinsX(),
1150  orig->GetXaxis()->GetXmin(),
1151  orig->GetXaxis()->GetXmax(),
1152  orig->GetNbinsY(),
1153  orig->GetYaxis()->GetXmin(),
1154  orig->GetYaxis()->GetXmax());
1155  r->SetDirectory(0);
1156  r->Reset();
1157  }
1158 
1159  r->Add(orig);
1160  orig->Reset();
1161  }
1162  else if (kind() == DQM_KIND_TH3F)
1163  {
1164  TH3F *orig = static_cast<TH3F *>(object_);
1165  TH3F *r = static_cast<TH3F *>(refvalue_);
1166  if (! r)
1167  {
1168  refvalue_ = r = new TH3F((std::string(orig->GetName()) + "_ref").c_str(),
1169  orig->GetTitle(),
1170  orig->GetNbinsX(),
1171  orig->GetXaxis()->GetXmin(),
1172  orig->GetXaxis()->GetXmax(),
1173  orig->GetNbinsY(),
1174  orig->GetYaxis()->GetXmin(),
1175  orig->GetYaxis()->GetXmax(),
1176  orig->GetNbinsZ(),
1177  orig->GetZaxis()->GetXmin(),
1178  orig->GetZaxis()->GetXmax());
1179  r->SetDirectory(0);
1180  r->Reset();
1181  }
1182 
1183  r->Add(orig);
1184  orig->Reset();
1185  }
1186  else if (kind() == DQM_KIND_TPROFILE)
1187  {
1188  TProfile *orig = static_cast<TProfile *>(object_);
1189  TProfile *r = static_cast<TProfile *>(refvalue_);
1190  if (! r)
1191  {
1192  refvalue_ = r = new TProfile((std::string(orig->GetName()) + "_ref").c_str(),
1193  orig->GetTitle(),
1194  orig->GetNbinsX(),
1195  orig->GetXaxis()->GetXmin(),
1196  orig->GetXaxis()->GetXmax(),
1197  orig->GetYaxis()->GetXmin(),
1198  orig->GetYaxis()->GetXmax(),
1199  orig->GetErrorOption());
1200  r->SetDirectory(0);
1201  r->Reset();
1202  }
1203 
1204  addProfiles(r, orig, r, 1, 1);
1205  orig->Reset();
1206  }
1207  else if (kind() == DQM_KIND_TPROFILE2D)
1208  {
1209  TProfile2D *orig = static_cast<TProfile2D *>(object_);
1210  TProfile2D *r = static_cast<TProfile2D *>(refvalue_);
1211  if (! r)
1212  {
1213  refvalue_ = r = new TProfile2D((std::string(orig->GetName()) + "_ref").c_str(),
1214  orig->GetTitle(),
1215  orig->GetNbinsX(),
1216  orig->GetXaxis()->GetXmin(),
1217  orig->GetXaxis()->GetXmax(),
1218  orig->GetNbinsY(),
1219  orig->GetYaxis()->GetXmin(),
1220  orig->GetYaxis()->GetXmax(),
1221  orig->GetZaxis()->GetXmin(),
1222  orig->GetZaxis()->GetXmax(),
1223  orig->GetErrorOption());
1224  r->SetDirectory(0);
1225  r->Reset();
1226  }
1227 
1228  addProfiles(r, orig, r, 1, 1);
1229  orig->Reset();
1230  }
1231  else
1232  incompatible(__PRETTY_FUNCTION__);
1233 }
1234 
1236 void
1238 {
1239  if (refvalue_)
1240  {
1241  if (kind() == DQM_KIND_TH1F
1242  || kind() == DQM_KIND_TH1S
1243  || kind() == DQM_KIND_TH1D
1244  || kind() == DQM_KIND_TH2F
1245  || kind() == DQM_KIND_TH2S
1246  || kind() == DQM_KIND_TH2D
1247  || kind() == DQM_KIND_TH3F)
1248  {
1249  TH1 *orig = static_cast<TH1 *>(object_);
1250  orig->Add(refvalue_);
1251  }
1252  else if (kind() == DQM_KIND_TPROFILE)
1253  {
1254  TProfile *orig = static_cast<TProfile *>(object_);
1255  TProfile *r = static_cast<TProfile *>(refvalue_);
1256  addProfiles(orig, r, orig, 1, 1);
1257  }
1258  else if (kind() == DQM_KIND_TPROFILE2D)
1259  {
1260  TProfile2D *orig = static_cast<TProfile2D *>(object_);
1261  TProfile2D *r = static_cast<TProfile2D *>(refvalue_);
1262  addProfiles(orig, r, orig, 1, 1);
1263  }
1264  else
1265  incompatible(__PRETTY_FUNCTION__);
1266 
1267  delete refvalue_;
1268  refvalue_ = 0;
1269  }
1270 }
1271 
1272 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1273 // Can be called with sum = h1 or sum = h2
1274 void
1275 MonitorElement::addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
1276 {
1277  assert(h1);
1278  assert(h2);
1279  assert(sum);
1280 
1281  static const Int_t NUM_STAT = 6;
1282  Double_t stats1[NUM_STAT];
1283  Double_t stats2[NUM_STAT];
1284  Double_t stats3[NUM_STAT];
1285 
1286  bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1287  sum->ResetBit(TH1::kCanRebin);
1288 
1289  for (Int_t i = 0; i < NUM_STAT; ++i)
1290  stats1[i] = stats2[i] = stats3[i] = 0;
1291 
1292  h1->GetStats(stats1);
1293  h2->GetStats(stats2);
1294 
1295  for (Int_t i = 0; i < NUM_STAT; ++i)
1296  stats3[i] = c1*stats1[i] + c2*stats2[i];
1297 
1298  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1299  + c2*TMath::Abs(c2)*stats2[1];
1300 
1301  Double_t entries = c1*h1->GetEntries() + c2* h2->GetEntries();
1302  TArrayD* h1sumw2 = h1->GetSumw2();
1303  TArrayD* h2sumw2 = h2->GetSumw2();
1304  for (Int_t bin = 0, nbin = sum->GetNbinsX()+1; bin <= nbin; ++bin)
1305  {
1306  Double_t entries = c1*h1->GetBinEntries(bin)
1307  + c2*h2->GetBinEntries(bin);
1308  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1309  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1310  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1311  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1312  sum->SetBinContent(bin, content);
1313  sum->SetBinError(bin, error);
1314  sum->SetBinEntries(bin, entries);
1315  }
1316 
1317  sum->SetEntries(entries);
1318  sum->PutStats(stats3);
1319  if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1320 }
1321 
1322 // implementation: Giuseppe.Della-Ricca@ts.infn.it
1323 // Can be called with sum = h1 or sum = h2
1324 void
1325 MonitorElement::addProfiles(TProfile2D *h1, TProfile2D *h2, TProfile2D *sum, float c1, float c2)
1326 {
1327  assert(h1);
1328  assert(h2);
1329  assert(sum);
1330 
1331  static const Int_t NUM_STAT = 9;
1332  Double_t stats1[NUM_STAT];
1333  Double_t stats2[NUM_STAT];
1334  Double_t stats3[NUM_STAT];
1335 
1336  bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1337  sum->ResetBit(TH1::kCanRebin);
1338 
1339  for (Int_t i = 0; i < NUM_STAT; ++i)
1340  stats1[i] = stats2[i] = stats3[i] = 0;
1341 
1342  h1->GetStats(stats1);
1343  h2->GetStats(stats2);
1344 
1345  for (Int_t i = 0; i < NUM_STAT; i++)
1346  stats3[i] = c1*stats1[i] + c2*stats2[i];
1347 
1348  stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1349  + c2*TMath::Abs(c2)*stats2[1];
1350 
1351  Double_t entries = c1*h1->GetEntries() + c2*h2->GetEntries();
1352  TArrayD *h1sumw2 = h1->GetSumw2();
1353  TArrayD *h2sumw2 = h2->GetSumw2();
1354  for (Int_t xbin = 0, nxbin = sum->GetNbinsX()+1; xbin <= nxbin; ++xbin)
1355  for (Int_t ybin = 0, nybin = sum->GetNbinsY()+1; ybin <= nybin; ++ybin)
1356  {
1357  Int_t bin = sum->GetBin(xbin, ybin);
1358  Double_t entries = c1*h1->GetBinEntries(bin)
1359  + c2*h2->GetBinEntries(bin);
1360  Double_t content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1361  + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1362  Double_t error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1363  + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1364 
1365  sum->SetBinContent(bin, content);
1366  sum->SetBinError(bin, error);
1367  sum->SetBinEntries(bin, entries);
1368  }
1369  sum->SetEntries(entries);
1370  sum->PutStats(stats3);
1371  if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1372 }
1373 
1374 void
1376 {
1377  // will copy functions only if local-copy and original-object are equal
1378  // (ie. no soft-resetting or accumulating is enabled)
1380  return;
1381 
1382  update();
1383  TList *fromf = from->GetListOfFunctions();
1384  TList *tof = to->GetListOfFunctions();
1385  for (int i = 0, nfuncs = fromf ? fromf->GetSize() : 0; i < nfuncs; ++i)
1386  {
1387  TObject *obj = fromf->At(i);
1388  // not interested in statistics
1389  if (!strcmp(obj->IsA()->GetName(), "TPaveStats"))
1390  continue;
1391 
1392  if (TF1 *fn = dynamic_cast<TF1 *>(obj))
1393  tof->Add(new TF1(*fn));
1394  //else if (dynamic_cast<TPaveStats *>(obj))
1395  // ; // FIXME? tof->Add(new TPaveStats(*stats));
1396  else
1397  raiseDQMError("MonitorElement", "Cannot extract function '%s' of type"
1398  " '%s' from monitor element '%s' for a copy",
1399  obj->GetName(), obj->IsA()->GetName(), data_.objname.c_str());
1400  }
1401 }
1402 
1403 void
1405 {
1406  TH1 *orig = accessRootObject(__PRETTY_FUNCTION__, 1);
1407  if (orig->GetTitle() != from->GetTitle())
1408  orig->SetTitle(from->GetTitle());
1409 
1410  if (!isAccumulateEnabled())
1411  orig->Reset();
1412 
1413  if (isSoftResetEnabled())
1414  {
1415  if (kind() == DQM_KIND_TH1F
1416  || kind() == DQM_KIND_TH1S
1417  || kind() == DQM_KIND_TH1D
1418  || kind() == DQM_KIND_TH2F
1419  || kind() == DQM_KIND_TH2S
1420  || kind() == DQM_KIND_TH2D
1421  || kind() == DQM_KIND_TH3F)
1422  // subtract "reference"
1423  orig->Add(from, refvalue_, 1, -1);
1424  else if (kind() == DQM_KIND_TPROFILE)
1425  // subtract "reference"
1426  addProfiles(static_cast<TProfile *>(from),
1427  static_cast<TProfile *>(refvalue_),
1428  static_cast<TProfile *>(orig),
1429  1, -1);
1430  else if (kind() == DQM_KIND_TPROFILE2D)
1431  // subtract "reference"
1432  addProfiles(static_cast<TProfile2D *>(from),
1433  static_cast<TProfile2D *>(refvalue_),
1434  static_cast<TProfile2D *>(orig),
1435  1, -1);
1436  else
1437  incompatible(__PRETTY_FUNCTION__);
1438  }
1439  else
1440  orig->Add(from);
1441 
1442  copyFunctions(from, orig);
1443 }
1444 
1445 // --- Operations on MEs that are normally reset at end of monitoring cycle ---
1446 void
1448 {
1449  assert(qreports_.size() == data_.qreports.size());
1450 
1451  qr = 0;
1452  qv = 0;
1453 
1454  size_t pos = 0, end = qreports_.size();
1455  while (pos < end && data_.qreports[pos].qtname != qtname)
1456  ++pos;
1457 
1458  if (pos == end && ! create)
1459  return;
1460  else if (pos == end)
1461  {
1462  data_.qreports.push_back(DQMNet::QValue());
1463  qreports_.push_back(QReport(0, 0));
1464 
1465  DQMNet::QValue &q = data_.qreports.back();
1467  q.qtresult = 0;
1468  q.qtname = qtname;
1469  q.message = "NO_MESSAGE_ASSIGNED";
1470  q.algorithm = "UNKNOWN_ALGORITHM";
1471  }
1472 
1473  qr = &qreports_[pos];
1474  qv = &data_.qreports[pos];
1475 }
1476 
1478 void
1480 {
1481  QReport *qr;
1482  DQMNet::QValue *qv;
1483  getQReport(true, desc.qtname, qr, qv);
1484  qr->qcriterion_ = qc;
1485  *qv = desc;
1486  update();
1487 }
1488 
1489 void
1491 {
1492  QReport *qr;
1493  DQMNet::QValue *qv;
1494  getQReport(true, qc->getName(), qr, qv);
1496  qv->message = "NO_MESSAGE_ASSIGNED";
1497  qr->qcriterion_ = qc;
1498  update();
1499 }
1500 
1502 void
1504 {
1505  data_.flags &= ~DQMNet::DQM_PROP_REPORT_ALARM;
1506  for (size_t i = 0, e = data_.qreports.size(); i < e; ++i)
1507  switch (data_.qreports[i].code)
1508  {
1510  break;
1511  case dqm::qstatus::WARNING:
1513  break;
1514  case dqm::qstatus::ERROR:
1516  break;
1517  default:
1519  break;
1520  }
1521 }
1522 
1523 // -------------------------------------------------------------------
1524 TObject *
1526 {
1527  const_cast<MonitorElement *>(this)->update();
1528  return object_;
1529 }
1530 
1531 TH1 *
1533 {
1534  const_cast<MonitorElement *>(this)->update();
1535  return accessRootObject(__PRETTY_FUNCTION__, 0);
1536 }
1537 
1538 TH1F *
1540 {
1541  assert(kind() == DQM_KIND_TH1F);
1542  const_cast<MonitorElement *>(this)->update();
1543  return static_cast<TH1F *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1544 }
1545 
1546 TH1S *
1548 {
1549  assert(kind() == DQM_KIND_TH1S);
1550  const_cast<MonitorElement *>(this)->update();
1551  return static_cast<TH1S *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1552 }
1553 
1554 TH1D *
1556 {
1557  assert(kind() == DQM_KIND_TH1D);
1558  const_cast<MonitorElement *>(this)->update();
1559  return static_cast<TH1D *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1560 }
1561 
1562 TH2F *
1564 {
1565  assert(kind() == DQM_KIND_TH2F);
1566  const_cast<MonitorElement *>(this)->update();
1567  return static_cast<TH2F *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1568 }
1569 
1570 TH2S *
1572 {
1573  assert(kind() == DQM_KIND_TH2S);
1574  const_cast<MonitorElement *>(this)->update();
1575  return static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1576 }
1577 
1578 TH2D *
1580 {
1581  assert(kind() == DQM_KIND_TH2D);
1582  const_cast<MonitorElement *>(this)->update();
1583  return static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1584 }
1585 
1586 TH3F *
1588 {
1589  assert(kind() == DQM_KIND_TH3F);
1590  const_cast<MonitorElement *>(this)->update();
1591  return static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 3));
1592 }
1593 
1594 TProfile *
1596 {
1597  assert(kind() == DQM_KIND_TPROFILE);
1598  const_cast<MonitorElement *>(this)->update();
1599  return static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1));
1600 }
1601 
1602 TProfile2D *
1604 {
1605  assert(kind() == DQM_KIND_TPROFILE2D);
1606  const_cast<MonitorElement *>(this)->update();
1607  return static_cast<TProfile2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
1608 }
1609 
1610 // -------------------------------------------------------------------
1611 TObject *
1613 {
1614  const_cast<MonitorElement *>(this)->update();
1615  return reference_;
1616 }
1617 
1618 TH1 *
1620 {
1621  const_cast<MonitorElement *>(this)->update();
1622  return checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 0);
1623 }
1624 
1625 TH1F *
1627 {
1628  assert(kind() == DQM_KIND_TH1F);
1629  const_cast<MonitorElement *>(this)->update();
1630  return static_cast<TH1F *>
1631  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1632 }
1633 
1634 TH1S *
1636 {
1637  assert(kind() == DQM_KIND_TH1S);
1638  const_cast<MonitorElement *>(this)->update();
1639  return static_cast<TH1S *>
1640  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1641 }
1642 
1643 TH1D *
1645 {
1646  assert(kind() == DQM_KIND_TH1D);
1647  const_cast<MonitorElement *>(this)->update();
1648  return static_cast<TH1D *>
1649  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1650 }
1651 
1652 TH2F *
1654 {
1655  assert(kind() == DQM_KIND_TH2F);
1656  const_cast<MonitorElement *>(this)->update();
1657  return static_cast<TH2F *>
1658  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1659 }
1660 
1661 TH2S *
1663 {
1664  assert(kind() == DQM_KIND_TH2S);
1665  const_cast<MonitorElement *>(this)->update();
1666  return static_cast<TH2S *>
1667  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1668 }
1669 
1670 TH2D *
1672 {
1673  assert(kind() == DQM_KIND_TH2D);
1674  const_cast<MonitorElement *>(this)->update();
1675  return static_cast<TH2D *>
1676  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1677 }
1678 
1679 TH3F *
1681 {
1682  assert(kind() == DQM_KIND_TH3F);
1683  const_cast<MonitorElement *>(this)->update();
1684  return static_cast<TH3F *>
1685  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 3));
1686 }
1687 
1688 TProfile *
1690 {
1691  assert(kind() == DQM_KIND_TPROFILE);
1692  const_cast<MonitorElement *>(this)->update();
1693  return static_cast<TProfile *>
1694  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 1));
1695 }
1696 
1697 TProfile2D *
1699 {
1700  assert(kind() == DQM_KIND_TPROFILE2D);
1701  const_cast<MonitorElement *>(this)->update();
1702  return static_cast<TProfile2D *>
1703  (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
1704 }
1705 
1706 // Local Variables:
1707 // show-trailing-whitespace: t
1708 // truncate-lines: t
1709 // 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: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
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:36
uint32_t flags
Definition: DQMNet.h:98
void disableSoftReset(void)
reverts action of softReset
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
static const int WARNING
TH3F * getTH3F(void) const
TH1D * getTH1D(void) const
void runQTests(void)
run all quality tests
void softReset(void)
TH2D * getTH2D(void) const
uint32_t tag
Definition: DQMNet.h:99
const std::string * dirname
Definition: DQMNet.h:105
void update(void)
Mark the object updated.
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
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
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: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 deleteObjects(void)
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:91
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: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