File indexing completed on 2023-03-17 10:58:58
0001 #ifndef DQMSERVICES_CORE_LEGACYIOHELPER_H
0002 #define DQMSERVICES_CORE_LEGACYIOHELPER_H
0003
0004 #include "DQMServices/Core/interface/DQMStore.h"
0005 #include "TROOT.h"
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 class LegacyIOHelper {
0016 public:
0017
0018 typedef dqm::implementation::DQMStore DQMStore;
0019 typedef dqm::legacy::MonitorElement MonitorElement;
0020
0021 typedef dqm::harvesting::DQMStore HarvestedDQMStore;
0022 typedef dqm::harvesting::MonitorElement HarvestedMonitorElement;
0023
0024 using MEMap = std::set<HarvestedMonitorElement*>;
0025
0026 LegacyIOHelper(DQMStore* dqmstore) : dbe_(dqmstore){};
0027 LegacyIOHelper(HarvestedDQMStore* hdqmstore) : dbe_(hdqmstore){};
0028
0029
0030
0031
0032
0033
0034
0035
0036 void save(std::string const& filename,
0037 std::string const& path = "",
0038 uint32_t const run = 0,
0039 bool saveall = true,
0040 std::string const& fileupdate = "RECREATE");
0041
0042 bool open(std::string const& filename, std::string const& path = "", uint32_t const run = 0);
0043
0044 private:
0045 template <class T>
0046 void getMEName(T* h, const std::string& toppath, std::string& meName) {
0047 std::ostringstream fullpath;
0048 fullpath << gDirectory->GetPath() << "/" << h->GetName();
0049 std::string dirpath = fullpath.str();
0050
0051 size_t pos = dirpath.find(toppath);
0052 if (pos != std::string::npos) {
0053 dirpath.erase(pos, toppath.length());
0054 }
0055 std::string rsummary = "/Run summary";
0056 pos = dirpath.find(rsummary);
0057 if (pos != std::string::npos) {
0058 dirpath.erase(pos, rsummary.length());
0059 }
0060 meName = dirpath;
0061 }
0062 bool readdir(TDirectory* dir, const std::string& toppath);
0063 bool createDirectoryIfNeededAndCd(const std::string& path);
0064 DQMStore* dbe_;
0065 MEMap data_;
0066 };
0067
0068 #endif