Dear rooters, I have a problem with the representation of a fitted function to TGraph. I use a code which boils down to the following macro: macro tgraph.C: ==================================================================== #if !defined( __CINT__ ) || defined( __MAKECINT__ ) #include "TGraph.h" #include "TF1.h" #include "TMath.h" #endif Double_t sine(Double_t *x, Double_t *par) { return par[0]*TMath::Sin(par[1]*x[0]); } TF1* getFunction() { TF1* func = new TF1("sine",sine,0,7,2); return func; } Bool_t tgraph() { Double_t x[5] = {0,1.57,3.14,4.71,6.24}; Double_t y[5] = {0,1,0,-1,0}; TGraph* graph = new TGraph(5, x, y); graph->SetMarkerStyle(8); graph->Draw("ap"); Double_t par[2] = {1,1}; TF1* func2 = getFunction(); // <--- causes the problem TF1* func = getFunction(); func->SetParameters(par); graph->Fit(func); return true; } ==================================================================== The result of this macro is okay if I interpret it in root (i.e. .x tgraph.C), but if I compile it in root (i.e. .x tgraph.C+) I get the function plotted in fill mode (see attached gif file). None of the goption does affect the way it is plotted. The problem vanishes if I remove the line defining func2. I see this problem with root 3.05/07 and 3.10/01 on both Mac OS X and RH9, however it seems to be okay for root 3.02/07 on RH7.2. Thanks for your help. Cheers, Remi
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET