24 return par[0] + par[1]*x[0];
38 double par0[8] = { 1, 0.05, 10 , 2, 0.5 , 10 , 7 , 1. };
52 cout <<
"Error creating minimizer " << endl;
78 for (
unsigned int i = 0; i < chi2Func.
NDim(); ++i) {
80 cout <<
"set variable " << i <<
" to value " << x0[i] << endl;
82 if ( i == 3 || i == 6 )
94 cout <<
"--------------------------------------" << endl;
95 cout <<
"GeneticMinimizer(" << xm1 <<
"," << xm2 <<
") : ";
96 cout <<
"chi2 min value = " << minval;
97 cout <<
" minimum values m1 = " << min->
X()[3] <<
" m2 = " << min->
X()[6] << endl;
99 std::cout <<
"All Fit parameters : ";
100 for (
unsigned int i = 0; i < chi2Func.
NDim(); ++i)
101 cout <<
"x(" << i <<
") = " << min->
X()[i] <<
" ";
118 cout <<
"Error creating minimizer " << endl;
136 for (
unsigned int i = 0; i < chi2Func.
NDim(); ++i) {
138 cout <<
"set variable " << i <<
" to value " << x0[i] << endl;
148 cout <<
"--------------------------------------" << endl;
149 cout <<
"Minuit2Minimizer(" << xm1 <<
"," << xm2 <<
") : ";
150 cout <<
"chi2 min value = " << minval;
151 cout <<
" minimum values - m1 = " << min->
X()[3] <<
" m2 = " << min->
X()[6] << endl;
153 std::cout <<
"All Fit parameters : ";
154 for (
unsigned int i = 0; i < chi2Func.
NDim(); ++i)
155 cout <<
"x(" << i <<
") = " << min->
X()[i] <<
" ";
175 for (
int i = 0; i <
ndata; ++i) {
192 cout <<
"Minuit2 minimization Time :\t " << t.
RealTime() << endl;
198 fitFunc->
Copy(*fitFunc0);
205 fitFunc0->
Draw(
"same");
214 cout <<
"Genetic minimization Time :\t " << t.
RealTime() << endl;
221 cout <<
"Second Minuit2 minimization Time :\t " << t.
RealTime() << endl;
229 legend->
AddEntry(h1,
"Histogram Data",
"F");
230 legend->
AddEntry(fitFunc0,
"Minuit only minimization");
231 legend->
AddEntry(fitFunc,
"Minuit+Genetic minimization");
242 int main(
int argc,
char **argv)
245 for (
Int_t i=1 ; i<argc ; i++) {
246 std::string arg = argv[i] ;
257 std::cout <<
"Usage: " << argv[0] <<
" [-g] [-v]\n";
258 std::cout <<
" where:\n";
259 std::cout <<
" -g : graphics mode\n";
260 std::cout <<
" -v : verbose mode\n";
261 std::cout <<
" -vv : very verbose mode\n";
262 std::cout << std::endl;
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetParameters(const Double_t *params)
virtual Double_t GetRandom()
Return a random number following this function shape.
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
virtual bool Minimize()
method to perform the minimization
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
This class displays a legend box (TPaveText) containing several legend entries.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
virtual void Copy(TObject &f1) const
Copy this F1 to a new F1.
int GAMinimize(ROOT::Math::IMultiGenFunction &chi2Func, double &xm1, double &xm2)
virtual TF1 * DrawCopy(Option_t *option="") const
Draw a copy of this function with its current attributes.
virtual double MinValue() const
return minimum function value
R__EXTERN TStyle * gStyle
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
Double_t background(Double_t *x, Double_t *par)
double fitFunc(double *x, double *p)
static ROOT::Math::Minimizer * CreateMinimizer(const std::string &minimizerType="", const std::string &algoType="")
static method to create the corrisponding Minimizer given the string Supported Minimizers types are: ...
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
const double gAbsTolerance
static const double x2[5]
Double_t fitFunction(Double_t *x, Double_t *par)
void Stop()
Stop the stopwatch.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2, Minuit, GSL, etc..) Plug-in's exist in ROOT to be able to instantiate the derived classes like ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the plug-in manager.
Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions...
virtual double MinValue() const =0
return minimum function value
virtual bool Minimize()=0
method to perform the minimization
Double_t gaussianPeak(Double_t *x, Double_t *par)
virtual const double * X() const =0
return pointer to X values at the minimum
Documentation for the abstract class IBaseFunctionMultiDim.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Chi2FCN class for binnned fits using the least square methods.
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize
void FillData(BinData &dv, const TH1 *hist, TF1 *func=0)
fill the data vector from a TH1.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
const double * Min2Minimize(ROOT::Math::IMultiGenFunction &chi2Func, double &xm1, double &xm2)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
void SetParameters(const GeneticMinimizerParameters ¶ms)
tomato 1-D histogram with a double per channel (see TH1 documentation)}
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculate a gaussian function with mean and sigma.
virtual const double * X() const
return pointer to X values at the minimum
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
static const double x1[5]
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
void SetTolerance(double tol)
set the tolerance
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
int main(int argc, char **argv)
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable
std::string ToString(const T &val)
Utility function for conversion to strings.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
void SetPrintLevel(int level)
set print level
virtual bool SetLimitedVariable(unsigned int, const std::string &, double, double, double, double)
set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default se...
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.