Reading leaf from a tree

Hi, all.

I am trying to read a leaf from a tree (I would like to get data from @size leaf), but without any progress so far.
I have tried the following code:

void treereader2()
{
	TFile *f = TFile::Open("bmndst4700_BMNHF_BMNTF.root");
	TTree *bmndata = (TTree*)f->Get("bmndata");
	bmndata->SetMakeClass(1);

	Float_t track_amount[209723];
	TBranch *tr_a = bmndata->GetBranch("BmnGlobalTrack@.GetEntries()");
	tr_a->SetAddress(track_amount);
	Int_t nevent = (Int_t)bmndata->GetEntries();
	for (Int_t i=0;i<nevent;i++) {
	tr_a->GetEntry(i);
	printf("Amount of tracks:",track_amount[i]);
	}

}

Any help would be appreciated.
With kind regards,
Ramin

_ROOT Version: 6.26/02
_Platform: Linux 3.10.0-1062.12.1.el7.x86_64
_Compiler: Red Hat 4.8.5-39


Hello,

The problem might be the name of the leaf you are passing to GetBranch? How is the leaf called? To find it out, you can do bmndata->Print().

Here’s a link to the docs in case it can help:

Hello etejedor,

I have tried something similar and it works. Thanks for your help.

With kind regards,
Ramin