Problem saving TF1 with general C function to file

From: Chris Roat <chris.roat_at_gmail.com>
Date: Fri, 25 Feb 2005 12:20:01 -0800


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 - 21:20:08 MET

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