CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMStore.cc
Go to the documentation of this file.
6 #include "classlib/utils/RegexpMatch.h"
7 #include "classlib/utils/Regexp.h"
8 #include "classlib/utils/StringOps.h"
9 #include "TFile.h"
10 #include "TROOT.h"
11 #include "TKey.h"
12 #include "TClass.h"
13 #include "TSystem.h"
14 #include <iterator>
15 #include <cerrno>
16 #include <boost/algorithm/string.hpp>
17 #include <fstream>
18 
45 static const std::string s_monitorDirName = "DQMData";
48 static const std::string s_referenceDirName = "Reference";
49 static const std::string s_collateDirName = "Collate";
50 static const std::string s_safe = "/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_()# ";
51 
52 static const lat::Regexp s_rxmeval ("^<(.*)>(i|f|s|e|t|qr)=(.*)</\\1>$");
53 static const lat::Regexp s_rxmeqr1 ("^st:(\\d+):([-+e.\\d]+):([^:]*):(.*)$");
54 static const lat::Regexp s_rxmeqr2 ("^st\\.(\\d+)\\.(.*)$");
55 static const lat::Regexp s_rxtrace ("(.*)\\((.*)\\+0x.*\\).*");
56 
60 static bool
62 {
63  return (ofdir.empty()
64  || (path.size() >= ofdir.size()
65  && path.compare(0, ofdir.size(), ofdir) == 0
66  && (path.size() == ofdir.size()
67  || path[ofdir.size()] == '/')));
68 }
69 
70 static void
72 {
73  clean.clear();
74  cleaned = &path;
75 
76  size_t len = path.size();
77  for ( ; len > 0 && path[len-1] == '/'; --len)
78  ;
79 
80  if (len != path.size())
81  {
82  clean = path.substr(0, len);
83  cleaned = &clean;
84  }
85 }
86 
87 static void
89 {
90  size_t slash = path.rfind('/');
91  if (slash != std::string::npos)
92  {
93  dir.append(path, 0, slash);
94  name.append(path, slash+1, std::string::npos);
95  }
96  else
97  name = path;
98 }
99 
100 static void
102 {
103  path.reserve(dir.size() + name.size() + 2);
104  path += dir;
105  if (! path.empty())
106  path += '/';
107  path += name;
108 }
109 
110 template <class T>
111 QCriterion *
113 { return new T(qtname); }
114 
115 template <class T>
116 void
118 { m[T::getAlgoName()] = &makeQCriterion<T>; }
119 
120 
122 fastmatch::fastmatch (std::string const& _fastString) :
123  fastString_ (_fastString), matching_ (UseFull)
124 {
125  try
126  {
127  regexp_ = NULL;
128  regexp_ = new lat::Regexp(fastString_, 0, lat::Regexp::Wildcard);
129  regexp_->study();
130  }
131  catch (lat::Error &e)
132  {
133  delete regexp_;
134  raiseDQMError("DQMStore", "Invalid wildcard pattern '%s' in quality"
135  " test specification", fastString_.c_str());
136  }
137 
138  // count stars ( "*" )
139  size_t starCount = 0;
140  int pos = -1;
141  while (true)
142  {
143  pos = fastString_.find("*", pos + 1 );
144  if ((size_t)pos == std::string::npos)
145  break;
146  starCount ++;
147  }
148 
149  // investigate for heuristics
150  if ((fastString_.find('"') != std::string::npos) ||
151  (fastString_.find(']') != std::string::npos) ||
152  (fastString_.find('?') != std::string::npos) ||
153  (fastString_.find('\\') != std::string::npos) ||
154  (starCount > 2))
155  {
156  // no fast version can be used
157  return;
158  }
159 
160  // match for pattern "*MyString" and "MyString*"
161  if (starCount == 1)
162  {
163  if (boost::algorithm::starts_with(fastString_, "*"))
164  {
166  fastString_.erase(0,1);
167  return;
168  }
169 
170  if (boost::algorithm::ends_with(fastString_, "*"))
171  {
173  fastString_.erase(fastString_.length()-1,1);
174  return;
175  }
176  }
177 
178  // match for pattern "*MyString*"
179  if (starCount == 2)
180  {
181  if (boost::algorithm::starts_with(fastString_, "*") &&
182  boost::algorithm::ends_with(fastString_, "*"))
183  {
184  matching_ = TwoStar;
185  fastString_.erase(0,1);
186  fastString_.erase(fastString_.size() - 1, 1);
187  return;
188  }
189  }
190 }
191 
193 {
194  if (regexp_ != NULL)
195  delete regexp_;
196 }
197 
199  std::string const& input) const
200 {
201  if (input.size() < pattern.size())
202  return false;
203 
204  // compare the two strings character by character for equalness:
205  // this does not create uneeded copies of std::string. The
206  // boost::algorithm implementation does
207  std::string::const_reverse_iterator rit_pattern = pattern.rbegin();
208  std::string::const_reverse_iterator rit_input = input.rbegin();
209 
210  for (; rit_pattern < pattern.rend(); rit_pattern++, rit_input++)
211  {
212  if (*rit_pattern != *rit_input)
213  // found a difference, fail
214  return false;
215  }
216  return true;
217 }
218 
220  std::string const& input) const
221 {
222  if (input.size() < pattern.size())
223  return false;
224 
225  // compare the two strings character by character for equalness:
226  // this does not create uneeded copies of std::string. The
227  // boost::algorithm implementation does.
228  std::string::const_iterator rit_pattern = pattern.begin();
229  std::string::const_iterator rit_input = input.begin();
230 
231  for (; rit_pattern < pattern.end(); rit_pattern++, rit_input++)
232  {
233  if (*rit_pattern != *rit_input)
234  // found a difference, fail
235  return false;
236  }
237  return true;
238 }
239 
240 bool fastmatch::match(std::string const& s) const
241 {
242  switch (matching_)
243  {
244  case OneStarStart:
246 
247  case OneStarEnd:
248  return compare_strings(fastString_, s);
249 
250  case TwoStar:
251  return (s.find(fastString_) != std::string::npos);
252 
253  default:
254  return regexp_->match(s);
255  }
256 }
257 
259  owner_->cd();
260 }
261 
263  owner_->cd(dir);
264 }
265 
267  owner_->setCurrentFolder(fullpath);
268 }
269 
270 void DQMStore::IBooker::tag(MonitorElement *me, unsigned int tag) {
271  owner_->tag(me, tag);
272 }
273 
286  uint32_t streamId,
287  uint32_t moduleId) {
288  if (verbose_ > 1)
289  std::cout << "Merging objects from run: "
290  << run
291  << ", stream: " << streamId
292  << " module: " << moduleId << std::endl;
293  std::string null_str("");
294  MonitorElement proto(&null_str, null_str, run, streamId, moduleId);
295  std::set<MonitorElement>::const_iterator e = data_.end();
296  std::set<MonitorElement>::const_iterator i = data_.lower_bound(proto);
297  while (i != e) {
298  if (i->data_.run != run
299  || i->data_.streamId != streamId
300  || i->data_.moduleId != moduleId)
301  break;
302 
303  // Handle Run-based histograms only.
304  if (i->getLumiFlag()) {
305  ++i;
306  continue;
307  }
308 
309  MonitorElement global_me(*i);
310  global_me.globalize();
311  std::set<MonitorElement>::const_iterator me = data_.find(global_me);
312  if (me != data_.end()) {
313  if (verbose_ > 1)
314  std::cout << "Found global Object, using it. ";
315  me->getTH1()->Add(i->getTH1());
316  } else {
317  // Since this is equivalent to a real booking operation it must
318  // be locked.
319  if (verbose_ > 1)
320  std::cout << "No global Object found. ";
321  std::lock_guard<std::mutex> guard(book_mutex_);
322  me = data_.find(global_me);
323  if (me != data_.end()) {
324  me->getTH1()->Add(i->getTH1());
325  } else {
326  std::pair<std::set<MonitorElement>::const_iterator, bool> gme;
327  gme = data_.insert(global_me);
328  assert(gme.second);
329  }
330  }
331  // TODO(rovere): eventually reset the local object and mark it as reusable??
332  ++i;
333  }
334 }
335 
337  uint32_t lumi,
338  uint32_t streamId,
339  uint32_t moduleId) {
340  if (verbose_ > 1)
341  std::cout << "Merging objects from run: "
342  << run << " lumi: " << lumi
343  << ", stream: " << streamId
344  << " module: " << moduleId << std::endl;
345  std::string null_str("");
346  MonitorElement proto(&null_str, null_str, run, streamId, moduleId);
347  std::set<MonitorElement>::const_iterator e = data_.end();
348  std::set<MonitorElement>::const_iterator i = data_.lower_bound(proto);
349  while (i != e) {
350  if (i->data_.run != run
351  || i->data_.streamId != streamId
352  || i->data_.moduleId != moduleId)
353  break;
354 
355  // Handle LS-based histograms only.
356  if (not i->getLumiFlag()) {
357  ++i;
358  continue;
359  }
360 
361  MonitorElement global_me(*i);
362  global_me.globalize();
363  global_me.setLumi(lumi);
364  std::set<MonitorElement>::const_iterator me = data_.find(global_me);
365  if (me != data_.end()) {
366  if (verbose_ > 1)
367  std::cout << "Found global Object, using it --> ";
368  me->getTH1()->Add(i->getTH1());
369  } else {
370  // Since this is equivalent to a real booking operation it must
371  // be locked.
372  if (verbose_ > 1)
373  std::cout << "No global Object found. ";
374  std::lock_guard<std::mutex> guard(book_mutex_);
375  me = data_.find(global_me);
376  if (me != data_.end()) {
377  me->getTH1()->Add(i->getTH1());
378  } else {
379  std::pair<std::set<MonitorElement>::const_iterator, bool> gme;
380  gme = data_.insert(global_me);
381  assert(gme.second);
382  }
383  }
384  const_cast<MonitorElement*>(&*i)->Reset();
385  // TODO(rovere): eventually reset the local object and mark it as reusable??
386  ++i;
387  }
388 }
389 
392  : verbose_ (1),
393  verboseQT_ (1),
394  reset_ (false),
398  run_(0),
399  streamId_(0),
400  moduleId_(0),
401  pwd_ (""),
402  ibooker_(0)
403 {
404  if (!ibooker_)
405  ibooker_ = new DQMStore::IBooker(this);
406  initializeFrom(pset);
407  if(pset.getUntrackedParameter<bool>("forceResetOnBeginRun",false)) {
409  }
410 }
411 
413  : verbose_ (1),
414  verboseQT_ (1),
415  reset_ (false),
416  collateHistograms_ (false),
417  enableMultiThread_(false),
418  readSelectedDirectory_ (""),
419  run_(0),
420  streamId_(0),
421  moduleId_(0),
422  pwd_ (""),
423  ibooker_(0)
424 {
425  if (!ibooker_)
426  ibooker_ = new DQMStore::IBooker(this);
427  initializeFrom(pset);
428 }
429 
431 {
432  for (QCMap::iterator i = qtests_.begin(), e = qtests_.end(); i != e; ++i)
433  delete i->second;
434 
435  for (QTestSpecs::iterator i = qtestspecs_.begin(), e = qtestspecs_.end(); i != e; ++i)
436  delete i->first;
437 
438 }
439 
440 void
442  makeDirectory("");
443  reset();
444 
445  // set steerable parameters
446  verbose_ = pset.getUntrackedParameter<int>("verbose", 0);
447  if (verbose_ > 0)
448  std::cout << "DQMStore: verbosity set to " << verbose_ << std::endl;
449 
450  verboseQT_ = pset.getUntrackedParameter<int>("verboseQT", 0);
451  if (verbose_ > 0)
452  std::cout << "DQMStore: QTest verbosity set to " << verboseQT_ << std::endl;
453 
454  collateHistograms_ = pset.getUntrackedParameter<bool>("collateHistograms", false);
455  if (collateHistograms_)
456  std::cout << "DQMStore: histogram collation is enabled\n";
457 
458  enableMultiThread_ = pset.getUntrackedParameter<bool>("enableMultiThread", false);
459  if (enableMultiThread_)
460  std::cout << "DQMStore: MultiThread option is enabled\n";
461 
462  std::string ref = pset.getUntrackedParameter<std::string>("referenceFileName", "");
463  if (! ref.empty())
464  {
465  std::cout << "DQMStore: using reference file '" << ref << "'\n";
466  readFile(ref, true, "", s_referenceDirName, StripRunDirs, false);
467  }
468 
469  initQCriterion<Comp2RefChi2>(qalgos_);
470  initQCriterion<Comp2RefKolmogorov>(qalgos_);
471  initQCriterion<ContentsXRange>(qalgos_);
472  initQCriterion<ContentsYRange>(qalgos_);
473  initQCriterion<MeanWithinExpected>(qalgos_);
474  initQCriterion<Comp2RefEqualH>(qalgos_);
475  initQCriterion<DeadChannel>(qalgos_);
476  initQCriterion<NoisyChannel>(qalgos_);
477  initQCriterion<ContentsWithinExpected>(qalgos_);
478  initQCriterion<CompareToMedian>(qalgos_);
479  initQCriterion<CompareLastFilledBin>(qalgos_);
480  initQCriterion<CheckVariance>(qalgos_);
481 
482  scaleFlag_ = pset.getUntrackedParameter<double>("ScalingFlag", 0.0);
483  if (verbose_ > 0)
484  std::cout << "DQMStore: Scaling Flag set to " << scaleFlag_ << std::endl;
485 }
486 
487 /* Generic method to do a backtrace and print it to stdout. It is
488  customised to properly get the routine that called the booking of the
489  histograms, which, following the usual stack, is at position 4. The
490  name of the calling function is properly demangled and the original
491  shared library including this function is also printed. For a more
492  detailed explanation of the routines involved, see here:
493  http://www.gnu.org/software/libc/manual/html_node/Backtraces.html
494  http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html.*/
495 
496 void
498 {
499  static std::ofstream stream("histogramBookingBT.log");
500  void *array[10];
501  size_t size;
502  char **strings;
503  int r=0;
504  lat::RegexpMatch m;
505  m.reset();
506 
507  size = backtrace (array, 10);
508  strings = backtrace_symbols (array, size);
509 
510  if ((size > 4)
511  &&s_rxtrace.match(strings[4], 0, 0, &m))
512  {
513  char * demangled = abi::__cxa_demangle(m.matchString(strings[4], 2).c_str(), 0, 0, &r);
514  stream << "\"" << dir << "/"
515  << name << "\" "
516  << (r ? m.matchString(strings[4], 2) : demangled) << " "
517  << m.matchString(strings[4], 1) << "\n";
518  free(demangled);
519  }
520  else
521  stream << "Skipping "<< dir << "/" << name
522  << " with stack size " << size << "\n";
523  /* In this case print the full stack trace, up to main or to the
524  * maximum stack size, i.e. 10. */
525  if (verbose_ > 4)
526  {
527  size_t i;
528  m.reset();
529 
530  for (i = 0; i < size; i++)
531  if (s_rxtrace.match(strings[i], 0, 0, &m))
532  {
533  char * demangled = abi::__cxa_demangle(m.matchString(strings[i], 2).c_str(), 0, 0, &r);
534  stream << "\t\t" << i << "/" << size << " "
535  << (r ? m.matchString(strings[i], 2) : demangled) << " "
536  << m.matchString(strings[i], 1) << std::endl;
537  free (demangled);
538  }
539  }
540  free (strings);
541 }
542 
547 void
548 DQMStore::setVerbose(unsigned /* level */)
549 { return; }
550 
555 const std::string &
556 DQMStore::pwd(void) const
557 { return pwd_; }
558 
560 void
562 { setCurrentFolder(""); }
563 
565 void
566 DQMStore::cd(const std::string &subdir)
567 {
569  const std::string *cleaned = 0;
570  cleanTrailingSlashes(subdir, clean, cleaned);
571 
572  if (! dirExists(*cleaned))
573  raiseDQMError("DQMStore", "Cannot 'cd' into non-existent directory '%s'",
574  cleaned->c_str());
575 
576  setCurrentFolder(*cleaned);
577 }
578 
583 void
585 {
587  const std::string *cleaned = 0;
588  cleanTrailingSlashes(fullpath, clean, cleaned);
589  makeDirectory(*cleaned);
590  pwd_ = *cleaned;
591 }
592 
594 void
596 {
597  size_t pos = pwd_.rfind('/');
598  if (pos == std::string::npos)
599  setCurrentFolder("");
600  else
601  setCurrentFolder(pwd_.substr(0, pos));
602 }
603 
604 // -------------------------------------------------------------------
606 void
608 {
609  std::string prev;
610  std::string subdir;
612  prev.reserve(path.size());
613  subdir.reserve(path.size());
614  name.reserve(path.size());
615  size_t prevname = 0;
616  size_t slash = 0;
617 
618  while (true)
619  {
620  // Create this subdirectory component.
621  subdir.clear();
622  subdir.append(path, 0, slash);
623  name.clear();
624  name.append(subdir, prevname, std::string::npos);
625  if (! prev.empty() && findObject(prev, name))
626  raiseDQMError("DQMStore", "Attempt to create subdirectory '%s'"
627  " which already exists as a monitor element",
628  subdir.c_str());
629 
630  if (! dirs_.count(subdir))
631  dirs_.insert(subdir);
632 
633  // Stop if we've reached the end (including possibly a trailing slash).
634  if (slash+1 >= path.size())
635  break;
636 
637  // Find the next slash, making sure we progress. If reach the end,
638  // process the last path component; the next loop round will terminate.
639  prevname = slash ? slash+1 : slash;
640  prev = subdir;
641  if ((slash = path.find('/', ++slash)) == std::string::npos)
642  slash = path.size();
643  }
644 }
645 
647 bool
649 { return dirs_.count(path) > 0; }
650 
654 template <class HISTO, class COLLATE>
657  const char *context, int kind,
658  HISTO *h, COLLATE collate)
659 {
660  assert(name.find('/') == std::string::npos);
661  if (verbose_ > 3)
662  print_trace(dir, name);
664  mergePath(path, dir, name);
665 
666  // Put us in charge of h.
667  h->SetDirectory(0);
668 
669  // Check if the request monitor element already exists.
670  MonitorElement *me = findObject(dir, name, run_, 0, streamId_, moduleId_);
671  if (me)
672  {
673  if (collateHistograms_)
674  {
675  collate(me, h);
676  delete h;
677  return me;
678  }
679  else
680  {
681  if (verbose_ > 1)
682  std::cout << "DQMStore: "
683  << context << ": monitor element '"
684  << path << "' already exists, collating" << std::endl;
685  me->Reset();
686  collate(me, h);
687  delete h;
688  return me;
689  }
690  }
691  else
692  {
693  // Create and initialise core object.
694  assert(dirs_.count(dir));
695  MonitorElement proto(&*dirs_.find(dir), name, run_, streamId_, moduleId_);
696  me = const_cast<MonitorElement &>(*data_.insert(proto).first)
698 
699  // Initialise quality test information.
700  QTestSpecs::iterator qi = qtestspecs_.begin();
701  QTestSpecs::iterator qe = qtestspecs_.end();
702  for ( ; qi != qe; ++qi)
703  {
704  if ( qi->first->match(path) )
705  me->addQReport(qi->second);
706  }
707 
708  // Assign reference if we have one.
709  std::string refdir;
710  refdir.reserve(s_referenceDirName.size() + dir.size() + 2);
711  refdir += s_referenceDirName;
712  refdir += '/';
713  refdir += dir;
714 
715  if (MonitorElement *refme = findObject(refdir, name))
716  {
717  me->data_.flags |= DQMNet::DQM_PROP_HAS_REFERENCE;
718  me->reference_ = refme->object_;
719  }
720 
721  // Return the monitor element.
722  return me;
723  }
724 }
725 
728  const std::string &name,
729  const char *context)
730 {
731  assert(name.find('/') == std::string::npos);
732  if (verbose_ > 3)
733  print_trace(dir, name);
734 
735  // Check if the request monitor element already exists.
736  if (MonitorElement *me = findObject(dir, name))
737  {
738  if (verbose_ > 1)
739  {
741  mergePath(path, dir, name);
742 
743  std::cout << "DQMStore: "
744  << context << ": monitor element '"
745  << path << "' already exists, resetting" << std::endl;
746  }
747  me->Reset();
748  return me;
749  }
750  else
751  {
752  // Create it and return for initialisation.
753  assert(dirs_.count(dir));
754  MonitorElement nme(&*dirs_.find(dir), name);
755  return &const_cast<MonitorElement &>(*data_.insert(nme).first);
756  }
757 }
758 
759 // -------------------------------------------------------------------
763 {
764  if (collateHistograms_)
765  {
766  if (MonitorElement *me = findObject(dir, name))
767  {
768  me->Fill(0);
769  return me;
770  }
771  }
772 
773  return book(dir, name, "bookInt")
775 }
776 
780 { return bookInt(pwd_, name); }
781 
785 {
786  return bookInt(pwd_, name);
787 }
788 
789 // -------------------------------------------------------------------
793 {
794  if (collateHistograms_)
795  {
796  if (MonitorElement *me = findObject(dir, name))
797  {
798  me->Fill(0.);
799  return me;
800  }
801  }
802 
803  return book(dir, name, "bookFloat")
805 }
806 
810 { return bookFloat(pwd_, name); }
811 
815 {
816  return bookFloat(pwd_, name);
817 }
818 
819 // -------------------------------------------------------------------
823  const std::string &name,
824  const std::string &value)
825 {
826  if (collateHistograms_)
827  {
828  if (MonitorElement *me = findObject(dir, name))
829  return me;
830  }
831 
832  return book(dir, name, "bookString")
834 }
835 
838 DQMStore::bookString(const char *name, const char *value)
839 { return bookString(pwd_, name, value); }
840 
844 {
845  return bookString(pwd_, name, value);
846 }
847 
848 // -------------------------------------------------------------------
852 {
853  return book(dir, name, "book1D", MonitorElement::DQM_KIND_TH1F, h, collate1D);
854 }
855 
859 {
860  return book(dir, name, "book1S", MonitorElement::DQM_KIND_TH1S, h, collate1S);
861 }
862 
866 {
867  return book(dir, name, "book1DD", MonitorElement::DQM_KIND_TH1D, h, collate1DD);
868 }
869 
872 DQMStore::book1D(const char *name, const char *title,
873  int nchX, double lowX, double highX)
874 {
875  return book1D(pwd_, name, new TH1F(name, title, nchX, lowX, highX));
876 }
877 
881  int nchX, double lowX, double highX)
882 {
883  return book1D(pwd_, name, new TH1F(name.c_str(), title.c_str(), nchX, lowX, highX));
884 }
885 
888 DQMStore::book1S(const char *name, const char *title,
889  int nchX, double lowX, double highX)
890 {
891  return book1S(pwd_, name, new TH1S(name, title, nchX, lowX, highX));
892 }
893 
897  int nchX, double lowX, double highX)
898 {
899  return book1S(pwd_, name, new TH1S(name.c_str(), title.c_str(), nchX, lowX, highX));
900 }
901 
904 DQMStore::book1DD(const char *name, const char *title,
905  int nchX, double lowX, double highX)
906 {
907  return book1DD(pwd_, name, new TH1D(name, title, nchX, lowX, highX));
908 }
909 
913  int nchX, double lowX, double highX)
914 {
915  return book1DD(pwd_, name, new TH1D(name.c_str(), title.c_str(), nchX, lowX, highX));
916 }
917 
920 DQMStore::book1D(const char *name, const char *title,
921  int nchX, float *xbinsize)
922 {
923  return book1D(pwd_, name, new TH1F(name, title, nchX, xbinsize));
924 }
925 
929  int nchX, float *xbinsize)
930 {
931  return book1D(pwd_, name, new TH1F(name.c_str(), title.c_str(), nchX, xbinsize));
932 }
933 
936 DQMStore::book1D(const char *name, TH1F *source)
937 {
938  return book1D(pwd_, name, static_cast<TH1F *>(source->Clone(name)));
939 }
940 
944 {
945  return book1D(pwd_, name, static_cast<TH1F *>(source->Clone(name.c_str())));
946 }
947 
950 DQMStore::book1S(const char *name, TH1S *source)
951 {
952  return book1S(pwd_, name, static_cast<TH1S *>(source->Clone(name)));
953 }
954 
958 {
959  return book1S(pwd_, name, static_cast<TH1S *>(source->Clone(name.c_str())));
960 }
961 
964 DQMStore::book1DD(const char *name, TH1D *source)
965 {
966  return book1DD(pwd_, name, static_cast<TH1D *>(source->Clone(name)));
967 }
968 
972 {
973  return book1DD(pwd_, name, static_cast<TH1D *>(source->Clone(name.c_str())));
974 }
975 
976 // -------------------------------------------------------------------
980 {
981  return book(dir, name, "book2D", MonitorElement::DQM_KIND_TH2F, h, collate2D);
982 }
983 
987 {
988  return book(dir, name, "book2S", MonitorElement::DQM_KIND_TH2S, h, collate2S);
989 }
990 
994 {
995  return book(dir, name, "book2DD", MonitorElement::DQM_KIND_TH2D, h, collate2DD);
996 }
997 
1000 DQMStore::book2D(const char *name, const char *title,
1001  int nchX, double lowX, double highX,
1002  int nchY, double lowY, double highY)
1003 {
1004  return book2D(pwd_, name, new TH2F(name, title,
1005  nchX, lowX, highX,
1006  nchY, lowY, highY));
1007 }
1008 
1012  int nchX, double lowX, double highX,
1013  int nchY, double lowY, double highY)
1014 {
1015  return book2D(pwd_, name, new TH2F(name.c_str(), title.c_str(),
1016  nchX, lowX, highX,
1017  nchY, lowY, highY));
1018 }
1019 
1022 DQMStore::book2S(const char *name, const char *title,
1023  int nchX, double lowX, double highX,
1024  int nchY, double lowY, double highY)
1025 {
1026  return book2S(pwd_, name, new TH2S(name, title,
1027  nchX, lowX, highX,
1028  nchY, lowY, highY));
1029 }
1030 
1034  int nchX, double lowX, double highX,
1035  int nchY, double lowY, double highY)
1036 {
1037  return book2S(pwd_, name, new TH2S(name.c_str(), title.c_str(),
1038  nchX, lowX, highX,
1039  nchY, lowY, highY));
1040 }
1041 
1044 DQMStore::book2DD(const char *name, const char *title,
1045  int nchX, double lowX, double highX,
1046  int nchY, double lowY, double highY)
1047 {
1048  return book2DD(pwd_, name, new TH2D(name, title,
1049  nchX, lowX, highX,
1050  nchY, lowY, highY));
1051 }
1052 
1056  int nchX, double lowX, double highX,
1057  int nchY, double lowY, double highY)
1058 {
1059  return book2DD(pwd_, name, new TH2D(name.c_str(), title.c_str(),
1060  nchX, lowX, highX,
1061  nchY, lowY, highY));
1062 }
1063 
1066 DQMStore::book2D(const char *name, const char *title,
1067  int nchX, float *xbinsize, int nchY, float *ybinsize)
1068 {
1069  return book2D(pwd_, name, new TH2F(name, title,
1070  nchX, xbinsize, nchY, ybinsize));
1071 }
1072 
1076  int nchX, float *xbinsize, int nchY, float *ybinsize)
1077 {
1078  return book2D(pwd_, name, new TH2F(name.c_str(), title.c_str(),
1079  nchX, xbinsize, nchY, ybinsize));
1080 }
1081 
1084 DQMStore::book2D(const char *name, TH2F *source)
1085 {
1086  return book2D(pwd_, name, static_cast<TH2F *>(source->Clone(name)));
1087 }
1088 
1092 {
1093  return book2D(pwd_, name, static_cast<TH2F *>(source->Clone(name.c_str())));
1094 }
1095 
1098 DQMStore::book2S(const char *name, TH2S *source)
1099 {
1100  return book2S(pwd_, name, static_cast<TH2S *>(source->Clone(name)));
1101 }
1102 
1106 {
1107  return book2S(pwd_, name, static_cast<TH2S *>(source->Clone(name.c_str())));
1108 }
1109 
1112 DQMStore::book2DD(const char *name, TH2D *source)
1113 {
1114  return book2DD(pwd_, name, static_cast<TH2D *>(source->Clone(name)));
1115 }
1116 
1120 {
1121  return book2DD(pwd_, name, static_cast<TH2D *>(source->Clone(name.c_str())));
1122 }
1123 
1124 // -------------------------------------------------------------------
1128 {
1129  return book(dir, name, "book3D", MonitorElement::DQM_KIND_TH3F, h, collate3D);
1130 }
1131 
1134 DQMStore::book3D(const char *name, const char *title,
1135  int nchX, double lowX, double highX,
1136  int nchY, double lowY, double highY,
1137  int nchZ, double lowZ, double highZ)
1138 {
1139  return book3D(pwd_, name, new TH3F(name, title,
1140  nchX, lowX, highX,
1141  nchY, lowY, highY,
1142  nchZ, lowZ, highZ));
1143 }
1144 
1148  int nchX, double lowX, double highX,
1149  int nchY, double lowY, double highY,
1150  int nchZ, double lowZ, double highZ)
1151 {
1152  return book3D(pwd_, name, new TH3F(name.c_str(), title.c_str(),
1153  nchX, lowX, highX,
1154  nchY, lowY, highY,
1155  nchZ, lowZ, highZ));
1156 }
1157 
1160 DQMStore::book3D(const char *name, TH3F *source)
1161 {
1162  return book3D(pwd_, name, static_cast<TH3F *>(source->Clone(name)));
1163 }
1164 
1168 {
1169  return book3D(pwd_, name, static_cast<TH3F *>(source->Clone(name.c_str())));
1170 }
1171 
1172 // -------------------------------------------------------------------
1176 {
1177  return book(dir, name, "bookProfile",
1179  h, collateProfile);
1180 }
1181 
1186 DQMStore::bookProfile(const char *name, const char *title,
1187  int nchX, double lowX, double highX,
1188  int /* nchY */, double lowY, double highY,
1189  const char *option /* = "s" */)
1190 {
1191  return bookProfile(pwd_, name, new TProfile(name, title,
1192  nchX, lowX, highX,
1193  lowY, highY,
1194  option));
1195 }
1196 
1202  int nchX, double lowX, double highX,
1203  int /* nchY */, double lowY, double highY,
1204  const char *option /* = "s" */)
1205 {
1206  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1207  nchX, lowX, highX,
1208  lowY, highY,
1209  option));
1210 }
1211 
1216 DQMStore::bookProfile(const char *name, const char *title,
1217  int nchX, double lowX, double highX,
1218  double lowY, double highY,
1219  const char *option /* = "s" */)
1220 {
1221  return bookProfile(pwd_, name, new TProfile(name, title,
1222  nchX, lowX, highX,
1223  lowY, highY,
1224  option));
1225 }
1226 
1232  int nchX, double lowX, double highX,
1233  double lowY, double highY,
1234  const char *option /* = "s" */)
1235 {
1236  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1237  nchX, lowX, highX,
1238  lowY, highY,
1239  option));
1240 }
1241 
1246 DQMStore::bookProfile(const char *name, const char *title,
1247  int nchX, double *xbinsize,
1248  int /* nchY */, double lowY, double highY,
1249  const char *option /* = "s" */)
1250 {
1251  return bookProfile(pwd_, name, new TProfile(name, title,
1252  nchX, xbinsize,
1253  lowY, highY,
1254  option));
1255 }
1256 
1262  int nchX, double *xbinsize,
1263  int /* nchY */, double lowY, double highY,
1264  const char *option /* = "s" */)
1265 {
1266  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1267  nchX, xbinsize,
1268  lowY, highY,
1269  option));
1270 }
1271 
1276 DQMStore::bookProfile(const char *name, const char *title,
1277  int nchX, double *xbinsize,
1278  double lowY, double highY,
1279  const char *option /* = "s" */)
1280 {
1281  return bookProfile(pwd_, name, new TProfile(name, title,
1282  nchX, xbinsize,
1283  lowY, highY,
1284  option));
1285 }
1286 
1292  int nchX, double *xbinsize,
1293  double lowY, double highY,
1294  const char *option /* = "s" */)
1295 {
1296  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1297  nchX, xbinsize,
1298  lowY, highY,
1299  option));
1300 }
1301 
1304 DQMStore::bookProfile(const char *name, TProfile *source)
1305 {
1306  return bookProfile(pwd_, name, static_cast<TProfile *>(source->Clone(name)));
1307 }
1308 
1312 {
1313  return bookProfile(pwd_, name, static_cast<TProfile *>(source->Clone(name.c_str())));
1314 }
1315 
1316 // -------------------------------------------------------------------
1320 {
1321  return book(dir, name, "bookProfile2D",
1323  h, collateProfile2D);
1324 }
1325 
1330 DQMStore::bookProfile2D(const char *name, const char *title,
1331  int nchX, double lowX, double highX,
1332  int nchY, double lowY, double highY,
1333  int /* nchZ */, double lowZ, double highZ,
1334  const char *option /* = "s" */)
1335 {
1336  return bookProfile2D(pwd_, name, new TProfile2D(name, title,
1337  nchX, lowX, highX,
1338  nchY, lowY, highY,
1339  lowZ, highZ,
1340  option));
1341 }
1342 
1348  int nchX, double lowX, double highX,
1349  int nchY, double lowY, double highY,
1350  int /* nchZ */, double lowZ, double highZ,
1351  const char *option /* = "s" */)
1352 {
1353  return bookProfile2D(pwd_, name, new TProfile2D(name.c_str(), title.c_str(),
1354  nchX, lowX, highX,
1355  nchY, lowY, highY,
1356  lowZ, highZ,
1357  option));
1358 }
1359 
1364 DQMStore::bookProfile2D(const char *name, const char *title,
1365  int nchX, double lowX, double highX,
1366  int nchY, double lowY, double highY,
1367  double lowZ, double highZ,
1368  const char *option /* = "s" */)
1369 {
1370  return bookProfile2D(pwd_, name, new TProfile2D(name, title,
1371  nchX, lowX, highX,
1372  nchY, lowY, highY,
1373  lowZ, highZ,
1374  option));
1375 }
1376 
1382  int nchX, double lowX, double highX,
1383  int nchY, double lowY, double highY,
1384  double lowZ, double highZ,
1385  const char *option /* = "s" */)
1386 {
1387  return bookProfile2D(pwd_, name, new TProfile2D(name.c_str(), title.c_str(),
1388  nchX, lowX, highX,
1389  nchY, lowY, highY,
1390  lowZ, highZ,
1391  option));
1392 }
1393 
1396 DQMStore::bookProfile2D(const char *name, TProfile2D *source)
1397 {
1398  return bookProfile2D(pwd_, name, static_cast<TProfile2D *>(source->Clone(name)));
1399 }
1400 
1404 {
1405  return bookProfile2D(pwd_, name, static_cast<TProfile2D *>(source->Clone(name.c_str())));
1406 }
1407 
1411 bool
1413 {
1414  if (me->getTH1()->GetNbinsX() != h->GetNbinsX()
1415  || me->getTH1()->GetNbinsY() != h->GetNbinsY()
1416  || me->getTH1()->GetNbinsZ() != h->GetNbinsZ()
1417  || me->getTH1()->GetXaxis()->GetXmin() != h->GetXaxis()->GetXmin()
1418  || me->getTH1()->GetYaxis()->GetXmin() != h->GetYaxis()->GetXmin()
1419  || me->getTH1()->GetZaxis()->GetXmin() != h->GetZaxis()->GetXmin()
1420  || me->getTH1()->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax()
1421  || me->getTH1()->GetYaxis()->GetXmax() != h->GetYaxis()->GetXmax()
1422  || me->getTH1()->GetZaxis()->GetXmax() != h->GetZaxis()->GetXmax())
1423  {
1424  // edm::LogWarning ("DQMStore")
1425  std::cout << "*** DQMStore: WARNING:"
1426  << "checkBinningMatches: different binning - cannot add object '"
1427  << h->GetName() << "' of type "
1428  << h->IsA()->GetName() << " to existing ME: '"
1429  << me->getFullname() << "'\n";
1430  return false;
1431  }
1432  return true;
1433 }
1434 
1435 void
1437 {
1438  if (checkBinningMatches(me,h))
1439  me->getTH1F()->Add(h);
1440 }
1441 
1442 void
1444 {
1445  if (checkBinningMatches(me,h))
1446  me->getTH1S()->Add(h);
1447 }
1448 
1449 void
1451 {
1452  if (checkBinningMatches(me,h))
1453  me->getTH1D()->Add(h);
1454 }
1455 
1456 void
1458 {
1459  if (checkBinningMatches(me,h))
1460  me->getTH2F()->Add(h);
1461 }
1462 
1463 void
1465 {
1466  if (checkBinningMatches(me,h))
1467  me->getTH2S()->Add(h);
1468 }
1469 
1470 void
1472 {
1473  if (checkBinningMatches(me,h))
1474  me->getTH2D()->Add(h);
1475 }
1476 
1477 void
1479 {
1480  if (checkBinningMatches(me,h))
1481  me->getTH3F()->Add(h);
1482 }
1483 
1484 void
1486 {
1487  if (checkBinningMatches(me,h))
1488  {
1489  TProfile *meh = me->getTProfile();
1490  me->addProfiles(h, meh, meh, 1, 1);
1491  }
1492 }
1493 
1494 void
1496 {
1497  if (checkBinningMatches(me,h))
1498  {
1499  TProfile2D *meh = me->getTProfile2D();
1500  me->addProfiles(h, meh, meh, 1, 1);
1501  }
1502 }
1503 
1508 void
1509 DQMStore::tag(MonitorElement *me, unsigned int myTag)
1510 {
1511  if (! myTag)
1512  raiseDQMError("DQMStore", "Attempt to tag monitor element '%s'"
1513  " with a zero tag", me->getFullname().c_str());
1514  if ((me->data_.flags & DQMNet::DQM_PROP_TAGGED) && myTag != me->data_.tag)
1515  raiseDQMError("DQMStore", "Attempt to tag monitor element '%s'"
1516  " twice with multiple tags", me->getFullname().c_str());
1517 
1518  me->data_.tag = myTag;
1520 }
1521 
1523 void
1524 DQMStore::tag(const std::string &path, unsigned int myTag)
1525 {
1526  std::string dir;
1527  std::string name;
1528  splitPath(dir, name, path);
1529 
1530  if (MonitorElement *me = findObject(dir, name))
1531  tag(me, myTag);
1532  else
1533  raiseDQMError("DQMStore", "Attempt to tag non-existent monitor element"
1534  " '%s' with tag %u", path.c_str(), myTag);
1535 
1536 }
1537 
1539 void
1540 DQMStore::tagContents(const std::string &path, unsigned int myTag)
1541 {
1542  MonitorElement proto(&path, std::string());
1543  MEMap::iterator e = data_.end();
1544  MEMap::iterator i = data_.lower_bound(proto);
1545  for ( ; i != e && path == *i->data_.dirname; ++i)
1546  tag(const_cast<MonitorElement *>(&*i), myTag);
1547 }
1548 
1551 void
1552 DQMStore::tagAllContents(const std::string &path, unsigned int myTag)
1553 {
1555  const std::string *cleaned = 0;
1556  cleanTrailingSlashes(path, clean, cleaned);
1557  MonitorElement proto(cleaned, std::string());
1558 
1559  // FIXME: WILDCARDS? Old one supported them, but nobody seemed to use them.
1560  MEMap::iterator e = data_.end();
1561  MEMap::iterator i = data_.lower_bound(proto);
1562  while (i != e && isSubdirectory(*cleaned, *i->data_.dirname))
1563  {
1564  tag(const_cast<MonitorElement *>(&*i), myTag);
1565  ++i;
1566  }
1567 }
1568 
1573 std::vector<std::string>
1575 {
1576  std::vector<std::string> result;
1577  std::set<std::string>::const_iterator e = dirs_.end();
1578  std::set<std::string>::const_iterator i = dirs_.find(pwd_);
1579 
1580  // If we didn't find current directory, the tree is empty, so quit.
1581  if (i == e)
1582  return result;
1583 
1584  // Skip the current directory and then start looking for immediate
1585  // subdirectories in the dirs_ list. Stop when we are no longer in
1586  // (direct or indirect) subdirectories of pwd_. Note that we don't
1587  // "know" which order the set will sort A/B, A/B/C and A/D.
1588  while (++i != e && isSubdirectory(pwd_, *i))
1589  if (i->find('/', pwd_.size()+1) == std::string::npos)
1590  result.push_back(*i);
1591 
1592  return result;
1593 }
1594 
1596 std::vector<std::string>
1597 DQMStore::getMEs(void) const
1598 {
1599  MonitorElement proto(&pwd_, std::string());
1600  std::vector<std::string> result;
1601  MEMap::const_iterator e = data_.end();
1602  MEMap::const_iterator i = data_.lower_bound(proto);
1603  for ( ; i != e && isSubdirectory(pwd_, *i->data_.dirname); ++i)
1604  if (pwd_ == *i->data_.dirname)
1605  result.push_back(i->getName());
1606 
1607  return result;
1608 }
1609 
1612 bool
1614 {
1615  MonitorElement proto(&path, std::string());
1616  MEMap::const_iterator e = data_.end();
1617  MEMap::const_iterator i = data_.lower_bound(proto);
1618  return (i != e && isSubdirectory(path, *i->data_.dirname));
1619 }
1620 
1624 {
1625  std::string dir;
1626  std::string name;
1627  splitPath(dir, name, path);
1628  MonitorElement proto(&dir, name);
1629  MEMap::const_iterator mepos = data_.find(proto);
1630  return (mepos == data_.end() ? 0
1631  : const_cast<MonitorElement *>(&*mepos));
1632 }
1633 
1635 std::vector<MonitorElement *>
1636 DQMStore::get(unsigned int tag) const
1637 {
1638  // FIXME: Use reverse map [tag -> path] / [tag -> dir]?
1639  std::vector<MonitorElement *> result;
1640  for (MEMap::const_iterator i = data_.begin(), e = data_.end(); i != e; ++i)
1641  {
1642  const MonitorElement &me = *i;
1643  if ((me.data_.flags & DQMNet::DQM_PROP_TAGGED) && me.data_.tag == tag)
1644  result.push_back(const_cast<MonitorElement *>(&me));
1645  }
1646  return result;
1647 }
1648 
1651 std::vector<MonitorElement *>
1653 {
1655  const std::string *cleaned = 0;
1656  cleanTrailingSlashes(path, clean, cleaned);
1657  MonitorElement proto(cleaned, std::string());
1658 
1659  std::vector<MonitorElement *> result;
1660  MEMap::const_iterator e = data_.end();
1661  MEMap::const_iterator i = data_.lower_bound(proto);
1662  for ( ; i != e && isSubdirectory(*cleaned, *i->data_.dirname); ++i)
1663  if (*cleaned == *i->data_.dirname)
1664  result.push_back(const_cast<MonitorElement *>(&*i));
1665 
1666  return result;
1667 }
1668 
1670 std::vector<MonitorElement *>
1671 DQMStore::getContents(const std::string &path, unsigned int tag) const
1672 {
1674  const std::string *cleaned = 0;
1675  cleanTrailingSlashes(path, clean, cleaned);
1676  MonitorElement proto(cleaned, std::string());
1677 
1678  std::vector<MonitorElement *> result;
1679  MEMap::const_iterator e = data_.end();
1680  MEMap::const_iterator i = data_.lower_bound(proto);
1681  for ( ; i != e && isSubdirectory(*cleaned, *i->data_.dirname); ++i)
1682  if (*cleaned == *i->data_.dirname
1683  && (i->data_.flags & DQMNet::DQM_PROP_TAGGED)
1684  && i->data_.tag == tag)
1685  result.push_back(const_cast<MonitorElement *>(&*i));
1686 
1687  return result;
1688 }
1689 
1694 void
1695 DQMStore::getContents(std::vector<std::string> &into, bool showContents /* = true */) const
1696 {
1697  into.clear();
1698  into.reserve(dirs_.size());
1699 
1700  MEMap::const_iterator me = data_.end();
1701  std::set<std::string>::const_iterator di = dirs_.begin();
1702  std::set<std::string>::const_iterator de = dirs_.end();
1703  for ( ; di != de; ++di)
1704  {
1705  MonitorElement proto(&*di, std::string());
1706  MEMap::const_iterator mi = data_.lower_bound(proto);
1707  MEMap::const_iterator m = mi;
1708  size_t sz = di->size() + 2;
1709  size_t nfound = 0;
1710  for ( ; m != me && isSubdirectory(*di, *m->data_.dirname); ++m)
1711  if (*di == *m->data_.dirname)
1712  {
1713  sz += m->data_.objname.size() + 1;
1714  ++nfound;
1715  }
1716 
1717  if (! nfound)
1718  continue;
1719 
1720  std::vector<std::string>::iterator istr
1721  = into.insert(into.end(), std::string());
1722 
1723  if (showContents)
1724  {
1725  istr->reserve(sz);
1726 
1727  *istr += *di;
1728  *istr += ':';
1729  for (sz = 0; mi != m; ++mi)
1730  {
1731  if (*di != *mi->data_.dirname)
1732  continue;
1733 
1734  if (sz > 0)
1735  *istr += ',';
1736 
1737  *istr += mi->data_.objname;
1738  ++sz;
1739  }
1740  }
1741  else
1742  {
1743  istr->reserve(di->size() + 2);
1744  *istr += *di;
1745  *istr += ':';
1746  }
1747  }
1748 }
1749 
1754  const std::string &name,
1755  const uint32_t run /* = 0 */,
1756  const uint32_t lumi /* = 0 */,
1757  const uint32_t streamId /* = 0 */,
1758  const uint32_t moduleId /* = 0 */) const
1759 {
1760  if (dir.find_first_not_of(s_safe) != std::string::npos)
1761  raiseDQMError("DQMStore", "Monitor element path name '%s' uses"
1762  " unacceptable characters", dir.c_str());
1763  if (name.find_first_not_of(s_safe) != std::string::npos)
1764  raiseDQMError("DQMStore", "Monitor element path name '%s' uses"
1765  " unacceptable characters", name.c_str());
1766 
1767  MonitorElement proto;
1768  proto.data_.dirname = &dir;
1769  proto.data_.objname = name;
1770  proto.data_.run = run;
1771  proto.data_.lumi = lumi;
1772  proto.data_.streamId = streamId;
1773  proto.data_.moduleId = moduleId;
1774 
1775  MEMap::const_iterator mepos = data_.find(proto);
1776  return (mepos == data_.end() ? 0
1777  : const_cast<MonitorElement *>(&*mepos));
1778 }
1779 
1782 void
1783 DQMStore::getAllTags(std::vector<std::string> &into) const
1784 {
1785  into.clear();
1786  into.reserve(dirs_.size());
1787 
1788  MEMap::const_iterator me = data_.end();
1789  std::set<std::string>::const_iterator di = dirs_.begin();
1790  std::set<std::string>::const_iterator de = dirs_.end();
1791  char tagbuf[32]; // more than enough for '/' and up to 10 digits
1792 
1793  for ( ; di != de; ++di)
1794  {
1795  MonitorElement proto(&*di, std::string());
1796  MEMap::const_iterator mi = data_.lower_bound(proto);
1797  MEMap::const_iterator m = mi;
1798  size_t sz = di->size() + 2;
1799  size_t nfound = 0;
1800  for ( ; m != me && isSubdirectory(*di, *m->data_.dirname); ++m)
1801  if (*di == *m->data_.dirname && (m->data_.flags & DQMNet::DQM_PROP_TAGGED))
1802  {
1803  // the tags count for '/' + up to 10 digits, otherwise ',' + ME name
1804  sz += 1 + m->data_.objname.size() + 11;
1805  ++nfound;
1806  }
1807 
1808  if (! nfound)
1809  continue;
1810 
1811  std::vector<std::string>::iterator istr
1812  = into.insert(into.end(), std::string());
1813 
1814  istr->reserve(sz);
1815 
1816  *istr += *di;
1817  *istr += ':';
1818  for (sz = 0; mi != m; ++mi)
1819  {
1820  if (*di == *m->data_.dirname && (m->data_.flags & DQMNet::DQM_PROP_TAGGED))
1821  {
1822  sprintf(tagbuf, "/%u", mi->data_.tag);
1823  if (sz > 0)
1824  *istr += ',';
1825  *istr += m->data_.objname;
1826  *istr += tagbuf;
1827  ++sz;
1828  }
1829  }
1830  }
1831 }
1832 
1835 std::vector<MonitorElement*>
1837  uint32_t runNumber /* = 0 */,
1838  uint32_t lumi /* = 0 */) const
1839 {
1841  const std::string *cleaned = 0;
1842  cleanTrailingSlashes(path, clean, cleaned);
1843  MonitorElement proto(cleaned, std::string(), runNumber);
1844  proto.setLumi(lumi);
1845 
1846  std::vector<MonitorElement *> result;
1847  MEMap::const_iterator e = data_.end();
1848  MEMap::const_iterator i = data_.lower_bound(proto);
1849  for ( ; i != e && isSubdirectory(*cleaned, *i->data_.dirname); ++i) {
1850  if (runNumber != 0) {
1851  if (i->data_.run > runNumber // TODO[rovere]: pleonastic? first we encounter local ME of the same run ...
1852  || i->data_.streamId != 0
1853  || i->data_.moduleId != 0)
1854  break;
1855  }
1856  if (lumi != 0) {
1857  if (i->data_.lumi > lumi
1858  || i->data_.streamId != 0
1859  || i->data_.moduleId != 0)
1860  break;
1861  }
1862  if (runNumber != 0 or lumi !=0) {
1863  assert(i->data_.streamId == 0);
1864  assert(i->data_.moduleId == 0);
1865  }
1866  result.push_back(const_cast<MonitorElement *>(&*i));
1867  }
1868  return result;
1869 }
1870 
1873 std::vector<MonitorElement*>
1874 DQMStore::getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType /* = Wildcard */) const
1875 {
1876  lat::Regexp rx;
1877  try
1878  {
1879  rx = lat::Regexp(pattern, 0, syntaxType);
1880  rx.study();
1881  }
1882  catch (lat::Error &e)
1883  {
1884  raiseDQMError("DQMStore", "Invalid regular expression '%s': %s",
1885  pattern.c_str(), e.explain().c_str());
1886  }
1887 
1888  std::string path;
1889  std::vector<MonitorElement *> result;
1890  MEMap::const_iterator i = data_.begin();
1891  MEMap::const_iterator e = data_.end();
1892  for ( ; i != e; ++i)
1893  {
1894  path.clear();
1895  mergePath(path, *i->data_.dirname, i->data_.objname);
1896  if (rx.match(path))
1897  result.push_back(const_cast<MonitorElement *>(&*i));
1898  }
1899 
1900  return result;
1901 }
1902 
1906 
1909 void
1911 {
1912  MEMap::iterator mi = data_.begin();
1913  MEMap::iterator me = data_.end();
1914  for ( ; mi != me; ++mi)
1915  {
1916  MonitorElement &me = const_cast<MonitorElement &>(*mi);
1917  if (mi->wasUpdated())
1918  {
1919  if (me.resetMe())
1920  me.Reset();
1921  me.resetUpdate();
1922  }
1923  }
1924 
1925  reset_ = true;
1926 }
1927 
1931 
1933 void
1935 {
1936  MEMap::iterator mi = data_.begin();
1937  MEMap::iterator me = data_.end();
1938  for ( ; mi != me; ++mi)
1939  {
1940  MonitorElement &me = const_cast<MonitorElement &>(*mi);
1941  me.Reset();
1942  me.resetUpdate();
1943  }
1944 
1945  reset_ = true;
1946 }
1947 
1953 bool
1954 DQMStore::extract(TObject *obj, const std::string &dir, bool overwrite)
1955 {
1956  // NB: Profile histograms inherit from TH*D, checking order matters.
1957  MonitorElement *refcheck = 0;
1958  if (TProfile *h = dynamic_cast<TProfile *>(obj))
1959  {
1960  MonitorElement *me = findObject(dir, h->GetName());
1961  if (! me)
1962  me = bookProfile(dir, h->GetName(), (TProfile *) h->Clone());
1963  else if (overwrite)
1964  me->copyFrom(h);
1965  else if (isCollateME(me) || collateHistograms_)
1966  collateProfile(me, h);
1967  refcheck = me;
1968  }
1969  else if (TProfile2D *h = dynamic_cast<TProfile2D *>(obj))
1970  {
1971  MonitorElement *me = findObject(dir, h->GetName());
1972  if (! me)
1973  me = bookProfile2D(dir, h->GetName(), (TProfile2D *) h->Clone());
1974  else if (overwrite)
1975  me->copyFrom(h);
1976  else if (isCollateME(me) || collateHistograms_)
1977  collateProfile2D(me, h);
1978  refcheck = me;
1979  }
1980  else if (TH1F *h = dynamic_cast<TH1F *>(obj))
1981  {
1982  MonitorElement *me = findObject(dir, h->GetName());
1983  if (! me)
1984  me = book1D(dir, h->GetName(), (TH1F *) h->Clone());
1985  else if (overwrite)
1986  me->copyFrom(h);
1987  else if (isCollateME(me) || collateHistograms_)
1988  collate1D(me, h);
1989  refcheck = me;
1990  }
1991  else if (TH1S *h = dynamic_cast<TH1S *>(obj))
1992  {
1993  MonitorElement *me = findObject(dir, h->GetName());
1994  if (! me)
1995  me = book1S(dir, h->GetName(), (TH1S *) h->Clone());
1996  else if (overwrite)
1997  me->copyFrom(h);
1998  else if (isCollateME(me) || collateHistograms_)
1999  collate1S(me, h);
2000  refcheck = me;
2001  }
2002  else if (TH1D *h = dynamic_cast<TH1D *>(obj))
2003  {
2004  MonitorElement *me = findObject(dir, h->GetName());
2005  if (! me)
2006  me = book1DD(dir, h->GetName(), (TH1D *) h->Clone());
2007  else if (overwrite)
2008  me->copyFrom(h);
2009  else if (isCollateME(me) || collateHistograms_)
2010  collate1DD(me, h);
2011  refcheck = me;
2012  }
2013  else if (TH2F *h = dynamic_cast<TH2F *>(obj))
2014  {
2015  MonitorElement *me = findObject(dir, h->GetName());
2016  if (! me)
2017  me = book2D(dir, h->GetName(), (TH2F *) h->Clone());
2018  else if (overwrite)
2019  me->copyFrom(h);
2020  else if (isCollateME(me) || collateHistograms_)
2021  collate2D(me, h);
2022  refcheck = me;
2023  }
2024  else if (TH2S *h = dynamic_cast<TH2S *>(obj))
2025  {
2026  MonitorElement *me = findObject(dir, h->GetName());
2027  if (! me)
2028  me = book2S(dir, h->GetName(), (TH2S *) h->Clone());
2029  else if (overwrite)
2030  me->copyFrom(h);
2031  else if (isCollateME(me) || collateHistograms_)
2032  collate2S(me, h);
2033  refcheck = me;
2034  }
2035  else if (TH2D *h = dynamic_cast<TH2D *>(obj))
2036  {
2037  MonitorElement *me = findObject(dir, h->GetName());
2038  if (! me)
2039  me = book2DD(dir, h->GetName(), (TH2D *) h->Clone());
2040  else if (overwrite)
2041  me->copyFrom(h);
2042  else if (isCollateME(me) || collateHistograms_)
2043  collate2DD(me, h);
2044  refcheck = me;
2045  }
2046  else if (TH3F *h = dynamic_cast<TH3F *>(obj))
2047  {
2048  MonitorElement *me = findObject(dir, h->GetName());
2049  if (! me)
2050  me = book3D(dir, h->GetName(), (TH3F *) h->Clone());
2051  else if (overwrite)
2052  me->copyFrom(h);
2053  else if (isCollateME(me) || collateHistograms_)
2054  collate3D(me, h);
2055  refcheck = me;
2056  }
2057  else if (dynamic_cast<TObjString *>(obj))
2058  {
2059  lat::RegexpMatch m;
2060  if (! s_rxmeval.match(obj->GetName(), 0, 0, &m))
2061  {
2062  if (strstr(obj->GetName(), "CMSSW"))
2063  {
2064  if (verbose_)
2065  std::cout << "Input file version: " << obj->GetName() << std::endl;
2066  return true;
2067  }
2068  else if (strstr(obj->GetName(), "DQMPATCH"))
2069  {
2070  if (verbose_)
2071  std::cout << "DQM patch version: " << obj->GetName() << std::endl;
2072  return true;
2073  }
2074  else
2075  {
2076  std::cout << "*** DQMStore: WARNING: cannot extract object '"
2077  << obj->GetName() << "' of type '"
2078  << obj->IsA()->GetName() << "'\n";
2079  return false;
2080  }
2081  }
2082 
2083  std::string label = m.matchString(obj->GetName(), 1);
2084  std::string kind = m.matchString(obj->GetName(), 2);
2085  std::string value = m.matchString(obj->GetName(), 3);
2086 
2087  if (kind == "i")
2088  {
2089  MonitorElement *me = findObject(dir, label);
2090  if (! me || overwrite)
2091  {
2092  if (! me) me = bookInt(dir, label);
2093  me->Fill(atoll(value.c_str()));
2094  }
2095  }
2096  else if (kind == "f")
2097  {
2098  MonitorElement *me = findObject(dir, label);
2099  if (! me || overwrite)
2100  {
2101  if (! me) me = bookFloat(dir, label);
2102  me->Fill(atof(value.c_str()));
2103  }
2104  }
2105  else if (kind == "s")
2106  {
2107  MonitorElement *me = findObject(dir, label);
2108  if (! me)
2109  me = bookString(dir, label, value);
2110  else if (overwrite)
2111  me->Fill(value);
2112  }
2113  else if (kind == "e")
2114  {
2115  MonitorElement *me = findObject(dir, label);
2116  if (! me)
2117  {
2118  std::cout << "*** DQMStore: WARNING: no monitor element '"
2119  << label << "' in directory '"
2120  << dir << "' to be marked as efficiency plot.\n";
2121  return false;
2122  }
2123  me->setEfficiencyFlag();
2124  }
2125  else if (kind == "t")
2126  {
2127  MonitorElement *me = findObject(dir, label);
2128  if (! me)
2129  {
2130  std::cout << "*** DQMStore: WARNING: no monitor element '"
2131  << label << "' in directory '"
2132  << dir << "' for a tag\n";
2133  return false;
2134  }
2135  errno = 0;
2136  char *endp = 0;
2137  unsigned long val = strtoul(value.c_str(), &endp, 10);
2138  if ((val == 0 && errno) || *endp || val > ~uint32_t(0))
2139  {
2140  std::cout << "*** DQMStore: WARNING: cannot restore tag '"
2141  << value << "' for monitor element '"
2142  << label << "' in directory '"
2143  << dir << "' - invalid value\n";
2144  return false;
2145  }
2146  tag(me, val);
2147  }
2148  else if (kind == "qr")
2149  {
2150  // Handle qreports, but skip them while reading in references.
2151  if (! isSubdirectory(s_referenceDirName, dir))
2152  {
2153  size_t dot = label.find('.');
2154  if (dot == std::string::npos)
2155  {
2156  std::cout << "*** DQMStore: WARNING: quality report label in '" << label
2157  << "' is missing a '.' and cannot be extracted\n";
2158  return false;
2159  }
2160 
2161  std::string mename (label, 0, dot);
2162  std::string qrname (label, dot+1, std::string::npos);
2163 
2164  m.reset();
2165  DQMNet::QValue qv;
2166  if (s_rxmeqr1.match(value, 0, 0, &m))
2167  {
2168  qv.code = atoi(m.matchString(value, 1).c_str());
2169  qv.qtresult = strtod(m.matchString(value, 2).c_str(), 0);
2170  qv.message = m.matchString(value, 4);
2171  qv.qtname = qrname;
2172  qv.algorithm = m.matchString(value, 3);
2173  }
2174  else if (s_rxmeqr2.match(value, 0, 0, &m))
2175  {
2176  qv.code = atoi(m.matchString(value, 1).c_str());
2177  qv.qtresult = 0; // unavailable in old format
2178  qv.message = m.matchString(value, 2);
2179  qv.qtname = qrname;
2180  // qv.algorithm unavailable in old format
2181  }
2182  else
2183  {
2184  std::cout << "*** DQMStore: WARNING: quality test value '"
2185  << value << "' is incorrectly formatted\n";
2186  return false;
2187  }
2188 
2189  MonitorElement *me = findObject(dir, mename);
2190  if (! me)
2191  {
2192  std::cout << "*** DQMStore: WARNING: no monitor element '"
2193  << mename << "' in directory '"
2194  << dir << "' for quality test '"
2195  << label << "'\n";
2196  return false;
2197  }
2198 
2199  me->addQReport(qv, /* FIXME: getQTest(qv.qtname)? */ 0);
2200  }
2201  }
2202  else
2203  {
2204  std::cout << "*** DQMStore: WARNING: cannot extract object '"
2205  << obj->GetName() << "' of type '"
2206  << obj->IsA()->GetName() << "'\n";
2207  return false;
2208  }
2209  }
2210  else if (TNamed *n = dynamic_cast<TNamed *>(obj))
2211  {
2212  // For old DQM data.
2213  std::string s;
2214  s.reserve(6 + strlen(n->GetTitle()) + 2*strlen(n->GetName()));
2215  s += '<'; s += n->GetName(); s += '>';
2216  s += n->GetTitle();
2217  s += '<'; s += '/'; s += n->GetName(); s += '>';
2218  TObjString os(s.c_str());
2219  return extract(&os, dir, overwrite);
2220  }
2221  else
2222  {
2223  std::cout << "*** DQMStore: WARNING: cannot extract object '"
2224  << obj->GetName() << "' of type '" << obj->IsA()->GetName()
2225  << "' and with title '" << obj->GetTitle() << "'\n";
2226  return false;
2227  }
2228 
2229  // If we just read in a reference monitor element, and there is a
2230  // monitor element with the same name, link the two together. The
2231  // other direction is handled by the initialise() method.
2232  if (refcheck && isSubdirectory(s_referenceDirName, dir))
2233  {
2234  std::string mdir(dir, s_referenceDirName.size()+1, std::string::npos);
2235  if (MonitorElement *master = findObject(mdir, obj->GetName()))
2236  {
2237  master->data_.flags |= DQMNet::DQM_PROP_HAS_REFERENCE;
2238  master->reference_ = refcheck->object_;
2239  }
2240  }
2241 
2242  return true;
2243 }
2244 
2248 bool
2250 {
2251  assert(! path.empty());
2252 
2253  // Find the first path component.
2254  size_t start = 0;
2255  size_t end = path.find('/', start);
2256  if (end == std::string::npos)
2257  end = path.size();
2258 
2259  while (true)
2260  {
2261  // Check if this subdirectory component exists. If yes, make sure
2262  // it is actually a subdirectory. Otherwise create or cd into it.
2263  std::string part(path, start, end-start);
2264  TObject *o = gDirectory->Get(part.c_str());
2265  if (o && ! dynamic_cast<TDirectory *>(o))
2266  raiseDQMError("DQMStore", "Attempt to create directory '%s' in a file"
2267  " fails because the part '%s' already exists and is not"
2268  " directory", path.c_str(), part.c_str());
2269  else if (! o)
2270  gDirectory->mkdir(part.c_str());
2271 
2272  if (! gDirectory->cd(part.c_str()))
2273  raiseDQMError("DQMStore", "Attempt to create directory '%s' in a file"
2274  " fails because could not cd into subdirectory '%s'",
2275  path.c_str(), part.c_str());
2276 
2277  // Stop if we reached the end, ignoring any trailing '/'.
2278  if (end+1 >= path.size())
2279  break;
2280 
2281  // Find the next path component.
2282  start = end+1;
2283  end = path.find('/', start);
2284  if (end == std::string::npos)
2285  end = path.size();
2286  }
2287 
2288  return true;
2289 }
2290 
2295 void
2297  const std::string &path /* = "" */,
2298  const std::string &pattern /* = "" */,
2299  const std::string &rewrite /* = "" */,
2300  const uint32_t run /* = 0 */,
2301  SaveReferenceTag ref /* = SaveWithReference */,
2302  int minStatus /* = dqm::qstatus::STATUS_OK */,
2303  const std::string &fileupdate /* = RECREATE */)
2304 {
2305  std::set<std::string>::iterator di, de;
2306  MEMap::iterator mi, me = data_.end();
2307  DQMNet::QReports::const_iterator qi, qe;
2308  int nme=0;
2309 
2310  // TFile flushes to disk with fsync() on every TDirectory written to the
2311  // file. This makes DQM file saving painfully slow, and ironically makes
2312  // it _more_ likely the file saving gets interrupted and corrupts the file.
2313  // The utility class below simply ignores the flush synchronisation.
2314  class TFileNoSync : public TFile
2315  {
2316  public:
2317  TFileNoSync(const char *file, const char *opt) : TFile(file, opt) {}
2318  virtual Int_t SysSync(Int_t) override { return 0; }
2319  };
2320 
2321  // open output file, on 1st save recreate, later update
2322  if (verbose_)
2323  std::cout << "\n DQMStore: Opening TFile '" << filename
2324  << "' with option '" << fileupdate <<"'\n";
2325 
2326  TFileNoSync f(filename.c_str(), fileupdate.c_str()); // open file
2327  if(f.IsZombie())
2328  raiseDQMError("DQMStore", "Failed to create/update file '%s'", filename.c_str());
2329  f.cd();
2330 
2331  // Construct a regular expression from the pattern string.
2332  std::auto_ptr<lat::Regexp> rxpat;
2333  if (! pattern.empty())
2334  rxpat.reset(new lat::Regexp(pattern.c_str()));
2335 
2336  // Prepare a path for the reference object selection.
2337  std::string refpath;
2338  refpath.reserve(s_referenceDirName.size() + path.size() + 2);
2339  refpath += s_referenceDirName;
2340  if (! path.empty())
2341  {
2342  refpath += '/';
2343  refpath += path;
2344  }
2345 
2346  // Loop over the directory structure.
2347  for (di = dirs_.begin(), de = dirs_.end(); di != de; ++di)
2348  {
2349  // Check if we should process this directory. We process the
2350  // requested part of the object tree, including references.
2351  if (! path.empty()
2352  && ! isSubdirectory(path, *di)
2353  && ! isSubdirectory(refpath, *di))
2354  continue;
2355 
2356  // Loop over monitor elements in this directory.
2357  MonitorElement proto(&*di, std::string(), run, 0, 0);
2358  mi = data_.lower_bound(proto);
2359  for ( ; mi != me && isSubdirectory(*di, *mi->data_.dirname); ++mi)
2360  {
2361  if (verbose_ > 1)
2362  std::cout << "Run: " << (*mi).run()
2363  << " Lumi: " << (*mi).lumi()
2364  << " LumiFlag: " << (*mi).getLumiFlag()
2365  << " streamId: " << (*mi).streamId()
2366  << " moduleId: " << (*mi).moduleId()
2367  << " fullpathname: " << (*mi).getPathname() << std::endl;
2368  // Skip if it isn't a direct child.
2369  if (*di != *mi->data_.dirname)
2370  continue;
2371 
2372  // Keep backward compatibility with the old way of
2373  // booking/handlind MonitorElements into the DQMStore. If run is
2374  // 0 it means that a booking happened w/ the old non-threadsafe
2375  // style, and we have to ignore the streamId and moduleId as a
2376  // consequence.
2377 
2378  if (run != 0 && (mi->data_.streamId !=0 || mi->data_.moduleId !=0))
2379  continue;
2380 
2381  // Handle reference histograms, with three distinct cases:
2382  // 1) Skip all references entirely on saving.
2383  // 2) Blanket saving of all references.
2384  // 3) Save only references for monitor elements with qtests.
2385  // The latter two are affected by "path" sub-tree selection,
2386  // i.e. references are saved only in the selected tree part.
2387  if (isSubdirectory(refpath, *mi->data_.dirname))
2388  {
2389  if (ref == SaveWithoutReference)
2390  // Skip the reference entirely.
2391  continue;
2392  else if (ref == SaveWithReference)
2393  // Save all references regardless of qtests.
2394  ;
2395  else if (ref == SaveWithReferenceForQTest)
2396  {
2397  // Save only references for monitor elements with qtests
2398  // with an optional cut on minimum quality test result.
2399  int status = -1;
2400  std::string mname(mi->getFullname(), s_referenceDirName.size()+1, std::string::npos);
2401  MonitorElement *master = get(mname);
2402  if (master)
2403  for (size_t i = 0, e = master->data_.qreports.size(); i != e; ++i)
2404  status = std::max(status, master->data_.qreports[i].code);
2405 
2406  if (! master || status < minStatus)
2407  {
2408  if (verbose_ > 1)
2409  std::cout << "DQMStore::save: skipping monitor element '"
2410  << mi->data_.objname << "' while saving, status is "
2411  << status << ", required minimum status is "
2412  << minStatus << std::endl;
2413  continue;
2414  }
2415  }
2416  }
2417 
2418  if (verbose_ > 1)
2419  std::cout << "DQMStore::save: saving monitor element '"
2420  << mi->data_.objname << "'\n";
2421  nme++; // count saved histograms
2422 
2423  // Create the directory.
2424  gDirectory->cd("/");
2425  if (di->empty())
2427  else if (rxpat.get())
2428  cdInto(s_monitorDirName + '/' + lat::StringOps::replace(*di, *rxpat, rewrite));
2429  else
2430  cdInto(s_monitorDirName + '/' + *di);
2431 
2432  // Save the object.
2433  switch (mi->kind())
2434  {
2438  TObjString(mi->tagString().c_str()).Write();
2439  break;
2440 
2441  default:
2442  mi->object_->Write();
2443  break;
2444  }
2445 
2446  // Save quality reports if this is not in reference section.
2447  if (! isSubdirectory(s_referenceDirName, *mi->data_.dirname))
2448  {
2449  qi = mi->data_.qreports.begin();
2450  qe = mi->data_.qreports.end();
2451  for ( ; qi != qe; ++qi)
2452  TObjString(mi->qualityTagString(*qi).c_str()).Write();
2453  }
2454 
2455  // Save efficiency tag, if any
2456  if (mi->data_.flags & DQMNet::DQM_PROP_EFFICIENCY_PLOT)
2457  TObjString(mi->effLabelString().c_str()).Write();
2458 
2459  // Save tag if any
2460  if (mi->data_.flags & DQMNet::DQM_PROP_TAGGED)
2461  TObjString(mi->tagLabelString().c_str()).Write();
2462  }
2463  }
2464 
2465  f.Close();
2466 
2467  // Maybe make some noise.
2468  if (verbose_)
2469  std::cout << "DQMStore::save: successfully wrote " << nme
2470  << " objects from path '" << path
2471  << "' into DQM file '" << filename << "'\n";
2472 }
2473 
2476 unsigned int
2478  bool overwrite,
2479  const std::string &onlypath,
2480  const std::string &prepend,
2481  const std::string &curdir,
2482  OpenRunDirs stripdirs)
2483 {
2484  unsigned int ntot = 0;
2485  unsigned int count = 0;
2486 
2487  if (! file->cd(curdir.c_str()))
2488  raiseDQMError("DQMStore", "Failed to process directory '%s' while"
2489  " reading file '%s'", curdir.c_str(), file->GetName());
2490 
2491  // Figure out current directory name, but strip out the top
2492  // directory into which we dump everything.
2493  std::string dirpart = curdir;
2494  if (dirpart.compare(0, s_monitorDirName.size(), s_monitorDirName) == 0)
2495  {
2496  if (dirpart.size() == s_monitorDirName.size())
2497  dirpart.clear();
2498  else if (dirpart[s_monitorDirName.size()] == '/')
2499  dirpart.erase(0, s_monitorDirName.size()+1);
2500  }
2501 
2502  // See if we are going to skip this directory.
2503  bool skip = (! onlypath.empty() && ! isSubdirectory(onlypath, dirpart));
2504 
2505  if (prepend == s_collateDirName ||
2506  prepend == s_referenceDirName ||
2507  stripdirs == StripRunDirs )
2508  {
2509  // Remove Run # and RunSummary dirs
2510  // first look for Run summary,
2511  // if that is found and erased, also erase Run dir
2512  size_t slash = dirpart.find('/');
2513  size_t pos = dirpart.find("/Run summary");
2514  if (slash != std::string::npos && pos !=std::string::npos)
2515  {
2516  dirpart.erase(pos,12);
2517 
2518  pos = dirpart.find("Run ");
2519  size_t length = dirpart.find('/',pos+1)-pos+1;
2520  if (pos !=std::string::npos)
2521  dirpart.erase(pos,length);
2522  }
2523  }
2524 
2525  // If we are prepending, add it to the directory name,
2526  // and suppress reading of already existing reference histograms
2527  if (prepend == s_collateDirName ||
2528  prepend == s_referenceDirName)
2529  {
2530  size_t slash = dirpart.find('/');
2531  // If we are reading reference, skip previous reference.
2532  if (slash == std::string::npos // skip if Reference is toplevel folder, i.e. no slash
2533  && slash+1+s_referenceDirName.size() == dirpart.size()
2534  && dirpart.compare(slash+1, s_referenceDirName.size(), s_referenceDirName) == 0)
2535  return 0;
2536 
2537  slash = dirpart.find('/');
2538  // Skip reading of EventInfo subdirectory.
2539  if (slash != std::string::npos
2540  && slash + 10 == dirpart.size()
2541  && dirpart.compare( slash+1 , 9 , "EventInfo") == 0) {
2542  if (verbose_)
2543  std::cout << "DQMStore::readDirectory: skipping '" << dirpart << "'\n";
2544  return 0;
2545  }
2546 
2547  // Add prefix.
2548  if (dirpart.empty())
2549  dirpart = prepend;
2550  else
2551  dirpart = prepend + '/' + dirpart;
2552  }
2553  else if (! prepend.empty())
2554  {
2555  if (dirpart.empty())
2556  dirpart = prepend;
2557  else
2558  dirpart = prepend + '/' + dirpart;
2559  }
2560 
2561  // Loop over the contents of this directory in the file.
2562  // Post-pone string object handling to happen after other
2563  // objects have been read in so we are guaranteed to have
2564  // histograms by the time we read in quality tests and tags.
2565  TKey *key;
2566  TIter next (gDirectory->GetListOfKeys());
2567  std::list<TObject *> delayed;
2568  while ((key = (TKey *) next()))
2569  {
2570  std::auto_ptr<TObject> obj(key->ReadObj());
2571  if (dynamic_cast<TDirectory *>(obj.get()))
2572  {
2573  std::string subdir;
2574  subdir.reserve(curdir.size() + strlen(obj->GetName()) + 2);
2575  subdir += curdir;
2576  if (! curdir.empty())
2577  subdir += '/';
2578  subdir += obj->GetName();
2579 
2580  ntot += readDirectory(file, overwrite, onlypath, prepend, subdir, stripdirs);
2581  }
2582  else if (skip)
2583  ;
2584  else if (dynamic_cast<TObjString *>(obj.get()))
2585  {
2586  delayed.push_back(obj.release());
2587  }
2588  else
2589  {
2590  if (verbose_ > 2)
2591  std::cout << "DQMStore: reading object '" << obj->GetName()
2592  << "' of type '" << obj->IsA()->GetName()
2593  << "' from '" << file->GetName()
2594  << "' into '" << dirpart << "'\n";
2595 
2596  makeDirectory(dirpart);
2597  if (extract(obj.get(), dirpart, overwrite))
2598  ++count;
2599  }
2600  }
2601 
2602  while (! delayed.empty())
2603  {
2604  if (verbose_ > 2)
2605  std::cout << "DQMStore: reading object '" << delayed.front()->GetName()
2606  << "' of type '" << delayed.front()->IsA()->GetName()
2607  << "' from '" << file->GetName()
2608  << "' into '" << dirpart << "'\n";
2609 
2610  makeDirectory(dirpart);
2611  if (extract(delayed.front(), dirpart, overwrite))
2612  ++count;
2613 
2614  delete delayed.front();
2615  delayed.pop_front();
2616  }
2617 
2618  if (verbose_ > 1)
2619  std::cout << "DQMStore: read " << count << '/' << ntot
2620  << " objects from directory '" << dirpart << "'\n";
2621 
2622  return ntot + count;
2623 }
2624 
2631 bool
2633  bool overwrite /* = false */,
2634  const std::string &onlypath /* ="" */,
2635  const std::string &prepend /* ="" */,
2636  OpenRunDirs stripdirs /* =KeepRunDirs */,
2637  bool fileMustExist /* =true */)
2638 {
2639  return readFile(filename,overwrite,onlypath,prepend,stripdirs,fileMustExist);
2640 }
2641 
2646 bool
2648  OpenRunDirs stripdirs /* =StripRunDirs */,
2649  bool fileMustExist /* =true */)
2650 {
2651  bool overwrite = true;
2652  if (collateHistograms_) overwrite = false;
2653  if (verbose_)
2654  {
2655  std::cout << "DQMStore::load: reading from file '" << filename << "'\n";
2656  if (collateHistograms_)
2657  std::cout << "DQMStore::load: in collate mode " << "\n";
2658  else
2659  std::cout << "DQMStore::load: in overwrite mode " << "\n";
2660  }
2661 
2662  return readFile(filename,overwrite,"","",stripdirs,fileMustExist);
2663 
2664 }
2665 
2671 bool
2673  bool overwrite /* = false */,
2674  const std::string &onlypath /* ="" */,
2675  const std::string &prepend /* ="" */,
2676  OpenRunDirs stripdirs /* =StripRunDirs */,
2677  bool fileMustExist /* =true */)
2678 {
2679 
2680  if (verbose_)
2681  std::cout << "DQMStore::readFile: reading from file '" << filename << "'\n";
2682 
2683  std::auto_ptr<TFile> f;
2684 
2685  try
2686  {
2687  f.reset(TFile::Open(filename.c_str()));
2688  if (! f.get() || f->IsZombie())
2689  raiseDQMError("DQMStore", "Failed to open file '%s'", filename.c_str());
2690  }
2691  catch (std::exception &)
2692  {
2693  if (fileMustExist)
2694  throw;
2695  else
2696  {
2697  if (verbose_)
2698  std::cout << "DQMStore::readFile: file '" << filename << "' does not exist, continuing\n";
2699  return false;
2700  }
2701  }
2702 
2703  unsigned n = readDirectory(f.get(), overwrite, onlypath, prepend, "", stripdirs);
2704  f->Close();
2705 
2706  MEMap::iterator mi = data_.begin();
2707  MEMap::iterator me = data_.end();
2708  for ( ; mi != me; ++mi)
2709  const_cast<MonitorElement &>(*mi).updateQReportStats();
2710 
2711  if (verbose_)
2712  {
2713  std::cout << "DQMStore::open: successfully read " << n
2714  << " objects from file '" << filename << "'";
2715  if (! onlypath.empty())
2716  std::cout << " from directory '" << onlypath << "'";
2717  if (! prepend.empty())
2718  std::cout << " into directory '" << prepend << "'";
2719  std::cout << std::endl;
2720  }
2721  return true;
2722 }
2723 
2729 void
2731 {
2733  const std::string *cleaned = 0;
2734  cleanTrailingSlashes(path, clean, cleaned);
2735  MonitorElement proto(cleaned, std::string());
2736 
2737  MEMap::iterator e = data_.end();
2738  MEMap::iterator i = data_.lower_bound(proto);
2739  while (i != e && isSubdirectory(*cleaned, *i->data_.dirname))
2740  data_.erase(i++);
2741 
2742  std::set<std::string>::iterator de = dirs_.end();
2743  std::set<std::string>::iterator di = dirs_.lower_bound(*cleaned);
2744  while (di != de && isSubdirectory(*cleaned, *di))
2745  dirs_.erase(di++);
2746 }
2747 
2749 void
2751 {
2752  MonitorElement proto(&dir, std::string());
2753  MEMap::iterator e = data_.end();
2754  MEMap::iterator i = data_.lower_bound(proto);
2755  while (i != e && isSubdirectory(dir, *i->data_.dirname))
2756  if (dir == *i->data_.dirname)
2757  data_.erase(i++);
2758  else
2759  ++i;
2760 }
2761 
2763 void
2765 {
2767 }
2768 
2771 void
2773 {
2774  removeElement(pwd_, name);
2775 }
2776 
2779 void
2781 {
2782  MonitorElement proto(&dir, name);
2783  MEMap::iterator pos = data_.find(proto);
2784  if (pos == data_.end() && warning)
2785  std::cout << "DQMStore: WARNING: attempt to remove non-existent"
2786  << " monitor element '" << name << "' in '" << dir << "'\n";
2787  else
2788  data_.erase(pos);
2789 }
2790 
2796 QCriterion *
2798 {
2799  QCMap::const_iterator i = qtests_.find(qtname);
2800  QCMap::const_iterator e = qtests_.end();
2801  return (i == e ? 0 : i->second);
2802 }
2803 
2807 QCriterion *
2808 DQMStore::createQTest(const std::string &algoname, const std::string &qtname)
2809 {
2810  if (qtests_.count(qtname))
2811  raiseDQMError("DQMStore", "Attempt to create duplicate quality test '%s'",
2812  qtname.c_str());
2813 
2814  QAMap::iterator i = qalgos_.find(algoname);
2815  if (i == qalgos_.end())
2816  raiseDQMError("DQMStore", "Cannot create a quality test using unknown"
2817  " algorithm '%s'", algoname.c_str());
2818 
2819  QCriterion *qc = i->second(qtname);
2820  qc->setVerbose(verboseQT_);
2821 
2822  qtests_[qtname] = qc;
2823  return qc;
2824 }
2825 
2828 void
2830 {
2831  // Clean the path
2833  const std::string *cleaned = 0;
2834  cleanTrailingSlashes(dir, clean, cleaned);
2835 
2836  // Validate the path.
2837  if (cleaned->find_first_not_of(s_safe) != std::string::npos)
2838  raiseDQMError("DQMStore", "Monitor element path name '%s'"
2839  " uses unacceptable characters", cleaned->c_str());
2840 
2841  // Redirect to the pattern match version.
2842  useQTestByMatch(*cleaned + "/*", qtname);
2843 }
2844 
2846 int
2848 {
2849  QCriterion *qc = getQCriterion(qtname);
2850  if (! qc)
2851  raiseDQMError("DQMStore", "Cannot apply non-existent quality test '%s'",
2852  qtname.c_str());
2853 
2854  fastmatch * fm = new fastmatch( pattern );
2855 
2856  // Record the test for future reference.
2857  QTestSpec qts(fm, qc);
2858  qtestspecs_.push_back(qts);
2859 
2860  // Apply the quality test.
2861  MEMap::iterator mi = data_.begin();
2862  MEMap::iterator me = data_.end();
2863  std::string path;
2864  int cases = 0;
2865  for ( ; mi != me; ++mi)
2866  {
2867  path.clear();
2868  mergePath(path, *mi->data_.dirname, mi->data_.objname);
2869  if (fm->match(path))
2870  {
2871  ++cases;
2872  const_cast<MonitorElement &>(*mi).addQReport(qts.second);
2873  }
2874  }
2875 
2876  //return the number of matched cases
2877  return cases;
2878 }
2881 void
2883 {
2884 
2885  if (verbose_ > 0)
2886  std::cout << "DQMStore: running runQTests() with reset = "
2887  << ( reset_ ? "true" : "false" ) << std::endl;
2888 
2889  // Apply quality tests to each monitor element, skipping references.
2890  MEMap::iterator mi = data_.begin();
2891  MEMap::iterator me = data_.end();
2892  for ( ; mi != me; ++mi)
2893  if (! isSubdirectory(s_referenceDirName, *mi->data_.dirname))
2894  const_cast<MonitorElement &>(*mi).runQTests();
2895 
2896  reset_ = false;
2897 }
2898 
2902 int
2903 DQMStore::getStatus(const std::string &path /* = "" */) const
2904 {
2906  const std::string *cleaned = 0;
2907  cleanTrailingSlashes(path, clean, cleaned);
2908 
2910  MEMap::const_iterator mi = data_.begin();
2911  MEMap::const_iterator me = data_.end();
2912  for ( ; mi != me; ++mi)
2913  {
2914  if (! cleaned->empty() && ! isSubdirectory(*cleaned, *mi->data_.dirname))
2915  continue;
2916 
2917  if (mi->hasError())
2918  return dqm::qstatus::ERROR;
2919  else if (mi->hasWarning())
2920  status = dqm::qstatus::WARNING;
2921  else if (status < dqm::qstatus::WARNING
2922  && mi->hasOtherReport())
2923  status = dqm::qstatus::OTHER;
2924  }
2925  return status;
2926 }
2927 
2933 void
2935 {
2936  if (me)
2937  me->softReset();
2938 }
2939 
2940 // reverts action of softReset
2941 void
2943 {
2944  if (me)
2945  me->disableSoftReset();
2946 }
2947 
2950 void
2952 {
2953  if (me)
2954  me->setAccumulate(flag);
2955 }
2956 
2960 void
2962 {
2963  std::vector<std::string> contents;
2964  getContents(contents);
2965 
2966  std::cout << " ------------------------------------------------------------\n"
2967  << " Directory structure: \n"
2968  << " ------------------------------------------------------------\n";
2969 
2970  std::copy(contents.begin(), contents.end(),
2971  std::ostream_iterator<std::string>(std::cout, "\n"));
2972 
2973  std::cout << " ------------------------------------------------------------\n";
2974 }
2975 
2979 // check if the collate option is active on the DQMStore
2980 bool
2982 {
2983  return collateHistograms_;
2984 }
2988 // check if the monitor element is in auto-collation folder
2989 bool
2991 { return me && isSubdirectory(s_collateDirName, *me->data_.dirname); }
2995 
2997 void
2999 {
3000  if (scaleFlag_ == 0.0) return;
3001  if (verbose_ > 0)
3002  std::cout << " =========== " << " ScaleFlag " << scaleFlag_ << std::endl;
3003  double factor = scaleFlag_;
3004  int events = 1;
3005  if (dirExists("Info/EventInfo")) {
3006  if ( scaleFlag_ == -1.0) {
3007  MonitorElement * scale_me = get("Info/EventInfo/ScaleFactor");
3008  if (scale_me && scale_me->kind()==MonitorElement::DQM_KIND_REAL) factor = scale_me->getFloatValue();
3009  }
3010  MonitorElement * event_me = get("Info/EventInfo/processedEvents");
3011  if (event_me && event_me->kind()==MonitorElement::DQM_KIND_INT) events = event_me->getIntValue();
3012  }
3013  factor = factor/(events*1.0);
3014 
3015  MEMap::iterator mi = data_.begin();
3016  MEMap::iterator me = data_.end();
3017  for ( ; mi != me; ++mi)
3018  {
3019  MonitorElement &me = const_cast<MonitorElement &>(*mi);
3020  switch (me.kind())
3021  {
3023  {
3024  me.getTH1F()->Scale(factor);
3025  break;
3026  }
3028  {
3029  me.getTH1S()->Scale(factor);
3030  break;
3031  }
3033  {
3034  me.getTH1D()->Scale(factor);
3035  break;
3036  }
3038  {
3039  me.getTH2F()->Scale(factor);
3040  break;
3041  }
3043  {
3044  me.getTH2S()->Scale(factor);
3045  break;
3046  }
3048  {
3049  me.getTH2D()->Scale(factor);
3050  break;
3051  }
3053  {
3054  me.getTH3F()->Scale(factor);
3055  break;
3056  }
3058  {
3059  me.getTProfile()->Scale(factor);
3060  break;
3061  }
3063  {
3064  me.getTProfile2D()->Scale(factor);
3065  break;
3066  }
3067  default:
3068  if (verbose_ > 0)
3069  std::cout << " The DQM object '" << me.getFullname() << "' is not scalable object " << std::endl;
3070  continue;
3071  }
3072  }
3073 }
3074 
3075 // Local Variables:
3076 // show-trailing-whitespace: t
3077 // truncate-lines: t
3078 // End:
static void collateProfile2D(MonitorElement *me, TProfile2D *h)
Definition: DQMStore.cc:1495
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:2797
bool compare_strings_reverse(std::string const &pattern, std::string const &input) const
Definition: DQMStore.cc:198
std::pair< fastmatch *, QCriterion * > QTestSpec
Definition: DQMStore.h:588
TH2S * getTH2S(void) const
TH1S * getTH1S(void) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
DQMStore(const edm::ParameterSet &pset, edm::ActivityRegistry &)
Definition: DQMStore.cc:391
static const lat::Regexp s_rxmeqr2("^st\\.(\\d+)\\.(.*)$")
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:1022
bool containsAnyMonitorable(const std::string &path) const
Definition: DQMStore.cc:1613
uint32_t moduleId
Definition: DQMNet.h:103
bool isCollateME(MonitorElement *me) const
Definition: DQMStore.cc:2990
void resetUpdate(void)
reset &quot;was updated&quot; flag
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
bool cdInto(const std::string &path) const
Definition: DQMStore.cc:2249
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:2903
void copyFrom(TH1 *from)
MonitorElement * initialise(Kind kind)
static const int OTHER
static void mergePath(std::string &path, const std::string &dir, const std::string &name)
Definition: DQMStore.cc:101
std::string algorithm
Definition: DQMNet.h:92
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1574
TProfile2D * getTProfile2D(void) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
bool match(std::string const &s) const
Definition: DQMStore.cc:240
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:2672
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:1753
static void collate3D(MonitorElement *me, TH3F *h)
Definition: DQMStore.cc:1478
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:1134
static void collate1D(MonitorElement *me, TH1F *h)
Definition: DQMStore.cc:1436
void setLumi(uint32_t ls)
void cd(void)
Definition: DQMStore.cc:258
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:561
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:1044
uint32_t streamId_
Definition: DQMStore.h:602
tuple lumi
Definition: fjr2json.py:35
static void collate1DD(MonitorElement *me, TH1D *h)
Definition: DQMStore.cc:1450
static const std::string s_safe
Definition: DQMStore.cc:50
static void splitPath(std::string &dir, std::string &name, const std::string &path)
Definition: DQMStore.cc:88
uint32_t flags
Definition: DQMNet.h:97
void disableSoftReset(void)
reverts action of softReset
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
Definition: DQMStore.cc:1874
static const int WARNING
TH3F * getTH3F(void) const
static const uint32_t DQM_PROP_TAGGED
Definition: DQMNet.h:54
TH1D * getTH1D(void) const
MatchingHeuristicEnum matching_
Definition: DQMStore.h:67
void runQTests(void)
run all quality tests
#define NULL
Definition: scimark2.h:8
static const uint32_t DQM_PROP_EFFICIENCY_PLOT
Definition: DQMNet.h:63
void softReset(void)
TH2D * getTH2D(void) const
uint32_t tag
Definition: DQMNet.h:98
bool reset_
Definition: DQMStore.h:596
const std::string * dirname
Definition: DQMNet.h:104
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:904
void initializeFrom(const edm::ParameterSet &)
Definition: DQMStore.cc:441
OpenRunDirs
Definition: DQMStore.h:79
uint32_t run
Definition: DQMNet.h:100
uint32_t moduleId_
Definition: DQMStore.h:603
void initQCriterion(std::map< std::string, QCriterion *(*)(const std::string &)> &m)
Definition: DQMStore.cc:117
QCMap qtests_
Definition: DQMStore.h:609
static const std::string s_collateDirName
Definition: DQMStore.cc:49
MonitorElement * book(const std::string &dir, const std::string &name, const char *context)
Definition: DQMStore.cc:727
static const std::string s_monitorDirName
name of global monitoring folder (containing all sources subdirectories)
Definition: DQMStore.cc:47
std::mutex book_mutex_
Definition: DQMStore.h:613
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:809
static std::string const input
Definition: EdmProvDump.cc:44
SaveReferenceTag
Definition: DQMStore.h:73
static const lat::Regexp s_rxtrace("(.*)\\((.*)\\+0x.*\\).*")
void Fill(long long x)
static void cleanTrailingSlashes(const std::string &path, std::string &clean, const std::string *&cleaned)
Definition: DQMStore.cc:71
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1509
~DQMStore(void)
Definition: DQMStore.cc:430
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:2942
static void collateProfile(MonitorElement *me, TProfile *h)
Definition: DQMStore.cc:1485
static const lat::Regexp s_rxmeval("^<(.*)>(i|f|s|e|t|qr)=(.*)</\\1>$")
void forceReset(void)
Definition: DQMStore.cc:1934
static bool isSubdirectory(const std::string &ofdir, const std::string &path)
Definition: DQMStore.cc:61
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1836
fastmatch(std::string const &_fastString)
Definition: DQMStore.cc:122
unsigned verboseQT_
Definition: DQMStore.h:595
bool extract(TObject *obj, const std::string &dir, bool overwrite)
Definition: DQMStore.cc:1954
static const uint32_t DQM_PROP_HAS_REFERENCE
Definition: DQMNet.h:53
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2764
QTestSpecs qtestspecs_
Definition: DQMStore.h:611
double scaleFlag_
Definition: DQMStore.h:597
const T & max(const T &a, const T &b)
void watchPostSourceRun(PostSourceRun::slot_type const &iSlot)
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:838
static void collate1S(MonitorElement *me, TH1S *h)
Definition: DQMStore.cc:1443
void setAccumulate(bool)
uint32_t lumi
Definition: DQMNet.h:101
bool isCollate(void) const
Definition: DQMStore.cc:2981
tuple result
Definition: query.py:137
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
static bool checkBinningMatches(MonitorElement *me, TH1 *h)
Definition: DQMStore.cc:1412
double getFloatValue(void) const
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:270
TH1 * getTH1(void) const
double f[11][100]
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
uint32_t run_
Definition: DQMStore.h:601
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:1186
QCriterion * makeQCriterion(const std::string &qtname)
Definition: DQMStore.cc:112
#define end
Definition: vmac.h:37
void setVerbose(unsigned level)
Definition: DQMStore.cc:548
void softReset(MonitorElement *me)
Definition: DQMStore.cc:2934
std::string pwd_
Definition: DQMStore.h:605
Kind kind(void) const
Get the type of the monitor element.
tuple warning
Definition: accesses.py:3
void runQTests(void)
Definition: DQMStore.cc:2882
lat::Regexp * regexp_
Definition: DQMStore.h:65
IBooker * ibooker_
Definition: DQMStore.h:614
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1623
QAMap qalgos_
Definition: DQMStore.h:610
const std::string getFullname(void) const
get full name of ME including Pathname
std::vector< MonitorElement * > getContents(const std::string &path) const
Definition: DQMStore.cc:1652
std::string readSelectedDirectory_
Definition: DQMStore.h:600
std::string objname
Definition: DQMNet.h:105
void mergeAndResetMEsRunSummaryCache(uint32_t run, uint32_t streamId, uint32_t moduleId)
Definition: DQMStore.cc:285
std::string fastString_
Definition: DQMStore.h:66
std::vector< T * > clean
Definition: MVATrainer.cc:156
std::string qtname
Definition: DQMNet.h:91
DQMNet::CoreObject data_
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:648
void getAllTags(std::vector< std::string > &into) const
Definition: DQMStore.cc:1783
bool load(const std::string &filename, OpenRunDirs stripdirs=StripRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2647
void scaleElements(void)
Definition: DQMStore.cc:2998
~fastmatch()
Definition: DQMStore.cc:192
void tagAllContents(const std::string &path, unsigned int myTag)
Definition: DQMStore.cc:1552
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:266
MonitorElement * initialise(MonitorElement *me, const std::string &path)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
unsigned verbose_
Definition: DQMStore.h:594
static void collate2S(MonitorElement *me, TH2S *h)
Definition: DQMStore.cc:1464
MEMap data_
Definition: DQMStore.h:606
part
Definition: HCALResponse.h:20
int64_t getIntValue(void) const
static void collate2D(MonitorElement *me, TH2F *h)
Definition: DQMStore.cc:1457
static const std::string s_referenceDirName
Definition: DQMStore.cc:48
void print_trace(const std::string &dir, const std::string &name)
Definition: DQMStore.cc:497
int useQTestByMatch(const std::string &pattern, const std::string &qtname)
attach quality test &lt;qc&gt; to monitor elements matching &lt;pattern&gt;.
Definition: DQMStore.cc:2847
TH1F * getTH1F(void) const
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1597
DQMStore * owner_
Definition: DQMStore.h:179
bool resetMe(void) const
true if ME should be reset at end of monitoring cycle
unsigned int readDirectory(TFile *file, bool overwrite, const std::string &path, const std::string &prepend, const std::string &curdir, OpenRunDirs stripdirs)
Definition: DQMStore.cc:2477
void setVerbose(int verbose)
probability limits for warnings, errors
Definition: QTest.h:116
static void collate2DD(MonitorElement *me, TH2D *h)
Definition: DQMStore.cc:1471
T dot(const Basic3DVector &v) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
void tagContents(const std::string &path, unsigned int myTag)
tag all children of folder (does NOT include subfolders)
Definition: DQMStore.cc:1540
list key
Definition: combine.py:13
tuple events
Definition: patZpeak.py:19
TProfile * getTProfile(void) const
void useQTest(const std::string &dir, const std::string &qtname)
Definition: DQMStore.cc:2829
tuple filename
Definition: lut2db_cfg.py:20
std::string message
Definition: DQMNet.h:90
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:595
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:2632
static const int STATUS_OK
void setAccumulate(MonitorElement *me, bool flag)
Definition: DQMStore.cc:2951
tuple cout
Definition: gather_cfg.py:121
void setEfficiencyFlag(void)
void Reset(std::vector< TH2F > &depth)
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:2808
dbl *** dir
Definition: mlp_gen.cc:35
volatile std::atomic< bool > shutdown_flag false
void showDirStructure(void) const
Definition: DQMStore.cc:2961
void reset(void)
Definition: DQMStore.cc:1910
tuple status
Definition: ntuplemaker.py:245
TH2F * getTH2F(void) const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:779
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:1000
long double T
uint32_t streamId
Definition: DQMNet.h:102
void mergeAndResetMEsLuminositySummaryCache(uint32_t run, uint32_t lumi, uint32_t streamId, uint32_t moduleId)
Definition: DQMStore.cc:336
float qtresult
Definition: DQMNet.h:89
std::set< std::string > dirs_
Definition: DQMStore.h:607
bool collateHistograms_
Definition: DQMStore.h:598
void Reset(void)
reset ME (ie. contents, errors, etc)
static std::string const source
Definition: EdmProvDump.cc:43
void addQReport(const DQMNet::QValue &desc, QCriterion *qc)
Add quality report, from DQMStore.
MonitorElement * book1S(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:888
tuple size
Write out results.
static const lat::Regexp s_rxmeqr1("^st:(\\d+):([-+e.\\d]+):([^:]*):(.*)$")
void makeDirectory(const std::string &path)
get folder corresponding to inpath wrt to root (create subdirs if necessary)
Definition: DQMStore.cc:607
bool compare_strings(std::string const &pattern, std::string const &input) const
Definition: DQMStore.cc:219
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
static const int ERROR
const std::string & pwd(void) const
Definition: DQMStore.cc:556
bool enableMultiThread_
Definition: DQMStore.h:599
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:1330
void raiseDQMError(const char *context, const char *fmt,...)
Definition: DQMError.cc:11