Re: TNtuple (or TTree?) and vector fill

From: Marco Calviani <marco.calviani_at_gmail.com>
Date: Wed, 10 Jan 2007 17:03:41 +0100


Thanks Rene,

   is it possible to keep the TTree open and do a Fill() for n loops and then at the end close the TTree?
Something like this:

int leggi()
  {

  TFile *f = new TFile("test.root","recreate");
  TTree *tree = new TTree("tree","example");
  tree->Branch("ampl",&ampl,"ampl");
  tree->Branch("time",&time,"time");

  for(int i=0; i>n; i++)
     {
       Float_t *ampl = new Float_t[];
       Float_t *time = new Float_t[];
       .......
       .......
       tree->Fill()
      }

  tree->Write();
  }

Will tree contain sequentially all the contents of the two vectors ampl and time?

Regards,
marco

On 1/10/07, Rene Brun <Rene.Brun_at_cern.ch> wrote:
> Marco,
>
> Use a TTree instead of TNtuple and proceed, for example, like in
> $ROOTSYS/tutorials/tree/tree2.C
> Make as many branches as you have vectors and call only
> mytree.Fill()
>
> Rene Brun
>
Received on Wed Jan 10 2007 - 17:10:21 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 17 2007 - 23:50:00 CET