Finding all objects in a root file, regardless of directries

see example below

[code]//file loopdir.C
void loopdir (TDirectory *dir) {
//loop on all keys of dir including possible subdirs
//print a message for all keys with a class TH1

TIter next (dir->GetListOfKeys());
TKey key;
while ((key = (TKey
)next())) {
if (strstr(key->GetClassName(),“TH1”)) {
printf (" key : %s is a %s in %s\n",
key->GetName(),key->GetClassName(),dir->GetPath());
}
if (!strcmp(key->GetClassName(),“TDirectory”)) {
dir->cd(key->GetName());
TDirectory *subdir = gDirectory;
loopdir(subdir);
dir->cd();
}
}
}[/code]

Do, for example

root > TFile f("myfile with subdirs.root"); root > .L loopdir.C root > loopdir(&f);
Rene