Revision 6bef5d95c9c192b6cb1ddcb0cc19ca28e897739d authored by Rene Brun on 06 April 2005, 15:56:14 UTC, committed by Rene Brun on 06 April 2005, 15:56:14 UTC
Template implementation should be in header files (especially when the
template class contains a ClassDef).


git-svn-id: http://root.cern.ch/svn/root/trunk@11511 27541ba8-7e3a-0410-8455-c3a389f83636
1 parent 854d6f8
Raw File
copytree.C
{
// Example of Root macro to copy a subset of a Tree to a new Tree
// The input file has been generated by the program in $ROOTSYS/test/Event
// with   Event 1000 1 1 1

   gROOT->Reset();
   gSystem->Load("$ROOTSYS/test/libEvent");

   //Get old file, old tree and set top branch address
   TFile *oldfile = new TFile("$ROOTSYS/test/Event.root");
   TTree *oldtree = (TTree*)oldfile->Get("T");
   Event *event   = new Event();
   oldtree->SetBranchAddress("event",&event);
   oldtree->SetBranchStatus("*",0);
   oldtree->SetBranchStatus("event",1);
   oldtree->SetBranchStatus("fNtrack",1);
   oldtree->SetBranchStatus("fNseg",1);
   oldtree->SetBranchStatus("fH",1);

   //Create a new file + a clone of old tree in new file
   TFile *newfile = new TFile("small.root","recreate");
   TTree *newtree = oldtree->CloneTree();

   newtree->Print();
   newfile->Write();
   delete oldfile;
   delete newfile;
}
back to top