162 for (
int i = 0; i<5; ++i)
fINDFLG[i] = 0;
212 gROOT->GetListOfSpecials()->Remove(
this);
344 if (
fFCN) (*fFCN)(npar,grad,fval,par,flag);
385 static TString clower =
"abcdefghijklmnopqrstuvwxyz";
386 static TString cupper =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
387 const Int_t nntot = 40;
388 const char *cname[nntot] = {
433 if (nargs<=0)
fCmPar[0] = 0;
436 if(i<nargs)
fCmPar[i] = args[i];
448 for (ind = 0; ind < nntot; ++ind) {
449 if (strncmp(ctemp.
Data(),cname[ind],3) == 0)
break;
451 if (ind==nntot)
return -3;
452 if (
fCword(0,4) ==
"MINO") ind=3;
454 case 0:
case 3:
case 2:
case 28:
476 if (nargs<1)
return -1;
477 for (i=0;i<nargs;i++) {
483 if (nargs<1)
return 0;
485 for (i=0;i<
fNpar;i++)
494 if (nargs<1)
return -1;
495 for (i=0;i<nargs;i++) {
508 Printf(
"SAVe command is obsolete");
513 {
if(nargs<1)
return -1;
534 case 26:
case 27:
case 29:
case 30:
case 31:
case 32:
536 case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
538 Printf(
"Obsolete command. Use corresponding SET command instead");
551 static Int_t nntot = 30;
552 static const char *cname[30] = {
584 TString cfname, cmode, ckind, cwarn, copt, ctemp, ctemp2;
587 for (ind = 0; ind < nntot; ++ind) {
591 if (strstr(ctemp2.
Data(),ckind.
Data()))
break;
594 if(ctemp2.
Contains(
"SET")) setCommand=
true;
597 if (ind>=nntot)
return -3;
601 if(!setCommand)
Printf(
"FCN=%f",
fS);
605 if (nargs<2 && setCommand)
return -1;
611 if(parnum<0 || parnum>=
fNpar)
return -2;
616 if(parnum<0 || parnum>=
fNpar)
return -2;
619 for (i=0;i<
fNpar;i++)
635 Printf(
"Limits for param %s: Low=%E, High=%E",
639 if(parnum<0 || parnum>=
fNpar)
return -1;
644 if(uplim==lolim)
return -1;
654 fAMN[parnum] = lolim;
655 fAMX[parnum] = uplim;
657 Printf(
"Limits for param %s Low=%E, High=%E",
664 if(setCommand)
return 0;
665 Printf(
"\nCovariant matrix ");
667 for (i=0;i<
fNpar;i++)
if(
fPL0[i]>0.) nn++;
669 for(;
fPL0[nnn]<=0.;nnn++) { }
670 printf(
"%5s: ",
fANames[nnn++].Data());
671 for (
Int_t j=0;j<=i;j++)
672 printf(
"%11.2E",
fZ[
l++]);
673 std::cout<<std::endl;
675 std::cout<<std::endl;
679 if(setCommand)
return 0;
680 Printf(
"\nGlobal correlation factors (maximum correlation of the parameter\n with arbitrary linear combination of other parameters)");
681 for(i=0;i<
fNpar;i++) {
682 printf(
"%5s: ",
fANames[i].Data());
685 std::cout<<std::endl;
690 if(!setCommand)
return 0;
694 if(!setCommand)
return 0;
706 if(!setCommand)
return 0;
710 if(!setCommand)
return 0;
727 Printf(
"Relative floating point precision RP=%E",
fRP);
731 if (pres<1e-5 && pres>1
e-34)
fRP=pres;
741 if(setCommand)
return 0;
742 Printf(
"FUMILI-ROOT version 0.1");
747 if(!setCommand)
return 0;
751 if(!setCommand)
return 0;
767 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]>0.) {
788 if (i < 0 || i >=
fNpar || j < 0 || j >=
fNpar) {
789 Error(
"GetCovarianceMatrixElement",
"Illegal arguments i=%d, j=%d",i,j);
820 if (ipar<0 || ipar>=
fNpar)
return 0;
829 if (ipar<0 || ipar>=
fNpar)
return 0;
830 else return fA[ipar];
846 if (ipar<0 || ipar>=
fNpar) {
853 strcpy(cname,
fANames[ipar].Data());
866 if (ipar < 0 || ipar >
fNpar)
return "";
878 if (ipar<0 || ipar>=
fNpar) {
904 if(
fPL0[ii]>0.) nvpar++;
945 Int_t i, k,
l, ii, ki, li, kk, ni, ll, nk, nl, ir, lk;
954 ap = 1.0e0 / (aps * aps);
956 for (i = 1; i <=
n; ++i) {
959 if (pl_1[ir] <= 0.0e0)
goto L1;
962 ni = i * (i - 1) / 2;
965 if (z_1[ii] <= rp *
TMath::Abs(r_1[ir]) || z_1[ii] <= ap) {
968 z_1[ii] = 1.0e0 / sqrt(z_1[ii]);
971 if (nl - ni <= 0)
goto L5;
981 if (i -
n >= 0)
goto L12;
985 nk = k * (k - 1) / 2;
988 d = z_1[kk] * z_1[ii];
994 z_1[ll] -= z_1[li] *
c;
997 if (
l - i <= 0)
goto L9;
1002 z_1[ll] -= z_1[li] *
d;
1005 if (
l <= 0)
goto L10;
1009 if (k - i - 1 <= 0)
goto L11;
1015 for (i = 1; i <=
n; ++i) {
1016 for (k = i; k <=
n; ++k) {
1017 nl = k * (k - 1) / 2;
1020 for (
l = k;
l <=
n; ++
l) {
1023 d += z_1[li] * z_1[lk];
1026 ki = k * (k - 1) / 2 + i;
1035 for (i = 1; i <= k; ++i) {
1038 if (pl_1[ir] <= 0.0e0) {
1054 if(ipar < 0 || ipar >=
fNpar) {
1055 Warning(
"IsFixed",
"Illegal parameter number :%d",ipar);
1090 for( i = 0; i <
fNpar; i++) {
1095 Int_t nn2,
n, fixFLG, ifix1, fi, nn3, nn1, n0;
1119 for( i=0; i <
n; i++) {
1136 for( i = 0; i <
n; i++) {
1149 for( i=0; i < nn0; i++)
fZ[i]=0.;
1161 if(!ijkl)
return 10;
1168 for( i=0; i < nn0; i++)
fZ0[i] =
fZ[i];
1174 if( 0.59*t < -
fGT)
goto L19;
1176 if (t < 0.25 ) t = 0.25;
1182 for( i = 0; i <
n; i++) {
1199 printf(
"trying to execute an illegal jump at L85\n");
1210 for( i = 0; i <
n; i++) {
1217 if ((
fA[i] >=
fAMX[i] &&
fGr[i] < 0.) ||
1224 for( j=0; j <= i; j++) {
1229 fZ[k2 -1] =
fZ0[k1 -1];
1245 for( i = 0; i <
n; i++) {
1261 fixFLG = fixFLG + 1;
1268 for( i = 0; i <
n; i++) {
1272 for(
l = 0;
l <
n;
l++) {
1276 if (i1 <= l1 ) k=l1*(l1-1)/2+i1;
1277 else k=i1*(i1-1)/2+l1;
1292 for( i = 0; i <
n; i++)
1316 fixFLG = fixFLG + 1;
1330 for( i = 0; i <
n; i++) {
1333 abi =
fA[i] +
fPL[i];
1337 abi =
fA[i] -
fPL[i];
1366 if (alambd > .0) amb = 0.25/alambd;
1367 for( i = 0; i <
n; i++) {
1439 for ( i = 0; i <
n; i++)
fA[i] =
fA[i] +
fDA[i];
1440 if (imax >= 0)
fA[imax] = aiMAX;
1450 if(
fPL0[ip] > .0) {
1451 for(
Int_t jp = 0; jp <= ip; jp++) {
1479 TString colhdu[3],colhdl[3],cx2,cx3;
1482 exitStatus=
"CONVERGED";
1485 exitStatus=
"CONST FCN";
1486 xsexpl=
"****\n* FUNCTION IS NOT DECREASING OR BAD DERIVATIVES\n****";
1489 exitStatus=
"ERRORS INF";
1490 xsexpl=
"****\n* ESTIMATED ERRORS ARE INfiNITE\n****";
1493 exitStatus=
"MAX ITER.";
1494 xsexpl=
"****\n* MAXIMUM NUMBER OF ITERATIONS IS EXCEEDED\n****";
1497 exitStatus=
"ZERO PROBAB";
1498 xsexpl=
"****\n* PROBABILITY OF LIKLIHOOD FUNCTION IS NEGATIVE OR ZERO\n****";
1501 exitStatus=
"UNDEfiNED";
1502 xsexpl=
"****\n* fiT IS IN PROGRESS\n****";
1507 colhdl[0] =
" ERROR ";
1508 colhdu[1] =
" PHYSICAL";
1509 colhdu[2] =
" LIMITS ";
1510 colhdl[1] =
" NEGATIVE ";
1511 colhdl[2] =
" POSITIVE ";
1515 colhdl[0] =
" ERROR ";
1516 colhdu[1] =
" INTERNAL ";
1517 colhdl[1] =
" STEP SIZE ";
1518 colhdu[2] =
" INTERNAL ";
1519 colhdl[2] =
" VALUE ";
1523 colhdl[0] =
" ERROR ";
1524 colhdu[1] =
" STEP ";
1525 colhdl[1] =
" SIZE ";
1526 colhdu[2] =
" fiRST ";
1527 colhdl[2] =
" DERIVATIVE";
1530 colhdu[0] =
" PARABOLIC ";
1531 colhdl[0] =
" ERROR ";
1532 colhdu[1] =
" MINOS ";
1533 colhdu[2] =
"ERRORS ";
1534 colhdl[1] =
" NEGATIVE ";
1535 colhdl[2] =
" POSITIVE ";
1538 Printf(
" FCN=%g FROM FUMILI STATUS=%-10s %9d CALLS OF FCN",
1541 Printf(
" EXT PARAMETER %-14s%-14s%-14s",
1542 (
const char*)colhdu[0].Data()
1543 ,(
const char*)colhdu[1].Data()
1544 ,(
const char*)colhdu[2].Data());
1545 Printf(
" NO. NAME VALUE %-14s%-14s%-14s",
1546 (
const char*)colhdl[0].Data()
1547 ,(
const char*)colhdl[1].Data()
1548 ,(
const char*)colhdl[2].Data());
1562 cx3 =
Form(
"%14.5e",
fA[i]);
1565 cx2 =
" *undefined* ";
1566 cx3 =
" *undefined* ";
1568 if(
fPL0[i]<=0.) { cx2=
" *fixed* ";cx3=
""; }
1569 Printf(
"%4d %-11s%14.5e%14.5e%-14s%-14s",i+1
1579 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]<=0.) {
1634 if (ipar<0 || ipar>=
fNpar)
return -1;
1665 Int_t i,j,
l,k2=1,k1,ki=0;
1699 fS =
fS + (
y*
y/(sig*sig))*.5;
1702 for (i=0;i<
fNpar;i++) {
1705 fGr[i] += df[
n]*(
y/sig);
1712 fZ[
l++] += df[i]*df[j];
1749 if(flag == 9)
return;
1760 if (nd > 2)
x[2] = cache[4];
1761 if (nd > 1)
x[1] = cache[3];
1772 for (j=0;j<npar;j++) {
1776 gin[j] += df[
n]*fsum;
1782 for (
Int_t k=0;k<=j;k++)
1783 zik[
l++] += df[j]*df[k];
1816 if(flag == 9)
return;
1830 fu =
f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
1831 }
else if (nd < 3) {
1832 fu = ((
TF2*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5])/(cache[3]*cache[5]);
1834 fu = ((
TF3*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5],cache[6] - 0.5*cache[7],cache[6] + 0.5*cache[7])/(cache[3]*cache[5]*cache[7]);
1842 for (j=0;j<npar;j++) {
1846 gin[j] += df[
n]*fsum;
1852 for (
Int_t k=0;k<=j;k++)
1853 zik[
l++] += df[j]*df[k];
1897 if(flag == 9)
return;
1899 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
1906 if (nd > 2)
x[2] = cache[4];
1907 if (nd > 1)
x[1] = cache[3];
1914 for (j=0;j<npar;j++) {
1919 if (fu < 1.e-9) fu = 1.e-9;
1928 for (j=0;j<npar;j++) {
1930 df[
n] = df[j]*(icu/fu-1);
1939 for (
Int_t k=0;k<=j;k++)
1940 zik[
l++] += df[j]*df[k];
1982 if(flag == 9) {
delete [] df;
return;}
1983 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
1990 if (nd > 2)
x[2] = cache[4];
1991 if (nd > 1)
x[1] = cache[3];
1996 fu =
f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
1997 }
else if (nd < 3) {
1998 fu = ((
TF2*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5])/(cache[3]*cache[5]);
2000 fu = ((
TF3*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5],cache[6] - 0.5*cache[7],cache[6] + 0.5*cache[7])/(cache[3]*cache[5]*cache[7]);
2004 for (j=0;j<npar;j++) {
2009 if (fu < 1.e-9) fu = 1.e-9;
2018 for (j=0;j<npar;j++) {
2020 df[
n] = df[j]*(icu/fu-1);
2029 for (
Int_t k=0;k<=j;k++)
2030 zik[
l++] += df[j]*df[k];
2109 Int_t i, bin, npfits=0;
2123 if(flag == 9)
return;
2131 for (bin=0;bin<
n;bin++) {
2146 if (exl < 0) exl = 0;
2147 if (exh < 0) exh = 0;
2149 if (exh > 0 && exl > 0) {
2155 if (eu <= 0) eu = 1;
2160 fsum = (fu-cu)/eusq;
2161 for (i=0;i<npar;i++) {
2165 gin[i] += df[
n]*fsum;
2171 for (
Int_t j=0;j<=i;j++)
2172 zik[
l++] += df[i]*df[j];
static const Double_t gMAXDOUBLE
void H1FitChisquareFumili(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method.
void GraphFitChisquareFumili(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for Graphs using a Chisquare method.
void H1FitLikelihoodFumili(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method.
static const Double_t gMINDOUBLE
R__EXTERN TFumili * gFumili
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
static void RejectPoint(Bool_t reject=kTRUE)
Static function to set the global flag to reject points the fgRejectPoint global flag is tested by al...
virtual Int_t GetNpar() const
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
IntegralOneDim or analytical integral.
virtual Double_t Derivative(Double_t x, Double_t *params=0, Double_t epsilon=0.001) const
Returns the first derivative of the function at point x, computed by Richardson's extrapolation metho...
virtual void SetNumberFitPoints(Int_t npfits)
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
static Bool_t RejectedPoint()
See TF1::RejectPoint above.
virtual void SetParameters(const Double_t *params)
virtual Bool_t IsInside(const Double_t *x) const
return kTRUE if the point is inside the function range
A 2-Dim function with parameters.
A 3-Dim function with parameters.
void DeleteArrays()
Deallocates memory. Called from destructor TFumili::~TFumili.
Bool_t fNumericDerivatives
virtual Int_t GetNumberFreeParameters() const
Return the number of free parameters.
Int_t fNED2
K - Length of vector X plus 2 (for chi2)
virtual Double_t Chisquare(Int_t npar, Double_t *params) const
return a chisquare equivalent
Int_t fNpar
fNpar - number of parameters
virtual Double_t GetParError(Int_t ipar) const
Return error of parameter ipar.
virtual void PrintResults(Int_t k, Double_t p) const
Prints fit results.
virtual ~TFumili()
TFumili destructor.
virtual Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const
Return errors after MINOs not implemented.
virtual void SetFitMethod(const char *name)
ret fit method (chisquare or log-likelihood)
virtual void FitLikelihood(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method.
virtual Double_t GetSumLog(Int_t)
Return Sum(log(i) i=0,n used by log-likelihood fits.
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
Execute MINUIT commands.
Double_t * fEXDA
[fNED12] experimental data poInt_ter
virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const
Return element i,j from the covariance matrix.
Int_t SGZ()
Evaluates objective function ( chi-square ), gradients and Z-matrix using data provided by user via T...
virtual void FitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method.
void Derivatives(Double_t *, Double_t *)
Calculates partial derivatives of theoretical function.
Double_t * fAMN
[fMaxParam] Minimum param value
TString * fANames
[fMaxParam] Parameter names
virtual void FixParameter(Int_t ipar)
Fixes parameter number ipar.
Double_t * GetPL0() const
Double_t * fPL
[fMaxParam] Limits for parameters step. If <0, then parameter is fixed
Int_t Eval(Int_t &npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag)
Evaluate the minimisation function.
void SetParNumber(Int_t ParNum)
void SetData(Double_t *, Int_t, Int_t)
Sets pointer to data array provided by user.
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const
Return global fit parameters.
Int_t fINDFLG[5]
internal flags;
Double_t EvalTFN(Double_t *, Double_t *)
Evaluate theoretical function.
Double_t * fParamError
[fMaxParam] Parameter errors
Int_t fENDFLG
End flag of fit.
Double_t * fR
[fMaxParam] Correlation factors
Double_t * fDA
[fMaxParam] Parameter step
Int_t fNstepDec
fNstepDec - maximum number of step decreasing counter
Double_t * fZ0
[fMaxParam2] Matrix of approximate second derivatives of objective function This matrix is diagonal a...
Double_t * fPL0
[fMaxParam] Step initial bounds
virtual Bool_t IsFixed(Int_t ipar) const
Return kTRUE if parameter ipar is fixed, kFALSE otherwise)
virtual void ReleaseParameter(Int_t ipar)
Releases parameter number ipar.
virtual Double_t * GetCovarianceMatrix() const
Return a pointer to the covariance matrix.
Double_t * fA
[fMaxParam] Fit parameter array
Int_t Minimize()
Main minimization procedure.
Int_t fNmaxIter
fNmaxIter - maximum number of iterations
Int_t ExecuteSetCommand(Int_t)
Called from TFumili::ExecuteCommand in case of "SET xxx" and "SHOW xxx".
Double_t fS
fS - objective function value (return)
Double_t fEPS
fEPS - required precision of parameters. If fEPS<0 then
virtual void FitChisquareI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method.
Int_t fNfcn
Number of FCN calls;.
Int_t fLastFixed
Last fixed parameter number.
void BuildArrays()
Allocates memory for internal arrays.
virtual Int_t GetNumberTotalParameters() const
Return the total number of parameters (free + fixed)
Double_t * fZ
[fMaxParam2] Invers fZ0 matrix - covariance matrix
Bool_t fLogLike
LogLikelihood flag.
Int_t fNED1
Number of experimental vectors X=(x1,x2,...xK)
Double_t * fGr
[fMaxParam] Gradients of objective function
Double_t fGT
Expected function change in next iteration.
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)
Sets for parameter number ipar initial parameter value, name parname, initial error verr and limits v...
TString fCword
Command string.
virtual void FitLikelihoodI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method.
Double_t fRP
Precision of fit ( machine zero on CDC 6000) quite old yeh?
virtual Double_t GetParameter(Int_t ipar) const
Return current value of parameter ipar.
Double_t * fCmPar
[fMaxParam] parameters of commands
Double_t * fDF
[fMaxParam] First derivatives of theoretical function
virtual void Clear(Option_t *opt="")
Resets all parameter names, values and errors to zero.
virtual const char * GetParName(Int_t ipar) const
Return name of parameter ipar.
Double_t * fSumLog
[fNlog]
Double_t * fAMX
[fMaxParam] Maximum param value
Int_t fNlimMul
fNlimMul - after fNlimMul successful iterations permits four-fold increasing of fPL
Bool_t fGRAD
user calculated gradients
void InvertZ(Int_t)
Inverts packed diagonal matrix Z by square-root method.
Double_t GetErrorXhigh(Int_t bin) const
It returns the error along X at point i.
Double_t GetErrorXlow(Int_t bin) const
It returns the error along X at point i.
Double_t GetErrorY(Int_t bin) const
It returns the error along Y at point i.
A TGraph is an object made of two arrays X and Y with npoints each.
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetDimension() const
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kInvalidObject
if object ctor succeeded but object should not be used
const char * Data() const
void ToUpper()
Change string to upper case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Int_t fPointSize
Number of words per point in the cache.
virtual TObject * GetObjectFit() const
TObject * fUserFunc
Pointer to user theoretical function (a TF1*)
virtual Foption_t GetFitOption() const
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...
Double_t * fCache
[fCacheSize] Array of points data (fNpoints*fPointSize < fCacheSize words)
void(* fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual TObject * GetUserFunc() const
Int_t fNpoints
Number of points to fit.
Short_t Max(Short_t a, Short_t b)
Double_t Sqrt(Double_t x)