Re: [ROOT] Unexpected reading of TH1 objects from a tree

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jun 17 2002 - 17:56:52 MEST


Hi,

On Mon, 17 Jun 2002, Nesterov Stanislav wrote:

> Hello Rene,
> 
>  Thank You for Your reply. Now I understand the point..
>  Now I just want to ask: 
>     1) why objects start to duplicate in my case?

If you do not delete the object at the address that you indicated
to SetBranchAddress, at the next call a new object will be allocated at
this address. However, because a reference to this object was also added
in gDirectory->GetList(), you are confusing the system.

>
2) is it really good to create objects in memory by default while
> reading a tree?

I do not understand this question.

>     3) if I don't want default
behavior what should I do ( I mean, what
> flag must be set to avoid creating objects in memory).

Again, I do not understand this question. By definition, if you read
something from disk, you read it in memory.
If your question is:
 Which flag to set to not automatically register a TH1 or TTree to
 gDirectory->GetList()"
see the Users Guide on Memory allocation and TH1::AddDirectory(kFALSE).

Rene Brun

> 
>    Once more Thank You very much
> 			Best regards,
> 					Stanislav.
> 
> On Mon, 17 Jun 2002, Rene Brun wrote:
> 
> > Hi Nesterov,
> > 
> > When calling whell->GetEntry, you request to read all the branches
> > of your Tree. If you want to read only one single branch, get
> > the pointer to the branch and call branch->GetEntry.
> > 
> > In your case, you should do something like:
> > 
> > TBranch *b_Spec = wheel->GetBranch("Spec");
> > TH1 *Spec=0;
> > b_Spec->SetAddress(&Spec);
> > b_Spec->GetEntry(22);
> > delete Spec; Spec=0; //to delete the current hist
> > Spec=0; // if you want to keep the current hist in memory
> > b_Spec->GetEntry(23); /etc..
> > 
> > Rene Brun
> > 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:57 MET