File indexing completed on 2022-12-13 23:50:05
0001
0002 #define DQM_DEPRECATED
0003 #include "DQMServices/Core/interface/DQMStore.h"
0004 #include "DQMServices/Core/interface/LegacyIOHelper.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ServiceRegistry/interface/GlobalContext.h"
0007 #include <string>
0008 #include <regex>
0009 #include <csignal>
0010
0011 #include <execinfo.h>
0012 #include <cxxabi.h>
0013
0014 namespace dqm::implementation {
0015
0016
0017
0018 static const std::string s_safe = "/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_()# ";
0019
0020 std::string NavigatorBase::pwd() {
0021 if (cwd_.empty()) {
0022 return "";
0023 } else {
0024
0025
0026
0027
0028 assert(cwd_[cwd_.size() - 1] == '/');
0029 auto pwd = cwd_.substr(0, cwd_.size() - 1);
0030 return pwd;
0031 }
0032 }
0033 void NavigatorBase::cd() { setCurrentFolder(""); }
0034 void NavigatorBase::cd(std::string const& dir) { setCurrentFolder(dir); }
0035 void NavigatorBase::goUp() { cd(cwd_ + ".."); }
0036 void NavigatorBase::setCurrentFolder(std::string const& fullpath) {
0037 MonitorElementData::Path path;
0038 path.set(fullpath, MonitorElementData::Path::Type::DIR);
0039 assert(this);
0040 cwd_ = path.getDirname();
0041 }
0042
0043 IBooker::IBooker(DQMStore* store) {
0044 store_ = store;
0045 scope_ = MonitorElementData::Scope::JOB;
0046 }
0047
0048 IBooker::~IBooker() {}
0049
0050 MonitorElementData::Scope IBooker::setScope(MonitorElementData::Scope newscope) {
0051 auto oldscope = scope_;
0052 scope_ = newscope;
0053 return oldscope;
0054 }
0055 uint64_t IBooker::setModuleID(uint64_t moduleID) {
0056 auto oldid = moduleID_;
0057 moduleID_ = moduleID;
0058 return oldid;
0059 }
0060
0061 edm::LuminosityBlockID IBooker::setRunLumi(edm::LuminosityBlockID runlumi) {
0062 auto oldrunlumi = runlumi_;
0063 runlumi_ = runlumi;
0064 return oldrunlumi;
0065 }
0066
0067 MonitorElement* IBooker::bookME(TString const& name,
0068 MonitorElementData::Kind kind,
0069 std::function<TH1*()> makeobject,
0070 bool forceReplace ) {
0071 MonitorElementData::Path path;
0072 std::string fullpath = cwd_ + std::string(name.View());
0073
0074 auto pathToCheck{fullpath};
0075 std::string limiter{".root:/"};
0076 size_t pos = pathToCheck.find(limiter);
0077
0078 pathToCheck.erase(0, pos + limiter.size());
0079
0080 if (pathToCheck.find_first_not_of(s_safe) != std::string::npos) {
0081 throw cms::Exception("BadMonitorElementPathName")
0082 << " Monitor element path name: '" << pathToCheck.c_str() << "' uses unacceptable characters."
0083 << "\n Acceptable characters are: " << s_safe.c_str();
0084 }
0085
0086 path.set(fullpath, MonitorElementData::Path::Type::DIR_AND_NAME);
0087
0088
0089
0090
0091 MonitorElement* me = store_->findME(path);
0092 store_->printTrace("Booking " + std::string(name) + (me ? " (existing)" : " (new)"));
0093
0094 if (me == nullptr) {
0095
0096
0097
0098 TH1* th1 = makeobject();
0099 MonitorElementData medata;
0100 medata.key_.path_ = path;
0101 medata.key_.kind_ = kind;
0102 medata.key_.scope_ = this->scope_;
0103
0104
0105
0106 if (this->scope_ == MonitorElementData::Scope::JOB) {
0107 medata.key_.id_ = edm::LuminosityBlockID();
0108 } else if (this->scope_ == MonitorElementData::Scope::RUN) {
0109 medata.key_.id_ = edm::LuminosityBlockID(this->runlumi_.run(), 0);
0110 } else if (this->scope_ == MonitorElementData::Scope::LUMI) {
0111
0112
0113
0114 if (this->runlumi_.run() != 0 && this->runlumi_.luminosityBlock() != 0) {
0115 medata.key_.id_ = this->runlumi_;
0116 } else {
0117 medata.key_.id_ = edm::LuminosityBlockID();
0118 }
0119 } else {
0120 assert(!"Illegal scope");
0121 }
0122
0123 medata.value_.object_ = std::unique_ptr<TH1>(th1);
0124 MonitorElement* me_ptr = new MonitorElement(std::move(medata));
0125 me = store_->putME(me_ptr);
0126 } else {
0127 if (forceReplace) {
0128 TH1* th1 = makeobject();
0129 assert(th1);
0130 store_->debugTrackME("bookME (forceReplace)", nullptr, me);
0131
0132 me->switchObject(std::unique_ptr<TH1>(th1));
0133 }
0134 }
0135
0136
0137 assert(me);
0138
0139
0140
0141
0142
0143
0144 auto localme = store_->putME(me, this->moduleID_);
0145
0146 assert(localme);
0147
0148 if (this->moduleID_ == 0) {
0149
0150
0151
0152
0153
0154
0155
0156 store_->debugTrackME("bookME (legacy)", localme, me);
0157 return me;
0158 } else {
0159
0160 store_->debugTrackME("bookME (normal)", localme, me);
0161 return localme;
0162 }
0163 }
0164
0165 MonitorElement* DQMStore::putME(MonitorElement* me) {
0166 auto lock = std::scoped_lock(this->booking_mutex_);
0167 assert(me);
0168 auto existing_new = globalMEs_[me->getRunLumi()].insert(me);
0169 if (existing_new.second == true) {
0170
0171 debugTrackME("putME (global)", nullptr, me);
0172 return me;
0173 } else {
0174
0175 delete me;
0176 assert(!"Currently, this should never happen.");
0177 return *(existing_new.first);
0178 }
0179 }
0180
0181 MonitorElement* DQMStore::putME(MonitorElement* me, uint64_t moduleID) {
0182 auto lock = std::scoped_lock(this->booking_mutex_);
0183 assert(me);
0184 auto& localmes = localMEs_[moduleID];
0185 auto existing = localmes.find(me);
0186 if (existing == localmes.end()) {
0187
0188 MonitorElement* local_me = new MonitorElement(me);
0189 auto existing_new = localmes.insert(local_me);
0190
0191 assert(existing_new.second == true);
0192 debugTrackME("putME (local, new)", local_me, me);
0193 return local_me;
0194 } else {
0195
0196 auto local_me = *existing;
0197 edm::LogInfo("DQMStore") << "ME " << me->getFullname() << " booked twice in the same module.";
0198
0199
0200
0201
0202
0203
0204 if (!local_me->isValid()) {
0205 local_me->switchData(me);
0206 }
0207 debugTrackME("putME (local, existing)", local_me, me);
0208 return local_me;
0209 }
0210 }
0211
0212 template <typename MELIKE>
0213 MonitorElement* DQMStore::findME(MELIKE const& path) {
0214 auto lock = std::scoped_lock(this->booking_mutex_);
0215 for (auto& [runlumi, meset] : this->globalMEs_) {
0216 auto it = meset.find(path);
0217 if (it != meset.end()) {
0218 debugTrackME("findME (found)", nullptr, *it);
0219
0220
0221 return *it;
0222 }
0223 }
0224 return nullptr;
0225 }
0226
0227 void DQMStore::printTrace(std::string const& message) {
0228 if (verbose_ < 3)
0229 return;
0230 edm::LogWarning("DQMStoreBooking").log([&](auto& logger) {
0231 std::regex s_rxtrace{"(.*)\\((.*)\\+0x.*\\).*(\\[.*\\])"};
0232 std::regex s_rxself{"^[^()]*dqm::implementation::.*|^[^()]*edm::.*|.*edm::convertException::wrap.*"};
0233
0234 void* array[10];
0235 size_t size;
0236 char** strings;
0237 int demangle_status = 0;
0238 std::vector<std::string> clean_trace;
0239
0240
0241 size = backtrace(array, 10);
0242 strings = backtrace_symbols(array, size);
0243
0244 size_t level = 1;
0245 char* demangled = nullptr;
0246 for (; level < size; ++level) {
0247 std::cmatch match;
0248 bool ok = std::regex_match(strings[level], match, s_rxtrace);
0249
0250 if (!ok) {
0251 edm::LogWarning("DQMStoreBacktrace") << "failed match" << level << strings[level];
0252 continue;
0253 }
0254
0255 if (match[2].length() == 0) {
0256
0257 continue;
0258 }
0259
0260
0261 demangled = abi::__cxa_demangle(std::string(match[2]).c_str(), nullptr, nullptr, &demangle_status);
0262 if (!demangled || demangle_status != 0) {
0263 edm::LogWarning("DQMStoreBacktrace") << "failed demangle! status " << demangle_status << " on " << match[2];
0264 continue;
0265 }
0266
0267 if (std::regex_match(demangled, s_rxself)) {
0268
0269 free(demangled);
0270 demangled = nullptr;
0271 continue;
0272 } else {
0273
0274
0275
0276
0277 clean_trace.push_back(std::string(demangled) + std::string(match[3]));
0278 free(demangled);
0279 demangled = nullptr;
0280 }
0281 }
0282
0283 if (!clean_trace.empty()) {
0284 logger << message << " at ";
0285 for (auto const& s : clean_trace) {
0286 logger << s << "; ";
0287 }
0288 } else {
0289 logger << message << " : failed to collect stack trace.";
0290 }
0291
0292 free(strings);
0293 });
0294 }
0295
0296 void DQMStore::debugTrackME(const char* message, MonitorElement* me_local, MonitorElement* me_global) const {
0297 const char* scopename[] = {"INVALID", "JOB", "RUN", "LUMI"};
0298 if (!this->trackME_.empty() && (me_local || me_global)) {
0299 std::string name = me_global ? me_global->getFullname() : me_local->getFullname();
0300 if (name.find(this->trackME_) != std::string::npos) {
0301 edm::LogWarning("DQMStoreTrackME").log([&](auto& logger) {
0302 logger << message << " for " << name << "(" << me_local << "," << me_global << ")";
0303 auto writeme = [&](MonitorElement* me) {
0304 if (me->isValid()) {
0305 logger << " " << me->getRunLumi() << " scope " << scopename[me->getScope()];
0306 if (me->kind() >= MonitorElement::Kind::TH1F) {
0307 logger << " entries " << me->getEntries();
0308 } else if (me->kind() == MonitorElement::Kind::STRING) {
0309 logger << " value " << me->getStringValue();
0310 } else if (me->kind() == MonitorElement::Kind::REAL) {
0311 logger << " value " << me->getFloatValue();
0312 } else if (me->kind() == MonitorElement::Kind::INT) {
0313 logger << " value " << me->getIntValue();
0314 }
0315 } else {
0316 logger << " (invalid)";
0317 }
0318 };
0319 if (me_local) {
0320 logger << " local:";
0321 writeme(me_local);
0322 }
0323 if (me_global) {
0324 logger << " global:";
0325 writeme(me_global);
0326 }
0327 });
0328
0329
0330 }
0331 }
0332 }
0333
0334 MonitorElement* DQMStore::findOrRecycle(MonitorElementData::Key const& key) {
0335
0336
0337
0338
0339
0340 auto lock = std::scoped_lock(this->booking_mutex_);
0341 auto existing = this->get(key);
0342 if (existing) {
0343
0344 debugTrackME("findOrRecycle (found)", nullptr, existing);
0345 return existing;
0346 }
0347
0348
0349 auto& targetset = this->globalMEs_[key.id_];
0350
0351 auto& prototypes = this->globalMEs_[edm::LuminosityBlockID()];
0352
0353 auto proto = prototypes.find(key.path_);
0354 if (proto != prototypes.end()) {
0355 MonitorElement* oldme = *proto;
0356 assert(oldme->getScope() == key.scope_);
0357 prototypes.erase(proto);
0358 auto medata = oldme->release();
0359
0360 medata->data_.key_.id_ = key.id_;
0361
0362
0363
0364 oldme->switchData(medata);
0365 auto result = targetset.insert(oldme);
0366 assert(result.second);
0367 auto newme = *result.first;
0368 assert(oldme == newme);
0369
0370 debugTrackME("findOrRecycle (recycled)", nullptr, newme);
0371 return newme;
0372 }
0373
0374 return nullptr;
0375 }
0376
0377 void DQMStore::initLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi) {
0378
0379 auto lock = std::scoped_lock(this->booking_mutex_);
0380 for (auto& kv : this->localMEs_) {
0381 initLumi(run, lumi, kv.first);
0382 }
0383 }
0384
0385 void DQMStore::initLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID) {
0386
0387
0388 auto lock = std::scoped_lock(this->booking_mutex_);
0389
0390
0391 auto& localset = this->localMEs_[moduleID];
0392
0393
0394 auto& targetset = this->globalMEs_[edm::LuminosityBlockID(run, lumi)];
0395
0396 auto& prototypes = this->globalMEs_[edm::LuminosityBlockID()];
0397
0398 auto checkScope = [run, lumi](MonitorElementData::Scope scope) {
0399 if (scope == MonitorElementData::Scope::JOB) {
0400 return (run == 0 && lumi == 0);
0401 } else if (scope == MonitorElementData::Scope::RUN) {
0402 return (run != 0 && lumi == 0);
0403 } else if (scope == MonitorElementData::Scope::LUMI) {
0404 return (lumi != 0);
0405 }
0406 assert(!"Impossible Scope.");
0407 return false;
0408 };
0409
0410 for (MonitorElement* me : localset) {
0411 auto target = targetset.find(me);
0412 if (target != targetset.end()) {
0413
0414 debugTrackME("initLumi (existing)", nullptr, *target);
0415 } else {
0416
0417 auto proto = prototypes.find(me);
0418 if (proto != prototypes.end()) {
0419
0420
0421
0422 if (checkScope((*proto)->getScope()) == false) {
0423 continue;
0424 }
0425
0426 MonitorElement* oldme = *proto;
0427 prototypes.erase(proto);
0428 auto medata = oldme->release();
0429
0430 medata->data_.key_.id_ = edm::LuminosityBlockID(run, lumi);
0431
0432
0433
0434 oldme->switchData(medata);
0435 auto result = targetset.insert(oldme);
0436 assert(result.second);
0437 target = result.first;
0438 debugTrackME("initLumi (reused)", nullptr, *target);
0439 } else {
0440
0441
0442 auto anyme = this->findME(me);
0443 assert(anyme || !"local ME without any global ME!");
0444 if (checkScope(anyme->getScope()) == false) {
0445 continue;
0446 }
0447
0448
0449
0450 assert(!assertLegacySafe_);
0451
0452 MonitorElementData newdata = anyme->cloneMEData();
0453 newdata.key_.id_ = edm::LuminosityBlockID(run, lumi);
0454 auto newme = new MonitorElement(std::move(newdata));
0455 newme->Reset();
0456 auto result = targetset.insert(newme);
0457 assert(result.second);
0458 target = result.first;
0459 debugTrackME("initLumi (allocated)", nullptr, *target);
0460 }
0461 }
0462 }
0463 }
0464
0465 void DQMStore::enterLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID) {
0466
0467
0468
0469
0470
0471
0472 auto lock = std::scoped_lock(this->booking_mutex_);
0473
0474
0475 auto& localset = this->localMEs_[moduleID];
0476
0477 auto& targetset = this->globalMEs_[edm::LuminosityBlockID(run, lumi)];
0478
0479
0480 auto checkScope = [run, lumi](MonitorElementData::Scope scope) {
0481 if (scope == MonitorElementData::Scope::JOB) {
0482 return (run == 0 && lumi == 0);
0483 } else if (scope == MonitorElementData::Scope::RUN) {
0484 return (run != 0 && lumi == 0);
0485 } else if (scope == MonitorElementData::Scope::LUMI) {
0486 return (lumi != 0);
0487 }
0488 assert(!"Impossible Scope.");
0489 return false;
0490 };
0491
0492 for (MonitorElement* me : localset) {
0493 auto target = targetset.find(me);
0494 if (target == targetset.end()) {
0495 auto anyme = this->findME(me);
0496 debugTrackME("enterLumi (nothingtodo)", me, nullptr);
0497 assert(anyme && checkScope(anyme->getScope()) == false);
0498 continue;
0499 }
0500 assert(target != targetset.end());
0501
0502
0503
0504 me->switchData(*target);
0505 debugTrackME("enterLumi (switchdata)", me, *target);
0506 }
0507 }
0508
0509 void DQMStore::leaveLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID) {
0510
0511
0512
0513
0514
0515
0516 auto lock = std::scoped_lock(this->booking_mutex_);
0517
0518
0519 auto& localset = this->localMEs_[moduleID];
0520
0521 auto checkScope = [run, lumi](MonitorElementData::Scope scope) {
0522 if (scope == MonitorElementData::Scope::JOB) {
0523 return (run == 0 && lumi == 0);
0524 } else if (scope == MonitorElementData::Scope::RUN) {
0525 return (run != 0 && lumi == 0);
0526 } else if (scope == MonitorElementData::Scope::LUMI) {
0527 return (lumi != 0);
0528 }
0529 assert(!"Impossible Scope.");
0530 return false;
0531 };
0532
0533 for (MonitorElement* me : localset) {
0534
0535 if (me->isValid() && checkScope(me->getScope()) == true) {
0536
0537 debugTrackME("leaveLumi (release)", me, nullptr);
0538 me->release();
0539 }
0540 }
0541 }
0542
0543 void DQMStore::cleanupLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi) {
0544
0545
0546
0547
0548 auto lock = std::scoped_lock(this->booking_mutex_);
0549
0550
0551
0552 assert(run != 0 || lumi != 0);
0553 auto& prototypes = this->globalMEs_[edm::LuminosityBlockID()];
0554
0555
0556 auto meset = std::set<MonitorElement*, MonitorElement::MEComparison>();
0557
0558 meset.swap(this->globalMEs_[edm::LuminosityBlockID(run, lumi)]);
0559
0560
0561
0562 auto torecycle = std::vector<MonitorElement*>();
0563
0564
0565 auto checkScope = [run, lumi](MonitorElementData::Scope scope) {
0566 if (scope == MonitorElementData::Scope::JOB) {
0567 assert(run == 0 && lumi == 0);
0568 } else if (scope == MonitorElementData::Scope::RUN) {
0569 assert(run != 0 && lumi == 0);
0570 } else if (scope == MonitorElementData::Scope::LUMI) {
0571 assert(lumi != 0);
0572 } else {
0573 assert(!"Impossible Scope.");
0574 }
0575 };
0576
0577 for (MonitorElement* me : meset) {
0578 assert(me->isValid());
0579 checkScope(me->getScope());
0580 auto other = this->findME(me);
0581 if (other) {
0582
0583 debugTrackME("cleanupLumi (delete)", nullptr, me);
0584 delete me;
0585 } else {
0586
0587
0588 debugTrackME("cleanupLumi (recycle)", nullptr, me);
0589 torecycle.push_back(me);
0590 }
0591 }
0592
0593 meset.clear();
0594
0595 for (MonitorElement* me : torecycle) {
0596 auto medata = me->release();
0597 medata->data_.key_.id_ = edm::LuminosityBlockID();
0598
0599
0600
0601 me->switchData(medata);
0602
0603 me->Reset();
0604 auto result = prototypes.insert(me);
0605 assert(result.second);
0606 debugTrackME("cleanupLumi (reset)", nullptr, me);
0607 }
0608 }
0609
0610 std::vector<dqm::harvesting::MonitorElement*> IGetter::getContents(std::string const& pathname) const {
0611 auto lock = std::scoped_lock(store_->booking_mutex_);
0612 std::vector<MonitorElement*> out;
0613 MonitorElementData::Path path;
0614 path.set(pathname, MonitorElementData::Path::Type::DIR);
0615 for (auto& [runlumi, meset] : store_->globalMEs_) {
0616 auto it = meset.lower_bound(path);
0617 while (it != meset.end() && (*it)->getPathname() == path.getDirname()) {
0618 store_->debugTrackME("getContents (match)", nullptr, *it);
0619 out.push_back(*it);
0620 ++it;
0621 }
0622 }
0623 return out;
0624 }
0625
0626 std::vector<dqm::harvesting::MonitorElement*> IGetter::getAllContents(std::string const& pathname) const {
0627 auto lock = std::scoped_lock(store_->booking_mutex_);
0628 std::vector<MonitorElement*> out;
0629 MonitorElementData::Path path;
0630 path.set(pathname, MonitorElementData::Path::Type::DIR);
0631
0632 auto path_str = path.getFullname();
0633 for (auto& [runlumi, meset] : store_->globalMEs_) {
0634 auto it = meset.lower_bound(path);
0635
0636 while (it != meset.end() && (*it)->getPathname().rfind(path_str, 0) == 0) {
0637 if (runlumi == edm::LuminosityBlockID() && (*it)->getScope() != MonitorElementData::Scope::JOB) {
0638
0639 } else {
0640 store_->debugTrackME("getAllContents (match)", nullptr, *it);
0641 out.push_back(*it);
0642 }
0643 ++it;
0644 }
0645 }
0646 return out;
0647 }
0648 std::vector<dqm::harvesting::MonitorElement*> IGetter::getAllContents(std::string const& pathname,
0649 uint32_t runNumber,
0650 uint32_t lumi) const {
0651 auto lock = std::scoped_lock(store_->booking_mutex_);
0652 std::vector<MonitorElement*> out;
0653 MonitorElementData::Path path;
0654 path.set(pathname, MonitorElementData::Path::Type::DIR);
0655
0656 auto path_str = path.getFullname();
0657 auto const& meset = store_->globalMEs_[edm::LuminosityBlockID(runNumber, lumi)];
0658 auto it = meset.lower_bound(path);
0659
0660
0661
0662
0663 while (it != meset.end() && (*it)->getFullname().rfind(path_str, 0) == 0) {
0664 bool saveIt = true;
0665
0666 if (store_->doSaveByLumi_ && not store_->MEsToSave_.empty()) {
0667 std::string name = (*it)->getFullname();
0668 saveIt = false;
0669 for (std::vector<std::string>::const_iterator ipath = store_->MEsToSave_.begin();
0670 ipath != store_->MEsToSave_.end();
0671 ++ipath) {
0672 std::string nameToSave = *ipath;
0673
0674
0675
0676
0677
0678 if (name == nameToSave) {
0679 saveIt = true;
0680
0681 break;
0682 }
0683 }
0684 }
0685
0686 store_->debugTrackME("getAllContents (run/lumi match)", nullptr, *it);
0687 if (saveIt) {
0688 out.push_back(*it);
0689 if (store_->doSaveByLumi_)
0690 store_->debugTrackME("getAllContents (run/lumi saved)", nullptr, *it);
0691 }
0692 ++it;
0693 }
0694 return out;
0695 }
0696
0697 MonitorElement* IGetter::get(std::string const& fullpath) const {
0698 MonitorElementData::Path path;
0699 path.set(fullpath, MonitorElementData::Path::Type::DIR_AND_NAME);
0700
0701
0702 return store_->findME(path);
0703 }
0704
0705 MonitorElement* IGetter::get(MonitorElementData::Key const& key) const {
0706 auto const& meset = store_->globalMEs_[key.id_];
0707 auto it = meset.find(key.path_);
0708 if (it != meset.end()) {
0709 assert((*it)->getScope() == key.scope_);
0710 store_->debugTrackME("get (key found)", nullptr, *it);
0711 return *it;
0712 }
0713 return nullptr;
0714 }
0715
0716 MonitorElement* IGetter::getElement(std::string const& path) const {
0717 auto result = this->get(path);
0718 if (result == nullptr) {
0719 throw cms::Exception("iGetter Error") << "ME " << path << " was requested but not found.";
0720 }
0721 return result;
0722 }
0723
0724 std::vector<std::string> IGetter::getSubdirs() const {
0725
0726
0727
0728 std::set<std::string> subdirs;
0729 for (auto me : this->getAllContents(this->cwd_)) {
0730 const auto& name = me->getPathname();
0731 auto subdirname = name.substr(this->cwd_.length(), std::string::npos);
0732 auto dirname = subdirname.substr(0, subdirname.find('/'));
0733 subdirs.insert(dirname);
0734 }
0735 std::vector<std::string> out;
0736 for (const auto& dir : subdirs) {
0737 if (dir.length() == 0)
0738 continue;
0739 out.push_back(this->cwd_ + dir);
0740 }
0741 return out;
0742 }
0743
0744 std::vector<std::string> IGetter::getMEs() const {
0745 auto mes = this->getContents(this->cwd_);
0746 std::vector<std::string> out;
0747 out.reserve(mes.size());
0748 for (auto me : mes) {
0749 out.push_back(me->getName());
0750 }
0751 return out;
0752 }
0753
0754 bool IGetter::dirExists(std::string const& path) const {
0755
0756 return !this->getAllContents(path).empty();
0757 }
0758
0759 IGetter::IGetter(DQMStore* store) { store_ = store; }
0760
0761 IGetter::~IGetter() {}
0762
0763 DQMStore::DQMStore(edm::ParameterSet const& pset, edm::ActivityRegistry& ar) : IGetter(this), IBooker(this) {
0764 verbose_ = pset.getUntrackedParameter<int>("verbose", 0);
0765 assertLegacySafe_ = pset.getUntrackedParameter<bool>("assertLegacySafe", false);
0766 doSaveByLumi_ = pset.getUntrackedParameter<bool>("saveByLumi", false);
0767 MEsToSave_ = pset.getUntrackedParameter<std::vector<std::string>>("MEsToSave", std::vector<std::string>());
0768 trackME_ = pset.getUntrackedParameter<std::string>("trackME", "");
0769
0770
0771
0772
0773
0774
0775
0776
0777 ar.watchPreGlobalBeginRun([this](edm::GlobalContext const& gc) {
0778 this->setRunLumi(gc.luminosityBlockID());
0779 this->initLumi(gc.luminosityBlockID().run(), 0);
0780 this->enterLumi(gc.luminosityBlockID().run(), 0, 0);
0781 this->setScope(MonitorElementData::Scope::JOB);
0782 });
0783 ar.watchPreGlobalBeginLumi([this](edm::GlobalContext const& gc) {
0784 this->setRunLumi(gc.luminosityBlockID());
0785 this->initLumi(gc.luminosityBlockID().run(), gc.luminosityBlockID().luminosityBlock());
0786 this->enterLumi(gc.luminosityBlockID().run(), gc.luminosityBlockID().luminosityBlock(), 0);
0787 });
0788 ar.watchPostGlobalEndRun([this](edm::GlobalContext const& gc) {
0789 this->leaveLumi(gc.luminosityBlockID().run(), 0, 0);
0790 });
0791 ar.watchPostGlobalEndLumi([this](edm::GlobalContext const& gc) {
0792 this->leaveLumi(gc.luminosityBlockID().run(), gc.luminosityBlockID().luminosityBlock(), 0);
0793 });
0794
0795
0796
0797 ar.watchPostGlobalWriteLumi([this](edm::GlobalContext const& gc) {
0798 this->cleanupLumi(gc.luminosityBlockID().run(), gc.luminosityBlockID().luminosityBlock());
0799 });
0800 ar.watchPostGlobalWriteRun(
0801 [this](edm::GlobalContext const& gc) { this->cleanupLumi(gc.luminosityBlockID().run(), 0); });
0802
0803
0804 }
0805
0806 DQMStore::~DQMStore() {}
0807
0808 void DQMStore::save(std::string const& filename, std::string const& path) {
0809 LegacyIOHelper h(this);
0810
0811 h.save(filename, path);
0812 }
0813
0814 bool DQMStore::open(std::string const& filename,
0815 bool overwrite,
0816 std::string const& path,
0817 std::string const& prepend,
0818 OpenRunDirs stripdirs,
0819 bool fileMustExist) {
0820 assert(!"NIY");
0821 }
0822
0823 }