14 namespace dqm::implementation {
41 scope_ = MonitorElementData::Scope::JOB;
81 TH1* th1 = makeobject();
89 if (this->
scope_ == MonitorElementData::Scope::JOB) {
91 }
else if (this->
scope_ == MonitorElementData::Scope::RUN) {
93 }
else if (this->
scope_ == MonitorElementData::Scope::LUMI) {
111 TH1* th1 = makeobject();
115 me->switchObject(std::unique_ptr<TH1>(th1));
152 if (existing_new.second ==
true) {
159 assert(!
"Currently, this should never happen.");
160 return *(existing_new.first);
172 auto existing_new = localmes.insert(local_me);
174 assert(existing_new.second ==
true);
187 if (!local_me->isValid()) {
188 local_me->switchData(me);
195 template <
typename MELIKE>
198 for (
auto& [runlumi, meset] : this->
globalMEs_) {
199 auto it = meset.find(path);
200 if (it != meset.end()) {
214 std::regex s_rxtrace{
"(.*)\\((.*)\\+0x.*\\).*(\\[.*\\])"};
215 std::regex s_rxself{
"^[^()]*dqm::implementation::.*|^[^()]*edm::.*|.*edm::convertException::wrap.*"};
220 int demangle_status = 0;
221 std::vector<std::string> clean_trace;
224 size = backtrace(array, 10);
225 strings = backtrace_symbols(array, size);
231 bool ok = std::regex_match(strings[level], match, s_rxtrace);
238 if (match[2].length() == 0) {
244 demangled = abi::__cxa_demangle(
std::string(match[2]).c_str(),
nullptr,
nullptr, &demangle_status);
245 if (!demangled || demangle_status != 0) {
246 edm::LogWarning(
"DQMStoreBacktrace") <<
"failed demangle! status " << demangle_status <<
" on " << match[2];
250 if (std::regex_match(demangled, s_rxself)) {
266 if (!clean_trace.empty()) {
267 logger << message <<
" at ";
268 for (
auto const&
s : clean_trace) {
272 logger << message <<
" : failed to collect stack trace.";
280 const char* scopename[] = {
"INVALID",
"JOB",
"RUN",
"LUMI"};
281 if (!this->
trackME_.empty() && (me_local || me_global)) {
283 if (name.find(this->trackME_) != std::string::npos) {
285 logger << message <<
" for " << name <<
"(" << me_local <<
"," << me_global <<
")";
288 logger <<
" " <<
me->getRunLumi() <<
" scope " << scopename[
me->getScope()];
290 logger <<
" entries " <<
me->getEntries();
292 logger <<
" value " <<
me->getStringValue();
294 logger <<
" value " <<
me->getFloatValue();
296 logger <<
" value " <<
me->getIntValue();
336 auto proto = prototypes.find(key.
path_);
337 if (proto != prototypes.end()) {
340 prototypes.erase(proto);
341 auto medata = oldme->release();
343 medata->data_.key_.id_ = key.
id_;
347 oldme->switchData(medata);
348 auto result = targetset.insert(oldme);
350 auto newme = *
result.first;
353 debugTrackME(
"findOrRecycle (recycled)",
nullptr, newme);
374 auto& localset = this->
localMEs_[moduleID];
382 if (scope == MonitorElementData::Scope::JOB) {
383 return (run == 0 && lumi == 0);
384 }
else if (scope == MonitorElementData::Scope::RUN) {
385 return (run != 0 && lumi == 0);
386 }
else if (scope == MonitorElementData::Scope::LUMI) {
389 assert(!
"Impossible Scope.");
395 if (
target != targetset.end()) {
400 auto proto = prototypes.find(
me);
401 if (proto != prototypes.end()) {
405 if (checkScope((*proto)->getScope()) ==
false) {
410 prototypes.erase(proto);
411 auto medata = oldme->release();
417 oldme->switchData(medata);
418 auto result = targetset.insert(oldme);
426 assert(anyme || !
"local ME without any global ME!");
427 if (checkScope(anyme->getScope()) ==
false) {
439 auto result = targetset.insert(newme);
458 auto& localset = this->
localMEs_[moduleID];
464 if (scope == MonitorElementData::Scope::JOB) {
465 return (run == 0 && lumi == 0);
466 }
else if (scope == MonitorElementData::Scope::RUN) {
467 return (run != 0 && lumi == 0);
468 }
else if (scope == MonitorElementData::Scope::LUMI) {
471 assert(!
"Impossible Scope.");
477 if (
target == targetset.end()) {
480 assert(anyme && checkScope(anyme->getScope()) ==
false);
502 auto& localset = this->
localMEs_[moduleID];
505 if (scope == MonitorElementData::Scope::JOB) {
506 return (run == 0 && lumi == 0);
507 }
else if (scope == MonitorElementData::Scope::RUN) {
508 return (run != 0 && lumi == 0);
509 }
else if (scope == MonitorElementData::Scope::LUMI) {
512 assert(!
"Impossible Scope.");
518 if (
me->isValid() && checkScope(
me->getScope()) ==
true) {
535 assert(run != 0 || lumi != 0);
539 auto meset = std::set<MonitorElement*, MonitorElement::MEComparison>();
545 auto torecycle = std::vector<MonitorElement*>();
549 if (scope == MonitorElementData::Scope::JOB) {
550 assert(run == 0 && lumi == 0);
551 }
else if (scope == MonitorElementData::Scope::RUN) {
552 assert(run != 0 && lumi == 0);
553 }
else if (scope == MonitorElementData::Scope::LUMI) {
556 assert(!
"Impossible Scope.");
562 checkScope(
me->getScope());
572 torecycle.push_back(
me);
579 auto medata =
me->release();
584 me->switchData(medata);
587 auto result = prototypes.insert(
me);
595 std::vector<MonitorElement*>
out;
599 auto it = meset.lower_bound(path);
600 while (it != meset.end() && (*it)->getPathname() == path.
getDirname()) {
611 std::vector<MonitorElement*>
out;
617 auto it = meset.lower_bound(path);
619 while (it != meset.end() && (*it)->getPathname().rfind(path_str, 0) == 0) {
633 uint32_t
lumi)
const {
635 std::vector<MonitorElement*>
out;
641 auto it = meset.lower_bound(path);
647 while (it != meset.end() && (*it)->getFullname().rfind(path_str, 0) == 0) {
649 for (std::vector<std::string>::const_iterator ipath =
store_->
MEsToSave_.begin();
653 if (name.find(*ipath) != std::string::npos) {
683 auto it = meset.find(key.
path_);
684 if (it != meset.end()) {
695 throw cms::Exception(
"iGetter Error") <<
"ME " << path <<
" was requested but not found.";
704 std::set<std::string> subdirs;
706 const auto& name =
me->getPathname();
707 auto subdirname = name.substr(this->
cwd_.length(), std::string::npos);
708 auto dirname = subdirname.substr(0, subdirname.find(
'/'));
711 std::vector<std::string>
out;
712 for (
const auto&
dir : subdirs) {
713 if (
dir.length() == 0)
715 out.push_back(this->
cwd_ +
dir);
722 std::vector<std::string>
out;
723 out.reserve(mes.size());
724 for (
auto me : mes) {
725 out.push_back(
me->getName());
757 this->
setScope(MonitorElementData::Scope::JOB);
787 h.
save(filename, path);
795 bool fileMustExist) {
DQMStore(edm::ParameterSet const &pset, edm::ActivityRegistry &)
T getUntrackedParameter(std::string const &, T const &) const
void save(std::string const &filename, std::string const &path="", uint32_t const run=0, bool saveall=true, std::string const &fileupdate="RECREATE")
virtual void setCurrentFolder(std::string const &fullpath)
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
virtual DQM_DEPRECATED MonitorElement * getElement(std::string const &path) const
void debugTrackME(const char *message, MonitorElement *me_local, MonitorElement *me_global) const
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
virtual std::string pwd()
edm::propagate_const< std::unique_ptr< TH1 > > object_
virtual edm::LuminosityBlockID setRunLumi(edm::LuminosityBlockID runlumi)
LuminosityBlockID const & luminosityBlockID() const
virtual MonitorElementData::Scope setScope(MonitorElementData::Scope newscope)
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
void printTrace(std::string const &message)
std::map< uint64_t, std::set< MonitorElement *, MonitorElement::MEComparison > > localMEs_
virtual MonitorElement * bookME(TString const &name, MonitorElementData::Kind kind, std::function< TH1 *()> makeobject, bool forceReplace=false)
virtual bool dirExists(std::string const &path) const
edm::LuminosityBlockID runlumi_
MonitorElementData::Scope scope_
unsigned int LuminosityBlockNumber_t
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
MonitorElement * findOrRecycle(MonitorElementData::Key const &)
void leaveLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
edm::LuminosityBlockID getRunLumi()
std::string const & getDirname() const
void set(std::string path, Path::Type type)
void initLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi)
void enterLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
std::recursive_mutex booking_mutex_
edm::LuminosityBlockID id_
virtual MonitorElement * get(std::string const &fullpath) const
tuple key
prepare the HTCondor submission files and eventually submit them
void watchPostGlobalEndLumi(PostGlobalEndLumi::slot_type const &iSlot)
std::string getFullname() const
std::map< edm::LuminosityBlockID, std::set< MonitorElement *, MonitorElement::MEComparison > > globalMEs_
virtual uint64_t setModuleID(uint64_t moduleID)
MonitorElementData::Scope getScope()
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
Log< level::Info, false > LogInfo
dqm::legacy::MonitorElement MonitorElement
unsigned long long uint64_t
void watchPostGlobalWriteRun(PostGlobalWriteRun::slot_type const &iSlot)
MonitorElement * findME(MELIKE const &path)
void watchPostGlobalEndRun(PostGlobalEndRun::slot_type const &iSlot)
LuminosityBlockNumber_t luminosityBlock() const
std::vector< std::string > MEsToSave_
MonitorElement * putME(MonitorElement *me)
virtual std::vector< std::string > getMEs() const
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
void watchPostGlobalWriteLumi(PostGlobalEndLumi::slot_type const &iSlot)
std::string getFullname() const
get full name of ME including Pathname
void cleanupLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Log< level::Warning, false > LogWarning
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
tuple size
Write out results.
DQM_DEPRECATED bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)