32 return par[0] + par[1]*
x[0] + par[2]*
x[0]*
x[0];
38 TMath::Max( 1.e-10,(
x[0]-par[2])*(
x[0]-par[2]) + .25*par[1]*par[1]);
43 return background(
x,par) + lorentzianPeak(
x,&par[3]);
47 printf(
"\n*********************************************************************************\n");
48 printf(
"\t %s \n",fitter);
49 printf(
"*********************************************************************************\n");
59 std::string title = std::string(fitter) +
" fit bench";
60 histo =
new TH1D(fitter,title.c_str(),200,0,3);
69 for (
Int_t pass=0;pass<npass;pass++) {
70 if (pass%100 == 0) printf(
"pass : %d\n",pass);
73 for (
Int_t i=0;i<5000;i++) {
76 int iret = histo->
Fit(fitFcn,
"Q0");
78 if (iret!=0)
Error(
"DoFit",
"Fit pass %d failed !",pass);
81 if (!fitterType.Contains(
"Fumili"))
82 histo->
Fit(fitFcn,
"E");
84 histo->
Fit(fitFcn,
"");
92 printf(
"%s, npass=%d : RT=%7.3f s, Cpu=%7.3f s\n",fitter,npass,timer.
RealTime(),cputime);
101int minuit2FitBench(
Int_t npass=20) {
107 fitFcn =
new TF1(
"fitFcn",fitFunction,0,3,6);
115 ok &= DoFit(
"Minuit",
gPad,npass);
119 ok &= DoFit(
"Fumili",
gPad,npass);
123 ok &= DoFit(
"Minuit2",
gPad,npass);
127 ok &= DoFit(
"Fumili2",
gPad,npass);
129 c1->SaveAs(
"FitBench.root");
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
static void SetDefaultMinimizer(const char *type, const char *algo=0)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void Update()
Called by functions such as SetRange, SetNpx, SetParameters to force the deletion of the associated h...
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
virtual Double_t GetRandom()
Return a random number following this function shape.
virtual void SetParameters(const Double_t *params)
1-D histogram with a double per channel (see TH1 documentation)}
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual TF1 * GetFunction(const char *name) const
Return pointer to function with name.
A Pave (see TPave) with a text centered in the Pave.
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
Random number generator class based on M.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Stop()
Stop the stopwatch.
void SetStatY(Float_t y=0)
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)=0
virtual void SetLogy(Int_t value=1)=0
Short_t Max(Short_t a, Short_t b)