Syntax question


I can’t get info for SetAddress. I have included a few lines from some code I’m reverse engineering. I think I know but could someone tell me what SetAddress is doing?


TFile *f = new TFile(“svx_hits.root”); //open svx_hits.root, f is the pointer

TTree tree = (TTree)f.Get(“svxhits”); //open a part of the root file as a tree

float Bzver;

TLeaf *leafzver = tree->GetLeaf(“zver”);


Hi Harry,
when root reads a file it doesn’t know where to put its data to; you’ll have to tell root where you want it. That’s what SetAddress is for: it instructs root to put the data of a certain branch or leaf into a certain address block, starting at the pointer which you pass to SetAddress. In you case it tells root to put the value of a leaf called “zver” in the tree “svxhits” into your variable Bzver when reading a tree entry. I’m positive this shows up in the users guide - it’s really worth a look!

hi axel,

i read the manual very carefully, ask Ilka

see you,

hi again axel,

my question was just a little more subtle. i am trying to get the “feel” of object oriented programming and i wanted to be absolutely certain that I got it right, the object.method() syntax has slowly sunk in.

plus i always read manuals, plus Ilka asked me to point out concerns about the manual, i tried rreally hard to find my answer there first, i do appreciate all of the effort that went into the manual. you guys have been so helpful and i am trying to help back if i can


Hi Harry and Axel,

The examples given in the User’s Guide with SetAddress() method are related to TBranch and TChain classes. There is no example given with TLeaf (or any of derived classes TLeafB, TLeafC, etc.). There could be some example in the $ROOTSYS/tutorials directory but I can check this on Monday.

Cheers, Ilka

Just to complete my answer: I did not find an example with SetAddress() and some of TLeaf… classes.

Cheers, Ilka

Users should call only

TLeaf::setAddress is called internally by the above functions.