339static const char charal[29] =
" .ABCDEFGHIJKLMNOPQRSTUVWXYZ";
454 gROOT->GetListOfSpecials()->Add(
this);
481 gROOT->GetListOfSpecials()->Add(
this);
491 Error(
"TMinuit",
"can not copy construct TMinuit");
504 if (
gROOT !=
nullptr &&
gROOT->GetListOfSpecials() !=
nullptr)
gROOT->GetListOfSpecials()->Remove(
this);
586 for (
int i = 0; i <
fMaxpar; i++) {
663 mncont(pa1,pa2,npoints,xcoor,ycoor,npfound);
666 Warning(
"Contour",
"Cannot find more than 4 points, no TGraph returned");
667 fStatus= (npfound==0 ? 1 : npfound);
672 if (npfound!=npoints) {
674 Warning(
"Contour",
"Returning a TGraph with %d points only",npfound);
679 xcoor[npoints] = xcoor[0];
680 ycoor[npoints] = ycoor[0];
683 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TMinuitGraph"))) {
684 if (
h->LoadPlugin() != -1)
685 gr = (
TObject*)
h->ExecPlugin(3,npoints+1,xcoor,ycoor);
700 mnparm( parNo, sname, initVal, initErr, lowerLimit, upperLimit, err);
820 if (
fFCN) (*fFCN)(npar,grad,fval,par,flag);
833 mnexcm(
"FIX", tmp, 1, err );
847 mnpout( parNo,
name, currentValue, currentError, bnd1, bnd2, err );
886 mnexcm(
"MIGRAD", tmp, 0, err );
900 mnexcm(
"RELEASE", tmp, 1, err );
912 mnexcm(
"SET ERRDEF", &up, 1, err );
939 m->SetParamPtrs(args);
958 mnexcm(
"SET PRINT", tmp, 1, err );
960 if (printLevel <=-1)
mnexcm(
"SET NOWarnings",tmp,0,err);
980 Printf(
" FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4.");
1001 Int_t kwid, lwid, na=0, log_;
1005 if (al ==
ah)
ah = al + 1;
1008 if (naa == -1)
goto L150;
1017 if (awid <= 1) --log_;
1020 if (sigfig > 2)
goto L40;
1024 if (sigfig > 2.5)
goto L50;
1028 if (sigfig > 5)
goto L60;
1039 if (bwid <= 0)
goto L10;
1043 if (alb < 0) --lwid;
1045 alb =
ah / bwid + 1;
1047 if (alb < 0) --kwid;
1050 if (naa > 5)
goto L240;
1051 if (naa == -1)
return;
1053 if (naa > 1 || nb == 1)
return;
1058 if (nb << 1 != naa)
return;
1073 Int_t ndex, i, j,
m,
n, nparx;
1079 for (i = 1; i <=
fNpar; ++i) {
1081 for (j = 1; j <=
fNpar; ++j) {
1084 ndex =
m*(
m-1) / 2 +
n;
1089 for (i = 1; i <=
fNpar; ++i) {denom +=
fGrd[i-1]*(
fXt[i-1] - pvec[i-1]); }
1095 ycalf = (
f -
fApsi) / denom;
1113 for (i = 1; i <=
fMaxext; ++i) {
1134 static const char *
const clabel =
"0123456789ABCDEFGHIJ";
1138 Double_t fcna[115], fcnb[115], contur[20];
1139 Double_t ylabel, fmn, fmx, xlo, ylo, xup, yup;
1140 Double_t devs, xsav, ysav, bwidx, bwidy, unext, ff, xb4;
1141 Int_t i, ngrid, ixmid, nparx, ix, nx, ny, ki1, ki2, ixzero, iy, ics;
1146 if (ke1 <= 0 || ke2 <= 0)
goto L1350;
1147 if (ke1 >
fNu || ke2 >
fNu)
goto L1350;
1150 if (ki1 <= 0 || ki2 <= 0)
goto L1350;
1151 if (ki1 == ki2)
goto L1350;
1161 if (devs <= 0) devs = 2;
1162 xlo =
fU[ke1-1] - devs*
fWerr[ki1-1];
1163 xup =
fU[ke1-1] + devs*
fWerr[ki1-1];
1164 ylo =
fU[ke2-1] - devs*
fWerr[ki2-1];
1165 yup =
fU[ke2-1] + devs*
fWerr[ki2-1];
1177 if (nx < 11) nx = 11;
1178 if (ny < 11) ny = 11;
1179 if (nx >= 115) nx = 114;
1190 bwidx = (xup - xlo) /
Double_t(nx);
1191 bwidy = (yup - ylo) /
Double_t(ny);
1192 ixmid =
Int_t(((xsav - xlo)*
Double_t(nx) / (xup - xlo)) + 1);
1193 if (ixmid < 1) ixmid = 1;
1196 for (i = 1; i <= 20; ++i) { contur[i-1] =
fAmin +
fUp*(i-1)*(i-1); }
1197 contur[0] +=
fUp*.01;
1206 for (ix = 1; ix <= nx + 1; ++ix) {
1210 if (xb4 < 0 &&
fU[ke1-1] > 0) ixzero = ix - 1;
1215 Printf(
" Y-AXIS: PARAMETER %3d: %s",ke2,(
const char*)
fCpnam[ke2-1]);
1217 chzero[ixzero-1] =
'+';
1222 for (iy = 1; iy <= ny; ++iy) {
1223 unext =
fU[ke2-1] - bwidy;
1228 chln[ixmid-1] =
'*';
1229 if (ixzero != 0) chln[ixzero-1] =
':';
1230 if (
fU[ke2-1] > ysav && unext < ysav) chln = chmid;
1231 if (
fU[ke2-1] > 0 && unext < 0) chln = chzero;
1233 ylabel =
fU[ke2-1] + bwidy*.5;
1235 for (ix = 1; ix <= nx + 1; ++ix) {
1236 fcna[ix-1] = fcnb[ix-1];
1242 for (ix = 1; ix <= nx; ++ix) {
1249 for (ics = 1; ics <= 20; ++ics) {
1250 if (contur[ics-1] > fmn)
goto L240;
1254 if (contur[ics-1] < fmx) chln[ix-1] = clabel[ics-1];
1257 Printf(
" %12.4g %s",ylabel,(
const char*)chln);
1262 chln(ixmid-1,1) =
'I';
1264 Printf(
" %s",(
const char*)chln);
1269 Printf(
" %12.4g%s%12.4g",xlo,(
const char*)chln,xup);
1270 Printf(
" %s%12.4g",(
const char*)chln,xsav);
1272 Printf(
" %12.4g%s%12.4g%s%12.4g",xlo,(
const char*)chln,xsav,(
const char*)chln,xup);
1274 Printf(
" X-AXIS: PARAMETER %3d %s ONE COLUMN=%12.4g"
1275 ,ke1,(
const char*)
fCpnam[ke1-1],bwidx);
1283 Printf(
" INVALID PARAMETER NUMBER(S) REQUESTED. IGNORED.");
1313 Int_t ierr, ipos, i, llist, lenbuf, lnc;
1315 TString comand, crdbuf, ctemp;
1319 lenbuf = crdbuf.
Length();
1324 for (i = 1; i <=
TMath::Min(20,lenbuf); ++i) {
1325 if (crdbuf[i-1] ==
'\'')
break;
1326 if (crdbuf[i-1] ==
' ') {
1334 if (ipos > lenbuf) {
1335 Printf(
" BLANK COMMAND IGNORED.");
1341 if (crdbuf(ipos-1,3) ==
"PAR") {
1347 if (crdbuf(ipos-1,3) ==
"SET INP") {
1353 if (crdbuf(ipos-1,7) ==
"SET TIT") {
1359 if (crdbuf(ipos-1,7) ==
"SET COV") {
1365 ctemp = crdbuf(ipos-1,lenbuf-ipos+1);
1368 Printf(
" COMMAND CANNOT BE INTERPRETED");
1402 Double_t dist, xdir, ydir, aopt, u1min, u2min;
1404 Double_t a1, a2, val2mi, val2pl, dc, sclfac, bigdis, sigsav;
1405 Int_t nall, iold,
line, mpar, ierr, inew, move, next, i, j, nfcol, iercr;
1406 Int_t idist=0, npcol, kints, i2, i1, lr, nfcnco=0, ki1, ki2, ki3, ke3;
1407 Int_t nowpts, istrav, nfmxin, isw2, isw4;
1413 ldebug =
fIdbg[6] >= 1;
1414 if (ke1 <= 0 || ke2 <= 0)
goto L1350;
1415 if (ke1 >
fNu || ke2 >
fNu)
goto L1350;
1418 if (ki1 <= 0 || ki2 <= 0)
goto L1350;
1419 if (ki1 == ki2)
goto L1350;
1420 if (nptu < 4)
goto L1400;
1432 Printf(
" START MNCONTOUR CALCULATION OF %4d POINTS ON CONTOUR.",nptu);
1435 ki3 = 6 - ki1 - ki2;
1437 Printf(
" EACH POINT IS A MINIMUM WITH RESPECT TO PARAMETER %3d %s",ke3,(
const char*)
fCpnam[ke3-1]);
1439 Printf(
" EACH POINT IS A MINIMUM WITH RESPECT TO THE OTHER %3d VARIABLE PARAMETERS.",
fNpar - 2);
1446 mnmnot(ke1, ke2, val2pl, val2mi);
1448 xptu[0] =
fAlim[ke1-1];
1449 mnwarn(
"W",
"MNContour ",
"Contour squeezed by parameter limits.");
1451 if (
fErn[ki1-1] >= 0)
goto L1500;
1452 xptu[0] = u1min +
fErn[ki1-1];
1457 xptu[2] =
fBlim[ke1-1];
1458 mnwarn(
"W",
"MNContour ",
"Contour squeezed by parameter limits.");
1460 if (
fErp[ki1-1] <= 0)
goto L1500;
1461 xptu[2] = u1min +
fErp[ki1-1];
1464 scalx = 1 / (xptu[2] - xptu[0]);
1466 mnmnot(ke2, ke1, val2pl, val2mi);
1468 yptu[1] =
fAlim[ke2-1];
1469 mnwarn(
"W",
"MNContour ",
"Contour squeezed by parameter limits.");
1471 if (
fErn[ki2-1] >= 0)
goto L1500;
1472 yptu[1] = u2min +
fErn[ki2-1];
1476 yptu[3] =
fBlim[ke2-1];
1477 mnwarn(
"W",
"MNContour ",
"Contour squeezed by parameter limits.");
1479 if (
fErp[ki2-1] <= 0)
goto L1500;
1480 yptu[3] = u2min +
fErp[ki2-1];
1483 scaly = 1 / (yptu[3] - yptu[1]);
1487 Printf(
" Plot of four points found by MINOS");
1493 for (i = 2; i <= nall; ++i) {
1494 fXpt[i-1] = xptu[i-2];
1495 fYpt[i-1] = yptu[i-2];
1511 for (i = 1; i <= mpar; ++i) {
fXt[i-1] =
fX[i-1]; }
1512 i__1 = mpar*(mpar + 1) / 2;
1514 for (i = 1; i <= mpar; ++i) {
1524 for (inew = next; inew <= nptu; ++inew) {
1527 for (iold = 1; iold <= inew - 1; ++iold) {
1529 if (i2 == inew) i2 = 1;
1530 d__1 = scalx*(xptu[iold-1] - xptu[i2-1]);
1531 d__2 = scaly*(yptu[iold-1] - yptu[i2-1]);
1532 dist = d__1*d__1 + d__2*d__2;
1533 if (dist > bigdis) {
1540 if (i2 == inew) i2 = 1;
1545 fXmidcr = a1*xptu[i1-1] + a2*xptu[i2-1];
1546 fYmidcr = a1*yptu[i1-1] + a2*yptu[i2-1];
1547 xdir = yptu[i2-1] - yptu[i1-1];
1548 ydir = xptu[i1-1] - xptu[i2-1];
1561 Printf(
" MNCONT CANNOT FIND NEXT POINT ON CONTOUR. ONLY %3d POINTS FOUND.",nowpts);
1565 mnwarn(
"W",
"MNContour ",
"Cannot find midpoint, try closer.");
1571 for (move = nowpts; move >= i1 + 1; --move) {
1572 xptu[move] = xptu[move-1];
1573 yptu[move] = yptu[move-1];
1583 if (nowpts < nptu)
fCstatu =
"INCOMPLETE";
1591 for (i = 2; i <= nall; ++i) {
1592 fXpt[i-1] = xptu[i-2];
1593 fYpt[i-1] = yptu[i-2];
1597 Printf(
" Y-AXIS: PARAMETER %3d %s",ke2,(
const char*)
fCpnam[ke2-1]);
1601 Printf(
" X-AXIS: PARAMETER %3d %s",ke1,(
const char*)
fCpnam[ke1-1]);
1605 npcol = (nowpts + 1) / 2;
1607 Printf(
"%5d POINTS ON CONTOUR. FMIN=%13.5e ERRDEF=%11.3g",nowpts,abest,
fUp);
1609 (
const char*)
fCpnam[ke2-1],
1610 (
const char*)
fCpnam[ke1-1],
1611 (
const char*)
fCpnam[ke2-1]);
1614 Printf(
" %5d%13.5e%13.5e %5d%13.5e%13.5e",
line,xptu[
line-1],yptu[
line-1],lr,xptu[lr-1],yptu[lr-1]);
1616 if (nfcol < npcol) {
1617 Printf(
" %5d%13.5e%13.5e",npcol,xptu[npcol-1],yptu[npcol-1]);
1624 i__1 = mpar*(mpar + 1) / 2;
1626 for (i = 1; i <= mpar; ++i) {
1645 Printf(
" INVALID PARAMETER NUMBERS.");
1648 Printf(
" LESS THAN FOUR POINTS REQUESTED.");
1654 Printf(
" MNCONT UNABLE TO FIND FOUR POINTS.");
1682 char *cnull =
nullptr;
1683 const char *cnumer =
"123456789-.0+";
1686 Int_t ifld, iend, lend, left, nreq, ipos, kcmnd, nextb, ic, ibegin, ltoadd;
1687 Int_t ielmnt, lelmnt[25], nelmnt;
1693 char *crdbuf = (
char*)cardbuf.
Data();
1700 for (ipos = nextb; ipos <= lend; ++ipos) {
1702 if (crdbuf[ipos-1] ==
' ')
continue;
1703 if (crdbuf[ipos-1] ==
',')
goto L250;
1709 for (ipos = ibegin + 1; ipos <= lend; ++ipos) {
1710 if (crdbuf[ipos-1] ==
' ')
goto L250;
1711 if (crdbuf[ipos-1] ==
',')
goto L250;
1717 if (iend >= ibegin) celmnt[ielmnt-1] = &crdbuf[ibegin-1];
1718 else celmnt[ielmnt-1] = cnull;
1719 lelmnt[ielmnt-1] = iend - ibegin + 1;
1720 if (lelmnt[ielmnt-1] > 19) {
1721 Printf(
" MINUIT WARNING: INPUT DATA WORD TOO LONG.");
1722 ctemp = cardbuf(ibegin-1,iend-ibegin+1);
1724 Printf(
" TRUNCATED TO:%s",celmnt[ielmnt-1]);
1725 lelmnt[ielmnt-1] = 19;
1727 if (ipos >= lend)
goto L300;
1728 if (ielmnt >= 25)
goto L300;
1730 for (ipos = iend + 1; ipos <= lend; ++ipos) {
1731 if (crdbuf[ipos-1] ==
' ')
continue;
1733 if (crdbuf[ipos-1] ==
',') nextb = ipos + 1;
1740 command[0] =
' '; command[1] = 0;
1744 if (ielmnt == 0)
goto L900;
1746 for (ielmnt = 1; ielmnt <= nelmnt; ++ielmnt) {
1747 if ( celmnt[ielmnt-1] == cnull)
goto L450;
1748 for (ic = 1; ic <= 13; ++ic) {
1749 if (*celmnt[ielmnt-1] == cnumer[ic-1])
goto L450;
1751 if (kcmnd >= maxcwd)
continue;
1752 left = maxcwd - kcmnd;
1753 ltoadd = lelmnt[ielmnt-1];
1754 if (ltoadd > left) ltoadd = left;
1755 strncpy(&command[kcmnd],celmnt[ielmnt-1],ltoadd);
1757 if (kcmnd == maxcwd)
continue;
1758 command[kcmnd] =
' ';
1768 for (ifld = ielmnt; ifld <= nelmnt; ++ifld) {
1771 nreq = nelmnt - ielmnt + 1;
1772 Printf(
" MINUIT WARNING IN MNCRCK: ");
1773 Printf(
" COMMAND HAS INPUT %5d NUMERIC FIELDS, BUT MINUIT CAN ACCEPT ONLY%3d",nreq,mxp);
1776 if (celmnt[ifld-1] == cnull) plist[llist-1] = 0;
1778 sscanf(celmnt[ifld-1],
"%lf",&plist[llist-1]);
1783 if (lnc <= 0) lnc = 1;
1801 Double_t alsb[3], flsb[3], bmin, bmax, zmid, sdev, zdir, zlim;
1802 Double_t coeff[3], aleft, aulim, fdist, adist, aminsv;
1804 Double_t determ, rt, smalla, aright, aim, tla, tlf, dfda,ecart;
1805 Int_t iout=0, i, ileft, ierev, maxlk, ibest, ik, it;
1806 Int_t noless, iworst=0, iright, itoohi, kex, ipt;
1811 ldebug =
fIdbg[6] >= 1;
1830 for (ik = 1; ik <= 2; ++ik) {
1836 if (
fKe2cr == 0)
continue;
1841 if (
fNvarl[kex-1] <= 1)
continue;
1842 if (zdir == 0)
continue;
1843 zlim =
fAlim[kex-1];
1844 if (zdir > 0) zlim =
fBlim[kex-1];
1845 aulim =
TMath::Min(aulim,(zlim - zmid) / zdir);
1853 mneval(anext, fnext, ierev);
1856 Printf(
" MNCROS: calls=%8d AIM=%10.5f F,A=%10.5f%10.5f",
fNfcn,aim,fnext,aopt);
1858 if (ierev > 0)
goto L900;
1859 if (
fLimset && fnext <= aim)
goto L930;
1861 fXpt[ipt-1] = anext;
1862 fYpt[ipt-1] = fnext;
1868 if (
TMath::Abs(fnext - aim) < tlf)
goto L800;
1870 if (aopt < -.5)aopt = -.5;
1871 if (aopt > 1) aopt = 1;
1877 mneval(aopt, fnext, ierev);
1880 Printf(
" MNCROS: calls=%8d AIM=%10.5f F,A=%10.5f%10.5f",
fNfcn,aim,fnext,aopt);
1882 if (ierev > 0)
goto L900;
1883 if (
fLimset && fnext <= aim)
goto L930;
1886 fXpt[ipt-1] = alsb[1];
1887 fYpt[ipt-1] = fnext;
1890 dfda = (flsb[1] - flsb[0]) / (alsb[1] - alsb[0]);
1892 if (dfda > 0)
goto L460;
1894 mnwarn(
"D",
"MNCROS ",
"Looking for slope of the right sign");
1896 for (it = 1; it <= maxlk; ++it) {
1905 mneval(aopt, fnext, ierev);
1908 Printf(
" MNCROS: calls=%8d AIM=%10.5f F,A=%10.5f%10.5f",
fNfcn,aim,fnext,aopt);
1910 if (ierev > 0)
goto L900;
1911 if (
fLimset && fnext <= aim)
goto L930;
1914 fXpt[ipt-1] = alsb[1];
1915 fYpt[ipt-1] = fnext;
1918 dfda = (flsb[1] - flsb[0]) / (alsb[1] - alsb[0]);
1919 if (dfda > 0)
goto L450;
1921 mnwarn(
"W",
"MNCROS ",
"Cannot find slope of the right sign");
1926 aopt = alsb[1] + (aim - flsb[1]) / dfda;
1931 if (adist < tla && fdist < tlf)
goto L800;
1932 if (ipt >= 15)
goto L950;
1934 if (aopt < bmin) aopt = bmin;
1936 if (aopt > bmax) aopt = bmax;
1943 mneval(aopt, fnext, ierev);
1946 Printf(
" MNCROS: calls=%8d AIM=%10.5f F,A=%10.5f%10.5f",
fNfcn,aim,fnext,aopt);
1948 if (ierev > 0)
goto L900;
1949 if (
fLimset && fnext <= aim)
goto L930;
1952 fXpt[ipt-1] = alsb[2];
1953 fYpt[ipt-1] = fnext;
1961 for (i = 1; i <= 3; ++i) {
1963 if (ecart > ecarmx) { ecarmx = ecart; iworst = i; }
1964 if (ecart < ecarmn) { ecarmn = ecart; ibest = i; }
1965 if (flsb[i-1] < aim) ++noless;
1968 if (noless == 1 || noless == 2)
goto L500;
1970 if (noless == 0 && ibest != 3)
goto L950;
1973 if (noless == 3 && ibest != 3) {
1979 alsb[iworst-1] = alsb[2];
1980 flsb[iworst-1] = flsb[2];
1981 dfda = (flsb[1] - flsb[0]) / (alsb[1] - alsb[0]);
1985 mnpfit(alsb, flsb, 3, coeff, sdev);
1986 if (coeff[2] <= 0) {
1987 mnwarn(
"D",
"MNCROS ",
"Curvature is negative near contour line.");
1989 determ = coeff[1]*coeff[1] - coeff[2]*4*(coeff[0] - aim);
1991 mnwarn(
"D",
"MNCROS ",
"Problem 2, impossible determinant");
1996 x1 = (-coeff[1] + rt) / (coeff[2]*2);
1997 x2 = (-coeff[1] - rt) / (coeff[2]*2);
1998 s1 = coeff[1] +
x1*2*coeff[2];
1999 s2 = coeff[1] +
x2*2*coeff[2];
2001 Printf(
" MNCONTour problem 1");
2015 if (ipt >= 15)
goto L950;
2024 for (i = 1; i <= 3; ++i) {
2026 if (ecart < ecarmn) { ecarmn = ecart; ibest = i; }
2027 if (ecart > ecarmx) { ecarmx = ecart; }
2028 if (flsb[i-1] > aim) {
2029 if (iright == 0) iright = i;
2030 else if (flsb[i-1] > flsb[iright-1]) iout = i;
2031 else { iout = iright; iright = i; }
2033 else if (ileft == 0) ileft = i;
2034 else if (flsb[i-1] < flsb[ileft-1]) iout = i;
2035 else { iout = ileft; ileft = i; }
2038 if (ecarmx >
TMath::Abs(flsb[iout-1] - aim)*10) {
2039 aopt = aopt*.5 + (alsb[iright-1] + alsb[ileft-1])*.25;
2043 if (slope*smalla > tlf) smalla = tlf / slope;
2044 aleft = alsb[ileft-1] + smalla;
2045 aright = alsb[iright-1] - smalla;
2047 if (aopt < aleft) aopt = aleft;
2048 if (aopt > aright) aopt = aright;
2049 if (aleft > aright) aopt = (aleft + aright)*.5;
2058 mneval(aopt, fnext, ierev);
2061 Printf(
" MNCROS: calls=%8d AIM=%10.5f F,A=%10.5f%10.5f",
fNfcn,aim,fnext,aopt);
2063 if (ierev > 0)
goto L900;
2064 if (
fLimset && fnext <= aim)
goto L930;
2067 fYpt[ipt-1] = fnext;
2070 alsb[iout-1] = aopt;
2071 flsb[iout-1] = fnext;
2083 if (ierev == 1)
goto L940;
2100 for (i = 1; i <= ipt; ++i) {
2109 if (
fXdircr < 0) chsign =
"NEGA";
2111 Printf(
" %sTIVE MINOS ERROR, PARAMETER %3d",chsign,
fKe1cr);
2114 Printf(
"POINTS LABELLED '+' WERE TOO HIGH TO PLOT.");
2117 Printf(
"RIGHTMOST POINT IS UP AGAINST LIMIT.");
2134 Int_t ndex, iext, i, j;
2137 Printf(
" FUNCTION MUST BE MINIMIZED BEFORE CALLING %s",(
const char*)
fCfrom);
2144 mnwarn(
"W",
fCfrom,
"NO ERROR MATRIX. WILL IMPROVISE.");
2145 for (i = 1; i <=
fNpar; ++i) {
2147 for (j = 1; j <= i-1; ++j) {
2152 if (
fG2[i-1] <= 0) {
2155 if (
fNvarl[iext-1] > 1) {
2160 fG2[i-1] =
fUp / (wint*wint);
2181 Double_t step, dfmin, stepb4, dd, df, fs1;
2182 Double_t tlrstp, tlrgrd, epspri, optstp, stpmax, stpmin, fs2, grbfor=0, d1d2, xtf;
2183 Int_t icyc, ncyc, iint, iext, i, nparx;
2187 ldebug =
fIdbg[2] >= 1;
2189 if (
fISW[2] == 1)
goto L100;
2201 Printf(
" FIRST DERIVATIVE DEBUG PRINTOUT. MNDERI");
2202 Printf(
" PAR DERIV STEP MINSTEP OPTSTEP D1-D2 2ND DRV");
2219 for (i = 1; i <=
fNpar; ++i) {
2226 for (icyc = 1; icyc <= ncyc; ++icyc) {
2232 if (
fGstep[i-1] < 0 && step > .5) step = .5;
2235 if (step > stpmax) step = stpmax;
2238 if (step < stpmin) step = stpmin;
2240 if (
TMath::Abs((step - stepb4) / step) < tlrstp)
goto L50;
2246 fX[i-1] = xtf + step;
2250 fX[i-1] = xtf - step;
2254 fGrd[i-1] = (fs1 - fs2) / (step*2);
2255 fG2[i-1] = (fs1 + fs2 -
fAmin*2) / (step*step);
2258 d1d2 = (fs1 + fs2 -
fAmin*2) / step;
2259 Printf(
"%4d%11.3g%11.3g%10.2g%10.2g%10.2g%10.2g",i,
fGrd[i-1],step,stpmin,optstp,d1d2,
fG2[i-1]);
2266 if (ncyc == 1)
goto L50;
2275 for (iint = 1; iint <=
fNpar; ++iint) {
2277 if (
fNvarl[iext-1] <= 1) {
2313 Int_t i, j, k,
l,
m=0, i0, i1, j1, m1, n1;
2317 a_offset = ndima + 1;
2325 for (i1 = 2; i1 <=
n; ++i1) {
2327 f =
a[i + (i-1)*ndima];
2330 if (
l < 1)
goto L25;
2332 for (k = 1; k <=
l; ++k) {
2333 d__1 =
a[i + k*ndima];
2339 if (gl > 1
e-35)
goto L30;
2347 if (
f >= 0) gl = -gl;
2350 a[i + (i-1)*ndima] =
f - gl;
2352 for (j = 1; j <=
l; ++j) {
2353 a[j + i*ndima] =
a[i + j*ndima] /
h;
2355 for (k = 1; k <= j; ++k) { gl +=
a[j + k*ndima]*
a[i + k*ndima]; }
2356 if (j >=
l)
goto L47;
2358 for (k = j1; k <=
l; ++k) { gl +=
a[k + j*ndima]*
a[i + k*ndima]; }
2360 work[
n + j] = gl /
h;
2361 f += gl*
a[j + i*ndima];
2364 for (j = 1; j <=
l; ++j) {
2366 gl = work[
n + j] - hh*
f;
2368 for (k = 1; k <= j; ++k) {
2369 a[j + k*ndima] =
a[j + k*ndima] -
f*work[
n + k] - gl*
a[i + k*ndima];
2378 for (i = 1; i <=
n; ++i) {
2380 if (work[i] == 0 ||
l == 0)
goto L100;
2382 for (j = 1; j <=
l; ++j) {
2384 for (k = 1; k <=
l; ++k) { gl +=
a[i + k*ndima]*
a[k + j*ndima]; }
2385 for (k = 1; k <=
l; ++k) {
a[k + j*ndima] -= gl*
a[k + i*ndima]; }
2388 work[i] =
a[i + i*ndima];
2390 if (
l == 0)
continue;
2392 for (j = 1; j <=
l; ++j) {
2399 for (i = 2; i <=
n; ++i) {
2401 work[i0] = work[i0 + 1];
2406 for (
l = 1;
l <=
n; ++
l) {
2410 for (m1 =
l; m1 <=
n; ++m1) {
2416 if (
m ==
l)
goto L205;
2419 if (j == mits)
return;
2421 pt = (work[
l + 1] - work[
l]) / (work[
n +
l]*2);
2424 if (
pt < 0) pr =
pt -
r;
2426 h = work[
l] - work[
n +
l] / pr;
2427 for (i =
l; i <=
n; ++i) { work[i] -=
h; }
2434 for (i1 =
l; i1 <= m1; ++i1) {
2441 c =
pt / work[
n + i];
2443 work[
n + j] = s*work[
n + i]*
r;
2448 c = work[
n + i] /
pt;
2450 work[
n + j] = s*
pt*
r;
2454 pt =
c*work[i] - s*gl;
2455 work[j] =
h + s*(
c*gl + s*work[i]);
2456 for (k = 1; k <=
n; ++k) {
2458 a[k + j*ndima] = s*
a[k + i*ndima] +
c*
h;
2459 a[k + i*ndima] =
c*
a[k + i*ndima] - s*
h;
2470 for (i = 1; i <= n1; ++i) {
2474 for (j = i1; j <=
n; ++j) {
2475 if (work[j] >=
pt)
continue;
2480 if (k == i)
continue;
2484 for (j = 1; j <=
n; ++j) {
2485 pt =
a[j + i*ndima];
2486 a[j + i*ndima] =
a[j + k*ndima];
2487 a[j + k*ndima] =
pt;
2504 Int_t emat_dim1, emat_offset;
2508 Int_t i, j, k, npard, k2, kk, iz, nperln, kga, kgb;
2513 emat_offset = emat_dim1 + 1;
2514 emat -= emat_offset;
2517 if (
fISW[1] < 1)
return;
2519 Printf(
" EXTERNAL ERROR MATRIX. NDIM=%4d NPAR=%3d ERR DEF=%g",ndim,
fNpar,
fUp);
2526 Printf(
" USER-DIMENSIONED ARRAY EMAT NOT BIG ENOUGH. REDUCED MATRIX CALCULATED.");
2533 if (
fISW[4] >= 1 && npard > nperln) {
2534 Printf(
" ELEMENTS ABOVE DIAGONAL ARE NOT PRINTED.");
2537 for (i = 1; i <= npard; ++i) {
2540 for (j = 1; j <= i; ++j) {
2543 emat[i + j*emat_dim1] = dxdi*
fVhmat[kgb-1]*dxdj*
fUp;
2544 emat[j + i*emat_dim1] = emat[i + j*emat_dim1];
2549 for (i = 1; i <= npard; ++i) {
2551 if (npard >= nperln) iz = i;
2553 for (k = 1; nperln < 0 ? k >= iz : k <= iz; k += nperln) {
2554 k2 = k + nperln - 1;
2555 if (k2 > iz) k2 = iz;
2556 for (kk = k; kk <= k2; ++kk) {
2559 Printf(
"%s",(
const char*)ctemp);
2581 Int_t ndiag, iin, iex;
2585 if (iex >
fNu || iex <= 0)
goto L900;
2587 if (iin <= 0)
goto L900;
2590 eplus =
fErp[iin-1];
2591 if (eplus ==
fUndefi) eplus = 0;
2592 eminus =
fErn[iin-1];
2593 if (eminus ==
fUndefi) eminus = 0;
2595 ndiag = iin*(iin + 1) / 2;
2599 if (
fISW[1] < 2)
return;
2637 if (
fISW[0] >= 1) ierev = 1;
2638 if (
fISW[3] < 1) ierev = 2;
2669 static const char *
const cname[40] = {
2714 Double_t step, xptu[101], yptu[101],
f, rno;
2715 Int_t icol, kcol, ierr, iint, iext, lnow, nptu, i, iflag, ierrf;
2716 Int_t ilist, nparx, izero, nf, lk, it, iw, inonde, nsuper;
2717 Int_t it2, ke1, ke2, nowprt, kll, krl;
2718 TString chwhy, c26, cvblnk, cneway, comd;
2720 Bool_t lfreed, ltofix, lfixed;
2727 if (lk > 20) lk = 20;
2732 for (iw = 1; iw <=
fMaxpar; ++iw) {
2734 if (iw <= llist)
fWord7[iw-1] = plist[iw-1];
2741 if (lnow > 4) lnow = 4;
2744 for (i = 1; i <= lnow; ++i) {
2747 Printf(
"%s",(
const char*)ctemp);
2756 for (i = lnow + 1; i <= kll; ++i) {
2757 Printf(
"%12.4g",plist[i-1]);
2762 Printf(
" ERROR: ABOVE CALL TO MNEXCM TRIED TO PASS MORE THAN %d PARAMETERS.",
fMaxpar);
2780 for (i = 1; i <= nntot; ++i) {
2781 if (strncmp(ctemp.
Data(),
cname[i-1],3) == 0)
goto L90;
2783 Printf(
"UNKNOWN COMMAND IGNORED:%s", comand.
Data());
2788 if (
fCword(0,4) ==
"MINO") i = 5;
2789 if (i != 6 && i != 7 && i != 8 && i != 23) {
2804 case 10:
goto L1000;
2805 case 11:
goto L1100;
2806 case 12:
goto L1200;
2807 case 13:
goto L1300;
2808 case 14:
goto L1400;
2809 case 15:
goto L1500;
2810 case 16:
goto L1600;
2811 case 17:
goto L1700;
2812 case 18:
goto L1800;
2813 case 19:
goto L1900;
2814 case 20:
goto L1900;
2815 case 21:
goto L1900;
2816 case 22:
goto L2200;
2817 case 23:
goto L2300;
2818 case 24:
goto L2400;
2819 case 25:
goto L1900;
2820 case 26:
goto L2600;
2821 case 27:
goto L3300;
2822 case 28:
goto L3300;
2823 case 29:
goto L3300;
2824 case 30:
goto L3300;
2825 case 31:
goto L3300;
2826 case 32:
goto L3300;
2827 case 33:
goto L3300;
2828 case 34:
goto L3400;
2829 case 35:
goto L3500;
2830 case 36:
goto L3600;
2831 case 37:
goto L3700;
2832 case 38:
goto L3800;
2833 case 39:
goto L3900;
2834 case 40:
goto L4000;
2843 if (
fISW[3] < 1) ierflg = 4;
2851 if (
fISW[3] >= 1)
return;
2853 if (
fISW[0] == 1)
return;
2854 if (
fCword(0,3) ==
"MIG")
return;
2859 if (
fISW[0] == 1)
return;
2862 if (
fISW[3] >= 1) ierflg = 0;
2878 if (
fNfcn < nsuper)
goto L510;
2879 Printf(
" TOO MANY FUNCTION CALLS. MINOS GIVES UP");
2899 Printf(
"%s: NO PARAMETERS REQUESTED ",(
const char*)
fCword);
2902 for (ilist = 1; ilist <= llist; ++ilist) {
2903 iext =
Int_t(plist[ilist-1]);
2904 chwhy =
" IS UNDEFINED.";
2905 if (iext <= 0)
goto L930;
2906 if (iext >
fNu)
goto L930;
2907 if (
fNvarl[iext-1] < 0)
goto L930;
2908 chwhy =
" IS CONSTANT. ";
2909 if (
fNvarl[iext-1] == 0)
goto L930;
2912 chwhy =
" ALREADY FIXED.";
2913 if (iint == 0)
goto L930;
2915 if (ierr == 0) lfixed =
kTRUE;
2918 chwhy =
" ALREADY VARIABLE.";
2919 if (iint > 0)
goto L930;
2926 if (
fISW[4] >= 0)
Printf(
" PARAMETER %4d %s IGNORED.",iext,(
const char*)chwhy);
2928 if (lfreed || lfixed)
mnrset(0);
2941 if (it > 1 || it < 0)
goto L1005;
2952 Printf(
" IGNORED. UNKNOWN ARGUMENT:%4d",it);
2962 if (iext <= 0)
goto L1210;
2965 if (it2 <= 0)
goto L1250;
2971 Printf(
" PARAMETER %4d NOT VARIABLE.",iext);
2983 Printf(
"%s: NO PARAMETERS REQUESTED ",(
const char*)
fCword);
2989 mncntr(ke1-1, ke2-1, ierrf);
2990 if (ierrf > 0) ierflg = 3;
3025 if (
fISW[4] >= 0 && iflag <= 5 && nowprt == 1) {
3030 if (iflag > 5)
mnrset(1);
3041 if (
fISW[4] >= 0)
Printf(
" CALL TO USER FUNCTION WITH IFLAG = 3");
3046 if (
fCword(0,3) ==
"END") ierflg = 10;
3047 if (
fCword(0,3) ==
"RET") ierflg = 12;
3053 Printf(
" MINUIT MEMORY CLEARED. NO PARAMETERS NOW DEFINED.");
3059 for (icol = 5; icol <= lk; ++icol) {
3060 if (
fCword[icol-1] ==
' ')
continue;
3065 if (kcol == 0) comd =
"* ";
3066 else comd =
fCword(kcol-1,lk-kcol+1);
3074 if (ke1 == 0 &&
fNpar == 2) {
3079 if (nptu <= 0) nptu = 20;
3080 if (nptu > 101) nptu = 101;
3082 mncont(ke1-1, ke2-1, nptu, xptu, yptu, ierrf);
3083 if (ierrf < nptu) ierflg = 4;
3084 if (ierrf == -1) ierflg = 3;
3089 if (step <= 0) step = 2;
3092 for (i = 1; i <=
fNpar; ++i) {
3095 fX[i-1] += rno*step*
fWerr[i-1];
3103 Printf(
" BLANK COMMAND IGNORED.");
3109 Printf(
" THE *COVARIANCE* COMMAND IS OSBSOLETE. THE COVARIANCE MATRIX IS NOW SAVED IN A DIFFERENT FORMAT WITH THE *SAVE* COMMAND AND READ IN WITH:*SET COVARIANCE*");
3114 cneway =
"SET PRInt ";
3118 cneway =
"SET GRAd ";
3122 cneway =
"SHOW COVar";
3126 cneway =
"SET ERRdef";
3130 cneway =
"SET LIMits";
3137 Printf(
" OBSOLETE COMMAND:%s PLEASE USE:%s",(
const char*)
fCword
3138 ,(
const char*)cneway);
3140 if (
fCword ==
"SAVE ")
goto L1500;
3157 for (iint = 1; iint <=
fNpar; ++iint) {
3160 pint[iint-1] = pinti;
3173 Int_t kold, nold, ndex, knew, iext, i, j,
m,
n, lc, ik;
3177 Int_t iint = iint1+1;
3178 if (iint >
fNpar || iint <= 0) {
3180 Printf(
" MINUIT ERROR. ARGUMENT TO MNFIXP=%4d",iint);
3186 Printf(
" MINUIT CANNOT FIX PARAMETER %4d MAXIMUM NUMBER THAT CAN BE FIXED IS %d",iext,
fMaxpar);
3206 for (ik = iext + 1; ik <=
fNu; ++ik) {
3220 if (
fISW[1] <= 0)
return;
3222 if (
fNpar <= 0)
return;
3223 for (i = 1; i <= nold; ++i) {
3226 ndex =
m*(
m-1) / 2 +
n;
3232 for (i = 1; i <= nold; ++i) {
3233 for (j = 1; j <= i; ++j) {
3235 if (j == iint || i == iint)
continue;
3259 Double_t grdv, xv, dirinv, g2v, gstepv, xtv;
3260 Int_t i, ipsav, ka, lc, ik,
iq, ir, is;
3263 Printf(
" CALL TO MNFREE IGNORED. ARGUMENT GREATER THAN ONE");
3266 Printf(
" CALL TO MNFREE IGNORED. THERE ARE NO FIXED PARAMETERS");
3268 if (k == 1 || k == 0)
goto L40;
3272 if (
fNiofex[ka-1] == 0)
goto L15;
3273 Printf(
" IGNORED. PARAMETER SPECIFIED IS ALREADY VARIABLE.");
3276 if (
fNpfix < 1)
goto L21;
3277 for (ik = 1; ik <=
fNpfix; ++ik) {
if (
fIpfix[ik-1] == ka)
goto L24; }
3279 Printf(
" PARAMETER %4d NOT FIXED. CANNOT BE RELEASED.",ka);
3282 if (ik ==
fNpfix)
goto L40;
3292 for (i = ik + 1; i <=
fNpfix; ++i) {
3310 if (
fNpfix < 1)
goto L300;
3313 for (ik =
fNu; ik >= ir; --ik) {
3319 fX[lc-1] =
fX[lc-2];
3329 if (is == 0) is =
fNpar;
3344 Printf(
" PARAMETER %4d %s RESTORED TO VARIABLE.",ir,
3345 (
const char*)
fCpnam[ir-1]);
3347 if (k == 0)
goto L40;
3366 Int_t i, nparx, lc, istsav;
3371 if (
fWord7[0] > 0)
goto L2000;
3385 Printf(
" CHECK OF GRADIENT CALCULATION IN FCN");
3386 Printf(
" PARAMETER G(IN FCN) G(MINUIT) DG(MINUIT) AGREEMENT");
3389 for (lc = 1; lc <=
fNpar; ++lc) {
3391 const char *cwd =
"GOOD";
3403 Printf(
" %5d %10s%12.4e%12.4e%12.4e %s",i
3404 ,(
const char*)
fCpnam[i-1]
3408 Printf(
" AGREEMENT=NONE MEANS FCN DID NOT CALCULATE THE DERIVATIVE");
3411 Printf(
" MINUIT DOES NOT ACCEPT DERIVATIVE CALCULATIONS BY FCN");
3412 Printf(
" TO FORCE ACCEPTANCE, ENTER *SET GRAD 1*");
3446 if( comd.
Length() == 0 || comd[0] ==
'*' || comd[0] ==
'?' || comd[0] == 0 || comd==
"HELP" ) {
3447 Printf(
" ==>List of MINUIT Interactive commands:");
3448 Printf(
" CLEar Reset all parameter names and values undefined");
3449 Printf(
" CONtour Make contour map of the user function");
3450 Printf(
" EXIT Exit from Interactive Minuit");
3451 Printf(
" FIX Cause parameter(s) to remain constant");
3452 Printf(
" HESse Calculate the Hessian or error matrix.");
3453 Printf(
" IMPROVE Search for a new minimum around current minimum");
3454 Printf(
" MIGrad Minimize by the method of Migrad");
3455 Printf(
" MINImize MIGRAD + SIMPLEX method if Migrad fails");
3456 Printf(
" MINOs Exact (non-linear) parameter error analysis");
3457 Printf(
" MNContour Calculate one MINOS function contour");
3458 Printf(
" PARameter Define or redefine new parameters and values");
3459 Printf(
" RELease Make previously FIXed parameters variable again");
3460 Printf(
" REStore Release last parameter fixed");
3461 Printf(
" SAVe Save current parameter values on a file");
3462 Printf(
" SCAn Scan the user function by varying parameters");
3463 Printf(
" SEEk Minimize by the method of Monte Carlo");
3464 Printf(
" SET Set various MINUIT constants or conditions");
3465 Printf(
" SHOw Show values of current constants or conditions");
3466 Printf(
" SIMplex Minimize by the method of Simplex");
3474 if( !strncmp(comd.
Data(),
"CLE",3) ) {
3476 Printf(
" Resets all parameter names and values to undefined.");
3477 Printf(
" Must normally be followed by a PARameters command or ");
3478 Printf(
" equivalent, in order to define parameter values.");
3485 if( !strncmp(comd.
Data(),
"CON",3) ) {
3486 Printf(
" ***>CONTOUR <par1> <par2> [devs] [ngrid]");
3487 Printf(
" Instructs Minuit to trace contour lines of the user function");
3488 Printf(
" with respect to the two parameters whose external numbers");
3489 Printf(
" are <par1> and <par2>.");
3490 Printf(
" Other variable parameters of the function, if any, will have");
3491 Printf(
" their values fixed at the current values during the contour");
3492 Printf(
" tracing. The optional parameter [devs] (default value 2.)");
3493 Printf(
" gives the number of standard deviations in each parameter");
3494 Printf(
" which should lie entirely within the plotting area.");
3495 Printf(
" Optional parameter [ngrid] (default value 25 unless page");
3496 Printf(
" size is too small) determines the resolution of the plot,");
3497 Printf(
" i.e. the number of rows and columns of the grid at which the");
3498 Printf(
" function will be evaluated. [See also MNContour.]");
3505 if( !strncmp(comd.
Data(),
"END",3) ) {
3507 Printf(
" Signals the end of a data block (i.e., the end of a fit),");
3508 Printf(
" and implies that execution should continue, because another");
3509 Printf(
" Data Block follows. A Data Block is a set of Minuit data");
3510 Printf(
" consisting of");
3512 Printf(
" (2) One or more Parameter Definitions,");
3513 Printf(
" (3) A blank line, and");
3514 Printf(
" (4) A set of Minuit Commands.");
3515 Printf(
" The END command is used when more than one Data Block is to");
3516 Printf(
" be used with the same FCN function. It first causes Minuit");
3517 Printf(
" to issue a CALL FCN with IFLAG=3, in order to allow FCN to");
3518 Printf(
" perform any calculations associated with the final fitted");
3519 Printf(
" parameter values, unless a CALL FCN 3 command has already");
3520 Printf(
" been executed at the current FCN value.");
3527 if( !strncmp(comd.
Data(),
"EXI",3) ) {
3529 Printf(
" Signals the end of execution.");
3530 Printf(
" The EXIT command first causes Minuit to issue a CALL FCN");
3531 Printf(
" with IFLAG=3, to allow FCN to perform any calculations");
3532 Printf(
" associated with the final fitted parameter values, unless a");
3533 Printf(
" CALL FCN 3 command has already been executed.");
3540 if( !strncmp(comd.
Data(),
"FIX",3) ) {
3541 Printf(
" ***>FIX} <parno> [parno] ... [parno]");
3542 Printf(
" Causes parameter(s) <parno> to be removed from the list of");
3543 Printf(
" variable parameters, and their value(s) will remain constant");
3544 Printf(
" during subsequent minimizations, etc., until another command");
3545 Printf(
" changes their value(s) or status.");
3552 if( !strncmp(comd.
Data(),
"HES",3) ) {
3553 Printf(
" ***>HESse [maxcalls]");
3554 Printf(
" Calculate, by finite differences, the Hessian or error matrix.");
3555 Printf(
" That is, it calculates the full matrix of second derivatives");
3556 Printf(
" of the function with respect to the currently variable");
3557 Printf(
" parameters, and inverts it, printing out the resulting error");
3558 Printf(
" matrix. The optional argument [maxcalls] specifies the");
3559 Printf(
" (approximate) maximum number of function calls after which");
3560 Printf(
" the calculation will be stopped.");
3567 if( !strncmp(comd.
Data(),
"IMP",3) ) {
3568 Printf(
" ***>IMPROVE [maxcalls]");
3569 Printf(
" If a previous minimization has converged, and the current");
3570 Printf(
" values of the parameters therefore correspond to a local");
3571 Printf(
" minimum of the function, this command requests a search for");
3572 Printf(
" additional distinct local minima.");
3573 Printf(
" The optional argument [maxcalls] specifies the (approximate");
3574 Printf(
" maximum number of function calls after which the calculation");
3575 Printf(
" will be stopped.");
3582 if( !strncmp(comd.
Data(),
"MIG",3) ) {
3583 Printf(
" ***>MIGrad [maxcalls] [tolerance]");
3584 Printf(
" Causes minimization of the function by the method of Migrad,");
3585 Printf(
" the most efficient and complete single method, recommended");
3586 Printf(
" for general functions (see also MINImize).");
3587 Printf(
" The minimization produces as a by-product the error matrix");
3588 Printf(
" of the parameters, which is usually reliable unless warning");
3589 Printf(
" messages are produced.");
3590 Printf(
" The optional argument [maxcalls] specifies the (approximate)");
3591 Printf(
" maximum number of function calls after which the calculation");
3592 Printf(
" will be stopped even if it has not yet converged.");
3593 Printf(
" The optional argument [tolerance] specifies required tolerance");
3594 Printf(
" on the function value at the minimum.");
3595 Printf(
" The default tolerance is 0.1, and the minimization will stop");
3596 Printf(
" when the estimated vertical distance to the minimum (EDM) is");
3597 Printf(
" less than 0.001*[tolerance]*UP (see [SET ERRordef]).");
3604 if( !strncmp(comd.
Data(),
"MINI",4) ) {
3605 Printf(
" ***>MINImize [maxcalls] [tolerance]");
3606 Printf(
" Causes minimization of the function by the method of Migrad,");
3607 Printf(
" as does the MIGrad command, but switches to the SIMplex method");
3608 Printf(
" if Migrad fails to converge. Arguments are as for MIGrad.");
3609 Printf(
" Note that command requires four characters to be unambiguous.");
3616 if( !strncmp(comd.
Data(),
"MIN0",4) ) {
3617 Printf(
" ***>MINOs [maxcalls] [parno] [parno] ...");
3618 Printf(
" Causes a Minos error analysis to be performed on the parameters");
3619 Printf(
" whose numbers [parno] are specified. If none are specified,");
3620 Printf(
" Minos errors are calculated for all variable parameters.");
3621 Printf(
" Minos errors may be expensive to calculate, but are very");
3622 Printf(
" reliable since they take account of non-linearities in the");
3623 Printf(
" problem as well as parameter correlations, and are in general");
3625 Printf(
" The optional argument [maxcalls] specifies the (approximate)");
3626 Printf(
" maximum number of function calls per parameter requested,");
3627 Printf(
" after which the calculation will stop for that parameter.");
3634 if( !strncmp(comd.
Data(),
"MNC",3) ) {
3635 Printf(
" ***>MNContour <par1> <par2> [npts]");
3636 Printf(
" Calculates one function contour of FCN with respect to");
3637 Printf(
" parameters par1 and par2, with FCN minimized always with");
3638 Printf(
" respect to all other NPAR-2 variable parameters (if any).");
3639 Printf(
" Minuit will try to find npts points on the contour (default 20)");
3640 Printf(
" If only two parameters are variable at the time, it is not");
3641 Printf(
" necessary to specify their numbers. To calculate more than");
3642 Printf(
" one contour, it is necessary to SET ERRordef to the appropriate");
3643 Printf(
" value and issue the MNContour command for each contour.");
3650 if( !strncmp(comd.
Data(),
"PAR",3) ) {
3651 Printf(
" ***>PARameters");
3652 Printf(
" followed by one or more parameter definitions.");
3653 Printf(
" Parameter definitions are of the form:");
3654 Printf(
" <number> ''name'' <value> <step> [lolim] [uplim] ");
3656 Printf(
" 3 ''K width'' 1.2 0.1");
3657 Printf(
" the last definition is followed by a blank line or a zero.");
3664 if( !strncmp(comd.
Data(),
"REL",3) ) {
3665 Printf(
" ***>RELease <parno> [parno] ... [parno]");
3666 Printf(
" If <parno> is the number of a previously variable parameter");
3667 Printf(
" which has been fixed by a command: FIX <parno>, then that");
3668 Printf(
" parameter will return to variable status. Otherwise a warning");
3669 Printf(
" message is printed and the command is ignored.");
3670 Printf(
" Note that this command operates only on parameters which were");
3671 Printf(
" at one time variable and have been FIXed. It cannot make");
3672 Printf(
" constant parameters variable; that must be done by redefining");
3673 Printf(
" the parameter with a PARameters command.");
3680 if( !strncmp(comd.
Data(),
"RES",3) ) {
3681 Printf(
" ***>REStore [code]");
3682 Printf(
" If no [code] is specified, this command restores all previously");
3683 Printf(
" FIXed parameters to variable status. If [code]=1, then only");
3684 Printf(
" the last parameter FIXed is restored to variable status.");
3685 Printf(
" If code is neither zero nor one, the command is ignored.");
3692 if( !strncmp(comd.
Data(),
"RET",3) ) {
3694 Printf(
" Signals the end of a data block, and instructs Minuit to return");
3695 Printf(
" to the program which called it. The RETurn command first");
3696 Printf(
" causes Minuit to CALL FCN with IFLAG=3, in order to allow FCN");
3697 Printf(
" to perform any calculations associated with the final fitted");
3698 Printf(
" parameter values, unless a CALL FCN 3 command has already been");
3699 Printf(
" executed at the current FCN value.");
3706 if( !strncmp(comd.
Data(),
"SAV",3) ) {
3708 Printf(
" Causes the current parameter values to be saved on a file in");
3709 Printf(
" such a format that they can be read in again as Minuit");
3710 Printf(
" parameter definitions. If the covariance matrix exists, it is");
3711 Printf(
" also output in such a format. The unit number is by default 7,");
3712 Printf(
" or that specified by the user in their call to MINTIO or");
3713 Printf(
" MNINIT. The user is responsible for opening the file previous");
3714 Printf(
" to issuing the [SAVe] command (except where this can be done");
3715 Printf(
" interactively).");
3722 if( !strncmp(comd.
Data(),
"SCA",3) ) {
3723 Printf(
" ***>SCAn [parno] [numpts] [from] [to]");
3724 Printf(
" Scans the value of the user function by varying parameter");
3725 Printf(
" number [parno], leaving all other parameters fixed at the");
3726 Printf(
" current value. If [parno] is not specified, all variable");
3727 Printf(
" parameters are scanned in sequence.");
3728 Printf(
" The number of points [numpts] in the scan is 40 by default,");
3729 Printf(
" and cannot exceed 100. The range of the scan is by default");
3730 Printf(
" 2 standard deviations on each side of the current best value,");
3731 Printf(
" but can be specified as from [from] to [to].");
3732 Printf(
" After each scan, if a new minimum is found, the best parameter");
3733 Printf(
" values are retained as start values for future scans or");
3734 Printf(
" minimizations. The curve resulting from each scan is plotted");
3735 Printf(
" on the output unit in order to show the approximate behaviour");
3736 Printf(
" of the function.");
3737 Printf(
" This command is not intended for minimization, but is sometimes");
3738 Printf(
" useful for debugging the user function or finding a");
3739 Printf(
" reasonable starting point.");
3746 if( !strncmp(comd.
Data(),
"SEE",3) ) {
3747 Printf(
" ***>SEEk [maxcalls] [devs]");
3748 Printf(
" Causes a Monte Carlo minimization of the function, by choosing");
3749 Printf(
" random values of the variable parameters, chosen uniformly");
3750 Printf(
" over a hypercube centered at the current best value.");
3751 Printf(
" The region size is by default 3 standard deviations on each");
3752 Printf(
" side, but can be changed by specifying the value of [devs].");
3759 if( !strncmp(comd.
Data(),
"SET",3) ) {
3760 Printf(
" ***>SET <option_name>");
3762 Printf(
" Informs Minuit that it is running in batch mode.");
3765 Printf(
" SET EPSmachine <accuracy>");
3766 Printf(
" Informs Minuit that the relative floating point arithmetic");
3767 Printf(
" precision is <accuracy>. Minuit determines the nominal");
3768 Printf(
" precision itself, but the SET EPSmachine command can be");
3769 Printf(
" used to override Minuit own determination, when the user");
3770 Printf(
" knows that the FCN function value is not calculated to");
3771 Printf(
" the nominal machine accuracy. Typical values of <accuracy>");
3772 Printf(
" are between 10**-5 and 10**-14.");
3775 Printf(
" SET ERRordef <up>");
3776 Printf(
" Sets the value of UP (default value= 1.), defining parameter");
3777 Printf(
" errors. Minuit defines parameter errors as the change");
3778 Printf(
" in parameter value required to change the function value");
3779 Printf(
" by UP. Normally, for chisquared fits UP=1, and for negative");
3780 Printf(
" log likelihood, UP=0.5.");
3783 Printf(
" SET GRAdient [force]");
3784 Printf(
" Informs Minuit that the user function is prepared to");
3785 Printf(
" calculate its own first derivatives and return their values");
3786 Printf(
" in the array GRAD when IFLAG=2 (see specs of FCN).");
3787 Printf(
" If [force] is not specified, Minuit will calculate");
3788 Printf(
" the FCN derivatives by finite differences at the current");
3789 Printf(
" point and compare with the user calculation at that point,");
3790 Printf(
" accepting the user values only if they agree.");
3791 Printf(
" If [force]=1, Minuit does not do its own derivative");
3792 Printf(
" calculation, and uses the derivatives calculated in FCN.");
3795 Printf(
" SET INPut [unitno] [filename]");
3796 Printf(
" Causes Minuit, in data-driven mode only, to read subsequent");
3797 Printf(
" commands (or parameter definitions) from a different input");
3798 Printf(
" file. If no [unitno] is specified, reading reverts to the");
3799 Printf(
" previous input file, assuming that there was one.");
3800 Printf(
" If [unitno] is specified, and that unit has not been opened,");
3801 Printf(
" then Minuit attempts to open the file [filename]} if a");
3802 Printf(
" name is specified. If running in interactive mode and");
3803 Printf(
" [filename] is not specified and [unitno] is not opened,");
3804 Printf(
" Minuit prompts the user to enter a file name.");
3805 Printf(
" If the word REWIND is added to the command (note:no blanks");
3806 Printf(
" between INPUT and REWIND), the file is rewound before");
3807 Printf(
" reading. Note that this command is implemented in standard");
3808 Printf(
" Fortran 77 and the results may depend on the system;");
3809 Printf(
" for example, if a filename is given under VM/CMS, it must");
3810 Printf(
" be preceded by a slash.");
3813 Printf(
" SET INTeractive");
3814 Printf(
" Informs Minuit that it is running interactively.");
3817 Printf(
" SET LIMits [parno] [lolim] [uplim]");
3818 Printf(
" Allows the user to change the limits on one or all");
3819 Printf(
" parameters. If no arguments are specified, all limits are");
3820 Printf(
" removed from all parameters. If [parno] alone is specified,");
3821 Printf(
" limits are removed from parameter [parno].");
3822 Printf(
" If all arguments are specified, then parameter [parno] will");
3823 Printf(
" be bounded between [lolim] and [uplim].");
3824 Printf(
" Limits can be specified in either order, Minuit will take");
3825 Printf(
" the smaller as [lolim] and the larger as [uplim].");
3826 Printf(
" However, if [lolim] is equal to [uplim], an error condition");
3830 Printf(
" SET LINesperpage");
3831 Printf(
" Sets the number of lines for one page of output.");
3832 Printf(
" Default value is 24 for interactive mode");
3835 Printf(
" SET NOGradient");
3836 Printf(
" The inverse of SET GRAdient, instructs Minuit not to");
3837 Printf(
" use the first derivatives calculated by the user in FCN.");
3840 Printf(
" SET NOWarnings");
3841 Printf(
" Suppresses Minuit warning messages.");
3844 Printf(
" SET OUTputfile <unitno>");
3845 Printf(
" Instructs Minuit to write further output to unit <unitno>.");
3848 Printf(
" SET PAGethrow <integer>");
3849 Printf(
" Sets the carriage control character for ``new page'' to");
3850 Printf(
" <integer>. Thus the value 1 produces a new page, and 0");
3851 Printf(
" produces a blank line, on some devices (see TOPofpage)");
3855 Printf(
" SET PARameter <parno> <value>");
3856 Printf(
" Sets the value of parameter <parno> to <value>.");
3857 Printf(
" The parameter in question may be variable, fixed, or");
3858 Printf(
" constant, but must be defined.");
3861 Printf(
" SET PRIntout <level>");
3862 Printf(
" Sets the print level, determining how much output will be");
3863 Printf(
" produced. Allowed values and their meanings are displayed");
3864 Printf(
" after a SHOw PRInt command, and are currently <level>=:");
3865 Printf(
" [-1] no output except from SHOW commands");
3866 Printf(
" [0] minimum output");
3867 Printf(
" [1] default value, normal output");
3868 Printf(
" [2] additional output giving intermediate results.");
3869 Printf(
" [3] maximum output, showing progress of minimizations.");
3870 Printf(
" Note: See also the SET WARnings command.");
3873 Printf(
" SET RANdomgenerator <seed>");
3874 Printf(
" Sets the seed of the random number generator used in SEEk.");
3875 Printf(
" This can be any integer between 10000 and 900000000, for");
3876 Printf(
" example one which was output from a SHOw RANdom command of");
3877 Printf(
" a previous run.");
3880 Printf(
" SET STRategy <level>");
3881 Printf(
" Sets the strategy to be used in calculating first and second");
3882 Printf(
" derivatives and in certain minimization methods.");
3883 Printf(
" In general, low values of <level> mean fewer function calls");
3884 Printf(
" and high values mean more reliable minimization.");
3885 Printf(
" Currently allowed values are 0, 1 (default), and 2.");
3889 Printf(
" Informs Minuit that the next input line is to be considered");
3890 Printf(
" the (new) title for this task or sub-task. This is for");
3891 Printf(
" the convenience of the user in reading their output.");
3895 Printf(
" Instructs Minuit to output warning messages when suspicious");
3896 Printf(
" conditions arise which may indicate unreliable results.");
3897 Printf(
" This is the default.");
3900 Printf(
" SET WIDthpage");
3901 Printf(
" Informs Minuit of the output page width.");
3902 Printf(
" Default values are 80 for interactive jobs");
3909 if( !strncmp(comd.
Data(),
"SHO",3) ) {
3910 Printf(
" ***>SHOw <option_name>");
3911 Printf(
" All SET XXXX commands have a corresponding SHOw XXXX command.");
3912 Printf(
" In addition, the SHOw commands listed starting here have no");
3913 Printf(
" corresponding SET command for obvious reasons.");
3916 Printf(
" SHOw CORrelations");
3917 Printf(
" Calculates and prints the parameter correlations from the");
3918 Printf(
" error matrix.");
3921 Printf(
" SHOw COVariance");
3922 Printf(
" Prints the (external) covariance (error) matrix.");
3925 Printf(
" SHOw EIGenvalues");
3926 Printf(
" Calculates and prints the eigenvalues of the covariance");
3930 Printf(
" SHOw FCNvalue");
3931 Printf(
" Prints the current value of FCN.");
3938 if( !strncmp(comd.
Data(),
"SIM",3) ) {
3939 Printf(
" ***>SIMplex [maxcalls] [tolerance]");
3940 Printf(
" Performs a function minimization using the simplex method of");
3941 Printf(
" Nelder and Mead. Minimization terminates either when the");
3942 Printf(
" function has been called (approximately) [maxcalls] times,");
3943 Printf(
" or when the estimated vertical distance to minimum (EDM) is");
3944 Printf(
" less than [tolerance].");
3945 Printf(
" The default value of [tolerance] is 0.1*UP(see SET ERRordef).");
3952 if( !strncmp(comd.
Data(),
"STA",3) ) {
3960 if( !strncmp(comd.
Data(),
"STO",3) ) {
3962 Printf(
" Same as EXIT.");
3969 if( !strncmp(comd.
Data(),
"TOP",3) ) {
3970 Printf(
" ***>TOPofpage");
3971 Printf(
" Causes Minuit to write the character specified in a");
3972 Printf(
" SET PAGethrow command (default = 1) to column 1 of the output");
3973 Printf(
" file, which may or may not position your output medium to");
3974 Printf(
" the top of a page depending on the device and system.");
3978 Printf(
" Unknown MINUIT command. Type HELP for list of commands.");
3996 Double_t dmin_, dxdi, elem, wint, tlrg2,
d, dlast, ztemp, g2bfor;
3997 Double_t df, aimsag, fs1, tlrstp, fs2, stpinm, g2i, sag=0, xtf, xti, xtj;
3998 Int_t icyc, ncyc, ndex, idrv, iext, npar2, i, j, ifail, npard, nparx,
id, multpy;
4001 ldebug =
fIdbg[3] >= 1;
4018 if (
fISW[4] >= 2 || ldebug) {
4019 Printf(
" START COVARIANCE MATRIX CALCULATION.");
4035 Printf(
" PAR D GSTEP D G2 GRD SAG ");
4045 for (i = 1; i <= npar2; ++i) {
fVhmat[i-1] = 0; }
4049 for (
id = 1;
id <= npard; ++
id) {
4050 i =
id +
fNpar - npard;
4052 if (
fG2[i-1] == 0) {
4053 mnwarn(
"W",
"HESSE",
Form(
"Second derivative enters zero, param %d",iext));
4055 if (
fNvarl[iext-1] > 1) {
4060 fG2[i-1] =
fUp / (wint*wint);
4068 for (icyc = 1; icyc <= ncyc; ++icyc) {
4070 for (multpy = 1; multpy <= 5; ++multpy) {
4080 sag = (fs1 + fs2 -
fAmin*2)*.5;
4081 if (sag != 0)
goto L30;
4083 if (
d >= .5)
goto L26;
4085 if (
d > .5)
d = .51;
4096 fG2[i-1] = sag*2 / (
d*
d);
4097 fGrd[i-1] = (fs1 - fs2) / (
d*2);
4110 if (
d < dmin_)
d = dmin_;
4124 ndex = i*(i + 1) / 2;
4135 if (
fNpar == 1)
goto L214;
4136 for (i = 1; i <=
fNpar; ++i) {
4137 for (j = 1; j <= i-1; ++j) {
4148 ndex = i*(i-1) / 2 + j;
4156 for (i = 1; i <=
fNpar; ++i) {
4157 for (j = 1; j <= i; ++j) {
4158 ndex = i*(i-1) / 2 + j;
4165 mnwarn(
"W",
"HESSE",
"Matrix inversion fails.");
4171 for (i = 1; i <=
fNpar; ++i) {
4174 for (j = 1; j <= i-1; ++j) {
4186 Printf(
" COVARIANCE MATRIX CALCULATED SUCCESSFULLY");
4195 Printf(
" MNHESS FAILS AND WILL RETURN DIAGONAL MATRIX. ");
4197 for (i = 1; i <=
fNpar; ++i) {
4199 for (j = 1; j <= i-1; ++j) {
4205 if (g2i <= 0) g2i = 1;
4206 fVhmat[ndex-1] = 2 / g2i;
4221 Double_t dmin_,
d, dfmin, dgmin=0, change, chgold, grdold=0, epspri;
4222 Double_t fs1, optstp, fs2, grdnew=0, sag, xtf;
4223 Int_t icyc, ncyc=0, idrv, i, nparx;
4226 ldebug =
fIdbg[5] >= 1;
4234 for (i = 1; i <=
fNpar; ++i) {
4240 if (
d > optstp)
d = optstp;
4241 if (
d < dmin_)
d = dmin_;
4244 for (icyc = 1; icyc <= ncyc; ++icyc) {
4253 sag = (fs1 + fs2 -
fAmin*2)*.5;
4255 grdnew = (fs1 - fs2) / (
d*2);
4258 Printf(
"%4d%2d%12.5g%12.5g%12.5g%12.5g%12.5g",i,idrv,
fGstep[i-1],
d,
fG2[i-1],grdnew,sag);
4260 if (grdnew == 0)
goto L60;
4261 change =
TMath::Abs((grdold - grdnew) / grdnew);
4262 if (change > chgold && icyc > 1)
goto L60;
4268 if (change < .05)
goto L60;
4269 if (
TMath::Abs(grdold - grdnew) < dgmin)
goto L60;
4271 mnwarn(
"D",
"MNHES1",
"Step size too small for 1st drv.");
4302 Double_t amax, ycalf, ystar, ystst;
4304 Int_t npfn, ndex, loop=0, i, j, ifail, iseed=0;
4305 Int_t jhold, nloop, nparx, nparp1, jh, jl, iswtr;
4307 if (
fNpar <= 0)
return;
4314 if (nloop <= 0) nloop =
fNpar + 4;
4321 for (i = 1; i <=
fNpar; ++i) {
4324 for (j = 1; j <= i; ++j) {
4325 ndex = i*(i-1) / 2 + j;
4331 if (ifail >= 1)
goto L280;
4333 for (i = 1; i <=
fNpar; ++i) {
4335 for (j = 1; j <= i; ++j) {
4343 for (i = 1; i <=
fNpar; ++i) {
4351 Printf(
"START ATTEMPT NO.%2d TO FIND NEW MINIMUM",loop);
4361 for (i = 1; i <=
fNpar; ++i) {
4364 fX[i-1] = xi -
fDirin[i-1]*(rnum - .5);
4370 }
else if (
fIMPRy[i-1] > amax) {
4383 if (
fAmin < 0)
goto L95;
4384 if (
fISW[1] <= 2)
goto L280;
4386 if (sig2 < ep &&
fEDM < ep)
goto L100;
4390 for (i = 1; i <=
fNpar; ++i) {
4398 if (ystar >=
fAmin)
goto L70;
4400 for (i = 1; i <=
fNpar; ++i) {
4405 if (ystst <
fIMPRy[jl-1])
goto L67;
4413 if (ystar >=
fIMPRy[jh-1])
goto L73;
4416 if (jhold != jh)
goto L50;
4419 for (i = 1; i <=
fNpar; ++i) {
4424 if (ystst >
fIMPRy[jh-1])
goto L30;
4426 if (ystst <
fAmin)
goto L67;
4432 Printf(
" AN IMPROVEMENT ON THE PREVIOUS MINIMUM HAS BEEN FOUND");
4439 for (i = 1; i <=
fNpar; ++i) {
4449 for (i = 1; i <=
fNpar; ++i) {
4467 Printf(
" IMPROVE HAS FOUND A TRULY NEW MINIMUM");
4468 Printf(
" *************************************");
4474 Printf(
" COVARIANCE MATRIX WAS NOT POSITIVE-DEFINITE");
4480 for (i = 1; i <=
fNpar; ++i) {
4489 Printf(
" IMPROVE HAS RETURNED TO REGION OF ORIGINAL MINIMUM");
4493 if (
fISW[1] < 2)
goto L380;
4494 if (loop < nloop &&
fISW[0] < 1)
goto L20;
4510 for (j = 0; j <
fNpar; ++j) {
4530 Double_t piby2, epstry, epsbak, distnn;
4548 fCovmes[0] =
"NO ERROR MATRIX ";
4549 fCovmes[1] =
"ERR MATRIX APPROXIMATE";
4550 fCovmes[2] =
"ERR MATRIX NOT POS-DEF";
4551 fCovmes[3] =
"ERROR MATRIX ACCURATE ";
4589 for (i = 1; i <= 100; ++i) {
4593 if (epsbak < epstry)
goto L35;
4597 Printf(
" MNINIT UNABLE TO DETERMINE ARITHMETIC PRECISION. WILL ASSUME:%g",
fEpsmac);
4620 Int_t kint, i2, newcod, ifx=0, inu;
4626 if (i2 >
fMaxext || i2 < 0)
goto L900;
4627 if (i2 > 0)
goto L30;
4631 for (inu = 1; inu <=
fNu; ++inu) {
4632 if (
fNvarl[inu-1] <= 0)
continue;
4633 if (
fNvarl[inu-1] == 1 && newcod == 1)
continue;
4638 Printf(
" LIMITS NOT CHANGED FOR FIXED PARAMETER:%4d",inu);
4645 Printf(
" LIMITS REMOVED FROM PARAMETER :%3d",inu);
4649 snew =
fGstep[kint-1]*dxdi;
4657 Printf(
" PARAMETER %3d LIMITS SET TO %15.5g%15.5g",inu,
fAlim[inu-1],
fBlim[inu-1]);
4668 Printf(
" PARAMETER %3d IS NOT VARIABLE.", i2);
4674 Printf(
" REQUEST TO CHANGE LIMITS ON FIXED PARAMETER:%3d",i2);
4675 for (ifx = 1; ifx <=
fNpfix; ++ifx) {
4676 if (i2 ==
fIpfix[ifx-1])
goto L92;
4678 Printf(
" MINUIT BUG IN MNLIMS. SEE F. JAMES");
4686 Printf(
" LIMITS REMOVED FROM PARAMETER %2d",i2);
4695 fGrd[kint-1] *= dxdi;
4699 Printf(
" NO LIMITS SPECIFIED. PARAMETER %3d IS ALREADY UNLIMITED. NO CHANGE.",i2);
4708 Printf(
" PARAMETER %3d LIMITS SET TO %15.5g%15.5g",i2,
fAlim[i2-1],
fBlim[i2-1]);
4711 if (kint <= 0)
fGsteps[ifx-1] = -.1;
4712 else fGstep[kint-1] = -.1;
4715 if (
fCstatu !=
"NO CHANGE ") {
4739 Double_t xpq[12], ypq[12], slam, sdev, coeff[3], denom, flast;
4740 Double_t fvals[3], xvals[3],
f1, fvmin, xvmin, ratio, f2, f3 = 0., fvmax;
4741 Double_t toler8, toler9, overal, undral, slamin, slamax, slopem;
4742 Int_t i, nparx=0, nvmax=0, nxypt, kk, ipt;
4749 l65 = 0; l70 = 0; l80 = 0;
4750 ldebug =
fIdbg[1] >= 1;
4759 Printf(
" MNLINE start point not consistent, F values, parameters=");
4760 for (kk = 1; kk <=
fNpar; ++kk) {
4774 for (i = 1; i <=
fNpar; ++i) {
4775 if (step[i-1] != 0) {
4777 if (slamin == 0) slamin = ratio;
4778 if (ratio < slamin) slamin = ratio;
4780 fX[i-1] = start[i-1] + step[i-1];
4782 if (slamin == 0) slamin =
fEpsmac;
4789 chpq[nxypt-1] =
charal[nxypt-1];
4804 denom = (flast - fstart - slope*slam)*2 / (slam*slam);
4806 if (denom != 0) slam = -slope / denom;
4807 if (slam < 0) slam = slamax;
4808 if (slam > slamax) slam = slamax;
4809 if (slam < toler8) slam = toler8;
4810 if (slam < slamin) {
4818 if (
TMath::Abs(slam - 1) < toler8) slam = toler8 + 1;
4823 for (i = 1; i <=
fNpar; ++i) {
fX[i-1] = start[i-1] + slam*step[i-1]; }
4828 chpq[nxypt-1] =
charal[nxypt-1];
4829 xpq[nxypt-1] = slam;
4835 if (fstart == fvmin) {
4837 toler8 = toler*slam;
4838 overal = slam - toler8;
4841 }
while (fstart == fvmin);
4843 if (!l65 && !l70 && !l80) {
4847 xvals[1] = xpq[nxypt-2];
4848 fvals[1] = ypq[nxypt-2];
4849 xvals[2] = xpq[nxypt-1];
4850 fvals[2] = ypq[nxypt-1];
4854 mnpfit(xvals, fvals, 3, coeff, sdev);
4855 if (coeff[2] <= 0) {
4856 slopem = coeff[2]*2*xvmin + coeff[1];
4857 if (slopem <= 0) slam = xvmin + slamax;
4858 else slam = xvmin - slamax;
4860 slam = -coeff[1] / (coeff[2]*2);
4861 if (slam > xvmin + slamax) slam = xvmin + slamax;
4862 if (slam < xvmin - slamax) slam = xvmin - slamax;
4867 else if (slam < undral)
4874 for (ipt = 1; ipt <= 3; ++ipt) {
4875 if (
TMath::Abs(slam - xvals[ipt-1]) < toler9) {
4886 for (i = 1; i <=
fNpar; ++i) {
fX[i-1] = start[i-1] + slam*step[i-1]; }
4890 chpq[nxypt-1] =
charal[nxypt-1];
4891 xpq[nxypt-1] = slam;
4896 if (fvals[1] > fvmax) {
4900 if (fvals[2] > fvmax) {
4910 if (slam > xvmin) overal =
TMath::Min(overal,slam - toler8);
4911 if (slam < xvmin) undral =
TMath::Max(undral,slam + toler8);
4912 slam = (slam + xvmin)*.5;
4914 }
while (f3 >= fvmax);
4917 if (l65 || l70)
break;
4919 xvals[nvmax-1] = slam;
4920 fvals[nvmax-1] = f3;
4925 if (slam > xvmin) overal =
TMath::Min(overal,slam - toler8);
4926 if (slam < xvmin) undral =
TMath::Max(undral,slam + toler8);
4928 }
while (nxypt < 12);
4933 if (!l70 && !l80 && ldebug) {
4934 cmess =
" LINE SEARCH HAS EXHAUSTED THE LIMIT OF FUNCTION CALLS ";
4935 Printf(
" MNLINE DEBUG: steps=");
4936 for (kk = 1; kk <=
fNpar; ++kk) {
4937 Printf(
" %12.4g",step[kk-1]);
4941 if (l70 && ldebug) cmess =
" LINE SEARCH HAS ATTAINED TOLERANCE ";
4942 if (l80 && ldebug) cmess =
" STEP SIZE AT ARITHMETICALLY ALLOWED MINIMUM";
4945 for (i = 1; i <=
fNpar; ++i) {
4946 fDirin[i-1] = step[i-1]*xvmin;
4947 fX[i-1] = start[i-1] +
fDirin[i-1];
4951 mnwarn(
"D",
"MNLINE",
" LINE MINIMUM IN BACKWARDS DIRECTION");
4953 if (fvmin == fstart) {
4954 mnwarn(
"D",
"MNLINE",
" LINE SEARCH FINDS NO IMPROVEMENT ");
4957 Printf(
" AFTER %3d POINTS,%s",nxypt,(
const char*)cmess);
4971 Int_t ndex, i, j,
m,
n, ncoef, nparm,
id, it, ix;
4972 Int_t nsofar, ndi, ndj, iso, isw2, isw5;
4981 Printf(
" MNMATU: NPAR=0");
4995 if (
fNpar <= 1)
return;
5001 Printf(
" PARAMETER CORRELATION COEFFICIENTS ");
5002 ctemp =
" NO. GLOBAL";
5003 for (
id = 1;
id <= nparm; ++
id) {
5006 Printf(
"%s",(
const char*)ctemp);
5007 for (i = 1; i <=
fNpar; ++i) {
5009 ndi = i*(i + 1) / 2;
5010 for (j = 1; j <=
fNpar; ++j) {
5013 ndex =
m*(
m-1) / 2 +
n;
5014 ndj = j*(j + 1) / 2;
5019 for (it = 1; it <= nparm; ++it) {
5022 Printf(
"%s",(
const char*)ctemp);
5023 if (i <= nparm)
continue;
5025 for (iso = 1; iso <= 10; ++iso) {
5028 for (it = nsofar + 1; it <= nparm; ++it) {
5031 Printf(
"%s",(
const char*)ctemp);
5032 if (i <= nparm)
break;
5051 Double_t gdel, gami, vlen, dsum, gssq, vsum,
d;
5054 Int_t npfn, ndex, iext, i, j,
m,
n, npsdf, nparx;
5055 Int_t iswtr, lined2, kk, nfcnmg, nrstrt,iter;
5059 if (
fNpar <= 0)
return;
5074 rhotol =
fApsi*.001;
5076 Printf(
" START MIGRAD MINIMIZATION. STRATEGY %2d. CONVERGENCE WHEN EDM .LT.%9.2e",
fIstrat,rhotol);
5091 if (
fISW[1] >= 1)
goto L10;
5099 if (
fISW[1] >= 1)
goto L10;
5101 for (i = 1; i <=
fNpar; ++i) {
5108 for (i = 1; i <=
fNpar; ++i) {
5109 if (
fG2[i-1] > 0)
continue;
5115 mnwarn(
"D",
"MNMIGR",
"Negative G2 line search");
5118 Printf(
" Negative G2 line search, param %3d %13.3g%13.3g",iext,
fs,
fAmin);
5124 for (i = 1; i <=
fNpar; ++i) {
5126 for (j = 1; j <= i-1; ++j) {
5131 if (
fG2[i-1] <= 0)
fG2[i-1] = 1;
5136 Printf(
" DEBUG MNMIGR, STARTING MATRIX DIAGONAL, VHMAT=");
5137 for (kk = 1; kk <=
Int_t(vlen); ++kk) {
5151 for (i = 1; i <=
fNpar; ++i) {
5155 for (j = 1; j <= i-1; ++j) {
5164 mnwarn(
"W",
"MIGRAD",
"STARTING MATRIX NOT POS-DEFINITE.");
5174 if (iswtr >= 2)
mnmatu(0);
5180 for (i = 1; i <=
fNpar; ++i) {
5183 for (j = 1; j <=
fNpar; ++j) {
5186 ndex =
m*(
m-1) / 2 +
n;
5193 mnwarn(
"D",
"MIGRAD",
" FIRST DERIVATIVES OF FCN ARE ALL ZERO");
5198 mnwarn(
"D",
"MIGRAD",
" NEWTON STEP NOT DESCENT.");
5199 if (npsdf == 1)
goto L1;
5223 for (i = 1; i <=
fNpar; ++i) {
5226 for (j = 1; j <=
fNpar; ++j) {
5229 ndex =
m*(
m-1) / 2 +
n;
5235 gdgssq += gami*gami;
5237 delgam +=
fDirin[i-1]*gami;
5242 if (
fEDM < 0 || gvg <= 0) {
5243 mnwarn(
"D",
"MIGRAD",
"NOT POS-DEF. EDM OR GVG NEGATIVE.");
5245 if (npsdf == 1)
goto L230;
5252 if (iswtr >= 3 || (iswtr == 2 && iter % 10 == 1)) {
5257 mnwarn(
"D",
"MIGRAD",
"NO CHANGE IN FIRST DERIVATIVES OVER LAST STEP");
5260 mnwarn(
"D",
"MIGRAD",
"FIRST DERIVATIVES INCREASING ALONG SEARCH LINE");
5266 for (kk = 1; kk <= 10; ++kk) {
5272 for (i = 1; i <=
fNpar; ++i) {
5273 for (j = 1; j <= i; ++j) {
5274 if(delgam == 0 || gvg == 0)
d = 0;
5277 ndex = i*(i-1) / 2 + j;
5284 if (iswtr >= 3 || ldebug) {
5285 Printf(
" RELATIVE CHANGE IN COV. MATRIX=%5.1f per cent",
fDcovar*100);
5289 for (kk = 1; kk <= 10; ++kk) {
5293 if (delgam <= gvg)
goto L135;
5294 for (i = 1; i <=
fNpar; ++i) {
5297 for (i = 1; i <=
fNpar; ++i) {
5298 for (j = 1; j <= i; ++j) {
5299 ndex = i*(i-1) / 2 + j;
5305 if (
fEDM < rhotol*.1)
goto L300;
5307 for (i = 1; i <=
fNpar; ++i) {
5321 Printf(
" CALL LIMIT EXCEEDED IN MIGRAD.");
5328 Printf(
" MIGRAD FAILS TO FIND IMPROVEMENT");
5331 if (
fEDM < rhotol)
goto L300;
5334 Printf(
" MACHINE ACCURACY LIMITS FURTHER IMPROVEMENT.");
5340 Printf(
" MIGRAD FAILS WITH STRATEGY=0. WILL TRY WITH STRATEGY=1.");
5348 Printf(
" MIGRAD TERMINATED WITHOUT CONVERGENCE.");
5356 Printf(
" MIGRAD MINIMIZATION HAS CONVERGED.");
5361 Printf(
" MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.");
5366 if (
fEDM > rhotol)
goto L10;
5378 if (iswtr >= 1)
mnmatu(1);
5392 Int_t nbad, ilax, ilax2, ngood, nfcnmi, iin, knt;
5394 if (
fNpar <= 0)
goto L700;
5399 for (knt = 1; knt <=
fNpar; ++knt) {
5403 if (knt >= 7)
break;
5405 if (ilax == 0)
break;
5406 if (ilax > 0 && ilax <=
fNu) {
5407 if (
fNiofex[ilax-1] > 0)
goto L565;
5409 Printf(
" PARAMETER NUMBER %3d NOT A VARIABLE. IGNORED.",ilax);
5415 mnmnot(ilax, ilax2, val2pl, val2mi);
5419 if (
fErp[iin-1] > 0) ++ngood;
5421 if (
fErn[iin-1] < 0) ++ngood;
5429 if (ngood == 0 && nbad == 0)
goto L700;
5430 if (ngood > 0 && nbad == 0)
fCstatu =
"SUCCESSFUL";
5431 if (ngood == 0 && nbad > 0)
fCstatu =
"FAILURE ";
5432 if (ngood > 0 && nbad > 0)
fCstatu =
"PROBLEMS ";
5442 Printf(
" NEW MINIMUM FOUND. GO BACK TO MINIMIZATION STEP.");
5443 Printf(
" =================================================");
5453 Printf(
" THERE ARE NO MINOS ERRORS TO CALCULATE.");
5470 Double_t abest, xunit, dc, ut, sigsav, du1;
5472 Int_t marc, isig, mpar, ndex, imax, indx, ierr, i, j;
5473 Int_t iercr, it, istrav, nfmxin, nlimit, isw2, isw4;
5487 for (i = 1; i <= mpar; ++i) {
fXt[i-1] =
fX[i-1]; }
5488 i__1 = mpar*(mpar + 1) / 2;
5490 for (i = 1; i <= mpar; ++i) {
5499 if (
fNvarl[ilax-1] == 1) {
5503 ndex = it*(it + 1) / 2;
5506 for (i = 1; i <= mpar; ++i) {
5507 if (i == it)
continue;
5516 Printf(
" MINUIT ERROR. CANNOT FIX PARAMETER %4d INTERNAL %3d",ilax,it);
5522 for (isig = 1; isig <= 2; ++isig) {
5532 Printf(
" DETERMINATION OF %sTIVE MINOS ERROR FOR PARAMETER %d %s"
5533 ,(
const char*)csig,ilax
5534 ,(
const char*)
fCpnam[ilax-1]);
5537 mnwarn(
"D",
"MINOS",
"NO COVARIANCE MATRIX.");
5539 nlimit =
fNfcn + nfmxin;
5542 fU[ilax-1] = ut + sig*du1;
5545 delu =
fU[ilax-1] - ut;
5548 if ( (delu == 0 && ut == 0) ||
5550 fac = delu /
fMNOTw[it-1];
5551 for (i = 1; i <=
fNpar; ++i) {
5555 Printf(
" PARAMETER %4d SET TO%11.3e + %10.3e = %12.3e",ilax,ut,delu,
fU[ilax-1]);
5566 if (abest -
fAmin >
fUp*.01)
goto L650;
5567 if (iercr == 1)
goto L440;
5568 if (iercr == 2)
goto L450;
5569 if (iercr == 3)
goto L460;
5573 Printf(
" THE %4sTIVE MINOS ERROR OF PARAMETER %3d %10s, IS %12.4e"
5574 ,(
const char*)csig,ilax
5575 ,(
const char*)
fCpnam[ilax-1],eros);
5581 Printf(
" THE %4sTIVE MINOS ERROR OF PARAMETER %3d, %s EXCEEDS ITS LIMIT."
5582 ,(
const char*)csig,ilax
5583 ,(
const char*)
fCpnam[ilax-1]);
5589 Printf(
" THE %4sTIVE MINOS ERROR %4d REQUIRES MORE THAN %5d FUNCTION CALLS."
5590 ,(
const char*)csig,ilax,nfmxin);
5596 Printf(
" %4sTIVE MINOS ERROR NOT CALCULATED FOR PARAMETER %d"
5597 ,(
const char*)csig,ilax);
5603 Printf(
" **************************************************************************");
5607 if (ilax2 > 0 && ilax2 <=
fNu) val2mi =
fU[ilax2-1];
5610 if (ilax2 > 0 && ilax2 <=
fNu) val2pl =
fU[ilax2-1];
5617 i__1 = mpar*(mpar + 1) / 2;
5619 for (i = 1; i <= mpar; ++i) {
5668 Double_t vplu, a_small, gsmin, pinti, vminu, danger, sav, sav2;
5669 Int_t ierr, kint, in, ix, ktofix, lastin, kinfix, nvl;
5677 Printf(
" MINUIT USER ERROR. PARAMETER NUMBER IS %3d ALLOWED RANGE IS ONE TO %4d",k,
fMaxext);
5682 if (
fNvarl[k-1] < 0)
goto L50;
5685 for (ix = 1; ix <=
fNpfix; ++ix) {
5686 if (
fIpfix[ix-1] == k) ktofix = k;
5689 mnwarn(
"W",
"PARAM DEF",
"REDEFINING A FIXED PARAMETER.");
5691 Printf(
" CANNOT RELEASE. MAX NPAR EXCEEDED.");
5702 Printf(
" PARAMETER DEFINITIONS:");
5703 Printf(
" NO. NAME VALUE STEP SIZE LIMITS");
5706 if (wk > 0)
goto L122;
5709 Printf(
" %5d %-10s %13.5e constant",k,(
const char*)cnamk,uk);
5714 if (
a == 0 &&
b == 0) {
5718 Printf(
" %5d %-10s %13.5e%13.5e no limits",k,(
const char*)cnamk,uk,wk);
5725 Printf(
" %5d %-10s %13.5e%13.5e %13.5e%13.5e",k,(
const char*)cnamk,uk,wk,
a,
b);
5731 Printf(
" MINUIT USER ERROR. TOO MANY VARIABLE PARAMETERS.");
5734 if (nvl == 1)
goto L200;
5736 Printf(
" USER ERROR IN MINUIT PARAMETER");
5738 Printf(
" UPPER AND LOWER LIMITS EQUAL.");
5745 mnwarn(
"W",
"PARAM DEF",
"PARAMETER LIMITS WERE REVERSED.");
5752 danger = (
b - uk)*(uk -
a);
5754 mnwarn(
"W",
"PARAM DEF",
"STARTING VALUE OUTSIDE LIMITS.");
5757 mnwarn(
"W",
"PARAM DEF",
"STARTING VALUE IS AT LIMIT.");
5775 for (ix = 1; ix <= k-1; ++ix) {
if (
fNiofex[ix-1] > 0) ++lastin; }
5777 if (kint ==
fNpar)
goto L280;
5780 for (in =
fNpar; in >= lastin + 1; --in) {
5794 for (in = lastin + 1; in <= kint; ++in) {
5817 mnpint(sav, ix-1, pinti);
5819 fXt[in-1] =
fX[in-1];
5822 mnpint(sav2, ix-1, pinti);
5823 vplu = pinti -
fX[in-1];
5825 mnpint(sav2, ix-1, pinti);
5826 vminu = pinti -
fX[in-1];
5845 if (kinfix > 0)
mnfixp(kinfix-1, ierr);
5846 if (ierr > 0)
goto L800;
5871 Int_t ierr, kapo1, kapo2;
5872 Int_t k, llist, ibegin, lenbuf, istart, lnc, icy;
5873 TString cnamk, comand, celmnt, ctemp;
5876 lenbuf = strlen((
const char*)crdbuf);
5878 kapo1 = strspn((
const char*)crdbuf,
"'");
5879 if (kapo1 == 0)
goto L150;
5880 kapo2 = strspn((
const char*)crdbuf + kapo1,
"'");
5881 if (kapo2 == 0)
goto L150;
5885 for (istart = 1; istart <= kapo1-1; ++istart) {
5886 if (crdbuf(istart-1,1) !=
' ')
goto L120;
5891 celmnt = crdbuf(istart-1, kapo1-istart);
5892 if (scanf((
const char*)celmnt,&fk)) {;}
5894 if (k <= 0)
goto L210;
5895 cnamk =
"PARAM " + celmnt;
5896 if (kapo2 - kapo1 > 1) {
5897 cnamk = crdbuf(kapo1, kapo2-1-kapo1);
5900 for (icy = kapo2 + 1; icy <= lenbuf; ++icy) {
5901 if (crdbuf(icy-1,1) ==
',')
goto L139;
5902 if (crdbuf(icy-1,1) !=
' ')
goto L140;
5913 ctemp = crdbuf(ibegin-1,lenbuf-ibegin);
5915 if (ierr > 0)
goto L180;
5926 if (scanf((
const char*)crdbuf,&xk,stmp,&uk,&wk,&
a,&
b)) {;}
5929 if (k == 0)
goto L210;
5932 mnparm(k-1, cnamk, uk, wk,
a,
b, ierr);
5959 Double_t a,
f, s, t,
y, s2,
x2, x3, x4,
y2, cz[3], xm,
xy, x2y;
5969 for (i = 1; i <= 3; ++i) { cz[i-1] = 0; }
5971 if (npar2p < 3)
goto L10;
5975 for (i = 1; i <= npar2p; ++i) { xm += parx2p[i]; }
5984 for (i = 1; i <= npar2p; ++i) {
5997 if (
a == 0)
goto L10;
5999 cz[1] = (
xy - x3*cz[2]) /
x2;
6000 cz[0] = (
y -
x2*cz[2]) /
f;
6001 if (npar2p == 3)
goto L6;
6002 sdev2p =
y2 - (cz[0]*
y + cz[1]*
xy + cz[2]*x2y);
6003 if (sdev2p < 0) sdev2p = 0;
6006 cz[0] += xm*(xm*cz[2] - cz[1]);
6007 cz[1] -= xm*2*cz[2];
6009 for (i = 1; i <= 3; ++i) { coef2p[i] = cz[i-1]; }
6031 yy = (pexti - alimi)*2 / (blimi - alimi) - 1;
6036 chbuf2 =
" IS AT ITS LOWER ALLOWED LIMIT.";
6039 chbuf2 =
" IS AT ITS UPPER ALLOWED LIMIT.";
6042 pexti = alimi + (blimi - alimi)*.5*(
TMath::Sin(
a) + 1);
6044 if (yy2 > 1) chbuf2 =
" BROUGHT BACK INSIDE LIMITS.";
6073 if ((
h =
gROOT->GetPluginManager()->FindHandler(
"TMinuitGraph"))) {
6075 if (
h->LoadPlugin() != -1)
6083 Double_t bwidx, bwidy, xbest, ybest, ax, ay, bx, by;
6084 Double_t xvalus[12], any, dxx, dyy;
6085 Int_t iten, i, j, k, maxnx, maxny, iquit, ni, linodd;
6086 Int_t nxbest, nybest, km1, ibk, isp1, nx, ny, ks, ix;
6095 if (maxnx < 10) maxnx = 10;
6097 if (maxny < 10) maxny = 10;
6098 if (nxypt <= 1)
return;
6104 for (i = 1; i <= km1; ++i) {
6107 for (j = 1; j <= ni; ++j) {
6108 if (ypt[j-1] > ypt[j])
continue;
6120 if (iquit == 0)
break;
6125 for (i = 1; i <= nxypt; ++i) {
6126 if (xpt[i-1] >
xmax)
xmax = xpt[i-1];
6127 if (xpt[i-1] <
xmin)
xmin = xpt[i-1];
6134 ymin = ypt[nxypt-1];
6142 if (chbest ==
' ')
goto L50;
6152 for (i = 1; i <= nxypt; ++i) {
6153 xpt[i-1] = ax*xpt[i-1] + bx;
6154 ypt[i-1] = any - ay*ypt[i-1] - by;
6156 nxbest =
Int_t((ax*xbest + bx));
6157 nybest =
Int_t((any - ay*ybest - by));
6164 for (i = 1; i <= ny; ++i) {
6165 for (ibk = 1; ibk <= nx; ++ibk) { cline[ibk-1] =
' '; }
6170 if (nx>0) cline[nx-1] =
'.';
6171 cline[nxbest-1] =
'.';
6172 if (i != 1 && i != nybest && i != ny)
goto L320;
6173 for (j = 1; j <= nx; ++j) { cline[j-1] =
'.'; }
6176 if (isp1 > nxypt)
goto L350;
6178 for (k = isp1; k <= nxypt; ++k) {
6179 ks =
Int_t(ypt[k-1]);
6180 if (ks > i)
goto L345;
6181 ix =
Int_t(xpt[k-1]);
6182 if (cline[ix-1] ==
'.')
goto L340;
6183 if (cline[ix-1] ==
' ')
goto L340;
6184 if (cline[ix-1] == chpt[k-1])
continue;
6191 cline[ix-1] = chpt[k-1];
6198 if (linodd == 1 || i == ny)
goto L380;
6201 Printf(
" %s",(
const char*)ctemp);
6205 Printf(
" %14.7g ..%s",yprt,(
const char*)ctemp);
6211 for (ibk = 1; ibk <= nx; ++ibk) {
6213 if (ibk % 10 == 1) cline[ibk-1] =
'/';
6217 for (ibk = 1; ibk <= 12; ++ibk) {
6220 iten = (nx + 9) / 10;
6222 for (ibk = 1; ibk <= iten; ++ibk)
6223 Printf(
"%# 8.3g ", xvalus[ibk-1]);
6226 if (overpr) chmess =
" Overprint character is &";
6227 Printf(
" ONE COLUMN=%13.7g%s",bwidx,(
const char*)chmess);
6250 Int_t iint, iext, nvl;
6252 Int_t iuext = iuext1 + 1;
6256 if (iuext == 0)
goto L100;
6260 if (iint >
fNpar)
goto L100;
6266 if (iext >
fNu)
goto L100;
6272 if (nvl < 0)
goto L100;
6275 if (iint > 0) err =
fWerr[iint-1];
6277 xlolim =
fAlim[iext-1];
6278 xuplim =
fBlim[iext-1];
6284 chnam =
"undefined";
6308 static const TString cblank =
" ";
6314 Int_t nadd, i, k,
l,
m, ikode, ic, nc, ntrail, lbl;
6316 TString colhdl[6], colhdu[6], cx2, cx3, cheval;
6319 Printf(
" THERE ARE CURRENTLY NO PARAMETERS DEFINED");
6325 ikode =
fISW[1] + 1;
6326 if (ikode > 3) ikode = 3;
6329 for (k = 1; k <= 6; ++k) {
6330 colhdu[k-1] =
"UNDEFINED";
6331 colhdl[k-1] =
"COLUMN HEAD";
6338 if (fval ==
fUndefi) cheval =
" unknown ";
6339 else cheval.
Form(
"%g",fval);
6345 Printf(
" FCN=%s FROM %8s STATUS=%10s %6d CALLS %9d TOTAL"
6346 ,(
const char*)cheval
6351 Printf(
" EDM=%s STRATEGY=%2d %s"
6357 Printf(
" EDM=%s STRATEGY=%2d ERROR MATRIX UNCERTAINTY %5.1f per cent"
6358 ,(
const char*)chedm,
fIstrat,dc);
6361 if (ikode == 0)
return;
6364 for (i = 1; i <=
fNu; ++i) {
6365 if (
fNvarl[i-1] < 0)
continue;
6366 for (ic = 10; ic >= 1; --ic) {
6367 if (
fCpnam[i-1](ic-1,1) !=
" ")
goto L16;
6372 if (lbl < ntrail) ntrail = lbl;
6374 nadd = ntrail / 2 + 1;
6377 colhdl[0] =
" ERROR ";
6378 colhdu[1] =
" PHYSICAL";
6379 colhdu[2] =
" LIMITS ";
6380 colhdl[1] =
" NEGATIVE ";
6381 colhdl[2] =
" POSITIVE ";
6385 colhdl[0] =
" ERROR ";
6386 colhdu[1] =
" INTERNAL ";
6387 colhdl[1] =
" STEP SIZE ";
6388 colhdu[2] =
" INTERNAL ";
6389 colhdl[2] =
" VALUE ";
6393 colhdl[0] =
" ERROR ";
6394 colhdu[1] =
" STEP ";
6395 colhdl[1] =
" SIZE ";
6396 colhdu[2] =
" FIRST ";
6397 colhdl[2] =
" DERIVATIVE ";
6400 colhdu[0] =
" PARABOLIC ";
6401 colhdl[0] =
" ERROR ";
6402 colhdu[1] =
" MINOS ";
6403 colhdu[2] =
"ERRORS ";
6404 colhdl[1] =
" NEGATIVE ";
6405 colhdl[2] =
" POSITIVE ";
6409 if (
fISW[1] < 3) colhdu[0] =
" APPROXIMATE ";
6410 if (
fISW[1] < 1) colhdu[0] =
" CURRENT GUESS";
6412 Printf(
" EXT PARAMETER %-14s%-14s%-14s",(
const char*)colhdu[0]
6413 ,(
const char*)colhdu[1]
6414 ,(
const char*)colhdu[2]);
6415 Printf(
" NO. NAME VALUE %-14s%-14s%-14s",(
const char*)colhdl[0]
6416 ,(
const char*)colhdl[1]
6417 ,(
const char*)colhdl[2]);
6419 for (i = 1; i <=
fNu; ++i) {
6420 if (
fNvarl[i-1] < 0)
continue;
6422 cnambf = cblank(0,nadd) +
fCpnam[i-1];
6423 if (
l == 0)
goto L55;
6426 cx2 =
"PLEASE GET X..";
6427 cx3 =
"PLEASE GET X..";
6430 Printf(
"%4d %-11s%14.5e%14.5e",i,(
const char*)cnambf,
fU[i-1],
x1);
6445 cx3 =
"** at limit **";
6450 if (
x2 == 0) cx2 =
" ";
6453 if (x3 == 0) cx3 =
" ";
6454 if (x3 ==
fUndefi) cx3 =
" at limit ";
6456 if (cx2 ==
"PLEASE GET X..") cx2.
Form(
"%14.5e",
x2);
6457 if (cx3 ==
"PLEASE GET X..") cx3.
Form(
"%14.5e",x3);
6458 Printf(
"%4d %-11s%14.5e%14.5e%-14s%-14s",i
6459 ,(
const char*)cnambf,
fU[i-1],
x1
6460 ,(
const char*)cx2,(
const char*)cx3);
6463 if (
fNvarl[i-1] <= 1 || ikode == 3)
continue;
6465 Printf(
" WARNING - - ABOVE PARAMETER IS AT LIMIT.");
6471 colhdu[0] =
" constant ";
6472 if (
fNvarl[i-1] > 0) colhdu[0] =
" fixed ";
6473 if (
fNvarl[i-1] == 4 && ikode == 1) {
6474 Printf(
"%4d %-11s%14.5e%-14s%14.5e%14.5e",i
6475 ,(
const char*)cnambf,
fU[i-1]
6476 ,(
const char*)colhdu[0],
fAlim[i-1],
fBlim[i-1]);
6478 Printf(
"%4d %-11s%14.5e%s",i
6479 ,(
const char*)cnambf,
fU[i-1],(
const char*)colhdu[0]);
6497 Double_t dgmin, pAdd, pmin, pmax, dg, epspdf, epsmin;
6498 Int_t ndex, i, j, ndexd, ip, ifault;
6505 for (i = 1; i <=
fNpar; ++i) {
6506 ndex = i*(i + 1) / 2;
6507 if (
fVhmat[ndex-1] <= 0) {
6513 dg = epspdf + 1 - dgmin;
6519 for (i = 1; i <=
fNpar; ++i) {
6523 if (
fVhmat[ndexd-1]==0) {
6528 for (j = 1; j <= i; ++j) {
6537 for (ip = 2; ip <=
fNpar; ++ip) {
6543 Printf(
" EIGENVALUES OF SECOND-DERIVATIVE MATRIX:");
6545 for (ip = 1; ip <=
fNpar; ++ip) {
6550 if (pmin > epspdf*pmax)
return;
6552 pAdd = pmax*.001 - pmin;
6553 for (ip = 1; ip <=
fNpar; ++ip) {
6554 ndex = ip*(ip + 1) / 2;
6555 fVhmat[ndex-1] *= pAdd + 1;
6558 mnwarn(
"W",
fCfrom,
Form(
"MATRIX FORCED POS-DEF BY ADDING %f TO DIAGONAL.",pAdd));
6578 for (i = 1; i <=
fNpar; ++i) {
fX[i-1] = pnew[i-1]; }
6586 for (j = 2; j <= nparp1; ++j) {
if (
y[j-1] >
y[jh-1]) jh = j; }
6587 fEDM =
y[jh-1] -
y[jl-1];
6588 if (
fEDM <= 0)
goto L45;
6589 for (i = 1; i <=
fNpar; ++i) {
6592 for (j = 2; j <= nparp1; ++j) {
6596 fDirin[i-1] = pbig - plit;
6602 Printf(
" FUNCTION VALUE DOES NOT SEEM TO DEPEND ON ANY OF THE %d VARIABLE PARAMETERS.",
fNpar);
6603 Printf(
" VERIFY THAT STEP SIZES ARE BIG ENOUGH AND CHECK FCN LOGIC.");
6604 Printf(
" *******************************************************************************");
6605 Printf(
" *******************************************************************************");
6623 static std::atomic<Int_t> g_iseed( 12345 );
6629 g_iseed.store(inseed, std::memory_order_release);
6633 int starting_seed = g_iseed.load( std::memory_order_acquire );
6637 next_seed = inseed = starting_seed;
6640 k = next_seed / 53668;
6641 next_seed = (next_seed - k*53668)*40014 - k*12211;
6642 if (next_seed < 0) next_seed += 2147483563;
6644 val =
Double_t(next_seed*4.656613e-10);
6649 }
while (! g_iseed.compare_exchange_strong(starting_seed, next_seed) );
6676 for (i = 1; i <=
fNpar; ++i) {
6697 Printf(
"mnsave is dummy in TMinuit");
6711 Double_t step, uhigh, xhreq, xlreq, ubest, fnext, unext, xh, xl;
6712 Int_t ipar, iint, icall, ncall, nbins, nparx;
6713 Int_t nxypt, nccall, iparwd;
6718 if (ncall <= 1) ncall = 41;
6719 if (ncall > 98) ncall = 98;
6725 if (iparwd > 0)
goto L200;
6730 if (ipar >
fNu)
goto L900;
6732 if (iint <= 0)
goto L100;
6744 if (
fNvarl[ipar-1] > 1)
goto L300;
6747 if (xlreq == xhreq)
goto L250;
6749 step = (xhreq - xlreq) /
Double_t(ncall-1);
6752 xl = ubest -
fWerr[iint-1];
6753 xh = ubest +
fWerr[iint-1];
6754 mnbins(xl, xh, ncall, unext, uhigh, nbins, step);
6759 if (xlreq == xhreq)
goto L350;
6764 if (xl >= xh)
goto L700;
6766 step = (xh - xl) /
Double_t(ncall-1);
6769 unext =
fAlim[ipar-1];
6773 for (icall = 1; icall <= nccall; ++icall) {
6778 fXpt[nxypt-1] = unext;
6779 fYpt[nxypt-1] = fnext;
6780 fChpt[nxypt-1] =
'*';
6781 if (fnext <
fAmin) {
6794 Printf(
"%dSCAN OF PARAMETER NO. %d, %s"
6799 Printf(
" REQUESTED RANGE OUTSIDE LIMITS FOR PARAMETER %d",ipar);
6801 if (iparwd <= 0)
goto L100;
6821 Double_t dxdi, rnum, ftry, rnum1, rnum2, alpha;
6823 Int_t ipar, iext, j, ifail, iseed=0, nparx, istep, ib, mxfail, mxstep;
6826 if (mxfail <= 0) mxfail =
fNpar*20 + 100;
6830 if (alpha <= 0) alpha = 3;
6832 Printf(
" MNSEEK: MONTE CARLO MINIMIZATION USING METROPOLIS ALGORITHM");
6833 Printf(
" TO STOP AFTER %6d SUCCESSIVE FAILURES, OR %7d STEPS",mxfail,mxstep);
6834 Printf(
" MAXIMUM STEP SIZE IS %9.3f ERROR BARS.",alpha);
6846 for (ipar = 1; ipar <=
fNpar; ++ipar) {
6849 if (
fNvarl[iext-1] > 1) {
6852 if (dxdi == 0) dxdi = 1;
6855 fDirin[ipar-1] = 6.2831859999999997;
6862 for (istep = 1; istep <= mxstep; ++istep) {
6863 if (ifail >= mxfail)
break;
6864 for (ipar = 1; ipar <=
fNpar; ++ipar) {
6894 Printf(
" MNSEEK: %5d SUCCESSIVE UNSUCCESSFUL TRIALS.",ifail);
6917 static const char *
const cname[30] = {
6949 static constexpr Int_t nname = 25;
6950 static constexpr Int_t nntot =
sizeof(
cname)/
sizeof(
char*);
6951 static const TString cprlev[5] = {
6952 "-1: NO OUTPUT EXCEPT FROM SHOW ",
6953 " 0: REDUCED OUTPUT ",
6954 " 1: NORMAL OUTPUT ",
6955 " 2: EXTRA OUTPUT FOR PROBLEM CASES",
6956 " 3: MAXIMUM OUTPUT "};
6958 static const TString cstrat[3] = {
6959 " 0: MINIMIZE THE NUMBER OF CALLS TO FUNCTION",
6960 " 1: TRY TO BALANCE SPEED AGAINST RELIABILITY",
6961 " 2: MAKE SURE MINIMUM TRUE, ERRORS CORRECT "};
6963 static const TString cdbopt[7] = {
6964 "REPORT ALL EXCEPTIONAL CONDITIONS ",
6965 "MNLINE: LINE SEARCH MINIMIZATION ",
6966 "MNDERI: FIRST DERIVATIVE CALCULATIONS ",
6967 "MNHESS: SECOND DERIVATIVE CALCULATIONS ",
6968 "MNMIGR: COVARIANCE MATRIX UPDATES ",
6969 "MNHES1: FIRST DERIVATIVE UNCERTAINTIES ",
6970 "MNCONT: MNCONTOUR PLOT (MNCROS SEARCH) "};
6977 Int_t iset, iprm, i, jseed, kname, iseed, iunit,
id, ii, kk;
6978 Int_t ikseed, idbopt, igrain=0, iswsav, isw2;
6979 TString cfname, cmode, ckind, cwarn, copt, ctemp, ctemp2;
6982 for (i = 1; i <= nntot; ++i) {
6986 if (strstr(ctemp2.
Data(),ckind.
Data()))
goto L5;
6994 if ( ctemp2.
Contains(
"HEL"))
goto L2000;
6995 if ( ctemp2.
Contains(
"SHO"))
goto L1000;
6996 if (!ctemp2.
Contains(
"SET"))
goto L1900;
7000 if (kname <= 0)
goto L1900;
7002 switch ((
int)kname) {
7020 case 18:
goto L3000;
7022 case 20:
goto L3000;
7027 case 25:
goto L3000;
7028 case 26:
goto L1900;
7038 if (iprm >
fNu)
goto L25;
7039 if (iprm <= 0)
goto L25;
7040 if (
fNvarl[iprm-1] < 0)
goto L25;
7052 Printf(
" UNDEFINED PARAMETER NUMBER. IGNORED.");
7083 for (i = 1; i <=
fNpar; ++i) {
7111 mnwarn(
"W",
"SHO",
"SHO");
7119 Printf(
" MINUIT RANDOM NUMBER SEED SET TO %d",jseed);
7131 if (
fISW[4] > 0)
goto L1172;
7149 if (
fISW[4] >= 0)
goto L1220;
7154 if (
fISW[4] >= 0)
goto L1100;
7159 if (
fISW[4] >= 0)
goto L1100;
7170 if (idbopt > 6)
goto L288;
7172 fIdbg[idbopt] = iset;
7173 if (iset == 1)
fIdbg[0] = 1;
7176 for (
id = 0;
id <= 6; ++
id) {
fIdbg[
id] = iset; }
7179 mnwarn(
"D",
"SHO",
"SHO");
7182 Printf(
" UNKNOWN DEBUG OPTION %d REQUESTED. IGNORED",idbopt);
7193 if (kname <= 0)
goto L1900;
7195 switch ((
int)kname) {
7205 case 10:
goto L1100;
7206 case 11:
goto L1110;
7207 case 12:
goto L1120;
7208 case 13:
goto L1130;
7209 case 14:
goto L1130;
7210 case 15:
goto L1150;
7211 case 16:
goto L1160;
7212 case 17:
goto L1170;
7213 case 18:
goto L1180;
7214 case 19:
goto L1190;
7215 case 20:
goto L1200;
7216 case 21:
goto L1210;
7217 case 22:
goto L1220;
7218 case 23:
goto L1100;
7219 case 24:
goto L1100;
7220 case 25:
goto L1250;
7221 case 26:
goto L1900;
7222 case 27:
goto L1270;
7223 case 28:
goto L1270;
7224 case 29:
goto L1290;
7225 case 30:
goto L1300;
7255 Printf(
" ALLOWED PRINT LEVELS ARE:");
7256 Printf(
" %s",cprlev[0].Data());
7257 Printf(
" %s",cprlev[1].Data());
7258 Printf(
" %s",cprlev[2].Data());
7259 Printf(
" %s",cprlev[3].Data());
7260 Printf(
" %s",cprlev[4].Data());
7261 Printf(
" CURRENT PRINTOUT LEVEL IS %s",cprlev[
fISW[4]+1].Data());
7266 Printf(
" NOGRAD IS SET. DERIVATIVES NOT COMPUTED IN FCN.");
7268 Printf(
" GRAD IS SET. USER COMPUTES DERIVATIVES IN FCN.");
7273 Printf(
" ERRORS CORRESPOND TO FUNCTION CHANGE OF %g",
fUp);
7297 cmode =
"BATCH MODE ";
7298 if (
fISW[5] == 1) cmode =
"INTERACTIVE MODE";
7299 if (! lname) cfname =
"unknown";
7300 Printf(
" INPUT NOW BEING READ IN %s FROM UNIT NO. %d FILENAME: %s"
7301 ,(
const char*)cmode,
fIsysrd,(
const char*)cfname);
7313 cwarn =
"SUPPRESSED";
7314 if (
fLwarn) cwarn =
"REPORTED ";
7315 Printf(
"%s",(
const char*)cwarn);
7323 Printf(
" MINUIT RNDM SEED IS CURRENTLY=%d",ikseed);
7330 Printf(
" TITLE OF CURRENT TASK IS:%s",(
const char*)
fCtitl);
7334 Printf(
" ALLOWED STRATEGIES ARE:");
7335 Printf(
" %s",cstrat[0].Data());
7336 Printf(
" %s",cstrat[1].Data());
7337 Printf(
" %s",cstrat[2].Data());
7339 Printf(
" NOW USING STRATEGY %s",(
const char*)cstrat[
fIstrat]);
7356 Printf(
" NO PAGE THROWS IN MINUIT OUTPUT");
7361 for (ii = 1; ii <=
fNpar; ++ii) {
7362 if (
fErp[ii-1] > 0 ||
fErn[ii-1] < 0)
goto L1204;
7364 Printf(
" THERE ARE NO MINOS ERRORS CURRENTLY VALID.");
7371 Printf(
" FLOATING-POINT NUMBERS ASSUMED ACCURATE TO %g",
fEpsmac);
7379 Printf(
" THIS IS MINUIT VERSION:%s",(
const char*)
fCvrsn);
7383 for (
id = 0;
id <= 6; ++
id) {
7385 if (
fIdbg[
id] >= 1) copt =
"ON ";
7386 Printf(
" DEBUG OPTION %3d IS %3s :%s"
7387 ,
id,(
const char*)copt,(
const char*)cdbopt[
id]);
7402 Printf(
" THE COMMAND:%10s IS UNKNOWN.",(
const char*)
fCword);
7409 if (strcmp(ctemp2.
Data(),
"SHO")) ckind =
"SHOW";
7411 Printf(
" THE FORMAT OF THE %4s COMMAND IS:",(
const char*)ckind);
7412 Printf(
" %s xxx [numerical arguments if any]",(
const char*)ckind);
7413 Printf(
" WHERE xxx MAY BE ONE OF THE FOLLOWING:");
7414 for (kk = 1; kk <= nname; ++kk) {
7421 Printf(
" ABOVE COMMAND IS ILLEGAL. IGNORED");
7435 static constexpr Double_t alpha = 1;
7436 static constexpr Double_t beta = .5;
7437 static constexpr Double_t gamma = 2;
7438 static constexpr Double_t rhomin = 4;
7439 static constexpr Double_t rhomax = 8;
7442 Double_t dmin_, dxdi, yrho,
f, ynpp1, aming, ypbar;
7444 Double_t absmin, rho, sig2, rho1, rho2;
7445 Int_t npfn, i, j, k, jhold, ncycl, nparx;
7446 Int_t nparp1, kg, jh, nf, jl, ns;
7448 if (
fNpar <= 0)
return;
7457 rho2 = rho1 + alpha*gamma;
7460 Printf(
" START SIMPLEX MINIMIZATION. CONVERGENCE WHEN EDM .LT. %g",
fEpsi);
7462 for (i = 1; i <=
fNpar; ++i) {
7475 for (i = 1; i <=
fNpar; ++i) {
7486 if (
f <= aming)
goto L6;
7488 if (kg == 1)
goto L8;
7492 if (nf < 3)
goto L4;
7502 if (ns < 6)
goto L4;
7506 if (aming < absmin) jl = i;
7507 if (aming < absmin) absmin = aming;
7527 for (i = 1; i <=
fNpar; ++i) {
7535 if (ystar >=
fAmin)
goto L70;
7537 for (i = 1; i <=
fNpar; ++i) {
7545 rho = (rho2*
y1 - rho1*
y2)*.5 / (
y1 -
y2);
7546 if (rho < rhomin)
goto L66;
7547 if (rho > rhomax) rho = rhomax;
7548 for (i = 1; i <=
fNpar; ++i) {
7553 if (yrho <
fSIMPy[jl-1] && yrho < ystst)
goto L65;
7554 if (ystst <
fSIMPy[jl-1])
goto L67;
7555 if (yrho >
fSIMPy[jl-1])
goto L66;
7561 if (ystst <
fSIMPy[jl-1])
goto L67;
7568 if (
fISW[4] < 2)
goto L50;
7569 if (
fISW[4] >= 3 || ncycl % 10 == 0) {
7575 if (ystar >=
fSIMPy[jh-1])
goto L73;
7578 if (jhold != jh)
goto L50;
7581 for (i = 1; i <=
fNpar; ++i) {
7586 if (ystst >
fSIMPy[jh-1])
goto L1;
7588 if (ystst <
fAmin)
goto L67;
7594 Printf(
" SIMPLEX MINIMIZATION HAS CONVERGED.");
7600 Printf(
" SIMPLEX TERMINATES WITHOUT CONVERGENCE.");
7606 for (i = 1; i <=
fNpar; ++i) {
7674 static const TString cpt =
" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890./;:[]$%*_!@#&+()";
7677 l = strlen((
const char*)cfname);
7678 for (i = 1; i <=
l; ++i) {
7679 for (ic = 1; ic <= 80; ++ic) {
7680 if (cfname[i-1] == cpt[ic-1])
goto L100;
7703 Int_t i, j, k, kp1, km1;
7711 if (
n < 1)
goto L100;
7714 for (i = 1; i <=
n; ++i) {
7716 if (si <= 0)
goto L100;
7719 for (i = 1; i <=
n; ++i) {
7720 for (j = 1; j <=
n; ++j) {
7725 for (i = 1; i <=
n; ++i) {
7728 if (
a[k + k*
l] != 0)
fVERTq[k-1] = 1 /
a[k + k*
l];
7734 if (km1 < 0)
goto L100;
7735 else if (km1 == 0)
goto L50;
7738 for (j = 1; j <= km1; ++j) {
7744 if (k -
n < 0)
goto L51;
7745 else if (k -
n == 0)
goto L60;
7748 for (j = kp1; j <=
n; ++j) {
7755 for (j = 1; j <=
n; ++j) {
7760 for (j = 1; j <=
n; ++j) {
7761 for (k = 1; k <= j; ++k) {
7763 a[j + k*
l] =
a[k + j*
l];
7790 const Int_t kMAXMES = 10;
7791 Int_t ityp, i, ic, nm;
7794 if (corg(0,3) !=
"SHO" || cmes(0,3) !=
"SHO") {
7800 Printf(
" MINUIT WARNING IN %s",(
const char*)corg);
7801 Printf(
" ============== %s",(
const char*)cmes);
7807 Printf(
" MINUIT DEBUG FOR %s",(
const char*)corg);
7808 Printf(
" =============== %s ",(
const char*)cmes);
7833 englsh =
" WAS SUPPRESSED. ";
7834 if (
fNwrmes[ityp-1] > 1) englsh =
"S WERE SUPPRESSED.";
7836 ,(
const char*)ctyp,(
const char*)englsh);
7840 Printf(
" ONLY THE MOST RECENT 10 WILL BE LISTED BELOW.");
7844 Printf(
" CALLS ORIGIN MESSAGE");
7845 for (i = 1; i <= nm; ++i) {
7847 if (ic > kMAXMES) ic = 1;
7863 Double_t denom, ba, al, dx, du1, du2;
7864 Int_t ndex, ierr, i, j, k,
l, ndiag, k1, iin;
7869 ndex =
l*(
l + 1) / 2;
7874 ba =
fBlim[i-1] - al;
7877 if (dx > 1) du1 = ba;
7885 for (i = 1; i <=
fNpar; ++i) {
7888 for (j = 1; j <= i; ++j) {
7896 for (iin = 1; iin <=
fNpar; ++iin) {
7897 ndiag = iin*(iin + 1) / 2;
7899 if (denom <= 1 && denom >= 0)
fGlobcc[iin-1] = 0;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void reg
Option_t Option_t TPoint TPoint const char y1
static const char charal[29]
void InteractiveFCNm(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Static function called when SetFCN is called in interactive mode.
R__EXTERN TMinuit * gMinuit
R__EXTERN TVirtualMutex * gROOTMutex
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
#define R__LOCKGUARD(mutex)
Method or function calling interface.
virtual void mnderi()
Calculates the first derivatives of FCN (GRD)
virtual void mnvert(Double_t *a, Int_t l, Int_t m, Int_t n, Int_t &ifail)
Inverts a symmetric matrix.
virtual Int_t GetParameter(Int_t parNo, Double_t ¤tValue, Double_t ¤tError) const
return parameter value and error
virtual Int_t FixParameter(Int_t parNo)
fix a parameter
virtual void mnbins(Double_t a1, Double_t a2, Int_t naa, Double_t &bl, Double_t &bh, Int_t &nb, Double_t &bwid)
Compute reasonable histogram intervals.
virtual Int_t GetNumPars() const
returns the total number of parameters that have been defined as fixed or free.
virtual void mnpsdf()
Calculates the eigenvalues of v to see if positive-def.
virtual Int_t GetNumFixedPars() const
returns the number of currently fixed parameters
virtual void mnpfit(Double_t *parx2p, Double_t *pary2p, Int_t npar2p, Double_t *coef2p, Double_t &sdev2p)
To fit a parabola to npar2p points.
virtual Int_t Release(Int_t parNo)
release a parameter
virtual void mnpars(TString &crdbuf, Int_t &icondn)
Implements one parameter definition.
virtual void mnimpr()
Attempts to improve on a good local minimum.
virtual void BuildArrays(Int_t maxpar=15)
Create internal Minuit arrays for the maxpar parameters.
virtual void mnwerr()
Calculates the WERR, external parameter errors.
virtual void mnrset(Int_t iopt)
Resets function value and errors to UNDEFINED.
virtual void mneig(Double_t *a, Int_t ndima, Int_t n, Int_t mits, Double_t *work, Double_t precis, Int_t &ifault)
Compute matrix eigen values.
virtual void mnsimp()
Minimization using the simplex method of Nelder and Mead.
TMethodCall * GetMethodCall() const
TMinuit()
Minuit normal constructor.
virtual void mnamin()
Initialize AMIN.
virtual Int_t SetErrorDef(Double_t up)
To get the n-sigma contour the error def parameter "up" has to set to n^2.
virtual void mncler()
Resets the parameter list to UNDEFINED.
virtual void mnplot(Double_t *xpt, Double_t *ypt, char *chpt, Int_t nxypt, Int_t npagwd, Int_t npagln)
Plots points in array xypt onto one page with labelled axes.
virtual Int_t Migrad()
invokes the MIGRAD minimizer
virtual void mncomd(const char *crdbin, Int_t &icondn)
Reads a command string and executes.
TString * fCpnam
Character to be plotted at the X,Y contour positions.
TMethodCall * fMethodCall
virtual void mngrad()
Interprets the SET GRAD command.
~TMinuit() override
Minuit default destructor.
virtual void mnrazz(Double_t ynew, Double_t *pnew, Double_t *y, Int_t &jh, Int_t &jl)
Called only by MNSIMP (and MNIMPR) to add a new point.
virtual void mnmnos()
Performs a MINOS error analysis.
virtual void mnline(Double_t *start, Double_t fstart, Double_t *step, Double_t slope, Double_t toler)
Perform a line search from position START.
virtual void mncuve()
Makes sure that the current point is a local minimum.
virtual void mnscan()
Scans the values of FCN as a function of one parameter.
virtual void DeleteArrays()
Delete internal Minuit arrays.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
TString fWarmes[kMAXWARN]
virtual void mnsave()
Writes current parameter values and step sizes onto file ISYSSA.
virtual void mnmatu(Int_t kode)
Prints the covariance matrix v when KODE=1.
virtual void mnlims()
Interprets the SET LIM command, to reset the parameter limits.
void(* fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
virtual void SetMaxIterations(Int_t maxiter=500)
virtual void SetFCN(void(*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t))
To set the address of the minimization function.
virtual void mncont(Int_t ke1, Int_t ke2, Int_t nptu, Double_t *xptu, Double_t *yptu, Int_t &ierrf)
Find points along a contour where FCN is minimum.
virtual void mninit(Int_t i1, Int_t i2, Int_t i3)
Main initialization member function for MINUIT.
virtual void mnseek()
Performs a rough (but global) minimization by monte carlo search.
virtual void mncalf(Double_t *pvec, Double_t &ycalf)
Transform FCN to find further minima.
virtual Int_t Command(const char *command)
Execute a Minuit command.
virtual void mnpout(Int_t iuext, TString &chnam, Double_t &val, Double_t &err, Double_t &xlolim, Double_t &xuplim, Int_t &iuint) const
Provides the user with information concerning the current status.
virtual Int_t Eval(Int_t npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag)
Evaluate the minimisation function Input parameters:
virtual void mnmigr()
Performs a local function minimization.
virtual void mnemat(Double_t *emat, Int_t ndim)
Calculates the external error matrix from the internal matrix.
virtual void mnrn15(Double_t &val, Int_t &inseed)
This is a super-portable random number generator.
virtual void mnerrs(Int_t number, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &gcc)
Utility routine to get MINOS errors.
virtual void mnexin(Double_t *pint)
Transforms the external parameter values U to internal values.
virtual void mnexcm(const char *comand, Double_t *plist, Int_t llist, Int_t &ierflg)
Interprets a command and takes appropriate action.
virtual void mnhelp(TString comd)
HELP routine for MINUIT interactive commands.
virtual Int_t SetPrintLevel(Int_t printLevel=0)
set Minuit print level.
Bool_t mnunpt(TString &cfname)
Returns .TRUE.
virtual void mnhess()
Calculates the full second-derivative matrix of FCN.
virtual void mneval(Double_t anext, Double_t &fnext, Int_t &ierev)
Evaluates the function being analysed by MNCROS.
virtual void mnset()
Interprets the commands that start with SET and SHOW.
virtual void mndxdi(Double_t pint, Int_t ipar, Double_t &dxdi)
Calculates the transformation factor between ext/internal values.
virtual void mntiny(Double_t epsp1, Double_t &epsbak)
To find the machine precision.
virtual void mninex(Double_t *pint)
Transforms from internal coordinates (PINT) to external (U)
virtual void mnpint(Double_t &pexti, Int_t i, Double_t &pinti)
Calculates the internal parameter value PINTI.
virtual void mnfixp(Int_t iint, Int_t &ierr)
Removes parameter IINT from the internal parameter list.
virtual void mnmnot(Int_t ilax, Int_t ilax2, Double_t &val2pl, Double_t &val2mi)
Performs a MINOS error analysis on one parameter.
virtual void mncrck(TString crdbuf, Int_t maxcwd, TString &comand, Int_t &lnc, Int_t mxp, Double_t *plist, Int_t &llist, Int_t &ierr, Int_t isyswr)
Cracks the free-format input.
virtual Int_t DefineParameter(Int_t parNo, const char *name, Double_t initVal, Double_t initErr, Double_t lowerLimit, Double_t upperLimit)
Define a parameter.
virtual void mnstat(Double_t &fmin, Double_t &fedm, Double_t &errdef, Int_t &npari, Int_t &nparx, Int_t &istat)
Returns concerning the current status of the minimization.
virtual void mnwarn(const char *copt, const char *corg, const char *cmes)
Prints Warning messages.
virtual void mnprin(Int_t inkode, Double_t fval)
Prints the values of the parameters at the time of the call.
TString fOrigin[kMAXWARN]
virtual void mncros(Double_t &aopt, Int_t &iercr)
Find point where MNEVAL=AMIN+UP.
virtual Int_t GetNumFreePars() const
returns the number of currently free parameters
virtual void mnhes1()
Calculate first derivatives (GRD) and uncertainties (DGRD)
virtual void mnfree(Int_t k)
Restores one or more fixed parameter(s) to variable status.
virtual void mncntr(Int_t ke1, Int_t ke2, Int_t &ierrf)
Print function contours in two variables, on line printer.
virtual TObject * Contour(Int_t npoints=10, Int_t pa1=0, Int_t pa2=1)
Creates a TGraph object describing the n-sigma contour of a TMinuit fit.
virtual void mnparm(Int_t k, TString cnamj, Double_t uk, Double_t wk, Double_t a, Double_t b, Int_t &ierflg)
Implements one parameter definition.
The TNamed class is the base class for all named ROOT classes.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * Data() const
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
void ToUpper()
Change string to upper case.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t ASin(Double_t)
Returns the principal value of the arc sine of x, expressed in radians.
Double_t ATan(Double_t)
Returns the principal value of the arc tangent of x, expressed in radians.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.