161 for (
int i = 0; i<5; ++i)
fINDFLG[i] = 0;
211 gROOT->GetListOfSpecials()->Remove(
this);
343 if (
fFCN) (*fFCN)(npar,grad,fval,par,flag);
384 static TString clower =
"abcdefghijklmnopqrstuvwxyz";
385 static TString cupper =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
386 const Int_t nntot = 40;
387 const char *cname[nntot] = {
432 if (nargs<=0)
fCmPar[0] = 0;
435 if(i<nargs)
fCmPar[i] = args[i];
447 for (ind = 0; ind < nntot; ++ind) {
448 if (strncmp(ctemp.
Data(),cname[ind],3) == 0)
break;
450 if (ind==nntot)
return -3;
451 if (
fCword(0,4) ==
"MINO") ind=3;
453 case 0:
case 3:
case 2:
case 28:
475 if (nargs<1)
return -1;
476 for (i=0;i<nargs;i++) {
482 if (nargs<1)
return 0;
484 for (i=0;i<
fNpar;i++)
493 if (nargs<1)
return -1;
494 for (i=0;i<nargs;i++) {
507 Printf(
"SAVe command is obsolete");
512 {
if(nargs<1)
return -1;
533 case 26:
case 27:
case 29:
case 30:
case 31:
case 32:
535 case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
537 Printf(
"Obsolete command. Use corresponding SET command instead");
550 static Int_t nntot = 30;
551 static const char *cname[30] = {
583 TString cfname, cmode, ckind, cwarn, copt, ctemp, ctemp2;
586 for (ind = 0; ind < nntot; ++ind) {
590 if (strstr(ctemp2.
Data(),ckind.
Data()))
break;
593 if(ctemp2.
Contains(
"SET")) setCommand=
true;
596 if (ind>=nntot)
return -3;
600 if(!setCommand)
Printf(
"FCN=%f",
fS);
604 if (nargs<2 && setCommand)
return -1;
610 if(parnum<0 || parnum>=
fNpar)
return -2;
615 if(parnum<0 || parnum>=
fNpar)
return -2;
618 for (i=0;i<
fNpar;i++)
634 Printf(
"Limits for param %s: Low=%E, High=%E",
638 if(parnum<0 || parnum>=
fNpar)
return -1;
643 if(uplim==lolim)
return -1;
653 fAMN[parnum] = lolim;
654 fAMX[parnum] = uplim;
656 Printf(
"Limits for param %s Low=%E, High=%E",
663 if(setCommand)
return 0;
664 Printf(
"\nCovariant matrix ");
666 for (i=0;i<
fNpar;i++)
if(
fPL0[i]>0.) nn++;
668 for(;
fPL0[nnn]<=0.;nnn++) { }
669 printf(
"%5s: ",
fANames[nnn++].Data());
670 for (
Int_t j=0;j<=i;j++)
671 printf(
"%11.2E",
fZ[
l++]);
672 std::cout<<std::endl;
674 std::cout<<std::endl;
678 if(setCommand)
return 0;
679 Printf(
"\nGlobal correlation factors (maximum correlation of the parameter\n with arbitrary linear combination of other parameters)");
680 for(i=0;i<
fNpar;i++) {
681 printf(
"%5s: ",
fANames[i].Data());
684 std::cout<<std::endl;
689 if(!setCommand)
return 0;
693 if(!setCommand)
return 0;
705 if(!setCommand)
return 0;
709 if(!setCommand)
return 0;
726 Printf(
"Relative floating point precision RP=%E",
fRP);
730 if (pres<1e-5 && pres>1
e-34)
fRP=pres;
740 if(setCommand)
return 0;
741 Printf(
"FUMILI-ROOT version 0.1");
746 if(!setCommand)
return 0;
750 if(!setCommand)
return 0;
766 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]>0.) {
787 if (i < 0 || i >=
fNpar || j < 0 || j >=
fNpar) {
788 Error(
"GetCovarianceMatrixElement",
"Illegal arguments i=%d, j=%d",i,j);
819 if (ipar<0 || ipar>=
fNpar)
return 0;
828 if (ipar<0 || ipar>=
fNpar)
return 0;
829 else return fA[ipar];
845 if (ipar<0 || ipar>=
fNpar) {
852 strcpy(cname,
fANames[ipar].Data());
865 if (ipar < 0 || ipar >
fNpar)
return "";
877 if (ipar<0 || ipar>=
fNpar) {
903 if(
fPL0[ii]>0.) nvpar++;
944 Int_t i, k,
l, ii, ki, li, kk, ni, ll, nk, nl, ir, lk;
953 ap = 1.0e0 / (aps * aps);
955 for (i = 1; i <=
n; ++i) {
958 if (pl_1[ir] <= 0.0e0)
goto L1;
961 ni = i * (i - 1) / 2;
964 if (z_1[ii] <= rp *
TMath::Abs(r_1[ir]) || z_1[ii] <= ap) {
967 z_1[ii] = 1.0e0 /
sqrt(z_1[ii]);
970 if (nl - ni <= 0)
goto L5;
980 if (i -
n >= 0)
goto L12;
984 nk = k * (k - 1) / 2;
987 d = z_1[kk] * z_1[ii];
993 z_1[ll] -= z_1[li] *
c;
996 if (
l - i <= 0)
goto L9;
1001 z_1[ll] -= z_1[li] *
d;
1004 if (
l <= 0)
goto L10;
1008 if (k - i - 1 <= 0)
goto L11;
1014 for (i = 1; i <=
n; ++i) {
1015 for (k = i; k <=
n; ++k) {
1016 nl = k * (k - 1) / 2;
1019 for (
l = k;
l <=
n; ++
l) {
1022 d += z_1[li] * z_1[lk];
1025 ki = k * (k - 1) / 2 + i;
1034 for (i = 1; i <= k; ++i) {
1037 if (pl_1[ir] <= 0.0e0) {
1053 if(ipar < 0 || ipar >=
fNpar) {
1054 Warning(
"IsFixed",
"Illegal parameter number :%d",ipar);
1089 for( i = 0; i <
fNpar; i++) {
1094 Int_t nn2,
n, fixFLG, ifix1, fi, nn3, nn1, n0;
1118 for( i=0; i <
n; i++) {
1135 for( i = 0; i <
n; i++) {
1148 for( i=0; i < nn0; i++)
fZ[i]=0.;
1160 if(!ijkl)
return 10;
1167 for( i=0; i < nn0; i++)
fZ0[i] =
fZ[i];
1173 if( 0.59*t < -
fGT)
goto L19;
1175 if (t < 0.25 ) t = 0.25;
1181 for( i = 0; i <
n; i++) {
1198 printf(
"trying to execute an illegal jump at L85\n");
1209 for( i = 0; i <
n; i++) {
1216 if ((
fA[i] >=
fAMX[i] &&
fGr[i] < 0.) ||
1223 for( j=0; j <= i; j++) {
1228 fZ[k2 -1] =
fZ0[k1 -1];
1244 for( i = 0; i <
n; i++) {
1260 fixFLG = fixFLG + 1;
1267 for( i = 0; i <
n; i++) {
1271 for(
l = 0;
l <
n;
l++) {
1275 if (i1 <= l1 ) k=l1*(l1-1)/2+i1;
1276 else k=i1*(i1-1)/2+l1;
1291 for( i = 0; i <
n; i++)
1315 fixFLG = fixFLG + 1;
1329 for( i = 0; i <
n; i++) {
1332 abi =
fA[i] +
fPL[i];
1336 abi =
fA[i] -
fPL[i];
1365 if (alambd > .0) amb = 0.25/alambd;
1366 for( i = 0; i <
n; i++) {
1438 for ( i = 0; i <
n; i++)
fA[i] =
fA[i] +
fDA[i];
1439 if (imax >= 0)
fA[imax] = aiMAX;
1449 if(
fPL0[ip] > .0) {
1450 for(
Int_t jp = 0; jp <= ip; jp++) {
1478 TString colhdu[3],colhdl[3],cx2,cx3;
1481 exitStatus=
"CONVERGED";
1484 exitStatus=
"CONST FCN";
1485 xsexpl=
"****\n* FUNCTION IS NOT DECREASING OR BAD DERIVATIVES\n****";
1488 exitStatus=
"ERRORS INF";
1489 xsexpl=
"****\n* ESTIMATED ERRORS ARE INfiNITE\n****";
1492 exitStatus=
"MAX ITER.";
1493 xsexpl=
"****\n* MAXIMUM NUMBER OF ITERATIONS IS EXCEEDED\n****";
1496 exitStatus=
"ZERO PROBAB";
1497 xsexpl=
"****\n* PROBABILITY OF LIKLIHOOD FUNCTION IS NEGATIVE OR ZERO\n****";
1500 exitStatus=
"UNDEfiNED";
1501 xsexpl=
"****\n* fiT IS IN PROGRESS\n****";
1506 colhdl[0] =
" ERROR ";
1507 colhdu[1] =
" PHYSICAL";
1508 colhdu[2] =
" LIMITS ";
1509 colhdl[1] =
" NEGATIVE ";
1510 colhdl[2] =
" POSITIVE ";
1514 colhdl[0] =
" ERROR ";
1515 colhdu[1] =
" INTERNAL ";
1516 colhdl[1] =
" STEP SIZE ";
1517 colhdu[2] =
" INTERNAL ";
1518 colhdl[2] =
" VALUE ";
1522 colhdl[0] =
" ERROR ";
1523 colhdu[1] =
" STEP ";
1524 colhdl[1] =
" SIZE ";
1525 colhdu[2] =
" fiRST ";
1526 colhdl[2] =
" DERIVATIVE";
1529 colhdu[0] =
" PARABOLIC ";
1530 colhdl[0] =
" ERROR ";
1531 colhdu[1] =
" MINOS ";
1532 colhdu[2] =
"ERRORS ";
1533 colhdl[1] =
" NEGATIVE ";
1534 colhdl[2] =
" POSITIVE ";
1537 Printf(
" FCN=%g FROM FUMILI STATUS=%-10s %9d CALLS OF FCN",
1540 Printf(
" EXT PARAMETER %-14s%-14s%-14s",
1541 (
const char*)colhdu[0].Data()
1542 ,(
const char*)colhdu[1].Data()
1543 ,(
const char*)colhdu[2].Data());
1544 Printf(
" NO. NAME VALUE %-14s%-14s%-14s",
1545 (
const char*)colhdl[0].Data()
1546 ,(
const char*)colhdl[1].Data()
1547 ,(
const char*)colhdl[2].Data());
1561 cx3 =
Form(
"%14.5e",
fA[i]);
1564 cx2 =
" *undefined* ";
1565 cx3 =
" *undefined* ";
1567 if(
fPL0[i]<=0.) { cx2=
" *fixed* ";cx3=
""; }
1568 Printf(
"%4d %-11s%14.5e%14.5e%-14s%-14s",i+1
1578 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]<=0.) {
1633 if (ipar<0 || ipar>=
fNpar)
return -1;
1664 Int_t i,j,
l,k2=1,k1,ki=0;
1698 fS =
fS + (
y*
y/(sig*sig))*.5;
1701 for (i=0;i<
fNpar;i++) {
1704 fGr[i] += df[
n]*(
y/sig);
1711 fZ[
l++] += df[i]*df[j];
1748 if(flag == 9)
return;
1759 if (nd > 2)
x[2] = cache[4];
1760 if (nd > 1)
x[1] = cache[3];
1771 for (j=0;j<npar;j++) {
1775 gin[j] += df[
n]*fsum;
1781 for (
Int_t k=0;k<=j;k++)
1782 zik[
l++] += df[j]*df[k];
1815 if(flag == 9)
return;
1829 fu =
f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
1830 }
else if (nd < 3) {
1831 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]);
1833 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]);
1841 for (j=0;j<npar;j++) {
1845 gin[j] += df[
n]*fsum;
1851 for (
Int_t k=0;k<=j;k++)
1852 zik[
l++] += df[j]*df[k];
1896 if(flag == 9)
return;
1898 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
1905 if (nd > 2)
x[2] = cache[4];
1906 if (nd > 1)
x[1] = cache[3];
1913 for (j=0;j<npar;j++) {
1918 if (fu < 1.e-9) fu = 1.e-9;
1927 for (j=0;j<npar;j++) {
1929 df[
n] = df[j]*(icu/fu-1);
1938 for (
Int_t k=0;k<=j;k++)
1939 zik[
l++] += df[j]*df[k];
1981 if(flag == 9) {
delete [] df;
return;}
1982 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
1989 if (nd > 2)
x[2] = cache[4];
1990 if (nd > 1)
x[1] = cache[3];
1995 fu =
f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
1996 }
else if (nd < 3) {
1997 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]);
1999 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]);
2003 for (j=0;j<npar;j++) {
2008 if (fu < 1.e-9) fu = 1.e-9;
2017 for (j=0;j<npar;j++) {
2019 df[
n] = df[j]*(icu/fu-1);
2028 for (
Int_t k=0;k<=j;k++)
2029 zik[
l++] += df[j]*df[k];
2108 Int_t i, bin, npfits=0;
2122 if(flag == 9)
return;
2130 for (bin=0;bin<
n;bin++) {
2145 if (exl < 0) exl = 0;
2146 if (exh < 0) exh = 0;
2148 if (exh > 0 && exl > 0) {
2154 if (
eu <= 0)
eu = 1;
2159 fsum = (fu-cu)/eusq;
2160 for (i=0;i<npar;i++) {
2164 gin[i] += df[
n]*fsum;
2170 for (
Int_t j=0;j<=i;j++)
2171 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
float type_of_call hi(const int &, const int &)
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
This function is called by GraphFitChisquare.
Double_t GetErrorXlow(Int_t bin) const
This function is called by GraphFitChisquare.
Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
A Graph is a graphics object made of two arrays X and Y with npoints each.
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
virtual TObject * GetObjectFit() const
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...
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
static constexpr double pi
static constexpr double eplus
Short_t Max(Short_t a, Short_t b)
Double_t Sqrt(Double_t x)