Re: storing basic variables

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 12 Jan 2005 09:49:20 +0100


Hi Mario,

In Root version 4.02 we introduced the possibility to save one or more objects independent from the Tree entries in a TList in the TTree header. Suppose you have an object (must derive from TObject), eg a TVectorD, a TGraph, a TH1, your own class, etc , eg a TH1* h   tree->GetUserInfo()->Add(h);
  tree->Write();

the object h will be saved with the Tree header. When reading back the Tree, you can again access your object, eg   TH1 *h = (TH1*)tree->GetUserInfo()->FindObject(objectname)

Using the GetUserInfo() is a better alternative than deriving your own class from TTree. You can still read the Tree with teh standard ROOT without having the class deriving from TTree.

Note that another possibility is to store your own object(s) as TKey objects via myobject->Write() in the file.

Concerning Pythia, we already have an interface with Pythia. See the class TPythia6 and the example pythiaExample.C in the tutorials.

Rene brun

Mario Kadastik wrote:
>
> Hello,
>
> how do I store a Float_t variable in a root file? I thought on saving it
> in a tree, but that didn't quite work as it will have a copy of the
> value in every new row. What I basically want to do is that from pythia
> I store my interesting information in a histogram which I dump at the
> end to a .dat file which I then read in with root to create a root tree
> for pT, Eta, Phi and so on. What I would like to save in addition is the
> cross section of that process which is just one float per datafile.
>
> Ideas are welcome...
>
> Mario
>
> PS! any chance of filling data to root files directly from pythia?
Received on Wed Jan 12 2005 - 09:50:50 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:04 MET