Reading NTuple from file

Wouter Hulsbergen (s37@nikhef.nl)
Mon, 2 Jun 1997 17:37:42 +0200 (MET DST)


In my (hera-b) analysis code I define a file, a histogram and an ntuple:

TROOT simple("simple","Test of histogramming and I/O");
TFile hfile("hsimple.root","RECREATE","Demo ROOT file with histograms");
TH1F *B0Mass = new TH1F("B0Mass","This is B0 mass distribution",500,0,500);
TNtuple *eventuple = new TNtuple("eventuple","Ntuple of B0Gold events",
"B0px:B0py:B0pz");

which I fill on eventbasis with

B0Mass->Fill(M);
eventuple->Fill(B0px,B0py,B0pz) ;

and somewhere at program termination apply

hfile.Write();
hfile.Close();

Then I start root and read the file:

Hfile f("hsimple.root")

Plotting the histogram is easy:

TH1F histo = f.Get("B0Mass");
histo.Draw() ;

Then I create an Ntuple:

TNtuple nt = f.Get("eventuple");

and indeed nt.GetEntries() returns the number of events in "eventuple".
But even after studying the tutorials etc I don't understand how to
plot f.e. "px:py". How should I use `GetEvent' and where do I define the
ntuple floats `px,py,pz'?

Wouter Hulsbergen