Single float in TFile

Dear all,
how do we store a simple float (or double, or…) in a TFile?
I need this to add some information to a TTree.
Reading the following post:

root.cern.ch/root/roottalk/roottalk05/0075.html

it seems that only TObjects can be written via standard root classes. Should I write my own simple class deriving from a TObject and containing a float? Or can I just use TNamed using the float value as the “title” field? (sprintf)

Thank you for any suggestion
Luigi

Luigi,

You can use any existing class like TVector, TVectorD, TGraph
to store one or more float values. Then add this object to
tree.GetUserInfo().
You can also encode your float into a TNamed or TObjString or
implement your own class if you like. I strongly suggest to use
an existing ROOT class in such a way that your file can be read by any reader not having your class definition.

Rene

You can also use the TParameter class.

Philippe