Re: [ROOT] Writing a TF2

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Jul 19 2001 - 19:16:57 MEST


Hi Otto, Jan,

You are both right. The functionality to save the TF2 information was only
inplemented for TF2s created with inline expressions.
I have now upgraded TF2 to behave like TF1. It is possible to save TF1 or TF2
objects even when they are created with interpreted functions or compiled
functions.
Below is the log I put in CVS describing the enhancement.

When a TF2 was created with an interpreted or compiled function,
it was not possible to save the TF2 object in a file and read it
in a separate program because TF2 does not save the code of the
interpreted function. Only TF2s created with inline expressions
could be paint in a separate session.
In TF1, we already had the logic to save an array fSave with
the function values created at fNpx points. TF2 has been modified
to provide the same functionality. One can save a TF2 and draw it 
again in a new session.
To implement this feature, the signature of the function TF1::Save
has been modified to be general for 1,2 and 3-d functions.
The classes TH1 and TGraph where TF1::Save was called have been
modified accordingly.


Rene Brun

Otto.Schaile@Physik.uni-muenchen.de wrote:
> 
> On Thu, 19 Jul 2001, Jan Olzem wrote:
> 
> > I would like to write a TF2 to a root file, but the Write() method uses to
> > fail. However, from a former root talk message I know how to save the TF2
> > histograms, but is there any possibility to stream the TF2 object itself
> > to a file?
> 
> Hi Jan,
> writing TF2 works( what are your error messages?):
> take this little macro:
> {
>    TF2 *f2 = new TF2("f2","x**2 + y**2 - x**3 -8*x*y**4",-1,1.2,-1.5,1.5);
>    TFile outf("test_tf2.root","RECREATE");
>    f2->Write();
>    outf.Close();
>    delete f2;
> //  now read it back
>    TFile outf("test_tf2.root");
>    outf.ls();
>    f2 = (TF2*)outf->Get("f2");
>    f2->Draw("lego");
> }
> Cheers
> Otto
> 
> Otto Schaile            Sektion Physik, LMU Muenchen
> Phone: +49 89 289 14070     Am Coulombwall 1, D-85748 Garching, Germany
> GSM:   +49 160 1553598
> FAX:   +49 89 289 14072     EMail: Otto.Schaile@Physik.Uni-Muenchen.DE



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:52 MET