CMS 3D CMS Logo

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
LegacyIOHelper
Definition: LegacyIOHelper.h:15
LegacyIOHelper::save
void save(std::string const &filename, std::string const &path="", uint32_t const run=0, bool saveall=true, std::string const &fileupdate="RECREATE")
Definition: LegacyIOHelper.cc:15
reco_skim_cfg_mod.fullpath
fullpath
Definition: reco_skim_cfg_mod.py:202
LegacyIOHelper::readdir
bool readdir(TDirectory *dir, const std::string &toppath)
Definition: LegacyIOHelper.cc:170
pos
Definition: PixelAliasList.h:18
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
LegacyIOHelper::HarvestedMonitorElement
dqm::harvesting::MonitorElement HarvestedMonitorElement
Definition: LegacyIOHelper.h:22
LegacyIOHelper::HarvestedDQMStore
dqm::harvesting::DQMStore HarvestedDQMStore
Definition: LegacyIOHelper.h:21
LegacyIOHelper::dbe_
DQMStore * dbe_
Definition: LegacyIOHelper.h:64
dqm::legacy::DQMStore
Definition: DQMStore.h:728
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
h
LegacyIOHelper::open
bool open(std::string const &filename, std::string const &path="", uint32_t const run=0)
Definition: LegacyIOHelper.cc:257
LegacyIOHelper::data_
MEMap data_
Definition: LegacyIOHelper.h:65
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LegacyIOHelper::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: LegacyIOHelper.h:19
LegacyIOHelper::LegacyIOHelper
LegacyIOHelper(HarvestedDQMStore *hdqmstore)
Definition: LegacyIOHelper.h:27
writedatasetfile.run
run
Definition: writedatasetfile.py:27
T
long double T
Definition: Basic3DVectorLD.h:48
LegacyIOHelper::getMEName
void getMEName(T *h, const std::string &toppath, std::string &meName)
Definition: LegacyIOHelper.h:46
LegacyIOHelper::DQMStore
dqm::implementation::DQMStore DQMStore
Definition: LegacyIOHelper.h:18
LegacyIOHelper::LegacyIOHelper
LegacyIOHelper(DQMStore *dqmstore)
Definition: LegacyIOHelper.h:26
LegacyIOHelper::createDirectoryIfNeededAndCd
bool createDirectoryIfNeededAndCd(const std::string &path)
Definition: LegacyIOHelper.cc:126
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
dqm::implementation::DQMStore
Definition: DQMStore.h:538
LegacyIOHelper::MEMap
std::set< HarvestedMonitorElement * > MEMap
Definition: LegacyIOHelper.h:24
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23