Get value of an entry

Is there a method in TTree which returns the value for branch x for entry n?

Alternatively, is there a method in TBranch which returns the value for entry n?

If not, is there a simple way of doing this (besides doing scan/show, which simply print on the screen)?

You can do

TBranch *br = tree.GetBranch("branchname"); br->GetEntry(entry number) double value = br->GetValue();
Rene

Rene, here is the error that I get when I try that:

[code]
root [0] TFile *_file0 = TFile::Open(“source.root”)
root [1] TBranch *xpos=GeomInfo->GetBranch(“xpos”)
root [2] xpos->ls()
OBJ: TBranch xpos xpos/D : 0 at: 0x22ca8d0
root [3] double x=xpos->GetValue()
Error: Can’t call TBranch::GetValue() in current scope (tmpfile):1:
Possible candidates are…(in TBranch)
*** Interpreter error recovered ***
root [4]

It appears that there is no GetValue() method in TBranch.

p.s. I am using Root version 5.18.[/code]

I forgot to include

Still an error.

Sorry I made a mistake, Getvalue is in TLeaf, not TBranch. Do

TLeaf *xpos = GeomInfo->GetLeaf("xpos"); xpos->GetBranch()->GetEntry(entry number); xpos->GetValue();
Rene

I just arrived to the same solution. :slight_smile: Thanks in any case!