Dear all,
I am trying to iterate over all histograms in a directory with:
TFile* f1 = new TFile("file.root");
TList* tdf_obs = f1->GetDirectory("path/to/directory")->GetList();
TIterator* obs_it = tdf_obs->MakeIterator();
TIter iter(obs_it);
std::for_each( iter.Begin(), iter.End(), fn );
where
void fn(TObject* histobj) {
std::cout << histobj->GetName() << std::endl;
TH2D* hist = (TH2D*)histobj->Clone();
std::cout << "information" << std::endl;
}
However the list that I make on the second line is empty even though I know that there are TH2Ds in the folder. E.g. the result of ls:
TDirectoryFile* Folder Folder
KEY: TH2D 0_Image;1 0_Image
KEY: TH2D 1_Image;1 1_Image
…
Does anybody know what could be causing this?
Cheers,
Sean