Re: How to extract the values of a variable in ntuple ?

From: Patois Yannick (patois@ganil.fr)
Date: Sat Feb 12 2000 - 13:55:37 MET


Hi,

As far as I understand ROOT, the easiest way would be to create your
'file 2' automatically, using the TNtuple method 'MakeClass'.

So create your root file with the ntuple, then use an interactive
session of ROOT to open it (easy to do if using the TBrowser, just type
 TBrowser b; on the prompt). Then type si_en->MakeClass("file2"). It
will create a file2.h and a file2.C file that will contain code for a
basic loop on the NTuple events. You can then enhance this basic code
with whatever you need.

You can have examples of what you'r asking for (and many more) on the
root web site.
In the Tutorial section (http://root.cern.ch/root/Tutorials.html and
HOWTO section (http://root.cern.ch/root/Howto.html).

But that's right that those one seems quitte complex when you start from
scratch.

	Yannick

 _/ Yannick Patois _________________ Address (home) __________________
| irc(undernet): Garp on #france25+ | La Villa des Sciences            |
| email : patois@ganil.fr           | 12, avenue de Cambridge          |
| web :http://www.sura.org/~patois/ | 14200 Herouville-Saint-Clair     |
| Tel/Fax-home:+33 (0)2 31 94 50 32 | FRANCE                           |
|___________________________________|__________________________________|


On Fri, 11 Feb 2000, Jayoung Wu wrote:

> Hi,
> 
> In file1, I created a ntuple "si_en":
>    TFile *ntfile = new TFile("Science.root","RECREATE","ATIC SCIENCE NTUPLE",2);
>    TNtuple *si_en = new TNtuple("si_en","SI ENERGY","inx:iny:ed");
> 
> In file 2, I want to extract the values of ed in si_en one by one:
>   char s1[80],s2[80];
>   Int_t i,j;
>   TCanvas *can;
>   TFile *ntfile = new TFile("Science.root");
>   gStyle->SetOptStat(1);
>   TNtuple *nt;
> 
>   nt = (TNtuple*)ntfile->Get("si_en");
> 
>   for( i=0 ; i<12 ; i++ ){  
>      for( j=8 ; j<48 ; j++ ){
>   ???
> 
>        How can I extract the values of inx, iny, and ed of ntuple, si_en
>        one by one?
> ---
> Thanks,
> Jayoung
> 
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET