in my tree I have a bunch of arrays that I created with
mytree->Branch(“Muon_N”,&Muon_N,“Muon_N/I”);
mytree->Branch(“Muon_E”,Muon_E,“Muon_N[Muon_N]/D”);
When I read my tree, I only load in single branches to speed up things. I randomly access my variables and it happens sometimes that I request (i.e. Branch->GetEntry) the Muon_E before I access Muon_N. In that case I end up with a Muon_E which is empty. If I reverse the order I get an non-empty Muon_E (if Muon_N>0).
So is there a way to obtain the “counting” variable (i.e. Muon_N) to get the corresponding entry before I actually access Muon_E?
Hi,
thank you, I knew it was something simple. Just one additional question, I am using PyRoot and I have to call l.GetLeafCounter(0) instead of l.GetLeafCounter(), does that make a difference?
Sorry I added an unfortunate typo and the simpliest code is actually:TBranch *b = mytree->GetBranch("Muon_E");
TLeaf *l = (TLeaf*)b->GetListOfLeaves()->At(0);
if (l->GetLeafCount()) {
l->GetLeafCount()->GetBranch()->GetEntry(entry);
}