17 double z1 =
double((x[0]-par[1])/par[2]);
18 double z2 =
double((x[1]-par[3])/par[4]);
19 return par[0]*
exp(-0.5*(z1*z1+z2*z2));
31 std::vector<std::pair<double, double> >
coords;
37 int n = coords.size();
40 for (
int i = 0; i <
n; ++i ) {
41 x[0] = coords[i].first;
42 x[1] = coords[i].second;
43 tmp = ( values[i] -
my2Dfunc(x,p))/errors[i];
52 const double mx1 = p[1];
53 const double my1 = p[3];
54 const double sx1 = p[2];
55 const double sy1 = p[4];
56 const double mx2 = p[6];
57 const double my2 = p[8];
58 const double sx2 = p[7];
59 const double sy2 = p[9];
61 const double w1 = 0.5;
64 for (
int i = 0; i <
n; ++i) {
68 double r = rndm.
Rndm(1);
102 TH2D *
h1 =
new TH2D(
"h1",
"core",nbx1,xlow1,xup1,nby1,ylow1,yup1);
103 TH2D *
h2 =
new TH2D(
"h2",
"tails",nbx2,xlow2,xup2,nby2,ylow2,yup2);
105 double iniParams[10] = { 100, 6., 2., 7., 3, 100, 12., 3., 11., 2. };
119 double dx1 = (xup1-xlow1)/
double(nbx1);
120 double dy1 = (yup1-ylow1)/
double(nby1);
121 double dx2 = (xup2-xlow2)/
double(nbx2);
122 double dy2 = (yup2-ylow2)/
double(nby2);
127 h2->
Scale( (
double(n1) * dx1 * dy1 ) / (
double(n2) * dx2 * dy2 ) );
132 std::cout <<
"Do global fit" << std::endl;
147 coords = std::vector<std::pair<double,double> >();
148 values = std::vector<double>();
149 errors = std::vector<double>();
152 for (
int ix = 1; ix <= nbinX1; ++ix) {
153 for (
int iy = 1; iy <= nbinY1; ++iy) {
161 for (
int ix = 1; ix <= nbinX2; ++ix) {
162 for (
int iy = 1; iy <= nbinY2; ++iy) {
173 for (
int i = 0; i < 10; ++i) {
189 double minParams[10];
190 double parErrors[10];
191 for (
int i = 0; i < 10; ++i) {
195 double chi2, edm, errdef;
197 minuit->
GetStats(chi2,edm,errdef,nvpar,nparx);
202 int ndf = coords.size()-nvpar;
205 std::cout <<
"Chi2 Fit = " << chi2 <<
" ndf = " << ndf <<
" " << func->
GetNDF() << std::endl;
220 TCanvas *
c1 =
new TCanvas(
"c1",
"Two HIstogram Fit example",100,10,900,800);
227 func->
SetRange(xlow1,ylow1,xup1,yup1);
233 func->
SetRange(xlow2,ylow2,xup2,yup2);
239 func->
Draw(
"surf1 same");
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
TList * GetListOfFunctions() const
virtual void SetParameters(const Double_t *params)
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Random number generator class based on M.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)=0
virtual const char * GetParName(Int_t ipar) const
R__EXTERN TStyle * gStyle
double gauss2D(double *x, double *par)
std::vector< double > values
static void SetDefaultFitter(const char *name="")
static: set name of default fitter
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
void myFcn(Int_t &, Double_t *, Double_t &fval, Double_t *p, Int_t)
virtual Double_t GetParameter(Int_t ipar) const =0
virtual void SetFCN(void *fcn)
To set the address of the minimization objective function.
void SetStatY(Float_t y=0)
virtual Int_t GetNbinsX() const
virtual Int_t GetNDF() const
Return the number of degrees of freedom in the fit the fNDF parameter has been previously computed du...
static double p2(double t, double a, double b, double c)
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
virtual Double_t GetParError(Int_t ipar) const =0
virtual TF1 * DrawCopy(Option_t *option="") const
Draw a copy of this function with its current attributes-*.
void FillHisto(TH2D *h, int n, double *p)
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetChisquare(Double_t chi2)
Class to manage histogram axis.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)=0
static double p1(double t, double a, double b)
A 2-Dim function with parameters.
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const =0
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
double func(double *x, double *p)
Abstract Base Class for Fitting.
virtual Double_t GetParameter(Int_t ipar) const
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual Int_t GetNbinsY() const
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
std::vector< std::pair< double, double > > coords
virtual void Add(TObject *obj)
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 void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
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...
int TwoHistoFit2D(bool global=true)
std::vector< double > errors
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Int_t Fill(Double_t)
Invalid Fill method.
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.
double my2Dfunc(double *x, double *par)
2-D histogram with a double per channel (see TH1 documentation)}