Hello,
I’m trying to find a way in root to load a file and find all objects of a certain class (say, 'TCanvas’s). Using code that (I think) Rene posted here a while ago, I’ve got code that works well if the file is flat (i.e. no directory structure):
void listRootCanvases (TString filename = "TrigMon203153_tmp.root")
{
TFile f(filename);
TIter next(f.GetListOfKeys());
TKey *key;
//TCanvas c1;
while ((key = (TKey*)next())) {
//continue;
TClass *clsPtr = gROOT->GetClass(key->GetClassName());
TString name = key->GetClassName();
if (! name.Contains("TCanvas")) continue;
// do something with the key
cout << ":::" << key->GetName() << ":::" << endl;
}
}
Unfortunately, this does not work on a file with directory structure. When I run this on a file that has directories, I don’t get anything (even the directories).
Is there either:
-
A way to list all objects regardless of directories, or
-
A way to systematically loop through all of the directories and getting all of the files in each directory?
Thanks,
Charles