Re: [ROOT] problem with tree->GetEntry

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Oct 18 2000 - 19:07:44 MEST


Hello Ursula,
What you get is correct. Let me explain.
At the first call to GetEntry for a given entry, the branch data
will be read from the branch buffer and the function returns the number
of bytes effectively read.
If you call again GetEntry for the same entry via TTree::GetEntry
or TBranch::GetEntry, these two functions check if you try to read
again the same data. If this is the case, one can skip the step
of decoding the branch data from the branch buffer(s) since
the data are already available in memory.
The TBranch::GetEntry function returns the code 1 in this case,
and TTree::GetEntry returns the sum of all branches (ie the number
of branches). The functions return 1 instead of 0 to distinguish
for the case 0 of a non-existing entry.
Logically these two functions should return the corresponding
number of bytes in the branch buffers, but returning this info would
require additional bookeeping and a time penalty.

Rene Brun

On Wed, 18 Oct 2000, Ursula Berthon wrote:

> Dear all,
> I have a problem (or is it a feature?) with TTree::GetEntry(..).
> Have a look at the following:
> root [0] TFile * f = new TFile("../../files/philippe.root")
> root [1] TTree * tree = (TTree*)f->Get("ODS")
> root [2] tree->GetEntry(20,0)
> (Int_t)49090                   <-- ok, that is the whole event
> root [3] tree->SetBranchStatus("*",0)
> root [4] tree->SetBranchStatus("HEAD",1)
> root [5] tree->GetEntry(20,0)
> (Int_t)1   <---- why only 1 byte? the HEAD branch contains more
> root [6] tree->SetBranchStatus("*",1)
> root [7] tree->GetEntry(20,0)
> (Int_t)140
> 
> The GetEntry(20,0), after what I understand, should read all active
> branches, in my case the whole event since I set all branches active, that
> means 49090 bytes. It seems to read something (the HEAD-branch??), but not
> the whole event (only 140 bytes).
> Thanks for your help!                                                                             
> 
> 
>         Gruss/greetings/A bientot!
>   
>                          Ursula
> 
> *************************************************************
>                                                 Ursula Berthon
>                                       E-mail  berthon@in2p3.fr
>                                     Tel. 33 - 1 - 69 33 31 21
>                                     Fax  33 - 1 - 69 33 30 02
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:35 MET