44 return p[0]*x[0]+ p[1]*x[0]*x[0] + p[2]*x[1] + p[3]*x[1]*x[1] + p[4];
49 const unsigned int ndim( bd.
NDim() );
50 const unsigned int npoints( bd.
NPoints() );
51 for (
unsigned int i = 0; i < npoints; ++i )
54 const double *
x = bd.
GetPoint(i, value, error);
55 for (
unsigned int j = 0; j < ndim; ++j )
57 out <<
" x[" << j <<
"]: " << x[j];
59 out <<
" value: " <<
value;
60 out <<
" error: " << error;
68 const unsigned int ndim = bd.
NDim();
69 const unsigned int npoints = bd.
NPoints();
71 for (
unsigned int i = 0; i < npoints; ++i )
73 double value1 = 0, error1 = 0;
74 const double *
x1 = bd.
GetPoint(i, value1, error1);
76 for (
unsigned int j = 0; j < ndim; ++j )
78 thisIsIt &=
fabs(x1[j] - x[j]) < 1
E-15;
80 if ( thisIsIt )
return i;
83 cout <<
"NO ENCONTRADO!";
84 copy(x, x+ndim, ostream_iterator<double>(cout,
" " ));
92 const unsigned int ndim = bd1.
NDim();
93 const unsigned int npoints = bd1.
NPoints();
97 cout <<
"Equals" << endl;
99 for (
unsigned int i = 0; i < npoints &&
equals; ++i )
101 double value1 = 0, error1 = 0;
102 const double *
x1 = bd1.
GetPoint(i, value1, error1);
106 double value2 = 0, error2 = 0;
107 const double *
x2 = bd2.
GetPoint(bin, value2, error2);
109 equals &= ( value1 == value2 );
111 equals &= ( error1 == error2 );
113 for (
unsigned int j = 0; j < ndim; ++j )
115 equals &=
fabs(x1[j] - x2[j]) < 1
E-15;
116 cout <<
" x[" << j <<
"]: " <<
equals;
120 std::copy(x1, &x1[ndim], ostream_iterator<double>(cout,
" "));
121 cout <<
" value:" << value1;
122 cout <<
" error:" << error1;
125 std::copy(x2, &x2[ndim], ostream_iterator<double>(cout,
" "));
126 cout <<
" value:" << value2;
127 cout <<
" error:" << error2;
129 cout <<
" equals: " <<
equals;
139 vector<double>
min(3); min[0] = 0.; min[1] = 0.; min[2] = 0.;
140 vector<double>
max(3); max[0] = 10.; max[1] = 10.; max[2] = 10.;
141 vector<int>
nbins(3); nbins[0] = 10; nbins[1] = 10; nbins[2] = 10;
143 TH3D*
h1 =
new TH3D(
"3D Original Hist Fit",
"h1-title",
144 nbins[0], min[0], max[0],
145 nbins[1], min[1], max[1],
146 nbins[2], min[2], max[2]);
147 TH3D* h2 =
new TH3D(
"3D Blanked Hist Fit",
"h1-title",
148 nbins[0], min[0], max[0],
149 nbins[1], min[1], max[1],
150 nbins[2], min[2], max[2]);
157 double initialPars[] = {20,5,2,5,1,5,2};
166 for (
int ix=1; ix <= h1->
GetNbinsX(); ++ix) {
167 for (
int iy=1; iy <= h1->
GetNbinsY(); ++iy) {
168 for (
int iz=1; iz <= h1->
GetNbinsZ(); ++iz) {
179 cout <<
"Retrieving the Sparse Data Structure" << endl;
186 cout <<
"Filling second histogram" << endl;
187 for (
unsigned int i = 0; i < bd.
NPoints(); ++i )
192 value = (
value)?value:-10;
193 h2->
Fill(x[0], x[1], x[2], value);
207 cout <<
"\n ******* Fit with Original BinData *******" << endl;
213 std::cout <<
"Fit Failed " << std::endl;
216 cout <<
"\n ******* Fit with Original BinData with Zeros (integrate function in bins)*******" << endl;
225 std::cout <<
"Fit Failed " << std::endl;
228 cout <<
"\n ******* Fit with BinData and NoZeros *******" << endl;
234 std::cout <<
"Fit Failed " << std::endl;
240 cout <<
"\n ******* Fit with BinData with Zeros ******* (integrate function in bins)" << endl;
246 std::cout <<
"Fit Failed " << std::endl;
268 vector<double>
min(2); min[0] = 0.; min[1] = 0.;
269 vector<double>
max(2); max[0] = 10.; max[1] = 10.;
270 vector<int>
nbins(2); nbins[0] = 10; nbins[1] = 10;
272 TH2D*
h1 =
new TH2D(
"2D Original Hist Fit",
"h1-title", nbins[0], min[0], max[0], nbins[1], min[1], max[1]);
273 TH2D* h2 =
new TH2D(
"2D Blanked Hist Fit",
"h1-title", nbins[0], min[0], max[0], nbins[1], min[1], max[1]);
276 min[0],max[0], min[1], max[1], 5);
277 double initialPars[] = {20,5,2,5,1};
286 for (
int ix=1; ix <= h1->
GetNbinsX(); ++ix) {
287 for (
int iy=1; iy <= h1->
GetNbinsY(); ++iy) {
296 cout <<
"Retrieving the Sparse Data Structure" << endl;
303 cout <<
"Filling second histogram" << endl;
304 for (
unsigned int i = 0; i < bd.
NPoints(); ++i )
309 value = (
value)?value:-10;
310 h2->
Fill(x[0], x[1], value);
323 cout <<
"\n ******* Fit with Original BinData *******" << endl;
329 std::cout <<
"Fit Failed " << std::endl;
332 cout <<
"\n ******* Fit with Original BinData with Zeros*******" << endl;
341 std::cout <<
"Fit Failed " << std::endl;
344 cout <<
"\n ******* Fit with BinData and NoZeros *******" << endl;
350 std::cout <<
"Fit Failed " << std::endl;
356 cout <<
"\n ******* Fit with BinData with Zeros *******" << endl;
362 std::cout <<
"Fit Failed " << std::endl;
457 int main(
int argc,
char** argv)
460 bool do3dfit =
false;
462 for (
Int_t i=1 ; i<argc ; i++) {
463 std::string arg = argv[i] ;
475 cerr <<
"Usage: " << argv[0] <<
" [-g] [-v]\n";
477 cerr <<
" -g : graphics mode\n";
478 cerr <<
" -v : verbose mode\n";
479 cerr <<
" -3d : 3d fit";
const FitConfig & Config() const
access to the fit configuration (const method)
virtual void SetParameters(const Double_t *params)
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
int main(int argc, char **argv)
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
int findBin(ROOT::Fit::BinData &bd, const double *x)
int equals(Double_t n1, Double_t n2, double ERRORLIMIT=1.E-10)
virtual Int_t GetNbinsX() const
bool operator==(ROOT::Fit::BinData &bd1, ROOT::Fit::BinData &bd2)
static const double x2[5]
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
double pol2D(double *x, double *p)
const FitResult & Result() const
get fit result
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void SetMinimizer(const char *type, const char *algo=0)
set minimizer type
void FillData(BinData &dv, const TH1 *hist, TF1 *func=0)
fill the data vector from a TH1.
void GetBinDataNoZeros(BinData &) const
DataOptions : simple structure holding the options on how the data are filled.
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
virtual void Draw(Option_t *option="")
Draw this histogram with options.
3-D histogram with a double per channel (see TH1 documentation)}
A 3-Dim function with parameters.
Fitter class, entry point for performing all type of fits.
void GetBinDataIntegral(BinData &) const
virtual Int_t GetNbinsZ() const
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
Int_t Fill(Double_t)
Invalid Fill method.
A 2-Dim function with parameters.
R__EXTERN TRandom * gRandom
bool LikelihoodFit(const BinData &data, bool extended=true)
Binned Likelihood fit.
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculate a gaussian function with mean and sigma.
ostream & operator<<(ostream &out, ROOT::Fit::BinData &bd)
unsigned int NPoints() const
return number of fit points
static const double x1[5]
void GetBinData(BinData &) const
void Print(std::ostream &os, bool covmat=false) const
print the result and optionaly covariance matrix and correlations
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual Int_t GetNbinsY() const
double gaus3D(double *x, double *p)
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.
double f2(const double *x)
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
const double * GetPoint(unsigned int ipoint, double &value) const
retrieve at the same time a pointer to the coordinate data and the fit value More efficient than call...
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
virtual void Update()
Update canvas pad buffers.
Int_t Fill(Double_t)
Invalid Fill method.
double gaus2D(double *x, double *p)
unsigned int NDim() const
return coordinate data dimension
2-D histogram with a double per channel (see TH1 documentation)}