Re: [ROOT] TTree Copy from one root-File to anotherone

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jul 12 2000 - 11:28:54 MEST


Hi Andreas,
To copy a Tree to another file, see tutorials examples at:

   http://root.cern.ch/root/html/examples/copytree.C.html
   http://root.cern.ch/root/html/examples/copytree2.C.html
   http://root.cern.ch/root/html/src/TTreePlayer.cxx.html#TTreePlayer:CopyTree


Rene Brun

Andreas Walte wrote:
> 
> Hi,
> 
> I got a problem copying one TTree from one root-File to another
> root-File. My macro for that looks as follows :
> 
> " #include "TTree.h"
> #include "TFile.h"
> void test()
> {
> gROOT->Reset();
> TFile * myfile = new TFile("$GD/data/galice.root");
> TTree *TreeR4999 = (TTree*)myfile->Get("TreeR4999");
> TreeR4999->Print();
> // the TTree contains data
> //TBranch *PHOS5GeV = TreeR4999->GetBranch("PHOS.fE");
> TFile *myfile2 = new TFile("$GD/data/galice_histogramme.root","CREATE");
> 
> TTree * TreeR5GeV = new TTree(*TreeR4999);
> TreeR5GeV->Print();
> // not empty
> myfile2->Write();
> myfile2->Close();
> myfile->Close() ;
>   }
> "
> 
> I did a .L test.C++ and test() , with test.C the name of the macro. So
> everything looked fine but when I try to browse the new file with
> TBrowser the file is completely empty.
> 
> Regards,
>     Andreas



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