FCN=2613.61 FROM MIGRAD STATUS=CONVERGED 1090 CALLS 1091 TOTAL
EDM=1.5599e-08 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 3.7 per cent
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 5.34104e+02 2.25626e+00 -1.45532e-03 2.18435e-05
2 p1 6.00014e+00 5.67524e-03 -2.38292e-06 -3.27949e-02
3 p2 1.98724e+00 3.63694e-03 -2.58780e-06 -5.50559e-03
4 p3 7.02973e+00 2.65118e-02 -2.44324e-05 -1.18794e-02
5 p4 2.99679e+00 1.39392e-02 -1.13807e-05 1.50299e-02
6 p5 5.19346e+02 5.08272e+01 3.87334e-02 -2.41684e-05
7 p6 1.15499e+01 4.81865e-01 5.78545e-04 4.63910e-03
8 p7 2.72921e+00 2.57821e-01 2.95923e-04 -5.50344e-03
9 p8 1.11977e+01 2.40323e-01 -9.65097e-05 7.16022e-03
10 p9 2.08422e+00 1.01013e-01 -2.43739e-05 -1.10303e-02
FCN=2220.46 FROM MIGRAD STATUS=CONVERGED 333 CALLS 334 TOTAL
EDM=6.12528e-07 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 1.1 per cent
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 5.30875e+02 1.56318e+00 -8.45958e-04 2.13120e-04
2 p1 6.01215e+00 1.39029e-02 5.56975e-05 1.20143e-01
3 p2 1.99424e+00 1.02676e-02 -3.65137e-05 1.99143e-01
4 p3 6.98634e+00 1.77537e-02 4.59097e-06 1.88058e-02
5 p4 2.98764e+00 1.14564e-02 5.16037e-06 2.41585e-02
6 p5 5.32751e+02 1.16044e+00 9.85153e-04 1.59279e-03
7 p6 1.19894e+01 8.92126e-03 7.18458e-06 8.54804e-02
8 p7 2.99536e+00 6.32688e-03 -5.28473e-06 3.40897e-01
9 p8 1.09975e+01 3.41959e-03 -1.79221e-06 2.14024e-02
10 p9 1.98880e+00 2.41489e-03 5.35898e-07 3.99846e-01
(int) 0
#include <iostream>
double gauss2D(
double *
x,
double *par) {
double z1 =
double((
x[0]-par[1])/par[2]);
double z2 =
double((
x[1]-par[3])/par[4]);
return par[0]*exp(-0.5*(z1*z1+z2*z2));
}
double my2Dfunc(
double *
x,
double *par) {
return gauss2D(
x,&par[0]) + gauss2D(
x,&par[5]);
}
class MyFcn {
public:
int npfits = 0;
double chi2 = 0;
double tmp;
npfits = 0;
for (int ix = 1; ix <= nbinX1; ++ix) {
for (int iy = 1; iy <= nbinY1; ++iy) {
chi2 += tmp*tmp;
npfits++;
}
}
}
for (int ix = 1; ix <= nbinX2; ++ix) {
for (int iy = 1; iy <= nbinY2; ++iy) {
chi2 += tmp*tmp;
npfits++;
}
}
}
return chi2;
}
};
void FillHisto(
TH2D *
h,
int n,
double *
p) {
const double w1 = 0.5;
for (
int i = 0; i <
n; ++i) {
}
else {
}
}
}
int nbx1 = 50;
int nby1 = 50;
int nbx2 = 50;
int nby2 = 50;
double xlow1 = 0.;
double ylow1 = 0.;
double xup1 = 10.;
double yup1 = 10.;
double xlow2 = 5.;
double ylow2 = 5.;
double xup2 = 20.;
double yup2 = 20.;
auto h1 =
new TH2D(
"h1",
"core",nbx1,xlow1,xup1,nby1,ylow1,yup1);
auto h2 =
new TH2D(
"h2",
"tails",nbx2,xlow2,xup2,nby2,ylow2,yup2);
double iniParams[10] = { 100, 6., 2., 7., 3, 100, 12., 3., 11., 2. };
TF2 * func =
new TF2(
"func",my2Dfunc,xlow2,xup2,ylow2,yup2, 10);
int n1 = 1000000;
int n2 = 1000000;
FillHisto(
h1,n1,iniParams);
FillHisto(h2,n2,iniParams);
double dx1 = (xup1-xlow1)/double(nbx1);
double dy1 = (yup1-ylow1)/double(nby1);
double dx2 = (xup2-xlow2)/double(nbx2);
double dy2 = (yup2-ylow2)/double(nby2);
h2->
Scale( (
double(n1) * dx1 * dy1 ) / (
double(n2) * dx2 * dy2 ) );
bool global = false;
if (
option > 10) global =
true;
if (global) {
std::cout << "Do global fit" << std::endl;
for (int i = 0; i < 10; ++i) {
}
if (!ret) {
Error(
"fit2DHist",
"Fit Failed to converge");
return -1;
}
double minParams[10];
double parErrors[10];
for (int i = 0; i < 10; ++i) {
}
int npfits = myFcn.npfits;
}
else {
}
func->
Draw(
"surf1 same");
return 0;
}
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
TRObject operator()(const T1 &t1) const
R__EXTERN TRandom * gRandom
R__EXTERN TStyle * gStyle
void SetMinimizer(const char *type, const char *algo=nullptr)
set minimizer type
const ParameterSettings & ParSettings(unsigned int i) const
get the parameter settings for the i-th parameter (const method)
double Error(unsigned int i) const
parameter error by index
double MinFcnValue() const
Return value of the objective function (chi2 or likelihood) used in the fit.
double Edm() const
Expected distance from minimum.
unsigned int NFreeParameters() const
get total number of free parameters
double Parameter(unsigned int i) const
parameter value by index
Fitter class, entry point for performing all type of fits.
bool FitFCN(unsigned int npar, Function &fcn, const double *params=0, unsigned int dataSize=0, bool chi2fit=false)
Fit using the a generic FCN function as a C++ callable object implementing double () (const double *)...
bool SetFCN(unsigned int npar, Function &fcn, const double *params=0, unsigned int dataSize=0, bool chi2fit=false)
Set a generic FCN function as a C++ callable object implementing double () (const double *) Note that...
const FitResult & Result() const
get fit result
const FitConfig & Config() const
access to the fit configuration (const method)
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
Class to manage histogram axis.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual void SetNDF(Int_t ndf)
Set the number of degrees of freedom ndf should be the number of points used in a fit - the number of...
virtual void SetChisquare(Double_t chi2)
virtual void SetParErrors(const Double_t *errors)
Set errors for all active parameters when calling this function, the array errors must have at least ...
virtual const char * GetParName(Int_t ipar) const
virtual void SetParameters(const Double_t *params)
virtual Double_t GetParameter(Int_t ipar) const
A 2-Dim function with parameters.
TF1 * DrawCopy(Option_t *option="") const override
Draw a copy of this function with its current attributes-*.
void Draw(Option_t *option="") override
Draw this function with its current attributes.
void SetRange(Double_t xmin, Double_t xmax) override
Initialize the upper and lower bounds to draw the function.
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
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 GetNbinsX() const
void Draw(Option_t *option="") override
Draw this histogram with options.
TList * GetListOfFunctions() const
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
2-D histogram with a double per channel (see TH1 documentation)}
Double_t GetBinContent(Int_t binx, Int_t biny) const override
void Add(TObject *obj) override
Double_t Rndm() override
Machine independent random number generator.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
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 ...