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 <memory>
15 #include <mutex>
16 #include <set>
17 #include <string>
18 #include <thread>
19 #include <vector>
20 #include <cxxabi.h>
21 #include <execinfo.h>
22 
23 #include <classlib/utils/Regexp.h>
24 
27 
28 namespace edm { class DQMHttpSource; class ParameterSet; class ActivityRegistry; class GlobalContext; }
29 namespace lat { class Regexp; }
30 namespace dqmstorepb {class ROOTFilePB; class ROOTFilePB_Histo;}
31 
32 class MonitorElement;
33 class QCriterion;
34 class TFile;
35 class TBufferFile;
36 class TObject;
37 class TH1;
38 class TObjString;
39 class TH1F;
40 class TH1S;
41 class TH1D;
42 class TH2F;
43 class TH2S;
44 class TH2D;
45 class TH3F;
46 class TProfile;
47 class TProfile2D;
48 class TNamed;
49 
50 
55 class fastmatch
56 {
57  private:
58  enum MatchingHeuristicEnum { UseFull, OneStarStart, OneStarEnd, TwoStar };
59 
60  public:
61  fastmatch (std::string _fastString);
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  std::unique_ptr<lat::Regexp> regexp_{nullptr};
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  IBooker booker{this};
363  f(booker);
364 
365  /* Reset the run number and module id only if multithreading is enabled */
366  if (enableMultiThread_) {
367  run_ = 0;
368  moduleId_ = 0;
369  }
370  }
371 
372  // Similar function used to book "global" histograms via the
373  // ConcurrentMonitorElement interface.
374  template <typename iFunc>
375  void bookConcurrentTransaction(iFunc f, uint32_t run) {
376  std::lock_guard<std::mutex> guard(book_mutex_);
377  /* Set the run_ member only if enableMultiThread is enabled */
378  if (enableMultiThread_) {
379  run_ = run;
380  }
381  ConcurrentBooker booker(this);
382  f(booker);
383 
384  /* Reset the run_ member only if enableMultiThread is enabled */
385  if (enableMultiThread_) {
386  run_ = 0;
387  }
388  }
389 
390  // Signature needed in the harvesting where the booking is done
391  // in the endJob. No handles to the run there. Two arguments ensure
392  // the capability of booking and getting. The method relies on the
393  // initialization of run, stream and module ID to 0. The mutex
394  // is not needed.
395  template <typename iFunc>
396  void meBookerGetter(iFunc f) {
397  IBooker booker{this};
398  IGetter getter{this};
399  f(booker, getter);
400  }
401 
402  //-------------------------------------------------------------------------
403  // ---------------------- Constructors ------------------------------------
405  DQMStore(const edm::ParameterSet &pset);
406  ~DQMStore();
407 
408  //-------------------------------------------------------------------------
409  void setVerbose(unsigned level);
410 
411  // ---------------------- public navigation -------------------------------
412  const std::string & pwd() const;
413  void cd();
414  void cd(const std::string &subdir);
415  void setCurrentFolder(const std::string &fullpath);
416  void goUp();
417 
418  bool dirExists(const std::string &path) const;
419 
420  //-------------------------------------------------------------------------
421  // ---------------------- public ME booking -------------------------------
422 
423  MonitorElement * bookInt (const char *name);
424  MonitorElement * bookInt (const std::string &name);
425 
426  MonitorElement * bookFloat (const char *name);
427  MonitorElement * bookFloat (const std::string &name);
428 
429  MonitorElement * bookString (const char *name,
430  const char *value);
431  MonitorElement * bookString (const std::string &name,
432  const std::string &value);
433 
434  MonitorElement * book1D (const char *name,
435  const char *title,
436  int nchX, double lowX, double highX);
437  MonitorElement * book1D (const std::string &name,
438  const std::string &title,
439  int nchX, double lowX, double highX);
440  MonitorElement * book1D (const char *name,
441  const char *title,
442  int nchX, const float *xbinsize);
443  MonitorElement * book1D (const std::string &name,
444  const std::string &title,
445  int nchX, const float *xbinsize);
446  MonitorElement * book1D (const char *name, TH1F *h);
447  MonitorElement * book1D (const std::string &name, TH1F *h);
448 
449  MonitorElement * book1S (const char *name,
450  const char *title,
451  int nchX, double lowX, double highX);
452  MonitorElement * book1S (const std::string &name,
453  const std::string &title,
454  int nchX, double lowX, double highX);
455  MonitorElement * book1S (const char *name,
456  const char *title,
457  int nchX, const float *xbinsize);
458  MonitorElement * book1S (const std::string &name,
459  const std::string &title,
460  int nchX, const float *xbinsize);
461  MonitorElement * book1S (const char *name, TH1S *h);
462  MonitorElement * book1S (const std::string &name, TH1S *h);
463 
464  MonitorElement * book1DD (const char *name,
465  const char *title,
466  int nchX, double lowX, double highX);
467  MonitorElement * book1DD (const std::string &name,
468  const std::string &title,
469  int nchX, double lowX, double highX);
470  MonitorElement * book1DD (const char *name,
471  const char *title,
472  int nchX, const float *xbinsize);
473  MonitorElement * book1DD (const std::string &name,
474  const std::string &title,
475  int nchX, const float *xbinsize);
476  MonitorElement * book1DD (const char *name, TH1D *h);
477  MonitorElement * book1DD (const std::string &name, TH1D *h);
478 
479  MonitorElement * book2D (const char *name,
480  const char *title,
481  int nchX, double lowX, double highX,
482  int nchY, double lowY, double highY);
483  MonitorElement * book2D (const std::string &name,
484  const std::string &title,
485  int nchX, double lowX, double highX,
486  int nchY, double lowY, double highY);
487  MonitorElement * book2D (const char *name,
488  const char *title,
489  int nchX, const float *xbinsize,
490  int nchY, const float *ybinsize);
491  MonitorElement * book2D (const std::string &name,
492  const std::string &title,
493  int nchX, const float *xbinsize,
494  int nchY, const float *ybinsize);
495  MonitorElement * book2D (const char *name, TH2F *h);
496  MonitorElement * book2D (const std::string &name, TH2F *h);
497 
498  MonitorElement * book2S (const char *name,
499  const char *title,
500  int nchX, double lowX, double highX,
501  int nchY, double lowY, double highY);
502  MonitorElement * book2S (const std::string &name,
503  const std::string &title,
504  int nchX, double lowX, double highX,
505  int nchY, double lowY, double highY);
506  MonitorElement * book2S (const char *name,
507  const char *title,
508  int nchX, const float *xbinsize,
509  int nchY, const float *ybinsize);
510  MonitorElement * book2S (const std::string &name,
511  const std::string &title,
512  int nchX, const float *xbinsize,
513  int nchY, const float *ybinsize);
514  MonitorElement * book2S (const char *name, TH2S *h);
515  MonitorElement * book2S (const std::string &name, TH2S *h);
516 
517  MonitorElement * book2DD (const char *name,
518  const char *title,
519  int nchX, double lowX, double highX,
520  int nchY, double lowY, double highY);
521  MonitorElement * book2DD (const std::string &name,
522  const std::string &title,
523  int nchX, double lowX, double highX,
524  int nchY, double lowY, double highY);
525  MonitorElement * book2DD (const char *name,
526  const char *title,
527  int nchX, const float *xbinsize,
528  int nchY, const float *ybinsize);
529  MonitorElement * book2DD (const std::string &name,
530  const std::string &title,
531  int nchX, const float *xbinsize,
532  int nchY, const float *ybinsize);
533  MonitorElement * book2DD (const char *name, TH2D *h);
534  MonitorElement * book2DD (const std::string &name, TH2D *h);
535 
536  MonitorElement * book3D (const char *name,
537  const char *title,
538  int nchX, double lowX, double highX,
539  int nchY, double lowY, double highY,
540  int nchZ, double lowZ, double highZ);
541  MonitorElement * book3D (const std::string &name,
542  const std::string &title,
543  int nchX, double lowX, double highX,
544  int nchY, double lowY, double highY,
545  int nchZ, double lowZ, double highZ);
546  MonitorElement * book3D (const char *name, TH3F *h);
547  MonitorElement * book3D (const std::string &name, TH3F *h);
548 
549  MonitorElement * bookProfile (const char *name,
550  const char *title,
551  int nchX, double lowX, double highX,
552  int nchY, double lowY, double highY,
553  const char *option = "s");
554  MonitorElement * bookProfile (const std::string &name,
555  const std::string &title,
556  int nchX, double lowX, double highX,
557  int nchY, double lowY, double highY,
558  const char *option = "s");
559  MonitorElement * bookProfile (const char *name,
560  const char *title,
561  int nchX, double lowX, double highX,
562  double lowY, double highY,
563  const char *option = "s");
564  MonitorElement * bookProfile (const std::string &name,
565  const std::string &title,
566  int nchX, double lowX, double highX,
567  double lowY, double highY,
568  const char *option = "s");
569  MonitorElement * bookProfile (const char *name,
570  const char *title,
571  int nchX, const double *xbinsize,
572  int nchY, double lowY, double highY,
573  const char *option = "s");
574  MonitorElement * bookProfile (const std::string &name,
575  const std::string &title,
576  int nchX, const double *xbinsize,
577  int nchY, double lowY, double highY,
578  const char *option = "s");
579  MonitorElement * bookProfile (const char *name,
580  const char *title,
581  int nchX, const double *xbinsize,
582  double lowY, double highY,
583  const char *option = "s");
584  MonitorElement * bookProfile (const std::string &name,
585  const std::string &title,
586  int nchX, const double *xbinsize,
587  double lowY, double highY,
588  const char *option = "s");
589  MonitorElement * bookProfile (const char *name, TProfile *h);
590  MonitorElement * bookProfile (const std::string &name, TProfile *h);
591 
592  MonitorElement * bookProfile2D(const char *name,
593  const char *title,
594  int nchX, double lowX, double highX,
595  int nchY, double lowY, double highY,
596  int nchZ, double lowZ, double highZ,
597  const char *option = "s");
599  const std::string &title,
600  int nchX, double lowX, double highX,
601  int nchY, double lowY, double highY,
602  int nchZ, double lowZ, double highZ,
603  const char *option = "s");
604  MonitorElement * bookProfile2D(const char *name,
605  const char *title,
606  int nchX, double lowX, double highX,
607  int nchY, double lowY, double highY,
608  double lowZ, double highZ,
609  const char *option = "s");
611  const std::string &title,
612  int nchX, double lowX, double highX,
613  int nchY, double lowY, double highY,
614  double lowZ, double highZ,
615  const char *option = "s");
616  MonitorElement * bookProfile2D(const char *name, TProfile2D *h);
617  MonitorElement * bookProfile2D(const std::string &name, TProfile2D *h);
618 
619  //-------------------------------------------------------------------------
620  // ---------------------- public tagging ----------------------------------
621  void tag(MonitorElement *me, unsigned int myTag);
622  void tag(const std::string &path, unsigned int myTag);
623  void tagContents(const std::string &path, unsigned int myTag);
624  void tagAllContents(const std::string &path, unsigned int myTag);
625 
626  //-------------------------------------------------------------------------
627  // ---------------------- public ME getters -------------------------------
628  std::vector<std::string> getSubdirs() const;
629  std::vector<std::string> getMEs() const;
630  bool containsAnyMonitorable(const std::string &path) const;
631 
632  MonitorElement * get(const std::string &path) const;
633  std::vector<MonitorElement *> get(unsigned int tag) const;
634  std::vector<MonitorElement *> getContents(const std::string &path) const;
635  std::vector<MonitorElement *> getContents(const std::string &path, unsigned int tag) const;
636  void getContents(std::vector<std::string> &into, bool showContents = true) const;
637 
638  // ---------------------- softReset methods -------------------------------
639  void softReset(MonitorElement *me);
641 
642  // ---------------------- Public deleting ---------------------------------
643  void rmdir(const std::string &fullpath);
644  void removeContents();
645  void removeContents(const std::string &dir);
646  void removeElement(const std::string &name);
647  void removeElement(const std::string &dir, const std::string &name, bool warning = true);
648 
649  // ------------------------------------------------------------------------
650  // ---------------------- public I/O --------------------------------------
651  void save(const std::string &filename,
652  const std::string &path = "",
653  const std::string &pattern = "",
654  const std::string &rewrite = "",
655  const uint32_t run = 0,
656  const uint32_t lumi = 0,
659  const std::string &fileupdate = "RECREATE");
660  void savePB(const std::string &filename,
661  const std::string &path = "",
662  const uint32_t run = 0,
663  const uint32_t lumi = 0);
664  bool open(const std::string &filename,
665  bool overwrite = false,
666  const std::string &path ="",
667  const std::string &prepend = "",
668  OpenRunDirs stripdirs = KeepRunDirs,
669  bool fileMustExist = true);
670  bool load(const std::string &filename,
671  OpenRunDirs stripdirs = StripRunDirs,
672  bool fileMustExist = true);
673  bool mtEnabled() { return enableMultiThread_; };
674 
675 
676  public:
677  // -------------------------------------------------------------------------
678  // ---------------------- Public print methods -----------------------------
679  void showDirStructure() const;
680 
681  // ---------------------- Public check options -----------------------------
682  bool isCollate() const;
683 
684  // -------------------------------------------------------------------------
685  // ---------------------- Quality Test methods -----------------------------
686  QCriterion * getQCriterion(const std::string &qtname) const;
687  QCriterion * createQTest(const std::string &algoname, const std::string &qtname);
688  void useQTest(const std::string &dir, const std::string &qtname);
689  int useQTestByMatch(const std::string &pattern, const std::string &qtname);
690  void runQTests();
691  int getStatus(const std::string &path = "") const;
692  void scaleElements();
693 
694  private:
695  // ---------------- Navigation -----------------------
696  bool cdInto(const std::string &path) const;
697 
698  // ------------------- Reference ME -------------------------------
699  bool isCollateME(MonitorElement *me) const;
700 
701  // ------------------- Private "getters" ------------------------------
702  bool readFilePB(const std::string &filename,
703  bool overwrite = false,
704  const std::string &path ="",
705  const std::string &prepend = "",
706  OpenRunDirs stripdirs = StripRunDirs,
707  bool fileMustExist = true);
708  bool readFile(const std::string &filename,
709  bool overwrite = false,
710  const std::string &path ="",
711  const std::string &prepend = "",
712  OpenRunDirs stripdirs = StripRunDirs,
713  bool fileMustExist = true);
714  void makeDirectory(const std::string &path);
715  unsigned int readDirectory(TFile *file,
716  bool overwrite,
717  const std::string &path,
718  const std::string &prepend,
719  const std::string &curdir,
720  OpenRunDirs stripdirs);
721 
723  const std::string &name,
724  const uint32_t run = 0,
725  const uint32_t lumi = 0,
726  const uint32_t moduleId = 0) const;
727 
730  std::string & objname,
731  TObject ** obj);
732 
733  public:
734  std::vector<MonitorElement*> getAllContents(const std::string &path,
735  uint32_t runNumber = 0,
736  uint32_t lumi = 0) const;
737  std::vector<MonitorElement*> getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType = lat::Regexp::Wildcard) const;
738 
739  // lumisection based histograms manipulations
740  void cloneLumiHistograms(uint32_t run, uint32_t lumi, uint32_t moduleId);
741  void cloneRunHistograms(uint32_t run, uint32_t moduleId);
742 
743  void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi);
744 
745  private:
746  // ---------------- Miscellaneous -----------------------------
747  void initializeFrom(const edm::ParameterSet&);
748  void reset();
749  void forceReset();
751 
752  bool extract(TObject *obj, const std::string &dir, bool overwrite, bool collateHistograms);
753  TObject * extractNextObject(TBufferFile&) const;
754 
755  // ---------------------- Booking ------------------------------------
757  MonitorElement * book_(const std::string &dir,
758  const std::string &name,
759  const char *context);
760  template <class HISTO, class COLLATE>
761  MonitorElement * book_(const std::string &dir,
762  const std::string &name,
763  const char *context,
764  int kind, HISTO *h, COLLATE collate);
765 
766  MonitorElement * bookInt_(const std::string &dir, const std::string &name);
767  MonitorElement * bookFloat_(const std::string &dir, const std::string &name);
768  MonitorElement * bookString_(const std::string &dir, const std::string &name, const std::string &value);
769  MonitorElement * book1D_(const std::string &dir, const std::string &name, TH1F *h);
770  MonitorElement * book1S_(const std::string &dir, const std::string &name, TH1S *h);
771  MonitorElement * book1DD_(const std::string &dir, const std::string &name, TH1D *h);
772  MonitorElement * book2D_(const std::string &dir, const std::string &name, TH2F *h);
773  MonitorElement * book2S_(const std::string &dir, const std::string &name, TH2S *h);
774  MonitorElement * book2DD_(const std::string &dir, const std::string &name, TH2D *h);
775  MonitorElement * book3D_(const std::string &dir, const std::string &name, TH3F *h);
776  MonitorElement * bookProfile_(const std::string &dir, const std::string &name, TProfile *h);
777  MonitorElement * bookProfile2D_(const std::string &dir, const std::string &name, TProfile2D *h);
778 
779  static bool checkBinningMatches(MonitorElement *me, TH1 *h, unsigned verbose);
780 
781  static void collate1D(MonitorElement *me, TH1F *h, unsigned verbose);
782  static void collate1S(MonitorElement *me, TH1S *h, unsigned verbose);
783  static void collate1DD(MonitorElement *me, TH1D *h, unsigned verbose);
784  static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose);
785  static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose);
786  static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose);
787  static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose);
788  static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose);
789  static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose);
790 
791  // --- Operations on MEs that are normally reset at end of monitoring cycle ---
792  void setAccumulate(MonitorElement *me, bool flag);
793 
794  void print_trace(const std::string &dir, const std::string &name);
795 
796  // ----------------------- Unavailable ---------------------------------------
797  DQMStore(DQMStore const&) = delete;
798  DQMStore& operator=(DQMStore const&) = delete;
799 
800  //-------------------------------------------------------------------------------
801  //-------------------------------------------------------------------------------
802  using QTestSpec = std::pair<fastmatch *, QCriterion *>;
803  using QTestSpecs = std::list<QTestSpec>;
804  using MEMap = std::set<MonitorElement>;
805  using QCMap = std::map<std::string, QCriterion *>;
806  using QAMap = std::map<std::string, QCriterion *(*)(const std::string &)>;
807 
808 
809  // ------------------------ private I/O helpers ------------------------------
811  MonitorElement const& me,
812  dqmstorepb::ROOTFilePB & file);
814  std::string const& dir,
815  unsigned int run,
816  MEMap::const_iterator begin,
817  MEMap::const_iterator end,
818  dqmstorepb::ROOTFilePB & file,
819  unsigned int & counter);
821  MonitorElement const& me,
822  TFile & file);
824  std::string const& dir,
825  std::string const& refpath,
826  SaveReferenceTag ref,
827  int minStatus,
828  unsigned int run,
829  MEMap::const_iterator begin,
830  MEMap::const_iterator end,
831  TFile & file,
832  unsigned int & counter);
833 
834  unsigned verbose_{1};
835  unsigned verboseQT_{1};
836  bool reset_{false};
837  double scaleFlag_;
838  bool collateHistograms_{false};
839  bool enableMultiThread_{false};
843  uint32_t run_{};
844  uint32_t moduleId_{};
845  std::unique_ptr<std::ostream> stream_{nullptr};
846 
849  std::set<std::string> dirs_;
850 
854 
856 
857  friend class edm::DQMHttpSource;
858  friend class DQMService;
859  friend class DQMNet;
860  friend class DQMArchiver;
861  friend class DQMStoreExample; // for get{All,Matching}Contents -- sole user of this method!
862  friend class DQMRootOutputModule;
863  friend class DQMRootSource;
864  friend class DQMFileSaver;
865  friend class MEtoEDMConverter;
866 };
867 
868 #endif // DQMServices_Core_DQMStore_h
ConcurrentMonitorElement book1DD(Args &&...args)
Definition: DQMStore.h:237
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:3209
~DQMStore()
Definition: DQMStore.cc:372
MonitorElement * book2DD_(const std::string &dir, const std::string &name, TH2D *h)
Book 2D histogram based on TH2D.
Definition: DQMStore.cc:958
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:987
bool containsAnyMonitorable(const std::string &path) const
Definition: DQMStore.cc:1600
bool isCollateME(MonitorElement *me) const
Definition: DQMStore.cc:3396
std::map< std::string, QCriterion * > QCMap
Definition: DQMStore.h:805
bool cdInto(const std::string &path) const
Definition: DQMStore.cc:2343
ConcurrentMonitorElement book2DD(Args &&...args)
Definition: DQMStore.h:258
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:3311
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:1303
static void get_info(const dqmstorepb::ROOTFilePB::Histo &h, std::string &dirname, std::string &objname, TObject **obj)
Definition: fastHadd.cc:189
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:837
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:3141
static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose)
Definition: DQMStore.cc:1465
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:2978
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose)
Definition: DQMStore.cc:1472
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:1118
MatchingHeuristicEnum
Definition: DQMStore.h:58
void scaleElements()
Definition: DQMStore.cc:3404
Definition: DQMNet.h:23
void postGlobalBeginLumi(const edm::GlobalContext &)
Definition: DQMStore.cc:1891
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:1009
std::pair< fastmatch *, QCriterion * > QTestSpec
Definition: DQMStore.h:802
static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose)
Definition: DQMStore.cc:1458
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:1812
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:836
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:869
void initializeFrom(const edm::ParameterSet &)
Definition: DQMStore.cc:382
#define nullptr
OpenRunDirs
Definition: DQMStore.h:87
std::set< MonitorElement > MEMap
Definition: DQMStore.h:804
Definition: DQMStore.h:29
uint32_t moduleId_
Definition: DQMStore.h:844
QCMap qtests_
Definition: DQMStore.h:851
void forceReset()
Definition: DQMStore.cc:1868
std::mutex book_mutex_
Definition: DQMStore.h:855
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:774
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:803
MonitorElement * book2D_(const std::string &dir, const std::string &name, TH2F *h)
Book 2D histogram based on TH2F.
Definition: DQMStore.cc:944
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:3348
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:2417
void saveMonitorElementToROOT(MonitorElement const &me, TFile &file)
Definition: DQMStore.cc:2386
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1765
unsigned verboseQT_
Definition: DQMStore.h:835
QTestSpecs qtestspecs_
Definition: DQMStore.h:853
double scaleFlag_
Definition: DQMStore.h:837
void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi)
Definition: DQMStore.cc:2000
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:803
bool isCollate() const
Definition: DQMStore.cc:3387
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:787
void removeElement(const std::string &name)
Definition: DQMStore.cc:3183
MonitorElement * book3D_(const std::string &dir, const std::string &name, TH3F *h)
Book 3D histogram based on TH3F.
Definition: DQMStore.cc:1111
static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose)
Definition: DQMStore.cc:1482
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
std::map< std::string, QCriterion *(*)(const std::string &)> QAMap
Definition: DQMStore.h:806
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:2645
MonitorElement * bookInt_(const std::string &dir, const std::string &name)
Book int.
Definition: DQMStore.cc:727
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:1159
double f[11][100]
uint32_t run_
Definition: DQMStore.h:843
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:1170
#define end
Definition: vmac.h:39
void setVerbose(unsigned level)
Definition: DQMStore.cc:509
Definition: value.py:1
void softReset(MonitorElement *me)
Definition: DQMStore.cc:3340
std::string pwd_
Definition: DQMStore.h:847
QAMap qalgos_
Definition: DQMStore.h:852
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1638
std::string readSelectedDirectory_
Definition: DQMStore.h:842
std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:1561
void bookConcurrentTransaction(iFunc f, uint32_t run)
Definition: DQMStore.h:375
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:1737
void saveMonitorElementToPB(MonitorElement const &me, dqmstorepb::ROOTFilePB &file)
Definition: DQMStore.cc:2616
static void collate1DD(MonitorElement *me, TH1D *h, unsigned verbose)
Definition: DQMStore.cc:1437
void tagAllContents(const std::string &path, unsigned int myTag)
Definition: DQMStore.cc:1539
ConcurrentMonitorElement bookFloat(Args &&...args)
Definition: DQMStore.h:216
void showDirStructure() const
Definition: DQMStore.cc:3367
MonitorElement * initialise(MonitorElement *me, const std::string &path)
void cd()
go to top directory (ie. root)
Definition: DQMStore.cc:522
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
unsigned verbose_
Definition: DQMStore.h:834
MonitorElement * book_(const std::string &dir, const std::string &name, const char *context)
Definition: DQMStore.cc:692
MonitorElement * book2S_(const std::string &dir, const std::string &name, TH2S *h)
Book 2D histogram based on TH2S.
Definition: DQMStore.cc:951
MEMap data_
Definition: DQMStore.h:848
DQMStore & operator=(DQMStore const &)=delete
def load(fileName)
Definition: svgfig.py:546
void print_trace(const std::string &dir, const std::string &name)
Definition: DQMStore.cc:444
MonitorElement * book1D_(const std::string &dir, const std::string &name, TH1F *h)
Book 1D histogram based on TH1F.
Definition: DQMStore.cc:816
int useQTestByMatch(const std::string &pattern, const std::string &qtname)
attach quality test <qc> to monitor elements matching <pattern>.
Definition: DQMStore.cc:3259
static void collate1D(MonitorElement *me, TH1F *h, unsigned verbose)
Definition: DQMStore.cc:1423
std::vector< std::string > getMEs() const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1584
MonitorElement * book1DD_(const std::string &dir, const std::string &name, TH1D *h)
Book 1D histogram based on TH1D.
Definition: DQMStore.cc:830
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:2781
void removeContents()
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:3175
IBooker(DQMStore *store)
Definition: DQMStore.h:179
bool forceResetOnBeginLumi_
Definition: DQMStore.h:841
#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:1527
void cloneRunHistograms(uint32_t run, uint32_t moduleId)
Definition: DQMStore.cc:1962
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:3060
void cloneLumiHistograms(uint32_t run, uint32_t lumi, uint32_t moduleId)
Definition: DQMStore.cc:1925
void useQTest(const std::string &dir, const std::string &qtname)
Definition: DQMStore.cc:3241
ConcurrentMonitorElement book2S(Args &&...args)
Definition: DQMStore.h:251
std::unique_ptr< std::ostream > stream_
Definition: DQMStore.h:845
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:2936
static const int STATUS_OK
void setAccumulate(MonitorElement *me, bool flag)
Definition: DQMStore.cc:3357
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:1430
void meBookerGetter(iFunc f)
Definition: DQMStore.h:396
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:3220
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:112
static bool checkBinningMatches(MonitorElement *me, TH1 *h, unsigned verbose)
Definition: DQMStore.cc:1396
dbl *** dir
Definition: mlp_gen.cc:35
void goUp()
equivalent to "cd .."
Definition: DQMStore.cc:556
void savePB(const std::string &filename, const std::string &path="", const uint32_t run=0, const uint32_t lumi=0)
Definition: DQMStore.cc:2693
MonitorElement * bookFloat_(const std::string &dir, const std::string &name)
Book float.
Definition: DQMStore.cc:757
static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose)
Definition: DQMStore.cc:1444
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:744
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:965
MonitorElement * book3D(Args &&...args)
Definition: DQMStore.h:154
DQMStore * owner_
Definition: DQMStore.h:344
std::set< std::string > dirs_
Definition: DQMStore.h:849
void reset(double vett[256])
Definition: TPedValues.cc:11
bool collateHistograms_
Definition: DQMStore.h:838
void removeElement(Args &&...args)
Definition: DQMStore.h:310
MonitorElement * book1DD(Args &&...args)
Definition: DQMStore.h:130
save
Definition: cuy.py:1164
bool LSbasedMode_
Definition: DQMStore.h:840
MonitorElement * book1S(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:853
void runQTests()
Definition: DQMStore.cc:3292
void makeDirectory(const std::string &path)
Definition: DQMStore.cc:569
ConcurrentMonitorElement book1S(Args &&...args)
Definition: DQMStore.h:230
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:545
static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose)
Definition: DQMStore.cc:1451
MonitorElement * book1S_(const std::string &dir, const std::string &name, TH1S *h)
Book 1D histogram based on TH1S.
Definition: DQMStore.cc:823
bool mtEnabled()
Definition: DQMStore.h:673
bool enableMultiThread_
Definition: DQMStore.h:839
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:1314
IGetter(DQMStore *store)
Definition: DQMStore.h:331