Hi Rene, many thanks, this helps a lot and the workaround you have is much nicer! Cheers, Birger On Tue, 24 Jun 2003, Rene Brun wrote: > Hi Birger, > > Before calling GetFile, do > chain.LoadTree(0); > This will force the first file to be loaded and GetFile will work. > > In the CVS version, I have modified TChain::GetFile to automatically > load the first file if no file has been connected. > > Rene Brun > > koblitz@poly.in2p3.fr wrote: > > > > Hi, > > > > I have problems reading a single object from a Chain, something which > > works for a normal file: > > TChain chain("Tree", "My Tree"); > > chain.Add("file.root"); > > TObject *o=chain.GetFile()->Get("MyObject"); > > does not work, because chain.GetFile() returns a null pointer unless one > > has at least connected to a branch on the file, first (which I use as a > > Workaround), while the following works allways: > > TFile f("file.root"); > > TObject *o=f.Get("MyObject"); > > Is this is a design limitation, or a bug? > > My personal conviction is, that it is probably a bug, because already > > connecting to a branch makes chain.GetFile() return the first file, while > > a design limitiation would probably require you to use GetEntry() on the > > chain, first. > > > > My request is therefore to have TChain::GetFile() return the first file in > > the chain as soon as there is one added, or, implement a Get() method on > > the TChain. > > > > Cheers, > > Birger > > > > -- > > Birger Koblitz Tel: +33/1 69 33 31 73 > > Ecole Polytechnique - LLR > > Route de Saclay > > F-91128 Palaiseau > -- Birger Koblitz Tel: +33/1 69 33 31 73 Ecole Polytechnique - LLR Route de Saclay F-91128 Palaiseau
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET