I am performing fittings using TMinuit in various settings.
Each fitting has different conditions, do I need to define a new TMinuit object? The current code is as follows
double global_factor;
void FCN(int &npar, double *gin, double &f, , double *par, int iflag)
{
// some process
f = par[0] + ... .... .... + global_factor;
}
int main()
{
// JUST DEFINE ONE TMinuit, in the begging
TMinuit *min = new TMinuit(1);
min->SetFCN(FCN);
min->mnparm(0, "local_factor", 0.5, 0.01, 0, 1, ierflg);
for (int i=0; i<1000; i++) {
global_factor = // set different global factor
// Do I need to define a new TMinuit object here???
// TMinuit *min = new TMinuit(1);
// min->SetFCN(FCN);
// min->mnparm(0, "local factor", 0.5, 0.01, 0, 1, ierflg);
min->mnexcm("MIGRAD", arglist ,2,ierflg);
}
}
Do you know if the above code would reflect the result of one previous fitting and not correctly implement the fitting of the new loop settings?
Or, even if the previous result is reflected, is it possible to find the minimum parameter for each new setting?
the main2 below might not be able to find proper minimm?? (because the previous parameter and the fitting results are remain).
int main1()
// JUST DEFINE ONE TMinuit, in the begging
TMinuit *min = new TMinuit(1);
min->SetFCN(FCN);
for (int i=0; i<1000; i++) {
global_factor = // set different global factor
min->mncler(); // clear the parameters
min->mnparm(0, "local_factor", 0.5, 0.01, 0, 1, ierflg);
min->mnexcm("MIGRAD", arglist ,2,ierflg);
}
int main2()
// JUST DEFINE ONE TMinuit, in the begging
TMinuit *min = new TMinuit(1);
min->SetFCN(FCN);
for (int i=0; i<1000; i++) {
global_factor = // set different global factor
//min->mncler(); // clear the parameters
min->mnparm(0, "local_factor", 0.5, 0.01, 0, 1, ierflg);
min->mnexcm("MIGRAD", arglist ,2,ierflg);
}
Hello,
I am not sure I have understood your problem. It is possible that without calling mncler works anyway or works even better, since it is re-using some information from the previous minimization.