Re: TF2 and I/O

Rene Brun (Rene.Brun@cern.ch)
Fri, 14 May 1999 16:37:33 +0200 (METDST)


Hi Peter,
You can save the histogram used to paint the function with:
f2->GetHistogram()->Write();
The name of the key will be the name of the function. You can
give a new name to the key with
f2->GetHistogram()->Write(newName);
When you fit a histogram with a TF1, TH1::Fit compute the value of the
function at the center of a bin in case of a function defined
with the interpreter or compiler
When reading a TF1 object back from a file, the definition of the
original function is not necessary. If this definition is missing,
Root will use the values computed at the center of each bin.
This feature is not implemented for TF2.

Rene Brun

On Thu,
13 May 1999, Peter M. Jacobs wrote:

> Daer Roottalk,
>
> I have a TF2 that I evaluate with several different sets of parameters
> within a macro. I would like to write to a root file a histogram of this
> function for each of these parameter sets, in order to read them in and
> plot them in a different macro. Plotting them within the original macro
> can be done via TF2::DrawCopy. How do I address these histograms in
> order to write them out?
>
> I naively tried to shortcircuit the hitsogramming by trying to use the
> Write method on my TF2, i.e.
>
> TF2 *f2 = new TF2 (.....)
> ....
> f2->Write();
>
> f2 is written to the root file, but when I open the file and do
> f2->Draw(), the resulting histogram is empty. (This technique works for
> TF1, by the way, in contrast to TF2.)
>
> Thanks,
>
> Peter Jacobs,
> LBNL
>