Get number of entries in a branch

Hey guys,

I am using GEANT4 and in my generated root file (after running a simulation) I have a ROOT tree with branches corresponding to each of the sensitive volumes in my detector. Each of these branches has a set of leaves that correspond to specific values recorded for each “hit” the detector sees.

Now, in addition to the branches I also have a series of leaves that correspond different variables that get recorded regardless of whether my detector records a “hit”.

For example, say I run the simulation with 3000 events, all of the leaves (excluding the leaves that are a result of “hits” in my detector) contain 3000 different entries. However, each of my branches that correspond to the different volumes of my detector only record “hits” and as a result, each of the leaves will only store as many entries as there are actual “hits” in the simulation. For instance, even though I ran 3000 events in the simulation, one sensitive volume may only record 12 of those 3000 events and therefore the leaves for that volume will only contain 12 entries.

What I want to do is get the number of entries for the leaves corresponding to each branch. The only issue is that whenever I try getting the number of entries, the result is always 3000 which doesn’t make sense. For instance, from the histograms generated, I can see that a leaf part of one of the branches only saw 12 entries but every time I try to get the number of entires I always get 3000.

Does anyone know how to do this?

Thank you!

Try:

$root -l FileName.root
[0] TreeName->Draw(“NameOfLeaf”, “”,“goff”)

A.