52double gauss2D(
double *
x, 
double *par) {
 
   53   double z1 = double((
x[0]-par[1])/par[2]);
 
   54   double z2 = double((
x[1]-par[3])/par[4]);
 
   55   return par[0]*
exp(-0.5*(z1*z1+z2*z2));
 
   57double my2Dfunc(
double *
x, 
double *par) {
 
   58   return gauss2D(
x,&par[0]) + gauss2D(
x,&par[5]);
 
   83   for (
int ix = 1; ix <= nbinX1; ++ix) {
 
   85      for (
int iy = 1; iy <= nbinY1; ++iy) {
 
   94   for (
int ix = 1; ix <= nbinX2; ++ix) {
 
   96      for (
int iy = 1; iy <= nbinY2; ++iy) {
 
  108void FillHisto(
TH2D * 
h, 
int n, 
double * p) {
 
  111   const double mx1 = p[1];
 
  112   const double my1 = p[3];
 
  113   const double sx1 = p[2];
 
  114   const double sy1 = p[4];
 
  115   const double mx2 = p[6];
 
  116   const double my2 = p[8];
 
  117   const double sx2 = p[7];
 
  118   const double sy2 = p[9];
 
  120   const double w1 = 0.5;
 
  123   for (
int i = 0; i < 
n; ++i) {
 
  127      double r = rndm.
Rndm(1);
 
  144int fit2dHist(
int option=1) {
 
  161   h1 = 
new TH2D(
"h1",
"core",nbx1,xlow1,xup1,nby1,ylow1,yup1);
 
  162   h2 = 
new TH2D(
"h2",
"tails",nbx2,xlow2,xup2,nby2,ylow2,yup2);
 
  164   double iniParams[10] = { 100, 6., 2., 7., 3, 100, 12., 3., 11., 2. };
 
  166   TF2 * func = 
new TF2(
"func",my2Dfunc,xlow2,xup2,ylow2,yup2, 10);
 
  172   FillHisto(
h1,n1,iniParams);
 
  173   FillHisto(h2,n2,iniParams);
 
  176   double dx1 = (xup1-xlow1)/
double(nbx1);
 
  177   double dy1 = (yup1-ylow1)/
double(nby1);
 
  178   double dx2 = (xup2-xlow2)/
double(nbx2);
 
  179   double dy2 = (yup2-ylow2)/
double(nby2);
 
  182   h2->
Scale(  ( 
double(n1) * dx1 * dy1 )  / ( 
double(n2) * dx2 * dy2 ) );
 
  185   if (option > 10) global = 
true;
 
  188      std::cout << 
"Do global fit" << std::endl;
 
  195      for (
int i = 0; i < 10; ++i) {
 
  211      double minParams[10];
 
  212      double parErrors[10];
 
  213      for (
int i = 0; i < 10; ++i) {
 
  217      double chi2, edm, errdef;
 
  219      minuit->
GetStats(chi2,edm,errdef,nvpar,nparx);
 
  224      int ndf = npfits-nvpar;
 
  238   TCanvas * 
c1 = 
new TCanvas(
"c1",
"Two HIstogram Fit example",100,10,900,800);
 
  245   func->
SetRange(xlow1,ylow1,xup1,yup1);
 
  251   func->
SetRange(xlow2,ylow2,xup2,yup2);
 
  257   func->
Draw(
"surf1 same");
 
R__EXTERN TStyle * gStyle
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.
virtual TF1 * DrawCopy(Option_t *option="") const
Draw a copy of this function with its current attributes-*.
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
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
TList * GetListOfFunctions() const
virtual void Draw(Option_t *option="")
Draw this histogram with options.
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)}
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void Add(TObject *obj)
Random number generator class based on M.
virtual Double_t Rndm()
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 ...
Abstract Base Class for Fitting.
static void SetDefaultFitter(const char *name="")
static: set name of default fitter
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const =0
virtual void SetFCN(void(*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t))
To set the address of the minimization objective function called by the native compiler (see function...
virtual Double_t GetParError(Int_t ipar) const =0
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)=0
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)=0
virtual Double_t GetParameter(Int_t ipar) const =0
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.