16 #include "Riostream.h"
21 #include "TObjString.h"
32 virtual Int_t
Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *pars, Int_t iflag);
40 TMinuit(NumPars), fxFitter(fitter) {
46 Int_t
TMinuitEx::Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *pars, Int_t iflag) {
58 TGo4FitterAction(Name,
"Fitter minimization using TMinuit object"), fxCommands(), fxResults() {
73 return ((TObjString*)
fxCommands[n])->GetString().Data();
79 fMinuit.SetPrintLevel(-1);
81 for(Int_t n=0;n<Fitter->
NumPars();n++) {
84 Double_t epsilon = 0, RangeMin = 0, RangeMax = 0;
87 if (!Fitter->
GetParRange(FullName,RangeMin,RangeMax)) { RangeMin = 0; RangeMax = 0; }
89 fMinuit.mnparm(n, FullName, Fitter->
GetParValue(FullName),
90 epsilon, RangeMin, RangeMax, ierflg);
92 if (Fitter->
GetParFixed(FullName)) fMinuit.FixParameter(n);
95 if (
fxCommands.GetLast()<0) fMinuit.Command(
"MIGRAD 500 1");
98 TString cmd ( ((TObjString*)
fxCommands[n])->GetString() );
100 if (cmd.Index(
"result",6,0,TString::kIgnoreCase) == 0) {
102 while ((cmd.Length()>0) && (cmd[0]==
' ')) cmd.Remove(0,1);
103 if (cmd.Length()==0) cmd =
"1000";
104 if (cmd.Length()<4) { std::cerr <<
"invalid result command syntax" << std::endl;
break; }
105 Bool_t getpar = (cmd[0]==
'1');
106 Bool_t geterr = (cmd[1]==
'1');
107 Bool_t getmatr = (cmd[2]==
'1');
108 Bool_t getcontr = (cmd[3]==
'1');
110 while ((cmd.Length()>0) && (cmd[0]==
' ')) cmd.Remove(0,1);
111 if (cmd.Length()==0) cmd=
"Result";
122 }
else fMinuit.Command(cmd);
125 for(Int_t n=0;n<Fitter->
NumPars();n++) {
126 Double_t value,error;
127 fMinuit.GetParameter(n, value, error);
158 std::cout <<
"List of commands:" << std::endl;
160 std::cout <<
" " << ((TObjString*)
fxCommands[n])->String().Data() << std::endl;
162 std::cout <<
"List of stored results:" << std::endl;
Bool_t SetParValue(const char *ParName, Double_t iValue)
virtual Bool_t GetParEpsilon(const char *ParName, Double_t &Epsilon)
void GetContourPlot(TMinuit *fMinuit)
TGo4FitterAbstract * fxFitter
void RemoveResult(TGo4FitMinuitResult *res)
TMinuitEx(Int_t NumPars, TGo4FitterAbstract *fitter)
void AddCommand(const char *iCommand)
virtual Bool_t GetParFixed(const char *ParName)
void CallMNERRS(TMinuit *fMinuit, Int_t nPars)
const char * GetCommand(Int_t n)
void CallMNEMAT(TMinuit *fMinuit, Int_t nPars, Bool_t DoTransform=kTRUE)
Bool_t SetParError(const char *ParName, Double_t iError)
void Print(Option_t *option) const
const char * GetParFullName(Int_t n)
TGo4FitMinuitResult * GetResult(Int_t indx)
Double_t CalculateFitFunction(Double_t *pars=0)
virtual void DoAction(TGo4FitterAbstract *Fitter)
virtual Bool_t GetParRange(const char *ParName, Double_t &RangeMin, Double_t &RangeMax)
virtual Int_t Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *pars, Int_t iflag)
virtual void Print(Option_t *option) const
TGo4FitMinuitResult * FindResult(const char *ResName)
void CallMNSTAT(TMinuit *fMinuit)
void AddResult(TGo4FitMinuitResult *res)
void CallMNPOUT(TMinuit *fMinuit, Int_t nPars)
Double_t GetParValue(const char *ParName)