TChain problem with TTreeIndex

Hi,

I’m trying to build TChains of files indexed using TTimeStamps (using ROOT 5.34/12). Then I’d like to search the TChain using GetEntryNumberWithBestIndex. The problem is that GetEntryNumberWithBestIndex returns -1 for entries that are at the TTree “borders” in the TChain.

Attached is a simple class and 2 macros. simple.C defines the class. testChain.cxx creates 3 root files each containing a tree filled with the simple class. testChainAnal.cxx then reads in the 3 files, creates a TChain of them and uses GetEntryNumberWithBestIndex to search for some entries.

To run the programs do the following on the command line after copying the attachments

root -b -q testChain.cxx
root -b -q testChainAnal.cxx

The last program should output the following:

  1. Why do we need to call BuildIndex on the chain when indices are built for for the individual trees?

  2. Why does GetEntryNumberWithBestIndex return -1 when searching for (1387541045, 0) and (1387541395, 0)? These values are between 2 valid indices in the chain. Should not en = 4 for those 2 indices?
    testChainAnal.cxx (1.44 KB)
    testChain.cxx (609 Bytes)
    simple.C (214 Bytes)