CMS 3D CMS Logo

DQMStore.h
Go to the documentation of this file.
1 #ifndef DQMServices_Core_DQMStore_h
2 #define DQMServices_Core_DQMStore_h
3 
4 #if __GNUC__ && ! defined DQM_DEPRECATED
5 #define DQM_DEPRECATED __attribute__((deprecated))
6 #endif
7 
8 #include <cassert>
9 #include <cstdio>
10 #include <cstdlib>
11 #include <iosfwd>
12 #include <list>
13 #include <map>
14 #include <mutex>
15 #include <set>
16 #include <string>
17 #include <thread>
18 #include <vector>
19 #include <cxxabi.h>
20 #include <execinfo.h>
21 
22 #include <classlib/utils/Regexp.h>
23 
26 
27 namespace edm { class DQMHttpSource; class ParameterSet; class ActivityRegistry; class GlobalContext; }
28 namespace lat { class Regexp; }
29 namespace dqmstorepb {class ROOTFilePB; class ROOTFilePB_Histo;}
30 
31 class MonitorElement;
32 class QCriterion;
33 class TFile;
34 class TBufferFile;
35 class TObject;
36 class TH1;
37 class TObjString;
38 class TH1F;
39 class TH1S;
40 class TH1D;
41 class TH2F;
42 class TH2S;
43 class TH2D;
44 class TH3F;
45 class TProfile;
46 class TProfile2D;
47 class TNamed;
48 
49 
54 class fastmatch
55 {
56  private:
57  enum MatchingHeuristicEnum { UseFull, OneStarStart, OneStarEnd, TwoStar };
58 
59  public:
60  fastmatch (std::string _fastString);
61  ~fastmatch();
62 
63  bool match (std::string const& s) const;
64 
65  private:
66  // checks if two strings are equal, starting at the back of the strings
67  bool compare_strings_reverse (std::string const& pattern,
68  std::string const& input) const;
69  // checks if two strings are equal, starting at the front of the strings
70  bool compare_strings (std::string const& pattern,
71  std::string const& input) const;
72 
73  lat::Regexp * regexp_;
76 };
77 
78 class DQMStore
79 {
80  public:
82  {
85  SaveWithReferenceForQTest
86  };
88  {
90  StripRunDirs
91  };
92 
93  class IBooker
94  {
95  public:
96  friend class DQMStore;
97 
98  // for the supported syntaxes, see the declarations of DQMStore::bookString
99  template <typename... Args>
100  MonitorElement * bookString(Args && ... args) {
101  return owner_->bookString(std::forward<Args>(args)...);
102  }
103 
104  // for the supported syntaxes, see the declarations of DQMStore::bookInt
105  template <typename... Args>
106  MonitorElement * bookInt(Args && ... args) {
107  return owner_->bookInt(std::forward<Args>(args)...);
108  }
109 
110  // for the supported syntaxes, see the declarations of DQMStore::bookFloat
111  template <typename... Args>
112  MonitorElement * bookFloat(Args && ... args) {
113  return owner_->bookFloat(std::forward<Args>(args)...);
114  }
115 
116  // for the supported syntaxes, see the declarations of DQMStore::book1D
117  template <typename... Args>
118  MonitorElement * book1D(Args && ... args) {
119  return owner_->book1D(std::forward<Args>(args)...);
120  }
121 
122  // for the supported syntaxes, see the declarations of DQMStore::book1S
123  template <typename... Args>
124  MonitorElement * book1S(Args && ... args) {
125  return owner_->book1S(std::forward<Args>(args)...);
126  }
127 
128  // for the supported syntaxes, see the declarations of DQMStore::book1DD
129  template <typename... Args>
130  MonitorElement * book1DD(Args && ... args) {
131  return owner_->book1DD(std::forward<Args>(args)...);
132  }
133 
134  // for the supported syntaxes, see the declarations of DQMStore::book2D
135  template <typename... Args>
136  MonitorElement * book2D(Args && ... args) {
137  return owner_->book2D(std::forward<Args>(args)...);
138  }
139 
140  // for the supported syntaxes, see the declarations of DQMStore::book2S
141  template <typename... Args>
142  MonitorElement * book2S(Args && ... args) {
143  return owner_->book2S(std::forward<Args>(args)...);
144  }
145 
146  // for the supported syntaxes, see the declarations of DQMStore::book2DD
147  template <typename... Args>
148  MonitorElement * book2DD(Args && ... args) {
149  return owner_->book2DD(std::forward<Args>(args)...);
150  }
151 
152  // for the supported syntaxes, see the declarations of DQMStore::book3D
153  template <typename... Args>
154  MonitorElement * book3D(Args && ... args) {
155  return owner_->book3D(std::forward<Args>(args)...);
156  }
157 
158  // for the supported syntaxes, see the declarations of DQMStore::bookProfile
159  template <typename... Args>
160  MonitorElement * bookProfile(Args && ... args) {
161  return owner_->bookProfile(std::forward<Args>(args)...);
162  }
163 
164  // for the supported syntaxes, see the declarations of DQMStore::bookProfile2D
165  template <typename... Args>
167  return owner_->bookProfile2D(std::forward<Args>(args)...);
168  }
169 
170  void cd();
171  void cd(const std::string &dir);
172  void setCurrentFolder(const std::string &fullpath);
173  void goUp();
174  const std::string & pwd();
175  void tag(MonitorElement *, unsigned int);
176  void tagContents(const std::string &, unsigned int);
177 
178  private:
179  explicit IBooker(DQMStore * store):owner_(nullptr) {
180  assert(store);
181  owner_ = store;
182  }
183 
184  public:
185  IBooker() = delete;
186  IBooker(const IBooker&) = delete;
187 
188  private:
189  // Embedded classes do not natively own a pointer to the embedding
190  // class. We therefore need to store a pointer to the main
191  // DQMStore instance (owner_).
193  }; // IBooker
194 
195  class ConcurrentBooker : public IBooker
196  {
197  public:
198  friend class DQMStore;
199 
200  // for the supported syntaxes, see the declarations of DQMStore::bookString
201  template <typename... Args>
203  MonitorElement* me = IBooker::bookString(std::forward<Args>(args)...);
204  return ConcurrentMonitorElement(me);
205  }
206 
207  // for the supported syntaxes, see the declarations of DQMStore::bookInt
208  template <typename... Args>
210  MonitorElement* me = IBooker::bookInt(std::forward<Args>(args)...);
211  return ConcurrentMonitorElement(me);
212  }
213 
214  // for the supported syntaxes, see the declarations of DQMStore::bookFloat
215  template <typename... Args>
217  MonitorElement* me = IBooker::bookFloat(std::forward<Args>(args)...);
218  return ConcurrentMonitorElement(me);
219  }
220 
221  // for the supported syntaxes, see the declarations of DQMStore::book1D
222  template <typename... Args>
224  MonitorElement* me = IBooker::book1D(std::forward<Args>(args)...);
225  return ConcurrentMonitorElement(me);
226  }
227 
228  // for the supported syntaxes, see the declarations of DQMStore::book1S
229  template <typename... Args>
231  MonitorElement* me = IBooker::book1S(std::forward<Args>(args)...);
232  return ConcurrentMonitorElement(me);
233  }
234 
235  // for the supported syntaxes, see the declarations of DQMStore::book1DD
236  template <typename... Args>
238  MonitorElement* me = IBooker::book1DD(std::forward<Args>(args)...);
239  return ConcurrentMonitorElement(me);
240  }
241 
242  // for the supported syntaxes, see the declarations of DQMStore::book2D
243  template <typename... Args>
245  MonitorElement* me = IBooker::book2D(std::forward<Args>(args)...);
246  return ConcurrentMonitorElement(me);
247  }
248 
249  // for the supported syntaxes, see the declarations of DQMStore::book2S
250  template <typename... Args>
252  MonitorElement* me = IBooker::book2S(std::forward<Args>(args)...);
253  return ConcurrentMonitorElement(me);
254  }
255 
256  // for the supported syntaxes, see the declarations of DQMStore::book2DD
257  template <typename... Args>
259  MonitorElement* me = IBooker::book2DD(std::forward<Args>(args)...);
260  return ConcurrentMonitorElement(me);
261  }
262 
263  // for the supported syntaxes, see the declarations of DQMStore::book3D
264  template <typename... Args>
266  MonitorElement* me = IBooker::book3D(std::forward<Args>(args)...);
267  return ConcurrentMonitorElement(me);
268  }
269 
270  // for the supported syntaxes, see the declarations of DQMStore::bookProfile
271  template <typename... Args>
273  MonitorElement* me = IBooker::bookProfile(std::forward<Args>(args)...);
274  return ConcurrentMonitorElement(me);
275  }
276 
277  // for the supported syntaxes, see the declarations of DQMStore::bookProfile2D
278  template <typename... Args>
280  MonitorElement* me = IBooker::bookProfile2D(std::forward<Args>(args)...);
281  return ConcurrentMonitorElement(me);
282  }
283 
284  private:
285  explicit ConcurrentBooker(DQMStore * store) :
286  IBooker(store)
287  { }
288 
289  ConcurrentBooker() = delete;
290  ConcurrentBooker(ConcurrentBooker const&) = delete;
291  ConcurrentBooker(ConcurrentBooker &&) = delete;
292  ConcurrentBooker& operator= (ConcurrentBooker const&) = delete;
294 
295  ~ConcurrentBooker() = default;
296  };
297 
298  class IGetter
299  {
300  public:
301  friend class DQMStore;
302 
303  // for the supported syntaxes, see the declarations of DQMStore::getContents
304  template <typename... Args>
305  std::vector<MonitorElement *> getContents(Args && ... args) {
306  return owner_->getContents(std::forward<Args>(args)...);
307  }
308  // for the supported syntaxes, see the declarations of DQMStore::removeElements
309  template <typename... Args>
310  void removeElement(Args && ... args) {
311  return owner_->removeElement(std::forward<Args>(args)...);
312  }
313 
314  std::vector<MonitorElement*> getAllContents(const std::string &path,
315  uint32_t runNumber = 0,
316  uint32_t lumi = 0);
317  MonitorElement * get(const std::string &path);
318 
319  // same as get, throws an exception if histogram not found
320  MonitorElement * getElement(const std::string &path);
321 
322  std::vector<std::string> getSubdirs();
323  std::vector<std::string> getMEs();
324  bool containsAnyMonitorable(const std::string &path);
325  bool dirExists(const std::string &path);
326  void cd();
327  void cd(const std::string &dir);
328  void setCurrentFolder(const std::string &fullpath);
329 
330  private:
331  explicit IGetter(DQMStore * store):owner_(nullptr) {
332  assert(store);
333  owner_ = store;
334  }
335 
336  public:
337  IGetter() = delete;
338  IGetter(const IGetter&) = delete;
339 
340  private:
341  // Embedded classes do not natively own a pointer to the embedding
342  // class. We therefore need to store a pointer to the main
343  // DQMStore instance (owner_).
345  }; //IGetter
346 
347  // Template function to be used inside each DQM Modules' lambda
348  // functions to book MonitorElements into the DQMStore. The function
349  // calls whatever user-supplied code via the function f. The latter
350  // is passed the instance of the IBooker class (owned by the *only*
351  // DQMStore instance), that is capable of booking MonitorElements
352  // into the DQMStore via a public API. The central mutex is acquired
353  // *before* invoking and automatically released upon returns.
354  template <typename iFunc>
355  void bookTransaction(iFunc f, uint32_t run, uint32_t moduleId) {
356  std::lock_guard<std::mutex> guard(book_mutex_);
357  /* Set the run number and module id only if multithreading is enabled */
358  if (enableMultiThread_) {
359  run_ = run;
360  moduleId_ = moduleId;
361  }
362  f(*ibooker_);
363 
364  /* Reset the run number and module id only if multithreading is enabled */
365  if (enableMultiThread_) {
366  run_ = 0;
367  moduleId_ = 0;
368  }
369  }
370 
371  // Similar function used to book "global" histograms via the
372  // ConcurrentMonitorElement interface.
373  template <typename iFunc>
374  void bookConcurrentTransaction(iFunc f, uint32_t run) {
375  std::lock_guard<std::mutex> guard(book_mutex_);
376  /* Set the run_ member only if enableMultiThread is enabled */
377  if (enableMultiThread_) {
378  run_ = run;
379  }
380  ConcurrentBooker booker(this);
381  f(booker);
382 
383  /* Reset the run_ member only if enableMultiThread is enabled */
384  if (enableMultiThread_) {
385  run_ = 0;
386  }
387  }
388 
389  // Signature needed in the harvesting where the booking is done
390  // in the endJob. No handles to the run there. Two arguments ensure
391  // the capability of booking and getting. The method relies on the
392  // initialization of run, stream and module ID to 0. The mutex
393  // is not needed.
394  template <typename iFunc>
395  void meBookerGetter(iFunc f) {
396  f(*ibooker_, *igetter_);
397  }
398 
399  //-------------------------------------------------------------------------
400  // ---------------------- Constructors ------------------------------------
402  DQMStore(const edm::ParameterSet &pset);
403  ~DQMStore();
404 
405  //-------------------------------------------------------------------------
406  void setVerbose(unsigned level);
407 
408  // ---------------------- public navigation -------------------------------
409  const std::string & pwd() const;
410  void cd();
411  void cd(const std::string &subdir);
412  void setCurrentFolder(const std::string &fullpath);
413  void goUp();
414 
415  bool dirExists(const std::string &path) const;
416 
417  //-------------------------------------------------------------------------
418  // ---------------------- public ME booking -------------------------------
419 
420  MonitorElement * bookInt (const char *name);
421  MonitorElement * bookInt (const std::string &name);
422 
423  MonitorElement * bookFloat (const char *name);
424  MonitorElement * bookFloat (const std::string &name);
425 
426  MonitorElement * bookString (const char *name,
427  const char *value);
428  MonitorElement * bookString (const std::string &name,
429  const std::string &value);
430 
431  MonitorElement * book1D (const char *name,
432  const char *title,
433  int nchX, double lowX, double highX);
434  MonitorElement * book1D (const std::string &name,
435  const std::string &title,
436  int nchX, double lowX, double highX);
437  MonitorElement * book1D (const char *name,
438  const char *title,
439  int nchX, const float *xbinsize);
440  MonitorElement * book1D (const std::string &name,
441  const std::string &title,
442  int nchX, const float *xbinsize);
443  MonitorElement * book1D (const char *name, TH1F *h);
444  MonitorElement * book1D (const std::string &name, TH1F *h);
445 
446  MonitorElement * book1S (const char *name,
447  const char *title,
448  int nchX, double lowX, double highX);
449  MonitorElement * book1S (const std::string &name,
450  const std::string &title,
451  int nchX, double lowX, double highX);
452  MonitorElement * book1S (const char *name,
453  const char *title,
454  int nchX, const float *xbinsize);
455  MonitorElement * book1S (const std::string &name,
456  const std::string &title,
457  int nchX, const float *xbinsize);
458  MonitorElement * book1S (const char *name, TH1S *h);
459  MonitorElement * book1S (const std::string &name, TH1S *h);
460 
461  MonitorElement * book1DD (const char *name,
462  const char *title,
463  int nchX, double lowX, double highX);
464  MonitorElement * book1DD (const std::string &name,
465  const std::string &title,
466  int nchX, double lowX, double highX);
467  MonitorElement * book1DD (const char *name,
468  const char *title,
469  int nchX, const float *xbinsize);
470  MonitorElement * book1DD (const std::string &name,
471  const std::string &title,
472  int nchX, const float *xbinsize);
473  MonitorElement * book1DD (const char *name, TH1D *h);
474  MonitorElement * book1DD (const std::string &name, TH1D *h);
475 
476  MonitorElement * book2D (const char *name,
477  const char *title,
478  int nchX, double lowX, double highX,
479  int nchY, double lowY, double highY);
480  MonitorElement * book2D (const std::string &name,
481  const std::string &title,
482  int nchX, double lowX, double highX,
483  int nchY, double lowY, double highY);
484  MonitorElement * book2D (const char *name,
485  const char *title,
486  int nchX, const float *xbinsize,
487  int nchY, const float *ybinsize);
488  MonitorElement * book2D (const std::string &name,
489  const std::string &title,
490  int nchX, const float *xbinsize,
491  int nchY, const float *ybinsize);
492  MonitorElement * book2D (const char *name, TH2F *h);
493  MonitorElement * book2D (const std::string &name, TH2F *h);
494 
495  MonitorElement * book2S (const char *name,
496  const char *title,
497  int nchX, double lowX, double highX,
498  int nchY, double lowY, double highY);
499  MonitorElement * book2S (const std::string &name,
500  const std::string &title,
501  int nchX, double lowX, double highX,
502  int nchY, double lowY, double highY);
503  MonitorElement * book2S (const char *name,
504  const char *title,
505  int nchX, const float *xbinsize,
506  int nchY, const float *ybinsize);
507  MonitorElement * book2S (const std::string &name,
508  const std::string &title,
509  int nchX, const float *xbinsize,
510  int nchY, const float *ybinsize);
511  MonitorElement * book2S (const char *name, TH2S *h);
512  MonitorElement * book2S (const std::string &name, TH2S *h);
513 
514  MonitorElement * book2DD (const char *name,
515  const char *title,
516  int nchX, double lowX, double highX,
517  int nchY, double lowY, double highY);
518  MonitorElement * book2DD (const std::string &name,
519  const std::string &title,
520  int nchX, double lowX, double highX,
521  int nchY, double lowY, double highY);
522  MonitorElement * book2DD (const char *name,
523  const char *title,
524  int nchX, const float *xbinsize,
525  int nchY, const float *ybinsize);
526  MonitorElement * book2DD (const std::string &name,
527  const std::string &title,
528  int nchX, const float *xbinsize,
529  int nchY, const float *ybinsize);
530  MonitorElement * book2DD (const char *name, TH2D *h);
531  MonitorElement * book2DD (const std::string &name, TH2D *h);
532 
533  MonitorElement * book3D (const char *name,
534  const char *title,
535  int nchX, double lowX, double highX,
536  int nchY, double lowY, double highY,
537  int nchZ, double lowZ, double highZ);
538  MonitorElement * book3D (const std::string &name,
539  const std::string &title,
540  int nchX, double lowX, double highX,
541  int nchY, double lowY, double highY,
542  int nchZ, double lowZ, double highZ);
543  MonitorElement * book3D (const char *name, TH3F *h);
544  MonitorElement * book3D (const std::string &name, TH3F *h);
545 
546  MonitorElement * bookProfile (const char *name,
547  const char *title,
548  int nchX, double lowX, double highX,
549  int nchY, double lowY, double highY,
550  const char *option = "s");
551  MonitorElement * bookProfile (const std::string &name,
552  const std::string &title,
553  int nchX, double lowX, double highX,
554  int nchY, double lowY, double highY,
555  const char *option = "s");
556  MonitorElement * bookProfile (const char *name,
557  const char *title,
558  int nchX, double lowX, double highX,
559  double lowY, double highY,
560  const char *option = "s");
561  MonitorElement * bookProfile (const std::string &name,
562  const std::string &title,
563  int nchX, double lowX, double highX,
564  double lowY, double highY,
565  const char *option = "s");
566  MonitorElement * bookProfile (const char *name,
567  const char *title,
568  int nchX, const double *xbinsize,
569  int nchY, double lowY, double highY,
570  const char *option = "s");
571  MonitorElement * bookProfile (const std::string &name,
572  const std::string &title,
573  int nchX, const double *xbinsize,
574  int nchY, double lowY, double highY,
575  const char *option = "s");
576  MonitorElement * bookProfile (const char *name,
577  const char *title,
578  int nchX, const double *xbinsize,
579  double lowY, double highY,
580  const char *option = "s");
581  MonitorElement * bookProfile (const std::string &name,
582  const std::string &title,
583  int nchX, const double *xbinsize,
584  double lowY, double highY,
585  const char *option = "s");
586  MonitorElement * bookProfile (const char *name, TProfile *h);
587  MonitorElement * bookProfile (const std::string &name, TProfile *h);
588 
589  MonitorElement * bookProfile2D(const char *name,
590  const char *title,
591  int nchX, double lowX, double highX,
592  int nchY, double lowY, double highY,
593  int nchZ, double lowZ, double highZ,
594  const char *option = "s");
596  const std::string &title,
597  int nchX, double lowX, double highX,
598  int nchY, double lowY, double highY,
599  int nchZ, double lowZ, double highZ,
600  const char *option = "s");
601  MonitorElement * bookProfile2D(const char *name,
602  const char *title,
603  int nchX, double lowX, double highX,
604  int nchY, double lowY, double highY,
605  double lowZ, double highZ,
606  const char *option = "s");
608  const std::string &title,
609  int nchX, double lowX, double highX,
610  int nchY, double lowY, double highY,
611  double lowZ, double highZ,
612  const char *option = "s");
613  MonitorElement * bookProfile2D(const char *name, TProfile2D *h);
614  MonitorElement * bookProfile2D(const std::string &name, TProfile2D *h);
615 
616  //-------------------------------------------------------------------------
617  // ---------------------- public tagging ----------------------------------
618  void tag(MonitorElement *me, unsigned int myTag);
619  void tag(const std::string &path, unsigned int myTag);
620  void tagContents(const std::string &path, unsigned int myTag);
621  void tagAllContents(const std::string &path, unsigned int myTag);
622 
623  //-------------------------------------------------------------------------
624  // ---------------------- public ME getters -------------------------------
625  std::vector<std::string> getSubdirs() const;
626  std::vector<std::string> getMEs() const;
627  bool containsAnyMonitorable(const std::string &path) const;
628 
629  MonitorElement * get(const std::string &path) const;
630  std::vector<MonitorElement *> get(unsigned int tag) const;
631  std::vector<MonitorElement *> getContents(const std::string &path) const;
632  std::vector<MonitorElement *> getContents(const std::string &path, unsigned int tag) const;
633  void getContents(std::vector<std::string> &into, bool showContents = true) const;
634 
635  // ---------------------- softReset methods -------------------------------
636  void softReset(MonitorElement *me);
638 
639  // ---------------------- Public deleting ---------------------------------
640  void rmdir(const std::string &fullpath);
641  void removeContents();
642  void removeContents(const std::string &dir);
643  void removeElement(const std::string &name);
644  void removeElement(const std::string &dir, const std::string &name, bool warning = true);
645 
646  // ------------------------------------------------------------------------
647  // ---------------------- public I/O --------------------------------------
648  void save(const std::string &filename,
649  const std::string &path = "",
650  const std::string &pattern = "",
651  const std::string &rewrite = "",
652  const uint32_t run = 0,
653  const uint32_t lumi = 0,
656  const std::string &fileupdate = "RECREATE");
657  void savePB(const std::string &filename,
658  const std::string &path = "",
659  const uint32_t run = 0,
660  const uint32_t lumi = 0);
661  bool open(const std::string &filename,
662  bool overwrite = false,
663  const std::string &path ="",
664  const std::string &prepend = "",
665  OpenRunDirs stripdirs = KeepRunDirs,
666  bool fileMustExist = true);
667  bool load(const std::string &filename,
668  OpenRunDirs stripdirs = StripRunDirs,
669  bool fileMustExist = true);
670  bool mtEnabled() { return enableMultiThread_; };
671 
672 
673  public:
674  // -------------------------------------------------------------------------
675  // ---------------------- Public print methods -----------------------------
676  void showDirStructure() const;
677 
678  // ---------------------- Public check options -----------------------------
679  bool isCollate() const;
680 
681  // -------------------------------------------------------------------------
682  // ---------------------- Quality Test methods -----------------------------
683  QCriterion * getQCriterion(const std::string &qtname) const;
684  QCriterion * createQTest(const std::string &algoname, const std::string &qtname);
685  void useQTest(const std::string &dir, const std::string &qtname);
686  int useQTestByMatch(const std::string &pattern, const std::string &qtname);
687  void runQTests();
688  int getStatus(const std::string &path = "") const;
689  void scaleElements();
690 
691  private:
692  // ---------------- Navigation -----------------------
693  bool cdInto(const std::string &path) const;
694 
695  // ------------------- Reference ME -------------------------------
696  bool isCollateME(MonitorElement *me) const;
697 
698  // ------------------- Private "getters" ------------------------------
699  bool readFilePB(const std::string &filename,
700  bool overwrite = false,
701  const std::string &path ="",
702  const std::string &prepend = "",
703  OpenRunDirs stripdirs = StripRunDirs,
704  bool fileMustExist = true);
705  bool readFile(const std::string &filename,
706  bool overwrite = false,
707  const std::string &path ="",
708  const std::string &prepend = "",
709  OpenRunDirs stripdirs = StripRunDirs,
710  bool fileMustExist = true);
711  void makeDirectory(const std::string &path);
712  unsigned int readDirectory(TFile *file,
713  bool overwrite,
714  const std::string &path,
715  const std::string &prepend,
716  const std::string &curdir,
717  OpenRunDirs stripdirs);
718 
720  const std::string &name,
721  const uint32_t run = 0,
722  const uint32_t lumi = 0,
723  const uint32_t moduleId = 0) const;
724 
727  std::string & objname,
728  TObject ** obj);
729 
730  public:
731  std::vector<MonitorElement*> getAllContents(const std::string &path,
732  uint32_t runNumber = 0,
733  uint32_t lumi = 0) const;
734  std::vector<MonitorElement*> getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType = lat::Regexp::Wildcard) const;
735 
736  // lumisection based histograms manipulations
737  void cloneLumiHistograms(uint32_t run, uint32_t lumi, uint32_t moduleId);
738  void cloneRunHistograms(uint32_t run, uint32_t moduleId);
739 
740  void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi);
741 
742  private:
743  // ---------------- Miscellaneous -----------------------------
744  void initializeFrom(const edm::ParameterSet&);
745  void reset();
746  void forceReset();
748 
749  bool extract(TObject *obj, const std::string &dir, bool overwrite, bool collateHistograms);
750  TObject * extractNextObject(TBufferFile&) const;
751 
752  // ---------------------- Booking ------------------------------------
754  MonitorElement * book_(const std::string &dir,
755  const std::string &name,
756  const char *context);
757  template <class HISTO, class COLLATE>
758  MonitorElement * book_(const std::string &dir,
759  const std::string &name,
760  const char *context,
761  int kind, HISTO *h, COLLATE collate);
762 
763  MonitorElement * bookInt_(const std::string &dir, const std::string &name);
764  MonitorElement * bookFloat_(const std::string &dir, const std::string &name);
765  MonitorElement * bookString_(const std::string &dir, const std::string &name, const std::string &value);
766  MonitorElement * book1D_(const std::string &dir, const std::string &name, TH1F *h);
767  MonitorElement * book1S_(const std::string &dir, const std::string &name, TH1S *h);
768  MonitorElement * book1DD_(const std::string &dir, const std::string &name, TH1D *h);
769  MonitorElement * book2D_(const std::string &dir, const std::string &name, TH2F *h);
770  MonitorElement * book2S_(const std::string &dir, const std::string &name, TH2S *h);
771  MonitorElement * book2DD_(const std::string &dir, const std::string &name, TH2D *h);
772  MonitorElement * book3D_(const std::string &dir, const std::string &name, TH3F *h);
773  MonitorElement * bookProfile_(const std::string &dir, const std::string &name, TProfile *h);
774  MonitorElement * bookProfile2D_(const std::string &dir, const std::string &name, TProfile2D *h);
775 
776  static bool checkBinningMatches(MonitorElement *me, TH1 *h, unsigned verbose);
777 
778  static void collate1D(MonitorElement *me, TH1F *h, unsigned verbose);
779  static void collate1S(MonitorElement *me, TH1S *h, unsigned verbose);
780  static void collate1DD(MonitorElement *me, TH1D *h, unsigned verbose);
781  static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose);
782  static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose);
783  static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose);
784  static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose);
785  static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose);
786  static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose);
787 
788  // --- Operations on MEs that are normally reset at end of monitoring cycle ---
789  void setAccumulate(MonitorElement *me, bool flag);
790 
791  void print_trace(const std::string &dir, const std::string &name);
792 
793  // ----------------------- Unavailable ---------------------------------------
794  DQMStore(const DQMStore&);
795  const DQMStore& operator=(const DQMStore&);
796 
797  //-------------------------------------------------------------------------------
798  //-------------------------------------------------------------------------------
799  using QTestSpec = std::pair<fastmatch *, QCriterion *>;
800  using QTestSpecs = std::list<QTestSpec>;
801  using MEMap = std::set<MonitorElement>;
802  using QCMap = std::map<std::string, QCriterion *>;
803  using QAMap = std::map<std::string, QCriterion *(*)(const std::string &)>;
804 
805 
806  // ------------------------ private I/O helpers ------------------------------
808  MonitorElement const& me,
809  dqmstorepb::ROOTFilePB & file);
811  std::string const& dir,
812  unsigned int run,
813  MEMap::const_iterator begin,
814  MEMap::const_iterator end,
815  dqmstorepb::ROOTFilePB & file,
816  unsigned int & counter);
818  MonitorElement const& me,
819  TFile & file);
821  std::string const& dir,
822  std::string const& refpath,
823  SaveReferenceTag ref,
824  int minStatus,
825  unsigned int run,
826  MEMap::const_iterator begin,
827  MEMap::const_iterator end,
828  TFile & file,
829  unsigned int & counter);
830 
831  unsigned verbose_;
832  unsigned verboseQT_;
833  bool reset_;
834  double scaleFlag_;
840  uint32_t run_;
841  uint32_t moduleId_;
842  std::ofstream * stream_;
843 
846  std::set<std::string> dirs_;
847 
851 
855 
856  friend class edm::DQMHttpSource;
857  friend class DQMService;
858  friend class DQMNet;
859  friend class DQMArchiver;
860  friend class DQMStoreExample; // for get{All,Matching}Contents -- sole user of this method!
861  friend class DQMRootOutputModule;
862  friend class DQMRootSource;
863  friend class DQMFileSaver;
864  friend class MEtoEDMConverter;
865 };
866 
867 #endif // DQMServices_Core_DQMStore_h
ConcurrentMonitorElement book1DD(Args &&...args)
Definition: DQMStore.h:237
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:3264
~DQMStore()
Definition: DQMStore.cc:411
IGetter * igetter_
Definition: DQMStore.h:854
MonitorElement * book2DD_(const std::string &dir, const std::string &name, TH2D *h)
Book 2D histogram based on TH2D.
Definition: DQMStore.cc:1003
std::vector< MonitorElement * > getContents(Args &&...args)
Definition: DQMStore.h:305
static boost::mutex mutex
Definition: Proxy.cc:11
def dirExists(dir)
ConcurrentMonitorElement bookProfile(Args &&...args)
Definition: DQMStore.h:272
MonitorElement * book1S(Args &&...args)
Definition: DQMStore.h:124
MonitorElement * book2S(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2S histogram.
Definition: DQMStore.cc:1032
bool containsAnyMonitorable(const std::string &path) const
Definition: DQMStore.cc:1645
bool isCollateME(MonitorElement *me) const
Definition: DQMStore.cc:3457
std::map< std::string, QCriterion * > QCMap
Definition: DQMStore.h:802
bool cdInto(const std::string &path) const
Definition: DQMStore.cc:2396
ConcurrentMonitorElement book2DD(Args &&...args)
Definition: DQMStore.h:258
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:3370
ConcurrentMonitorElement book3D(Args &&...args)
Definition: DQMStore.h:265
MonitorElement * bookProfile2D_(const std::string &dir, const std::string &name, TProfile2D *h)
Book 2D profile histogram based on TProfile2D.
Definition: DQMStore.cc:1348
static void get_info(const dqmstorepb::ROOTFilePB::Histo &h, std::string &dirname, std::string &objname, TObject **obj)
Definition: fastHadd.cc:189
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:882
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:3196
static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose)
Definition: DQMStore.cc:1510
bool readFile(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=StripRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:3031
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose)
Definition: DQMStore.cc:1517
TObject * extractNextObject(TBufferFile &buf)
Definition: fastHadd.cc:181
ConcurrentMonitorElement bookProfile2D(Args &&...args)
Definition: DQMStore.h:279
MonitorElement * book3D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ)
Book 3D histogram.
Definition: DQMStore.cc:1163
MatchingHeuristicEnum
Definition: DQMStore.h:57
void scaleElements()
Definition: DQMStore.cc:3465
Definition: DQMNet.h:23
void postGlobalBeginLumi(const edm::GlobalContext &)
Definition: DQMStore.cc:1944
MonitorElement * book2DD(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D double histogram.
Definition: DQMStore.cc:1054
std::pair< fastmatch *, QCriterion * > QTestSpec
Definition: DQMStore.h:799
static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose)
Definition: DQMStore.cc:1503
MonitorElement * bookInt(Args &&...args)
Definition: DQMStore.h:106
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
Definition: DQMStore.cc:1859
MonitorElement * bookString(Args &&...args)
Definition: DQMStore.h:100
MatchingHeuristicEnum matching_
Definition: DQMStore.h:75
ConcurrentBooker(DQMStore *store)
Definition: DQMStore.h:285
bool reset_
Definition: DQMStore.h:833
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:914
void initializeFrom(const edm::ParameterSet &)
Definition: DQMStore.cc:425
#define nullptr
OpenRunDirs
Definition: DQMStore.h:87
std::set< MonitorElement > MEMap
Definition: DQMStore.h:801
Definition: DQMStore.h:28
uint32_t moduleId_
Definition: DQMStore.h:841
QCMap qtests_
Definition: DQMStore.h:848
void forceReset()
Definition: DQMStore.cc:1919
std::mutex book_mutex_
Definition: DQMStore.h:852
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:819
static std::string const input
Definition: EdmProvDump.cc:44
SaveReferenceTag
Definition: DQMStore.h:81
ConcurrentMonitorElement bookInt(Args &&...args)
Definition: DQMStore.h:209
std::list< QTestSpec > QTestSpecs
Definition: DQMStore.h:800
MonitorElement * book2D_(const std::string &dir, const std::string &name, TH2F *h)
Book 2D histogram based on TH2F.
Definition: DQMStore.cc:989
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:3409
void saveMonitorElementRangeToROOT(std::string const &dir, std::string const &refpath, SaveReferenceTag ref, int minStatus, unsigned int run, MEMap::const_iterator begin, MEMap::const_iterator end, TFile &file, unsigned int &counter)
Definition: DQMStore.cc:2470
void saveMonitorElementToROOT(MonitorElement const &me, TFile &file)
Definition: DQMStore.cc:2439
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1812
unsigned verboseQT_
Definition: DQMStore.h:832
QTestSpecs qtestspecs_
Definition: DQMStore.h:850
double scaleFlag_
Definition: DQMStore.h:834
void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi)
Definition: DQMStore.cc:2053
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:848
bool isCollate() const
Definition: DQMStore.cc:3448
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:166
ConcurrentMonitorElement book2D(Args &&...args)
Definition: DQMStore.h:244
MonitorElement * bookString_(const std::string &dir, const std::string &name, const std::string &value)
Book string.
Definition: DQMStore.cc:832
void removeElement(const std::string &name)
Definition: DQMStore.cc:3238
MonitorElement * book3D_(const std::string &dir, const std::string &name, TH3F *h)
Book 3D histogram based on TH3F.
Definition: DQMStore.cc:1156
static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose)
Definition: DQMStore.cc:1527
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
std::map< std::string, QCriterion *(*)(const std::string &)> QAMap
Definition: DQMStore.h:803
ConcurrentMonitorElement book1D(Args &&...args)
Definition: DQMStore.h:223
void saveMonitorElementRangeToPB(std::string const &dir, unsigned int run, MEMap::const_iterator begin, MEMap::const_iterator end, dqmstorepb::ROOTFilePB &file, unsigned int &counter)
Definition: DQMStore.cc:2698
MonitorElement * bookInt_(const std::string &dir, const std::string &name)
Book int.
Definition: DQMStore.cc:772
MonitorElement * book2S(Args &&...args)
Definition: DQMStore.h:142
MonitorElement * bookProfile_(const std::string &dir, const std::string &name, TProfile *h)
Book profile histogram based on TProfile.
Definition: DQMStore.cc:1204
double f[11][100]
uint32_t run_
Definition: DQMStore.h:840
ConcurrentMonitorElement bookString(Args &&...args)
Definition: DQMStore.h:202
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1215
#define end
Definition: vmac.h:39
void setVerbose(unsigned level)
Definition: DQMStore.cc:552
Definition: value.py:1
void softReset(MonitorElement *me)
Definition: DQMStore.cc:3401
std::string pwd_
Definition: DQMStore.h:844
lat::Regexp * regexp_
Definition: DQMStore.h:73
IBooker * ibooker_
Definition: DQMStore.h:853
QAMap qalgos_
Definition: DQMStore.h:849
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1683
std::string readSelectedDirectory_
Definition: DQMStore.h:839
std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:1606
void bookConcurrentTransaction(iFunc f, uint32_t run)
Definition: DQMStore.h:374
std::string fastString_
Definition: DQMStore.h:74
int extract(std::vector< int > *output, const std::string &dati)
MonitorElement * findObject(const std::string &dir, const std::string &name, const uint32_t run=0, const uint32_t lumi=0, const uint32_t moduleId=0) const
Definition: DQMStore.cc:1784
const DQMStore & operator=(const DQMStore &)
void saveMonitorElementToPB(MonitorElement const &me, dqmstorepb::ROOTFilePB &file)
Definition: DQMStore.cc:2669
static void collate1DD(MonitorElement *me, TH1D *h, unsigned verbose)
Definition: DQMStore.cc:1482
void tagAllContents(const std::string &path, unsigned int myTag)
Definition: DQMStore.cc:1584
ConcurrentMonitorElement bookFloat(Args &&...args)
Definition: DQMStore.h:216
void showDirStructure() const
Definition: DQMStore.cc:3428
MonitorElement * initialise(MonitorElement *me, const std::string &path)
void cd()
go to top directory (ie. root)
Definition: DQMStore.cc:565
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
unsigned verbose_
Definition: DQMStore.h:831
MonitorElement * book_(const std::string &dir, const std::string &name, const char *context)
Definition: DQMStore.cc:737
MonitorElement * book2S_(const std::string &dir, const std::string &name, TH2S *h)
Book 2D histogram based on TH2S.
Definition: DQMStore.cc:996
MEMap data_
Definition: DQMStore.h:845
def load(fileName)
Definition: svgfig.py:546
void print_trace(const std::string &dir, const std::string &name)
Definition: DQMStore.cc:487
MonitorElement * book1D_(const std::string &dir, const std::string &name, TH1F *h)
Book 1D histogram based on TH1F.
Definition: DQMStore.cc:861
int useQTestByMatch(const std::string &pattern, const std::string &qtname)
attach quality test <qc> to monitor elements matching <pattern>.
Definition: DQMStore.cc:3314
static void collate1D(MonitorElement *me, TH1F *h, unsigned verbose)
Definition: DQMStore.cc:1468
std::vector< std::string > getMEs() const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1629
MonitorElement * book1DD_(const std::string &dir, const std::string &name, TH1D *h)
Book 1D histogram based on TH1D.
Definition: DQMStore.cc:875
DQMStore * owner_
Definition: DQMStore.h:192
unsigned int readDirectory(TFile *file, bool overwrite, const std::string &path, const std::string &prepend, const std::string &curdir, OpenRunDirs stripdirs)
Definition: DQMStore.cc:2834
void removeContents()
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:3230
IBooker(DQMStore *store)
Definition: DQMStore.h:179
bool forceResetOnBeginLumi_
Definition: DQMStore.h:838
#define begin
Definition: vmac.h:32
HLT enums.
void tagContents(const std::string &path, unsigned int myTag)
tag all children of folder (does NOT include subfolders)
Definition: DQMStore.cc:1572
void cloneRunHistograms(uint32_t run, uint32_t moduleId)
Definition: DQMStore.cc:2015
bool readFilePB(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=StripRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:3115
void cloneLumiHistograms(uint32_t run, uint32_t lumi, uint32_t moduleId)
Definition: DQMStore.cc:1978
void useQTest(const std::string &dir, const std::string &qtname)
Definition: DQMStore.cc:3296
ConcurrentMonitorElement book2S(Args &&...args)
Definition: DQMStore.h:251
MonitorElement * book2DD(Args &&...args)
Definition: DQMStore.h:148
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2989
static const int STATUS_OK
void setAccumulate(MonitorElement *me, bool flag)
Definition: DQMStore.cc:3418
void bookTransaction(iFunc f, uint32_t run, uint32_t moduleId)
Definition: DQMStore.h:355
static void collate1S(MonitorElement *me, TH1S *h, unsigned verbose)
Definition: DQMStore.cc:1475
void meBookerGetter(iFunc f)
Definition: DQMStore.h:395
std::ofstream * stream_
Definition: DQMStore.h:842
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:3275
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:112
static bool checkBinningMatches(MonitorElement *me, TH1 *h, unsigned verbose)
Definition: DQMStore.cc:1441
dbl *** dir
Definition: mlp_gen.cc:35
void goUp()
equivalent to "cd .."
Definition: DQMStore.cc:599
void savePB(const std::string &filename, const std::string &path="", const uint32_t run=0, const uint32_t lumi=0)
Definition: DQMStore.cc:2746
MonitorElement * bookFloat_(const std::string &dir, const std::string &name)
Book float.
Definition: DQMStore.cc:802
static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose)
Definition: DQMStore.cc:1489
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:789
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1010
MonitorElement * book3D(Args &&...args)
Definition: DQMStore.h:154
DQMStore * owner_
Definition: DQMStore.h:344
std::set< std::string > dirs_
Definition: DQMStore.h:846
void reset(double vett[256])
Definition: TPedValues.cc:11
bool collateHistograms_
Definition: DQMStore.h:835
void removeElement(Args &&...args)
Definition: DQMStore.h:310
MonitorElement * book1DD(Args &&...args)
Definition: DQMStore.h:130
save
Definition: cuy.py:1163
bool LSbasedMode_
Definition: DQMStore.h:837
MonitorElement * book1S(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:898
void runQTests()
Definition: DQMStore.cc:3349
void makeDirectory(const std::string &path)
Definition: DQMStore.cc:612
ConcurrentMonitorElement book1S(Args &&...args)
Definition: DQMStore.h:230
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:588
static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose)
Definition: DQMStore.cc:1496
MonitorElement * book1S_(const std::string &dir, const std::string &name, TH1S *h)
Book 1D histogram based on TH1S.
Definition: DQMStore.cc:868
bool mtEnabled()
Definition: DQMStore.h:670
bool enableMultiThread_
Definition: DQMStore.h:836
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")
Definition: DQMStore.cc:1359
IGetter(DQMStore *store)
Definition: DQMStore.h:331