Re: [ROOT] Writing array of histograms

From: jgonzalez@neuub0.physics.neu.edu
Date: Thu May 15 2003 - 18:08:53 MEST


Hi this is just a message regarding Jason's question

Couldn't you write the histograms into a TTree? that would solve the
problem of comparing it to other TTrees with histograms. Then you have the
problem of random access, so you decide.

One problem I see with Rene's method is that if you have something else in
your directory you would write that too. That's not big deal though.

does this make sense? 

Javier

> Date: Wed, 14 May 2003 21:25:30 +0200 (MEST)
> From: Rene Brun <Rene.Brun@cern.ch>
> Subject: Re: [ROOT] Writing array of histograms
>
> Hi Jason,
>
> This is quite easy to do. Let me assume that you have created several
> histograms TH1 *h1,*h2,*h3, etc in the current directory.
> You can get a pointer to the list in memory with
>    TList *list = gDirectory->GetList();
>
> then write this list as one single key in a Root file with:
>   TFile f("junk.root","new");
>   list->Write("allhists",TObject::kSingleKey);
>
> To read the list again in memory, you can do
>   TFile f("junk.root");
>   TList *list = (TList*)f.Get("allhists");
>   list->ls();
>
> Rene Brun



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET