See comments in the code below Rene Brun void NtupleRead() { //open the Tree file and read the Tree headers TFile f1 = ("enw.root","READ"); TTree *T1 = (TTree*)f1.Get("T1"); TTree *T2 = (TTree*)f1.Get("T2"); //open the output file. Becomes the current dir. //Newly created histograms will be automatically added to it TFile f("test.root","RECREATE"); cHist = new TCanvas("cHist","Canvas 1",100,100,800,800); cHist->Divide(2,2); cHist->cd(1); T1->Draw("fEvis>>hEvis"); cHist->cd(2); T1->Draw("fPt>>hPt"); cHist->cd(3); T2->Draw("fPl>>hPl"); cHist->cd(4); T2->Draw("fNchg>>hNchg"); f.Write(); } On Sat, 5 Jan 2002, Dennis C. Arrogancia wrote: > > > Dear ROOTERS, > > > I have a little problem regarding reading ntuples. I have a code below, > I have a file which contains 2 ntuples "T1" and "T2". Since i want to draw > thw data in a desired range, i place it in histograms. The histograms > below are already initialized. My problem is how to save the result in a > file where i can view the histograms one by one. What should be added in > the code below to save the result in a file? I tried creating a file but > its empty. What's wrong with the code below? > > > void NtupleRead() > { > > f = new TFile("test.root","RECREATE"); > > f1 = new TFile("enw.root","READ"); > f1.cd(); > > cHist = new TCanvas("cHist","Canvas 1",100,100,800,800); > cHist->Divide(2,2); > > cHist->cd(1); T1.Draw("fEvis>>hEvis"); > cHist->cd(2); T1.Draw("fPt>>hPt"); > cHist->cd(3); T2.Draw("fPl>>hPl"); > cHist->cd(4); T2.Draw("fNchg>>hNchg"); > cHist->Update(); > > f.Write(); > > } > > > > > Dennis Arogancia > MSU-IIT >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET