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.
7 #include "classlib/utils/RegexpMatch.h"
8 #include "classlib/utils/Regexp.h"
9 #include "classlib/utils/StringOps.h"
10 #include <google/protobuf/io/coded_stream.h>
11 #include <google/protobuf/io/gzip_stream.h>
12 #include <google/protobuf/io/zero_copy_stream_impl.h>
13 #include "TFile.h"
14 #include "TROOT.h"
15 #include "TKey.h"
16 #include "TClass.h"
17 #include "TSystem.h"
18 #include "TBufferFile.h"
19 #include <iterator>
20 #include <cerrno>
21 #include <boost/algorithm/string.hpp>
22 
23 #include <fstream>
24 #include <sstream>
25 #include <exception>
26 
53 static const std::string s_monitorDirName = "DQMData";
56 static const std::string s_referenceDirName = "Reference";
57 static const std::string s_collateDirName = "Collate";
58 static const std::string s_safe = "/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_()# ";
59 
60 static const lat::Regexp s_rxmeval ("^<(.*)>(i|f|s|e|t|qr)=(.*)</\\1>$");
61 static const lat::Regexp s_rxmeqr1 ("^st:(\\d+):([-+e.\\d]+):([^:]*):(.*)$");
62 static const lat::Regexp s_rxmeqr2 ("^st\\.(\\d+)\\.(.*)$");
63 static const lat::Regexp s_rxtrace ("(.*)\\((.*)\\+0x.*\\).*");
64 static const lat::Regexp s_rxpbfile (".*\\.pb$");
65 
69 static bool
71 {
72  return (ofdir.empty()
73  || (path.size() >= ofdir.size()
74  && path.compare(0, ofdir.size(), ofdir) == 0
75  && (path.size() == ofdir.size()
76  || path[ofdir.size()] == '/')));
77 }
78 
79 static void
81 {
82  clean.clear();
83  cleaned = &path;
84 
85  size_t len = path.size();
86  for ( ; len > 0 && path[len-1] == '/'; --len)
87  ;
88 
89  if (len != path.size())
90  {
91  clean = path.substr(0, len);
92  cleaned = &clean;
93  }
94 }
95 
96 static void
98 {
99  size_t slash = path.rfind('/');
100  if (slash != std::string::npos)
101  {
102  dir.append(path, 0, slash);
103  name.append(path, slash+1, std::string::npos);
104  }
105  else
106  name = path;
107 }
108 
109 static void
111 {
112  path.reserve(dir.size() + name.size() + 2);
113  path += dir;
114  if (! path.empty())
115  path += '/';
116  path += name;
117 }
118 
119 template <class T>
120 QCriterion *
122 { return new T(qtname); }
123 
124 template <class T>
125 void
127 { m[T::getAlgoName()] = &makeQCriterion<T>; }
128 
129 
131 fastmatch::fastmatch (std::string const& _fastString) :
132  fastString_ (_fastString), matching_ (UseFull)
133 {
134  try
135  {
136  regexp_ = NULL;
137  regexp_ = new lat::Regexp(fastString_, 0, lat::Regexp::Wildcard);
138  regexp_->study();
139  }
140  catch (lat::Error &e)
141  {
142  delete regexp_;
143  raiseDQMError("DQMStore", "Invalid wildcard pattern '%s' in quality"
144  " test specification", fastString_.c_str());
145  }
146 
147  // count stars ( "*" )
148  size_t starCount = 0;
149  int pos = -1;
150  while (true)
151  {
152  pos = fastString_.find("*", pos + 1 );
153  if ((size_t)pos == std::string::npos)
154  break;
155  starCount ++;
156  }
157 
158  // investigate for heuristics
159  if ((fastString_.find('"') != std::string::npos) ||
160  (fastString_.find(']') != std::string::npos) ||
161  (fastString_.find('?') != std::string::npos) ||
162  (fastString_.find('\\') != std::string::npos) ||
163  (starCount > 2))
164  {
165  // no fast version can be used
166  return;
167  }
168 
169  // match for pattern "*MyString" and "MyString*"
170  if (starCount == 1)
171  {
172  if (boost::algorithm::starts_with(fastString_, "*"))
173  {
175  fastString_.erase(0,1);
176  return;
177  }
178 
179  if (boost::algorithm::ends_with(fastString_, "*"))
180  {
182  fastString_.erase(fastString_.length()-1,1);
183  return;
184  }
185  }
186 
187  // match for pattern "*MyString*"
188  if (starCount == 2)
189  {
190  if (boost::algorithm::starts_with(fastString_, "*") &&
191  boost::algorithm::ends_with(fastString_, "*"))
192  {
193  matching_ = TwoStar;
194  fastString_.erase(0,1);
195  fastString_.erase(fastString_.size() - 1, 1);
196  return;
197  }
198  }
199 }
200 
202 {
203  if (regexp_ != NULL)
204  delete regexp_;
205 }
206 
208  std::string const& input) const
209 {
210  if (input.size() < pattern.size())
211  return false;
212 
213  // compare the two strings character by character for equalness:
214  // this does not create uneeded copies of std::string. The
215  // boost::algorithm implementation does
216  std::string::const_reverse_iterator rit_pattern = pattern.rbegin();
217  std::string::const_reverse_iterator rit_input = input.rbegin();
218 
219  for (; rit_pattern < pattern.rend(); rit_pattern++, rit_input++)
220  {
221  if (*rit_pattern != *rit_input)
222  // found a difference, fail
223  return false;
224  }
225  return true;
226 }
227 
229  std::string const& input) const
230 {
231  if (input.size() < pattern.size())
232  return false;
233 
234  // compare the two strings character by character for equalness:
235  // this does not create uneeded copies of std::string. The
236  // boost::algorithm implementation does.
237  std::string::const_iterator rit_pattern = pattern.begin();
238  std::string::const_iterator rit_input = input.begin();
239 
240  for (; rit_pattern < pattern.end(); rit_pattern++, rit_input++)
241  {
242  if (*rit_pattern != *rit_input)
243  // found a difference, fail
244  return false;
245  }
246  return true;
247 }
248 
249 bool fastmatch::match(std::string const& s) const
250 {
251  switch (matching_)
252  {
253  case OneStarStart:
255 
256  case OneStarEnd:
257  return compare_strings(fastString_, s);
258 
259  case TwoStar:
260  return (s.find(fastString_) != std::string::npos);
261 
262  default:
263  return regexp_->match(s);
264  }
265 }
266 
267 //IBooker methods
269  owner_->cd();
270 }
271 
273  owner_->cd(dir);
274 }
275 
277  owner_->setCurrentFolder(fullpath);
278 }
279 
281  owner_->goUp();
282 }
283 
285  return owner_->pwd();
286 }
287 
289  owner_->tag(me, tag);
290 }
291 
292 void DQMStore::IBooker::tagContents(const std::string &path, unsigned int myTag) {
293  owner_->tagContents(path, myTag);
294 }
295 
296 //IGetter methods
297 std::vector<MonitorElement*>
299  uint32_t runNumber /* = 0 */,
300  uint32_t lumi /* = 0 */) {
301  return owner_->getAllContents(path, runNumber, lumi);
302 }
303 
305  return owner_->get(path);
306 }
307 
309  MonitorElement *ptr = this->get(path);
310  if (ptr == nullptr) {
311  std::stringstream msg;
312  msg << "DQM object not found";
313 
314  msg << ": " << path;
315 
316  // can't use cms::Exception inside DQMStore
317  throw std::out_of_range(msg.str());
318  }
319  return ptr;
320 }
321 
322 std::vector<std::string> DQMStore::IGetter::getSubdirs(void) {
323  return owner_->getSubdirs();
324 }
325 
326 std::vector<std::string> DQMStore::IGetter::getMEs(void) {
327  return owner_->getMEs();
328 }
329 
331  return owner_->containsAnyMonitorable(path);
332 }
333 
335  return owner_->dirExists(path);
336 }
337 
339  owner_->cd();
340 }
341 
343  owner_->cd(dir);
344 }
345 
347  owner_->setCurrentFolder(fullpath);
348 }
349 
360  uint32_t streamId,
361  uint32_t moduleId) {
362  if (verbose_ > 1)
363  std::cout << "DQMStore::mergeAndResetMEsRunSummaryCache - Merging objects from run: "
364  << run
365  << ", stream: " << streamId
366  << " module: " << moduleId << std::endl;
367 
368  if (LSbasedMode_) {
369  return;
370  }
371 
372  std::string null_str("");
373  MonitorElement proto(&null_str, null_str, run, streamId, moduleId);
374  std::set<MonitorElement>::const_iterator e = data_.end();
375  std::set<MonitorElement>::const_iterator i = data_.lower_bound(proto);
376  while (i != e) {
377  if (i->data_.run != run
378  || i->data_.streamId != streamId
379  || i->data_.moduleId != moduleId)
380  break;
381 
382  // Handle Run-based histograms only.
383  if (i->getLumiFlag() || LSbasedMode_) {
384  ++i;
385  continue;
386  }
387 
388  // don't call the copy constructor
389  // we are just searching for a global histogram - a copy is not necessary
390  MonitorElement global_me(*i, MonitorElementNoCloneTag());
391  global_me.globalize();
392 
393  // Since this accesses the data, the operation must be
394  // be locked.
395  std::lock_guard<std::mutex> guard(book_mutex_);
396  std::set<MonitorElement>::const_iterator me = data_.find(global_me);
397  if (me != data_.end()) {
398  if (verbose_ > 1)
399  std::cout << "Found global Object, using it --> " << me->getFullname() << std::endl;
400 
401  //don't take any action if the ME is an INT || FLOAT || STRING
402  if(me->kind() >= MonitorElement::DQM_KIND_TH1F)
403  {
404  if(me->getTH1()->CanExtendAllAxes() && i->getTH1()->CanExtendAllAxes()) {
405  TList list;
406  list.Add(i->getTH1());
407  if( -1 == me->getTH1()->Merge(&list)) {
408  std::cout << "mergeAndResetMEsRunSummaryCache: Failed to merge DQM element "<<me->getFullname();
409  }
410  }
411  else {
412  if (i->getTH1()->GetEntries())
413  me->getTH1()->Add(i->getTH1());
414  }
415  }
416  } else {
417  if (verbose_ > 1)
418  std::cout << "No global Object found. " << std::endl;
419  std::pair<std::set<MonitorElement>::const_iterator, bool> gme;
420 
421  // this makes an actual and a single copy with Clone()'ed th1
422  MonitorElement actual_global_me(*i);
423  actual_global_me.globalize();
424  gme = data_.insert(std::move(actual_global_me));
425  assert(gme.second);
426  }
427  // TODO(rovere): eventually reset the local object and mark it as reusable??
428  ++i;
429  }
430 }
431 
433  uint32_t lumi,
434  uint32_t streamId,
435  uint32_t moduleId) {
436  if (verbose_ > 1)
437  std::cout << "DQMStore::mergeAndResetMEsLuminositySummaryCache - Merging objects from run: "
438  << run << " lumi: " << lumi
439  << ", stream: " << streamId
440  << " module: " << moduleId << std::endl;
441  std::string null_str("");
442  MonitorElement proto(&null_str, null_str, run, streamId, moduleId);
443  std::set<MonitorElement>::const_iterator e = data_.end();
444  std::set<MonitorElement>::const_iterator i = data_.lower_bound(proto);
445 
446  while (i != e) {
447  if (i->data_.run != run
448  || i->data_.streamId != streamId
449  || i->data_.moduleId != moduleId)
450  break;
451 
452  // Handle LS-based histograms only.
453  if (not (i->getLumiFlag() || LSbasedMode_)) {
454  ++i;
455  continue;
456  }
457 
458  MonitorElement global_me(*i, MonitorElementNoCloneTag());
459  global_me.globalize();
460  global_me.setLumi(lumi);
461  // Since this accesses the data, the operation must be
462  // be locked.
463  std::lock_guard<std::mutex> guard(book_mutex_);
464  std::set<MonitorElement>::const_iterator me = data_.find(global_me);
465  if (me != data_.end()) {
466  if (verbose_ > 1)
467  std::cout << "Found global Object, using it --> " << me->getFullname() << std::endl;
468 
469  //don't take any action if the ME is an INT || FLOAT || STRING
470  if(me->kind() >= MonitorElement::DQM_KIND_TH1F)
471  {
472  if(me->getTH1()->CanExtendAllAxes() && i->getTH1()->CanExtendAllAxes()) {
473  TList list;
474  list.Add(i->getTH1());
475  if( -1 == me->getTH1()->Merge(&list)) {
476  std::cout << "mergeAndResetMEsLuminositySummaryCache: Failed to merge DQM element "<<me->getFullname();
477  }
478  }
479  else {
480  if (i->getTH1()->GetEntries())
481  me->getTH1()->Add(i->getTH1());
482  }
483  }
484  } else {
485  if (verbose_ > 1)
486  std::cout << "No global Object found. " << std::endl;
487  std::pair<std::set<MonitorElement>::const_iterator, bool> gme;
488 
489  // this makes an actual and a single copy with Clone()'ed th1
490  MonitorElement actual_global_me(*i);
491  actual_global_me.globalize();
492  actual_global_me.setLumi(lumi);
493  gme = data_.insert(std::move(actual_global_me));
494  assert(gme.second);
495  }
496  // make the ME reusable for the next LS
497  const_cast<MonitorElement*>(&*i)->Reset();
498  ++i;
499  }
500 }
501 
504  : verbose_ (1),
505  verboseQT_ (1),
506  reset_ (false),
511  run_(0),
512  streamId_(0),
513  moduleId_(0),
514  stream_(nullptr),
515  pwd_ (""),
516  ibooker_(0),
517  igetter_(0)
518 {
519  if (!ibooker_)
520  ibooker_ = new DQMStore::IBooker(this);
521  if (!igetter_)
522  igetter_ = new DQMStore::IGetter(this);
523  initializeFrom(pset);
524 
525  if(pset.getUntrackedParameter<bool>("forceResetOnBeginRun",false)) {
527  }
528  ar.preallocateSignal_.connect([this](edm::service::SystemBounds const& iBounds) {
529  if(iBounds.maxNumberOfStreams() > 1 ) {
530  enableMultiThread_ = true;
531  }
532  });
533  if(pset.getUntrackedParameter<bool>("forceResetOnBeginLumi",false) && enableMultiThread_ == false) {
534  forceResetOnBeginLumi_ = true;
536  }
537 }
538 
540  : verbose_ (1),
541  verboseQT_ (1),
542  reset_ (false),
543  collateHistograms_ (false),
544  enableMultiThread_(false),
545  readSelectedDirectory_ (""),
546  run_(0),
547  streamId_(0),
548  moduleId_(0),
549  stream_(nullptr),
550  pwd_ (""),
551  ibooker_(0),
552  igetter_(0)
553 {
554  if (!ibooker_)
555  ibooker_ = new DQMStore::IBooker(this);
556  if (!igetter_)
557  igetter_ = new DQMStore::IGetter(this);
558  initializeFrom(pset);
559 }
560 
562 {
563  for (QCMap::iterator i = qtests_.begin(), e = qtests_.end(); i != e; ++i)
564  delete i->second;
565 
566  for (QTestSpecs::iterator i = qtestspecs_.begin(), e = qtestspecs_.end(); i != e; ++i)
567  delete i->first;
568 
569  if (stream_)
570  stream_->close();
571  delete stream_;
572 }
573 
574 void
576  makeDirectory("");
577  reset();
578 
579  // set steerable parameters
580  verbose_ = pset.getUntrackedParameter<int>("verbose", 0);
581  if (verbose_ > 0)
582  std::cout << "DQMStore: verbosity set to " << verbose_ << std::endl;
583 
584  verboseQT_ = pset.getUntrackedParameter<int>("verboseQT", 0);
585  if (verbose_ > 0)
586  std::cout << "DQMStore: QTest verbosity set to " << verboseQT_ << std::endl;
587 
588  collateHistograms_ = pset.getUntrackedParameter<bool>("collateHistograms", false);
589  if (collateHistograms_)
590  std::cout << "DQMStore: histogram collation is enabled\n";
591 
592  enableMultiThread_ = pset.getUntrackedParameter<bool>("enableMultiThread", false);
593  if (enableMultiThread_)
594  std::cout << "DQMStore: MultiThread option is enabled\n";
595 
596  LSbasedMode_ = pset.getUntrackedParameter<bool>("LSbasedMode", false);
597  if (LSbasedMode_)
598  std::cout << "DQMStore: LSbasedMode option is enabled\n";
599 
600  std::string ref = pset.getUntrackedParameter<std::string>("referenceFileName", "");
601  if (! ref.empty())
602  {
603  std::cout << "DQMStore: using reference file '" << ref << "'\n";
604  readFile(ref, true, "", s_referenceDirName, StripRunDirs, false);
605  }
606 
607  initQCriterion<Comp2RefChi2>(qalgos_);
608  initQCriterion<Comp2RefKolmogorov>(qalgos_);
609  initQCriterion<ContentsXRange>(qalgos_);
610  initQCriterion<ContentsYRange>(qalgos_);
611  initQCriterion<MeanWithinExpected>(qalgos_);
612  initQCriterion<Comp2RefEqualH>(qalgos_);
613  initQCriterion<DeadChannel>(qalgos_);
614  initQCriterion<NoisyChannel>(qalgos_);
615  initQCriterion<ContentsWithinExpected>(qalgos_);
616  initQCriterion<CompareToMedian>(qalgos_);
617  initQCriterion<CompareLastFilledBin>(qalgos_);
618  initQCriterion<CheckVariance>(qalgos_);
619 
620  scaleFlag_ = pset.getUntrackedParameter<double>("ScalingFlag", 0.0);
621  if (verbose_ > 0)
622  std::cout << "DQMStore: Scaling Flag set to " << scaleFlag_ << std::endl;
623 }
624 
625 /* Generic method to do a backtrace and print it to stdout. It is
626  customised to properly get the routine that called the booking of the
627  histograms, which, following the usual stack, is at position 4. The
628  name of the calling function is properly demangled and the original
629  shared library including this function is also printed. For a more
630  detailed explanation of the routines involved, see here:
631  http://www.gnu.org/software/libc/manual/html_node/Backtraces.html
632  http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html.*/
633 
634 void
636 {
637  // the access to the member stream_ is implicitely protected against
638  // concurrency problems because the print_trace method is always called behind
639  // a lock (see bookTransaction).
640  if (!stream_)
641  stream_ = new std::ofstream("histogramBookingBT.log");
642 
643  void *array[10];
644  size_t size;
645  char **strings;
646  int r=0;
647  lat::RegexpMatch m;
648  m.reset();
649 
650  size = backtrace (array, 10);
651  strings = backtrace_symbols (array, size);
652 
653  if ((size > 4)
654  &&s_rxtrace.match(strings[4], 0, 0, &m))
655  {
656  char * demangled = abi::__cxa_demangle(m.matchString(strings[4], 2).c_str(), 0, 0, &r);
657  *stream_ << "\"" << dir << "/"
658  << name << "\" "
659  << (r ? m.matchString(strings[4], 2) : demangled) << " "
660  << m.matchString(strings[4], 1) << "\n";
661  free(demangled);
662  }
663  else
664  *stream_ << "Skipping "<< dir << "/" << name
665  << " with stack size " << size << "\n";
666  /* In this case print the full stack trace, up to main or to the
667  * maximum stack size, i.e. 10. */
668  if (verbose_ > 4)
669  {
670  size_t i;
671  m.reset();
672 
673  for (i = 0; i < size; i++)
674  if (s_rxtrace.match(strings[i], 0, 0, &m))
675  {
676  char * demangled = abi::__cxa_demangle(m.matchString(strings[i], 2).c_str(), 0, 0, &r);
677  *stream_ << "\t\t" << i << "/" << size << " "
678  << (r ? m.matchString(strings[i], 2) : demangled) << " "
679  << m.matchString(strings[i], 1) << std::endl;
680  free (demangled);
681  }
682  }
683  free (strings);
684 }
685 
690 void
691 DQMStore::setVerbose(unsigned /* level */)
692 { return; }
693 
698 const std::string &
699 DQMStore::pwd(void) const
700 { return pwd_; }
701 
703 void
705 { setCurrentFolder(""); }
706 
708 void
709 DQMStore::cd(const std::string &subdir)
710 {
712  const std::string *cleaned = 0;
713  cleanTrailingSlashes(subdir, clean, cleaned);
714 
715  if (! dirExists(*cleaned))
716  raiseDQMError("DQMStore", "Cannot 'cd' into non-existent directory '%s'",
717  cleaned->c_str());
718 
719  setCurrentFolder(*cleaned);
720 }
721 
726 void
728 {
730  const std::string *cleaned = 0;
731  cleanTrailingSlashes(fullpath, clean, cleaned);
732  makeDirectory(*cleaned);
733  pwd_ = *cleaned;
734 }
735 
737 void
739 {
740  size_t pos = pwd_.rfind('/');
741  if (pos == std::string::npos)
742  setCurrentFolder("");
743  else
744  setCurrentFolder(pwd_.substr(0, pos));
745 }
746 
747 // -------------------------------------------------------------------
750 void
752 {
753  std::string prev;
754  std::string subdir;
756  prev.reserve(path.size());
757  subdir.reserve(path.size());
758  name.reserve(path.size());
759  size_t prevname = 0;
760  size_t slash = 0;
761 
762  while (true)
763  {
764  // Create this subdirectory component.
765  subdir.clear();
766  subdir.append(path, 0, slash);
767  name.clear();
768  name.append(subdir, prevname, std::string::npos);
769  if (! prev.empty() && findObject(prev, name))
770  raiseDQMError("DQMStore", "Attempt to create subdirectory '%s'"
771  " which already exists as a monitor element",
772  subdir.c_str());
773 
774  if (! dirs_.count(subdir))
775  dirs_.insert(subdir);
776 
777  // Stop if we've reached the end (including possibly a trailing slash).
778  if (slash+1 >= path.size())
779  break;
780 
781  // Find the next slash, making sure we progress. If reach the end,
782  // process the last path component; the next loop round will terminate.
783  prevname = slash ? slash+1 : slash;
784  prev = subdir;
785  if ((slash = path.find('/', ++slash)) == std::string::npos)
786  slash = path.size();
787  }
788 }
789 
791 bool
793 { return dirs_.count(path) > 0; }
794 
798 template <class HISTO, class COLLATE>
801  const char *context, int kind,
802  HISTO *h, COLLATE collate)
803 {
804  assert(name.find('/') == std::string::npos);
805  if (verbose_ > 3)
806  print_trace(dir, name);
808  mergePath(path, dir, name);
809 
810  // Put us in charge of h.
811  h->SetDirectory(0);
812 
813  // Check if the request monitor element already exists.
814  MonitorElement *me = findObject(dir, name, run_, 0, streamId_, moduleId_);
815  if (me)
816  {
817  if (collateHistograms_)
818  {
819  collate(me, h, verbose_);
820  delete h;
821  return me;
822  }
823  else
824  {
825  if (verbose_ > 1)
826  std::cout << "DQMStore: "
827  << context << ": monitor element '"
828  << path << "' already exists, collating" << std::endl;
829  me->Reset();
830  collate(me, h, verbose_);
831  delete h;
832  return me;
833  }
834  }
835  else
836  {
837  // Create and initialise core object.
838  assert(dirs_.count(dir));
839  MonitorElement proto(&*dirs_.find(dir), name, run_, streamId_, moduleId_);
840  me = const_cast<MonitorElement &>(*data_.insert(std::move(proto)).first)
842 
843  // Initialise quality test information.
844  QTestSpecs::iterator qi = qtestspecs_.begin();
845  QTestSpecs::iterator qe = qtestspecs_.end();
846  for ( ; qi != qe; ++qi)
847  {
848  if ( qi->first->match(path) )
849  me->addQReport(qi->second);
850  }
851 
852  // If we just booked a (plain) MonitorElement, and there is a reference
853  // MonitorElement with the same name, link the two together.
854  // The other direction is handled by the extract method.
855  std::string refdir;
856  refdir.reserve(s_referenceDirName.size() + dir.size() + 1);
857  refdir += s_referenceDirName;
858  refdir += '/';
859  refdir += dir;
860  MonitorElement* referenceME = findObject(refdir, name);
861  if (referenceME) {
862  // We have booked a new MonitorElement with a specific dir and name.
863  // Then, if we can find the corresponding MonitorElement in the reference
864  // dir we assign the object_ of the reference MonitorElement to the
865  // reference_ property of our new MonitorElement.
866  me->data_.flags |= DQMNet::DQM_PROP_HAS_REFERENCE;
867  me->reference_ = referenceME->object_;
868  }
869 
870  // Return the monitor element.
871  return me;
872  }
873 }
874 
877  const std::string &name,
878  const char *context)
879 {
880  assert(name.find('/') == std::string::npos);
881  if (verbose_ > 3)
882  print_trace(dir, name);
883 
884  // Check if the request monitor element already exists.
885  if (MonitorElement *me = findObject(dir, name, run_, 0, streamId_, moduleId_))
886  {
887  if (verbose_ > 1)
888  {
890  mergePath(path, dir, name);
891 
892  std::cout << "DQMStore: "
893  << context << ": monitor element '"
894  << path << "' already exists, resetting" << std::endl;
895  }
896  me->Reset();
897  return me;
898  }
899  else
900  {
901  // Create it and return for initialisation.
902  assert(dirs_.count(dir));
903  MonitorElement proto(&*dirs_.find(dir), name, run_, streamId_, moduleId_);
904  return &const_cast<MonitorElement &>(*data_.insert(std::move(proto)).first);
905  }
906 }
907 
908 // -------------------------------------------------------------------
912 {
913  if (collateHistograms_)
914  {
915  if (MonitorElement *me = findObject(dir, name, run_, 0, streamId_, moduleId_))
916  {
917  me->Fill(0);
918  return me;
919  }
920  }
921 
922  return book(dir, name, "bookInt")
924 }
925 
929 { return bookInt(pwd_, name); }
930 
934 {
935  return bookInt(pwd_, name);
936 }
937 
938 // -------------------------------------------------------------------
942 {
943  if (collateHistograms_)
944  {
945  if (MonitorElement *me = findObject(dir, name, run_, 0, streamId_, moduleId_))
946  {
947  me->Fill(0.);
948  return me;
949  }
950  }
951 
952  return book(dir, name, "bookFloat")
954 }
955 
959 { return bookFloat(pwd_, name); }
960 
964 {
965  return bookFloat(pwd_, name);
966 }
967 
968 // -------------------------------------------------------------------
972  const std::string &name,
973  const std::string &value)
974 {
975  if (collateHistograms_)
976  {
977  if (MonitorElement *me = findObject(dir, name, run_, 0, streamId_, moduleId_))
978  return me;
979  }
980 
981  return book(dir, name, "bookString")
983 }
984 
987 DQMStore::bookString(const char *name, const char *value)
988 { return bookString(pwd_, name, value); }
989 
993 {
994  return bookString(pwd_, name, value);
995 }
996 
997 // -------------------------------------------------------------------
1001 {
1002  return book(dir, name, "book1D", MonitorElement::DQM_KIND_TH1F, h, collate1D);
1003 }
1004 
1008 {
1009  return book(dir, name, "book1S", MonitorElement::DQM_KIND_TH1S, h, collate1S);
1010 }
1011 
1015 {
1016  return book(dir, name, "book1DD", MonitorElement::DQM_KIND_TH1D, h, collate1DD);
1017 }
1018 
1021 DQMStore::book1D(const char *name, const char *title,
1022  int nchX, double lowX, double highX)
1023 {
1024  return book1D(pwd_, name, new TH1F(name, title, nchX, lowX, highX));
1025 }
1026 
1030  int nchX, double lowX, double highX)
1031 {
1032  return book1D(pwd_, name, new TH1F(name.c_str(), title.c_str(), nchX, lowX, highX));
1033 }
1034 
1037 DQMStore::book1S(const char *name, const char *title,
1038  int nchX, double lowX, double highX)
1039 {
1040  return book1S(pwd_, name, new TH1S(name, title, nchX, lowX, highX));
1041 }
1042 
1046  int nchX, double lowX, double highX)
1047 {
1048  return book1S(pwd_, name, new TH1S(name.c_str(), title.c_str(), nchX, lowX, highX));
1049 }
1050 
1053 DQMStore::book1DD(const char *name, const char *title,
1054  int nchX, double lowX, double highX)
1055 {
1056  return book1DD(pwd_, name, new TH1D(name, title, nchX, lowX, highX));
1057 }
1058 
1062  int nchX, double lowX, double highX)
1063 {
1064  return book1DD(pwd_, name, new TH1D(name.c_str(), title.c_str(), nchX, lowX, highX));
1065 }
1066 
1069 DQMStore::book1D(const char *name, const char *title,
1070  int nchX, const float *xbinsize)
1071 {
1072  return book1D(pwd_, name, new TH1F(name, title, nchX, xbinsize));
1073 }
1074 
1078  int nchX, const float *xbinsize)
1079 {
1080  return book1D(pwd_, name, new TH1F(name.c_str(), title.c_str(), nchX, xbinsize));
1081 }
1082 
1085 DQMStore::book1D(const char *name, TH1F *source)
1086 {
1087  return book1D(pwd_, name, static_cast<TH1F *>(source->Clone(name)));
1088 }
1089 
1093 {
1094  return book1D(pwd_, name, static_cast<TH1F *>(source->Clone(name.c_str())));
1095 }
1096 
1099 DQMStore::book1S(const char *name, TH1S *source)
1100 {
1101  return book1S(pwd_, name, static_cast<TH1S *>(source->Clone(name)));
1102 }
1103 
1107 {
1108  return book1S(pwd_, name, static_cast<TH1S *>(source->Clone(name.c_str())));
1109 }
1110 
1113 DQMStore::book1DD(const char *name, TH1D *source)
1114 {
1115  return book1DD(pwd_, name, static_cast<TH1D *>(source->Clone(name)));
1116 }
1117 
1121 {
1122  return book1DD(pwd_, name, static_cast<TH1D *>(source->Clone(name.c_str())));
1123 }
1124 
1125 // -------------------------------------------------------------------
1129 {
1130  return book(dir, name, "book2D", MonitorElement::DQM_KIND_TH2F, h, collate2D);
1131 }
1132 
1136 {
1137  return book(dir, name, "book2S", MonitorElement::DQM_KIND_TH2S, h, collate2S);
1138 }
1139 
1143 {
1144  return book(dir, name, "book2DD", MonitorElement::DQM_KIND_TH2D, h, collate2DD);
1145 }
1146 
1149 DQMStore::book2D(const char *name, const char *title,
1150  int nchX, double lowX, double highX,
1151  int nchY, double lowY, double highY)
1152 {
1153  return book2D(pwd_, name, new TH2F(name, title,
1154  nchX, lowX, highX,
1155  nchY, lowY, highY));
1156 }
1157 
1161  int nchX, double lowX, double highX,
1162  int nchY, double lowY, double highY)
1163 {
1164  return book2D(pwd_, name, new TH2F(name.c_str(), title.c_str(),
1165  nchX, lowX, highX,
1166  nchY, lowY, highY));
1167 }
1168 
1171 DQMStore::book2S(const char *name, const char *title,
1172  int nchX, double lowX, double highX,
1173  int nchY, double lowY, double highY)
1174 {
1175  return book2S(pwd_, name, new TH2S(name, title,
1176  nchX, lowX, highX,
1177  nchY, lowY, highY));
1178 }
1179 
1183  int nchX, double lowX, double highX,
1184  int nchY, double lowY, double highY)
1185 {
1186  return book2S(pwd_, name, new TH2S(name.c_str(), title.c_str(),
1187  nchX, lowX, highX,
1188  nchY, lowY, highY));
1189 }
1190 
1193 DQMStore::book2DD(const char *name, const char *title,
1194  int nchX, double lowX, double highX,
1195  int nchY, double lowY, double highY)
1196 {
1197  return book2DD(pwd_, name, new TH2D(name, title,
1198  nchX, lowX, highX,
1199  nchY, lowY, highY));
1200 }
1201 
1205  int nchX, double lowX, double highX,
1206  int nchY, double lowY, double highY)
1207 {
1208  return book2DD(pwd_, name, new TH2D(name.c_str(), title.c_str(),
1209  nchX, lowX, highX,
1210  nchY, lowY, highY));
1211 }
1212 
1215 DQMStore::book2D(const char *name, const char *title,
1216  int nchX, const float *xbinsize, int nchY, const float *ybinsize)
1217 {
1218  return book2D(pwd_, name, new TH2F(name, title,
1219  nchX, xbinsize, nchY, ybinsize));
1220 }
1221 
1225  int nchX, const float *xbinsize, int nchY, const float *ybinsize)
1226 {
1227  return book2D(pwd_, name, new TH2F(name.c_str(), title.c_str(),
1228  nchX, xbinsize, nchY, ybinsize));
1229 }
1230 
1233 DQMStore::book2D(const char *name, TH2F *source)
1234 {
1235  return book2D(pwd_, name, static_cast<TH2F *>(source->Clone(name)));
1236 }
1237 
1241 {
1242  return book2D(pwd_, name, static_cast<TH2F *>(source->Clone(name.c_str())));
1243 }
1244 
1247 DQMStore::book2S(const char *name, TH2S *source)
1248 {
1249  return book2S(pwd_, name, static_cast<TH2S *>(source->Clone(name)));
1250 }
1251 
1255 {
1256  return book2S(pwd_, name, static_cast<TH2S *>(source->Clone(name.c_str())));
1257 }
1258 
1261 DQMStore::book2DD(const char *name, TH2D *source)
1262 {
1263  return book2DD(pwd_, name, static_cast<TH2D *>(source->Clone(name)));
1264 }
1265 
1269 {
1270  return book2DD(pwd_, name, static_cast<TH2D *>(source->Clone(name.c_str())));
1271 }
1272 
1273 // -------------------------------------------------------------------
1277 {
1278  return book(dir, name, "book3D", MonitorElement::DQM_KIND_TH3F, h, collate3D);
1279 }
1280 
1283 DQMStore::book3D(const char *name, const char *title,
1284  int nchX, double lowX, double highX,
1285  int nchY, double lowY, double highY,
1286  int nchZ, double lowZ, double highZ)
1287 {
1288  return book3D(pwd_, name, new TH3F(name, title,
1289  nchX, lowX, highX,
1290  nchY, lowY, highY,
1291  nchZ, lowZ, highZ));
1292 }
1293 
1297  int nchX, double lowX, double highX,
1298  int nchY, double lowY, double highY,
1299  int nchZ, double lowZ, double highZ)
1300 {
1301  return book3D(pwd_, name, new TH3F(name.c_str(), title.c_str(),
1302  nchX, lowX, highX,
1303  nchY, lowY, highY,
1304  nchZ, lowZ, highZ));
1305 }
1306 
1309 DQMStore::book3D(const char *name, TH3F *source)
1310 {
1311  return book3D(pwd_, name, static_cast<TH3F *>(source->Clone(name)));
1312 }
1313 
1317 {
1318  return book3D(pwd_, name, static_cast<TH3F *>(source->Clone(name.c_str())));
1319 }
1320 
1321 // -------------------------------------------------------------------
1325 {
1326  return book(dir, name, "bookProfile",
1328  h, collateProfile);
1329 }
1330 
1335 DQMStore::bookProfile(const char *name, const char *title,
1336  int nchX, double lowX, double highX,
1337  int /* nchY */, double lowY, double highY,
1338  const char *option /* = "s" */)
1339 {
1340  return bookProfile(pwd_, name, new TProfile(name, title,
1341  nchX, lowX, highX,
1342  lowY, highY,
1343  option));
1344 }
1345 
1351  int nchX, double lowX, double highX,
1352  int /* nchY */, double lowY, double highY,
1353  const char *option /* = "s" */)
1354 {
1355  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1356  nchX, lowX, highX,
1357  lowY, highY,
1358  option));
1359 }
1360 
1365 DQMStore::bookProfile(const char *name, const char *title,
1366  int nchX, double lowX, double highX,
1367  double lowY, double highY,
1368  const char *option /* = "s" */)
1369 {
1370  return bookProfile(pwd_, name, new TProfile(name, title,
1371  nchX, lowX, highX,
1372  lowY, highY,
1373  option));
1374 }
1375 
1381  int nchX, double lowX, double highX,
1382  double lowY, double highY,
1383  const char *option /* = "s" */)
1384 {
1385  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1386  nchX, lowX, highX,
1387  lowY, highY,
1388  option));
1389 }
1390 
1395 DQMStore::bookProfile(const char *name, const char *title,
1396  int nchX, const double *xbinsize,
1397  int /* nchY */, double lowY, double highY,
1398  const char *option /* = "s" */)
1399 {
1400  return bookProfile(pwd_, name, new TProfile(name, title,
1401  nchX, xbinsize,
1402  lowY, highY,
1403  option));
1404 }
1405 
1411  int nchX, const double *xbinsize,
1412  int /* nchY */, double lowY, double highY,
1413  const char *option /* = "s" */)
1414 {
1415  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1416  nchX, xbinsize,
1417  lowY, highY,
1418  option));
1419 }
1420 
1425 DQMStore::bookProfile(const char *name, const char *title,
1426  int nchX, const double *xbinsize,
1427  double lowY, double highY,
1428  const char *option /* = "s" */)
1429 {
1430  return bookProfile(pwd_, name, new TProfile(name, title,
1431  nchX, xbinsize,
1432  lowY, highY,
1433  option));
1434 }
1435 
1441  int nchX, const double *xbinsize,
1442  double lowY, double highY,
1443  const char *option /* = "s" */)
1444 {
1445  return bookProfile(pwd_, name, new TProfile(name.c_str(), title.c_str(),
1446  nchX, xbinsize,
1447  lowY, highY,
1448  option));
1449 }
1450 
1453 DQMStore::bookProfile(const char *name, TProfile *source)
1454 {
1455  return bookProfile(pwd_, name, static_cast<TProfile *>(source->Clone(name)));
1456 }
1457 
1461 {
1462  return bookProfile(pwd_, name, static_cast<TProfile *>(source->Clone(name.c_str())));
1463 }
1464 
1465 // -------------------------------------------------------------------
1469 {
1470  return book(dir, name, "bookProfile2D",
1472  h, collateProfile2D);
1473 }
1474 
1479 DQMStore::bookProfile2D(const char *name, const char *title,
1480  int nchX, double lowX, double highX,
1481  int nchY, double lowY, double highY,
1482  int /* nchZ */, double lowZ, double highZ,
1483  const char *option /* = "s" */)
1484 {
1485  return bookProfile2D(pwd_, name, new TProfile2D(name, title,
1486  nchX, lowX, highX,
1487  nchY, lowY, highY,
1488  lowZ, highZ,
1489  option));
1490 }
1491 
1497  int nchX, double lowX, double highX,
1498  int nchY, double lowY, double highY,
1499  int /* nchZ */, double lowZ, double highZ,
1500  const char *option /* = "s" */)
1501 {
1502  return bookProfile2D(pwd_, name, new TProfile2D(name.c_str(), title.c_str(),
1503  nchX, lowX, highX,
1504  nchY, lowY, highY,
1505  lowZ, highZ,
1506  option));
1507 }
1508 
1513 DQMStore::bookProfile2D(const char *name, const char *title,
1514  int nchX, double lowX, double highX,
1515  int nchY, double lowY, double highY,
1516  double lowZ, double highZ,
1517  const char *option /* = "s" */)
1518 {
1519  return bookProfile2D(pwd_, name, new TProfile2D(name, title,
1520  nchX, lowX, highX,
1521  nchY, lowY, highY,
1522  lowZ, highZ,
1523  option));
1524 }
1525 
1531  int nchX, double lowX, double highX,
1532  int nchY, double lowY, double highY,
1533  double lowZ, double highZ,
1534  const char *option /* = "s" */)
1535 {
1536  return bookProfile2D(pwd_, name, new TProfile2D(name.c_str(), title.c_str(),
1537  nchX, lowX, highX,
1538  nchY, lowY, highY,
1539  lowZ, highZ,
1540  option));
1541 }
1542 
1545 DQMStore::bookProfile2D(const char *name, TProfile2D *source)
1546 {
1547  return bookProfile2D(pwd_, name, static_cast<TProfile2D *>(source->Clone(name)));
1548 }
1549 
1553 {
1554  return bookProfile2D(pwd_, name, static_cast<TProfile2D *>(source->Clone(name.c_str())));
1555 }
1556 
1560 bool
1562 {
1563  if (me->getTH1()->GetNbinsX() != h->GetNbinsX()
1564  || me->getTH1()->GetNbinsY() != h->GetNbinsY()
1565  || me->getTH1()->GetNbinsZ() != h->GetNbinsZ()
1566  || me->getTH1()->GetXaxis()->GetXmin() != h->GetXaxis()->GetXmin()
1567  || me->getTH1()->GetYaxis()->GetXmin() != h->GetYaxis()->GetXmin()
1568  || me->getTH1()->GetZaxis()->GetXmin() != h->GetZaxis()->GetXmin()
1569  || me->getTH1()->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax()
1570  || me->getTH1()->GetYaxis()->GetXmax() != h->GetYaxis()->GetXmax()
1571  || me->getTH1()->GetZaxis()->GetXmax() != h->GetZaxis()->GetXmax()
1572  || !MonitorElement::CheckBinLabels((TAxis*)me->getTH1()->GetXaxis(),(TAxis*)h->GetXaxis())
1573  || !MonitorElement::CheckBinLabels((TAxis*)me->getTH1()->GetYaxis(),(TAxis*)h->GetYaxis())
1574  || !MonitorElement::CheckBinLabels((TAxis*)me->getTH1()->GetZaxis(),(TAxis*)h->GetZaxis()) )
1575  {
1576  if(verbose > 0)
1577  std::cout << "*** DQMStore: WARNING:"
1578  << "checkBinningMatches: different binning - cannot add object '"
1579  << h->GetName() << "' of type "
1580  << h->IsA()->GetName() << " to existing ME: '"
1581  << me->getFullname() << "'\n";
1582  return false;
1583  }
1584  return true;
1585 }
1586 
1587 void
1589 {
1590  if (checkBinningMatches(me,h,verbose))
1591  me->getTH1F()->Add(h);
1592 }
1593 
1594 void
1596 {
1597  if (checkBinningMatches(me,h,verbose))
1598  me->getTH1S()->Add(h);
1599 }
1600 
1601 void
1603 {
1604  if (checkBinningMatches(me,h,verbose))
1605  me->getTH1D()->Add(h);
1606 }
1607 
1608 void
1610 {
1611  if (checkBinningMatches(me,h,verbose))
1612  me->getTH2F()->Add(h);
1613 }
1614 
1615 void
1617 {
1618  if (checkBinningMatches(me,h,verbose))
1619  me->getTH2S()->Add(h);
1620 }
1621 
1622 void
1624 {
1625  if (checkBinningMatches(me,h,verbose))
1626  me->getTH2D()->Add(h);
1627 }
1628 
1629 void
1631 {
1632  if (checkBinningMatches(me,h,verbose))
1633  me->getTH3F()->Add(h);
1634 }
1635 
1636 void
1638 {
1639  if (checkBinningMatches(me,h,verbose))
1640  {
1641  TProfile *meh = me->getTProfile();
1642  me->addProfiles(h, meh, meh, 1, 1);
1643  }
1644 }
1645 
1646 void
1648 {
1649  if (checkBinningMatches(me,h,verbose))
1650  {
1651  TProfile2D *meh = me->getTProfile2D();
1652  me->addProfiles(h, meh, meh, 1, 1);
1653  }
1654 }
1655 
1660 void
1661 DQMStore::tag(MonitorElement *me, unsigned int myTag)
1662 {
1663  if (! myTag)
1664  raiseDQMError("DQMStore", "Attempt to tag monitor element '%s'"
1665  " with a zero tag", me->getFullname().c_str());
1666  if ((me->data_.flags & DQMNet::DQM_PROP_TAGGED) && myTag != me->data_.tag)
1667  raiseDQMError("DQMStore", "Attempt to tag monitor element '%s'"
1668  " twice with multiple tags", me->getFullname().c_str());
1669 
1670  me->data_.tag = myTag;
1672 }
1673 
1675 void
1676 DQMStore::tag(const std::string &path, unsigned int myTag)
1677 {
1678  std::string dir;
1679  std::string name;
1680  splitPath(dir, name, path);
1681 
1682  if (MonitorElement *me = findObject(dir, name))
1683  tag(me, myTag);
1684  else
1685  raiseDQMError("DQMStore", "Attempt to tag non-existent monitor element"
1686  " '%s' with tag %u", path.c_str(), myTag);
1687 
1688 }
1689 
1691 void
1692 DQMStore::tagContents(const std::string &path, unsigned int myTag)
1693 {
1694  MonitorElement proto(&path, std::string());
1695  MEMap::iterator e = data_.end();
1696  MEMap::iterator i = data_.lower_bound(proto);
1697  for ( ; i != e && path == *i->data_.dirname; ++i)
1698  tag(const_cast<MonitorElement *>(&*i), myTag);
1699 }
1700 
1703 void
1704 DQMStore::tagAllContents(const std::string &path, unsigned int myTag)
1705 {
1707  const std::string *cleaned = 0;
1708  cleanTrailingSlashes(path, clean, cleaned);
1709  MonitorElement proto(cleaned, std::string());
1710 
1711  // FIXME: WILDCARDS? Old one supported them, but nobody seemed to use them.
1712  MEMap::iterator e = data_.end();
1713  MEMap::iterator i = data_.lower_bound(proto);
1714  while (i != e && isSubdirectory(*cleaned, *i->data_.dirname))
1715  {
1716  tag(const_cast<MonitorElement *>(&*i), myTag);
1717  ++i;
1718  }
1719 }
1720 
1725 std::vector<std::string>
1727 {
1728  std::vector<std::string> result;
1729  std::set<std::string>::const_iterator e = dirs_.end();
1730  std::set<std::string>::const_iterator i = dirs_.find(pwd_);
1731 
1732  // If we didn't find current directory, the tree is empty, so quit.
1733  if (i == e)
1734  return result;
1735 
1736  // Skip the current directory and then start looking for immediate
1737  // subdirectories in the dirs_ list. Stop when we are no longer in
1738  // (direct or indirect) subdirectories of pwd_. Note that we don't
1739  // "know" which order the set will sort A/B, A/B/C and A/D.
1740  while (++i != e && isSubdirectory(pwd_, *i))
1741  if (i->find('/', pwd_.size()+1) == std::string::npos)
1742  result.push_back(*i);
1743 
1744  return result;
1745 }
1746 
1748 std::vector<std::string>
1749 DQMStore::getMEs(void) const
1750 {
1751  MonitorElement proto(&pwd_, std::string());
1752  std::vector<std::string> result;
1753  MEMap::const_iterator e = data_.end();
1754  MEMap::const_iterator i = data_.lower_bound(proto);
1755  for ( ; i != e && isSubdirectory(pwd_, *i->data_.dirname); ++i)
1756  if (pwd_ == *i->data_.dirname)
1757  result.push_back(i->getName());
1758 
1759  return result;
1760 }
1761 
1764 bool
1766 {
1767  MonitorElement proto(&path, std::string());
1768  MEMap::const_iterator e = data_.end();
1769  MEMap::const_iterator i = data_.lower_bound(proto);
1770  return (i != e && isSubdirectory(path, *i->data_.dirname));
1771 }
1772 
1776 {
1777  std::string dir;
1778  std::string name;
1779  splitPath(dir, name, path);
1780  MonitorElement proto(&dir, name);
1781  MEMap::const_iterator mepos = data_.find(proto);
1782  return (mepos == data_.end() ? 0
1783  : const_cast<MonitorElement *>(&*mepos));
1784 }
1785 
1787 std::vector<MonitorElement *>
1788 DQMStore::get(unsigned int tag) const
1789 {
1790  // FIXME: Use reverse map [tag -> path] / [tag -> dir]?
1791  std::vector<MonitorElement *> result;
1792  for (MEMap::const_iterator i = data_.begin(), e = data_.end(); i != e; ++i)
1793  {
1794  const MonitorElement &me = *i;
1795  if ((me.data_.flags & DQMNet::DQM_PROP_TAGGED) && me.data_.tag == tag)
1796  result.push_back(const_cast<MonitorElement *>(&me));
1797  }
1798  return result;
1799 }
1800 
1803 std::vector<MonitorElement *>
1805 {
1807  const std::string *cleaned = 0;
1808  cleanTrailingSlashes(path, clean, cleaned);
1809  MonitorElement proto(cleaned, std::string());
1810 
1811  std::vector<MonitorElement *> result;
1812  MEMap::const_iterator e = data_.end();
1813  MEMap::const_iterator i = data_.lower_bound(proto);
1814  for ( ; i != e && isSubdirectory(*cleaned, *i->data_.dirname); ++i)
1815  if (*cleaned == *i->data_.dirname)
1816  result.push_back(const_cast<MonitorElement *>(&*i));
1817 
1818  return result;
1819 }
1820 
1822 std::vector<MonitorElement *>
1823 DQMStore::getContents(const std::string &path, unsigned int tag) const
1824 {
1826  const std::string *cleaned = 0;
1827  cleanTrailingSlashes(path, clean, cleaned);
1828  MonitorElement proto(cleaned, std::string());
1829 
1830  std::vector<MonitorElement *> result;
1831  MEMap::const_iterator e = data_.end();
1832  MEMap::const_iterator i = data_.lower_bound(proto);
1833  for ( ; i != e && isSubdirectory(*cleaned, *i->data_.dirname); ++i)
1834  if (*cleaned == *i->data_.dirname
1835  && (i->data_.flags & DQMNet::DQM_PROP_TAGGED)
1836  && i->data_.tag == tag)
1837  result.push_back(const_cast<MonitorElement *>(&*i));
1838 
1839  return result;
1840 }
1841 
1846 void
1847 DQMStore::getContents(std::vector<std::string> &into, bool showContents /* = true */) const
1848 {
1849  into.clear();
1850  into.reserve(dirs_.size());
1851 
1852  MEMap::const_iterator me = data_.end();
1853  std::set<std::string>::const_iterator di = dirs_.begin();
1854  std::set<std::string>::const_iterator de = dirs_.end();
1855  for ( ; di != de; ++di)
1856  {
1857  MonitorElement proto(&*di, std::string());
1858  MEMap::const_iterator mi = data_.lower_bound(proto);
1859  MEMap::const_iterator m = mi;
1860  size_t sz = di->size() + 2;
1861  size_t nfound = 0;
1862  for ( ; m != me && isSubdirectory(*di, *m->data_.dirname); ++m)
1863  if (*di == *m->data_.dirname)
1864  {
1865  sz += m->data_.objname.size() + 1;
1866  ++nfound;
1867  }
1868 
1869  if (! nfound)
1870  continue;
1871 
1872  std::vector<std::string>::iterator istr
1873  = into.insert(into.end(), std::string());
1874 
1875  if (showContents)
1876  {
1877  istr->reserve(sz);
1878 
1879  *istr += *di;
1880  *istr += ':';
1881  for (sz = 0; mi != m; ++mi)
1882  {
1883  if (*di != *mi->data_.dirname)
1884  continue;
1885 
1886  if (sz > 0)
1887  *istr += ',';
1888 
1889  *istr += mi->data_.objname;
1890  ++sz;
1891  }
1892  }
1893  else
1894  {
1895  istr->reserve(di->size() + 2);
1896  *istr += *di;
1897  *istr += ':';
1898  }
1899  }
1900 }
1901 
1906  const std::string &name,
1907  const uint32_t run /* = 0 */,
1908  const uint32_t lumi /* = 0 */,
1909  const uint32_t streamId /* = 0 */,
1910  const uint32_t moduleId /* = 0 */) const
1911 {
1912  if (dir.find_first_not_of(s_safe) != std::string::npos)
1913  raiseDQMError("DQMStore", "Monitor element path name '%s' uses"
1914  " unacceptable characters", dir.c_str());
1915  if (name.find_first_not_of(s_safe) != std::string::npos)
1916  raiseDQMError("DQMStore", "Monitor element path name '%s' uses"
1917  " unacceptable characters", name.c_str());
1918 
1919  MonitorElement proto;
1920  proto.data_.dirname = &dir;
1921  proto.data_.objname = name;
1922  proto.data_.run = run;
1923  proto.data_.lumi = lumi;
1924  proto.data_.streamId = streamId;
1925  proto.data_.moduleId = moduleId;
1926 
1927  MEMap::const_iterator mepos = data_.find(proto);
1928  return (mepos == data_.end() ? 0
1929  : const_cast<MonitorElement *>(&*mepos));
1930 }
1931 
1934 void
1935 DQMStore::getAllTags(std::vector<std::string> &into) const
1936 {
1937  into.clear();
1938  into.reserve(dirs_.size());
1939 
1940  MEMap::const_iterator me = data_.end();
1941  std::set<std::string>::const_iterator di = dirs_.begin();
1942  std::set<std::string>::const_iterator de = dirs_.end();
1943  char tagbuf[32]; // more than enough for '/' and up to 10 digits
1944 
1945  for ( ; di != de; ++di)
1946  {
1947  MonitorElement proto(&*di, std::string());
1948  MEMap::const_iterator mi = data_.lower_bound(proto);
1949  MEMap::const_iterator m = mi;
1950  size_t sz = di->size() + 2;
1951  size_t nfound = 0;
1952  for ( ; m != me && isSubdirectory(*di, *m->data_.dirname); ++m)
1953  if (*di == *m->data_.dirname && (m->data_.flags & DQMNet::DQM_PROP_TAGGED))
1954  {
1955  // the tags count for '/' + up to 10 digits, otherwise ',' + ME name
1956  sz += 1 + m->data_.objname.size() + 11;
1957  ++nfound;
1958  }
1959 
1960  if (! nfound)
1961  continue;
1962 
1963  std::vector<std::string>::iterator istr
1964  = into.insert(into.end(), std::string());
1965 
1966  istr->reserve(sz);
1967 
1968  *istr += *di;
1969  *istr += ':';
1970  for (sz = 0; mi != m; ++mi)
1971  {
1972  if (*di == *m->data_.dirname && (m->data_.flags & DQMNet::DQM_PROP_TAGGED))
1973  {
1974  sprintf(tagbuf, "/%u", mi->data_.tag);
1975  if (sz > 0)
1976  *istr += ',';
1977  *istr += m->data_.objname;
1978  *istr += tagbuf;
1979  ++sz;
1980  }
1981  }
1982  }
1983 }
1984 
1987 std::vector<MonitorElement*>
1989  uint32_t runNumber /* = 0 */,
1990  uint32_t lumi /* = 0 */) const
1991 {
1993  const std::string *cleaned = 0;
1994  cleanTrailingSlashes(path, clean, cleaned);
1995  MonitorElement proto(cleaned, std::string(), runNumber);
1996  proto.setLumi(lumi);
1997 
1998  std::vector<MonitorElement *> result;
1999  MEMap::const_iterator e = data_.end();
2000  MEMap::const_iterator i = data_.lower_bound(proto);
2001  for ( ; i != e && isSubdirectory(*cleaned, *i->data_.dirname); ++i) {
2002  if (runNumber != 0) {
2003  if (i->data_.run > runNumber // TODO[rovere]: pleonastic? first we encounter local ME of the same run ...
2004  || i->data_.streamId != 0
2005  || i->data_.moduleId != 0)
2006  break;
2007  }
2008  if (lumi != 0) {
2009  if (i->data_.lumi > lumi
2010  || i->data_.streamId != 0
2011  || i->data_.moduleId != 0)
2012  break;
2013  }
2014  if (runNumber != 0 or lumi !=0) {
2015  assert(i->data_.streamId == 0);
2016  assert(i->data_.moduleId == 0);
2017  }
2018  result.push_back(const_cast<MonitorElement *>(&*i));
2019  }
2020 
2021  if (enableMultiThread_)
2022  {
2023  //save legacy modules when running MT
2024  i = data_.begin();
2025  for ( ; i != e && isSubdirectory(*cleaned, *i->data_.dirname); ++i) {
2026  if (i->data_.run != 0 || i->data_.streamId != 0 || i->data_.moduleId != 0) break;
2027  result.push_back(const_cast<MonitorElement *>(&*i));
2028  }
2029  }
2030 
2031  return result;
2032 }
2033 
2036 std::vector<MonitorElement*>
2037 DQMStore::getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType /* = Wildcard */) const
2038 {
2039  lat::Regexp rx;
2040  try
2041  {
2042  rx = lat::Regexp(pattern, 0, syntaxType);
2043  rx.study();
2044  }
2045  catch (lat::Error &e)
2046  {
2047  raiseDQMError("DQMStore", "Invalid regular expression '%s': %s",
2048  pattern.c_str(), e.explain().c_str());
2049  }
2050 
2051  std::string path;
2052  std::vector<MonitorElement *> result;
2053  MEMap::const_iterator i = data_.begin();
2054  MEMap::const_iterator e = data_.end();
2055  for ( ; i != e; ++i)
2056  {
2057  path.clear();
2058  mergePath(path, *i->data_.dirname, i->data_.objname);
2059  if (rx.match(path))
2060  result.push_back(const_cast<MonitorElement *>(&*i));
2061  }
2062 
2063  return result;
2064 }
2065 
2069 
2072 void
2074 {
2075  MEMap::iterator mi = data_.begin();
2076  MEMap::iterator me = data_.end();
2077  for ( ; mi != me; ++mi)
2078  {
2079  MonitorElement &me = const_cast<MonitorElement &>(*mi);
2080  if (mi->wasUpdated())
2081  {
2082  if (me.resetMe())
2083  me.Reset();
2084  me.resetUpdate();
2085  }
2086  }
2087 
2088  reset_ = true;
2089 }
2090 
2094 
2096 void
2098 {
2099  MEMap::iterator mi = data_.begin();
2100  MEMap::iterator me = data_.end();
2101  for ( ; mi != me; ++mi)
2102  {
2103  if (forceResetOnBeginLumi_ && ((*mi).getLumiFlag() == false))
2104  continue;
2105  MonitorElement &me = const_cast<MonitorElement &>(*mi);
2106  me.Reset();
2107  me.resetUpdate();
2108  }
2109 
2110  reset_ = true;
2111 }
2112 
2116 
2120 void
2122 {
2123  if (!enableMultiThread_)
2124  return;
2125 
2126  std::lock_guard<std::mutex> guard(book_mutex_);
2127 
2128  std::string null_str("");
2129  MonitorElement proto(&null_str, null_str, run, 0, 0);
2130  proto.setLumi(lumi);
2131 
2132  std::set<MonitorElement>::const_iterator e = data_.end();
2133  std::set<MonitorElement>::const_iterator i = data_.lower_bound(proto);
2134 
2135  while (i != e) {
2136  if (i->data_.streamId != 0 ||
2137  i->data_.moduleId != 0)
2138  break;
2139  if (i->data_.lumi != lumi)
2140  break;
2141  if (i->data_.run != run)
2142  break;
2143 
2144  auto temp = i;
2145  ++i;
2146 
2147  if (verbose_ > 1) {
2148  std::cout << "DQMStore::deleteUnusedLumiHistograms: deleted monitor element '"
2149  << *i->data_.dirname << "/" << i->data_.objname << "'"
2150  << "flags " << i->data_.flags << "\n";
2151  }
2152 
2153  data_.erase(temp);
2154  }
2155 }
2156 
2162 bool
2164  bool overwrite, bool collateHistograms)
2165 {
2166  // NB: Profile histograms inherit from TH*D, checking order matters.
2167  MonitorElement *refcheck = 0;
2168  if (TProfile *h = dynamic_cast<TProfile *>(obj))
2169  {
2170  MonitorElement *me = findObject(dir, h->GetName());
2171  if (! me)
2172  me = bookProfile(dir, h->GetName(), (TProfile *) h->Clone());
2173  else if (overwrite)
2174  me->copyFrom(h);
2175  else if (isCollateME(me) || collateHistograms)
2176  collateProfile(me, h, verbose_);
2177  refcheck = me;
2178  }
2179  else if (TProfile2D *h = dynamic_cast<TProfile2D *>(obj))
2180  {
2181  MonitorElement *me = findObject(dir, h->GetName());
2182  if (! me)
2183  me = bookProfile2D(dir, h->GetName(), (TProfile2D *) h->Clone());
2184  else if (overwrite)
2185  me->copyFrom(h);
2186  else if (isCollateME(me) || collateHistograms)
2187  collateProfile2D(me, h, verbose_);
2188  refcheck = me;
2189  }
2190  else if (TH1F *h = dynamic_cast<TH1F *>(obj))
2191  {
2192  MonitorElement *me = findObject(dir, h->GetName());
2193  if (! me)
2194  me = book1D(dir, h->GetName(), (TH1F *) h->Clone());
2195  else if (overwrite)
2196  me->copyFrom(h);
2197  else if (isCollateME(me) || collateHistograms)
2198  collate1D(me, h, verbose_);
2199  refcheck = me;
2200  }
2201  else if (TH1S *h = dynamic_cast<TH1S *>(obj))
2202  {
2203  MonitorElement *me = findObject(dir, h->GetName());
2204  if (! me)
2205  me = book1S(dir, h->GetName(), (TH1S *) h->Clone());
2206  else if (overwrite)
2207  me->copyFrom(h);
2208  else if (isCollateME(me) || collateHistograms)
2209  collate1S(me, h, verbose_);
2210  refcheck = me;
2211  }
2212  else if (TH1D *h = dynamic_cast<TH1D *>(obj))
2213  {
2214  MonitorElement *me = findObject(dir, h->GetName());
2215  if (! me)
2216  me = book1DD(dir, h->GetName(), (TH1D *) h->Clone());
2217  else if (overwrite)
2218  me->copyFrom(h);
2219  else if (isCollateME(me) || collateHistograms)
2220  collate1DD(me, h, verbose_);
2221  refcheck = me;
2222  }
2223  else if (TH2F *h = dynamic_cast<TH2F *>(obj))
2224  {
2225  MonitorElement *me = findObject(dir, h->GetName());
2226  if (! me)
2227  me = book2D(dir, h->GetName(), (TH2F *) h->Clone());
2228  else if (overwrite)
2229  me->copyFrom(h);
2230  else if (isCollateME(me) || collateHistograms)
2231  collate2D(me, h, verbose_);
2232  refcheck = me;
2233  }
2234  else if (TH2S *h = dynamic_cast<TH2S *>(obj))
2235  {
2236  MonitorElement *me = findObject(dir, h->GetName());
2237  if (! me)
2238  me = book2S(dir, h->GetName(), (TH2S *) h->Clone());
2239  else if (overwrite)
2240  me->copyFrom(h);
2241  else if (isCollateME(me) || collateHistograms)
2242  collate2S(me, h, verbose_);
2243  refcheck = me;
2244  }
2245  else if (TH2D *h = dynamic_cast<TH2D *>(obj))
2246  {
2247  MonitorElement *me = findObject(dir, h->GetName());
2248  if (! me)
2249  me = book2DD(dir, h->GetName(), (TH2D *) h->Clone());
2250  else if (overwrite)
2251  me->copyFrom(h);
2252  else if (isCollateME(me) || collateHistograms)
2253  collate2DD(me, h, verbose_);
2254  refcheck = me;
2255  }
2256  else if (TH3F *h = dynamic_cast<TH3F *>(obj))
2257  {
2258  MonitorElement *me = findObject(dir, h->GetName());
2259  if (! me)
2260  me = book3D(dir, h->GetName(), (TH3F *) h->Clone());
2261  else if (overwrite)
2262  me->copyFrom(h);
2263  else if (isCollateME(me) || collateHistograms)
2264  collate3D(me, h, verbose_);
2265  refcheck = me;
2266  }
2267  else if (dynamic_cast<TObjString *>(obj))
2268  {
2269  lat::RegexpMatch m;
2270  if (! s_rxmeval.match(obj->GetName(), 0, 0, &m))
2271  {
2272  if (strstr(obj->GetName(), "CMSSW"))
2273  {
2274  if (verbose_)
2275  std::cout << "Input file version: " << obj->GetName() << std::endl;
2276  return true;
2277  }
2278  else if (strstr(obj->GetName(), "DQMPATCH"))
2279  {
2280  if (verbose_)
2281  std::cout << "DQM patch version: " << obj->GetName() << std::endl;
2282  return true;
2283  }
2284  else
2285  {
2286  std::cout << "*** DQMStore: WARNING: cannot extract object '"
2287  << obj->GetName() << "' of type '"
2288  << obj->IsA()->GetName() << "'\n";
2289  return false;
2290  }
2291  }
2292 
2293  std::string label = m.matchString(obj->GetName(), 1);
2294  std::string kind = m.matchString(obj->GetName(), 2);
2295  std::string value = m.matchString(obj->GetName(), 3);
2296 
2297  if (kind == "i")
2298  {
2299  MonitorElement *me = findObject(dir, label);
2300  if (! me || overwrite)
2301  {
2302  if (! me) me = bookInt(dir, label);
2303  me->Fill(atoll(value.c_str()));
2304  }
2305  }
2306  else if (kind == "f")
2307  {
2308  MonitorElement *me = findObject(dir, label);
2309  if (! me || overwrite)
2310  {
2311  if (! me) me = bookFloat(dir, label);
2312  me->Fill(atof(value.c_str()));
2313  }
2314  }
2315  else if (kind == "s")
2316  {
2317  MonitorElement *me = findObject(dir, label);
2318  if (! me)
2319  me = bookString(dir, label, value);
2320  else if (overwrite)
2321  me->Fill(value);
2322  }
2323  else if (kind == "e")
2324  {
2325  MonitorElement *me = findObject(dir, label);
2326  if (! me)
2327  {
2328  std::cout << "*** DQMStore: WARNING: no monitor element '"
2329  << label << "' in directory '"
2330  << dir << "' to be marked as efficiency plot.\n";
2331  return false;
2332  }
2333  me->setEfficiencyFlag();
2334  }
2335  else if (kind == "t")
2336  {
2337  MonitorElement *me = findObject(dir, label);
2338  if (! me)
2339  {
2340  std::cout << "*** DQMStore: WARNING: no monitor element '"
2341  << label << "' in directory '"
2342  << dir << "' for a tag\n";
2343  return false;
2344  }
2345  errno = 0;
2346  char *endp = 0;
2347  unsigned long val = strtoul(value.c_str(), &endp, 10);
2348  if ((val == 0 && errno) || *endp || val > ~uint32_t(0))
2349  {
2350  std::cout << "*** DQMStore: WARNING: cannot restore tag '"
2351  << value << "' for monitor element '"
2352  << label << "' in directory '"
2353  << dir << "' - invalid value\n";
2354  return false;
2355  }
2356  tag(me, val);
2357  }
2358  else if (kind == "qr")
2359  {
2360  // Handle qreports, but skip them while reading in references.
2361  if (! isSubdirectory(s_referenceDirName, dir))
2362  {
2363  size_t dot = label.find('.');
2364  if (dot == std::string::npos)
2365  {
2366  std::cout << "*** DQMStore: WARNING: quality report label in '" << label
2367  << "' is missing a '.' and cannot be extracted\n";
2368  return false;
2369  }
2370 
2371  std::string mename (label, 0, dot);
2372  std::string qrname (label, dot+1, std::string::npos);
2373 
2374  m.reset();
2375  DQMNet::QValue qv;
2376  if (s_rxmeqr1.match(value, 0, 0, &m))
2377  {
2378  qv.code = atoi(m.matchString(value, 1).c_str());
2379  qv.qtresult = strtod(m.matchString(value, 2).c_str(), 0);
2380  qv.message = m.matchString(value, 4);
2381  qv.qtname = qrname;
2382  qv.algorithm = m.matchString(value, 3);
2383  }
2384  else if (s_rxmeqr2.match(value, 0, 0, &m))
2385  {
2386  qv.code = atoi(m.matchString(value, 1).c_str());
2387  qv.qtresult = 0; // unavailable in old format
2388  qv.message = m.matchString(value, 2);
2389  qv.qtname = qrname;
2390  // qv.algorithm unavailable in old format
2391  }
2392  else
2393  {
2394  std::cout << "*** DQMStore: WARNING: quality test value '"
2395  << value << "' is incorrectly formatted\n";
2396  return false;
2397  }
2398 
2399  MonitorElement *me = findObject(dir, mename);
2400  if (! me)
2401  {
2402  std::cout << "*** DQMStore: WARNING: no monitor element '"
2403  << mename << "' in directory '"
2404  << dir << "' for quality test '"
2405  << label << "'\n";
2406  return false;
2407  }
2408 
2409  me->addQReport(qv, /* FIXME: getQTest(qv.qtname)? */ 0);
2410  }
2411  }
2412  else
2413  {
2414  std::cout << "*** DQMStore: WARNING: cannot extract object '"
2415  << obj->GetName() << "' of type '"
2416  << obj->IsA()->GetName() << "'\n";
2417  return false;
2418  }
2419  }
2420  else if (TNamed *n = dynamic_cast<TNamed *>(obj))
2421  {
2422  // For old DQM data.
2423  std::string s;
2424  s.reserve(6 + strlen(n->GetTitle()) + 2*strlen(n->GetName()));
2425  s += '<'; s += n->GetName(); s += '>';
2426  s += n->GetTitle();
2427  s += '<'; s += '/'; s += n->GetName(); s += '>';
2428  TObjString os(s.c_str());
2429  return extract(&os, dir, overwrite, collateHistograms_);
2430  }
2431  else
2432  {
2433  std::cout << "*** DQMStore: WARNING: cannot extract object '"
2434  << obj->GetName() << "' of type '" << obj->IsA()->GetName()
2435  << "' and with title '" << obj->GetTitle() << "'\n";
2436  return false;
2437  }
2438 
2439  // If we just read in a reference MonitorElement, and there is a
2440  // MonitorElement with the same name, link the two together.
2441  // The other direction is handled by the book() method.
2442  if (refcheck && isSubdirectory(s_referenceDirName, dir))
2443  {
2444  std::string mdir(dir, s_referenceDirName.size()+1, std::string::npos);
2445  if (MonitorElement *master = findObject(mdir, obj->GetName()))
2446  {
2447  // We have extracted a MonitorElement, and it's located in the reference
2448  // dir. Then we find the corresponding MonitorElement in the
2449  // non-reference dir and assign the object_ of the reference
2450  // MonitorElement to the reference_ property of the corresponding
2451  // non-reference MonitorElement.
2452  master->data_.flags |= DQMNet::DQM_PROP_HAS_REFERENCE;
2453  master->reference_ = refcheck->object_;
2454  }
2455  }
2456 
2457  return true;
2458 }
2459 
2463 bool
2465 {
2466  assert(! path.empty());
2467 
2468  // Find the first path component.
2469  size_t start = 0;
2470  size_t end = path.find('/', start);
2471  if (end == std::string::npos)
2472  end = path.size();
2473 
2474  while (true)
2475  {
2476  // Check if this subdirectory component exists. If yes, make sure
2477  // it is actually a subdirectory. Otherwise create or cd into it.
2478  std::string part(path, start, end-start);
2479  TObject *o = gDirectory->Get(part.c_str());
2480  if (o && ! dynamic_cast<TDirectory *>(o))
2481  raiseDQMError("DQMStore", "Attempt to create directory '%s' in a file"
2482  " fails because the part '%s' already exists and is not"
2483  " directory", path.c_str(), part.c_str());
2484  else if (! o)
2485  gDirectory->mkdir(part.c_str());
2486 
2487  if (! gDirectory->cd(part.c_str()))
2488  raiseDQMError("DQMStore", "Attempt to create directory '%s' in a file"
2489  " fails because could not cd into subdirectory '%s'",
2490  path.c_str(), part.c_str());
2491 
2492  // Stop if we reached the end, ignoring any trailing '/'.
2493  if (end+1 >= path.size())
2494  break;
2495 
2496  // Find the next path component.
2497  start = end+1;
2498  end = path.find('/', start);
2499  if (end == std::string::npos)
2500  end = path.size();
2501  }
2502 
2503  return true;
2504 }
2505 
2507  const std::string &path /* = "" */,
2508  const uint32_t run /* = 0 */,
2509  const uint32_t lumi /* = 0 */,
2510  const bool resetMEsAfterWriting /* = false */)
2511 {
2512  using google::protobuf::io::FileOutputStream;
2513  using google::protobuf::io::GzipOutputStream;
2514  using google::protobuf::io::StringOutputStream;
2515 
2516  std::lock_guard<std::mutex> guard(book_mutex_);
2517 
2518  std::set<std::string>::iterator di, de;
2519  MEMap::iterator mi, me = data_.end();
2520  dqmstorepb::ROOTFilePB dqmstore_message;
2521  int nme = 0;
2522 
2523  if (verbose_)
2524  std::cout << "\n DQMStore: Opening PBFile '"
2525  << filename << "'"<< std::endl;
2526 
2527  // Loop over the directory structure.
2528  for (di = dirs_.begin(), de = dirs_.end(); di != de; ++di)
2529  {
2530  // Check if we should process this directory. We process the
2531  // requested part of the object tree, including references.
2532  if (! path.empty()
2533  && ! isSubdirectory(path, *di))
2534  continue;
2535 
2536  // Loop over monitor elements in this directory.
2537  MonitorElement proto(&*di, std::string(), run, 0, 0);
2538  if (enableMultiThread_)
2539  proto.setLumi(lumi);
2540 
2541  mi = data_.lower_bound(proto);
2542  for ( ; mi != me && isSubdirectory(*di, *mi->data_.dirname); ++mi)
2543  {
2544  if (verbose_ > 1)
2545  std::cout << "Run: " << (*mi).run()
2546  << " Lumi: " << (*mi).lumi()
2547  << " LumiFlag: " << (*mi).getLumiFlag()
2548  << " streamId: " << (*mi).streamId()
2549  << " moduleId: " << (*mi).moduleId()
2550  << " fullpathname: " << (*mi).getFullname() << std::endl;
2551 
2552  // Upper bound in the loop over the MEs
2553  if (enableMultiThread_ && ((*mi).lumi() != lumi))
2554  break;
2555 
2556  // Skip if it isn't a direct child.
2557  if (*di != *mi->data_.dirname)
2558  continue;
2559 
2560  // Keep backward compatibility with the old way of
2561  // booking/handlind MonitorElements into the DQMStore. If run is
2562  // 0 it means that a booking happened w/ the old non-threadsafe
2563  // style, and we have to ignore the streamId and moduleId as a
2564  // consequence.
2565 
2566  if (run != 0 && (mi->data_.streamId !=0 || mi->data_.moduleId !=0))
2567  continue;
2568 
2569  if (verbose_ > 1)
2570  std::cout << "DQMStore::savePB: saving monitor element '"
2571  << *mi->data_.dirname << "/" << mi->data_.objname << "'"
2572  << "flags " << mi->data_.flags << "\n";
2573 
2574  nme++;
2575  dqmstorepb::ROOTFilePB::Histo* me = dqmstore_message.add_histo();
2576  me->set_full_pathname((*mi->data_.dirname) + '/' + mi->data_.objname);
2577  me->set_flags(mi->data_.flags);
2578 
2579  TObject *toWrite = nullptr;
2580  bool deleteObject = false;
2581 
2582  if (mi->kind() < MonitorElement::DQM_KIND_TH1F) {
2583  toWrite = new TObjString(mi->tagString().c_str());
2584  deleteObject = true;
2585  } else {
2586  toWrite = mi->object_;
2587  }
2588 
2589  TBufferFile buffer(TBufferFile::kWrite);
2590  buffer.WriteObject(toWrite);
2591  me->set_size(buffer.Length());
2592  me->set_streamed_histo((const void*)buffer.Buffer(),
2593  buffer.Length());
2594 
2595  if (deleteObject) {
2596  delete toWrite;
2597  }
2598 
2599  //reset the ME just written to make it available for the next LS (online)
2600  if (resetMEsAfterWriting)
2601  const_cast<MonitorElement*>(&*mi)->Reset();
2602  }
2603  }
2604 
2605  int filedescriptor = ::open(filename.c_str(),
2606  O_WRONLY | O_CREAT | O_TRUNC,
2607  S_IRUSR | S_IWUSR |
2608  S_IRGRP | S_IWGRP |
2609  S_IROTH);
2610  FileOutputStream file_stream(filedescriptor);
2612  options.format = GzipOutputStream::GZIP;
2613  options.compression_level = 1;
2614  GzipOutputStream gzip_stream(&file_stream,
2615  options);
2616  dqmstore_message.SerializeToZeroCopyStream(&gzip_stream);
2617 
2618  // we need to flush it before we close the fd
2619  gzip_stream.Close();
2620  file_stream.Close();
2621  ::close(filedescriptor);
2622 
2623  // Maybe make some noise.
2624  if (verbose_)
2625  std::cout << "DQMStore::savePB: successfully wrote " << nme
2626  << " objects from path '" << path
2627  << "' into DQM file '" << filename << "'\n";
2628 }
2629 
2630 
2635 void
2637  const std::string &path /* = "" */,
2638  const std::string &pattern /* = "" */,
2639  const std::string &rewrite /* = "" */,
2640  const uint32_t run /* = 0 */,
2641  const uint32_t lumi /* = 0 */,
2642  SaveReferenceTag ref /* = SaveWithReference */,
2643  int minStatus /* = dqm::qstatus::STATUS_OK */,
2644  const std::string &fileupdate /* = RECREATE */,
2645  const bool resetMEsAfterWriting /* = false */)
2646 {
2647  std::lock_guard<std::mutex> guard(book_mutex_);
2648 
2649  std::set<std::string>::iterator di, de;
2650  MEMap::iterator mi, me = data_.end();
2651  DQMNet::QReports::const_iterator qi, qe;
2652  int nme=0;
2653 
2654  // TFile flushes to disk with fsync() on every TDirectory written to
2655  // the file. This makes DQM file saving painfully slow, and
2656  // ironically makes it _more_ likely the file saving gets
2657  // interrupted and corrupts the file. The utility class below
2658  // simply ignores the flush synchronisation.
2659  class TFileNoSync : public TFile
2660  {
2661  public:
2662  TFileNoSync(const char *file, const char *opt) : TFile(file, opt) {}
2663  virtual Int_t SysSync(Int_t) override { return 0; }
2664  };
2665 
2666  // open output file, on 1st save recreate, later update
2667  if (verbose_)
2668  std::cout << "\n DQMStore: Opening TFile '" << filename
2669  << "' with option '" << fileupdate <<"'\n";
2670 
2671  TFileNoSync f(filename.c_str(), fileupdate.c_str()); // open file
2672  if(f.IsZombie())
2673  raiseDQMError("DQMStore", "Failed to create/update file '%s'", filename.c_str());
2674  f.cd();
2675 
2676  // Construct a regular expression from the pattern string.
2677  std::auto_ptr<lat::Regexp> rxpat;
2678  if (! pattern.empty())
2679  rxpat.reset(new lat::Regexp(pattern.c_str()));
2680 
2681  // Prepare a path for the reference object selection.
2682  std::string refpath;
2683  refpath.reserve(s_referenceDirName.size() + path.size() + 2);
2684  refpath += s_referenceDirName;
2685  if (! path.empty())
2686  {
2687  refpath += '/';
2688  refpath += path;
2689  }
2690 
2691  // Loop over the directory structure.
2692  for (di = dirs_.begin(), de = dirs_.end(); di != de; ++di)
2693  {
2694  // Check if we should process this directory. We process the
2695  // requested part of the object tree, including references.
2696  if (! path.empty()
2697  && ! isSubdirectory(path, *di)
2698  && ! isSubdirectory(refpath, *di))
2699  continue;
2700 
2701  // Loop over monitor elements in this directory.
2702  MonitorElement proto(&*di, std::string(), run, 0, 0);
2703  if (enableMultiThread_)
2704  proto.setLumi(lumi);
2705 
2706  mi = data_.lower_bound(proto);
2707  for ( ; mi != me && isSubdirectory(*di, *mi->data_.dirname); ++mi)
2708  {
2709  if (verbose_ > 1)
2710  std::cout << "DQMStore::save: Run: " << (*mi).run()
2711  << " Lumi: " << (*mi).lumi()
2712  << " LumiFlag: " << (*mi).getLumiFlag()
2713  << " streamId: " << (*mi).streamId()
2714  << " moduleId: " << (*mi).moduleId()
2715  << " fullpathname: " << (*mi).getFullname() << std::endl;
2716 
2717  // Upper bound in the loop over the MEs
2718  if (enableMultiThread_ && ((*mi).lumi() != lumi))
2719  break;
2720 
2721  // Skip if it isn't a direct child.
2722  if (*di != *mi->data_.dirname) {
2723  if (verbose_ > 1)
2724  std::cout << "DQMStore::save: isn't a direct child. Skipping" << std::endl;
2725  continue;
2726  }
2727 
2728  // Keep backward compatibility with the old way of
2729  // booking/handlind MonitorElements into the DQMStore. If run is
2730  // 0 it means that a booking happened w/ the old non-threadsafe
2731  // style, and we have to ignore the streamId and moduleId as a
2732  // consequence.
2733 
2734  if (run != 0 && (mi->data_.streamId !=0 || mi->data_.moduleId !=0)) {
2735  continue;
2736  }
2737 
2738  // Handle reference histograms, with three distinct cases:
2739  // 1) Skip all references entirely on saving.
2740  // 2) Blanket saving of all references.
2741  // 3) Save only references for monitor elements with qtests.
2742  // The latter two are affected by "path" sub-tree selection,
2743  // i.e. references are saved only in the selected tree part.
2744  if (isSubdirectory(refpath, *mi->data_.dirname))
2745  {
2746  if (ref == SaveWithoutReference)
2747  // Skip the reference entirely.
2748  continue;
2749  else if (ref == SaveWithReference)
2750  // Save all references regardless of qtests.
2751  ;
2752  else if (ref == SaveWithReferenceForQTest)
2753  {
2754  // Save only references for monitor elements with qtests
2755  // with an optional cut on minimum quality test result.
2756  int status = -1;
2757  std::string mname(mi->getFullname(), s_referenceDirName.size()+1, std::string::npos);
2758  MonitorElement *master = get(mname);
2759  if (master)
2760  for (size_t i = 0, e = master->data_.qreports.size(); i != e; ++i)
2761  status = std::max(status, master->data_.qreports[i].code);
2762 
2763  if (! master || status < minStatus)
2764  {
2765  if (verbose_ > 1)
2766  std::cout << "DQMStore::save: skipping monitor element '"
2767  << mi->data_.objname << "' while saving, status is "
2768  << status << ", required minimum status is "
2769  << minStatus << std::endl;
2770  continue;
2771  }
2772  }
2773  }
2774 
2775  if (verbose_ > 1)
2776  std::cout << "DQMStore::save: saving monitor element '"
2777  << mi->data_.objname << "'\n";
2778  nme++; // count saved histograms
2779 
2780  // Create the directory.
2781  gDirectory->cd("/");
2782  if (di->empty())
2784  else if (rxpat.get())
2785  cdInto(s_monitorDirName + '/' + lat::StringOps::replace(*di, *rxpat, rewrite));
2786  else
2787  cdInto(s_monitorDirName + '/' + *di);
2788 
2789  // Save the object.
2790  switch (mi->kind())
2791  {
2795  TObjString(mi->tagString().c_str()).Write();
2796  break;
2797 
2798  default:
2799  mi->object_->Write();
2800  break;
2801  }
2802 
2803  // Save quality reports if this is not in reference section.
2804  if (! isSubdirectory(s_referenceDirName, *mi->data_.dirname))
2805  {
2806  qi = mi->data_.qreports.begin();
2807  qe = mi->data_.qreports.end();
2808  for ( ; qi != qe; ++qi)
2809  TObjString(mi->qualityTagString(*qi).c_str()).Write();
2810  }
2811 
2812  // Save efficiency tag, if any
2813  if (mi->data_.flags & DQMNet::DQM_PROP_EFFICIENCY_PLOT)
2814  TObjString(mi->effLabelString().c_str()).Write();
2815 
2816  // Save tag if any
2817  if (mi->data_.flags & DQMNet::DQM_PROP_TAGGED)
2818  TObjString(mi->tagLabelString().c_str()).Write();
2819 
2820  //reset the ME just written to make it available for the next LS (online)
2821  if (resetMEsAfterWriting)
2822  const_cast<MonitorElement*>(&*mi)->Reset();
2823  }
2824  }
2825 
2826  f.Close();
2827 
2828  // Maybe make some noise.
2829  if (verbose_)
2830  std::cout << "DQMStore::save: successfully wrote " << nme
2831  << " objects from path '" << path
2832  << "' into DQM file '" << filename << "'\n";
2833 }
2834 
2837 unsigned int
2839  bool overwrite,
2840  const std::string &onlypath,
2841  const std::string &prepend,
2842  const std::string &curdir,
2843  OpenRunDirs stripdirs)
2844 {
2845  unsigned int ntot = 0;
2846  unsigned int count = 0;
2847 
2848  if (! file->cd(curdir.c_str()))
2849  raiseDQMError("DQMStore", "Failed to process directory '%s' while"
2850  " reading file '%s'", curdir.c_str(), file->GetName());
2851 
2852  // Figure out current directory name, but strip out the top
2853  // directory into which we dump everything.
2854  std::string dirpart = curdir;
2855  if (dirpart.compare(0, s_monitorDirName.size(), s_monitorDirName) == 0)
2856  {
2857  if (dirpart.size() == s_monitorDirName.size())
2858  dirpart.clear();
2859  else if (dirpart[s_monitorDirName.size()] == '/')
2860  dirpart.erase(0, s_monitorDirName.size()+1);
2861  }
2862 
2863  // See if we are going to skip this directory.
2864  bool skip = (! onlypath.empty() && ! isSubdirectory(onlypath, dirpart));
2865 
2866  if (prepend == s_collateDirName ||
2867  prepend == s_referenceDirName ||
2868  stripdirs == StripRunDirs )
2869  {
2870  // Remove Run # and RunSummary dirs
2871  // first look for Run summary,
2872  // if that is found and erased, also erase Run dir
2873  size_t slash = dirpart.find('/');
2874  size_t pos = dirpart.find("/Run summary");
2875  if (slash != std::string::npos && pos !=std::string::npos)
2876  {
2877  dirpart.erase(pos,12);
2878 
2879  pos = dirpart.find("Run ");
2880  size_t length = dirpart.find('/',pos+1)-pos+1;
2881  if (pos !=std::string::npos)
2882  dirpart.erase(pos,length);
2883  }
2884  }
2885 
2886  // If we are prepending, add it to the directory name,
2887  // and suppress reading of already existing reference histograms
2888  if (prepend == s_collateDirName ||
2889  prepend == s_referenceDirName)
2890  {
2891  size_t slash = dirpart.find('/');
2892  // If we are reading reference, skip previous reference.
2893  if (slash == std::string::npos // skip if Reference is toplevel folder, i.e. no slash
2894  && slash+1+s_referenceDirName.size() == dirpart.size()
2895  && dirpart.compare(slash+1, s_referenceDirName.size(), s_referenceDirName) == 0)
2896  return 0;
2897 
2898  slash = dirpart.find('/');
2899  // Skip reading of EventInfo subdirectory.
2900  if (slash != std::string::npos
2901  && slash + 10 == dirpart.size()
2902  && dirpart.compare( slash+1 , 9 , "EventInfo") == 0) {
2903  if (verbose_)
2904  std::cout << "DQMStore::readDirectory: skipping '" << dirpart << "'\n";
2905  return 0;
2906  }
2907 
2908  // Add prefix.
2909  if (dirpart.empty())
2910  dirpart = prepend;
2911  else
2912  dirpart = prepend + '/' + dirpart;
2913  }
2914  else if (! prepend.empty())
2915  {
2916  if (dirpart.empty())
2917  dirpart = prepend;
2918  else
2919  dirpart = prepend + '/' + dirpart;
2920  }
2921 
2922  // Loop over the contents of this directory in the file.
2923  // Post-pone string object handling to happen after other
2924  // objects have been read in so we are guaranteed to have
2925  // histograms by the time we read in quality tests and tags.
2926  TKey *key;
2927  TIter next (gDirectory->GetListOfKeys());
2928  std::list<TObject *> delayed;
2929  while ((key = (TKey *) next()))
2930  {
2931  std::auto_ptr<TObject> obj(key->ReadObj());
2932  if (dynamic_cast<TDirectory *>(obj.get()))
2933  {
2934  std::string subdir;
2935  subdir.reserve(curdir.size() + strlen(obj->GetName()) + 2);
2936  subdir += curdir;
2937  if (! curdir.empty())
2938  subdir += '/';
2939  subdir += obj->GetName();
2940 
2941  ntot += readDirectory(file, overwrite, onlypath, prepend, subdir, stripdirs);
2942  }
2943  else if (skip)
2944  ;
2945  else if (dynamic_cast<TObjString *>(obj.get()))
2946  {
2947  delayed.push_back(obj.release());
2948  }
2949  else
2950  {
2951  if (verbose_ > 2)
2952  std::cout << "DQMStore: reading object '" << obj->GetName()
2953  << "' of type '" << obj->IsA()->GetName()
2954  << "' from '" << file->GetName()
2955  << "' into '" << dirpart << "'\n";
2956 
2957  makeDirectory(dirpart);
2958  if (extract(obj.get(), dirpart, overwrite, collateHistograms_))
2959  ++count;
2960  }
2961  }
2962 
2963  while (! delayed.empty())
2964  {
2965  if (verbose_ > 2)
2966  std::cout << "DQMStore: reading object '" << delayed.front()->GetName()
2967  << "' of type '" << delayed.front()->IsA()->GetName()
2968  << "' from '" << file->GetName()
2969  << "' into '" << dirpart << "'\n";
2970 
2971  makeDirectory(dirpart);
2972  if (extract(delayed.front(), dirpart, overwrite, collateHistograms_))
2973  ++count;
2974 
2975  delete delayed.front();
2976  delayed.pop_front();
2977  }
2978 
2979  if (verbose_ > 1)
2980  std::cout << "DQMStore: read " << count << '/' << ntot
2981  << " objects from directory '" << dirpart << "'\n";
2982 
2983  return ntot + count;
2984 }
2985 
2992 bool
2994  bool overwrite /* = false */,
2995  const std::string &onlypath /* ="" */,
2996  const std::string &prepend /* ="" */,
2997  OpenRunDirs stripdirs /* =KeepRunDirs */,
2998  bool fileMustExist /* =true */)
2999 {
3000  return readFile(filename,overwrite,onlypath,prepend,stripdirs,fileMustExist);
3001 }
3002 
3007 bool
3009  OpenRunDirs stripdirs /* =StripRunDirs */,
3010  bool fileMustExist /* =true */)
3011 {
3012  bool overwrite = true;
3013  if (collateHistograms_) overwrite = false;
3014  if (verbose_)
3015  {
3016  std::cout << "DQMStore::load: reading from file '" << filename << "'\n";
3017  if (collateHistograms_)
3018  std::cout << "DQMStore::load: in collate mode " << "\n";
3019  else
3020  std::cout << "DQMStore::load: in overwrite mode " << "\n";
3021  }
3022 
3023  if (!s_rxpbfile.match(filename, 0, 0))
3024  return readFile(filename, overwrite, "", "", stripdirs, fileMustExist);
3025  else
3026  return readFilePB(filename, overwrite, "", "", stripdirs, fileMustExist);
3027 }
3028 
3034 bool
3036  bool overwrite /* = false */,
3037  const std::string &onlypath /* ="" */,
3038  const std::string &prepend /* ="" */,
3039  OpenRunDirs stripdirs /* =StripRunDirs */,
3040  bool fileMustExist /* =true */)
3041 {
3042 
3043  if (verbose_)
3044  std::cout << "DQMStore::readFile: reading from file '" << filename << "'\n";
3045 
3046  std::auto_ptr<TFile> f;
3047 
3048  try
3049  {
3050  f.reset(TFile::Open(filename.c_str()));
3051  if (! f.get() || f->IsZombie())
3052  raiseDQMError("DQMStore", "Failed to open file '%s'", filename.c_str());
3053  }
3054  catch (std::exception &)
3055  {
3056  if (fileMustExist)
3057  throw;
3058  else
3059  {
3060  if (verbose_)
3061  std::cout << "DQMStore::readFile: file '" << filename << "' does not exist, continuing\n";
3062  return false;
3063  }
3064  }
3065 
3066  unsigned n = readDirectory(f.get(), overwrite, onlypath, prepend, "", stripdirs);
3067  f->Close();
3068 
3069  MEMap::iterator mi = data_.begin();
3070  MEMap::iterator me = data_.end();
3071  for ( ; mi != me; ++mi)
3072  const_cast<MonitorElement &>(*mi).updateQReportStats();
3073 
3074  if (verbose_)
3075  {
3076  std::cout << "DQMStore::open: successfully read " << n
3077  << " objects from file '" << filename << "'";
3078  if (! onlypath.empty())
3079  std::cout << " from directory '" << onlypath << "'";
3080  if (! prepend.empty())
3081  std::cout << " into directory '" << prepend << "'";
3082  std::cout << std::endl;
3083  }
3084  return true;
3085 }
3086 
3090 inline TObject * DQMStore::extractNextObject(TBufferFile &buf) const {
3091  if (buf.Length() == buf.BufferSize())
3092  return 0;
3093  buf.InitMap();
3094  void *ptr = buf.ReadObjectAny(0);
3095  return reinterpret_cast<TObject *>(ptr);
3096 }
3097 
3100  std::string &objname,
3101  TObject ** obj) {
3102 
3103  size_t slash = h.full_pathname().rfind('/');
3104  size_t dirpos = (slash == std::string::npos ? 0 : slash);
3105  size_t namepos = (slash == std::string::npos ? 0 : slash+1);
3106  dirname.assign(h.full_pathname(), 0, dirpos);
3107  objname.assign(h.full_pathname(), namepos, std::string::npos);
3108  TBufferFile buf(TBufferFile::kRead, h.size(),
3109  (void*)h.streamed_histo().data(),
3110  kFALSE);
3111  buf.Reset();
3112  *obj = extractNextObject(buf);
3113  if (!*obj) {
3114  raiseDQMError("DQMStore", "Error reading element:'%s'" , h.full_pathname().c_str());
3115  }
3116 }
3117 
3118 bool
3120  bool overwrite /* = false */,
3121  const std::string &onlypath /* ="" */,
3122  const std::string &prepend /* ="" */,
3123  OpenRunDirs stripdirs /* =StripRunDirs */,
3124  bool fileMustExist /* =true */)
3125 {
3126  using google::protobuf::io::FileInputStream;
3127  using google::protobuf::io::FileOutputStream;
3128  using google::protobuf::io::GzipInputStream;
3129  using google::protobuf::io::GzipOutputStream;
3130  using google::protobuf::io::CodedInputStream;
3131  using google::protobuf::io::ArrayInputStream;
3132 
3133  if (verbose_)
3134  std::cout << "DQMStore::readFile: reading from file '" << filename << "'\n";
3135 
3136  int filedescriptor;
3137  if ((filedescriptor = ::open(filename.c_str(), O_RDONLY)) == -1) {
3138  if (fileMustExist)
3139  raiseDQMError("DQMStore", "Failed to open file '%s'", filename.c_str());
3140  else
3141  if (verbose_)
3142  std::cout << "DQMStore::readFile: file '" << filename << "' does not exist, continuing\n";
3143  return false;
3144  }
3145 
3146  dqmstorepb::ROOTFilePB dqmstore_message;
3147  FileInputStream fin(filedescriptor);
3148  GzipInputStream input(&fin);
3149  CodedInputStream input_coded(&input);
3150  input_coded.SetTotalBytesLimit(1024*1024*1024, -1);
3151  if (!dqmstore_message.ParseFromCodedStream(&input_coded)) {
3152  raiseDQMError("DQMStore", "Fatal parsing file '%s'", filename.c_str());
3153  return false;
3154  }
3155  ::close(filedescriptor);
3156 
3157  for (int i = 0; i < dqmstore_message.histo_size(); i++) {
3158  std::string path;
3159  std::string objname;
3160 
3161  TObject *obj = NULL;
3162  const dqmstorepb::ROOTFilePB::Histo &h = dqmstore_message.histo(i);
3163  get_info(h, path, objname, &obj);
3164 
3165  setCurrentFolder(path);
3166  if (obj)
3167  {
3168  /* Before calling the extract() check if histogram exists:
3169  * if it does - flags for the given monitor are already set (and merged)
3170  * else - set the flags after the histogram is created.
3171  */
3172  MonitorElement *me = findObject(path, objname);
3173 
3174  /* Run histograms should be collated and not overwritten,
3175  * Lumi histograms should be overwritten (and collate flag is not checked)
3176  */
3177  bool overwrite = h.flags() & DQMNet::DQM_PROP_LUMI;
3178  bool collate = !(h.flags() & DQMNet::DQM_PROP_LUMI);
3179  extract(static_cast<TObject *>(obj), path, overwrite, collate);
3180 
3181  if (me == nullptr) {
3182  me = findObject(path, objname);
3183  me->data_.flags = h.flags();
3184  }
3185 
3186  delete obj;
3187  }
3188  }
3189 
3190  cd();
3191  return true;
3192 }
3193 
3199 void
3201 {
3203  const std::string *cleaned = 0;
3204  cleanTrailingSlashes(path, clean, cleaned);
3205  MonitorElement proto(cleaned, std::string());
3206 
3207  MEMap::iterator e = data_.end();
3208  MEMap::iterator i = data_.lower_bound(proto);
3209  while (i != e && isSubdirectory(*cleaned, *i->data_.dirname))
3210  data_.erase(i++);
3211 
3212  std::set<std::string>::iterator de = dirs_.end();
3213  std::set<std::string>::iterator di = dirs_.lower_bound(*cleaned);
3214  while (di != de && isSubdirectory(*cleaned, *di))
3215  dirs_.erase(di++);
3216 }
3217 
3219 void
3221 {
3222  MonitorElement proto(&dir, std::string());
3223  MEMap::iterator e = data_.end();
3224  MEMap::iterator i = data_.lower_bound(proto);
3225  while (i != e && isSubdirectory(dir, *i->data_.dirname))
3226  if (dir == *i->data_.dirname)
3227  data_.erase(i++);
3228  else
3229  ++i;
3230 }
3231 
3233 void
3235 {
3237 }
3238 
3241 void
3243 {
3244  removeElement(pwd_, name);
3245 }
3246 
3249 void
3250 DQMStore::removeElement(const std::string &dir, const std::string &name, bool warning /* = true */)
3251 {
3252  MonitorElement proto(&dir, name);
3253  MEMap::iterator pos = data_.find(proto);
3254  if (pos != data_.end())
3255  data_.erase(pos);
3256  else if (warning)
3257  std::cout << "DQMStore: WARNING: attempt to remove non-existent"
3258  << " monitor element '" << name << "' in '" << dir << "'\n";
3259 }
3260 
3266 QCriterion *
3268 {
3269  QCMap::const_iterator i = qtests_.find(qtname);
3270  QCMap::const_iterator e = qtests_.end();
3271  return (i == e ? 0 : i->second);
3272 }
3273 
3277 QCriterion *
3278 DQMStore::createQTest(const std::string &algoname, const std::string &qtname)
3279 {
3280  if (qtests_.count(qtname))
3281  raiseDQMError("DQMStore", "Attempt to create duplicate quality test '%s'",
3282  qtname.c_str());
3283 
3284  QAMap::iterator i = qalgos_.find(algoname);
3285  if (i == qalgos_.end())
3286  raiseDQMError("DQMStore", "Cannot create a quality test using unknown"
3287  " algorithm '%s'", algoname.c_str());
3288 
3289  QCriterion *qc = i->second(qtname);
3290  qc->setVerbose(verboseQT_);
3291 
3292  qtests_[qtname] = qc;
3293  return qc;
3294 }
3295 
3298 void
3300 {
3301  // Clean the path
3303  const std::string *cleaned = 0;
3304  cleanTrailingSlashes(dir, clean, cleaned);
3305 
3306  // Validate the path.
3307  if (cleaned->find_first_not_of(s_safe) != std::string::npos)
3308  raiseDQMError("DQMStore", "Monitor element path name '%s'"
3309  " uses unacceptable characters", cleaned->c_str());
3310 
3311  // Redirect to the pattern match version.
3312  useQTestByMatch(*cleaned + "/*", qtname);
3313 }
3314 
3316 int
3318 {
3319  QCriterion *qc = getQCriterion(qtname);
3320  if (! qc)
3321  raiseDQMError("DQMStore", "Cannot apply non-existent quality test '%s'",
3322  qtname.c_str());
3323 
3324  fastmatch * fm = new fastmatch( pattern );
3325 
3326  // Record the test for future reference.
3327  QTestSpec qts(fm, qc);
3328  qtestspecs_.push_back(qts);
3329 
3330  // Apply the quality test.
3331  MEMap::iterator mi = data_.begin();
3332  MEMap::iterator me = data_.end();
3333  std::string path;
3334  int cases = 0;
3335  for ( ; mi != me; ++mi)
3336  {
3337  path.clear();
3338  mergePath(path, *mi->data_.dirname, mi->data_.objname);
3339  if (fm->match(path))
3340  {
3341  ++cases;
3342  const_cast<MonitorElement &>(*mi).addQReport(qts.second);
3343  }
3344  }
3345 
3346  //return the number of matched cases
3347  return cases;
3348 }
3351 void
3353 {
3354 
3355  if (verbose_ > 0)
3356  std::cout << "DQMStore: running runQTests() with reset = "
3357  << ( reset_ ? "true" : "false" ) << std::endl;
3358 
3359  // Apply quality tests to each monitor element, skipping references.
3360  MEMap::iterator mi = data_.begin();
3361  MEMap::iterator me = data_.end();
3362  for ( ; mi != me; ++mi)
3363  if (! isSubdirectory(s_referenceDirName, *mi->data_.dirname))
3364  const_cast<MonitorElement &>(*mi).runQTests();
3365 
3366  reset_ = false;
3367 }
3368 
3372 int
3373 DQMStore::getStatus(const std::string &path /* = "" */) const
3374 {
3376  const std::string *cleaned = 0;
3377  cleanTrailingSlashes(path, clean, cleaned);
3378 
3380  MEMap::const_iterator mi = data_.begin();
3381  MEMap::const_iterator me = data_.end();
3382  for ( ; mi != me; ++mi)
3383  {
3384  if (! cleaned->empty() && ! isSubdirectory(*cleaned, *mi->data_.dirname))
3385  continue;
3386 
3387  if (mi->hasError())
3388  return dqm::qstatus::ERROR;
3389  else if (mi->hasWarning())
3390  status = dqm::qstatus::WARNING;
3391  else if (status < dqm::qstatus::WARNING
3392  && mi->hasOtherReport())
3393  status = dqm::qstatus::OTHER;
3394  }
3395  return status;
3396 }
3397 
3403 void
3405 {
3406  if (me)
3407  me->softReset();
3408 }
3409 
3410 // reverts action of softReset
3411 void
3413 {
3414  if (me)
3415  me->disableSoftReset();
3416 }
3417 
3420 void
3422 {
3423  if (me)
3424  me->setAccumulate(flag);
3425 }
3426 
3430 void
3432 {
3433  std::vector<std::string> contents;
3434  getContents(contents);
3435 
3436  std::cout << " ------------------------------------------------------------\n"
3437  << " Directory structure: \n"
3438  << " ------------------------------------------------------------\n";
3439 
3440  std::copy(contents.begin(), contents.end(),
3441  std::ostream_iterator<std::string>(std::cout, "\n"));
3442 
3443  std::cout << " ------------------------------------------------------------\n";
3444 }
3445 
3449 // check if the collate option is active on the DQMStore
3450 bool
3452 {
3453  return collateHistograms_;
3454 }
3458 // check if the monitor element is in auto-collation folder
3459 bool
3461 { return me && isSubdirectory(s_collateDirName, *me->data_.dirname); }
3465 
3467 void
3469 {
3470  if (scaleFlag_ == 0.0) return;
3471  if (verbose_ > 0)
3472  std::cout << " =========== " << " ScaleFlag " << scaleFlag_ << std::endl;
3473  double factor = scaleFlag_;
3474  int events = 1;
3475  if (dirExists("Info/EventInfo")) {
3476  if ( scaleFlag_ == -1.0) {
3477  MonitorElement * scale_me = get("Info/EventInfo/ScaleFactor");
3478  if (scale_me && scale_me->kind()==MonitorElement::DQM_KIND_REAL) factor = scale_me->getFloatValue();
3479  }
3480  MonitorElement * event_me = get("Info/EventInfo/processedEvents");
3481  if (event_me && event_me->kind()==MonitorElement::DQM_KIND_INT) events = event_me->getIntValue();
3482  }
3483  factor = factor/(events*1.0);
3484 
3485  MEMap::iterator mi = data_.begin();
3486  MEMap::iterator me = data_.end();
3487  for ( ; mi != me; ++mi)
3488  {
3489  MonitorElement &me = const_cast<MonitorElement &>(*mi);
3490  switch (me.kind())
3491  {
3493  {
3494  me.getTH1F()->Scale(factor);
3495  break;
3496  }
3498  {
3499  me.getTH1S()->Scale(factor);
3500  break;
3501  }
3503  {
3504  me.getTH1D()->Scale(factor);
3505  break;
3506  }
3508  {
3509  me.getTH2F()->Scale(factor);
3510  break;
3511  }
3513  {
3514  me.getTH2S()->Scale(factor);
3515  break;
3516  }
3518  {
3519  me.getTH2D()->Scale(factor);
3520  break;
3521  }
3523  {
3524  me.getTH3F()->Scale(factor);
3525  break;
3526  }
3528  {
3529  me.getTProfile()->Scale(factor);
3530  break;
3531  }
3533  {
3534  me.getTProfile2D()->Scale(factor);
3535  break;
3536  }
3537  default:
3538  if (verbose_ > 0)
3539  std::cout << " The DQM object '" << me.getFullname() << "' is not scalable object " << std::endl;
3540  continue;
3541  }
3542  }
3543 }
QCriterion * getQCriterion(const std::string &qtname) const
Definition: DQMStore.cc:3267
MonitorElement * getElement(const std::string &path)
Definition: DQMStore.cc:308
IGetter * igetter_
Definition: DQMStore.h:723
bool compare_strings_reverse(std::string const &pattern, std::string const &input) const
Definition: DQMStore.cc:207
std::pair< fastmatch *, QCriterion * > QTestSpec
Definition: DQMStore.h:693
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:503
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:1171
bool containsAnyMonitorable(const std::string &path) const
Definition: DQMStore.cc:1765
uint32_t moduleId
Definition: DQMNet.h:104
inline::google::protobuf::uint32 size() const
tuple array
Definition: mps_check.py:181
bool isCollateME(MonitorElement *me) const
Definition: DQMStore.cc:3460
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:2464
const ::std::string & full_pathname() const
void cd(void)
Definition: DQMStore.cc:338
int getStatus(const std::string &path="") const
Definition: DQMStore.cc:3373
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:110
std::string algorithm
Definition: DQMNet.h:93
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1726
TProfile2D * getTProfile2D(void) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:1021
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:3200
static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose)
Definition: DQMStore.cc:1630
bool match(std::string const &s) const
Definition: DQMStore.cc:249
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:3035
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:1905
static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose)
Definition: DQMStore.cc:1637
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:1283
void setLumi(uint32_t ls)
void cd(void)
Definition: DQMStore.cc:268
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:704
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:304
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:1193
uint32_t streamId_
Definition: DQMStore.h:709
tuple lumi
Definition: fjr2json.py:35
static const std::string s_safe
Definition: DQMStore.cc:58
static void splitPath(std::string &dir, std::string &name, const std::string &path)
Definition: DQMStore.cc:97
uint32_t flags
Definition: DQMNet.h:98
const std::string & pwd(void)
Definition: DQMStore.cc:284
assert(m_qm.get())
void disableSoftReset(void)
reverts action of softReset
static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose)
Definition: DQMStore.cc:1623
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
Definition: DQMStore.cc:2037
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:72
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:99
bool reset_
Definition: DQMStore.h:701
const std::string * dirname
Definition: DQMNet.h:105
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:1053
void initializeFrom(const edm::ParameterSet &)
Definition: DQMStore.cc:575
#define nullptr
OpenRunDirs
Definition: DQMStore.h:84
void set_flags(::google::protobuf::uint32 value)
uint32_t run
Definition: DQMNet.h:101
uint32_t moduleId_
Definition: DQMStore.h:710
const ::std::string & streamed_histo() const
void initQCriterion(std::map< std::string, QCriterion *(*)(const std::string &)> &m)
Definition: DQMStore.cc:126
QCMap qtests_
Definition: DQMStore.h:717
static const std::string s_collateDirName
Definition: DQMStore.cc:57
MonitorElement * book(const std::string &dir, const std::string &name, const char *context)
Definition: DQMStore.cc:876
static const std::string s_monitorDirName
name of global monitoring folder (containing all sources subdirectories)
Definition: DQMStore.cc:55
std::mutex book_mutex_
Definition: DQMStore.h:721
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:958
static std::string const input
Definition: EdmProvDump.cc:44
SaveReferenceTag
Definition: DQMStore.h:78
tuple result
Definition: mps_fire.py:84
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:80
Preallocate preallocateSignal_
signal is emitted before beginJob
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1661
~DQMStore(void)
Definition: DQMStore.cc:561
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:3412
unsigned int maxNumberOfStreams() const
Definition: SystemBounds.h:43
static const lat::Regexp s_rxmeval("^<(.*)>(i|f|s|e|t|qr)=(.*)</\\1>$")
void forceReset(void)
Definition: DQMStore.cc:2097
static bool isSubdirectory(const std::string &ofdir, const std::string &path)
Definition: DQMStore.cc:70
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1988
fastmatch(std::string const &_fastString)
Definition: DQMStore.cc:131
unsigned verboseQT_
Definition: DQMStore.h:700
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:3234
QTestSpecs qtestspecs_
Definition: DQMStore.h:719
double scaleFlag_
Definition: DQMStore.h:702
void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi)
Definition: DQMStore.cc:2121
void get_info(const dqmstorepb::ROOTFilePB_Histo &, std::string &dirname, std::string &objname, TObject **obj)
Definition: DQMStore.cc:3098
void watchPostSourceRun(PostSourceRun::slot_type const &iSlot)
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:987
void setAccumulate(bool)
uint32_t lumi
Definition: DQMNet.h:102
bool isCollate(void) const
Definition: DQMStore.cc:3451
void removeElement(const std::string &name)
Definition: DQMStore.cc:3242
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
def move
Definition: eostools.py:510
static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose)
Definition: DQMStore.cc:1647
double getFloatValue(void) const
void tag(MonitorElement *, unsigned int)
Definition: DQMStore.cc:288
TH1 * getTH1(void) const
double f[11][100]
uint32_t run_
Definition: DQMStore.h:708
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:1335
QCriterion * makeQCriterion(const std::string &qtname)
Definition: DQMStore.cc:121
#define end
Definition: vmac.h:37
void setVerbose(unsigned level)
Definition: DQMStore.cc:691
void softReset(MonitorElement *me)
Definition: DQMStore.cc:3404
std::string pwd_
Definition: DQMStore.h:713
Kind kind(void) const
Get the type of the monitor element.
void runQTests(void)
Definition: DQMStore.cc:3352
TObject * extractNextObject(TBufferFile &) const
Definition: DQMStore.cc:3090
lat::Regexp * regexp_
Definition: DQMStore.h:70
IBooker * ibooker_
Definition: DQMStore.h:722
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1775
QAMap qalgos_
Definition: DQMStore.h:718
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:1804
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::string readSelectedDirectory_
Definition: DQMStore.h:707
std::vector< std::string > getMEs(void)
Definition: DQMStore.cc:326
std::string objname
Definition: DQMNet.h:106
void mergeAndResetMEsRunSummaryCache(uint32_t run, uint32_t streamId, uint32_t moduleId)
Definition: DQMStore.cc:359
std::string fastString_
Definition: DQMStore.h:71
std::vector< T * > clean
Definition: MVATrainer.cc:156
std::string qtname
Definition: DQMNet.h:92
DQMNet::CoreObject data_
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:792
void savePB(const std::string &filename, const std::string &path="", const uint32_t run=0, const uint32_t lumi=0, const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2506
void getAllTags(std::vector< std::string > &into) const
Definition: DQMStore.cc:1935
bool dirExists(const std::string &path)
Definition: DQMStore.cc:334
bool load(const std::string &filename, OpenRunDirs stripdirs=StripRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:3008
void scaleElements(void)
Definition: DQMStore.cc:3468
~fastmatch()
Definition: DQMStore.cc:201
static void collate1DD(MonitorElement *me, TH1D *h, unsigned verbose)
Definition: DQMStore.cc:1602
void tagAllContents(const std::string &path, unsigned int myTag)
Definition: DQMStore.cc:1704
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
MonitorElement * initialise(MonitorElement *me, const std::string &path)
void watchPostSourceLumi(PostSourceLumi::slot_type const &iSlot)
void goUp(void)
Definition: DQMStore.cc:280
bool containsAnyMonitorable(const std::string &path)
Definition: DQMStore.cc:330
void tagContents(const std::string &, unsigned int)
Definition: DQMStore.cc:292
const ::dqmstorepb::ROOTFilePB_Histo & histo(int index) const
unsigned verbose_
Definition: DQMStore.h:699
void set_size(::google::protobuf::uint32 value)
MEMap data_
Definition: DQMStore.h:714
part
Definition: HCALResponse.h:20
int64_t getIntValue(void) const
static const std::string s_referenceDirName
Definition: DQMStore.cc:56
void print_trace(const std::string &dir, const std::string &name)
Definition: DQMStore.cc:635
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:3317
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0)
Definition: DQMStore.cc:298
TH1F * getTH1F(void) const
static void collate1D(MonitorElement *me, TH1F *h, unsigned verbose)
Definition: DQMStore.cc:1588
tuple demangled
Definition: symbols.py:61
static const lat::Regexp s_rxpbfile(".*\\.pb$")
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1749
std::vector< std::string > getSubdirs(void)
Definition: DQMStore.cc:322
DQMStore * owner_
Definition: DQMStore.h:187
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:346
bool resetMe(void) const
true if ME should be reset at end of monitoring cycle
void set_full_pathname(const ::std::string &value)
unsigned int readDirectory(TFile *file, bool overwrite, const std::string &path, const std::string &prepend, const std::string &curdir, OpenRunDirs stripdirs)
Definition: DQMStore.cc:2838
void setVerbose(int verbose)
probability limits for warnings, errors
Definition: QTest.h:116
bool extract(TObject *obj, const std::string &dir, bool overwrite, bool collateHistograms)
Definition: DQMStore.cc:2163
bool forceResetOnBeginLumi_
Definition: DQMStore.h:706
T dot(const Basic3DVector &v) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
std::vector< boost::shared_ptr< fireworks::OptionNode > > Options
void tagContents(const std::string &path, unsigned int myTag)
tag all children of folder (does NOT include subfolders)
Definition: DQMStore.cc:1692
tuple events
Definition: patZpeak.py:19
if(dp >Float(M_PI)) dp-
inline::dqmstorepb::ROOTFilePB_Histo * add_histo()
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2636
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:3119
TProfile * getTProfile(void) const
void useQTest(const std::string &dir, const std::string &qtname)
Definition: DQMStore.cc:3299
tuple filename
Definition: lut2db_cfg.py:20
std::string message
Definition: DQMNet.h:91
void goUp(void)
equivalent to &quot;cd ..&quot;
Definition: DQMStore.cc:738
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:2993
inline::google::protobuf::uint32 flags() const
static const int STATUS_OK
void setAccumulate(MonitorElement *me, bool flag)
Definition: DQMStore.cc:3421
tuple cout
Definition: gather_cfg.py:145
void setEfficiencyFlag(void)
static void collate1S(MonitorElement *me, TH1S *h, unsigned verbose)
Definition: DQMStore.cc:1595
void Reset(std::vector< TH2F > &depth)
std::ofstream * stream_
Definition: DQMStore.h:711
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
Definition: DQMStore.cc:3278
static bool checkBinningMatches(MonitorElement *me, TH1 *h, unsigned verbose)
Definition: DQMStore.cc:1561
dbl *** dir
Definition: mlp_gen.cc:35
volatile std::atomic< bool > shutdown_flag false
void showDirStructure(void) const
Definition: DQMStore.cc:3431
void reset(void)
Definition: DQMStore.cc:2073
bool deleteObject(T *fObject, const std::string &fInput, const std::string &fInputTag, HcalDbTool::IOVRun fInputRun, bool fVerbose)
TH2F * getTH2F(void) const
static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose)
Definition: DQMStore.cc:1609
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:928
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:1149
tuple collateHistograms
for(const auto &isodef:isoDefs)
long double T
uint32_t streamId
Definition: DQMNet.h:103
void mergeAndResetMEsLuminositySummaryCache(uint32_t run, uint32_t lumi, uint32_t streamId, uint32_t moduleId)
Definition: DQMStore.cc:432
float qtresult
Definition: DQMNet.h:90
std::set< std::string > dirs_
Definition: DQMStore.h:715
bool collateHistograms_
Definition: DQMStore.h:703
void Reset(void)
reset ME (ie. contents, errors, etc)
static const uint32_t DQM_PROP_LUMI
Definition: DQMNet.h:60
static std::string const source
Definition: EdmProvDump.cc:43
bool LSbasedMode_
Definition: DQMStore.h:705
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:1037
tuple size
Write out results.
static const lat::Regexp s_rxmeqr1("^st:(\\d+):([-+e.\\d]+):([^:]*):(.*)$")
void makeDirectory(const std::string &path)
Definition: DQMStore.cc:751
void connect(U iFunc)
Definition: Signal.h:63
bool compare_strings(std::string const &pattern, std::string const &input) const
Definition: DQMStore.cc:228
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:727
static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose)
Definition: DQMStore.cc:1616
static const int ERROR
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
tuple status
Definition: mps_update.py:57
const std::string & pwd(void) const
Definition: DQMStore.cc:699
bool enableMultiThread_
Definition: DQMStore.h:704
void set_streamed_histo(const ::std::string &value)
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Check the consistency of the axis labels.
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:1479
void raiseDQMError(const char *context, const char *fmt,...)
Definition: DQMError.cc:11