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_,
"*") &&
199 std::string
const&
input)
const
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)
220 std::string
const&
input)
const
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_ (
""),
277 collateHistograms_ (
false),
278 readSelectedDirectory_ (
""),
310 std::cout <<
"DQMStore: histogram collation is enabled\n";
315 std::cout <<
"DQMStore: using reference file '" << ref <<
"'\n";
319 initQCriterion<Comp2RefChi2>(
qalgos_);
320 initQCriterion<Comp2RefKolmogorov>(
qalgos_);
321 initQCriterion<ContentsXRange>(
qalgos_);
322 initQCriterion<ContentsYRange>(
qalgos_);
323 initQCriterion<MeanWithinExpected>(
qalgos_);
324 initQCriterion<Comp2RefEqualH>(
qalgos_);
325 initQCriterion<DeadChannel>(
qalgos_);
326 initQCriterion<NoisyChannel>(
qalgos_);
327 initQCriterion<ContentsWithinExpected>(
qalgos_);
328 initQCriterion<CompareToMedian>(
qalgos_);
329 initQCriterion<CompareLastFilledBin>(
qalgos_);
344 static std::ofstream stream(
"histogramBookingBT.log");
352 size = backtrace (array, 10);
353 strings = backtrace_symbols (array, size);
358 char * demangled = abi::__cxa_demangle(m.matchString(strings[4], 2).c_str(), 0, 0, &
r);
359 stream <<
"\"" << dir <<
"/"
361 << (r ? m.matchString(strings[4], 2) : demangled) <<
" "
362 << m.matchString(strings[4], 1) <<
"\n";
366 stream <<
"Skipping "<< dir <<
"/" << name
367 <<
" with stack size " << size <<
"\n";
375 for (i = 0; i <
size; i++)
376 if (
s_rxtrace.match(strings[i], 0, 0, &m))
378 char * demangled = abi::__cxa_demangle(m.matchString(strings[i], 2).c_str(), 0, 0, &
r);
379 stream <<
"\t\t" << i <<
"/" << size <<
" "
380 << (r ? m.matchString(strings[i], 2) : demangled) <<
" "
381 << m.matchString(strings[i], 1) << std::endl;
414 const std::string *cleaned = 0;
418 raiseDQMError(
"DQMStore",
"Cannot 'cd' into non-existent directory '%s'",
432 const std::string *cleaned = 0;
443 if (pos == std::string::npos)
457 prev.reserve(path.size());
458 subdir.reserve(path.size());
459 name.reserve(path.size());
467 subdir.append(path, 0, slash);
469 name.append(subdir, prevname, std::string::npos);
471 raiseDQMError(
"DQMStore",
"Attempt to create subdirectory '%s'"
472 " which already exists as a monitor element",
475 if (!
dirs_.count(subdir))
476 dirs_.insert(subdir);
479 if (slash+1 >= path.size())
484 prevname = slash ? slash+1 :
slash;
486 if ((slash = path.find(
'/', ++slash)) == std::string::npos)
494 {
return dirs_.count(path) > 0; }
499 template <
class HISTO,
class COLLATE>
502 const char *context,
int kind,
503 HISTO *
h, COLLATE collate)
505 assert(name.find(
'/') == std::string::npos);
528 << context <<
": monitor element '"
529 << path <<
"' already exists, collating" << std::endl;
539 assert(
dirs_.count(dir));
547 for ( ; qi != qe; ++qi)
549 if ( qi->first->match(path) )
550 me->addQReport(qi->second);
563 me->reference_ = refme->object_;
573 const std::string &
name,
576 assert(name.find(
'/') == std::string::npos);
589 << context <<
": monitor element '"
590 << path <<
"' already exists, resetting" << std::endl;
598 assert(
dirs_.count(dir));
618 return book(dir, name,
"bookInt")
648 return book(dir, name,
"bookFloat")
668 const std::string &
name,
669 const std::string &
value)
677 return book(dir, name,
"bookString")
718 int nchX,
double lowX,
double highX)
720 return book1D(
pwd_, name,
new TH1F(name, title, nchX, lowX, highX));
726 int nchX,
double lowX,
double highX)
728 return book1D(
pwd_, name,
new TH1F(name.c_str(), title.c_str(), nchX, lowX, highX));
734 int nchX,
double lowX,
double highX)
736 return book1S(
pwd_, name,
new TH1S(name, title, nchX, lowX, highX));
742 int nchX,
double lowX,
double highX)
744 return book1S(
pwd_, name,
new TH1S(name.c_str(), title.c_str(), nchX, lowX, highX));
750 int nchX,
double lowX,
double highX)
752 return book1DD(
pwd_, name,
new TH1D(name, title, nchX, lowX, highX));
758 int nchX,
double lowX,
double highX)
760 return book1DD(
pwd_, name,
new TH1D(name.c_str(), title.c_str(), nchX, lowX, highX));
766 int nchX,
float *xbinsize)
768 return book1D(
pwd_, name,
new TH1F(name, title, nchX, xbinsize));
774 int nchX,
float *xbinsize)
776 return book1D(
pwd_, name,
new TH1F(name.c_str(), title.c_str(), nchX, xbinsize));
783 return book1D(
pwd_, name, static_cast<TH1F *>(source->Clone(name)));
790 return book1D(
pwd_, name, static_cast<TH1F *>(source->Clone(name.c_str())));
797 return book1S(
pwd_, name, static_cast<TH1S *>(source->Clone(name)));
804 return book1S(
pwd_, name, static_cast<TH1S *>(source->Clone(name.c_str())));
811 return book1DD(
pwd_, name, static_cast<TH1D *>(source->Clone(name)));
818 return book1DD(
pwd_, name, static_cast<TH1D *>(source->Clone(name.c_str())));
846 int nchX,
double lowX,
double highX,
847 int nchY,
double lowY,
double highY)
849 return book2D(
pwd_, name,
new TH2F(name, title,
857 int nchX,
double lowX,
double highX,
858 int nchY,
double lowY,
double highY)
860 return book2D(
pwd_, name,
new TH2F(name.c_str(), title.c_str(),
868 int nchX,
double lowX,
double highX,
869 int nchY,
double lowY,
double highY)
871 return book2S(
pwd_, name,
new TH2S(name, title,
879 int nchX,
double lowX,
double highX,
880 int nchY,
double lowY,
double highY)
882 return book2S(
pwd_, name,
new TH2S(name.c_str(), title.c_str(),
890 int nchX,
double lowX,
double highX,
891 int nchY,
double lowY,
double highY)
901 int nchX,
double lowX,
double highX,
902 int nchY,
double lowY,
double highY)
904 return book2DD(
pwd_, name,
new TH2D(name.c_str(), title.c_str(),
912 int nchX,
float *xbinsize,
int nchY,
float *ybinsize)
914 return book2D(
pwd_, name,
new TH2F(name, title,
915 nchX, xbinsize, nchY, ybinsize));
921 int nchX,
float *xbinsize,
int nchY,
float *ybinsize)
923 return book2D(
pwd_, name,
new TH2F(name.c_str(), title.c_str(),
924 nchX, xbinsize, nchY, ybinsize));
931 return book2D(
pwd_, name, static_cast<TH2F *>(source->Clone(name)));
938 return book2D(
pwd_, name, static_cast<TH2F *>(source->Clone(name.c_str())));
945 return book2S(
pwd_, name, static_cast<TH2S *>(source->Clone(name)));
952 return book2S(
pwd_, name, static_cast<TH2S *>(source->Clone(name.c_str())));
959 return book2DD(
pwd_, name, static_cast<TH2D *>(source->Clone(name)));
966 return book2DD(
pwd_, name, static_cast<TH2D *>(source->Clone(name.c_str())));
980 int nchX,
double lowX,
double highX,
981 int nchY,
double lowY,
double highY,
982 int nchZ,
double lowZ,
double highZ)
984 return book3D(
pwd_, name,
new TH3F(name, title,
993 int nchX,
double lowX,
double highX,
994 int nchY,
double lowY,
double highY,
995 int nchZ,
double lowZ,
double highZ)
997 return book3D(
pwd_, name,
new TH3F(name.c_str(), title.c_str(),
1000 nchZ, lowZ, highZ));
1007 return book3D(
pwd_, name, static_cast<TH3F *>(source->Clone(name)));
1014 return book3D(
pwd_, name, static_cast<TH3F *>(source->Clone(name.c_str())));
1022 return book(dir, name,
"bookProfile",
1032 int nchX,
double lowX,
double highX,
1033 int ,
double lowY,
double highY,
1034 const char *option )
1047 int nchX,
double lowX,
double highX,
1048 int ,
double lowY,
double highY,
1049 const char *option )
1051 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1062 int nchX,
double lowX,
double highX,
1063 double lowY,
double highY,
1064 const char *option )
1077 int nchX,
double lowX,
double highX,
1078 double lowY,
double highY,
1079 const char *option )
1081 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1092 int nchX,
double *xbinsize,
1093 int ,
double lowY,
double highY,
1094 const char *option )
1107 int nchX,
double *xbinsize,
1108 int ,
double lowY,
double highY,
1109 const char *option )
1111 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1122 int nchX,
double *xbinsize,
1123 double lowY,
double highY,
1124 const char *option )
1137 int nchX,
double *xbinsize,
1138 double lowY,
double highY,
1139 const char *option )
1141 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1151 return bookProfile(
pwd_, name, static_cast<TProfile *>(source->Clone(name)));
1158 return bookProfile(
pwd_, name, static_cast<TProfile *>(source->Clone(name.c_str())));
1166 return book(dir, name,
"bookProfile2D",
1176 int nchX,
double lowX,
double highX,
1177 int nchY,
double lowY,
double highY,
1178 int ,
double lowZ,
double highZ,
1179 const char *option )
1193 int nchX,
double lowX,
double highX,
1194 int nchY,
double lowY,
double highY,
1195 int ,
double lowZ,
double highZ,
1196 const char *option )
1210 int nchX,
double lowX,
double highX,
1211 int nchY,
double lowY,
double highY,
1212 double lowZ,
double highZ,
1213 const char *option )
1227 int nchX,
double lowX,
double highX,
1228 int nchY,
double lowY,
double highY,
1229 double lowZ,
double highZ,
1230 const char *option )
1243 return bookProfile2D(
pwd_, name, static_cast<TProfile2D *>(source->Clone(name)));
1250 return bookProfile2D(
pwd_, name, static_cast<TProfile2D *>(source->Clone(name.c_str())));
1259 if (me->
getTH1()->GetNbinsX() != h->GetNbinsX()
1260 || me->
getTH1()->GetNbinsY() != h->GetNbinsY()
1261 || me->
getTH1()->GetNbinsZ() != h->GetNbinsZ()
1262 || me->
getTH1()->GetXaxis()->GetXmin() != h->GetXaxis()->GetXmin()
1263 || me->
getTH1()->GetYaxis()->GetXmin() != h->GetYaxis()->GetXmin()
1264 || me->
getTH1()->GetZaxis()->GetXmin() != h->GetZaxis()->GetXmin()
1265 || me->
getTH1()->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax()
1266 || me->
getTH1()->GetYaxis()->GetXmax() != h->GetYaxis()->GetXmax()
1267 || me->
getTH1()->GetZaxis()->GetXmax() != h->GetZaxis()->GetXmax())
1271 <<
"checkBinningMatches: different binning - cannot add object '"
1272 << h->GetName() <<
"' of type "
1273 << h->IsA()->GetName() <<
" to existing ME: '"
1357 raiseDQMError(
"DQMStore",
"Attempt to tag monitor element '%s'"
1360 raiseDQMError(
"DQMStore",
"Attempt to tag monitor element '%s'"
1361 " twice with multiple tags", me->
getFullname().c_str());
1378 raiseDQMError(
"DQMStore",
"Attempt to tag non-existent monitor element"
1379 " '%s' with tag %u", path.c_str(), myTag);
1388 MEMap::iterator
e =
data_.end();
1389 MEMap::iterator
i =
data_.lower_bound(proto);
1390 for ( ; i != e && path == *i->data_.dirname; ++
i)
1391 tag(const_cast<MonitorElement *>(&*i), myTag);
1400 const std::string *cleaned = 0;
1405 MEMap::iterator
e =
data_.end();
1406 MEMap::iterator
i =
data_.lower_bound(proto);
1409 tag(const_cast<MonitorElement *>(&*i), myTag);
1418 std::vector<std::string>
1421 std::vector<std::string>
result;
1422 std::set<std::string>::const_iterator
e =
dirs_.end();
1423 std::set<std::string>::const_iterator
i =
dirs_.find(
pwd_);
1434 if (i->find(
'/',
pwd_.size()+1) == std::string::npos)
1435 result.push_back(*i);
1441 std::vector<std::string>
1445 std::vector<std::string>
result;
1446 MEMap::const_iterator
e =
data_.end();
1447 MEMap::const_iterator
i =
data_.lower_bound(proto);
1449 if (
pwd_ == *i->data_.dirname)
1450 result.push_back(i->getName());
1461 MEMap::const_iterator
e =
data_.end();
1462 MEMap::const_iterator
i =
data_.lower_bound(proto);
1474 MEMap::const_iterator mepos =
data_.find(proto);
1475 return (mepos ==
data_.end() ? 0
1480 std::vector<MonitorElement *>
1484 std::vector<MonitorElement *>
result;
1485 for (MEMap::const_iterator
i =
data_.begin(),
e =
data_.end();
i !=
e; ++
i)
1489 result.push_back(const_cast<MonitorElement *>(&me));
1496 std::vector<MonitorElement *>
1500 const std::string *cleaned = 0;
1504 std::vector<MonitorElement *>
result;
1505 MEMap::const_iterator
e =
data_.end();
1506 MEMap::const_iterator
i =
data_.lower_bound(proto);
1508 if (*cleaned == *i->data_.dirname)
1509 result.push_back(const_cast<MonitorElement *>(&*i));
1515 std::vector<MonitorElement *>
1519 const std::string *cleaned = 0;
1523 std::vector<MonitorElement *>
result;
1524 MEMap::const_iterator
e =
data_.end();
1525 MEMap::const_iterator
i =
data_.lower_bound(proto);
1527 if (*cleaned == *i->data_.dirname
1529 && i->data_.tag ==
tag)
1530 result.push_back(const_cast<MonitorElement *>(&*i));
1543 into.reserve(
dirs_.size());
1545 MEMap::const_iterator me =
data_.end();
1546 std::set<std::string>::const_iterator di =
dirs_.begin();
1547 std::set<std::string>::const_iterator de =
dirs_.end();
1548 for ( ; di != de; ++di)
1551 MEMap::const_iterator mi =
data_.lower_bound(proto);
1552 MEMap::const_iterator
m = mi;
1553 size_t sz = di->size() + 2;
1556 if (*di == *m->data_.dirname)
1558 sz += m->data_.objname.size() + 1;
1565 std::vector<std::string>::iterator istr
1566 = into.insert(into.end(), std::string());
1574 for (sz = 0; mi !=
m; ++mi)
1576 if (*di != *mi->data_.dirname)
1582 *istr += mi->data_.objname;
1588 istr->reserve(di->size() + 2);
1600 if (dir.find_first_not_of(
s_safe) != std::string::npos)
1601 raiseDQMError(
"DQMStore",
"Monitor element path name '%s' uses"
1602 " unacceptable characters", dir.c_str());
1603 if (name.find_first_not_of(
s_safe) != std::string::npos)
1604 raiseDQMError(
"DQMStore",
"Monitor element path name '%s' uses"
1605 " unacceptable characters", name.c_str());
1611 MEMap::const_iterator mepos =
data_.find(proto);
1612 return (mepos ==
data_.end() ? 0
1622 into.reserve(
dirs_.size());
1624 MEMap::const_iterator me =
data_.end();
1625 std::set<std::string>::const_iterator di =
dirs_.begin();
1626 std::set<std::string>::const_iterator de =
dirs_.end();
1629 for ( ; di != de; ++di)
1632 MEMap::const_iterator mi =
data_.lower_bound(proto);
1633 MEMap::const_iterator
m = mi;
1634 size_t sz = di->size() + 2;
1640 sz += 1 + m->data_.objname.size() + 11;
1647 std::vector<std::string>::iterator istr
1648 = into.insert(into.end(), std::string());
1654 for (sz = 0; mi !=
m; ++mi)
1658 sprintf(tagbuf,
"/%u", mi->data_.tag);
1661 *istr += m->data_.objname;
1671 std::vector<MonitorElement*>
1675 const std::string *cleaned = 0;
1679 std::vector<MonitorElement *>
result;
1680 MEMap::const_iterator
e =
data_.end();
1681 MEMap::const_iterator
i =
data_.lower_bound(proto);
1683 result.push_back(const_cast<MonitorElement *>(&*i));
1690 std::vector<MonitorElement*>
1696 rx = lat::Regexp(pattern, 0, syntaxType);
1699 catch (lat::Error &
e)
1701 raiseDQMError(
"DQMStore",
"Invalid regular expression '%s': %s",
1702 pattern.c_str(), e.explain().c_str());
1706 std::vector<MonitorElement *>
result;
1707 MEMap::const_iterator
i =
data_.begin();
1708 MEMap::const_iterator e =
data_.end();
1709 for ( ; i !=
e; ++
i)
1712 mergePath(path, *i->data_.dirname, i->data_.objname);
1714 result.push_back(const_cast<MonitorElement *>(&*i));
1729 MEMap::iterator mi =
data_.begin();
1730 MEMap::iterator me =
data_.end();
1731 for ( ; mi != me; ++mi)
1734 if (mi->wasUpdated())
1753 MEMap::iterator mi =
data_.begin();
1754 MEMap::iterator me =
data_.end();
1755 for ( ; mi != me; ++mi)
1775 if (TProfile *
h = dynamic_cast<TProfile *>(obj))
1779 me =
bookProfile(dir,
h->GetName(), (TProfile *)
h->Clone());
1786 else if (TProfile2D *
h = dynamic_cast<TProfile2D *>(obj))
1797 else if (TH1F *
h = dynamic_cast<TH1F *>(obj))
1801 me =
book1D(dir,
h->GetName(), (TH1F *)
h->Clone());
1808 else if (TH1S *
h = dynamic_cast<TH1S *>(obj))
1812 me =
book1S(dir,
h->GetName(), (TH1S *)
h->Clone());
1819 else if (TH1D *
h = dynamic_cast<TH1D *>(obj))
1823 me =
book1DD(dir,
h->GetName(), (TH1D *)
h->Clone());
1830 else if (TH2F *
h = dynamic_cast<TH2F *>(obj))
1834 me =
book2D(dir,
h->GetName(), (TH2F *)
h->Clone());
1841 else if (TH2S *
h = dynamic_cast<TH2S *>(obj))
1845 me =
book2S(dir,
h->GetName(), (TH2S *)
h->Clone());
1852 else if (TH2D *
h = dynamic_cast<TH2D *>(obj))
1856 me =
book2DD(dir,
h->GetName(), (TH2D *)
h->Clone());
1863 else if (TH3F *
h = dynamic_cast<TH3F *>(obj))
1867 me =
book3D(dir,
h->GetName(), (TH3F *)
h->Clone());
1874 else if (dynamic_cast<TObjString *>(obj))
1877 if (!
s_rxmeval.match(obj->GetName(), 0, 0, &
m))
1879 if (strstr(obj->GetName(),
"CMSSW"))
1882 std::cout <<
"Input file version: " << obj->GetName() << std::endl;
1885 else if (strstr(obj->GetName(),
"DQMPATCH"))
1888 std::cout <<
"DQM patch version: " << obj->GetName() << std::endl;
1893 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
1894 << obj->GetName() <<
"' of type '"
1895 << obj->IsA()->GetName() <<
"'\n";
1900 std::string
label = m.matchString(obj->GetName(), 1);
1901 std::string kind = m.matchString(obj->GetName(), 2);
1902 std::string
value = m.matchString(obj->GetName(), 3);
1907 if (! me || overwrite)
1909 if (! me) me =
bookInt(dir, label);
1910 me->
Fill(atoll(value.c_str()));
1913 else if (kind ==
"f")
1916 if (! me || overwrite)
1919 me->
Fill(atof(value.c_str()));
1922 else if (kind ==
"s")
1930 else if (kind ==
"e")
1935 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
1936 << label <<
"' in directory '"
1937 << dir <<
"' to be marked as efficiency plot.\n";
1942 else if (kind ==
"t")
1947 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
1948 << label <<
"' in directory '"
1949 << dir <<
"' for a tag\n";
1954 unsigned long val = strtoul(value.c_str(), &endp, 10);
1955 if ((val == 0 && errno) || *endp || val > ~uint32_t(0))
1957 std::cout <<
"*** DQMStore: WARNING: cannot restore tag '"
1958 << value <<
"' for monitor element '"
1959 << label <<
"' in directory '"
1960 << dir <<
"' - invalid value\n";
1965 else if (kind ==
"qr")
1970 size_t dot = label.find(
'.');
1971 if (dot == std::string::npos)
1973 std::cout <<
"*** DQMStore: WARNING: quality report label in '" << label
1974 <<
"' is missing a '.' and cannot be extracted\n";
1978 std::string mename (label, 0, dot);
1979 std::string qrname (label, dot+1, std::string::npos);
1985 qv.
code = atoi(m.matchString(value, 1).c_str());
1986 qv.
qtresult = strtod(m.matchString(value, 2).c_str(), 0);
1987 qv.
message = m.matchString(value, 4);
1991 else if (
s_rxmeqr2.match(value, 0, 0, &m))
1993 qv.
code = atoi(m.matchString(value, 1).c_str());
1995 qv.
message = m.matchString(value, 2);
2001 std::cout <<
"*** DQMStore: WARNING: quality test value '"
2002 << value <<
"' is incorrectly formatted\n";
2009 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
2010 << mename <<
"' in directory '"
2011 << dir <<
"' for quality test '"
2021 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
2022 << obj->GetName() <<
"' of type '"
2023 << obj->IsA()->GetName() <<
"'\n";
2027 else if (TNamed *
n = dynamic_cast<TNamed *>(obj))
2031 s.reserve(6 + strlen(
n->GetTitle()) + 2*strlen(
n->GetName()));
2032 s +=
'<'; s +=
n->GetName(); s +=
'>';
2034 s +=
'<'; s +=
'/'; s +=
n->GetName(); s +=
'>';
2035 TObjString os(s.c_str());
2036 return extract(&os, dir, overwrite);
2040 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
2041 << obj->GetName() <<
"' of type '" << obj->IsA()->GetName()
2042 <<
"' and with title '" << obj->GetTitle() <<
"'\n";
2068 assert(! path.empty());
2072 size_t end = path.find(
'/', start);
2073 if (end == std::string::npos)
2080 std::string
part(path, start, end-start);
2081 TObject *
o = gDirectory->Get(part.c_str());
2082 if (o && ! dynamic_cast<TDirectory *>(o))
2083 raiseDQMError(
"DQMStore",
"Attempt to create directory '%s' in a file"
2084 " fails because the part '%s' already exists and is not"
2085 " directory", path.c_str(), part.c_str());
2087 gDirectory->mkdir(part.c_str());
2089 if (! gDirectory->cd(part.c_str()))
2090 raiseDQMError(
"DQMStore",
"Attempt to create directory '%s' in a file"
2091 " fails because could not cd into subdirectory '%s'",
2092 path.c_str(), part.c_str());
2095 if (end+1 >= path.size())
2100 end = path.find(
'/', start);
2101 if (end == std::string::npos)
2114 const std::string &
path ,
2116 const std::string &rewrite ,
2119 const std::string &fileupdate )
2121 std::set<std::string>::iterator di, de;
2122 MEMap::iterator mi, me =
data_.end();
2123 DQMNet::QReports::const_iterator qi, qe;
2130 class TFileNoSync :
public TFile
2133 TFileNoSync(
const char *
file,
const char *opt) : TFile(file, opt) {}
2134 virtual Int_t SysSync(Int_t) {
return 0; }
2139 std::cout <<
"\n DQMStore: Opening TFile '" << filename
2140 <<
"' with option '" << fileupdate <<
"'\n";
2142 TFileNoSync
f(filename.c_str(), fileupdate.c_str());
2144 raiseDQMError(
"DQMStore",
"Failed to create/update file '%s'", filename.c_str());
2148 std::auto_ptr<lat::Regexp> rxpat;
2149 if (! pattern.empty())
2150 rxpat.reset(
new lat::Regexp(pattern.c_str()));
2153 std::string refpath;
2163 for (di =
dirs_.begin(), de =
dirs_.end(); di != de; ++di)
2174 mi =
data_.lower_bound(proto);
2175 for ( ; mi != me &&
isSubdirectory(*di, *mi->data_.dirname); ++mi)
2178 if (*di != *mi->data_.dirname)
2200 std::string mname(mi->getFullname(),
s_referenceDirName.size()+1, std::string::npos);
2203 for (
size_t i = 0,
e = master->data_.qreports.size();
i !=
e; ++
i)
2204 status =
std::max(status, master->data_.qreports[
i].code);
2206 if (! master || status < minStatus)
2209 std::cout <<
"DQMStore::save: skipping monitor element '"
2210 << mi->data_.objname <<
"' while saving, status is "
2211 << status <<
", required minimum status is "
2212 << minStatus << std::endl;
2219 std::cout <<
"DQMStore::save: saving monitor element '"
2220 << mi->data_.objname <<
"'\n";
2224 gDirectory->cd(
"/");
2227 else if (rxpat.get())
2238 TObjString(mi->tagString().c_str()).Write();
2242 mi->object_->Write();
2249 qi = mi->data_.qreports.begin();
2250 qe = mi->data_.qreports.end();
2251 for ( ; qi != qe; ++qi)
2252 TObjString(mi->qualityTagString(*qi).c_str()).Write();
2257 TObjString(mi->effLabelString().c_str()).Write();
2261 TObjString(mi->tagLabelString().c_str()).Write();
2269 std::cout <<
"DQMStore::save: successfully wrote " << nme
2270 <<
" objects from path '" << path
2271 <<
"' into DQM file '" << filename <<
"'\n";
2279 const std::string &onlypath,
2280 const std::string &prepend,
2281 const std::string &curdir,
2284 unsigned int ntot = 0;
2285 unsigned int count = 0;
2287 if (! file->cd(curdir.c_str()))
2288 raiseDQMError(
"DQMStore",
"Failed to process directory '%s' while"
2289 " reading file '%s'", curdir.c_str(), file->GetName());
2293 std::string dirpart = curdir;
2312 size_t slash = dirpart.find(
'/');
2313 size_t pos = dirpart.find(
"/Run summary");
2314 if (slash != std::string::npos && pos !=std::string::npos)
2316 dirpart.erase(pos,12);
2318 pos = dirpart.find(
"Run ");
2319 size_t length = dirpart.find(
'/',pos+1)-pos+1;
2320 if (pos !=std::string::npos)
2321 dirpart.erase(pos,length);
2330 size_t slash = dirpart.find(
'/');
2332 if (slash == std::string::npos
2337 slash = dirpart.find(
'/');
2339 if (slash != std::string::npos
2340 && slash + 10 == dirpart.size()
2341 && dirpart.compare( slash+1 , 9 ,
"EventInfo") == 0) {
2343 std::cout <<
"DQMStore::readDirectory: skipping '" << dirpart <<
"'\n";
2348 if (dirpart.empty())
2351 dirpart = prepend +
'/' + dirpart;
2353 else if (! prepend.empty())
2355 if (dirpart.empty())
2358 dirpart = prepend +
'/' + dirpart;
2366 TIter
next (gDirectory->GetListOfKeys());
2367 std::list<TObject *> delayed;
2368 while ((key = (TKey *)
next()))
2370 std::auto_ptr<TObject>
obj(key->ReadObj());
2371 if (dynamic_cast<TDirectory *>(
obj.get()))
2374 subdir.reserve(curdir.size() + strlen(
obj->GetName()) + 2);
2376 if (! curdir.empty())
2378 subdir +=
obj->GetName();
2380 ntot +=
readDirectory(file, overwrite, onlypath, prepend, subdir, stripdirs);
2384 else if (dynamic_cast<TObjString *>(
obj.get()))
2386 delayed.push_back(
obj.release());
2391 std::cout <<
"DQMStore: reading object '" <<
obj->GetName()
2392 <<
"' of type '" <<
obj->IsA()->GetName()
2393 <<
"' from '" << file->GetName()
2394 <<
"' into '" << dirpart <<
"'\n";
2402 while (! delayed.empty())
2405 std::cout <<
"DQMStore: reading object '" << delayed.front()->GetName()
2406 <<
"' of type '" << delayed.front()->IsA()->GetName()
2407 <<
"' from '" << file->GetName()
2408 <<
"' into '" << dirpart <<
"'\n";
2411 if (
extract(delayed.front(), dirpart, overwrite))
2414 delete delayed.front();
2415 delayed.pop_front();
2419 std::cout <<
"DQMStore: read " << count <<
'/' << ntot
2420 <<
" objects from directory '" << dirpart <<
"'\n";
2422 return ntot +
count;
2434 const std::string &onlypath ,
2435 const std::string &prepend ,
2437 bool fileMustExist )
2439 return readFile(filename,overwrite,onlypath,prepend,stripdirs,fileMustExist);
2449 bool fileMustExist )
2451 bool overwrite =
true;
2455 std::cout <<
"DQMStore::load: reading from file '" << filename <<
"'\n";
2457 std::cout <<
"DQMStore::load: in collate mode " <<
"\n";
2459 std::cout <<
"DQMStore::load: in overwrite mode " <<
"\n";
2462 return readFile(filename,overwrite,
"",
"",stripdirs,fileMustExist);
2474 const std::string &onlypath ,
2475 const std::string &prepend ,
2477 bool fileMustExist )
2481 std::cout <<
"DQMStore::readFile: reading from file '" << filename <<
"'\n";
2483 std::auto_ptr<TFile>
f;
2487 f.reset(TFile::Open(filename.c_str()));
2488 if (! f.get() || f->IsZombie())
2489 raiseDQMError(
"DQMStore",
"Failed to open file '%s'", filename.c_str());
2498 std::cout <<
"DQMStore::readFile: file '" << filename <<
"' does not exist, continuing\n";
2503 unsigned n =
readDirectory(f.get(), overwrite, onlypath, prepend,
"", stripdirs);
2506 MEMap::iterator mi =
data_.begin();
2507 MEMap::iterator me =
data_.end();
2508 for ( ; mi != me; ++mi)
2509 const_cast<MonitorElement &>(*mi).updateQReportStats();
2513 std::cout <<
"DQMStore::open: successfully read " << n
2514 <<
" objects from file '" << filename <<
"'";
2515 if (! onlypath.empty())
2516 std::cout <<
" from directory '" << onlypath <<
"'";
2517 if (! prepend.empty())
2518 std::cout <<
" into directory '" << prepend <<
"'";
2533 const std::string *cleaned = 0;
2537 MEMap::iterator
e =
data_.end();
2538 MEMap::iterator
i =
data_.lower_bound(proto);
2542 std::set<std::string>::iterator de =
dirs_.end();
2543 std::set<std::string>::iterator di =
dirs_.lower_bound(*cleaned);
2553 MEMap::iterator
e =
data_.end();
2554 MEMap::iterator
i =
data_.lower_bound(proto);
2556 if (dir == *i->data_.dirname)
2583 MEMap::iterator
pos =
data_.find(proto);
2585 std::cout <<
"DQMStore: WARNING: attempt to remove non-existent"
2586 <<
" monitor element '" << name <<
"' in '" << dir <<
"'\n";
2599 QCMap::const_iterator
i =
qtests_.find(qtname);
2600 QCMap::const_iterator
e =
qtests_.end();
2601 return (i == e ? 0 : i->second);
2611 raiseDQMError(
"DQMStore",
"Attempt to create duplicate quality test '%s'",
2614 QAMap::iterator
i =
qalgos_.find(algoname);
2616 raiseDQMError(
"DQMStore",
"Cannot create a quality test using unknown"
2617 " algorithm '%s'", algoname.c_str());
2633 const std::string *cleaned = 0;
2637 if (cleaned->find_first_not_of(
s_safe) != std::string::npos)
2639 " uses unacceptable characters", cleaned->c_str());
2651 raiseDQMError(
"DQMStore",
"Cannot apply non-existent quality test '%s'",
2661 MEMap::iterator mi =
data_.begin();
2662 MEMap::iterator me =
data_.end();
2665 for ( ; mi != me; ++mi)
2668 mergePath(path, *mi->data_.dirname, mi->data_.objname);
2669 if (fm->match(path))
2686 std::cout <<
"DQMStore: running runQTests() with reset = "
2687 << (
reset_ ?
"true" :
"false" ) << std::endl;
2690 MEMap::iterator mi =
data_.begin();
2691 MEMap::iterator me =
data_.end();
2692 for ( ; mi != me; ++mi)
2706 const std::string *cleaned = 0;
2710 MEMap::const_iterator mi =
data_.begin();
2711 MEMap::const_iterator me =
data_.end();
2712 for ( ; mi != me; ++mi)
2714 if (! cleaned->empty() && !
isSubdirectory(*cleaned, *mi->data_.dirname))
2719 else if (mi->hasWarning())
2722 && mi->hasOtherReport())
2766 std::cout <<
" ------------------------------------------------------------\n"
2767 <<
" Directory structure: \n"
2768 <<
" ------------------------------------------------------------\n";
2770 std::copy(contents.begin(), contents.end(),
2771 std::ostream_iterator<std::string>(
std::cout,
"\n"));
2773 std::cout <<
" ------------------------------------------------------------\n";
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
Master< F > master(const F &f)
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
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)
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)
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)
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)
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,...)