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:

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


You can use any existing class like TVector, TVectorD, TGraph
to store one or more float values. Then add this object to
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.


You can also use the TParameter class.