TChain not in directory

Fons Rademakers wrote:

Concerning the TChain, the chain itself is not added to the current
directory (TROOT), only the TTree’s that are part of the chain will be
later added once you have added them to the chain. TTree’s are
automatically added to the current directory (as convenience, like THxx
objects).

So, how would I fetch the pointer to a chain that was created in a function, like:

f1 () {
TChain* tc = new TChain(“tc”,“tc tit”);
tc->Add…
.
.
.
}

f2 () {
// this is what I wanted to do, as is usually done with TTree and TH**
TChain* tc = (TChain*) gDirectory->Get(“tc”);
.
.
.
}

If I do this in CINT

root [0] new TChain(“tc”,“tc tit”);
root [1] tc
(class TChain*)0x829eef0

The second command shows the pointer to the chain. So, what does CINT do that I (currently) cannot.

Cheers, Heiko

You can retrieve a pointer to the chain with

gROOT->GetListOfSpecials()->FindObject(chainname); or (with ROOT >=5.17)

gROOT->GetListOfDataSets()->FindObject(chainname);
Rene