Re: Problem saving TF1 with general C function to file

From: Rene BRUN <brun_at_mail.cern.ch>
Date: Fri, 25 Feb 2005 23:18:44 +0100 (MET)


Hi Chris,

This is the expected behaviour.
In case of an interpreted or compiled function, the code of the function itself is not saved in the file. We save only the values of the function at fNpx points. You can increase the number of points via TF1::SetNpx

Rene Brun

On Fri, 25 Feb
2005, Chris Roat wrote:

> Hi,
>
> I find that a TF1 with a general C function does not give similar
> behaviour after it has been retreived from a file. The macro makes a
> plot showing the function before (left) and after (right) saving to a
> file. One bin on a boundary between to function regions seems to get
> a wrong value. In other more complicated 2D functions, I've seen
> large jumps in single rows at the edges of plots.
>
> I am running on debian and have seen the problem in both ROOT 4.02.00
> and 4.03.02.
>
> Cheers,
> Chris
>
> Double_t myfunc( Double_t *deps, Double_t *pars ) {
> return deps[0]<0.5 ? 0 : 1;
> }
>
> void test() {
>
> // create a simple 1d function
> TF1 *func= new TF1( "func", myfunc, 0,1, 0 );
>
> // open a canvas and divide it
> TCanvas *c1= new TCanvas;
> c1->Divide(2,1);
>
> // draw the function on the left half of canvas
> c1->cd(1);
> func->Draw("LEGO");
>
> // save the function to a file and close file
> TFile g( "test.root","RECREATE");
> func->Write();
> g.Close();
>
> // reopen file and plot the function saved in it
> TFile h("test.root");
> TF2 *func2= (TF2*)h.Get("func");
> c1->cd(2);
> func2->Draw("LEGO");
>
> }
>
Received on Fri Feb 25 2005 - 23:19:47 MET

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