Accessing subdirectory on a root file

Hi,
I’m trying to access a subdirectory “decay” within a root file, by calling the function do_plots,
I tried to get the list of keys of that subdirectory by using cd(“subdirectory”), and then GetListOfKeys(); but the keys that I got are the keys for the parent Directory, How can I get the keys of a given subdirectory?

Thank you. Here is some of the piecesof code i’m using, It seems it gets on to the subdirectory but doesn’t get the right keys.

Jorge A.

void do_plots (TDirectory *f, TString &path, TEnv *params)
{
f->cd(“decay”);
TList *objlist = f->GetListOfKeys();
TIterator *itr = objlist->MakeIterator();
TKey key;
while ((key = static_cast<TKey
>(itr->Next())) != 0) {
TObject *obj = key->ReadObj();

if (obj->IsA()->InheritsFrom("TH1")) {

// cout << "Ploting routine "<< endl;
}
}
}

Replace

TList *objlist = f->GetListOfKeys(); with

Cheers,
Philippe.