6 #include "boost/regex.hpp"
19 if (subdir.length()) {
23 fpath +=
"/" + subdir;
29 TDirectory *
dir = file_->GetDirectory(fpath.c_str());
35 if (!createNeededDirectories) {
36 cout <<
"here " << fpath << endl;
37 throw cms::Exception(
"InvalidDirectory") <<
"directory " << fpath <<
" doesn't exist.";
40 dir = file_->GetDirectory(
path_.c_str());
53 if (subdir.length()) {
54 throw cms::Exception(
"InvalidDirectory") <<
"directory " << fpath <<
" doesn't exist.";
60 dir = _mkdir(dir,
dir_, descr_);
62 bool ok = file_->cd(fpath.c_str());
64 throw cms::Exception(
"InvalidDirectory") <<
"Can't change directory to path: " << fpath;
71 TDirectory *subdirPtr = dirPtr->GetDirectory(subdirName.c_str());
78 const boost::regex subdirRE(
"(.+?)/([^/]+)");
79 boost::smatch matches;
80 TDirectory *parentDir =
nullptr;
81 string useName = subdirName;
82 if (boost::regex_match(subdirName, matches, subdirRE)) {
83 parentDir = _mkdir(dirPtr, matches[1], description);
89 subdirPtr = parentDir->mkdir(useName.c_str());
98 TObject *objPtr = getBareDirectory(subdir)->Get(objname.c_str());
101 if (subdir.length()) {
102 throw cms::Exception(
"ObjectNotFound") <<
"Can not find object named " << objname <<
" in subdir " << subdir;
104 throw cms::Exception(
"ObjectNotFound") <<
"Can not find object named " << objname;
TDirectory * getBareDirectory(const std::string &subdir="") const
TDirectory * _cd(const std::string &subdir="", bool createNeededDirectories=true) const
TObject * _getObj(const std::string &objname, const std::string &subdir="") const
TDirectory * _mkdir(TDirectory *dirPtr, const std::string &dir, const std::string &description) const
std::string fullPath() const
return the full path of the stored histograms
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory