Re: TGraph::fFunctions points nothing?

From: aihong@cnr2.kent.edu
Date: Fri Aug 27 1999 - 16:31:07 MEST


Thanks, Rene.

You are right. But what if we do not know the true number
of effective points when we construct the Graph? (and that is the case
in my code, the macro I provided does not show that clearly.) 

Actually if we add option "N" (do not keep fit functions ) when call
TGraph::Fit(), the crash can be avoided. This is a solution, but not a
good solution.


Best Regards.

Aihong



On Fri, 27 Aug 1999, Rene Brun wrote:

> Hello Aihong,
> Replace your statement:
>   TGraph *gr=new TGraph();
> by
>   TGraph *gr=new TGraph(6);
> Also note that the point numbering should start at 0, not 1
> In my development version, I have protected TGraph::Fit in case the
> graph
> object was created via the default constructor.
> Always specify the true number of effective points in the TGraph
> constructor.
> This is much more efficient. It avoids two arrays relocation for every
> SetPoint.
> 
> Rene Brun
> 
> 
> aihong@cnr2.kent.edu wrote:
> > 
> > Hi,
> > 
> > I got an error when using TGraph::Fit().the error message is the
> > following:
> > 
> > -------------------------------
> > 
> > signal SEGV (no mapping at the fault address) in TGraph::Fit at line 676
> > in file "G_Graph.cxx"
> >   676         if (!Foption.Plus) fFunctions->Delete();
> > (dbx) print fFunctions
> > fFunctions = (nil)
> > 
> > ----------------------------------
> > 
> > It seems that fFunctions points to nothing.
> > To reproduce the error, try to run the following macro:
> > 
> > fittest (){
> > 
> > TF1 *myfit = new TF1("myfit","[0]*sin(x) + [1]*exp(-[2]*x)", 0, 2);
> > 
> > myfit->SetParName(0,"c0");
> > myfit->SetParName(1,"c1");
> > myfit->SetParName(2,"slope");
> > myfit->SetParameter(0, 1);
> > myfit->SetParameter(1, 0.05);
> > myfit->SetParameter(2, 0.2);
> > 
> >   TGraph *gr=new TGraph;
> >   gr->SetPoint(1,0.4,0.45);
> >   gr->SetPoint(2,0.8,0.74);
> >   gr->SetPoint(3,1.2,0.97);
> >   gr->SetPoint(4,1.6,1.035);
> >   gr->SetPoint(5,1.4,1.02);
> > 
> >   gr->Fit("myfit","R");
> > }
> > 
> > Is there any solution for this ?
> > 
> > I will appreciate any help. Thanks.
> > Best Regards.
> > 
> > Aihong
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:38 MET