diff --git a/DQM/EcalCommon/interface/MESet.h b/DQM/EcalCommon/interface/MESet.h index 5bd8ae16983e7..4f7ad5189d967 100644 --- a/DQM/EcalCommon/interface/MESet.h +++ b/DQM/EcalCommon/interface/MESet.h @@ -11,10 +11,10 @@ #include "FWCore/Utilities/interface/Exception.h" #include +#include +#include #include -#include "boost/ptr_container/ptr_map.hpp" - namespace ecaldqm { /* class MESet @@ -338,15 +338,33 @@ namespace ecaldqm { } // namespace ecaldqm -namespace boost { - template <> - inline ecaldqm::MESet *new_clone(ecaldqm::MESet const &); - template <> - void delete_clone(ecaldqm::MESet const *); -} // namespace boost - namespace ecaldqm { - typedef boost::ptr_map MESetCollection; -} + + class MESetCollection { + using MESetColletionType = std::map>; + + public: + using iterator = MESetColletionType::iterator; + using const_iterator = MESetColletionType::const_iterator; + + void insert(const std::string &key, MESet *ptr) { _MESetColletion.emplace(key, ptr); } + void insert(const std::string &&key, MESet *ptr) { _MESetColletion.emplace(key, ptr); } + + void erase(const std::string &key) { _MESetColletion.erase(key); } + + auto begin() { return _MESetColletion.begin(); } + auto end() const { return _MESetColletion.end(); } + + const_iterator find(const std::string &key) const { return _MESetColletion.find(key); } + iterator find(const std::string &key) { return _MESetColletion.find(key); } + + //return a reference, but this collection still has the ownership + MESet &at(const std::string &key) { return *(_MESetColletion.at(key).get()); } + + private: + MESetColletionType _MESetColletion; + }; + +} // namespace ecaldqm #endif diff --git a/DQM/EcalCommon/plugins/EcalMEFormatter.cc b/DQM/EcalCommon/plugins/EcalMEFormatter.cc index 36ee4963d5739..08e0f3fbfcc6d 100644 --- a/DQM/EcalCommon/plugins/EcalMEFormatter.cc +++ b/DQM/EcalCommon/plugins/EcalMEFormatter.cc @@ -36,20 +36,20 @@ void EcalMEFormatter::dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &_igetter void EcalMEFormatter::format_(DQMStore::IGetter &_igetter, bool _checkLumi) { std::string failedPath; - for (ecaldqm::MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr) { - if (_checkLumi && !mItr->second->getLumiFlag()) + for (auto &mItr : MEs_) { + if (_checkLumi && !mItr.second->getLumiFlag()) continue; - mItr->second->clear(); - if (!mItr->second->retrieve(_igetter, &failedPath)) { + mItr.second->clear(); + if (!mItr.second->retrieve(_igetter, &failedPath)) { if (verbosity_ > 0) - edm::LogWarning("EcalDQM") << "Could not find ME " << mItr->first << "@" << failedPath; + edm::LogWarning("EcalDQM") << "Could not find ME " << mItr.first << "@" << failedPath; continue; } if (verbosity_ > 1) - edm::LogInfo("EcalDQM") << "Retrieved " << mItr->first << " from DQMStore"; + edm::LogInfo("EcalDQM") << "Retrieved " << mItr.first << " from DQMStore"; - if (dynamic_cast(mItr->second)) - formatDet2D_(*mItr->second); + if (dynamic_cast(mItr.second.get())) + formatDet2D_(*mItr.second); } } diff --git a/DQM/EcalCommon/src/MESet.cc b/DQM/EcalCommon/src/MESet.cc index 9f4c4b199d7c3..e6fdea156c023 100644 --- a/DQM/EcalCommon/src/MESet.cc +++ b/DQM/EcalCommon/src/MESet.cc @@ -487,14 +487,3 @@ namespace ecaldqm { return true; } } // namespace ecaldqm - -namespace boost { - template <> - inline ecaldqm::MESet *new_clone(ecaldqm::MESet const &_s) { - return _s.clone(); - } - template <> - void delete_clone(ecaldqm::MESet const *_s) { - checked_delete(_s); - } -} // namespace boost diff --git a/DQM/EcalMonitorClient/src/DQWorkerClient.cc b/DQM/EcalMonitorClient/src/DQWorkerClient.cc index ef8c5c5a13bdf..d517cbc891cbb 100644 --- a/DQM/EcalMonitorClient/src/DQWorkerClient.cc +++ b/DQM/EcalMonitorClient/src/DQWorkerClient.cc @@ -36,8 +36,8 @@ namespace ecaldqm { // Flags the Client ME to run as lumibased: // In offline mode will save the ME client at the end of the LS // See: EcalDQMonitorClient::dqmEndLuminosityBlock - for (MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr) { - if (mItr->second->getLumiFlag()) { + for (auto& mItr : MEs_) { + if (mItr.second->getLumiFlag()) { hasLumiPlots_ = true; break; } @@ -111,15 +111,15 @@ namespace ecaldqm { } void DQWorkerClient::resetMEs() { - for (MESetCollection::iterator mItr(MEs_.begin()); mItr != MEs_.end(); ++mItr) { - MESet* meset(mItr->second); + for (auto& mItr : MEs_) { + MESet* meset(mItr.second.get()); // Protects Trend-type Client MEs from being reset at the end of the LS // See: EcalDQMonitorClient::runWorkers if (meset->getBinType() == ecaldqm::binning::kTrend) continue; - if (qualitySummaries_.find(mItr->first) != qualitySummaries_.end()) { + if (qualitySummaries_.find(mItr.first) != qualitySummaries_.end()) { MESetMulti* multi(dynamic_cast(meset)); if (multi) { for (unsigned iS(0); iS < multi->getMultiplicity(); ++iS) {