You should never do gDirectory->Get(name) where name is a subdirectory of gDirectory. Like on a Unix system, do gDirectory->cd("ku"); //this will set gDirectory to the ku directory In the case of t2.C below, you create the directory "ku" and you then read again in memory the directory from disk. TDirectory::cd is doing this work automatically for you. If the directory structure is already in memory, cd() simply sets a link to this directory. If the directory does not exist (case of t1.C), then the directory will be rebuilt in memory. I will make this info more explicit in TDirectory::Get. Rene Brun mayer@ik1.fzk.de wrote: > > Dear rooters > > I have a problem accessing a newly created directory. The following macro > and its output shows the problem. However first closing and then reopening > the file does work. I use redhat 4.2 with root version 2.011. > The problem however does not appear under DEC/OSF1. > > Thanks in advance > Hajo. > > //--------> t2.C this does not work > { > gROOT.Reset(); > file = new TFile("test.root","new"); > gDirectory.pwd(); > gDirectory.mkdir("ku","Die Kunst"); > gDirectory.pwd(); > gDirectory.ls(); > > TObject *obj = gDirectory->Get("ku;1"); > printf("%s \n",obj->GetTitle()); > gDirectory.pwd(); > gDirectory.ls(); > > } > > root [0] .x t2.C > test.root:/ > test.root:/ > TFile** test.root > TFile* test.root > TDirectory* ku Die Kunst > KEY: TDirectory ku;1 Die Kunst > Die Kunst > test.root:/ > TFile** test.root > TFile* test.root > > *** Break *** segmentation violation > > //-------> t1.C this does work > { > gROOT.Reset(); > file = new TFile("test.root","new"); > gDirectory.pwd(); > gDirectory.mkdir("ku","Die Kunst"); > gDirectory.pwd(); > gDirectory.ls(); > > file.Close(); > file = new TFile("test.root"); > gDirectory.pwd(); > gDirectory.ls(); > > TObject *obj = gDirectory->Get("ku;1"); > printf("%s \n",obj->GetTitle()); > gDirectory.pwd(); > gDirectory.ls(); > > } > > root [2] .x t1.C > test.root:/ > test.root:/ > TFile** test.root > TFile* test.root > TDirectory* ku Die Kunst > KEY: TDirectory ku;1 Die Kunst > test.root:/ > TFile** test.root > TFile* test.root > KEY: TDirectory ku;1 Die Kunst > Die Kunst > test.root:/ > TFile** test.root > TFile* test.root > TDirectory* ku Die Kunst > KEY: TDirectory ku;1 Die Kunst
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET