162 for (
int i = 0; i<5; ++i)
fINDFLG[i] = 0;
166 gROOT->GetListOfSpecials()->Add(gFumili);
214 gROOT->GetListOfSpecials()->Remove(
this);
215 if (gFumili ==
this) gFumili = 0;
310 if (
fAMN[i]-ai+hi<0) {
395 static TString clower =
"abcdefghijklmnopqrstuvwxyz";
396 static TString cupper =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
397 const Int_t nntot = 40;
398 const char *cname[nntot] = {
443 if (nargs<=0)
fCmPar[0] = 0;
446 if(i<nargs)
fCmPar[i] = args[i];
458 for (ind = 0; ind < nntot; ++ind) {
459 if (strncmp(ctemp.
Data(),cname[ind],3) == 0)
break;
461 if (ind==nntot)
return -3;
462 if (
fCword(0,4) ==
"MINO") ind=3;
464 case 0:
case 3:
case 2:
case 28:
486 if (nargs<1)
return -1;
487 for (i=0;i<nargs;i++) {
493 if (nargs<1)
return 0;
495 for (i=0;i<
fNpar;i++)
504 if (nargs<1)
return -1;
505 for (i=0;i<nargs;i++) {
518 Printf(
"SAVe command is obsolete");
523 {
if(nargs<1)
return -1;
544 case 26:
case 27:
case 29:
case 30:
case 31:
case 32:
546 case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
548 Printf(
"Obsolete command. Use corresponding SET command instead");
565 static Int_t nntot = 30;
566 static const char *cname[30] = {
598 TString cfname, cmode, ckind, cwarn, copt, ctemp, ctemp2;
601 for (ind = 0; ind < nntot; ++ind) {
605 if (strstr(ctemp2.
Data(),ckind.
Data()))
break;
608 if(ctemp2.
Contains(
"SET")) setCommand=
true;
611 if (ind>=nntot)
return -3;
615 if(!setCommand)
Printf(
"FCN=%f",
fS);
619 if (nargs<2 && setCommand)
return -1;
625 if(parnum<0 || parnum>=
fNpar)
return -2;
630 if(parnum<0 || parnum>=
fNpar)
return -2;
633 for (i=0;i<
fNpar;i++)
649 Printf(
"Limits for param %s: Low=%E, High=%E",
653 if(parnum<0 || parnum>=
fNpar)
return -1;
658 if(uplim==lolim)
return -1;
668 fAMN[parnum] = lolim;
669 fAMX[parnum] = uplim;
671 Printf(
"Limits for param %s Low=%E, High=%E",
678 if(setCommand)
return 0;
679 Printf(
"\nCovariant matrix ");
681 for (i=0;i<fNpar;i++) if(fPL0[i]>0.) nn++;
683 for(;
fPL0[nnn]<=0.;nnn++) { }
685 for (
Int_t j=0;j<=i;j++)
687 std::cout<<std::endl;
689 std::cout<<std::endl;
693 if(setCommand)
return 0;
694 Printf(
"\nGlobal correlation factors (maximum correlation of the parameter\n with arbitrary linear combination of other parameters)");
695 for(i=0;i<
fNpar;i++) {
699 std::cout<<std::endl;
704 if(!setCommand)
return 0;
708 if(!setCommand)
return 0;
720 if(!setCommand)
return 0;
724 if(!setCommand)
return 0;
741 Printf(
"Relative floating point presicion RP=%E",
fRP);
745 if (pres<1e-5 && pres>1e-34)
fRP=pres;
755 if(setCommand)
return 0;
756 Printf(
"FUMILI-ROOT version 0.1");
761 if(!setCommand)
return 0;
765 if(!setCommand)
return 0;
781 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]>0.) {
802 if (i < 0 || i >=
fNpar || j < 0 || j >=
fNpar) {
803 Error(
"GetCovarianceMatrixElement",
"Illegal arguments i=%d, j=%d",i,j);
835 if (ipar<0 || ipar>=
fNpar)
return 0;
844 if (ipar<0 || ipar>=
fNpar)
return 0;
845 else return fA[ipar];
861 if (ipar<0 || ipar>=
fNpar) {
881 if (ipar < 0 || ipar >
fNpar)
return "";
893 if (ipar<0 || ipar>=
fNpar) {
965 Int_t i, k,
l,
ii, ki, li, kk, ni, ll, nk, nl, ir, lk;
974 ap = 1.0e0 / (aps * aps);
976 for (i = 1; i <=
n; ++i) {
979 if (pl_1[ir] <= 0.0e0)
goto L1;
982 ni = i * (i - 1) / 2;
985 if (z_1[ii] <= rp *
TMath::Abs(r_1[ir]) || z_1[
ii] <= ap) {
988 z_1[
ii] = 1.0e0 /
sqrt(z_1[ii]);
991 if (nl - ni <= 0)
goto L5;
1001 if (i - n >= 0)
goto L12;
1005 nk = k * (k - 1) / 2;
1008 d = z_1[kk] * z_1[
ii];
1014 z_1[ll] -= z_1[li] *
c;
1017 if (l - i <= 0)
goto L9;
1022 z_1[ll] -= z_1[li] *
d;
1025 if (l <= 0)
goto L10;
1029 if (k - i - 1 <= 0)
goto L11;
1035 for (i = 1; i <=
n; ++i) {
1036 for (k = i; k <=
n; ++k) {
1037 nl = k * (k - 1) / 2;
1040 for (l = k; l <=
n; ++
l) {
1043 d += z_1[li] * z_1[lk];
1046 ki = k * (k - 1) / 2 + i;
1055 for (i = 1; i <= k; ++i) {
1058 if (pl_1[ir] <= 0.0e0) {
1077 if(ipar < 0 || ipar >=
fNpar) {
1078 Warning(
"IsFixed",
"Illegal parameter number :%d",ipar);
1122 for( i = 0; i <
fNpar; i++) {
1127 Int_t nn2,
n, fixFLG, ifix1, fi, nn3, nn1, n0;
1151 for( i=0; i <
n; i++) {
1168 for( i = 0; i <
n; i++) {
1181 for( i=0; i < nn0; i++)
fZ[i]=0.;
1193 if(!ijkl)
return 10;
1200 for( i=0; i < nn0; i++)
fZ0[i] =
fZ[i];
1205 if (TMath::Abs(
fS-olds) <= sp && -
fGT <= sp)
goto L19;
1206 if( 0.59*t < -fGT)
goto L19;
1208 if (t < 0.25 ) t = 0.25;
1214 for( i = 0; i <
n; i++) {
1231 printf(
"trying to execute an illegal junp at L85\n");
1242 for( i = 0; i <
n; i++) {
1249 if ((
fA[i] >=
fAMX[i] &&
fGr[i] < 0.) ||
1256 for( j=0; j <= i; j++) {
1261 fZ[k2 -1] =
fZ0[k1 -1];
1277 for( i = 0; i <
n; i++) {
1293 fixFLG = fixFLG + 1;
1300 for( i = 0; i <
n; i++) {
1304 for( l = 0; l <
n; l++) {
1308 if (i1 <= l1 ) k=l1*(l1-1)/2+i1;
1309 else k=i1*(i1-1)/2+l1;
1324 for( i = 0; i <
n; i++)
1348 fixFLG = fixFLG + 1;
1362 for( i = 0; i <
n; i++) {
1365 abi = fA[i] +
fPL[i];
1368 bm = fA[i] -
fAMN[i];
1369 abi = fA[i] - fPL[i];
1380 if ( TMath::Abs(
fDA[i]) > bi) {
1398 if (alambd > .0) amb = 0.25/alambd;
1399 for( i = 0; i <
n; i++) {
1402 if (TMath::Abs(
fDA[i]/
fPL[i]) > amb ) {
1417 if (-
fGT <= sp && t1 < 1. && alambd < 1.)
fENDFLG = -1;
1471 for ( i = 0; i <
n; i++)
fA[i] =
fA[i] +
fDA[i];
1472 if (imax >= 0)
fA[imax] = aiMAX;
1482 if(
fPL0[ip] > .0) {
1483 for(
Int_t jp = 0; jp <= ip; jp++) {
1512 TString colhdu[3],colhdl[3],cx2,cx3;
1515 exitStatus=
"CONVERGED";
1518 exitStatus=
"CONST FCN";
1519 xsexpl=
"****\n* FUNCTION IS NOT DECREASING OR BAD DERIVATIVES\n****";
1522 exitStatus=
"ERRORS INF";
1523 xsexpl=
"****\n* ESTIMATED ERRORS ARE INfiNITE\n****";
1526 exitStatus=
"MAX ITER.";
1527 xsexpl=
"****\n* MAXIMUM NUMBER OF ITERATIONS IS EXCEEDED\n****";
1530 exitStatus=
"ZERO PROBAB";
1531 xsexpl=
"****\n* PROBABILITY OF LIKLIHOOD FUNCTION IS NEGATIVE OR ZERO\n****";
1534 exitStatus=
"UNDEfiNED";
1535 xsexpl=
"****\n* fiT IS IN PROGRESS\n****";
1540 colhdl[0] =
" ERROR ";
1541 colhdu[1] =
" PHYSICAL";
1542 colhdu[2] =
" LIMITS ";
1543 colhdl[1] =
" NEGATIVE ";
1544 colhdl[2] =
" POSITIVE ";
1548 colhdl[0] =
" ERROR ";
1549 colhdu[1] =
" INTERNAL ";
1550 colhdl[1] =
" STEP SIZE ";
1551 colhdu[2] =
" INTERNAL ";
1552 colhdl[2] =
" VALUE ";
1556 colhdl[0] =
" ERROR ";
1557 colhdu[1] =
" STEP ";
1558 colhdl[1] =
" SIZE ";
1559 colhdu[2] =
" fiRST ";
1560 colhdl[2] =
" DERIVATIVE";
1563 colhdu[0] =
" PARABOLIC ";
1564 colhdl[0] =
" ERROR ";
1565 colhdu[1] =
" MINOS ";
1566 colhdu[2] =
"ERRORS ";
1567 colhdl[1] =
" NEGATIVE ";
1568 colhdl[2] =
" POSITIVE ";
1571 Printf(
" FCN=%g FROM FUMILI STATUS=%-10s %9d CALLS OF FCN",
1574 Printf(
" EXT PARAMETER %-14s%-14s%-14s",
1575 (
const char*)colhdu[0].
Data()
1576 ,(
const char*)colhdu[1].
Data()
1577 ,(
const char*)colhdu[2].
Data());
1578 Printf(
" NO. NAME VALUE %-14s%-14s%-14s",
1579 (
const char*)colhdl[0].
Data()
1580 ,(
const char*)colhdl[1].
Data()
1581 ,(
const char*)colhdl[2].
Data());
1595 cx3 =
Form(
"%14.5e",
fA[i]);
1598 cx2 =
" *undefined* ";
1599 cx3 =
" *undefined* ";
1601 if(
fPL0[i]<=0.) { cx2=
" *fixed* ";cx3=
""; }
1602 Printf(
"%4d %-11s%14.5e%14.5e%-14s%-14s",i+1
1613 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]<=0.) {
1672 if (ipar<0 || ipar>=
fNpar)
return -1;
1704 Int_t i,j,
l,k2=1,k1,ki=0;
1708 for (l=0;l<
fNED1;l++) {
1737 y = y -
fEXDA[k1-1];
1738 fS =
fS + (y*y/(sig*sig))*.5;
1741 for (i=0;i<
fNpar;i++) {
1744 fGr[i] += df[
n]*(y/sig);
1751 fZ[l++] += df[i]*df[j];
1788 if(flag == 9)
return;
1799 if (nd > 2) x[2] = cache[4];
1800 if (nd > 1) x[1] = cache[3];
1811 for (j=0;j<npar;j++) {
1815 gin[j] += df[
n]*fsum;
1821 for (
Int_t k=0;k<=j;k++)
1822 zik[l++] += df[j]*df[k];
1856 if(flag == 9)
return;
1870 fu = f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
1871 }
else if (nd < 3) {
1872 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]);
1874 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]);
1882 for (j=0;j<npar;j++) {
1886 gin[j] += df[
n]*fsum;
1892 for (
Int_t k=0;k<=j;k++)
1893 zik[l++] += df[j]*df[k];
1937 if(flag == 9)
return;
1939 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
1946 if (nd > 2) x[2] = cache[4];
1947 if (nd > 1) x[1] = cache[3];
1954 for (j=0;j<npar;j++) {
1959 if (fu < 1.e-9) fu = 1.e-9;
1968 for (j=0;j<npar;j++) {
1970 df[
n] = df[j]*(icu/fu-1);
1979 for (
Int_t k=0;k<=j;k++)
1980 zik[l++] += df[j]*df[k];
2022 if(flag == 9) {
delete [] df;
return;}
2023 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
2030 if (nd > 2) x[2] = cache[4];
2031 if (nd > 1) x[1] = cache[3];
2036 fu = f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
2037 }
else if (nd < 3) {
2038 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]);
2040 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]);
2044 for (j=0;j<npar;j++) {
2049 if (fu < 1.e-9) fu = 1.e-9;
2058 for (j=0;j<npar;j++) {
2060 df[
n] = df[j]*(icu/fu-1);
2069 for (
Int_t k=0;k<=j;k++)
2070 zik[l++] += df[j]*df[k];
2167 if(flag == 9)
return;
2175 for (bin=0;bin<
n;bin++) {
2190 if (exl < 0) exl = 0;
2191 if (exh < 0) exh = 0;
2193 if (exh > 0 && exl > 0) {
2195 eux = 0.5*(exl + exh)*f1->
Derivative(x[0], u);
2199 if (eu <= 0) eu = 1;
2204 fsum = (fu-cu)/eusq;
2205 for (i=0;i<npar;i++) {
2209 gin[i] += df[
n]*fsum;
2215 for (
Int_t j=0;j<=i;j++)
2216 zik[l++] += df[i]*df[j];
virtual Int_t GetNumberTotalParameters() const
return the total number of parameters (free + fixed)
virtual void SetParameters(const Double_t *params)
Int_t Eval(Int_t &npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag)
Evaluate the minimisation function Input parameters: npar: number of currently variable parameters pa...
virtual Foption_t GetFitOption() const
virtual void FixParameter(Int_t ipar)
Fixes parameter number ipar.
virtual Int_t GetDimension() const
virtual Double_t Chisquare(Int_t npar, Double_t *params) const
return a chisquare equivalent
virtual void SetName(const char *name)
Change (i.e.
virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const
return element i,j from the covariance matrix
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const
return global fit parameters amin : chisquare edm : estimated distance to minimum errdef nvpar : numb...
void ToUpper()
Change string to upper case.
virtual TObject * GetUserFunc() const
virtual void SetNumberFitPoints(Int_t npfits)
virtual void SetFCN(void *fcn)
To set the address of the minimization objective function.
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
IntegralOneDim or analytical integral.
Bool_t fNumericDerivatives
virtual Double_t GetErrorXhigh(Int_t bin) const
This function is called by GraphFitChisquare.
virtual Double_t GetParameter(Int_t ipar) const
return current value of parameter ipar
const char * Data() const
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)
Sets for prameter number ipar initial parameter value, name parname, initial error verr and limits vl...
void InvertZ(Int_t)
Inverts packed diagonal matrix Z by square-root method.
virtual void PrintResults(Int_t k, Double_t p) const
Prints fit results.
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
virtual Double_t GetParError(Int_t ipar) const
return error of parameter ipar
void BuildArrays()
Allocates memory for internal arrays.
TLine l1(2.5, 4.5, 15.5, 4.5)
static const Double_t gMINDOUBLE
std::vector< std::vector< double > > Data
Double_t EvalTFN(Double_t *, Double_t *)
Evaluate theoretical function df: array of partial derivatives X: vector of theoretical function argu...
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual Int_t GetNumberFreeParameters() const
return the number of free parameters
virtual Double_t GetErrorXlow(Int_t bin) const
This function is called by GraphFitChisquare.
Int_t ExecuteSetCommand(Int_t)
Called from TFumili::ExecuteCommand in case of "SET xxx" and "SHOW xxx".
Double_t * GetPL0() const
A 3-Dim function with parameters.
virtual Bool_t IsFixed(Int_t ipar) const
return kTRUE if parameter ipar is fixed, kFALSE othersise)
static const Double_t gMAXDOUBLE
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*-*-*-*-*-* Basically, it forms the likelihood by determining the Poisson probability that given a number of entries in a particular bin, the fit would predict it's value.
void DeleteArrays()
Deallocates memory.
char * Form(const char *fmt,...)
static TVirtualFitter * GetFitter()
static: return the current Fitter
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...
A 2-Dim function with parameters.
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
Execute MINUIT commands.
virtual void SetFitMethod(const char *name)
ret fit method (chisquare or loglikelihood)
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 The "I"ntegral method is used for each point t...
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 FitLikelihoodI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method*-*-*-*-*-* Basically, it forms the likelihood...
virtual Double_t * GetCovarianceMatrix() const
return a pointer to the covariance matrix
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual ~TFumili()
TFumili destructor.
void Derivatives(Double_t *, Double_t *)
Calculates partial derivatives of theoretical function.
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 Default method (function evaluated at center o...
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
virtual Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
virtual void ReleaseParameter(Int_t ipar)
Releases parameter number ipar.
static Bool_t RejectedPoint()
See TF1::RejectPoint above.
virtual Double_t GetSumLog(Int_t)
return Sum(log(i) i=0,n used by log likelihood fits
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual TObject * GetObjectFit() const
A Graph is a graphics object made of two arrays X and Y with npoints each.
void SetData(Double_t *, Int_t, Int_t)
Sets pointer to data array provided by user.
void(* fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
virtual void Clear(Option_t *opt="")
Resets all parameter names, values and errors to zero.
float type_of_call hi(const int &, const int &)
void SetParNumber(Int_t ParNum)
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*-*-*-*-*-* Basically, it forms the likelihood...
Double_t Sqrt(Double_t x)
virtual Bool_t IsInside(const Double_t *x) const
return kTRUE if the point is inside the function range
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
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*-*-*-*-* *-* ===================...
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 const char * GetParName(Int_t ipar) const
return name of parameter ipar
virtual Int_t GetNpar() const
Int_t SGZ()
Evaluates objective function ( chi-square ), gradients and Z-matrix using data provided by user via T...
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.