Hi Jayoung, If I understand correctly your question, you simply want to store the energy deposition in an array of devices. I assume that your array has a constant size in x and y. In this is the case, you should not store the I and J values. You store the two D array. Here is an example. You can add asmany branches as you want. To run it, do: Root > .L array.C Root > fillarray() Root > readarray() Rene Brun //----------file array.C void fillarray() { TFile f("test.root","recreate"); TTree T("T","a simple test with an array"); Float_t ed[12][48]; T.Branch("ed",ed,"ed[12][48]/F"); //loop on some events for (Int_t ev=0;ev<100;ev++) { for (Int_t i=0;i<12;i++) { for (Int_t j=0;j<48;j++) { ed[i][j] = gRandom->Gaus(i,j); } } T.Fill(); } T.Write(); } void readarray() { TFile *f = new TFile("test.root"); TTree *T = (TTree*)f->Get("T"); Float_t ed[12][48]; T->SetBranchAddress("ed",ed); //read events TH1F *hed = new TH1F("hed","ed values",100,-100,100); Int_t nevents = Int_t(T->GetEntries()); for (Int_t ev=0;ev<nevents;ev++) { T->GetEntry(ev); for (Int_t i=0;i<12;i++) { for (Int_t j=0;j<48;j++) { hed->Fill(ed[i][j]); } } } hed->Draw(); } 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