Re: [ROOT] Filling branches separetely

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Nov 03 2003 - 15:21:39 MET


Hi Joaquin,

In your example you are reading 4 different data sets consecutively from the
same file. Calling TTree::Fill for each line is not the solution.
You have two possible solutions

solution 1
==========
Create 4 Trees instead of 1 (say T1, t2, T3, T4). In your first loop, you
fill T1, in the 2nd T2, etc.
T1 should have only the branches that you read in the first loop, etc.
Then you make a logical Tree by declaring T2,T3 and T4 friends of T1.
See TTree::AddFriend

solution 2
==========
You must use the current CVS version.
You create one single Tree with 4 branches corresponding to the data you read
from each loop. Inside each loop, you call only TBranch::Fill instead of
TTree::Fill.
Then at the end of the job, you call tree.SetEntries(nentries).
TTree::setEntries is a new function introduced in TTree only in the CVS version.

Rene Brun


Joaquin Poveda I Torres wrote:
> 
> Hello everybody:
> 
> I'm trying to read data from several ascii files and write it on a single tree, in different branches (I attach a simplified version of my script). The problem is that doing like this a lot of entries are filled just with zeros or their maximum values, because the whole tree is filled in every time, even when another brach is being read.
> My question is, is it possible to fill the different branches or leaves separetely, without filling the whole tree?
> 
> Thank you,
>  Joaquin
> 
> ===================================================
> 
> 
> 
>   --------------------------------------------------------------------------------
>               Name: br.C
>    br.C       Type: Plain Text (text/plain)
>           Encoding: base64
>        Description: br.C



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