Re: different trees to different files

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Oct 07 1998 - 08:15:36 MEST


Horst Goeringer wrote:
> 
> Hi,
> 
> can I fill  independent trees in one analysis and
> write them to different files?
> Must I use TBranch::SetFile()  ?  I cannot find a
> TTree::SetFile() or similar!
> 

Hi Horst,
When you create a TTree, this object is assigned by default
to the current directory/file. You can fill a TTree without
changing the current directory. At the end of the process,
you must save the TTree header in the file where it was
initially created. Example with 2 TTrees:
  TFile f1("f1.root","recreate");
  TTree tree1("tree1",..);
  TFile f2("f2.root","recreate");
  TTree tree2("tree2"..)
...
   //loop on events
  f1.Fill();
  f2.Fill();
...
  //end of process
  f1.cd();
  tree1.Write();
  f1.Close();
  f2.cd();
  tree2.Write();
  f2.Close();

Assuming one TTree, you can write branches of this Tree
to different files via TBranch::SetFile

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET