How to get the parameters after fitting

recently time ,i fitted a datasample with the convolution of Breit-wigner and Gauss , then added exponential distribution.

after the fitting ,how can i get the final parameters.ie,sigmma,fwhm…

cheers!

this is my code (please check it ,any idea is welcome):

{
TFile *f = new TFile(“results.root”);
TH1F t12_m = (TH1F)f->Get(“t12_m”);

TF1 bw1 = new TF1(“bw1”,"[0][2]/((x-[1])(x-[1])+([2][2]/4))",60,130);
bw1->SetParameters(1500,91.138,2.3);
bw1->SetParNames(“Constant”,“Mean_value”,“Sigma”);
//t12_m->Fit(“bw1”,“R”);

TF1 gaus1 = new TF1(“gaus1”,"[3]exp( (-0.5(x - [0])(x - [0])) / ([1]*[1]) )",60,130);
gaus1->SetParameters(91.138,2.3,1500);
gaus1->SetParNames(“Constant”,“w”);
gaus1->SetLineColor(4);
//t12_m->Fit(“gaus1”,“R+”);

TF1 *exp1 = new TF1(“exp1”,“expo”,60,130);
exp1->SetParameters(0,3.5);
exp1->SetParNames(“Constant1”,“w1”);
exp1->SetLineColor(3);
//t12_m->Fit(“exp1”,“R+”);

TF1 bw =new TF1(“bw”,"bw1gaus1+expo",70,110);
bw->SetParameters(1500,91.138,2.3,91.138,2.3,1500);
bw->SetParNames(“Constant”,“Mean_value”,“Sigma”,“gaus1_massz”,“gaus1_error”,“gaus1_constant”,“Exp_constant1”,“Exp_constant2”);bw->SetLineColor(2);

t12_m->Fit(“bw”,“R+”);
t12_m->Draw();
}

You can use the GetParameters() or GetParameter(int ipar) methods of TF1.
and GetParErrors() to get the parameter errors.

In your case you can do

double * params = bw->GetParameters();
double * parErrors = bw->GetParErrors();

[quote=“moneta”]
In your case you can do

double * params = bw->GetParameters(); double * parErrors = bw->GetParErrors(); [/quote]

I looked quickly at the documentation. Am I correct that these functions do a ‘new Double_t[numparams]’ and that the user is responsible for cleaning up the memory when they are finished?

[quote=“moneta”]

In your case you can do

double * params = bw->GetParameters();
double * parErrors = bw->GetParErrors();[/quote]

you means just add the commands above?
or should i add some commands like “printf …” to print out the params??

to cplager:

[quote]I looked quickly at the documentation. Am I correct that these functions
do a ‘new Double_t[numparams]’ and that the user is responsible for
cleaning up the memory when they are finished?
[/quote]
Where have you seen this?
The array of parameters and/or errors belong to the TF1/TFormula object.
They are automatically deleted bt the TF1 destructor.

to hangyin:

[quote]you means just add the commands above?
or should i add some commands like “printf …” to print out the params??
[/quote]
You must add print statements to print the values in your own format.
You can also use TF1::Print
bw->Print();

Rene

[quote=“brun”]to cplager:

[quote]I looked quickly at the documentation. Am I correct that these functions
do a ‘new Double_t[numparams]’ and that the user is responsible for
cleaning up the memory when they are finished?
[/quote]
Where have you seen this?
The array of parameters and/or errors belong to the TF1/TFormula object.
They are automatically deleted bt the TF1 destructor.
[/quote]

I had assumed that the GetParameters functions was returning copies of the parameters, not the actual array storing the parameters. Or, are you saying it is a copy, but that the TF1 keeps a list of all the copies it makes and deletes them when it’s destroyed?

Cheers,
Charles

[quote=“brun”]to cplager:
You must add print statements to print the values in your own format.
You can also use TF1::Print
bw->Print();

Rene[/quote]

Thank you very much for your help!
i have another question .how can i get the FWHM of the histogram after fitting ?