6 #include "boost/regex.hpp" 15 return _cd (subdir,
false);
28 string fpath = fullPath();
35 fpath +=
"/" + subdir;
41 TDirectory *
dir = file_->GetDirectory( fpath.c_str() );
48 if (! createNeededDirectories)
50 cout <<
"here " << fpath << endl;
53 <<
"directory " << fpath <<
" doesn't exist.";
55 if ( !
path_.empty() )
57 dir = file_->GetDirectory(
path_.c_str() );
62 <<
"Can't change directory to path: " <<
path_;
78 <<
"directory " << fpath <<
" doesn't exist.";
84 dir = _mkdir (dir,
dir_, descr_);
86 bool ok = file_->cd( fpath.c_str() );
91 <<
"Can't change directory to path: " << fpath;
98 const string &subdirName,
102 TDirectory *subdirPtr = dirPtr->GetDirectory (subdirName.c_str());
110 const boost::regex subdirRE (
"(.+?)/([^/]+)");
112 TDirectory *parentDir =
nullptr;
113 string useName = subdirName;
114 if( boost::regex_match (subdirName, matches, subdirRE) )
116 parentDir = _mkdir (dirPtr, matches[1], description);
117 useName = matches[2];
122 subdirPtr = parentDir->mkdir (useName.c_str());
127 <<
"Can't create directory " <<
dir_ <<
" in path: " <<
path_;
136 TObject *objPtr = getBareDirectory (subdir)->Get (objname.c_str());
144 <<
"Can not find object named " << objname
145 <<
" in subdir " << subdir;
149 <<
"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