How to locate a value in TTree and get the entry number back

it is actually a very simple issue, but I can’t solve it yet.
I have written a very big tree (c.a 2GB ). And my plan is to cut a certain interval from the tree, for example between 4.0 and 5.0. So I have to locate the begin of this interval. I wanted to locate the value 4.0 in the tree by iterating the whole tree entries. But it is very time consuming to repeat this procedure for lots of times. So the question is: is there such a method, with which I can just locate the entry 4.0 and get the entry number? It will be fatally helpful for me!
Thanks in advance


a 2GB tree is a small tree. If the Tree is well structured, ie the variable on which you select has its on branch, a pass on the Tree should be very fast. You should give more details
-about your tree (eg post the result of TTree::Print)
-indicate how you loop on your Tree
-see doc of TEventList and TEntrylist with examples