In your example, you loop on objects in memory. What you want
is to loop on all objects on the file.
You will find below a small example illustrating how to do it.
For more elaborated examples, see the code of TDirectory itself.
For example:
http://root.cern.ch/root/html/src/TDirectory.cxx.html#TDirectory:Browse
{
TFile *file = new TFile("hsimple.root");
TObject *obj;
TKey *key;
TIter next( file->GetListOfKeys());
while ((key = (TKey *) next())) {
obj = file->Get(key->GetName()); // copy object to memory
// do something with obj
printf(" found object:%s\n",key->GetName());
}
}
Rene Brun