Using TTreeIndex with expressions


I have a TTree with a branch named “time” which gives the time of an event in seconds. The type is double.

Now I would like to sort events by “time” using the TTreeIndex class. Here is what I did:

[code] // build index
TTreeIndex index = (TTreeIndex)eventtree->GetTreeIndex();
Long64_t N = index->GetN();

// loop over events
for(int t=0; t<N; t++){
As you can see I used the expression “time*1000000” to sort events at the level of the micro-second. However, this does not work. Events are not correctly sorted. What’s wrong with that? What should I do instead?
Thank you.

OK, something’s weird.

If I use the sorting criterion in minor instead of major:

It seems to work?! I have no idea why…


The index is calculated as: major<<31 + minor and stored in a Long64_t. So when using the major both the major and the minor needs to stays small enough to fit into a 32 bit integer (time*1000000 probably does not).