aregjan
1
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)?
brun
2
You can do
TBranch *br = tree.GetBranch("branchname");
br->GetEntry(entry number)
double value = br->GetValue();
Rene
aregjan
3
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]
brun
5
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
aregjan
6
I just arrived to the same solution. Thanks in any case!