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.";
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(
"(.+?)/([^/]+)");
80 TDirectory *parentDir =
nullptr;
81 string useName = subdirName;
82 if (boost::regex_match(subdirName,
matches, subdirRE)) {
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 * _cd(const std::string &subdir="", bool createNeededDirectories=true) const
TObject * _getObj(const std::string &objname, const std::string &subdir="") const
TDirectory * getBareDirectory(const std::string &subdir="") const
TDirectory * _mkdir(TDirectory *dirPtr, const std::string &dir, const std::string &description) const
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
std::string fullPath() const
return the full path of the stored histograms