Re: a problem in reading TFile

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 11 Oct 2006 15:50:22 +0200


By default (see chapter about object ownership in the Users Guide), the histogram is added to the current directory. If you close the file/directory, the histogram is deleted. If you want to do your own management and be independent of file opening/closing, add the following line at the start of your script; TH1::AddDirectory(kFALSE);

Rene Brun

Zhijun Liang wrote:
> hi :
> I found a problem in reading TFile
> I want to read a object from a root file ,but meet some error .
> here is the code :
> {
> TFile f("hsimple.root")
> TH1F *hist=(TH1F *) f->Get("hpx"))
> TH1F *hpx1=hpx->Clone("hpx")
> f.Close()
> hist->Draw()
> }
>
> and the "hsimple.root " is from tutorial directory.
> error information appears
> *** Break *** segmentation violation
> Generating stack trace...
> 0x02fff4f0 in <unknown> from /lib/libc.so.6
> 0x0086efb6 in G__ExceptionWrapper + 0x42 from /home/zliang/root/lib/libCint.so
> 0x008fed5b in G__call_cppfunc + 0x2a7 from /home/zliang/root/lib/libCint.so
>
> do you know what is the problem ?
> thank you
> best regards
> Liang
>
>
>
Received on Wed Oct 11 2006 - 15:50:31 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET