Re: [ROOT] How to write the TTree in seperate file?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jun 23 2004 - 09:58:16 MEST


Use TTree::CloneTree, eg

TFile *f = new TFile("origin.root");
TTree *t = (TTree*)f->Get("t");
TFile *newfile = new TFile("newfile.root","recreate");
TTree *newt = t->CloneTree();
newt->Write();

see tutorials copytree.C, copytree2.C, copytree3.C

Rene Brun

On Tue, 22 Jun 2004, 
Datao Gong wrote:

> Hi,
> I have root file which contained several TTree. I want to separate them in 
> different files.
> So i try:
> TFile *f = new TFile("origin.root");
> TTree *t = h1; //h1 one of the Tree name
> f2 = new TFile("h1.root","RECREATE");
> t->Write();
> f2->Close();
> 
> But i found the h1.root is very small and do not contain all the 
> information of the origin Tree. Actually i did this before,
> but i can not find the right way do it now. Anyone can help
> me on this?
> 
> 
> Datao Gong
> 
> 
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET