Re: [ROOT] GetEntries() problem

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Apr 19 2000 - 11:23:35 MEST


Hi Thorsten,

I assume that you run in split mode.
When reading the event in this mode, the number of entries in the array
is not updated. You must do yourself:
     event.GetTracks()->Clear()
before reading a new event.
I have fixed the problem in the coming 2.24/03.

Rene Brun


thorsten glebe wrote:
> 
> Hello,
> 
> running the Event-example from the test subdirectory of the ROOT release,
> I observed that I am not able to get always the correct number of tracks
> in the TClonesArray via the GetEntries() function.
> 
> What I did was (using root 2.23.10):
> 
> root [0] .x eventload.cxx
> root [1]  TFile f("Event.root");
> root [2]  TTree *T = (TTree*)f.Get("T");
> root [3]  Event *event = new Event();
> root [4]  T->SetBranchAddress("event", &event);
> root [5]  T->GetEntry(0)
> root [6]  event.GetTracks().GetEntries()
> (Int_t)594
> root [7]  T->GetEntry(5)
> root [8]  event.GetTracks().GetEntries()
> (Int_t)610
> root [9]  T->GetEntry(0)
> root [10] event.GetTracks().GetEntries()
> (Int_t)610
> 
> I expected to get again 594. GetLast() and GetEntriesFast() behaved better:
> 
> root [11] event.GetTracks().GetLast()
> (Int_t)593
> root [12] event.GetTracks().GetEntriesFast()
> (Int_t)594
> 
> So my question is: what is the correct way to retrieve the number of entries
> in a TClonesArray/TObjectArray?
> 
> BTW: does anybody know how to use namespaces together with the
> ClassDef/ClassImp macros?
> 
> Goodbye,
>   Thorsten
> 
> ----------------------------------------------------
> Dr. Thorsten Glebe    <Thorsten.Glebe@mpi-hd.mpg.de>
> 
>         Max-Planck-Institut fuer Kernphysik
> 
> Saupfercheckweg 1                 Tel: 06221/516-631
> D-69117 Heidelberg                Fax: 06221/516-603
> ----------------------------------------------------



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