TTree->GetEntry with a TTReeIndex is too slow


I did a TTreeIndex to ordinate the entries in a TTree, but when I call GetEntry using the order in the TTreeIndex the macro is very slow (it process about 500 event every 4 seconds)
It is possible to make it faster or the problem is that I should order the TTree when I fill it?

here there is the part of the code

for(Long64_t i = 0; i < index->GetN() - 1 ; i++ ) { gSystem->ProcessEvents(); Long64_t local = myTree->LoadTree( index->GetIndex()[i] ); myTree->GetEntry(local);

I noticed that is the call myTree->GetEntry(local) that slow down everything so much

Hi Antonio,

I am having the same problem… Have you found a solution to this problem?

Thank you and best regards,

nope, and I admit I do not remember how I worked on that problem at the end

Wow kudos to you for answering 4 years later!

@feliciasutanto you might want to open a new topic explaining your specific issue, other users might be able to help

Antonio- Thanks for your reply. I really appreciate it.
Eguiraud- Yep, will do :grinning:

Dear All,

It seems that reading TTree not sequentially (i.e., using TTreeIndex) leads to decompression issue…
This post solves the slow TTree random access problem:


Non-sequential reading of a tree forces many I/O to the disk, which of course will slow things down.

To avoid this, you should first read the tree fully into memory first (which I believe can be achieved by increasing the basket size).

Yep, Thanks Areg! It works!