test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MonitorElement.h
Go to the documentation of this file.
1 #ifndef DQMSERVICES_CORE_MONITOR_ELEMENT_H
2 # define DQMSERVICES_CORE_MONITOR_ELEMENT_H
3 
6 # include "TF1.h"
7 # include "TH1F.h"
8 # include "TH1S.h"
9 # include "TH1D.h"
10 # include "TH2F.h"
11 # include "TH2S.h"
12 # include "TH2D.h"
13 # include "TH3F.h"
14 # include "TProfile.h"
15 # include "TProfile2D.h"
16 # include "TObjString.h"
17 # include "TAxis.h"
18 # include <sys/time.h>
19 # include <string>
20 # include <set>
21 # include <map>
22 # include <sstream>
23 # include <iomanip>
24 # include <cassert>
25 # include <stdint.h>
26 
27 # ifndef DQM_ROOT_METHODS
28 # define DQM_ROOT_METHODS 1
29 # endif
30 
31 class QCriterion;
32 
35 {
36  friend class DQMStore;
37  friend class DQMService;
38 public:
39  struct Scalar
40  {
41  int64_t num;
42  double real;
44  };
45 
46  enum Kind
47  {
61  };
62 
63  typedef std::vector<QReport>::const_iterator QReportIterator;
64 
65 private:
66  DQMNet::CoreObject data_; //< Core object information.
67  Scalar scalar_; //< Current scalar value.
68  TH1 *object_; //< Current ROOT object value.
69  TH1 *reference_; //< Current ROOT reference object.
70  TH1 *refvalue_; //< Soft reference if any.
71  std::vector<QReport> qreports_; //< QReports associated to this object.
72 
74  MonitorElement *initialise(Kind kind, TH1 *rootobj);
76  void globalize() {
77  data_.streamId = 0;
78  data_.moduleId = 0;
79  }
80  void setLumi(uint32_t ls) {data_.lumi = ls;}
81 
82 public:
83  MonitorElement(void);
85  const std::string &name,
86  uint32_t run = 0,
87  uint32_t streamId = 0,
88  uint32_t moduleId = 0);
91  ~MonitorElement(void);
92 
93  void deleteObjects(void);
94 
96  bool operator<(const MonitorElement &x) const
97  {
98  return DQMNet::setOrder(data_, x.data_);
99  }
100 
102  static bool CheckBinLabels(const TAxis* a1, const TAxis * a2);
103 
105  Kind kind(void) const
107 
109  uint32_t flags(void) const
110  { return data_.flags; }
111 
113  const std::string &getName(void) const
114  { return data_.objname; }
115 
117  const std::string &getPathname(void) const
118  { return *data_.dirname; }
119 
121  const std::string getFullname(void) const
122  {
124  path.reserve(data_.dirname->size() + data_.objname.size() + 2);
125  path += *data_.dirname;
126  if (! data_.dirname->empty())
127  path += '/';
128  path += data_.objname;
129  return path;
130  }
131 
133  bool wasUpdated(void) const
134  { return data_.flags & DQMNet::DQM_PROP_NEW; }
135 
137  void update(void)
139 
142  void setResetMe(bool /* flag */)
144 
146  bool getLumiFlag(void) const
147  { return data_.flags & DQMNet::DQM_PROP_LUMI; }
148 
150  void setLumiFlag(void)
152 
155  void setEfficiencyFlag(void)
157 
158  // A static assert to check that T actually fits in
159  // int64_t.
160  template <typename T>
162  {
163  int checkArray[sizeof(int64_t) - sizeof(T) + 1];
164  };
165 
166  void Fill(long long x) { fits_in_int64_t<long long>(); doFill(static_cast<int64_t>(x)); }
167  void Fill(unsigned long long x) { fits_in_int64_t<unsigned long long>(); doFill(static_cast<int64_t>(x)); }
168  void Fill(unsigned long x) { fits_in_int64_t<unsigned long>(); doFill(static_cast<int64_t>(x)); }
169  void Fill(long x) { fits_in_int64_t<long>(); doFill(static_cast<int64_t>(x)); }
170  void Fill(unsigned int x) { fits_in_int64_t<unsigned int>(); doFill(static_cast<int64_t>(x)); }
171  void Fill(int x) { fits_in_int64_t<int>(); doFill(static_cast<int64_t>(x)); }
172  void Fill(short x) { fits_in_int64_t<short>(); doFill(static_cast<int64_t>(x)); }
173  void Fill(unsigned short x) { fits_in_int64_t<unsigned short>(); doFill(static_cast<int64_t>(x)); }
174  void Fill(char x) { fits_in_int64_t<char>(); doFill(static_cast<int64_t>(x)); }
175  void Fill(unsigned char x) { fits_in_int64_t<unsigned char>(); doFill(static_cast<int64_t>(x)); }
176 
177  void Fill(float x) { Fill(static_cast<double>(x)); }
178  void Fill(double x);
179  void Fill(std::string &value);
180 
181  void Fill(double x, double yw);
182  void Fill(double x, double y, double zw);
183  void Fill(double x, double y, double z, double w);
184  void ShiftFillLast(double y, double ye = 0., int32_t xscale = 1);
185  void Reset(void);
186 
187  std::string valueString(void) const;
188  std::string tagString(void) const;
189  std::string tagLabelString(void) const;
190  std::string effLabelString(void) const;
192  void packScalarData(std::string &into, const char *prefix) const;
193  void packQualityData(std::string &into) const;
194 
196  bool hasError(void) const
198 
200  bool hasWarning(void) const
202 
204  bool hasOtherReport(void) const
206 
209  bool isEfficiency(void) const
211 
213  const QReport *getQReport(const std::string &qtname) const;
214 
216  std::vector<QReport *> getQReports(void) const;
217 
219  std::vector<QReport *> getQWarnings(void) const;
220 
222  std::vector<QReport *> getQErrors(void) const;
223 
226  std::vector<QReport *> getQOthers(void) const;
227 
229  void runQTests(void);
230 
231 private:
232  void doFill(int64_t x);
233  void incompatible(const char *func) const;
234  TH1 *accessRootObject(const char *func, int reqdim) const;
235 
236 public:
237 #if DQM_ROOT_METHODS
238  double getMean(int axis = 1) const;
239  double getMeanError(int axis = 1) const;
240  double getRMS(int axis = 1) const;
241  double getRMSError(int axis = 1) const;
242  int getNbinsX(void) const;
243  int getNbinsY(void) const;
244  int getNbinsZ(void) const;
245  double getBinContent(int binx) const;
246  double getBinContent(int binx, int biny) const;
247  double getBinContent(int binx, int biny, int binz) const;
248  double getBinError(int binx) const;
249  double getBinError(int binx, int biny) const;
250  double getBinError(int binx, int biny, int binz) const;
251  double getEntries(void) const;
252  double getBinEntries(int bin) const;
253 
254 private:
255  double getYmin(void) const;
256  double getYmax(void) const;
257 
258 public:
259  std::string getAxisTitle(int axis = 1) const;
260  std::string getTitle(void) const;
261  void setBinContent(int binx, double content);
262  void setBinContent(int binx, int biny, double content);
263  void setBinContent(int binx, int biny, int binz, double content);
264  void setBinError(int binx, double error);
265  void setBinError(int binx, int biny, double error);
266  void setBinError(int binx, int biny, int binz, double error);
267  void setBinEntries(int bin, double nentries);
268  void setEntries(double nentries);
269  void setBinLabel(int bin, const std::string &label, int axis = 1);
270  void setAxisRange(double xmin, double xmax, int axis = 1);
271  void setAxisTitle(const std::string &title, int axis = 1);
272  void setAxisTimeDisplay(int value, int axis = 1);
273  void setAxisTimeFormat(const char *format = "", int axis = 1);
274 
275 private:
276  void setAxisTimeOffset(double toffset, const char *option="local", int axis = 1);
277 
278 public:
279  void setTitle(const std::string &title);
280 #endif // DQM_ROOT_METHODS
281 
282 private:
284  bool isSoftResetEnabled(void) const
285  { return refvalue_ != 0; }
286 
288  bool isAccumulateEnabled(void) const
290 
292  bool markedToDelete(void) const
294 
297  void markToDelete(void)
299 
300 private:
302  void resetUpdate(void)
303  { data_.flags &= ~DQMNet::DQM_PROP_NEW; }
304 
306  bool resetMe(void) const
307  { return data_.flags & DQMNet::DQM_PROP_RESET; }
308 
311  void setAccumulate(bool /* flag */)
313 
314  TAxis *getAxis(const char *func, int axis) const;
315 
316  // ------------ Operations for MEs that are normally never reset ---------
317  void softReset(void);
318  void disableSoftReset(void);
319  void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2);
320  void addProfiles(TProfile2D *h1, TProfile2D *h2, TProfile2D *sum, float c1, float c2);
321  void copyFunctions(TH1 *from, TH1 *to);
322  void copyFrom(TH1 *from);
323 
324 
325  // --- Operations on MEs that are normally reset at end of monitoring cycle ---
326  void getQReport(bool create, const std::string &qtname, QReport *&qr, DQMNet::QValue *&qv);
327  void addQReport(const DQMNet::QValue &desc, QCriterion *qc);
328  void addQReport(QCriterion *qc);
329  void updateQReportStats(void);
330 
331 public:
332  TObject *getRootObject(void) const;
333  TH1 *getTH1(void) const;
334  TH1F *getTH1F(void) const;
335  TH1S *getTH1S(void) const;
336  TH1D *getTH1D(void) const;
337  TH2F *getTH2F(void) const;
338  TH2S *getTH2S(void) const;
339  TH2D *getTH2D(void) const;
340  TH3F *getTH3F(void) const;
341  TProfile *getTProfile(void) const;
342  TProfile2D *getTProfile2D(void) const;
343 
344  TObject *getRefRootObject(void) const;
345  TH1 *getRefTH1(void) const;
346  TH1F *getRefTH1F(void) const;
347  TH1S *getRefTH1S(void) const;
348  TH1D *getRefTH1D(void) const;
349  TH2F *getRefTH2F(void) const;
350  TH2S *getRefTH2S(void) const;
351  TH2D *getRefTH2D(void) const;
352  TH3F *getRefTH3F(void) const;
353  TProfile *getRefTProfile(void) const;
354  TProfile2D *getRefTProfile2D(void) const;
355 
356  int64_t getIntValue(void) const
357  {
358  assert(kind() == DQM_KIND_INT);
359  return scalar_.num;
360  }
361 
362  double getFloatValue(void) const
363  {
364  assert(kind() == DQM_KIND_REAL);
365  return scalar_.real;
366  }
367 
368  const std::string &getStringValue(void) const
369  {
370  assert(kind() == DQM_KIND_STRING);
371  return scalar_.str;
372  }
373 
374  DQMNet::TagList getTags(void) const // DEPRECATED
375  {
378  tags.push_back(data_.tag);
379  return tags;
380  }
381 
382  const uint32_t getTag(void) const
383  { return data_.tag; }
384 
385  const uint32_t run(void) const {return data_.run;}
386  const uint32_t lumi(void) const {return data_.lumi;}
387  const uint32_t streamId(void) const {return data_.streamId;}
388  const uint32_t moduleId(void) const {return data_.moduleId;}
389 };
390 
391 #endif // DQMSERVICES_CORE_MONITOR_ELEMENT_H
392 
393 /* Local Variables: */
394 /* show-trailing-whitespace: t */
395 /* truncate-lines: t */
396 /* End: */
TH1F * getRefTH1F(void) const
TH2S * getTH2S(void) const
TH1S * getTH1S(void) const
static const uint32_t DQM_PROP_REPORT_WARN
Definition: DQMNet.h:47
const std::string & getName(void) const
get name of ME
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 resetUpdate(void)
reset &quot;was updated&quot; flag
void setBinContent(int binx, double content)
set content of bin (1-D)
static const uint32_t DQM_PROP_TYPE_TH1S
Definition: DQMNet.h:32
TH1 * accessRootObject(const char *func, int reqdim) const
void copyFrom(TH1 *from)
bool markedToDelete(void) const
true if ME is marked for deletion
MonitorElement * initialise(Kind kind)
static const uint32_t DQM_PROP_TYPE_TPROF
Definition: DQMNet.h:40
const double w
Definition: UKUtility.cc:23
MonitorElement & operator=(const MonitorElement &)
TProfile2D * getTProfile2D(void) const
TH1 * getRefTH1(void) const
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
static const uint32_t DQM_PROP_TYPE_TH2D
Definition: DQMNet.h:36
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_
void Fill(unsigned short x)
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
void setLumi(uint32_t ls)
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)
bool hasError(void) const
true if at least of one of the quality tests returned an error
TH3F * getTH3F(void) const
static const uint32_t DQM_PROP_TAGGED
Definition: DQMNet.h:54
TH1D * getTH1D(void) const
void runQTests(void)
run all quality tests
void Fill(float x)
static const uint32_t DQM_PROP_EFFICIENCY_PLOT
Definition: DQMNet.h:63
void softReset(void)
static const uint32_t DQM_PROP_TYPE_TH3F
Definition: DQMNet.h:37
static const uint32_t DQM_PROP_RESET
Definition: DQMNet.h:56
TH2D * getTH2D(void) const
uint32_t tag
Definition: DQMNet.h:99
const std::string * dirname
Definition: DQMNet.h:105
static const uint32_t DQM_PROP_TYPE_TH1F
Definition: DQMNet.h:31
void update(void)
Mark the object updated.
void Fill(short x)
static const uint32_t DQM_PROP_MARKTODELETE
Definition: DQMNet.h:64
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)
bool operator<(const MonitorElement &x) const
Compare monitor elements, for ordering in sets.
uint32_t run
Definition: DQMNet.h:101
float float float z
void Fill(unsigned long long x)
double getMeanError(int axis=1) const
void packScalarData(std::string &into, const char *prefix) const
convert scalar data into a string.
const uint32_t getTag(void) const
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
static const uint32_t DQM_PROP_ACCUMULATE
Definition: DQMNet.h:55
TH3F * getRefTH3F(void) const
bool getLumiFlag(void) const
true if ME is meant to be stored for each luminosity section
const uint32_t lumi(void) const
void Fill(int x)
void ShiftFillLast(double y, double ye=0., int32_t xscale=1)
void packQualityData(std::string &into) const
serialise quality report information into a string.
const std::string & getPathname(void) const
get pathname of parent folder
tuple path
else: Piece not in the list, fine.
TH2F * getRefTH2F(void) const
bool hasWarning(void) const
true if at least of one of the quality tests returned a warning
void setAxisTimeDisplay(int value, int axis=1)
set x-, y-, or z-axis to display time values
static const uint32_t DQM_PROP_TYPE_INT
Definition: DQMNet.h:28
void doFill(int64_t x)
&quot;Fill&quot; ME method for int64_t
DQMNet::TagList getTags(void) const
int getNbinsZ(void) const
get # of bins in Z-axis
void setAccumulate(bool)
uint32_t lumi
Definition: DQMNet.h:102
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
std::string getTitle(void) const
get MonitorElement title
double getFloatValue(void) const
int checkArray[sizeof(int64_t)-sizeof(T)+1]
TH1 * getTH1(void) const
static const uint32_t DQM_PROP_REPORT_ERROR
Definition: DQMNet.h:46
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
std::vector< QReport >::const_iterator QReportIterator
static const uint32_t DQM_PROP_REPORT_OTHER
Definition: DQMNet.h:48
Kind kind(void) const
Get the type of the monitor element.
static const uint32_t DQM_PROP_TYPE_TH1D
Definition: DQMNet.h:33
void setEntries(double nentries)
set # of entries
uint32_t flags(void) const
Get the object flags.
const std::string getFullname(void) const
get full name of ME including Pathname
const std::string & getStringValue(void) const
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
void Fill(unsigned int x)
void Fill(char x)
std::string objname
Definition: DQMNet.h:106
std::string valueString(void) const
TH2D * getRefTH2D(void) const
DQMNet::CoreObject data_
TAxis * getAxis(const char *func, int axis) const
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
tuple tags
Definition: o2o.py:248
void markToDelete(void)
void Fill(long x)
double getRMSError(int axis=1) const
get RMS uncertainty of histogram along x, y or z axis(axis=1,2,3 respectively)
std::vector< uint32_t > TagList
Definition: DQMNet.h:84
TObject * getRootObject(void) const
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
void Fill(unsigned long x)
bool isEfficiency(void) const
std::vector< QReport * > getQOthers(void) const
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
int64_t getIntValue(void) const
TH1F * getTH1F(void) const
void setResetMe(bool)
std::string tagString(void) const
string const
Definition: compareJSON.py:14
bool hasOtherReport(void) const
true if at least of one of the tests returned some other (non-ok) status
TProfile * getRefTProfile(void) const
void copyFunctions(TH1 *from, TH1 *to)
bool resetMe(void) const
true if ME should be reset at end of monitoring cycle
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)
static bool setOrder(const CoreObject &a, const CoreObject &b)
Definition: DQMNet.h:179
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
static const uint32_t DQM_PROP_TYPE_TH2S
Definition: DQMNet.h:35
int getNbinsX(void) const
get # of bins in X-axis
void Fill(unsigned char x)
const uint32_t run(void) const
void setEfficiencyFlag(void)
static const uint32_t DQM_PROP_TYPE_STRING
Definition: DQMNet.h:30
static const uint32_t DQM_PROP_NEW
Definition: DQMNet.h:58
Definition: DDAxes.h:10
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
static const uint32_t DQM_PROP_TYPE_MASK
Definition: DQMNet.h:25
TH2F * getTH2F(void) const
long double T
uint32_t streamId
Definition: DQMNet.h:103
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
static const uint32_t DQM_PROP_LUMI
Definition: DQMNet.h:60
void setBinEntries(int bin, double nentries)
set # of bin entries (to be used for profiles)
TH1S * getRefTH1S(void) const
static const uint32_t DQM_PROP_TYPE_REAL
Definition: DQMNet.h:29
SurfaceDeformation * create(int type, const std::vector< double > &params)
void addQReport(const DQMNet::QValue &desc, QCriterion *qc)
Add quality report, from DQMStore.
static const uint32_t DQM_PROP_TYPE_INVALID
Definition: DQMNet.h:27
static const uint32_t DQM_PROP_TYPE_TPROF2D
Definition: DQMNet.h:41
double getYmin(void) const
get min Y value (for profiles)
static const uint32_t DQM_PROP_TYPE_TH2F
Definition: DQMNet.h:34
TH1D * getRefTH1D(void) const
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Check the consistency of the axis labels.