54 return p[0]*x[0]+ p[1]*x[0]*x[0] + p[2]*x[1] + p[3]*x[1]*x[1] + p[4];
59 const unsigned int ndim( bd.
NDim() );
60 const unsigned int npoints( bd.
NPoints() );
61 for (
unsigned int i = 0; i < npoints; ++i )
63 double value = 0, error = 0;
64 const double *
x = bd.
GetPoint(i, value, error);
65 for (
unsigned int j = 0; j < ndim; ++j )
67 out <<
" x[" << j <<
"]: " << x[j];
69 out <<
" value: " <<
value;
70 out <<
" error: " << error;
78 const unsigned int ndim = bd.
NDim();
79 const unsigned int npoints = bd.
NPoints();
81 for (
unsigned int i = 0; i < npoints; ++i )
83 double value1 = 0, error1 = 0;
84 const double *
x1 = bd.
GetPoint(i, value1, error1);
86 for (
unsigned int j = 0; j < ndim; ++j )
88 thisIsIt &=
fabs(x1[j] - x[j]) < 1
E-15;
90 if ( thisIsIt )
return i;
93 cout <<
"NO ENCONTRADO!";
94 copy(x, x+ndim, ostream_iterator<double>(cout,
" " ));
102 const unsigned int ndim = bd1.
NDim();
103 const unsigned int npoints = bd1.
NPoints();
107 cout <<
"Equals" << endl;
109 for (
unsigned int i = 0; i < npoints &&
equals; ++i )
111 double value1 = 0, error1 = 0;
112 const double *
x1 = bd1.
GetPoint(i, value1, error1);
116 double value2 = 0, error2 = 0;
117 const double *
x2 = bd2.
GetPoint(bin, value2, error2);
119 equals &= ( value1 == value2 );
121 equals &= ( error1 == error2 );
123 for (
unsigned int j = 0; j < ndim; ++j )
125 equals &=
fabs(x1[j] - x2[j]) < 1
E-15;
126 cout <<
" x[" << j <<
"]: " <<
equals;
130 std::copy(x1, &x1[ndim], ostream_iterator<double>(cout,
" "));
131 cout <<
" value:" << value1;
132 cout <<
" error:" << error1;
135 std::copy(x2, &x2[ndim], ostream_iterator<double>(cout,
" "));
136 cout <<
" value:" << value2;
137 cout <<
" error:" << error2;
139 cout <<
" equals: " <<
equals;
153 for (
UInt_t i = 0; i < ndim; ++ i )
156 s->
Fill(points, value );
157 cout << value <<
" " << s->
GetNbins() << endl;
165 cout <<
"DoFit: dim = " << s->
GetNdimensions() <<
" - Retrieving the Sparse Data Structure" << endl;
184 cout <<
"\n ******* Likelihood with BinData and NoZeros *******" << endl;
186 d.GetBinDataNoZeros(bdNoZeros);
190 std::cout <<
"Fit Failed " << std::endl;
193 cout <<
"\n ******* Likelihood with BinData with Zeros *******" << endl;
195 d.GetBinDataIntegral(bdWithZeros);
199 std::cout <<
"Fit Failed " << std::endl;
207 std::cout <<
"1D SPARSE FIT \n" << std::endl;
209 const unsigned int ndim = 1;
218 cout <<
"1D Fit : Retrieving the Sparse Data Structure" << endl;
227 std::cout <<
"2D SPARSE FIT \n" << std::endl;
228 const unsigned int ndim = 2;
235 for (
int ix=1; ix <=
bsize[0]; ++ix) {
236 for (
int iy=1; iy <=
bsize[1]; ++iy) {
244 s1->
Fill( points, value );
252 TH2D* h2 =
new TH2D(
"2D Blanked Hist Fit",
"h1-title",
256 for (
unsigned int i = 0; i < bd.
NPoints(); ++i )
261 value = (
value)?value:-10;
262 h2->
Fill(x[0], x[1], value);
274 const unsigned int ndim = 3;
276 std::cout <<
"3D SPARSE FIT \n" << std::endl;
287 for (
int ix=1; ix <=
bsize[0]; ++ix) {
288 for (
int iy=1; iy <=
bsize[1]; ++iy) {
289 for (
int iz=1; iz <=
bsize[2]; ++iz) {
298 s1->
Fill( points, value );
309 int main(
int argc,
char** argv)
312 bool do3dfit =
false;
315 for (
Int_t i=1 ; i<argc ; i++) {
316 std::string arg = argv[i] ;
328 cerr <<
"Usage: " << argv[0] <<
" [-g] [-v]\n";
330 cerr <<
" -g : graphics mode\n";
331 cerr <<
" -v : verbose mode\n";
332 cerr <<
" -3d : 3d fit";
348 cout <<
"C'est fini!" << endl;
const FitConfig & Config() const
access to the fit configuration (const method)
virtual void SetParameters(const Double_t *params)
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Long64_t Fill(const Double_t *x, Double_t w=1.)
Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions...
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
void DoFit(THnSparse *s, TF1 *f, ROOT::Fit::BinData &bd)
int main(int argc, char **argv)
int equals(Double_t n1, Double_t n2, double ERRORLIMIT=1.E-10)
Long64_t GetNbins() const
THnSparseT< TArrayD > THnSparseD
double pol2D(double *x, double *p)
int findBin(ROOT::Fit::BinData &bd, const double *x)
static const double x2[5]
Int_t GetNdimensions() const
Efficient multidimensional histogram.
bool operator==(ROOT::Fit::BinData &bd1, ROOT::Fit::BinData &bd2)
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
const FitResult & Result() const
get fit result
void fillSparse(THnSparse *s, TF1 *f, int nEvents=5)
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.
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.
A 3-Dim function with parameters.
Fitter class, entry point for performing all type of fits.
ostream & operator<<(ostream &out, ROOT::Fit::BinData &bd)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
TAxis * GetAxis(Int_t dim) const
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.
unsigned int NPoints() const
return number of fit points
static const double x1[5]
void Print(std::ostream &os, bool covmat=false) const
print the result and optionaly covariance matrix and correlations
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
double gaus1D(double *x, double *p)
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
double gaus2D(double *x, double *p)
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
double gaus3D(double *x, double *p)
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...
Templated implementation of the abstract base THnSparse.
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Int_t Fill(Double_t)
Invalid Fill method.
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
unsigned int NDim() const
return coordinate data dimension
2-D histogram with a double per channel (see TH1 documentation)}