3 #include <TCollection.h>
4 #include <TDirectory.h>
22 TDirectory*
save = gDirectory;
37 if (!dest->IsWritable())
39 std::cout <<
"TDirectoryHelper::copyToFile : destination file is not "
95 newdir =
static_cast<TDirectory*
>(gDirectory->FindObject(source->GetName()));
99 newdir = dest->mkdir(source->GetName(), source->GetTitle());
104 TIter
next(source->GetList());
107 while ((obj =
next()))
109 TDirectory* dir =
dynamic_cast<TDirectory*
>(obj);
124 static std::vector<std::string> paths;
128 TDirectory* currentdir = dir;
130 for (
auto&
path : paths)
134 currentdir =
dynamic_cast<TDirectory*
>(gDirectory->Get(
path.c_str()));
137 currentdir = gDirectory->mkdir(
path.c_str());
138 assert(currentdir !=
nullptr);
149 std::vector<std::string>*
titles)
151 TDirectory*
save = gDirectory;
153 TDirectory* dir = topDir;
154 TDirectory* tdir = dir;
156 if (topDir ==
nullptr)
165 std::vector<std::string> paths;
169 for (
size_t i = 0;
i < paths.size();
i++)
171 TDirectory* subdir =
static_cast<TDirectory*
>(dir->FindObject(paths[
i].c_str()));
172 if (subdir ==
nullptr)
174 if (titles && i < titles->
size())
176 dir = dir->mkdir(paths[
i].c_str(), (*titles)[
i].c_str());
180 dir = dir->mkdir(paths[
i].c_str());
203 TDirectory* dirsave = gDirectory;
205 static std::vector<std::string> paths;
212 TDirectory* cdir = dir;
214 for (
size_t i = 0;
i < paths.size() && ok;
i++)
218 cdir =
dynamic_cast<TDirectory*
>(cdir->Get(paths[
i].c_str()));
246 ok = dir->cd(where.c_str());
248 TObject* obj = gDirectory->Get(histoname.c_str());
251 rv =
dynamic_cast<TH1*
>(obj);
254 std::cout <<
"GetHisto : object " << histoname <<
" is not a TH1" << std::endl;
263 std::vector<std::string>& paths)
277 std::vector<size_t> slashes_pos;
281 str.insert(str.begin(),
'/');
284 if (str[str.size() - 1] !=
'/')
289 for (
size_t i = 0;
i < str.size();
i++)
293 slashes_pos.push_back(
i);
297 if (not slashes_pos.empty())
299 for (
size_t i = 0;
i < slashes_pos.size() - 1;
i++)
301 paths.push_back(str.substr(slashes_pos[
i] + 1,
302 slashes_pos[
i + 1] - slashes_pos[
i] - 1));