Struggling with reading from TTree

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:

"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:

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);
}

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

SetBranchAddress
----------ˆˆ
1 Like

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