CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LegacyIOHelper.h
Go to the documentation of this file.
1 #ifndef DQMSERVICES_CORE_LEGACYIOHELPER_H
2 #define DQMSERVICES_CORE_LEGACYIOHELPER_H
3 
5 #include "TROOT.h"
6 
7 // This class encapsulates the TDirectory based file format used for DQMGUI
8 // uploads and many other use cases.
9 // This should be part of `DQMFileSaver`, however since DQMServices/Components
10 // DQMFileSaver and DQMServices/FileIO DQMFileSaverOnline both write this
11 // format, the code is shared here (evnetually, these modules should become one
12 // again).
13 // This code is in DQMServices/Core to also allow the legacy DQMStore::save
14 // interface to use this without adding another dependency.
16 public:
17  // use internal type here since we call this from the DQMStore itself.
20 
23 
24  using MEMap = std::set<HarvestedMonitorElement*>;
25 
26  LegacyIOHelper(DQMStore* dqmstore) : dbe_(dqmstore){};
27  LegacyIOHelper(HarvestedDQMStore* hdqmstore) : dbe_(hdqmstore){};
28  // Replace or append to `filename`, a TDirectory ROOT file. If a run number
29  // is passed, the paths are rewritten to the "Run Summary" format used by
30  // DQMGUI. The run number does not affect which MEs are saved; this code only
31  // supports non-threaded mode. `fileupdate` is passed to ROOT unchanged.
32  // The run number passed in is added to the Directory structure inside the
33  // file ("Run xxxxxx/.../Run Summary/...") if not 0. It is only used to
34  // select only MEs for that run iff saveall is false, else all MEs (RUN, LUMI
35  // and JOB) are saved.
36  void save(std::string const& filename,
37  std::string const& path = "",
38  uint32_t const run = 0,
39  bool saveall = true,
40  std::string const& fileupdate = "RECREATE");
41 
42  bool open(std::string const& filename, std::string const& path = "", uint32_t const run = 0);
43 
44 private:
45  template <class T>
46  void getMEName(T* h, const std::string& toppath, std::string& meName) {
47  std::ostringstream fullpath;
48  fullpath << gDirectory->GetPath() << "/" << h->GetName();
49  std::string dirpath = fullpath.str();
50  // Search for the substring in string
51  size_t pos = dirpath.find(toppath);
52  if (pos != std::string::npos) {
53  dirpath.erase(pos, toppath.length());
54  }
55  std::string rsummary = "/Run summary";
56  pos = dirpath.find(rsummary);
57  if (pos != std::string::npos) {
58  dirpath.erase(pos, rsummary.length());
59  }
60  meName = dirpath;
61  }
62  bool readdir(TDirectory* dir, const std::string& toppath);
66 };
67 
68 #endif
bool createDirectoryIfNeededAndCd(const std::string &path)
std::set< HarvestedMonitorElement * > MEMap
void save(std::string const &filename, std::string const &path="", uint32_t const run=0, bool saveall=true, std::string const &fileupdate="RECREATE")
def fullpath
Definition: das_client.py:267
bool open(std::string const &filename, std::string const &path="", uint32_t const run=0)
LegacyIOHelper(HarvestedDQMStore *hdqmstore)
DQMStore * dbe_
bool readdir(TDirectory *dir, const std::string &toppath)
dqm::implementation::DQMStore DQMStore
dqm::harvesting::MonitorElement HarvestedMonitorElement
void getMEName(T *h, const std::string &toppath, std::string &meName)
dqm::legacy::MonitorElement MonitorElement
tuple filename
Definition: lut2db_cfg.py:20
dqm::harvesting::DQMStore HarvestedDQMStore
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
LegacyIOHelper(DQMStore *dqmstore)
long double T