6 #include "classlib/utils/RegexpMatch.h"
7 #include "classlib/utils/Regexp.h"
8 #include "classlib/utils/StringOps.h"
16 #include <boost/algorithm/string.hpp>
50 static std::string s_safe =
"/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_()# ";
52 static const lat::Regexp
s_rxmeval (
"^<(.*)>(i|f|s|e|t|qr)=(.*)</\\1>$");
53 static const lat::Regexp
s_rxmeqr1 (
"^st:(\\d+):([-+e.\\d]+):([^:]*):(.*)$");
54 static const lat::Regexp
s_rxmeqr2 (
"^st\\.(\\d+)\\.(.*)$");
55 static const lat::Regexp
s_rxtrace (
"(.*)\\((.*)\\+0x.*\\).*");
64 || (path.size() >= ofdir.size()
65 && path.compare(0, ofdir.size(), ofdir) == 0
66 && (path.size() == ofdir.size()
67 || path[ofdir.size()] ==
'/')));
76 size_t len = path.size();
77 for ( ; len > 0 && path[len-1] ==
'/'; --len)
80 if (len != path.size())
82 clean = path.substr(0, len);
90 size_t slash = path.rfind(
'/');
91 if (slash != std::string::npos)
93 dir.append(path, 0, slash);
94 name.append(path, slash+1, std::string::npos);
103 path.reserve(dir.size() + name.size() + 2);
113 {
return new T(qtname); }
118 {
m[T::getAlgoName()] = &makeQCriterion<T>; }
123 fastString_ (_fastString), matching_ (UseFull)
131 catch (lat::Error &
e)
134 raiseDQMError(
"DQMStore",
"Invalid wildcard pattern '%s' in quality"
139 size_t starCount = 0;
144 if ((
size_t)pos == std::string::npos)
150 if ((
fastString_.find(
'"') != std::string::npos) ||
163 if (boost::algorithm::starts_with(
fastString_,
"*"))
181 if (boost::algorithm::starts_with(
fastString_,
"*") &&
201 if (input.size() < pattern.size())
207 std::string::const_reverse_iterator rit_pattern = pattern.rbegin();
208 std::string::const_reverse_iterator rit_input = input.rbegin();
210 for (; rit_pattern < pattern.rend(); rit_pattern++, rit_input++)
212 if (*rit_pattern != *rit_input)
222 if (input.size() < pattern.size())
228 std::string::const_iterator rit_pattern = pattern.begin();
229 std::string::const_iterator rit_input = input.begin();
231 for (; rit_pattern < pattern.end(); rit_pattern++, rit_input++)
233 if (*rit_pattern != *rit_input)
263 collateHistograms_ (
false),
264 readSelectedDirectory_ (
""),
271 std::cout << __LINE__ <<
" DQMStore::DQMStore " << std::endl;
278 collateHistograms_ (
false),
279 readSelectedDirectory_ (
""),
311 std::cout <<
"DQMStore: histogram collation is enabled\n";
316 std::cout <<
"DQMStore: using reference file '" << ref <<
"'\n";
320 initQCriterion<Comp2RefChi2>(
qalgos_);
321 initQCriterion<Comp2RefKolmogorov>(
qalgos_);
322 initQCriterion<ContentsXRange>(
qalgos_);
323 initQCriterion<ContentsYRange>(
qalgos_);
324 initQCriterion<MeanWithinExpected>(
qalgos_);
325 initQCriterion<Comp2RefEqualH>(
qalgos_);
326 initQCriterion<DeadChannel>(
qalgos_);
327 initQCriterion<NoisyChannel>(
qalgos_);
328 initQCriterion<ContentsWithinExpected>(
qalgos_);
329 initQCriterion<CompareToMedian>(
qalgos_);
330 initQCriterion<CompareLastFilledBin>(
qalgos_);
334 std::cout <<
"DQMStore: Scaling Flag set to " << scaleFlag_ << std::endl;
349 static std::ofstream stream(
"histogramBookingBT.log");
357 size = backtrace (array, 10);
358 strings = backtrace_symbols (array, size);
363 char * demangled = abi::__cxa_demangle(m.matchString(strings[4], 2).c_str(), 0, 0, &
r);
364 stream <<
"\"" << dir <<
"/"
366 << (r ? m.matchString(strings[4], 2) : demangled) <<
" "
367 << m.matchString(strings[4], 1) <<
"\n";
371 stream <<
"Skipping "<< dir <<
"/" << name
372 <<
" with stack size " << size <<
"\n";
380 for (i = 0; i <
size; i++)
381 if (
s_rxtrace.match(strings[i], 0, 0, &m))
383 char * demangled = abi::__cxa_demangle(m.matchString(strings[i], 2).c_str(), 0, 0, &
r);
384 stream <<
"\t\t" << i <<
"/" << size <<
" "
385 << (r ? m.matchString(strings[i], 2) : demangled) <<
" "
386 << m.matchString(strings[i], 1) << std::endl;
423 raiseDQMError(
"DQMStore",
"Cannot 'cd' into non-existent directory '%s'",
448 if (pos == std::string::npos)
462 prev.reserve(path.size());
463 subdir.reserve(path.size());
464 name.reserve(path.size());
472 subdir.append(path, 0, slash);
474 name.append(subdir, prevname, std::string::npos);
476 raiseDQMError(
"DQMStore",
"Attempt to create subdirectory '%s'"
477 " which already exists as a monitor element",
480 if (!
dirs_.count(subdir))
481 dirs_.insert(subdir);
484 if (slash+1 >= path.size())
489 prevname = slash ? slash+1 :
slash;
491 if ((slash = path.find(
'/', ++slash)) == std::string::npos)
499 {
return dirs_.count(path) > 0; }
504 template <
class HISTO,
class COLLATE>
507 const char *context,
int kind,
508 HISTO *
h, COLLATE collate)
510 assert(name.find(
'/') == std::string::npos);
533 << context <<
": monitor element '"
534 << path <<
"' already exists, collating" << std::endl;
544 assert(
dirs_.count(dir));
552 for ( ; qi != qe; ++qi)
554 if ( qi->first->match(path) )
555 me->addQReport(qi->second);
568 me->reference_ = refme->object_;
581 assert(name.find(
'/') == std::string::npos);
594 << context <<
": monitor element '"
595 << path <<
"' already exists, resetting" << std::endl;
603 assert(
dirs_.count(dir));
623 return book(dir, name,
"bookInt")
653 return book(dir, name,
"bookFloat")
682 return book(dir, name,
"bookString")
723 int nchX,
double lowX,
double highX)
725 return book1D(
pwd_, name,
new TH1F(name, title, nchX, lowX, highX));
731 int nchX,
double lowX,
double highX)
733 return book1D(
pwd_, name,
new TH1F(name.c_str(), title.c_str(), nchX, lowX, highX));
739 int nchX,
double lowX,
double highX)
741 return book1S(
pwd_, name,
new TH1S(name, title, nchX, lowX, highX));
747 int nchX,
double lowX,
double highX)
749 return book1S(
pwd_, name,
new TH1S(name.c_str(), title.c_str(), nchX, lowX, highX));
755 int nchX,
double lowX,
double highX)
757 return book1DD(
pwd_, name,
new TH1D(name, title, nchX, lowX, highX));
763 int nchX,
double lowX,
double highX)
765 return book1DD(
pwd_, name,
new TH1D(name.c_str(), title.c_str(), nchX, lowX, highX));
771 int nchX,
float *xbinsize)
773 return book1D(
pwd_, name,
new TH1F(name, title, nchX, xbinsize));
779 int nchX,
float *xbinsize)
781 return book1D(
pwd_, name,
new TH1F(name.c_str(), title.c_str(), nchX, xbinsize));
788 return book1D(
pwd_, name, static_cast<TH1F *>(source->Clone(name)));
795 return book1D(
pwd_, name, static_cast<TH1F *>(source->Clone(name.c_str())));
802 return book1S(
pwd_, name, static_cast<TH1S *>(source->Clone(name)));
809 return book1S(
pwd_, name, static_cast<TH1S *>(source->Clone(name.c_str())));
816 return book1DD(
pwd_, name, static_cast<TH1D *>(source->Clone(name)));
823 return book1DD(
pwd_, name, static_cast<TH1D *>(source->Clone(name.c_str())));
851 int nchX,
double lowX,
double highX,
852 int nchY,
double lowY,
double highY)
854 return book2D(
pwd_, name,
new TH2F(name, title,
862 int nchX,
double lowX,
double highX,
863 int nchY,
double lowY,
double highY)
865 return book2D(
pwd_, name,
new TH2F(name.c_str(), title.c_str(),
873 int nchX,
double lowX,
double highX,
874 int nchY,
double lowY,
double highY)
876 return book2S(
pwd_, name,
new TH2S(name, title,
884 int nchX,
double lowX,
double highX,
885 int nchY,
double lowY,
double highY)
887 return book2S(
pwd_, name,
new TH2S(name.c_str(), title.c_str(),
895 int nchX,
double lowX,
double highX,
896 int nchY,
double lowY,
double highY)
906 int nchX,
double lowX,
double highX,
907 int nchY,
double lowY,
double highY)
909 return book2DD(
pwd_, name,
new TH2D(name.c_str(), title.c_str(),
917 int nchX,
float *xbinsize,
int nchY,
float *ybinsize)
919 return book2D(
pwd_, name,
new TH2F(name, title,
920 nchX, xbinsize, nchY, ybinsize));
926 int nchX,
float *xbinsize,
int nchY,
float *ybinsize)
928 return book2D(
pwd_, name,
new TH2F(name.c_str(), title.c_str(),
929 nchX, xbinsize, nchY, ybinsize));
936 return book2D(
pwd_, name, static_cast<TH2F *>(source->Clone(name)));
943 return book2D(
pwd_, name, static_cast<TH2F *>(source->Clone(name.c_str())));
950 return book2S(
pwd_, name, static_cast<TH2S *>(source->Clone(name)));
957 return book2S(
pwd_, name, static_cast<TH2S *>(source->Clone(name.c_str())));
964 return book2DD(
pwd_, name, static_cast<TH2D *>(source->Clone(name)));
971 return book2DD(
pwd_, name, static_cast<TH2D *>(source->Clone(name.c_str())));
985 int nchX,
double lowX,
double highX,
986 int nchY,
double lowY,
double highY,
987 int nchZ,
double lowZ,
double highZ)
989 return book3D(
pwd_, name,
new TH3F(name, title,
998 int nchX,
double lowX,
double highX,
999 int nchY,
double lowY,
double highY,
1000 int nchZ,
double lowZ,
double highZ)
1002 return book3D(
pwd_, name,
new TH3F(name.c_str(), title.c_str(),
1005 nchZ, lowZ, highZ));
1012 return book3D(
pwd_, name, static_cast<TH3F *>(source->Clone(name)));
1019 return book3D(
pwd_, name, static_cast<TH3F *>(source->Clone(name.c_str())));
1027 return book(dir, name,
"bookProfile",
1037 int nchX,
double lowX,
double highX,
1038 int ,
double lowY,
double highY,
1039 const char *option )
1052 int nchX,
double lowX,
double highX,
1053 int ,
double lowY,
double highY,
1054 const char *option )
1056 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1067 int nchX,
double lowX,
double highX,
1068 double lowY,
double highY,
1069 const char *option )
1082 int nchX,
double lowX,
double highX,
1083 double lowY,
double highY,
1084 const char *option )
1086 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1097 int nchX,
double *xbinsize,
1098 int ,
double lowY,
double highY,
1099 const char *option )
1112 int nchX,
double *xbinsize,
1113 int ,
double lowY,
double highY,
1114 const char *option )
1116 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1127 int nchX,
double *xbinsize,
1128 double lowY,
double highY,
1129 const char *option )
1142 int nchX,
double *xbinsize,
1143 double lowY,
double highY,
1144 const char *option )
1146 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1156 return bookProfile(
pwd_, name, static_cast<TProfile *>(source->Clone(name)));
1163 return bookProfile(
pwd_, name, static_cast<TProfile *>(source->Clone(name.c_str())));
1171 return book(dir, name,
"bookProfile2D",
1181 int nchX,
double lowX,
double highX,
1182 int nchY,
double lowY,
double highY,
1183 int ,
double lowZ,
double highZ,
1184 const char *option )
1198 int nchX,
double lowX,
double highX,
1199 int nchY,
double lowY,
double highY,
1200 int ,
double lowZ,
double highZ,
1201 const char *option )
1215 int nchX,
double lowX,
double highX,
1216 int nchY,
double lowY,
double highY,
1217 double lowZ,
double highZ,
1218 const char *option )
1232 int nchX,
double lowX,
double highX,
1233 int nchY,
double lowY,
double highY,
1234 double lowZ,
double highZ,
1235 const char *option )
1248 return bookProfile2D(
pwd_, name, static_cast<TProfile2D *>(source->Clone(name)));
1255 return bookProfile2D(
pwd_, name, static_cast<TProfile2D *>(source->Clone(name.c_str())));
1264 if (me->
getTH1()->GetNbinsX() != h->GetNbinsX()
1265 || me->
getTH1()->GetNbinsY() != h->GetNbinsY()
1266 || me->
getTH1()->GetNbinsZ() != h->GetNbinsZ()
1267 || me->
getTH1()->GetXaxis()->GetXmin() != h->GetXaxis()->GetXmin()
1268 || me->
getTH1()->GetYaxis()->GetXmin() != h->GetYaxis()->GetXmin()
1269 || me->
getTH1()->GetZaxis()->GetXmin() != h->GetZaxis()->GetXmin()
1270 || me->
getTH1()->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax()
1271 || me->
getTH1()->GetYaxis()->GetXmax() != h->GetYaxis()->GetXmax()
1272 || me->
getTH1()->GetZaxis()->GetXmax() != h->GetZaxis()->GetXmax())
1276 <<
"checkBinningMatches: different binning - cannot add object '"
1277 << h->GetName() <<
"' of type "
1278 << h->IsA()->GetName() <<
" to existing ME: '"
1362 raiseDQMError(
"DQMStore",
"Attempt to tag monitor element '%s'"
1365 raiseDQMError(
"DQMStore",
"Attempt to tag monitor element '%s'"
1366 " twice with multiple tags", me->
getFullname().c_str());
1383 raiseDQMError(
"DQMStore",
"Attempt to tag non-existent monitor element"
1384 " '%s' with tag %u", path.c_str(), myTag);
1393 MEMap::iterator
e =
data_.end();
1394 MEMap::iterator
i =
data_.lower_bound(proto);
1395 for ( ; i != e && path == *i->data_.dirname; ++
i)
1396 tag(const_cast<MonitorElement *>(&*i), myTag);
1410 MEMap::iterator
e =
data_.end();
1411 MEMap::iterator
i =
data_.lower_bound(proto);
1414 tag(const_cast<MonitorElement *>(&*i), myTag);
1423 std::vector<std::string>
1426 std::vector<std::string>
result;
1427 std::set<std::string>::const_iterator
e =
dirs_.end();
1428 std::set<std::string>::const_iterator
i =
dirs_.find(
pwd_);
1439 if (i->find(
'/',
pwd_.size()+1) == std::string::npos)
1440 result.push_back(*i);
1446 std::vector<std::string>
1450 std::vector<std::string>
result;
1451 MEMap::const_iterator
e =
data_.end();
1452 MEMap::const_iterator
i =
data_.lower_bound(proto);
1454 if (
pwd_ == *i->data_.dirname)
1455 result.push_back(i->getName());
1466 MEMap::const_iterator
e =
data_.end();
1467 MEMap::const_iterator
i =
data_.lower_bound(proto);
1479 MEMap::const_iterator mepos =
data_.find(proto);
1480 return (mepos ==
data_.end() ? 0
1485 std::vector<MonitorElement *>
1489 std::vector<MonitorElement *>
result;
1490 for (MEMap::const_iterator
i =
data_.begin(),
e =
data_.end();
i !=
e; ++
i)
1494 result.push_back(const_cast<MonitorElement *>(&me));
1501 std::vector<MonitorElement *>
1509 std::vector<MonitorElement *>
result;
1510 MEMap::const_iterator
e =
data_.end();
1511 MEMap::const_iterator
i =
data_.lower_bound(proto);
1513 if (*cleaned == *i->data_.dirname)
1514 result.push_back(const_cast<MonitorElement *>(&*i));
1520 std::vector<MonitorElement *>
1528 std::vector<MonitorElement *>
result;
1529 MEMap::const_iterator
e =
data_.end();
1530 MEMap::const_iterator
i =
data_.lower_bound(proto);
1532 if (*cleaned == *i->data_.dirname
1534 && i->data_.tag ==
tag)
1535 result.push_back(const_cast<MonitorElement *>(&*i));
1548 into.reserve(
dirs_.size());
1550 MEMap::const_iterator me =
data_.end();
1551 std::set<std::string>::const_iterator di =
dirs_.begin();
1552 std::set<std::string>::const_iterator de =
dirs_.end();
1553 for ( ; di != de; ++di)
1556 MEMap::const_iterator mi =
data_.lower_bound(proto);
1557 MEMap::const_iterator
m = mi;
1558 size_t sz = di->size() + 2;
1561 if (*di == *m->data_.dirname)
1563 sz += m->data_.objname.size() + 1;
1570 std::vector<std::string>::iterator istr
1579 for (sz = 0; mi !=
m; ++mi)
1581 if (*di != *mi->data_.dirname)
1587 *istr += mi->data_.objname;
1593 istr->reserve(di->size() + 2);
1605 if (dir.find_first_not_of(
s_safe) != std::string::npos)
1606 raiseDQMError(
"DQMStore",
"Monitor element path name '%s' uses"
1607 " unacceptable characters", dir.c_str());
1608 if (name.find_first_not_of(
s_safe) != std::string::npos)
1609 raiseDQMError(
"DQMStore",
"Monitor element path name '%s' uses"
1610 " unacceptable characters", name.c_str());
1616 MEMap::const_iterator mepos =
data_.find(proto);
1617 return (mepos ==
data_.end() ? 0
1627 into.reserve(
dirs_.size());
1629 MEMap::const_iterator me =
data_.end();
1630 std::set<std::string>::const_iterator di =
dirs_.begin();
1631 std::set<std::string>::const_iterator de =
dirs_.end();
1634 for ( ; di != de; ++di)
1637 MEMap::const_iterator mi =
data_.lower_bound(proto);
1638 MEMap::const_iterator
m = mi;
1639 size_t sz = di->size() + 2;
1645 sz += 1 + m->data_.objname.size() + 11;
1652 std::vector<std::string>::iterator istr
1659 for (sz = 0; mi !=
m; ++mi)
1663 sprintf(tagbuf,
"/%u", mi->data_.tag);
1666 *istr += m->data_.objname;
1676 std::vector<MonitorElement*>
1684 std::vector<MonitorElement *>
result;
1685 MEMap::const_iterator
e =
data_.end();
1686 MEMap::const_iterator
i =
data_.lower_bound(proto);
1688 result.push_back(const_cast<MonitorElement *>(&*i));
1695 std::vector<MonitorElement*>
1701 rx = lat::Regexp(pattern, 0, syntaxType);
1704 catch (lat::Error &
e)
1706 raiseDQMError(
"DQMStore",
"Invalid regular expression '%s': %s",
1707 pattern.c_str(), e.explain().c_str());
1711 std::vector<MonitorElement *>
result;
1712 MEMap::const_iterator
i =
data_.begin();
1713 MEMap::const_iterator e =
data_.end();
1714 for ( ; i !=
e; ++
i)
1717 mergePath(path, *i->data_.dirname, i->data_.objname);
1719 result.push_back(const_cast<MonitorElement *>(&*i));
1734 MEMap::iterator mi =
data_.begin();
1735 MEMap::iterator me =
data_.end();
1736 for ( ; mi != me; ++mi)
1739 if (mi->wasUpdated())
1758 MEMap::iterator mi =
data_.begin();
1759 MEMap::iterator me =
data_.end();
1760 for ( ; mi != me; ++mi)
1780 if (TProfile *
h = dynamic_cast<TProfile *>(obj))
1784 me =
bookProfile(dir,
h->GetName(), (TProfile *)
h->Clone());
1791 else if (TProfile2D *
h = dynamic_cast<TProfile2D *>(obj))
1802 else if (TH1F *
h = dynamic_cast<TH1F *>(obj))
1806 me =
book1D(dir,
h->GetName(), (TH1F *)
h->Clone());
1813 else if (TH1S *
h = dynamic_cast<TH1S *>(obj))
1817 me =
book1S(dir,
h->GetName(), (TH1S *)
h->Clone());
1824 else if (TH1D *
h = dynamic_cast<TH1D *>(obj))
1828 me =
book1DD(dir,
h->GetName(), (TH1D *)
h->Clone());
1835 else if (TH2F *
h = dynamic_cast<TH2F *>(obj))
1839 me =
book2D(dir,
h->GetName(), (TH2F *)
h->Clone());
1846 else if (TH2S *
h = dynamic_cast<TH2S *>(obj))
1850 me =
book2S(dir,
h->GetName(), (TH2S *)
h->Clone());
1857 else if (TH2D *
h = dynamic_cast<TH2D *>(obj))
1861 me =
book2DD(dir,
h->GetName(), (TH2D *)
h->Clone());
1868 else if (TH3F *
h = dynamic_cast<TH3F *>(obj))
1872 me =
book3D(dir,
h->GetName(), (TH3F *)
h->Clone());
1879 else if (dynamic_cast<TObjString *>(obj))
1882 if (!
s_rxmeval.match(obj->GetName(), 0, 0, &
m))
1884 if (strstr(obj->GetName(),
"CMSSW"))
1887 std::cout <<
"Input file version: " << obj->GetName() << std::endl;
1890 else if (strstr(obj->GetName(),
"DQMPATCH"))
1893 std::cout <<
"DQM patch version: " << obj->GetName() << std::endl;
1898 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
1899 << obj->GetName() <<
"' of type '"
1900 << obj->IsA()->GetName() <<
"'\n";
1906 std::string kind = m.matchString(obj->GetName(), 2);
1912 if (! me || overwrite)
1914 if (! me) me =
bookInt(dir, label);
1915 me->
Fill(atoll(value.c_str()));
1918 else if (kind ==
"f")
1921 if (! me || overwrite)
1924 me->
Fill(atof(value.c_str()));
1927 else if (kind ==
"s")
1935 else if (kind ==
"e")
1940 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
1941 << label <<
"' in directory '"
1942 << dir <<
"' to be marked as efficiency plot.\n";
1947 else if (kind ==
"t")
1952 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
1953 << label <<
"' in directory '"
1954 << dir <<
"' for a tag\n";
1959 unsigned long val = strtoul(value.c_str(), &endp, 10);
1960 if ((val == 0 && errno) || *endp || val > ~uint32_t(0))
1962 std::cout <<
"*** DQMStore: WARNING: cannot restore tag '"
1963 << value <<
"' for monitor element '"
1964 << label <<
"' in directory '"
1965 << dir <<
"' - invalid value\n";
1970 else if (kind ==
"qr")
1975 size_t dot = label.find(
'.');
1976 if (dot == std::string::npos)
1978 std::cout <<
"*** DQMStore: WARNING: quality report label in '" << label
1979 <<
"' is missing a '.' and cannot be extracted\n";
1984 std::string qrname (label, dot+1, std::string::npos);
1990 qv.
code = atoi(m.matchString(value, 1).c_str());
1991 qv.
qtresult = strtod(m.matchString(value, 2).c_str(), 0);
1992 qv.
message = m.matchString(value, 4);
1996 else if (
s_rxmeqr2.match(value, 0, 0, &m))
1998 qv.
code = atoi(m.matchString(value, 1).c_str());
2000 qv.
message = m.matchString(value, 2);
2006 std::cout <<
"*** DQMStore: WARNING: quality test value '"
2007 << value <<
"' is incorrectly formatted\n";
2014 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
2015 << mename <<
"' in directory '"
2016 << dir <<
"' for quality test '"
2026 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
2027 << obj->GetName() <<
"' of type '"
2028 << obj->IsA()->GetName() <<
"'\n";
2032 else if (TNamed *
n = dynamic_cast<TNamed *>(obj))
2036 s.reserve(6 + strlen(
n->GetTitle()) + 2*strlen(
n->GetName()));
2037 s +=
'<'; s +=
n->GetName(); s +=
'>';
2039 s +=
'<'; s +=
'/'; s +=
n->GetName(); s +=
'>';
2040 TObjString os(s.c_str());
2041 return extract(&os, dir, overwrite);
2045 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
2046 << obj->GetName() <<
"' of type '" << obj->IsA()->GetName()
2047 <<
"' and with title '" << obj->GetTitle() <<
"'\n";
2073 assert(! path.empty());
2077 size_t end = path.find(
'/', start);
2078 if (end == std::string::npos)
2086 TObject *
o = gDirectory->Get(part.c_str());
2087 if (o && ! dynamic_cast<TDirectory *>(o))
2088 raiseDQMError(
"DQMStore",
"Attempt to create directory '%s' in a file"
2089 " fails because the part '%s' already exists and is not"
2090 " directory", path.c_str(), part.c_str());
2092 gDirectory->mkdir(part.c_str());
2094 if (! gDirectory->cd(part.c_str()))
2095 raiseDQMError(
"DQMStore",
"Attempt to create directory '%s' in a file"
2096 " fails because could not cd into subdirectory '%s'",
2097 path.c_str(), part.c_str());
2100 if (end+1 >= path.size())
2105 end = path.find(
'/', start);
2106 if (end == std::string::npos)
2126 std::set<std::string>::iterator di, de;
2127 MEMap::iterator mi, me =
data_.end();
2128 DQMNet::QReports::const_iterator qi, qe;
2135 class TFileNoSync :
public TFile
2138 TFileNoSync(
const char *
file,
const char *opt) : TFile(file, opt) {}
2139 virtual Int_t SysSync(Int_t) {
return 0; }
2144 std::cout <<
"\n DQMStore: Opening TFile '" << filename
2145 <<
"' with option '" << fileupdate <<
"'\n";
2147 TFileNoSync
f(filename.c_str(), fileupdate.c_str());
2149 raiseDQMError(
"DQMStore",
"Failed to create/update file '%s'", filename.c_str());
2153 std::auto_ptr<lat::Regexp> rxpat;
2154 if (! pattern.empty())
2155 rxpat.reset(
new lat::Regexp(pattern.c_str()));
2168 for (di =
dirs_.begin(), de =
dirs_.end(); di != de; ++di)
2179 mi =
data_.lower_bound(proto);
2180 for ( ; mi != me &&
isSubdirectory(*di, *mi->data_.dirname); ++mi)
2183 if (*di != *mi->data_.dirname)
2208 for (
size_t i = 0,
e = master->data_.qreports.size();
i !=
e; ++
i)
2209 status =
std::max(status, master->data_.qreports[
i].code);
2211 if (! master || status < minStatus)
2214 std::cout <<
"DQMStore::save: skipping monitor element '"
2215 << mi->data_.objname <<
"' while saving, status is "
2216 << status <<
", required minimum status is "
2217 << minStatus << std::endl;
2224 std::cout <<
"DQMStore::save: saving monitor element '"
2225 << mi->data_.objname <<
"'\n";
2229 gDirectory->cd(
"/");
2232 else if (rxpat.get())
2243 TObjString(mi->tagString().c_str()).Write();
2247 mi->object_->Write();
2254 qi = mi->data_.qreports.begin();
2255 qe = mi->data_.qreports.end();
2256 for ( ; qi != qe; ++qi)
2257 TObjString(mi->qualityTagString(*qi).c_str()).Write();
2262 TObjString(mi->effLabelString().c_str()).Write();
2266 TObjString(mi->tagLabelString().c_str()).Write();
2274 std::cout <<
"DQMStore::save: successfully wrote " << nme
2275 <<
" objects from path '" << path
2276 <<
"' into DQM file '" << filename <<
"'\n";
2289 unsigned int ntot = 0;
2290 unsigned int count = 0;
2292 if (! file->cd(curdir.c_str()))
2293 raiseDQMError(
"DQMStore",
"Failed to process directory '%s' while"
2294 " reading file '%s'", curdir.c_str(), file->GetName());
2317 size_t slash = dirpart.find(
'/');
2318 size_t pos = dirpart.find(
"/Run summary");
2319 if (slash != std::string::npos && pos !=std::string::npos)
2321 dirpart.erase(pos,12);
2323 pos = dirpart.find(
"Run ");
2324 size_t length = dirpart.find(
'/',pos+1)-pos+1;
2325 if (pos !=std::string::npos)
2326 dirpart.erase(pos,length);
2335 size_t slash = dirpart.find(
'/');
2337 if (slash == std::string::npos
2342 slash = dirpart.find(
'/');
2344 if (slash != std::string::npos
2345 && slash + 10 == dirpart.size()
2346 && dirpart.compare( slash+1 , 9 ,
"EventInfo") == 0) {
2348 std::cout <<
"DQMStore::readDirectory: skipping '" << dirpart <<
"'\n";
2353 if (dirpart.empty())
2356 dirpart = prepend +
'/' + dirpart;
2358 else if (! prepend.empty())
2360 if (dirpart.empty())
2363 dirpart = prepend +
'/' + dirpart;
2371 TIter next (gDirectory->GetListOfKeys());
2372 std::list<TObject *> delayed;
2373 while ((key = (TKey *) next()))
2375 std::auto_ptr<TObject>
obj(key->ReadObj());
2376 if (dynamic_cast<TDirectory *>(
obj.get()))
2379 subdir.reserve(curdir.size() + strlen(
obj->GetName()) + 2);
2381 if (! curdir.empty())
2383 subdir +=
obj->GetName();
2385 ntot +=
readDirectory(file, overwrite, onlypath, prepend, subdir, stripdirs);
2389 else if (dynamic_cast<TObjString *>(
obj.get()))
2391 delayed.push_back(
obj.release());
2396 std::cout <<
"DQMStore: reading object '" <<
obj->GetName()
2397 <<
"' of type '" <<
obj->IsA()->GetName()
2398 <<
"' from '" << file->GetName()
2399 <<
"' into '" << dirpart <<
"'\n";
2407 while (! delayed.empty())
2410 std::cout <<
"DQMStore: reading object '" << delayed.front()->GetName()
2411 <<
"' of type '" << delayed.front()->IsA()->GetName()
2412 <<
"' from '" << file->GetName()
2413 <<
"' into '" << dirpart <<
"'\n";
2416 if (
extract(delayed.front(), dirpart, overwrite))
2419 delete delayed.front();
2420 delayed.pop_front();
2424 std::cout <<
"DQMStore: read " << count <<
'/' << ntot
2425 <<
" objects from directory '" << dirpart <<
"'\n";
2427 return ntot +
count;
2442 bool fileMustExist )
2444 return readFile(filename,overwrite,onlypath,prepend,stripdirs,fileMustExist);
2454 bool fileMustExist )
2456 bool overwrite =
true;
2460 std::cout <<
"DQMStore::load: reading from file '" << filename <<
"'\n";
2462 std::cout <<
"DQMStore::load: in collate mode " <<
"\n";
2464 std::cout <<
"DQMStore::load: in overwrite mode " <<
"\n";
2467 return readFile(filename,overwrite,
"",
"",stripdirs,fileMustExist);
2482 bool fileMustExist )
2486 std::cout <<
"DQMStore::readFile: reading from file '" << filename <<
"'\n";
2488 std::auto_ptr<TFile>
f;
2492 f.reset(TFile::Open(filename.c_str()));
2493 if (! f.get() || f->IsZombie())
2494 raiseDQMError(
"DQMStore",
"Failed to open file '%s'", filename.c_str());
2503 std::cout <<
"DQMStore::readFile: file '" << filename <<
"' does not exist, continuing\n";
2508 unsigned n =
readDirectory(f.get(), overwrite, onlypath, prepend,
"", stripdirs);
2511 MEMap::iterator mi =
data_.begin();
2512 MEMap::iterator me =
data_.end();
2513 for ( ; mi != me; ++mi)
2514 const_cast<MonitorElement &>(*mi).updateQReportStats();
2518 std::cout <<
"DQMStore::open: successfully read " << n
2519 <<
" objects from file '" << filename <<
"'";
2520 if (! onlypath.empty())
2521 std::cout <<
" from directory '" << onlypath <<
"'";
2522 if (! prepend.empty())
2523 std::cout <<
" into directory '" << prepend <<
"'";
2542 MEMap::iterator
e =
data_.end();
2543 MEMap::iterator
i =
data_.lower_bound(proto);
2547 std::set<std::string>::iterator de =
dirs_.end();
2548 std::set<std::string>::iterator di =
dirs_.lower_bound(*cleaned);
2558 MEMap::iterator
e =
data_.end();
2559 MEMap::iterator
i =
data_.lower_bound(proto);
2561 if (dir == *i->data_.dirname)
2588 MEMap::iterator
pos =
data_.find(proto);
2590 std::cout <<
"DQMStore: WARNING: attempt to remove non-existent"
2591 <<
" monitor element '" << name <<
"' in '" << dir <<
"'\n";
2604 QCMap::const_iterator
i =
qtests_.find(qtname);
2605 QCMap::const_iterator
e =
qtests_.end();
2606 return (i == e ? 0 : i->second);
2616 raiseDQMError(
"DQMStore",
"Attempt to create duplicate quality test '%s'",
2619 QAMap::iterator
i =
qalgos_.find(algoname);
2621 raiseDQMError(
"DQMStore",
"Cannot create a quality test using unknown"
2622 " algorithm '%s'", algoname.c_str());
2642 if (cleaned->find_first_not_of(
s_safe) != std::string::npos)
2644 " uses unacceptable characters", cleaned->c_str());
2656 raiseDQMError(
"DQMStore",
"Cannot apply non-existent quality test '%s'",
2666 MEMap::iterator mi =
data_.begin();
2667 MEMap::iterator me =
data_.end();
2670 for ( ; mi != me; ++mi)
2673 mergePath(path, *mi->data_.dirname, mi->data_.objname);
2674 if (fm->match(path))
2691 std::cout <<
"DQMStore: running runQTests() with reset = "
2692 << (
reset_ ?
"true" :
"false" ) << std::endl;
2695 MEMap::iterator mi =
data_.begin();
2696 MEMap::iterator me =
data_.end();
2697 for ( ; mi != me; ++mi)
2715 MEMap::const_iterator mi =
data_.begin();
2716 MEMap::const_iterator me =
data_.end();
2717 for ( ; mi != me; ++mi)
2719 if (! cleaned->empty() && !
isSubdirectory(*cleaned, *mi->data_.dirname))
2724 else if (mi->hasWarning())
2727 && mi->hasOtherReport())
2771 std::cout <<
" ------------------------------------------------------------\n"
2772 <<
" Directory structure: \n"
2773 <<
" ------------------------------------------------------------\n";
2775 std::copy(contents.begin(), contents.end(),
2776 std::ostream_iterator<std::string>(
std::cout,
"\n"));
2778 std::cout <<
" ------------------------------------------------------------\n";
2815 MonitorElement * event_me =
get(
"Info/EventInfo/processedEvents");
2818 factor = factor/(events*1.0);
2820 MEMap::iterator mi =
data_.begin();
2821 MEMap::iterator me =
data_.end();
2822 for ( ; mi != me; ++mi)
2874 std::cout <<
" The DQM object '" << me.
getFullname() <<
"' is not scalable object " << std::endl;
static void collateProfile2D(MonitorElement *me, TProfile2D *h)
QCriterion * getQCriterion(const std::string &qtname) const
bool compare_strings_reverse(std::string const &pattern, std::string const &input) const
std::pair< fastmatch *, QCriterion * > QTestSpec
TH2S * getTH2S(void) const
TH1S * getTH1S(void) const
T getUntrackedParameter(std::string const &, T const &) const
DQMStore(const edm::ParameterSet &pset, edm::ActivityRegistry &)
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.
bool containsAnyMonitorable(const std::string &path) const
bool isCollateME(MonitorElement *me) const
void resetUpdate(void)
reset "was updated" flag
tuple start
Check for commandline option errors.
bool cdInto(const std::string &path) const
int getStatus(const std::string &path="") const
MonitorElement * initialise(Kind kind)
static void mergePath(std::string &path, const std::string &dir, const std::string &name)
std::vector< std::string > getSubdirs(void) const
TProfile2D * getTProfile2D(void) const
static std::string s_collateDirName
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
void rmdir(const std::string &fullpath)
bool match(std::string const &s) const
bool readFile(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=StripRunDirs, bool fileMustExist=true)
static void collate3D(MonitorElement *me, TH3F *h)
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.
static void collate1D(MonitorElement *me, TH1F *h)
void cd(void)
go to top directory (ie. root)
MonitorElement * book2DD(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D double histogram.
static void collate1DD(MonitorElement *me, TH1D *h)
static void splitPath(std::string &dir, std::string &name, const std::string &path)
static std::string s_referenceDirName
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
void disableSoftReset(void)
reverts action of softReset
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
TH3F * getTH3F(void) const
static const uint32_t DQM_PROP_TAGGED
TH1D * getTH1D(void) const
MatchingHeuristicEnum matching_
void runQTests(void)
run all quality tests
static const uint32_t DQM_PROP_EFFICIENCY_PLOT
TH2D * getTH2D(void) const
const std::string * dirname
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
void initializeFrom(const edm::ParameterSet &)
void initQCriterion(std::map< std::string, QCriterion *(*)(const std::string &)> &m)
MonitorElement * book(const std::string &dir, const std::string &name, const char *context)
MonitorElement * bookFloat(const char *name)
Book float.
std::vector< MonitorElement * > getAllContents(const std::string &path) const
static const lat::Regexp s_rxtrace("(.*)\\((.*)\\+0x.*\\).*")
static void cleanTrailingSlashes(const std::string &path, std::string &clean, const std::string *&cleaned)
void tag(MonitorElement *me, unsigned int myTag)
void disableSoftReset(MonitorElement *me)
static void collateProfile(MonitorElement *me, TProfile *h)
static const lat::Regexp s_rxmeval("^<(.*)>(i|f|s|e|t|qr)=(.*)</\\1>$")
static bool isSubdirectory(const std::string &ofdir, const std::string &path)
fastmatch(std::string const &_fastString)
bool extract(TObject *obj, const std::string &dir, bool overwrite)
static const uint32_t DQM_PROP_HAS_REFERENCE
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
const T & max(const T &a, const T &b)
void watchPostSourceRun(PostSourceRun::slot_type const &iSlot)
MonitorElement * bookString(const char *name, const char *value)
Book string.
static std::string s_safe
static void collate1S(MonitorElement *me, TH1S *h)
bool isCollate(void) const
void removeElement(const std::string &name)
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
static bool checkBinningMatches(MonitorElement *me, TH1 *h)
double getFloatValue(void) const
MonitorElement * findObject(const std::string &dir, const std::string &name) const
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
QCriterion * makeQCriterion(const std::string &qtname)
void setVerbose(unsigned level)
void softReset(MonitorElement *me)
Kind kind(void) const
Get the type of the monitor element.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
const std::string getFullname(void) const
get full name of ME including Pathname
std::vector< MonitorElement * > getContents(const std::string &path) const
bool dirExists(const std::string &path) const
true if directory exists
void getAllTags(std::vector< std::string > &into) const
bool load(const std::string &filename, OpenRunDirs stripdirs=StripRunDirs, bool fileMustExist=true)
void tagAllContents(const std::string &path, unsigned int myTag)
MonitorElement * initialise(MonitorElement *me, const std::string &path)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
static void collate2S(MonitorElement *me, TH2S *h)
int64_t getIntValue(void) const
static void collate2D(MonitorElement *me, TH2F *h)
void print_trace(const std::string &dir, const std::string &name)
int useQTestByMatch(const std::string &pattern, const std::string &qtname)
attach quality test <qc> to monitor elements matching <pattern>.
TH1F * getTH1F(void) const
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
bool resetMe(void) const
true if ME should be reset at end of monitoring cycle
unsigned int readDirectory(TFile *file, bool overwrite, const std::string &path, const std::string &prepend, const std::string &curdir, OpenRunDirs stripdirs)
void setVerbose(int verbose)
probability limits for warnings, errors
static void collate2DD(MonitorElement *me, TH2D *h)
T dot(const Basic3DVector &v) const
Scalar product, or "dot" 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)
TProfile * getTProfile(void) const
void useQTest(const std::string &dir, const std::string &qtname)
void goUp(void)
equivalent to "cd .."
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
static const int STATUS_OK
void setAccumulate(MonitorElement *me, bool flag)
void setEfficiencyFlag(void)
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
void showDirStructure(void) const
TH2F * getTH2F(void) const
MonitorElement * bookInt(const char *name)
Book int.
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
static std::string s_monitorDirName
name of global monitoring folder (containing all sources subdirectories)
std::set< std::string > dirs_
void Reset(void)
reset ME (ie. contents, errors, etc)
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.
tuple size
Write out results.
static const lat::Regexp s_rxmeqr1("^st:(\\d+):([-+e.\\d]+):([^:]*):(.*)$")
void makeDirectory(const std::string &path)
get folder corresponding to inpath wrt to root (create subdirs if necessary)
bool compare_strings(std::string const &pattern, std::string const &input) const
void setCurrentFolder(const std::string &fullpath)
const std::string & pwd(void) const
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")
void raiseDQMError(const char *context, const char *fmt,...)