Question about TList using several root files

Dear experts,
I made the simple macro to superposing several histogram in same canvas.
Each group histogram are in different root input files. I use the TList to access the GetListOfKeys in these root files and I made a loop all the objets of ROOT file directory.
However, in each loop this script see does not same the object in each file.
I would like to access same root object in different root file in same time.
You can see the root macro here.

Could you clarify this point for me?
Thanks in advance,
Sandro Fonseca
UERJ/Brazil
loopdir2.C (7.86 KB)

[quote]I would like to access same root object in different root file in same time. [/quote]I recommend that you iterate over only ‘one’ of the list of keys (keep only one of the iterator), and look up the key by name in the other list (i.e objlist2->FindObject(key1->GetName()); ).

Cheers,
Philippe.

PS. Alternatively, if you are guaranteed that the histogram are in the same order in each of the file you can execute: key3 = static_cast<TKey*>(iter.Next()); key2 = static_cast<TKey*>(iter.Next());within the looop.

Cheers,
Philippe.