Re: Simple Tree macro

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Feb 11 1999 - 16:58:08 MET


Hi Michal,
You had two problems with your macro.
- TTree::SetAutosave expects an integer as argument, not a string.

- You were using the wrong TTree::Branch function.

I have fixed the code below.

Rene Brun

lijowski@cosray2.wustl.edu wrote:
> 
>   Hello,
> 
>   Below is a simple macro I have a problem with on SunOS 5.5 Root v2.20/06
>   compiled under SunOS 5.4.
> 
>   First, it returns an error
> Error: Can't call TTree::SetAutoSave() in current scope FILE:/export/home/lijowski/ace/cris/flight/root/fits/./test_Tree.C LINE:17
> *** Interpreter error recovered ***
> 
> But when I comment this line, the macro crashes in line 26 with a message
> error in <TFile::TFile>; file does not exist.
> 
>  Am I missing anything?  Thank you for any hints.
> 
>  Regards
> 
>  Michal Lijowski
> 
> void test_Tree()
> {
>    gROOT -> Reset();
> 
>  // Create a new ROOT file to contain tree
> 
>    Int_t comp = 1;  // compress file
>    Int_t bufsize = 32000;
> 
>    TFile *tfile = new TFile("test_Tree.root", "recreate");
> // file is compressed
>    tfile -> SetCompressionLevel(comp);
> 
> // Create a new Tree with branches
> 
>    TTree *TT = new TTree("TT", "test tree");
>    TT -> SetAutoSave(1000000000); // autosave when 1 GB is written
> 
> // create branches
> 
>    Int_t EventNo = 0;
>    TBranch *br0  = TT -> Branch("EventNo", &EventNo, "EventNo/I",bufsize);
> 
>    for (EventNo = 0; EventNo < 10; EventNo++)  {
>       TT -> Fill();
>    }
>    tfile -> Write();
> }



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