# Reading Ttree from ROOT file

**URL:** <https://root-forum.cern.ch/t/reading-ttree-from-root-file/57923>\
**Category:** Newbie\
**Tags:** tree\
**Created:** [January 22, 2024, 11:15am UTC](https://root-forum.cern.ch/t/reading-ttree-from-root-file/57923 "2024-01-22T11:15:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![souvikc](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@souvikc](https://root-forum.cern.ch/u/souvikc)\
**Post date:** [January 22, 2024, 11:15am UTC](https://root-forum.cern.ch/t/reading-ttree-from-root-file/57923/1 "2024-01-22T11:15:45Z")

</div>

I want to read i\_th and j\_th entry from a Ttree using a for loop, for example:

```auto
for (Long64_t entryi = 0; entryi < tree_sig->GetEntries(); ++entryi) {
        tree_sig->GetEntry(entryi);
        entryj=4;
        tree_sig->GetEntry(entryj);
}

```

But this give me break segmentation error. Could you please help me.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [January 22, 2024, 11:50am UTC](https://root-forum.cern.ch/t/reading-ttree-from-root-file/57923/2 "2024-01-22T11:50:33Z")

</div>

First check: are you sure the tree has enough entries for the index you set by hand? (in this case, 5 entries, so that there is an entry number 4)
