How to save TF1 fit values to .txt

Hi everyone,

I have used the code

TF1 *f1 = new TF1("f1", "gaus", -.5, .5); hist->Fit("f1", "R");

to fit a gaussian to my histogram, with the fit parameters showing the in terminal.

I have also used the code

ofstream outFitNumbers; outFitNumbers.open("FitNumbers.txt"); outFitNumbers << "Histogram Name = " << histName << endl;

etc to write different variables into a .txt file.

However I have tried

and it isn’t working like I would like it to, just gives me zero. Anyone have any ideas how this can be done?

Cheers
Jason

Found solution, for those who are interested:

outFitNumbers << f1->GetParameter(n) << endl; outFitNumbers << f1->GetParError(n) << endl;

where n is the index of the parameter starting from 0. Using “gaus” as an example:

Cheers
Jason