You have two ways
way1:
=====
TFile f("r.root");
TNtuple* n = (TNtuple*) f.Get("test");
Int_t count = n->GetEntries();
Float_t* xy = n->GetArgs();
for(Int_t i = 0; i<count; i++) {
n->GetEntry(i);
Float_t x = xy[0];
Float_t y = xy[1];
Float_t z = x+y;
}
way2
====
TFile f("r.root");
TNtuple* n = (TNtuple*) f.Get("test");
Int_t count = n->GetEntries();
Float_t x,y;
n->SetBranchAddress("x",&x);
n->SetBranchAddress("y",&y);
for(Int_t i = 0; i<count; i++) {
n->GetEntry(i);
Float_t z = x+y;
}
see tutorials tree1.C, tree2.C, etc
Rene Brun
On Sat, 26 Jun 2004, Yang Ruizhe
wrote:
> Hi, ROOTers!
>
> I have a problem when reading .root file created by myself.
>
> For example, I have created a .root file called "r.root" storing a TNtuple("test","","x:y")
>
> In the next step, load it by
>
> TFile f("r.root");
> TNtuple* n = (TNtuple*) f.Get("test");
> Int_t count = n->GetEntries();
> for(Int_t i = 0; i<count; i++)
> {
> ??????
> }
>
> Then, if I want to read exactly the x and y value correspoding to the No. i entry, what should I do? I checked the source code for TNtuple and TTree but could not find the right member function to do this job.
>
> Thank you very much.
>
> Best Regards,
> Yang Ruizhe
>
> 2004.6.26.
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET