[ROOT] TNtuple reading

From: Tommaso Chiarusi (Tommaso.Chiarusi@bo.infn.it)
Date: Sun Aug 05 2001 - 19:11:51 MEST


Hello rooters,

According to the userguide, I wrote the following:
Note:
1. "vario.root" is the root file in which I have stored my ntuple.
2. "front" is the name of my ntuple (in "vario.root" there are many
other ntuples!).
3. "p" is the variable that I want to plot. ("p" is either the name of
the TLeaf inside the ntuple "front" and of the variable the histogram I
fill with)

The problem I get is that I actually do NOT Get the Entry value, but
something like 5.30784e-315!!!!!

Thank you very much!



void plot()
{      
gROOT->Reset();
 
 TFile *f = new TFile("vario.root");
 TNtuple *nf = (TNtuple*)f->Get("front");

 
 Int_t entries = (Int_t)nf->GetEntries();
 cout<<"Number of Entries: "<<entries<< endl;

 
 Double_t p=0;
 nf->SetBranchAddress("p",&p);

 TH1F *htp = new TH1F("htp","p",100,0,10);


for (Int_t ki=1;ki<entries;ki++)
{
  nf->GetEntry(ki);
  htp->Fill(p);
}

TCanvas *c1 = new TCanvas("c1", "c1",515,210,540,376);
c1->Draw();
htp->Draw();

//
}

Tommaso



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:56 MET