Output of fi function into table txt file

Hi

I have the following function defined to fit different series of data
return par[0] + par[1] * TMath::Exp(bofpar[2] + dirpar[3] + x[0] * x[0] * x[0] * par[4] + x[0] * x[0] * par[5] + x[0] * par[6]);
Does someone knows how to get the get the output of results of fitting par[…]
ibn an excel tabel or txt file
Thanks
sor

Supposing you have a TF1 f wrapping that function:

for (int i=0; i<f.GetNPar();++i ){
   cout << f.GetParameter(i) << " ";
}
cout << endl;

you can replace cout with a file following standard C++ guidelines.

ROOT 5.34/32 (v5-34-32@v5-34-32, Jun 23 2015, 17:58:02 on win32)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .cd C:\rootFiles\VesselPar
root [1] .x analyze_ConsumptionLevMarq3terms.C

GSLNLSMinimizer: Minimum Found
FVAL = 28.934564838573074
Edm = 0.0090369124205464443
NIterations = 5
NFuncCalls = 38
p0 = 12.5468 +/- 0
p1 = -12.2617 +/- 0
p2 = -3.37677e-005 +/- 1.06942e-006

Covariance Matrix:

                      p0          p1          p2

p0 0 0 0
p1 0 0 0
p2 0 0 2.5455e-013

Correlation Matrix:

                      p0          p1          p2

p0 0 0 0
p1 0 0 0
p2 0 0 1


Minimizer is GSLMultiFit
Chi2 = 28.9346
NDf = 130
Edm = 0.00903691
NCalls = 38
p0 = 12.5468 +/- 0
p1 = -12.2617 +/- 0
p2 = -3.37677e-005 +/- 5.04529e-007
Warning: wrong member access operator ‘.’ C:\rootFiles\VesselPar\analyze_ConsumptionLevMarq3terms.C(43)
Error: Can’t call TF1::GetNPar() in current scope C:\rootFiles\VesselPar\analyze_ConsumptionLevMarq3terms.C(43)
Possible candidates are…
(in TF1)
(in TFormula)
*** Interpreter error recovered ***
root [2]

Hi

Is a difference between linux and windows? Apparently I cannot get even the parameters nr when I just do simply printf(“nr de param”, fitf.GetNPar()); fitf is my TF1 function
I managed to print of the terminal but not in a file.
when I try with fitf.GetNpar() it says wrong member access operator
Any idea?
Sor

If you have a “TF1 fitf”, then “fitf.GetNPar()”, but if you have a “TF1 *fitf”, then “fitf->GetNPar()” or “(*fitf).GetNPar()”.

thanks, it worked. i did this
for (int i = 0; iGetNpar(); i++) {
Float_t value = fitf->GetParameter(i);
fprintf(fp, “%d %f”, i, value);
Sor