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,
356  uint32_t run,
357  uint32_t streamId,
358  uint32_t moduleId) {
359  std::lock_guard<std::mutex> guard(book_mutex_);
360  /* If enableMultiThread is not enabled we do not set run_,
361  streamId_ and moduleId_ to 0, since we rely on their default
362  initialization in DQMStore constructor. */
363  if (enableMultiThread_) {
364  run_ = run;
365  streamId_ = streamId;
366  moduleId_ = moduleId;
367  }
368  f(*ibooker_);
369 
370  /* Initialize to 0 the run_, streamId_ and moduleId_ variables
371  in case we run in mixed conditions with DQMEDAnalyzers and
372  legacy modules */
373  if (enableMultiThread_) {
374  run_ = 0;
375  streamId_ = 0;
376  moduleId_ = 0;
377  }
378  }
379 
380  // Similar function used to book "global" histograms via the
381  // ConcurrentMonitorElement interface.
382  template <typename iFunc>
383  void bookConcurrentTransaction(iFunc f, uint32_t run) {
384  std::lock_guard<std::mutex> guard(book_mutex_);
385  /* Even if enableMultiThread_ is enabled, keep the streamId_
386  and moduleId_ to 0, since we want to book global histograms. */
387  if (enableMultiThread_) {
388  run_ = run;
389  }
390  ConcurrentBooker booker(this);
391  f(booker);
392 
393  /* Set back to 0 the run_ in case we run in mixed conditions
394  with DQMEDAnalyzers and legacy modules */
395  if (enableMultiThread_) {
396  run_ = 0;
397  }
398  }
399 
400  // Signature needed in the harvesting where the booking is done
401  // in the endJob. No handles to the run there. Two arguments ensure
402  // the capability of booking and getting. The method relies on the
403  // initialization of run, stream and module ID to 0. The mutex
404  // is not needed.
405  template <typename iFunc>
406  void meBookerGetter(iFunc f) {
407  f(*ibooker_, *igetter_);
408  }
409 
410  // Signature needed in the harvesting where it might be needed to get
411  // the LS based histograms. Handle to the Lumi and to the iSetup are available.
412  // No need to book anything there. The method relies on the
413  // initialization of run, stream and module ID to 0. The mutex
414  // is not needed.
415  template <typename iFunc>
416  void meGetter(iFunc f) {
417  f(*igetter_);
418  }
419 
420  //-------------------------------------------------------------------------
421  // ---------------------- Constructors ------------------------------------
423  DQMStore(const edm::ParameterSet &pset);
424  ~DQMStore();
425 
426  //-------------------------------------------------------------------------
427  void setVerbose(unsigned level);
428 
429  // ---------------------- public navigation -------------------------------
430  const std::string & pwd() const;
431  void cd();
432  void cd(const std::string &subdir);
433  void setCurrentFolder(const std::string &fullpath);
434  void goUp();
435 
436  bool dirExists(const std::string &path) const;
437 
438  //-------------------------------------------------------------------------
439  // ---------------------- public ME booking -------------------------------
440 
441  MonitorElement * bookInt (const char *name);
442  MonitorElement * bookInt (const std::string &name);
443 
444  MonitorElement * bookFloat (const char *name);
445  MonitorElement * bookFloat (const std::string &name);
446 
447  MonitorElement * bookString (const char *name,
448  const char *value);
449  MonitorElement * bookString (const std::string &name,
450  const std::string &value);
451 
452  MonitorElement * book1D (const char *name,
453  const char *title,
454  int nchX, double lowX, double highX);
455  MonitorElement * book1D (const std::string &name,
456  const std::string &title,
457  int nchX, double lowX, double highX);
458  MonitorElement * book1D (const char *name,
459  const char *title,
460  int nchX, const float *xbinsize);
461  MonitorElement * book1D (const std::string &name,
462  const std::string &title,
463  int nchX, const float *xbinsize);
464  MonitorElement * book1D (const char *name, TH1F *h);
465  MonitorElement * book1D (const std::string &name, TH1F *h);
466 
467  MonitorElement * book1S (const char *name,
468  const char *title,
469  int nchX, double lowX, double highX);
470  MonitorElement * book1S (const std::string &name,
471  const std::string &title,
472  int nchX, double lowX, double highX);
473  MonitorElement * book1S (const char *name,
474  const char *title,
475  int nchX, const float *xbinsize);
476  MonitorElement * book1S (const std::string &name,
477  const std::string &title,
478  int nchX, const float *xbinsize);
479  MonitorElement * book1S (const char *name, TH1S *h);
480  MonitorElement * book1S (const std::string &name, TH1S *h);
481 
482  MonitorElement * book1DD (const char *name,
483  const char *title,
484  int nchX, double lowX, double highX);
485  MonitorElement * book1DD (const std::string &name,
486  const std::string &title,
487  int nchX, double lowX, double highX);
488  MonitorElement * book1DD (const char *name,
489  const char *title,
490  int nchX, const float *xbinsize);
491  MonitorElement * book1DD (const std::string &name,
492  const std::string &title,
493  int nchX, const float *xbinsize);
494  MonitorElement * book1DD (const char *name, TH1D *h);
495  MonitorElement * book1DD (const std::string &name, TH1D *h);
496 
497  MonitorElement * book2D (const char *name,
498  const char *title,
499  int nchX, double lowX, double highX,
500  int nchY, double lowY, double highY);
501  MonitorElement * book2D (const std::string &name,
502  const std::string &title,
503  int nchX, double lowX, double highX,
504  int nchY, double lowY, double highY);
505  MonitorElement * book2D (const char *name,
506  const char *title,
507  int nchX, const float *xbinsize,
508  int nchY, const float *ybinsize);
509  MonitorElement * book2D (const std::string &name,
510  const std::string &title,
511  int nchX, const float *xbinsize,
512  int nchY, const float *ybinsize);
513  MonitorElement * book2D (const char *name, TH2F *h);
514  MonitorElement * book2D (const std::string &name, TH2F *h);
515 
516  MonitorElement * book2S (const char *name,
517  const char *title,
518  int nchX, double lowX, double highX,
519  int nchY, double lowY, double highY);
520  MonitorElement * book2S (const std::string &name,
521  const std::string &title,
522  int nchX, double lowX, double highX,
523  int nchY, double lowY, double highY);
524  MonitorElement * book2S (const char *name,
525  const char *title,
526  int nchX, const float *xbinsize,
527  int nchY, const float *ybinsize);
528  MonitorElement * book2S (const std::string &name,
529  const std::string &title,
530  int nchX, const float *xbinsize,
531  int nchY, const float *ybinsize);
532  MonitorElement * book2S (const char *name, TH2S *h);
533  MonitorElement * book2S (const std::string &name, TH2S *h);
534 
535  MonitorElement * book2DD (const char *name,
536  const char *title,
537  int nchX, double lowX, double highX,
538  int nchY, double lowY, double highY);
539  MonitorElement * book2DD (const std::string &name,
540  const std::string &title,
541  int nchX, double lowX, double highX,
542  int nchY, double lowY, double highY);
543  MonitorElement * book2DD (const char *name,
544  const char *title,
545  int nchX, const float *xbinsize,
546  int nchY, const float *ybinsize);
547  MonitorElement * book2DD (const std::string &name,
548  const std::string &title,
549  int nchX, const float *xbinsize,
550  int nchY, const float *ybinsize);
551  MonitorElement * book2DD (const char *name, TH2D *h);
552  MonitorElement * book2DD (const std::string &name, TH2D *h);
553 
554  MonitorElement * book3D (const char *name,
555  const char *title,
556  int nchX, double lowX, double highX,
557  int nchY, double lowY, double highY,
558  int nchZ, double lowZ, double highZ);
559  MonitorElement * book3D (const std::string &name,
560  const std::string &title,
561  int nchX, double lowX, double highX,
562  int nchY, double lowY, double highY,
563  int nchZ, double lowZ, double highZ);
564  MonitorElement * book3D (const char *name, TH3F *h);
565  MonitorElement * book3D (const std::string &name, TH3F *h);
566 
567  MonitorElement * bookProfile (const char *name,
568  const char *title,
569  int nchX, double lowX, double highX,
570  int nchY, double lowY, double highY,
571  const char *option = "s");
572  MonitorElement * bookProfile (const std::string &name,
573  const std::string &title,
574  int nchX, double lowX, double highX,
575  int nchY, double lowY, double highY,
576  const char *option = "s");
577  MonitorElement * bookProfile (const char *name,
578  const char *title,
579  int nchX, double lowX, double highX,
580  double lowY, double highY,
581  const char *option = "s");
582  MonitorElement * bookProfile (const std::string &name,
583  const std::string &title,
584  int nchX, double lowX, double highX,
585  double lowY, double highY,
586  const char *option = "s");
587  MonitorElement * bookProfile (const char *name,
588  const char *title,
589  int nchX, const double *xbinsize,
590  int nchY, double lowY, double highY,
591  const char *option = "s");
592  MonitorElement * bookProfile (const std::string &name,
593  const std::string &title,
594  int nchX, const double *xbinsize,
595  int nchY, double lowY, double highY,
596  const char *option = "s");
597  MonitorElement * bookProfile (const char *name,
598  const char *title,
599  int nchX, const double *xbinsize,
600  double lowY, double highY,
601  const char *option = "s");
602  MonitorElement * bookProfile (const std::string &name,
603  const std::string &title,
604  int nchX, const double *xbinsize,
605  double lowY, double highY,
606  const char *option = "s");
607  MonitorElement * bookProfile (const char *name, TProfile *h);
608  MonitorElement * bookProfile (const std::string &name, TProfile *h);
609 
610  MonitorElement * bookProfile2D(const char *name,
611  const char *title,
612  int nchX, double lowX, double highX,
613  int nchY, double lowY, double highY,
614  int nchZ, double lowZ, double highZ,
615  const char *option = "s");
617  const std::string &title,
618  int nchX, double lowX, double highX,
619  int nchY, double lowY, double highY,
620  int nchZ, double lowZ, double highZ,
621  const char *option = "s");
622  MonitorElement * bookProfile2D(const char *name,
623  const char *title,
624  int nchX, double lowX, double highX,
625  int nchY, double lowY, double highY,
626  double lowZ, double highZ,
627  const char *option = "s");
629  const std::string &title,
630  int nchX, double lowX, double highX,
631  int nchY, double lowY, double highY,
632  double lowZ, double highZ,
633  const char *option = "s");
634  MonitorElement * bookProfile2D(const char *name, TProfile2D *h);
635  MonitorElement * bookProfile2D(const std::string &name, TProfile2D *h);
636 
637  //-------------------------------------------------------------------------
638  // ---------------------- public tagging ----------------------------------
639  void tag(MonitorElement *me, unsigned int myTag);
640  void tag(const std::string &path, unsigned int myTag);
641  void tagContents(const std::string &path, unsigned int myTag);
642  void tagAllContents(const std::string &path, unsigned int myTag);
643 
644  //-------------------------------------------------------------------------
645  // ---------------------- public ME getters -------------------------------
646  std::vector<std::string> getSubdirs() const;
647  std::vector<std::string> getMEs() const;
648  bool containsAnyMonitorable(const std::string &path) const;
649 
650  MonitorElement * get(const std::string &path) const;
651  std::vector<MonitorElement *> get(unsigned int tag) const;
652  std::vector<MonitorElement *> getContents(const std::string &path) const;
653  std::vector<MonitorElement *> getContents(const std::string &path, unsigned int tag) const;
654  void getContents(std::vector<std::string> &into, bool showContents = true) const;
655 
656  // ---------------------- softReset methods -------------------------------
657  void softReset(MonitorElement *me);
659 
660  // ---------------------- Public deleting ---------------------------------
661  void rmdir(const std::string &fullpath);
662  void removeContents();
663  void removeContents(const std::string &dir);
664  void removeElement(const std::string &name);
665  void removeElement(const std::string &dir, const std::string &name, bool warning = true);
666 
667  // ------------------------------------------------------------------------
668  // ---------------------- public I/O --------------------------------------
669  void save(const std::string &filename,
670  const std::string &path = "",
671  const std::string &pattern = "",
672  const std::string &rewrite = "",
673  const uint32_t run = 0,
674  const uint32_t lumi = 0,
677  const std::string &fileupdate = "RECREATE");
678  void savePB(const std::string &filename,
679  const std::string &path = "",
680  const uint32_t run = 0,
681  const uint32_t lumi = 0);
682  bool open(const std::string &filename,
683  bool overwrite = false,
684  const std::string &path ="",
685  const std::string &prepend = "",
686  OpenRunDirs stripdirs = KeepRunDirs,
687  bool fileMustExist = true);
688  bool load(const std::string &filename,
689  OpenRunDirs stripdirs = StripRunDirs,
690  bool fileMustExist = true);
691  bool mtEnabled() { return enableMultiThread_; };
692 
693 
694  // -------------------------------------------------------------------------
695  // ---------------------- Public print methods -----------------------------
696  public:
697  void showDirStructure() const;
698 
699  // ---------------------- Public check options -----------------------------
700  bool isCollate() const;
701 
702  // -------------------------------------------------------------------------
703  // ---------------------- Quality Test methods -----------------------------
704  QCriterion * getQCriterion(const std::string &qtname) const;
705  QCriterion * createQTest(const std::string &algoname, const std::string &qtname);
706  void useQTest(const std::string &dir, const std::string &qtname);
707  int useQTestByMatch(const std::string &pattern, const std::string &qtname);
708  void runQTests();
709  int getStatus(const std::string &path = "") const;
710  void scaleElements();
711 
712  private:
713  // ---------------- Navigation -----------------------
714  bool cdInto(const std::string &path) const;
715 
716  // ------------------- Reference ME -------------------------------
717  bool isCollateME(MonitorElement *me) const;
718 
719  // ------------------- Private "getters" ------------------------------
720  bool readFilePB(const std::string &filename,
721  bool overwrite = false,
722  const std::string &path ="",
723  const std::string &prepend = "",
724  OpenRunDirs stripdirs = StripRunDirs,
725  bool fileMustExist = true);
726  bool readFile(const std::string &filename,
727  bool overwrite = false,
728  const std::string &path ="",
729  const std::string &prepend = "",
730  OpenRunDirs stripdirs = StripRunDirs,
731  bool fileMustExist = true);
732  void makeDirectory(const std::string &path);
733  unsigned int readDirectory(TFile *file,
734  bool overwrite,
735  const std::string &path,
736  const std::string &prepend,
737  const std::string &curdir,
738  OpenRunDirs stripdirs);
739 
741  const std::string &name,
742  const uint32_t run = 0,
743  const uint32_t lumi = 0,
744  const uint32_t streamId = 0,
745  const uint32_t moduleId = 0) const;
746 
749  std::string & objname,
750  TObject ** obj);
751 
752  public:
753  void getAllTags(std::vector<std::string> &into) const;
754  std::vector<MonitorElement*> getAllContents(const std::string &path,
755  uint32_t runNumber = 0,
756  uint32_t lumi = 0) const;
757  std::vector<MonitorElement*> getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType = lat::Regexp::Wildcard) const;
758 
759  // Multithread SummaryCache manipulations
760  void mergeAndResetMEsRunSummaryCache(uint32_t run,
761  uint32_t streamId,
762  uint32_t moduleId);
763  void mergeAndResetMEsLuminositySummaryCache(uint32_t run,
764  uint32_t lumi,
765  uint32_t streamId,
766  uint32_t moduleId);
767 
768  void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi);
769  private:
770 
771  // ---------------- Miscellaneous -----------------------------
772  void initializeFrom(const edm::ParameterSet&);
773  void reset();
774  void forceReset();
776 
777  bool extract(TObject *obj, const std::string &dir, bool overwrite, bool collateHistograms);
778  TObject * extractNextObject(TBufferFile&) const;
779 
780  // ---------------------- Booking ------------------------------------
782  MonitorElement * book_(const std::string &dir,
783  const std::string &name,
784  const char *context);
785  template <class HISTO, class COLLATE>
786  MonitorElement * book_(const std::string &dir,
787  const std::string &name,
788  const char *context,
789  int kind, HISTO *h, COLLATE collate);
790 
791  MonitorElement * bookInt_(const std::string &dir, const std::string &name);
792  MonitorElement * bookFloat_(const std::string &dir, const std::string &name);
793  MonitorElement * bookString_(const std::string &dir, const std::string &name, const std::string &value);
794  MonitorElement * book1D_(const std::string &dir, const std::string &name, TH1F *h);
795  MonitorElement * book1S_(const std::string &dir, const std::string &name, TH1S *h);
796  MonitorElement * book1DD_(const std::string &dir, const std::string &name, TH1D *h);
797  MonitorElement * book2D_(const std::string &dir, const std::string &name, TH2F *h);
798  MonitorElement * book2S_(const std::string &dir, const std::string &name, TH2S *h);
799  MonitorElement * book2DD_(const std::string &dir, const std::string &name, TH2D *h);
800  MonitorElement * book3D_(const std::string &dir, const std::string &name, TH3F *h);
801  MonitorElement * bookProfile_(const std::string &dir, const std::string &name, TProfile *h);
802  MonitorElement * bookProfile2D_(const std::string &dir, const std::string &name, TProfile2D *h);
803 
804  static bool checkBinningMatches(MonitorElement *me, TH1 *h, unsigned verbose);
805 
806  static void collate1D(MonitorElement *me, TH1F *h, unsigned verbose);
807  static void collate1S(MonitorElement *me, TH1S *h, unsigned verbose);
808  static void collate1DD(MonitorElement *me, TH1D *h, unsigned verbose);
809  static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose);
810  static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose);
811  static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose);
812  static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose);
813  static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose);
814  static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose);
815 
816  // --- Operations on MEs that are normally reset at end of monitoring cycle ---
817  void setAccumulate(MonitorElement *me, bool flag);
818 
819  void print_trace(const std::string &dir, const std::string &name);
820 
821  // ----------------------- Unavailable ---------------------------------------
822  DQMStore(const DQMStore&);
823  const DQMStore& operator=(const DQMStore&);
824 
825  //-------------------------------------------------------------------------------
826  //-------------------------------------------------------------------------------
827  using QTestSpec = std::pair<fastmatch *, QCriterion *>;
828  using QTestSpecs = std::list<QTestSpec>;
829  using MEMap = std::set<MonitorElement>;
830  using QCMap = std::map<std::string, QCriterion *>;
831  using QAMap = std::map<std::string, QCriterion *(*)(const std::string &)>;
832 
833 
834  // ------------------------ private I/O helpers ------------------------------
836  MonitorElement const& me,
837  dqmstorepb::ROOTFilePB & file);
839  std::string const& dir,
840  unsigned int run,
841  MEMap::const_iterator begin,
842  MEMap::const_iterator end,
843  dqmstorepb::ROOTFilePB & file,
844  unsigned int & counter);
846  MonitorElement const& me,
847  TFile & file);
849  std::string const& dir,
850  std::string const& refpath,
851  SaveReferenceTag ref,
852  int minStatus,
853  unsigned int run,
854  MEMap::const_iterator begin,
855  MEMap::const_iterator end,
856  TFile & file,
857  unsigned int & counter);
858 
859  unsigned verbose_;
860  unsigned verboseQT_;
861  bool reset_;
862  double scaleFlag_;
868  uint32_t run_;
869  uint32_t streamId_;
870  uint32_t moduleId_;
871  std::ofstream * stream_;
872 
875  std::set<std::string> dirs_;
876 
880 
884 
885  friend class edm::DQMHttpSource;
886  friend class DQMService;
887  friend class DQMNet;
888  friend class DQMArchiver;
889  friend class DQMStoreExample; // for get{All,Matching}Contents -- sole user of this method!
890  friend class DQMRootOutputModule;
891  friend class DQMRootSource;
892  friend class DQMFileSaver;
893  friend class MEtoEDMConverter;
894 };
895 
896 #endif // DQMServices_Core_DQMStore_h
ConcurrentMonitorElement book1DD(Args &&...args)
Definition: DQMStore.h:237
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:3420
~DQMStore()
Definition: DQMStore.cc:570
IGetter * igetter_
Definition: DQMStore.h:883
MonitorElement * book2DD_(const std::string &dir, const std::string &name, TH2D *h)
Book 2D histogram based on TH2D.
Definition: DQMStore.cc:1161
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:1190
bool containsAnyMonitorable(const std::string &path) const
Definition: DQMStore.cc:1802
bool isCollateME(MonitorElement *me) const
Definition: DQMStore.cc:3613
std::map< std::string, QCriterion * > QCMap
Definition: DQMStore.h:830
bool cdInto(const std::string &path) const
Definition: DQMStore.cc:2533
ConcurrentMonitorElement book2DD(Args &&...args)
Definition: DQMStore.h:258
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:3526
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:1505
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:1040
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:3353
static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose)
Definition: DQMStore.cc:1667
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:3188
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
MonitorElement * findObject(const std::string &dir, const std::string &name, const uint32_t run=0, const uint32_t lumi=0, const uint32_t streamId=0, const uint32_t moduleId=0) const
Definition: DQMStore.cc:1941
static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose)
Definition: DQMStore.cc:1674
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:1320
MatchingHeuristicEnum
Definition: DQMStore.h:57
void scaleElements()
Definition: DQMStore.cc:3621
Definition: DQMNet.h:23
void postGlobalBeginLumi(const edm::GlobalContext &)
Definition: DQMStore.cc:2158
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:1212
uint32_t streamId_
Definition: DQMStore.h:869
std::pair< fastmatch *, QCriterion * > QTestSpec
Definition: DQMStore.h:827
static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose)
Definition: DQMStore.cc:1660
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:2073
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:861
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:1072
void initializeFrom(const edm::ParameterSet &)
Definition: DQMStore.cc:584
#define nullptr
OpenRunDirs
Definition: DQMStore.h:87
std::set< MonitorElement > MEMap
Definition: DQMStore.h:829
Definition: DQMStore.h:28
uint32_t moduleId_
Definition: DQMStore.h:870
QCMap qtests_
Definition: DQMStore.h:877
void forceReset()
Definition: DQMStore.cc:2133
std::mutex book_mutex_
Definition: DQMStore.h:881
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:977
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:828
MonitorElement * book2D_(const std::string &dir, const std::string &name, TH2F *h)
Book 2D histogram based on TH2F.
Definition: DQMStore.cc:1147
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:3565
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:2607
void saveMonitorElementToROOT(MonitorElement const &me, TFile &file)
Definition: DQMStore.cc:2576
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:2024
unsigned verboseQT_
Definition: DQMStore.h:860
QTestSpecs qtestspecs_
Definition: DQMStore.h:879
double scaleFlag_
Definition: DQMStore.h:862
void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi)
Definition: DQMStore.cc:2189
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:1006
bool isCollate() const
Definition: DQMStore.cc:3604
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:990
void removeElement(const std::string &name)
Definition: DQMStore.cc:3395
MonitorElement * book3D_(const std::string &dir, const std::string &name, TH3F *h)
Book 3D histogram based on TH3F.
Definition: DQMStore.cc:1313
static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose)
Definition: DQMStore.cc:1684
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
std::map< std::string, QCriterion *(*)(const std::string &)> QAMap
Definition: DQMStore.h:831
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:2845
MonitorElement * bookInt_(const std::string &dir, const std::string &name)
Book int.
Definition: DQMStore.cc:930
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:1361
double f[11][100]
uint32_t run_
Definition: DQMStore.h:868
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:1372
#define end
Definition: vmac.h:39
void setVerbose(unsigned level)
Definition: DQMStore.cc:710
Definition: value.py:1
void softReset(MonitorElement *me)
Definition: DQMStore.cc:3557
std::string pwd_
Definition: DQMStore.h:873
lat::Regexp * regexp_
Definition: DQMStore.h:73
IBooker * ibooker_
Definition: DQMStore.h:882
QAMap qalgos_
Definition: DQMStore.h:878
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1840
std::string readSelectedDirectory_
Definition: DQMStore.h:867
std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:1763
void bookConcurrentTransaction(iFunc f, uint32_t run)
Definition: DQMStore.h:383
void mergeAndResetMEsRunSummaryCache(uint32_t run, uint32_t streamId, uint32_t moduleId)
Definition: DQMStore.cc:362
std::string fastString_
Definition: DQMStore.h:74
void meGetter(iFunc f)
Definition: DQMStore.h:416
int extract(std::vector< int > *output, const std::string &dati)
void getAllTags(std::vector< std::string > &into) const
Definition: DQMStore.cc:1971
const DQMStore & operator=(const DQMStore &)
void saveMonitorElementToPB(MonitorElement const &me, dqmstorepb::ROOTFilePB &file)
Definition: DQMStore.cc:2816
static void collate1DD(MonitorElement *me, TH1D *h, unsigned verbose)
Definition: DQMStore.cc:1639
void tagAllContents(const std::string &path, unsigned int myTag)
Definition: DQMStore.cc:1741
ConcurrentMonitorElement bookFloat(Args &&...args)
Definition: DQMStore.h:216
void showDirStructure() const
Definition: DQMStore.cc:3584
MonitorElement * initialise(MonitorElement *me, const std::string &path)
void cd()
go to top directory (ie. root)
Definition: DQMStore.cc:723
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
unsigned verbose_
Definition: DQMStore.h:859
MonitorElement * book_(const std::string &dir, const std::string &name, const char *context)
Definition: DQMStore.cc:895
MonitorElement * book2S_(const std::string &dir, const std::string &name, TH2S *h)
Book 2D histogram based on TH2S.
Definition: DQMStore.cc:1154
MEMap data_
Definition: DQMStore.h:874
def load(fileName)
Definition: svgfig.py:546
void print_trace(const std::string &dir, const std::string &name)
Definition: DQMStore.cc:645
MonitorElement * book1D_(const std::string &dir, const std::string &name, TH1F *h)
Book 1D histogram based on TH1F.
Definition: DQMStore.cc:1019
int useQTestByMatch(const std::string &pattern, const std::string &qtname)
attach quality test <qc> to monitor elements matching <pattern>.
Definition: DQMStore.cc:3470
static void collate1D(MonitorElement *me, TH1F *h, unsigned verbose)
Definition: DQMStore.cc:1625
std::vector< std::string > getMEs() const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1786
void bookTransaction(iFunc f, uint32_t run, uint32_t streamId, uint32_t moduleId)
Definition: DQMStore.h:355
MonitorElement * book1DD_(const std::string &dir, const std::string &name, TH1D *h)
Book 1D histogram based on TH1D.
Definition: DQMStore.cc:1033
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:2991
void removeContents()
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:3387
IBooker(DQMStore *store)
Definition: DQMStore.h:179
bool forceResetOnBeginLumi_
Definition: DQMStore.h:866
#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:1729
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:3272
void useQTest(const std::string &dir, const std::string &qtname)
Definition: DQMStore.cc:3452
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:3146
static const int STATUS_OK
void setAccumulate(MonitorElement *me, bool flag)
Definition: DQMStore.cc:3574
static void collate1S(MonitorElement *me, TH1S *h, unsigned verbose)
Definition: DQMStore.cc:1632
void meBookerGetter(iFunc f)
Definition: DQMStore.h:406
std::ofstream * stream_
Definition: DQMStore.h:871
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:3431
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:112
static bool checkBinningMatches(MonitorElement *me, TH1 *h, unsigned verbose)
Definition: DQMStore.cc:1598
dbl *** dir
Definition: mlp_gen.cc:35
void goUp()
equivalent to "cd .."
Definition: DQMStore.cc:757
void savePB(const std::string &filename, const std::string &path="", const uint32_t run=0, const uint32_t lumi=0)
Definition: DQMStore.cc:2903
MonitorElement * bookFloat_(const std::string &dir, const std::string &name)
Book float.
Definition: DQMStore.cc:960
static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose)
Definition: DQMStore.cc:1646
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:947
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:1168
MonitorElement * book3D(Args &&...args)
Definition: DQMStore.h:154
void mergeAndResetMEsLuminositySummaryCache(uint32_t run, uint32_t lumi, uint32_t streamId, uint32_t moduleId)
Definition: DQMStore.cc:437
DQMStore * owner_
Definition: DQMStore.h:344
std::set< std::string > dirs_
Definition: DQMStore.h:875
void reset(double vett[256])
Definition: TPedValues.cc:11
bool collateHistograms_
Definition: DQMStore.h:863
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:865
MonitorElement * book1S(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:1056
void runQTests()
Definition: DQMStore.cc:3505
void makeDirectory(const std::string &path)
Definition: DQMStore.cc:770
ConcurrentMonitorElement book1S(Args &&...args)
Definition: DQMStore.h:230
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:746
static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose)
Definition: DQMStore.cc:1653
MonitorElement * book1S_(const std::string &dir, const std::string &name, TH1S *h)
Book 1D histogram based on TH1S.
Definition: DQMStore.cc:1026
bool mtEnabled()
Definition: DQMStore.h:691
bool enableMultiThread_
Definition: DQMStore.h:864
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:1516
IGetter(DQMStore *store)
Definition: DQMStore.h:331