Get the entry number


Our experiment uses the entry number as the event number in TTree.
For example, entry 5 is the 5-th event.

Is there any way I can get the entry number?

I draw some plot and make a graphical cut.
Here I need the entry numbers in the cut.

Thank you so much for your comments.


Search for “Entry$” in the TTree::Draw method description.

Thanks for the reply.

I tried that already and it gives histogram of entry number but not giving the entry number itself.
If I use Scan(“Entry$”, “CUTG”), it’ll show the entry number but I cannot save those number to file
or put them in a vector.

Is it possible?

Thank you.

I googled some and found this way.

I can just loop over all entry and check if it’s in the CUTG or not.
If you have any better idea, please let me know.

Thank you for your replay.

If you work with a TTree, maybe you could add a branch that stores the entry number.