TTree returns incorrect number of entries

Hi there,

I am trying to read entries stored in a TTree within a root file. The structure is a number of folders, within each one is a TTree with several branches, and I am trying to access the leaf values of a specific branch. I created the file, and I can see when I look into it that each leaf of the TTrees I am calling is populated with a number of entries greater than 1. However, when I try to access the Trees, the number of entries is always returned as 1 (this is also seen when I try to print the TTree - the name of each branch is there as expected, but they all say Entries: 1), and the value of all these entries is 0. The code I am running to try to read the Trees is:

TTree* clustTree = (TTree*) fClusts->Get(Form("Event%i/fTreeR",nevent));
TBranch* clustBranch = clustTree->GetBranch("ClusterBranch");

The variable nevent is an input to the code, I have confirmed that the folder being called exists within the original root file. The Both clustTree→GetEntries() and clustBranch→GetEntries() return 1, regardless of the folder I call, while in the file each folder’s Tree usually has between 10 and 50 entries. Any advice is much appreciated, thank you in advance!


ROOT Version: 6.32.06
Platform: MacOS


Can you post the output of printing the tree (clustTree->Print())? Maybe it is indeed one entry (one event) but it’s an array or a vector, and all the “entries” that you see are just elements of that one entry.

Hi @dastudillo, thank you so much for the help! After a closer look at the Print output and some experimentation I see that it is something to do with how the entries are being stored, and I have found a way to access everything now.