# Reading leaf from a tree

**URL:** <https://root-forum.cern.ch/t/reading-leaf-from-a-tree/51061>\
**Category:** Newbie\
**Created:** [August 4, 2022, 10:22am UTC](https://root-forum.cern.ch/t/reading-leaf-from-a-tree/51061 "2022-08-04T10:22:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramin](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/71e660/32.png) [@Ramin](https://root-forum.cern.ch/u/Ramin)\
**Post date:** [August 4, 2022, 10:22am UTC](https://root-forum.cern.ch/t/reading-leaf-from-a-tree/51061/1 "2022-08-04T10:22:42Z")

</div>

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:

```auto
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

* * *

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [August 4, 2022, 1:02pm UTC](https://root-forum.cern.ch/t/reading-leaf-from-a-tree/51061/2 "2022-08-04T13:02:35Z")

</div>

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:

> **[Trees](https://root.cern/manual/trees/#reading-a-tree)**
>
> Data Analysis Framework

---

<div class="post-metadata">

**Author:** ![Ramin](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/71e660/32.png) [@Ramin](https://root-forum.cern.ch/u/Ramin)\
**Post date:** [August 23, 2022, 8:50am UTC](https://root-forum.cern.ch/t/reading-leaf-from-a-tree/51061/3 "2022-08-23T08:50:23Z")

</div>

Hello etejedor,

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

With kind regards,  
Ramin
