Re: GetEntries vs GetEntriesFast with TChain

From: Axel Naumann <axel_at_fnal.gov>
Date: Thu, 24 Feb 2005 17:32:56 -0600


Hi Dean,

see the doc on TChain::Add(const char *name, Long64_t nentries) at http://root.cern.ch/root/html/TChain#TChain:Add

       if (nentries == kBigNumber) (default), the file is not connected.
       the number of entries in each file will be read only when the file
       will need to be connected to read an entry.
       This option is the default and very efficient if one process
       the chain sequentially. Note that in case TChain::GetEntry(entry)
       is called and entry refers to an entry in the 3rd file, for example,
       this forces the Tree headers in the first and second file
       to be read to find the number of entries in these files.
       Note that if one calls TChain::GetEntriesFast() after having created
       a chain with this default, GetEntriesFast will return kBigNumber!
       TChain::GetEntries will force of the Tree headers in the chain to be
       read to read the number of entries in each Tree.

Axel.

--On 24.02.2005 16:44 -0600 Dean Andrew Hidas <dhidas_at_fnal.gov> wrote:

>
> Hi rooters!
>
> Say I have: TChain* chain = new TChain("whatever");
>
> I can use:
>
> chain->GetEntries()
>
> to get the correct number, but when I use
>
> chain->GetEntriesFast()
>
> it'll always gives me 1234567890. Why is this? I also notice that if I
> call GetEntries() first and then GetEntriesFast then GetEntriesFast will
> return the correct number. Anyway, I'd really like to use GetEntriesFast
> with my TChain if it's faster because on large datasets GetEntries can
> take a while... Here's the actual code that I'm compiling with gcc
> v3.3.1 and root "Version 4.00/03 24 March 2004":
>
> #include <iostream>
>
> #include "TChain.h"
>
> int main ()
> {
> TChain* chain = new TChain("Tree");
>
> chain->Add("file1.root");
> chain->Add("file2.root");
>
> std::cout << chain->GetEntriesFast() << std::endl; // returns bad
> number std::cout << chain->GetEntries() << std::endl; // returns good
> number std::cout << chain->GetEntriesFast() << std::endl; // returns
> good number
>
> return 0;
> }
>
>
> Thanks,
>
> -Dean
Received on Fri Feb 25 2005 - 00:33:04 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET