3 #include <TCollection.h>
4 #include <TDirectory.h>
24 TDirectory* save = gDirectory;
39 if (!dest->IsWritable())
41 cerr <<
"TDirectoryHelper::copyToFile : destination file is not "
47 duplicateDir(dest, src);
96 newdir =
static_cast<TDirectory*
>(gDirectory->FindObject(source->GetName()));
100 newdir = dest->mkdir(source->GetName(), source->GetTitle());
105 TIter next(source->GetList());
108 while ((obj = next()))
110 TDirectory*
dir =
dynamic_cast<TDirectory*
>(obj);
113 duplicateDir(newdir, dir);
125 static vector<string> paths;
127 splitPath(path, paths);
129 TDirectory* currentdir =
dir;
131 for (
size_t i = 0; i < paths.size(); i++)
135 currentdir =
dynamic_cast<TDirectory*
>(gDirectory->Get(paths[i].c_str()));
138 currentdir = gDirectory->mkdir(paths[i].c_str());
139 assert(currentdir != 0);
150 std::vector<std::string>* titles)
152 TDirectory* save = gDirectory;
154 TDirectory*
dir = topDir;
155 TDirectory* tdir =
dir;
166 std::vector<std::string> paths;
168 splitPath(path, paths);
170 for (
size_t i = 0; i < paths.size(); i++)
172 TDirectory* subdir =
static_cast<TDirectory*
>(dir->FindObject(paths[i].c_str()));
175 if (titles && i < titles->size())
177 dir = dir->mkdir(paths[i].c_str(), (*titles)[i].c_str());
181 dir = dir->mkdir(paths[i].c_str());
204 TDirectory* dirsave = gDirectory;
206 static std::vector<string> paths;
209 splitPath(path, paths);
213 TDirectory* cdir =
dir;
215 for (
size_t i = 0; i < paths.size() && ok; i++)
219 cdir =
dynamic_cast<TDirectory*
>(cdir->Get(paths[i].c_str()));
240 bool ok = pathIsInDir(where, dir);
247 ok = dir->cd(where.c_str());
249 TObject* obj = gDirectory->Get(histoname.c_str());
252 rv =
dynamic_cast<TH1*
>(obj);
255 cerr <<
"GetHisto : object " << histoname <<
" is not a TH1" << endl;
264 std::vector<std::string>& paths)
271 std::string str = path;
278 std::vector<size_t> slashes_pos;
282 str.insert(str.begin(),
'/');
285 if (str[str.size() - 1] !=
'/')
290 for (
size_t i = 0; i < str.size(); i++)
294 slashes_pos.push_back(i);
298 if (not slashes_pos.empty())
300 for (
size_t i = 0; i < slashes_pos.size() - 1; i++)
302 paths.push_back(str.substr(slashes_pos[i] + 1,
303 slashes_pos[i + 1] - slashes_pos[i] - 1));