I have a TTree containing some parameters and time (actually unix time as Double_t).
I would like to sort the entries of the TTree in growing time and then save the sorted TTree.
The code below works fine but the “saving” part of the code takes about 1 hours to complete for a tree of 2M entries.
It sounds strange to me as it takes about O(minutes) to create the tree and 0(seconds) to create the sorted index.
Is my approach efficient ?
Thanks !
Code :
// TTree to be sorted, containing 2M entries, 35 branches (no arrays).
TTree *t_raw…
// Create index on tunix branch (time)
Int_t nb_idx = t_raw->BuildIndex(“tunix”);
TTreeIndex att_index = (TTreeIndex)t_raw->GetTreeIndex();
TTree* t = (TTree*)t_raw->CloneTree(0);
t->SetName(“sorted”);
// Loop on t_raw entries and fill t
for( Long64_t i = 0; i < att_index->GetN(); i++ ) {
t_raw->GetEntry( att_index->GetIndex()[i] );
t->Fill();
}
t->Write();