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