RE: TNtuple (or TTree?) and vector fill

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Wed, 17 Jan 2007 12:28:39 -0600


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

yes.

You should replace  

  tree->Write();

while   

  f->Write();

  // Or tree->GetDirectory()->GetFile()->Write();
  // if you TTree is so large that it triggers the creation of additional
  // file (See TTree::ChangeFile for details)

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Marco Calviani
Sent: Wednesday, January 10, 2007 10:04 AM To: Rene Brun; roottalk_at_pcroot.cern.ch
Subject: Re: [ROOT] TNtuple (or TTree?) and vector fill

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 17 2007 - 19:30:16 CET

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