18 static const std::string s_safe =
"/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_()# ";
45 scope_ = MonitorElementData::Scope::JOB;
76 size_t pos = pathToCheck.find(limiter);
78 pathToCheck.erase(0,
pos + limiter.size());
80 if (pathToCheck.find_first_not_of(
s_safe) != std::string::npos) {
82 <<
" Monitor element path name: '" << pathToCheck.c_str() <<
"' uses unacceptable characters." 83 <<
"\n Acceptable characters are: " <<
s_safe.c_str();
98 TH1* th1 = makeobject();
106 if (this->
scope_ == MonitorElementData::Scope::JOB) {
108 }
else if (this->
scope_ == MonitorElementData::Scope::RUN) {
110 }
else if (this->
scope_ == MonitorElementData::Scope::LUMI) {
128 TH1* th1 = makeobject();
132 me->switchObject(std::unique_ptr<TH1>(th1));
169 if (existing_new.second ==
true) {
176 assert(!
"Currently, this should never happen.");
177 return *(existing_new.first);
189 auto existing_new = localmes.insert(local_me);
191 assert(existing_new.second ==
true);
197 edm::LogInfo(
"DQMStore") <<
"ME " <<
me->getFullname() <<
" booked twice in the same module.";
204 if (!local_me->isValid()) {
205 local_me->switchData(
me);
212 template <
typename MELIKE>
215 for (
auto& [runlumi, meset] : this->
globalMEs_) {
216 auto it = meset.find(
path);
217 if (it != meset.end()) {
231 std::regex s_rxtrace{
"(.*)\\((.*)\\+0x.*\\).*(\\[.*\\])"};
232 std::regex s_rxself{
"^[^()]*dqm::implementation::.*|^[^()]*edm::.*|.*edm::convertException::wrap.*"};
237 int demangle_status = 0;
238 std::vector<std::string> clean_trace;
255 if (match[2].length() == 0) {
261 demangled = abi::__cxa_demangle(
std::string(match[2]).c_str(),
nullptr,
nullptr, &demangle_status);
262 if (!
demangled || demangle_status != 0) {
263 edm::LogWarning(
"DQMStoreBacktrace") <<
"failed demangle! status " << demangle_status <<
" on " << match[2];
267 if (std::regex_match(
demangled, s_rxself)) {
283 if (!clean_trace.empty()) {
284 logger << message <<
" at ";
285 for (
auto const&
s : clean_trace) {
289 logger << message <<
" : failed to collect stack trace.";
297 const char* scopename[] = {
"INVALID",
"JOB",
"RUN",
"LUMI"};
298 if (!this->
trackME_.empty() && (me_local || me_global)) {
300 if (
name.find(this->trackME_) != std::string::npos) {
302 logger << message <<
" for " <<
name <<
"(" << me_local <<
"," << me_global <<
")";
305 logger <<
" " <<
me->getRunLumi() <<
" scope " << scopename[
me->getScope()];
307 logger <<
" entries " <<
me->getEntries();
309 logger <<
" value " <<
me->getStringValue();
311 logger <<
" value " <<
me->getFloatValue();
313 logger <<
" value " <<
me->getIntValue();
353 auto proto = prototypes.find(
key.path_);
354 if (proto != prototypes.end()) {
357 prototypes.erase(proto);
358 auto medata = oldme->release();
360 medata->data_.key_.id_ =
key.id_;
364 oldme->switchData(medata);
365 auto result = targetset.insert(oldme);
367 auto newme = *
result.first;
370 debugTrackME(
"findOrRecycle (recycled)",
nullptr, newme);
391 auto& localset = this->
localMEs_[moduleID];
399 if (scope == MonitorElementData::Scope::JOB) {
400 return (
run == 0 &&
lumi == 0);
401 }
else if (scope == MonitorElementData::Scope::RUN) {
402 return (
run != 0 &&
lumi == 0);
403 }
else if (scope == MonitorElementData::Scope::LUMI) {
406 assert(!
"Impossible Scope.");
412 if (
target != targetset.end()) {
417 auto proto = prototypes.find(
me);
418 if (proto != prototypes.end()) {
422 if (checkScope((*proto)->getScope()) ==
false) {
427 prototypes.erase(proto);
428 auto medata = oldme->release();
434 oldme->switchData(medata);
435 auto result = targetset.insert(oldme);
443 assert(anyme || !
"local ME without any global ME!");
444 if (checkScope(anyme->getScope()) ==
false) {
456 auto result = targetset.insert(newme);
475 auto& localset = this->
localMEs_[moduleID];
481 if (scope == MonitorElementData::Scope::JOB) {
482 return (
run == 0 &&
lumi == 0);
483 }
else if (scope == MonitorElementData::Scope::RUN) {
484 return (
run != 0 &&
lumi == 0);
485 }
else if (scope == MonitorElementData::Scope::LUMI) {
488 assert(!
"Impossible Scope.");
494 if (
target == targetset.end()) {
497 assert(anyme && checkScope(anyme->getScope()) ==
false);
519 auto& localset = this->
localMEs_[moduleID];
522 if (scope == MonitorElementData::Scope::JOB) {
523 return (
run == 0 &&
lumi == 0);
524 }
else if (scope == MonitorElementData::Scope::RUN) {
525 return (
run != 0 &&
lumi == 0);
526 }
else if (scope == MonitorElementData::Scope::LUMI) {
529 assert(!
"Impossible Scope.");
535 if (
me->isValid() && checkScope(
me->getScope()) ==
true) {
556 auto meset = std::set<MonitorElement*, MonitorElement::MEComparison>();
562 auto torecycle = std::vector<MonitorElement*>();
566 if (scope == MonitorElementData::Scope::JOB) {
568 }
else if (scope == MonitorElementData::Scope::RUN) {
570 }
else if (scope == MonitorElementData::Scope::LUMI) {
573 assert(!
"Impossible Scope.");
579 checkScope(
me->getScope());
589 torecycle.push_back(
me);
596 auto medata =
me->release();
601 me->switchData(medata);
604 auto result = prototypes.insert(
me);
612 std::vector<MonitorElement*>
out;
616 auto it = meset.lower_bound(
path);
617 while (it != meset.end() && (*it)->getPathname() ==
path.getDirname()) {
628 std::vector<MonitorElement*>
out;
632 auto path_str =
path.getFullname();
634 auto it = meset.lower_bound(
path);
636 while (it != meset.end() && (*it)->getPathname().rfind(path_str, 0) == 0) {
650 uint32_t
lumi)
const {
652 std::vector<MonitorElement*>
out;
656 auto path_str =
path.getFullname();
658 auto it = meset.lower_bound(
path);
664 while (it != meset.end() && (*it)->getFullname().rfind(path_str, 0) == 0) {
666 for (std::vector<std::string>::const_iterator ipath =
store_->
MEsToSave_.begin();
670 if (
name.find(*ipath) != std::string::npos) {
700 auto it = meset.find(
key.path_);
701 if (it != meset.end()) {
712 throw cms::Exception(
"iGetter Error") <<
"ME " << path <<
" was requested but not found.";
723 const auto& name =
me->getPathname();
724 auto subdirname =
name.substr(this->
cwd_.length(), std::string::npos);
725 auto dirname = subdirname.substr(0, subdirname.find(
'/'));
728 std::vector<std::string>
out;
730 if (
dir.length() == 0)
739 std::vector<std::string>
out;
740 out.reserve(mes.size());
741 for (
auto me : mes) {
742 out.push_back(
me->getName());
757 verbose_ =
pset.getUntrackedParameter<
int>(
"verbose", 0);
760 MEsToSave_ =
pset.getUntrackedParameter<std::vector<std::string>>(
"MEsToSave", std::vector<std::string>());
774 this->
setScope(MonitorElementData::Scope::JOB);
812 bool fileMustExist) {
DQMStore(edm::ParameterSet const &pset, edm::ActivityRegistry &)
LuminosityBlockNumber_t luminosityBlock() const
virtual DQM_DEPRECATED MonitorElement * getElement(std::string const &path) const
virtual void setCurrentFolder(std::string const &fullpath)
virtual std::vector< std::string > getMEs() const
virtual std::string pwd()
edm::propagate_const< std::unique_ptr< TH1 > > object_
virtual edm::LuminosityBlockID setRunLumi(edm::LuminosityBlockID runlumi)
virtual MonitorElementData::Scope setScope(MonitorElementData::Scope newscope)
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
virtual bool dirExists(std::string const &path) const
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)
edm::LuminosityBlockID runlumi_
MonitorElementData::Scope scope_
unsigned int LuminosityBlockNumber_t
MonitorElement * findOrRecycle(MonitorElementData::Key const &)
void leaveLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
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_
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
edm::LuminosityBlockID id_
void watchPostGlobalEndLumi(PostGlobalEndLumi::slot_type const &iSlot)
std::map< edm::LuminosityBlockID, std::set< MonitorElement *, MonitorElement::MEComparison > > globalMEs_
virtual uint64_t setModuleID(uint64_t moduleID)
LuminosityBlockID const & luminosityBlockID() const
MonitorElementData::Scope getScope()
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
Log< level::Info, false > LogInfo
dqm::legacy::MonitorElement MonitorElement
std::string getFullname() const
get full name of ME including Pathname
unsigned long long uint64_t
void watchPostGlobalWriteRun(PostGlobalWriteRun::slot_type const &iSlot)
MonitorElement * findME(MELIKE const &path)
void watchPostGlobalEndRun(PostGlobalEndRun::slot_type const &iSlot)
virtual MonitorElement * get(std::string const &fullpath) const
std::vector< std::string > MEsToSave_
MonitorElement * putME(MonitorElement *me)
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
void watchPostGlobalWriteLumi(PostGlobalEndLumi::slot_type const &iSlot)
static const std::string s_safe
void cleanupLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi)
Log< level::Warning, false > LogWarning
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void debugTrackME(const char *message, MonitorElement *me_local, MonitorElement *me_global) const
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)
virtual std::vector< dqm::harvesting::MonitorElement * > getContents(std::string const &path) const
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const