Number of Processed events


is there an easy way to check the number of processed events from terminal for a branch taken from already existing ntuple (.root file) ? For example, if I have a branch named “Muon_pt” and I would like to know how many events are there in total.


There is this way:

int n = your_tree->Project("h","Muon_pt","some_selection_on_Muon_pt");

n should be what you are looking for.
May be some other ways are possible also.

Thanks for your reply. Like this I get exactly what is written in “Entries” , is number of Events and Entries the same?

If you add a selection you will get the number of event passing the selection.

1 Like

Thank you for your help!

Dear @couet ,
Do you happen to know why the results I get are different when I count number of events manually (with output in the terminal, with std::cout << " ... " << std::endl;) and when I do as suggested with Events->Project("h", "Muon_pt", "Muon_pt>25") ? I get much less number of events when checking them with “Project”.

Try: Events->Scan("Muon_pt", "Muon_pt>25")

Not exactly. An event may have many muons, this depends on the structure of your ntuple. Consider you have just two events: one with 5 muons, another one with 3 muons. This is two events but 5+3=8 entries.

Regarding the

, can you show exactly how you


Hi @yus!

So, what I am doing is something like this:
for(int i = 0 ; i<nMuon; i++){
if(Muon_pt[i]>25) {
std::cout << " muon pt " << std::endl;
hist->Fill(Muon_pt[i]); }
Now, I expect that the frequency of “muon pt” as an output (let’s say I will have 10 “muon pt” outputs in the terminal from “cout”) should be the same as number of entries. However when I checked with Events->Project("Muon_pt", "Muon_pt>25") as well as with Events->Project("h","Muon_pt","Muon_pt>25") , the number I got was much smaller than 10. And I am trying to understand why.

Try: std::cout << h->GetEntries() << std:;endl;

Hello @Wile_E_Coyote ,
It works like this, however I am trying to understand what is the difference between what I described for @yus

It has explicitly been explained in his post.