24double gauss2D(
double *
x,
double *par) {
27 return par[0]*exp(-0.5*(
z1*
z1+
z2*
z2));
39std::vector<std::pair<double, double> > coords;
40std::vector<double > values;
41std::vector<double >
errors;
43void myFcn(
int & ,
double * ,
double &
fval,
double *
p,
int )
45 int n = coords.size();
48 for (
int i = 0; i <
n; ++i ) {
49 x[0] = coords[i].first;
50 x[1] = coords[i].second;
60 const double mx1 =
p[1];
61 const double my1 =
p[3];
62 const double sx1 =
p[2];
63 const double sy1 =
p[4];
64 const double mx2 =
p[6];
65 const double my2 =
p[8];
66 const double sx2 =
p[7];
67 const double sy2 =
p[9];
69 const double w1 = 0.5;
72 for (
int i = 0; i <
n; ++i) {
76 double r =
rndm.Rndm(1);
113 double iniParams[10] = { 100, 6., 2., 7., 3, 100, 12., 3., 11., 2. };
140 std::cout <<
"Do global fit" << std::endl;
155 coords = std::vector<std::pair<double,double> >();
156 values = std::vector<double>();
157 errors = std::vector<double>();
160 for (
int ix = 1; ix <=
nbinX1; ++ix) {
161 for (
int iy = 1; iy <=
nbinY1; ++iy) {
163 coords.push_back( std::make_pair(
xaxis1->GetBinCenter(ix),
yaxis1->GetBinCenter(iy) ) );
169 for (
int ix = 1; ix <=
nbinX2; ++ix) {
170 for (
int iy = 1; iy <=
nbinY2; ++iy) {
171 if (
h2->GetBinContent(ix,iy) > 0 ) {
172 coords.push_back( std::make_pair(
xaxis2->GetBinCenter(ix),
yaxis2->GetBinCenter(iy) ) );
173 values.push_back(
h2->GetBinContent(ix,iy) );
174 errors.push_back(
h2->GetBinError(ix,iy) );
181 for (
int i = 0; i < 10; ++i) {
199 for (
int i = 0; i < 10; ++i) {
213 std::cout <<
"Chi2 Fit = " <<
chi2 <<
" ndf = " <<
ndf <<
" " << func->
GetNDF() << std::endl;
217 h2->GetListOfFunctions()->Add(func);
228 TCanvas *
c1 =
new TCanvas(
"c1",
"Two HIstogram Fit example",100,10,900,800);
247 func->
Draw(
"surf1 same");
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
R__EXTERN TStyle * gStyle
Class to manage histogram axis.
virtual Int_t GetNDF() const
Return the number of degrees of freedom in the fit the fNDF parameter has been previously computed du...
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.
2-D histogram with a double per channel (see TH1 documentation)
void Add(TObject *obj) override
Random number generator class based on M.
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
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.