# Struggling with reading from TTree

**URL:** <https://root-forum.cern.ch/t/struggling-with-reading-from-ttree/32057>\
**Category:** Newbie\
**Tags:** tree\
**Created:** [December 18, 2018, 4:18pm UTC](https://root-forum.cern.ch/t/struggling-with-reading-from-ttree/32057 "2018-12-18T16:18:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerom](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jerom/32/17652_2.png) [@Jerom](https://root-forum.cern.ch/u/Jerom)\
**Post date:** [December 18, 2018, 4:18pm UTC](https://root-forum.cern.ch/t/struggling-with-reading-from-ttree/32057/1 "2018-12-18T16:18:09Z")

</div>

Hello,

I’m trying to read a TTree file with four branches. However when implementing the code analogous to how it is done in some of the simple Tree examples, it gives an error message when setting the Branch address:

```auto
"Error: Can't call TTree::SetBranchAdress("edep",&edep) in current scope C:\Users\Jerom\pixelanalysis.cpp(22)
Possible candidates are... 
(in TTree)"

```

I tried to search for this error message but couldn’t find any clues. Below is the code that I am using:

```auto
void pixelanalysis()
{
    TFile *my_file = new TFile("B4Grid.root");
    TTree *my_tree = (TTree*)my_file->Get("B4Grid");

    Double_t edep,xpos,ypos,zpos;

    my_tree->SetBranchAdress("edep",&edep);
    my_tree->SetBranchAdress("xpos",&xpos);
    my_tree->SetBranchAdress("ypos",&ypos);
    my_tree->SetBranchAdress("zpos",&zpos);
}

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [December 18, 2018, 4:30pm UTC](https://root-forum.cern.ch/t/struggling-with-reading-from-ttree/32057/2 "2018-12-18T16:30:51Z")

</div>

you miss-spelled “Address” … it has 2 “d” …ie:

```auto
SetBranchAddress
----------ˆˆ

```

---

<div class="post-metadata">

**Author:** ![Jerom](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jerom/32/17652_2.png) [@Jerom](https://root-forum.cern.ch/u/Jerom)\
**Post date:** [December 18, 2018, 8:23pm UTC](https://root-forum.cern.ch/t/struggling-with-reading-from-ttree/32057/3 "2018-12-18T20:23:42Z")

</div>

Thank you so much, I was already thinking I had gone crazy, turns out I just can’t spell to save my life.
