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 const 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)
267 owner_->setCurrentFolder(fullpath);
271 owner_->tag(me, tag);
289 std::cout <<
"Merging objects from run: "
291 <<
", stream: " << streamId
292 <<
" module: " << moduleId << std::endl;
294 MonitorElement proto(&null_str, null_str, run, streamId, moduleId);
295 std::set<MonitorElement>::const_iterator
e =
data_.end();
296 std::set<MonitorElement>::const_iterator
i =
data_.lower_bound(proto);
298 if (i->data_.run != run
299 || i->data_.streamId != streamId
300 || i->data_.moduleId != moduleId)
304 if (i->getLumiFlag()) {
311 std::set<MonitorElement>::const_iterator me =
data_.find(global_me);
312 if (me !=
data_.end()) {
314 std::cout <<
"Found global Object, using it. ";
315 me->getTH1()->Add(i->getTH1());
322 me =
data_.find(global_me);
323 if (me !=
data_.end()) {
324 me->getTH1()->Add(i->getTH1());
326 std::pair<std::set<MonitorElement>::const_iterator,
bool> gme;
327 gme =
data_.insert(global_me);
341 std::cout <<
"Merging objects from run: "
342 << run <<
" lumi: " << lumi
343 <<
", stream: " << streamId
344 <<
" module: " << moduleId << std::endl;
346 MonitorElement proto(&null_str, null_str, run, streamId, moduleId);
347 std::set<MonitorElement>::const_iterator
e =
data_.end();
348 std::set<MonitorElement>::const_iterator
i =
data_.lower_bound(proto);
350 if (i->data_.run != run
351 || i->data_.streamId != streamId
352 || i->data_.moduleId != moduleId)
356 if (not i->getLumiFlag()) {
364 std::set<MonitorElement>::const_iterator me =
data_.find(global_me);
365 if (me !=
data_.end()) {
367 std::cout <<
"Found global Object, using it --> ";
368 me->getTH1()->Add(i->getTH1());
375 me =
data_.find(global_me);
376 if (me !=
data_.end()) {
377 me->getTH1()->Add(i->getTH1());
379 std::pair<std::set<MonitorElement>::const_iterator,
bool> gme;
380 gme =
data_.insert(global_me);
416 collateHistograms_ (
false),
417 enableMultiThread_(
false),
418 readSelectedDirectory_ (
""),
456 std::cout <<
"DQMStore: histogram collation is enabled\n";
460 std::cout <<
"DQMStore: MultiThread option is enabled\n";
465 std::cout <<
"DQMStore: using reference file '" << ref <<
"'\n";
469 initQCriterion<Comp2RefChi2>(
qalgos_);
470 initQCriterion<Comp2RefKolmogorov>(
qalgos_);
471 initQCriterion<ContentsXRange>(
qalgos_);
472 initQCriterion<ContentsYRange>(
qalgos_);
473 initQCriterion<MeanWithinExpected>(
qalgos_);
474 initQCriterion<Comp2RefEqualH>(
qalgos_);
475 initQCriterion<DeadChannel>(
qalgos_);
476 initQCriterion<NoisyChannel>(
qalgos_);
477 initQCriterion<ContentsWithinExpected>(
qalgos_);
478 initQCriterion<CompareToMedian>(
qalgos_);
479 initQCriterion<CompareLastFilledBin>(
qalgos_);
480 initQCriterion<CheckVariance>(
qalgos_);
484 std::cout <<
"DQMStore: Scaling Flag set to " << scaleFlag_ << std::endl;
499 static std::ofstream stream(
"histogramBookingBT.log");
507 size = backtrace (array, 10);
508 strings = backtrace_symbols (array, size);
513 char * demangled = abi::__cxa_demangle(m.matchString(strings[4], 2).c_str(), 0, 0, &
r);
514 stream <<
"\"" << dir <<
"/"
516 << (r ? m.matchString(strings[4], 2) : demangled) <<
" "
517 << m.matchString(strings[4], 1) <<
"\n";
521 stream <<
"Skipping "<< dir <<
"/" << name
522 <<
" with stack size " << size <<
"\n";
530 for (i = 0; i <
size; i++)
531 if (
s_rxtrace.match(strings[i], 0, 0, &m))
533 char * demangled = abi::__cxa_demangle(m.matchString(strings[i], 2).c_str(), 0, 0, &
r);
534 stream <<
"\t\t" << i <<
"/" << size <<
" "
535 << (r ? m.matchString(strings[i], 2) : demangled) <<
" "
536 << m.matchString(strings[i], 1) << std::endl;
573 raiseDQMError(
"DQMStore",
"Cannot 'cd' into non-existent directory '%s'",
597 size_t pos =
pwd_.rfind(
'/');
598 if (pos == std::string::npos)
612 prev.reserve(path.size());
613 subdir.reserve(path.size());
614 name.reserve(path.size());
622 subdir.append(path, 0, slash);
624 name.append(subdir, prevname, std::string::npos);
626 raiseDQMError(
"DQMStore",
"Attempt to create subdirectory '%s'"
627 " which already exists as a monitor element",
630 if (!
dirs_.count(subdir))
631 dirs_.insert(subdir);
634 if (slash+1 >= path.size())
639 prevname = slash ? slash+1 :
slash;
641 if ((slash = path.find(
'/', ++slash)) == std::string::npos)
649 {
return dirs_.count(path) > 0; }
654 template <
class HISTO,
class COLLATE>
657 const char *context,
int kind,
658 HISTO *
h, COLLATE collate)
660 assert(name.find(
'/') == std::string::npos);
683 << context <<
": monitor element '"
684 << path <<
"' already exists, collating" << std::endl;
694 assert(
dirs_.count(dir));
702 for ( ; qi != qe; ++qi)
704 if ( qi->first->match(path) )
705 me->addQReport(qi->second);
718 me->reference_ = refme->object_;
731 assert(name.find(
'/') == std::string::npos);
744 << context <<
": monitor element '"
745 << path <<
"' already exists, resetting" << std::endl;
753 assert(
dirs_.count(dir));
773 return book(dir, name,
"bookInt")
803 return book(dir, name,
"bookFloat")
832 return book(dir, name,
"bookString")
873 int nchX,
double lowX,
double highX)
875 return book1D(
pwd_, name,
new TH1F(name, title, nchX, lowX, highX));
881 int nchX,
double lowX,
double highX)
883 return book1D(
pwd_, name,
new TH1F(name.c_str(), title.c_str(), nchX, lowX, highX));
889 int nchX,
double lowX,
double highX)
891 return book1S(
pwd_, name,
new TH1S(name, title, nchX, lowX, highX));
897 int nchX,
double lowX,
double highX)
899 return book1S(
pwd_, name,
new TH1S(name.c_str(), title.c_str(), nchX, lowX, highX));
905 int nchX,
double lowX,
double highX)
907 return book1DD(
pwd_, name,
new TH1D(name, title, nchX, lowX, highX));
913 int nchX,
double lowX,
double highX)
915 return book1DD(
pwd_, name,
new TH1D(name.c_str(), title.c_str(), nchX, lowX, highX));
921 int nchX,
float *xbinsize)
923 return book1D(
pwd_, name,
new TH1F(name, title, nchX, xbinsize));
929 int nchX,
float *xbinsize)
931 return book1D(
pwd_, name,
new TH1F(name.c_str(), title.c_str(), nchX, xbinsize));
938 return book1D(
pwd_, name, static_cast<TH1F *>(source->Clone(name)));
945 return book1D(
pwd_, name, static_cast<TH1F *>(source->Clone(name.c_str())));
952 return book1S(
pwd_, name, static_cast<TH1S *>(source->Clone(name)));
959 return book1S(
pwd_, name, static_cast<TH1S *>(source->Clone(name.c_str())));
966 return book1DD(
pwd_, name, static_cast<TH1D *>(source->Clone(name)));
973 return book1DD(
pwd_, name, static_cast<TH1D *>(source->Clone(name.c_str())));
1001 int nchX,
double lowX,
double highX,
1002 int nchY,
double lowY,
double highY)
1004 return book2D(
pwd_, name,
new TH2F(name, title,
1006 nchY, lowY, highY));
1012 int nchX,
double lowX,
double highX,
1013 int nchY,
double lowY,
double highY)
1015 return book2D(
pwd_, name,
new TH2F(name.c_str(), title.c_str(),
1017 nchY, lowY, highY));
1023 int nchX,
double lowX,
double highX,
1024 int nchY,
double lowY,
double highY)
1026 return book2S(
pwd_, name,
new TH2S(name, title,
1028 nchY, lowY, highY));
1034 int nchX,
double lowX,
double highX,
1035 int nchY,
double lowY,
double highY)
1037 return book2S(
pwd_, name,
new TH2S(name.c_str(), title.c_str(),
1039 nchY, lowY, highY));
1045 int nchX,
double lowX,
double highX,
1046 int nchY,
double lowY,
double highY)
1050 nchY, lowY, highY));
1056 int nchX,
double lowX,
double highX,
1057 int nchY,
double lowY,
double highY)
1059 return book2DD(
pwd_, name,
new TH2D(name.c_str(), title.c_str(),
1061 nchY, lowY, highY));
1067 int nchX,
float *xbinsize,
int nchY,
float *ybinsize)
1069 return book2D(
pwd_, name,
new TH2F(name, title,
1070 nchX, xbinsize, nchY, ybinsize));
1076 int nchX,
float *xbinsize,
int nchY,
float *ybinsize)
1078 return book2D(
pwd_, name,
new TH2F(name.c_str(), title.c_str(),
1079 nchX, xbinsize, nchY, ybinsize));
1086 return book2D(
pwd_, name, static_cast<TH2F *>(source->Clone(name)));
1093 return book2D(
pwd_, name, static_cast<TH2F *>(source->Clone(name.c_str())));
1100 return book2S(
pwd_, name, static_cast<TH2S *>(source->Clone(name)));
1107 return book2S(
pwd_, name, static_cast<TH2S *>(source->Clone(name.c_str())));
1114 return book2DD(
pwd_, name, static_cast<TH2D *>(source->Clone(name)));
1121 return book2DD(
pwd_, name, static_cast<TH2D *>(source->Clone(name.c_str())));
1135 int nchX,
double lowX,
double highX,
1136 int nchY,
double lowY,
double highY,
1137 int nchZ,
double lowZ,
double highZ)
1139 return book3D(
pwd_, name,
new TH3F(name, title,
1142 nchZ, lowZ, highZ));
1148 int nchX,
double lowX,
double highX,
1149 int nchY,
double lowY,
double highY,
1150 int nchZ,
double lowZ,
double highZ)
1152 return book3D(
pwd_, name,
new TH3F(name.c_str(), title.c_str(),
1155 nchZ, lowZ, highZ));
1162 return book3D(
pwd_, name, static_cast<TH3F *>(source->Clone(name)));
1169 return book3D(
pwd_, name, static_cast<TH3F *>(source->Clone(name.c_str())));
1177 return book(dir, name,
"bookProfile",
1187 int nchX,
double lowX,
double highX,
1188 int ,
double lowY,
double highY,
1189 const char *option )
1202 int nchX,
double lowX,
double highX,
1203 int ,
double lowY,
double highY,
1204 const char *option )
1206 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1217 int nchX,
double lowX,
double highX,
1218 double lowY,
double highY,
1219 const char *option )
1232 int nchX,
double lowX,
double highX,
1233 double lowY,
double highY,
1234 const char *option )
1236 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1247 int nchX,
double *xbinsize,
1248 int ,
double lowY,
double highY,
1249 const char *option )
1262 int nchX,
double *xbinsize,
1263 int ,
double lowY,
double highY,
1264 const char *option )
1266 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1277 int nchX,
double *xbinsize,
1278 double lowY,
double highY,
1279 const char *option )
1292 int nchX,
double *xbinsize,
1293 double lowY,
double highY,
1294 const char *option )
1296 return bookProfile(
pwd_, name,
new TProfile(name.c_str(), title.c_str(),
1306 return bookProfile(
pwd_, name, static_cast<TProfile *>(source->Clone(name)));
1313 return bookProfile(
pwd_, name, static_cast<TProfile *>(source->Clone(name.c_str())));
1321 return book(dir, name,
"bookProfile2D",
1331 int nchX,
double lowX,
double highX,
1332 int nchY,
double lowY,
double highY,
1333 int ,
double lowZ,
double highZ,
1334 const char *option )
1348 int nchX,
double lowX,
double highX,
1349 int nchY,
double lowY,
double highY,
1350 int ,
double lowZ,
double highZ,
1351 const char *option )
1365 int nchX,
double lowX,
double highX,
1366 int nchY,
double lowY,
double highY,
1367 double lowZ,
double highZ,
1368 const char *option )
1382 int nchX,
double lowX,
double highX,
1383 int nchY,
double lowY,
double highY,
1384 double lowZ,
double highZ,
1385 const char *option )
1398 return bookProfile2D(
pwd_, name, static_cast<TProfile2D *>(source->Clone(name)));
1405 return bookProfile2D(
pwd_, name, static_cast<TProfile2D *>(source->Clone(name.c_str())));
1414 if (me->
getTH1()->GetNbinsX() != h->GetNbinsX()
1415 || me->
getTH1()->GetNbinsY() != h->GetNbinsY()
1416 || me->
getTH1()->GetNbinsZ() != h->GetNbinsZ()
1417 || me->
getTH1()->GetXaxis()->GetXmin() != h->GetXaxis()->GetXmin()
1418 || me->
getTH1()->GetYaxis()->GetXmin() != h->GetYaxis()->GetXmin()
1419 || me->
getTH1()->GetZaxis()->GetXmin() != h->GetZaxis()->GetXmin()
1420 || me->
getTH1()->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax()
1421 || me->
getTH1()->GetYaxis()->GetXmax() != h->GetYaxis()->GetXmax()
1422 || me->
getTH1()->GetZaxis()->GetXmax() != h->GetZaxis()->GetXmax())
1426 <<
"checkBinningMatches: different binning - cannot add object '"
1427 << h->GetName() <<
"' of type "
1428 << h->IsA()->GetName() <<
" to existing ME: '"
1512 raiseDQMError(
"DQMStore",
"Attempt to tag monitor element '%s'"
1515 raiseDQMError(
"DQMStore",
"Attempt to tag monitor element '%s'"
1516 " twice with multiple tags", me->
getFullname().c_str());
1533 raiseDQMError(
"DQMStore",
"Attempt to tag non-existent monitor element"
1534 " '%s' with tag %u", path.c_str(), myTag);
1543 MEMap::iterator
e =
data_.end();
1544 MEMap::iterator
i =
data_.lower_bound(proto);
1545 for ( ; i != e && path == *i->data_.dirname; ++
i)
1546 tag(const_cast<MonitorElement *>(&*i), myTag);
1560 MEMap::iterator
e =
data_.end();
1561 MEMap::iterator
i =
data_.lower_bound(proto);
1564 tag(const_cast<MonitorElement *>(&*i), myTag);
1573 std::vector<std::string>
1576 std::vector<std::string>
result;
1577 std::set<std::string>::const_iterator
e =
dirs_.end();
1578 std::set<std::string>::const_iterator
i =
dirs_.find(
pwd_);
1589 if (i->find(
'/',
pwd_.size()+1) == std::string::npos)
1590 result.push_back(*i);
1596 std::vector<std::string>
1600 std::vector<std::string>
result;
1601 MEMap::const_iterator
e =
data_.end();
1602 MEMap::const_iterator
i =
data_.lower_bound(proto);
1604 if (
pwd_ == *i->data_.dirname)
1605 result.push_back(i->getName());
1616 MEMap::const_iterator
e =
data_.end();
1617 MEMap::const_iterator
i =
data_.lower_bound(proto);
1629 MEMap::const_iterator mepos =
data_.find(proto);
1630 return (mepos ==
data_.end() ? 0
1635 std::vector<MonitorElement *>
1639 std::vector<MonitorElement *>
result;
1640 for (MEMap::const_iterator
i =
data_.begin(),
e =
data_.end();
i !=
e; ++
i)
1644 result.push_back(const_cast<MonitorElement *>(&me));
1651 std::vector<MonitorElement *>
1659 std::vector<MonitorElement *>
result;
1660 MEMap::const_iterator
e =
data_.end();
1661 MEMap::const_iterator
i =
data_.lower_bound(proto);
1663 if (*cleaned == *i->data_.dirname)
1664 result.push_back(const_cast<MonitorElement *>(&*i));
1670 std::vector<MonitorElement *>
1678 std::vector<MonitorElement *>
result;
1679 MEMap::const_iterator
e =
data_.end();
1680 MEMap::const_iterator
i =
data_.lower_bound(proto);
1682 if (*cleaned == *i->data_.dirname
1684 && i->data_.tag ==
tag)
1685 result.push_back(const_cast<MonitorElement *>(&*i));
1698 into.reserve(
dirs_.size());
1700 MEMap::const_iterator me =
data_.end();
1701 std::set<std::string>::const_iterator di =
dirs_.begin();
1702 std::set<std::string>::const_iterator de =
dirs_.end();
1703 for ( ; di != de; ++di)
1706 MEMap::const_iterator mi =
data_.lower_bound(proto);
1707 MEMap::const_iterator
m = mi;
1708 size_t sz = di->size() + 2;
1711 if (*di == *m->data_.dirname)
1713 sz += m->data_.objname.size() + 1;
1720 std::vector<std::string>::iterator istr
1729 for (sz = 0; mi !=
m; ++mi)
1731 if (*di != *mi->data_.dirname)
1737 *istr += mi->data_.objname;
1743 istr->reserve(di->size() + 2);
1755 const uint32_t
run ,
1756 const uint32_t
lumi ,
1757 const uint32_t streamId ,
1758 const uint32_t moduleId )
const
1760 if (dir.find_first_not_of(
s_safe) != std::string::npos)
1761 raiseDQMError(
"DQMStore",
"Monitor element path name '%s' uses"
1762 " unacceptable characters", dir.c_str());
1763 if (name.find_first_not_of(
s_safe) != std::string::npos)
1764 raiseDQMError(
"DQMStore",
"Monitor element path name '%s' uses"
1765 " unacceptable characters", name.c_str());
1775 MEMap::const_iterator mepos =
data_.find(proto);
1776 return (mepos ==
data_.end() ? 0
1786 into.reserve(
dirs_.size());
1788 MEMap::const_iterator me =
data_.end();
1789 std::set<std::string>::const_iterator di =
dirs_.begin();
1790 std::set<std::string>::const_iterator de =
dirs_.end();
1793 for ( ; di != de; ++di)
1796 MEMap::const_iterator mi =
data_.lower_bound(proto);
1797 MEMap::const_iterator
m = mi;
1798 size_t sz = di->size() + 2;
1804 sz += 1 + m->data_.objname.size() + 11;
1811 std::vector<std::string>::iterator istr
1818 for (sz = 0; mi !=
m; ++mi)
1822 sprintf(tagbuf,
"/%u", mi->data_.tag);
1825 *istr += m->data_.objname;
1835 std::vector<MonitorElement*>
1838 uint32_t
lumi )
const
1846 std::vector<MonitorElement *>
result;
1847 MEMap::const_iterator
e =
data_.end();
1848 MEMap::const_iterator
i =
data_.lower_bound(proto);
1850 if (runNumber != 0) {
1851 if (i->data_.run > runNumber
1852 || i->data_.streamId != 0
1853 || i->data_.moduleId != 0)
1857 if (i->data_.lumi > lumi
1858 || i->data_.streamId != 0
1859 || i->data_.moduleId != 0)
1862 if (runNumber != 0
or lumi !=0) {
1863 assert(i->data_.streamId == 0);
1864 assert(i->data_.moduleId == 0);
1866 result.push_back(const_cast<MonitorElement *>(&*i));
1873 std::vector<MonitorElement*>
1879 rx = lat::Regexp(pattern, 0, syntaxType);
1882 catch (lat::Error &
e)
1884 raiseDQMError(
"DQMStore",
"Invalid regular expression '%s': %s",
1885 pattern.c_str(), e.explain().c_str());
1889 std::vector<MonitorElement *>
result;
1890 MEMap::const_iterator
i =
data_.begin();
1891 MEMap::const_iterator e =
data_.end();
1892 for ( ; i !=
e; ++
i)
1895 mergePath(path, *i->data_.dirname, i->data_.objname);
1897 result.push_back(const_cast<MonitorElement *>(&*i));
1912 MEMap::iterator mi =
data_.begin();
1913 MEMap::iterator me =
data_.end();
1914 for ( ; mi != me; ++mi)
1917 if (mi->wasUpdated())
1936 MEMap::iterator mi =
data_.begin();
1937 MEMap::iterator me =
data_.end();
1938 for ( ; mi != me; ++mi)
1958 if (TProfile *
h = dynamic_cast<TProfile *>(obj))
1962 me =
bookProfile(dir,
h->GetName(), (TProfile *)
h->Clone());
1969 else if (TProfile2D *
h = dynamic_cast<TProfile2D *>(obj))
1980 else if (TH1F *
h = dynamic_cast<TH1F *>(obj))
1984 me =
book1D(dir,
h->GetName(), (TH1F *)
h->Clone());
1991 else if (TH1S *
h = dynamic_cast<TH1S *>(obj))
1995 me =
book1S(dir,
h->GetName(), (TH1S *)
h->Clone());
2002 else if (TH1D *
h = dynamic_cast<TH1D *>(obj))
2006 me =
book1DD(dir,
h->GetName(), (TH1D *)
h->Clone());
2013 else if (TH2F *
h = dynamic_cast<TH2F *>(obj))
2017 me =
book2D(dir,
h->GetName(), (TH2F *)
h->Clone());
2024 else if (TH2S *
h = dynamic_cast<TH2S *>(obj))
2028 me =
book2S(dir,
h->GetName(), (TH2S *)
h->Clone());
2035 else if (TH2D *
h = dynamic_cast<TH2D *>(obj))
2039 me =
book2DD(dir,
h->GetName(), (TH2D *)
h->Clone());
2046 else if (TH3F *
h = dynamic_cast<TH3F *>(obj))
2050 me =
book3D(dir,
h->GetName(), (TH3F *)
h->Clone());
2057 else if (dynamic_cast<TObjString *>(obj))
2060 if (!
s_rxmeval.match(obj->GetName(), 0, 0, &
m))
2062 if (strstr(obj->GetName(),
"CMSSW"))
2065 std::cout <<
"Input file version: " << obj->GetName() << std::endl;
2068 else if (strstr(obj->GetName(),
"DQMPATCH"))
2071 std::cout <<
"DQM patch version: " << obj->GetName() << std::endl;
2076 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
2077 << obj->GetName() <<
"' of type '"
2078 << obj->IsA()->GetName() <<
"'\n";
2084 std::string kind = m.matchString(obj->GetName(), 2);
2090 if (! me || overwrite)
2092 if (! me) me =
bookInt(dir, label);
2093 me->
Fill(atoll(value.c_str()));
2096 else if (kind ==
"f")
2099 if (! me || overwrite)
2102 me->
Fill(atof(value.c_str()));
2105 else if (kind ==
"s")
2113 else if (kind ==
"e")
2118 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
2119 << label <<
"' in directory '"
2120 << dir <<
"' to be marked as efficiency plot.\n";
2125 else if (kind ==
"t")
2130 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
2131 << label <<
"' in directory '"
2132 << dir <<
"' for a tag\n";
2137 unsigned long val = strtoul(value.c_str(), &endp, 10);
2138 if ((val == 0 && errno) || *endp || val > ~uint32_t(0))
2140 std::cout <<
"*** DQMStore: WARNING: cannot restore tag '"
2141 << value <<
"' for monitor element '"
2142 << label <<
"' in directory '"
2143 << dir <<
"' - invalid value\n";
2148 else if (kind ==
"qr")
2153 size_t dot = label.find(
'.');
2154 if (dot == std::string::npos)
2156 std::cout <<
"*** DQMStore: WARNING: quality report label in '" << label
2157 <<
"' is missing a '.' and cannot be extracted\n";
2162 std::string qrname (label, dot+1, std::string::npos);
2168 qv.
code = atoi(m.matchString(value, 1).c_str());
2169 qv.
qtresult = strtod(m.matchString(value, 2).c_str(), 0);
2170 qv.
message = m.matchString(value, 4);
2174 else if (
s_rxmeqr2.match(value, 0, 0, &m))
2176 qv.
code = atoi(m.matchString(value, 1).c_str());
2178 qv.
message = m.matchString(value, 2);
2184 std::cout <<
"*** DQMStore: WARNING: quality test value '"
2185 << value <<
"' is incorrectly formatted\n";
2192 std::cout <<
"*** DQMStore: WARNING: no monitor element '"
2193 << mename <<
"' in directory '"
2194 << dir <<
"' for quality test '"
2204 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
2205 << obj->GetName() <<
"' of type '"
2206 << obj->IsA()->GetName() <<
"'\n";
2210 else if (TNamed *
n = dynamic_cast<TNamed *>(obj))
2214 s.reserve(6 + strlen(
n->GetTitle()) + 2*strlen(
n->GetName()));
2215 s +=
'<'; s +=
n->GetName(); s +=
'>';
2217 s +=
'<'; s +=
'/'; s +=
n->GetName(); s +=
'>';
2218 TObjString os(s.c_str());
2219 return extract(&os, dir, overwrite);
2223 std::cout <<
"*** DQMStore: WARNING: cannot extract object '"
2224 << obj->GetName() <<
"' of type '" << obj->IsA()->GetName()
2225 <<
"' and with title '" << obj->GetTitle() <<
"'\n";
2251 assert(! path.empty());
2255 size_t end = path.find(
'/', start);
2256 if (end == std::string::npos)
2264 TObject *
o = gDirectory->Get(part.c_str());
2265 if (o && ! dynamic_cast<TDirectory *>(o))
2266 raiseDQMError(
"DQMStore",
"Attempt to create directory '%s' in a file"
2267 " fails because the part '%s' already exists and is not"
2268 " directory", path.c_str(), part.c_str());
2270 gDirectory->mkdir(part.c_str());
2272 if (! gDirectory->cd(part.c_str()))
2273 raiseDQMError(
"DQMStore",
"Attempt to create directory '%s' in a file"
2274 " fails because could not cd into subdirectory '%s'",
2275 path.c_str(), part.c_str());
2278 if (end+1 >= path.size())
2283 end = path.find(
'/', start);
2284 if (end == std::string::npos)
2300 const uint32_t
run ,
2305 std::set<std::string>::iterator di, de;
2306 MEMap::iterator mi, me =
data_.end();
2307 DQMNet::QReports::const_iterator qi, qe;
2314 class TFileNoSync :
public TFile
2317 TFileNoSync(
const char *
file,
const char *opt) : TFile(file, opt) {}
2318 virtual Int_t SysSync(Int_t)
override {
return 0; }
2323 std::cout <<
"\n DQMStore: Opening TFile '" << filename
2324 <<
"' with option '" << fileupdate <<
"'\n";
2326 TFileNoSync
f(filename.c_str(), fileupdate.c_str());
2328 raiseDQMError(
"DQMStore",
"Failed to create/update file '%s'", filename.c_str());
2332 std::auto_ptr<lat::Regexp> rxpat;
2333 if (! pattern.empty())
2334 rxpat.reset(
new lat::Regexp(pattern.c_str()));
2347 for (di =
dirs_.begin(), de =
dirs_.end(); di != de; ++di)
2358 mi =
data_.lower_bound(proto);
2359 for ( ; mi != me &&
isSubdirectory(*di, *mi->data_.dirname); ++mi)
2363 <<
" Lumi: " << (*mi).lumi()
2364 <<
" LumiFlag: " << (*mi).getLumiFlag()
2365 <<
" streamId: " << (*mi).streamId()
2366 <<
" moduleId: " << (*mi).moduleId()
2367 <<
" fullpathname: " << (*mi).getPathname() << std::endl;
2369 if (*di != *mi->data_.dirname)
2378 if (run != 0 && (mi->data_.streamId !=0 || mi->data_.moduleId !=0))
2403 for (
size_t i = 0,
e = master->data_.qreports.size();
i !=
e; ++
i)
2404 status =
std::max(status, master->data_.qreports[
i].code);
2406 if (! master || status < minStatus)
2409 std::cout <<
"DQMStore::save: skipping monitor element '"
2410 << mi->data_.objname <<
"' while saving, status is "
2411 << status <<
", required minimum status is "
2412 << minStatus << std::endl;
2419 std::cout <<
"DQMStore::save: saving monitor element '"
2420 << mi->data_.objname <<
"'\n";
2424 gDirectory->cd(
"/");
2427 else if (rxpat.get())
2438 TObjString(mi->tagString().c_str()).Write();
2442 mi->object_->Write();
2449 qi = mi->data_.qreports.begin();
2450 qe = mi->data_.qreports.end();
2451 for ( ; qi != qe; ++qi)
2452 TObjString(mi->qualityTagString(*qi).c_str()).Write();
2457 TObjString(mi->effLabelString().c_str()).Write();
2461 TObjString(mi->tagLabelString().c_str()).Write();
2469 std::cout <<
"DQMStore::save: successfully wrote " << nme
2470 <<
" objects from path '" << path
2471 <<
"' into DQM file '" << filename <<
"'\n";
2484 unsigned int ntot = 0;
2485 unsigned int count = 0;
2487 if (! file->cd(curdir.c_str()))
2488 raiseDQMError(
"DQMStore",
"Failed to process directory '%s' while"
2489 " reading file '%s'", curdir.c_str(), file->GetName());
2512 size_t slash = dirpart.find(
'/');
2513 size_t pos = dirpart.find(
"/Run summary");
2514 if (slash != std::string::npos && pos !=std::string::npos)
2516 dirpart.erase(pos,12);
2518 pos = dirpart.find(
"Run ");
2519 size_t length = dirpart.find(
'/',pos+1)-pos+1;
2520 if (pos !=std::string::npos)
2521 dirpart.erase(pos,length);
2530 size_t slash = dirpart.find(
'/');
2532 if (slash == std::string::npos
2537 slash = dirpart.find(
'/');
2539 if (slash != std::string::npos
2540 && slash + 10 == dirpart.size()
2541 && dirpart.compare( slash+1 , 9 ,
"EventInfo") == 0) {
2543 std::cout <<
"DQMStore::readDirectory: skipping '" << dirpart <<
"'\n";
2548 if (dirpart.empty())
2551 dirpart = prepend +
'/' + dirpart;
2553 else if (! prepend.empty())
2555 if (dirpart.empty())
2558 dirpart = prepend +
'/' + dirpart;
2566 TIter
next (gDirectory->GetListOfKeys());
2567 std::list<TObject *> delayed;
2568 while ((key = (TKey *)
next()))
2570 std::auto_ptr<TObject>
obj(key->ReadObj());
2571 if (dynamic_cast<TDirectory *>(
obj.get()))
2574 subdir.reserve(curdir.size() + strlen(
obj->GetName()) + 2);
2576 if (! curdir.empty())
2578 subdir +=
obj->GetName();
2580 ntot +=
readDirectory(file, overwrite, onlypath, prepend, subdir, stripdirs);
2584 else if (dynamic_cast<TObjString *>(
obj.get()))
2586 delayed.push_back(
obj.release());
2591 std::cout <<
"DQMStore: reading object '" <<
obj->GetName()
2592 <<
"' of type '" <<
obj->IsA()->GetName()
2593 <<
"' from '" << file->GetName()
2594 <<
"' into '" << dirpart <<
"'\n";
2602 while (! delayed.empty())
2605 std::cout <<
"DQMStore: reading object '" << delayed.front()->GetName()
2606 <<
"' of type '" << delayed.front()->IsA()->GetName()
2607 <<
"' from '" << file->GetName()
2608 <<
"' into '" << dirpart <<
"'\n";
2611 if (
extract(delayed.front(), dirpart, overwrite))
2614 delete delayed.front();
2615 delayed.pop_front();
2619 std::cout <<
"DQMStore: read " << count <<
'/' << ntot
2620 <<
" objects from directory '" << dirpart <<
"'\n";
2622 return ntot +
count;
2637 bool fileMustExist )
2639 return readFile(filename,overwrite,onlypath,prepend,stripdirs,fileMustExist);
2649 bool fileMustExist )
2651 bool overwrite =
true;
2655 std::cout <<
"DQMStore::load: reading from file '" << filename <<
"'\n";
2657 std::cout <<
"DQMStore::load: in collate mode " <<
"\n";
2659 std::cout <<
"DQMStore::load: in overwrite mode " <<
"\n";
2662 return readFile(filename,overwrite,
"",
"",stripdirs,fileMustExist);
2677 bool fileMustExist )
2681 std::cout <<
"DQMStore::readFile: reading from file '" << filename <<
"'\n";
2683 std::auto_ptr<TFile>
f;
2687 f.reset(TFile::Open(filename.c_str()));
2688 if (! f.get() || f->IsZombie())
2689 raiseDQMError(
"DQMStore",
"Failed to open file '%s'", filename.c_str());
2698 std::cout <<
"DQMStore::readFile: file '" << filename <<
"' does not exist, continuing\n";
2703 unsigned n =
readDirectory(f.get(), overwrite, onlypath, prepend,
"", stripdirs);
2706 MEMap::iterator mi =
data_.begin();
2707 MEMap::iterator me =
data_.end();
2708 for ( ; mi != me; ++mi)
2709 const_cast<MonitorElement &>(*mi).updateQReportStats();
2713 std::cout <<
"DQMStore::open: successfully read " << n
2714 <<
" objects from file '" << filename <<
"'";
2715 if (! onlypath.empty())
2716 std::cout <<
" from directory '" << onlypath <<
"'";
2717 if (! prepend.empty())
2718 std::cout <<
" into directory '" << prepend <<
"'";
2737 MEMap::iterator
e =
data_.end();
2738 MEMap::iterator
i =
data_.lower_bound(proto);
2742 std::set<std::string>::iterator de =
dirs_.end();
2743 std::set<std::string>::iterator di =
dirs_.lower_bound(*cleaned);
2753 MEMap::iterator
e =
data_.end();
2754 MEMap::iterator
i =
data_.lower_bound(proto);
2756 if (dir == *i->data_.dirname)
2783 MEMap::iterator pos =
data_.find(proto);
2785 std::cout <<
"DQMStore: WARNING: attempt to remove non-existent"
2786 <<
" monitor element '" << name <<
"' in '" << dir <<
"'\n";
2799 QCMap::const_iterator
i =
qtests_.find(qtname);
2800 QCMap::const_iterator
e =
qtests_.end();
2801 return (i == e ? 0 : i->second);
2811 raiseDQMError(
"DQMStore",
"Attempt to create duplicate quality test '%s'",
2814 QAMap::iterator
i =
qalgos_.find(algoname);
2816 raiseDQMError(
"DQMStore",
"Cannot create a quality test using unknown"
2817 " algorithm '%s'", algoname.c_str());
2837 if (cleaned->find_first_not_of(
s_safe) != std::string::npos)
2839 " uses unacceptable characters", cleaned->c_str());
2851 raiseDQMError(
"DQMStore",
"Cannot apply non-existent quality test '%s'",
2861 MEMap::iterator mi =
data_.begin();
2862 MEMap::iterator me =
data_.end();
2865 for ( ; mi != me; ++mi)
2868 mergePath(path, *mi->data_.dirname, mi->data_.objname);
2869 if (fm->match(path))
2886 std::cout <<
"DQMStore: running runQTests() with reset = "
2887 << (
reset_ ?
"true" :
"false" ) << std::endl;
2890 MEMap::iterator mi =
data_.begin();
2891 MEMap::iterator me =
data_.end();
2892 for ( ; mi != me; ++mi)
2910 MEMap::const_iterator mi =
data_.begin();
2911 MEMap::const_iterator me =
data_.end();
2912 for ( ; mi != me; ++mi)
2914 if (! cleaned->empty() && !
isSubdirectory(*cleaned, *mi->data_.dirname))
2919 else if (mi->hasWarning())
2922 && mi->hasOtherReport())
2966 std::cout <<
" ------------------------------------------------------------\n"
2967 <<
" Directory structure: \n"
2968 <<
" ------------------------------------------------------------\n";
2970 std::copy(contents.begin(), contents.end(),
2971 std::ostream_iterator<std::string>(
std::cout,
"\n"));
2973 std::cout <<
" ------------------------------------------------------------\n";
3010 MonitorElement * event_me =
get(
"Info/EventInfo/processedEvents");
3013 factor = factor/(events*1.0);
3015 MEMap::iterator mi =
data_.begin();
3016 MEMap::iterator me =
data_.end();
3017 for ( ; mi != me; ++mi)
3069 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
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
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
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)
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
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 setLumi(uint32_t ls)
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 const std::string s_safe
static void splitPath(std::string &dir, std::string &name, const std::string &path)
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)
static const std::string s_collateDirName
MonitorElement * book(const std::string &dir, const std::string &name, const char *context)
static const std::string s_monitorDirName
name of global monitoring folder (containing all sources subdirectories)
MonitorElement * bookFloat(const char *name)
Book float.
static std::string const input
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)
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
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 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
void tag(MonitorElement *, unsigned int)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
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
std::string readSelectedDirectory_
void mergeAndResetMEsRunSummaryCache(uint32_t run, uint32_t streamId, uint32_t moduleId)
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)
void setCurrentFolder(const std::string &fullpath)
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)
static const std::string s_referenceDirName
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)
void Reset(std::vector< TH2F > &depth)
QCriterion * createQTest(const std::string &algoname, const std::string &qtname)
volatile std::atomic< bool > shutdown_flag false
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.
void mergeAndResetMEsLuminositySummaryCache(uint32_t run, uint32_t lumi, uint32_t streamId, uint32_t moduleId)
std::set< std::string > dirs_
void Reset(void)
reset ME (ie. contents, errors, etc)
static std::string const source
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,...)