Get the number of entries in a branch that are within certain restrictions

I was wondering if there was an easier way to get the number of entries within a tree that fit a certain restriction. For example, the name of my tree is “store” and I know that using the command


Will return the number of entries in the x_det branch with the restriction that x_det must be more than -100. But I need to do this many times in a loop, so drawing a graph every time is very inefficient.

_ROOT Version:6.14.06
_Platform: Linux
Compiler: Not Provided



printf("%lli entries satisfy the requirement\n", store->Scan("x_det", "x_det > -100"));

When I run this command it prints out a table telling me the value of each entry, and requires me to type CR to show more entries. My tree has 3*10^6 entries so this isn’t feasible.

Right, sorry. I was testing on a very tight selection, and only a handful of events survived the cut, so I didn’t see this effect. Please try this instead:

printf("%lli entries satisfy the requirement\n", store->GetEntries("x_det > -100"));
1 Like

That seemed to work, thank you!