6 #include "boost/regex.hpp"
15 return _cd (subdir,
false);
21 TObject *objPtr = _getObj (histname, subdir);
23 TH1* retval =
dynamic_cast< TH1*
> ( objPtr );
29 <<
"Object named " << histname <<
" is not a histogram";
44 string fpath = fullPath();
51 fpath +=
"/" + subdir;
57 TDirectory *
dir = file_->GetDirectory( fpath.c_str() );
64 if (! createNeededDirectories)
66 cout <<
"here " << fpath << endl;
69 <<
"directory " << fpath <<
" doesn't exist.";
71 if ( !
path_.empty() )
73 dir = file_->GetDirectory(
path_.c_str() );
78 <<
"Can't change directory to path: " <<
path_;
94 <<
"directory " << fpath <<
" doesn't exist.";
100 dir = _mkdir (dir,
dir_, descr_);
102 bool ok = file_->cd( fpath.c_str() );
107 <<
"Can't change directory to path: " << fpath;
114 const string &subdirName,
118 TDirectory *subdirPtr = dirPtr->GetDirectory (subdirName.c_str());
126 const boost::regex subdirRE (
"(.+?)/([^/]+)");
127 boost::smatch matches;
128 TDirectory *parentDir = 0;
129 string useName = subdirName;
130 if( boost::regex_match (subdirName, matches, subdirRE) )
132 parentDir = _mkdir (dirPtr, matches[1], description);
133 useName = matches[2];
138 subdirPtr = parentDir->mkdir (useName.c_str());
143 <<
"Can't create directory " <<
dir_ <<
" in path: " <<
path_;
152 TObject *objPtr = getBareDirectory (subdir)->Get (objname.c_str());
160 <<
"Can not find object named " << objname
161 <<
" in subdir " << subdir;
165 <<
"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
TH1 * getHist(const std::string &histname, const std::string &subdir="") const
TDirectory * _mkdir(TDirectory *dirPtr, const std::string &dir, const std::string &description) const
std::string fullPath() const
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory