ROOT Version: 6.18 Platform: Ubuntu Compiler: Not Provided
Good Afternoon,
I need some help with Fit Parameters. I have an array of histogram and I’m fitting them with the same function and now I want to write the fit parameters on text file for each histogram.
I tried to use a cicle
ofstream myoutput;
myoutput.open(“datafit.txt”);
if (myoutput.fail()){
cout << “Non posso aprire il file” << endl;
exit(1);
}
I’m not sure about the condition you are setting with jGetNpar(), is it possibly a typo?
Also keep in mind that the variables you define in the for loop have local scope so they won’t be declared when the loop is finished.
Cheers,
Vincenzo
I still think only one j<GetNPar() should be enough. You can try retrieving the array of parameters outside the loop and then write each of them to the file in the loop like this:
// Open file and fit function
[...]
// Retrieve the vector of fit parameters
auto pars = myTF1obj->GetParameters();
// Write the values to the file
for(Int_t j = 0; j < GetNPar(); j++){
myoutputfile << pars[j] << "\n";
}