26void makeData(
double*
x,
double&
d,
double&
e)
29 double upp[5] = { 10, 10, 10, 10, 1 };
30 double low[5] = { 0, 0, 0, 0, .1 };
31 for (
int i = 0; i < 4; i++)
32 x[i] = (upp[i] - low[i]) *
gRandom->Rndm() + low[i];
46 double GoodCoeffsNoFit[] = {
71 double GoodCoeffs[] = {
124 if (nc != 21)
return 1;
127 for (
int i=0;i<nc;i++) {
132 if (
TMath::Abs((*coeffs)[i] - GoodCoeffsNoFit[i]) > 5
e-5)
return 2;
134 for (
int j=0;j<nv;j++) {
135 if (powers[pindex[i]*nv+j] != GoodPower[k])
return 3;
141 gROOT->ProcessLine(
".L MDF.C");
143 double refMDF = (doFit) ? 43.95 : 43.98;
148 std::intptr_t iret =
gROOT->ProcessLine(
" double xvalues[] = {5,5,5,5}; double result=MDF(xvalues); &result;");
149 double rMDF = * ( (
double*)iret);
156int multidimfit(
bool doFit =
true)
159 std::cout <<
"*************************************************" << std::endl;
160 std::cout <<
"* Multidimensional Fit *" << std::endl;
161 std::cout <<
"* *" << std::endl;
162 std::cout <<
"* By Christian Holm <cholm@nbi.dk> 14/10/00 *" << std::endl;
163 std::cout <<
"*************************************************" << std::endl;
164 std::cout << std::endl;
170 TFile* output =
new TFile(
"mdf.root",
"RECREATE");
180 int mPowers[] = { 6 , 6, 6, 6 };
197 printf(
"======================================\n");
201 for (i = 0; i < nData ; i++) {
224 double *xMax =
new double[nVars];
225 double *xMin =
new double[nVars];
226 for (i = 0; i < nVars; i++) {
235 for (i = 0; i < nData ; i++) {
239 for (j = 0; j < nVars; j++)
240 if (
x[j] < xMin[j] ||
x[j] > xMax[j])
268 int compare = CompareResults(fit, doFit);
270 printf(
"\nmultidimfit .............................................. OK\n");
272 printf(
"\nmultidimfit .............................................. fails case %d\n",compare);
TVectorT< Double_t > TVectorD
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) override
Write memory objects to this file.
void Close(Option_t *option="") override
Close a file.
Multidimensional Fits in ROOT.
void Print(Option_t *option="ps") const override
Print statistics etc. Options are P Parameters S Statistics C Coefficients R Result of parameterisati...
Int_t GetNCoefficients() const
void SetMaxStudy(Int_t n)
void SetMaxFunctions(Int_t n)
virtual void MakeHistograms(Option_t *option="A")
void SetMaxTerms(Int_t terms)
Int_t GetNVariables() const
virtual void AddRow(const Double_t *x, Double_t D, Double_t E=0)
const TVectorD * GetMaxVariables() const
void SetPowerLimit(Double_t limit=1e-3)
Set the user parameter for the function selection. The bigger the limit, the more functions are used....
const TVectorD * GetMinVariables() const
const Int_t * GetPowers() const
virtual void FindParameterization(Option_t *option="")
void SetMaxPowers(const Int_t *powers)
Set the maximum power to be considered in the fit for each variable. See also class description.
virtual void Fit(Option_t *option="")
void SetMinRelativeError(Double_t error)
Set the acceptable relative error for when sum of square residuals is considered minimized....
void SetMaxAngle(Double_t angle=0)
Set the max angle (in degrees) between the initial data vector to be fitted, and the new candidate fu...
virtual void MakeCode(const char *functionName="MDF", Option_t *option="")
Int_t * GetPowerIndex() const
virtual void AddTestRow(const Double_t *x, Double_t D, Double_t E=0)
void SetMinAngle(Double_t angle=1)
Set the min angle (in degrees) between a new candidate function and the subspace spanned by the previ...
const TVectorD * GetCoefficients() const
This is the base class for the ROOT Random number generators.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Comparing floating points.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.