I am unfortunately having trouble getting a meaningful result out of my attempts to sort a tree. When I use the technique described above on relatively small files (<50 entries), everything works great. However for somewhat larger files the sorting is clearly wrong. I am attaching two such example files.
The actual sorting procedure is the following (also attached):
{
std::cout<< "Entries:" << ptree->GetEntries()<< std::endl;
ptree->BuildIndex("time");
TTreeIndex *I=(TTreeIndex*)ptree->GetTreeIndex(); // get the tree index
Long64_t* index=I->GetIndex(); //create an array of entries in sorted order
TLeaf* time=ptree->GetBranch("event")->GetLeaf("time");
for (int i=0;i<ptree->GetEntries();i++){
ptree->GetEntry(index[i]);
std::cout <<time->GetValue() << std::endl; //print the (hopefully sorted) time
}
}
Just load the files into root, and run test.C. For good_file.root things come out perfectly sorted, for problem_file.root it’s clearly is not. Any clue as to what I am doing wrong?
problem_file.root (76 KB)
good_file.root (13.5 KB)
test.C (468 Bytes)