Hi Fred,
What you do is nearly correct, except that you MUST cast
root [1] TH1 *myHist = (TH1*)f->Get("myHist");
Rene Brun
On Thu, 30 May 2002, Frederic Sarazin wrote:
> Dear ROOTers,
>
> I want to retrieve myHist and keep it in memory
> EXACTLY as it was on disk.
>
> Please consider the following example:
>
> root [0] TFile *f = new TFile("test.root")
> root [1] TH1 *myHist = f->Get("myHist")
> root [2] myHist->SetDirectory(0)
> root [3] f->Close()
>
> I want this part to be treated by my GUI. The user selects
> a histogram on disk and decide to transfer it into memory.
> The problem is at root[1]...
>
> I have two questions...
>
> 1 - Is it possible to "dynamically" cast *myHist with its
> true class (in C++)?
>
> 2 - in this example, I create a new pointer which happens to have
> the same name than myHist... my GUI would need to
> create the pointer with the same name than the one on disk.
> Is it possible ? Is there a way to really keep an exact copy of
> myHist in memory when f is closed (same pointer name) ?
>
> Thanks for your help and thoughts,
>
> Fred
>
>
>
>
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET