Extracting parameters from fit function to use in main prog

Hello,

How do I extract fit parameters? I have a user defined function with 5 parameters

//In a fit.cxx file

double myformula( , )
{ code for formula }

double fitfunc(histoname, some more arguments)
{ code for fit.  In here I call myformula and set parameters and parameter names.}

//In main program which creates histogram
#include fit.cxx
{ code which fills and draws histogram,
  calls fitfunc, to fit histogram and draws fit }

Now on the ‘root’ shell, the parameters are printed out, but how can i extract these parameters?
Maybe declare an array in main funtion, pass into fitfunc and fill?

//E.g, in main prog:
double para[5];
fitfunc(histoname, arguments, para[5])
use the parameters

//while in fitfunc(TH1F histoname, type arguments, double &para[5])
//after set parameters etc
para[0->4]= histoname -> GetParameters(0,1,2,3,4)

Will that do the job? I’ve tried but i get compilation errors. Oh what about the errors?

I saw a similar question asked in this post
http://root.cern.ch/phpBB2/viewtopic.php?t=289&highlight=extracting+parameters
But it wasn’t answered, so had to ask again :confused:

Hi,

Are you fitting with TMinuit ? If this is the case, I think you just need :

gMinuit->GetParameter(0,para[0],perr[0]);
gMinuit->GetParameter(1,para[1],perr[1]);
...[/code]

No i’m not using TMinuit, but passing arrays into the function seems to work … but only up until a point

I want to GetParamters from the fit functions to use in calculations in the main script.

I intialise and pass an array into the fit function to extract these parameters.
Thats ok.
(I just used (e.g) myarray[i] = f1 -> GetParameter(1) )
But when I loop (pass the array into the function again), it doesn’t return the parameters as the ones printed out by default on the extern window, but as what I gave the fit function as ‘starting’ parameters.

How do I solve this one?

(Sorry if you’re reading this twice, but the question seemed more relevant to this topic)
Thanks.