163 for (
int i = 0; i<5; ++i)
fINDFLG[i] = 0;
222 gROOT->GetListOfSpecials()->Remove(
this);
464 case 0:
case 3:
case 2:
case 28:
486 if (
nargs<1)
return -1;
487 for (i=0;i<
nargs;i++) {
493 if (
nargs<1)
return 0;
495 for (i=0;i<
fNpar;i++)
504 if (
nargs<1)
return -1;
505 for (i=0;i<
nargs;i++) {
518 Printf(
"SAVe command is obsolete");
523 {
if(
nargs<1)
return -1;
544 case 26:
case 27:
case 29:
case 30:
case 31:
case 32:
546 case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
548 Printf(
"Obsolete command. Use corresponding SET command instead");
562 static const char *
cname[30] = {
629 for (i=0;i<
fNpar;i++)
645 Printf(
"Limits for param %s: Low=%E, High=%E",
667 Printf(
"Limits for param %s Low=%E, High=%E",
675 Printf(
"\nCovariant matrix ");
683 std::cout<<std::endl;
685 std::cout<<std::endl;
690 Printf(
"\nGlobal correlation factors (maximum correlation of the parameter\n with arbitrary linear combination of other parameters)");
691 for(i=0;i<
fNpar;i++) {
695 std::cout<<std::endl;
737 Printf(
"Relative floating point precision RP=%E",
fRP);
752 Printf(
"FUMILI-ROOT version 0.1");
777 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]>0.) {
799 Error(
"GetCovarianceMatrixElement",
"Illegal arguments i=%d, j=%d",i,
j);
840 else return fA[ipar];
955 Int_t i, k,
l,
ii,
ki,
li,
kk,
ni, ll,
nk,
nl,
ir,
lk;
966 for (i = 1; i <=
n; ++i) {
969 if (
pl_1[
ir] <= 0.0e0)
goto L1;
972 ni = i * (i - 1) / 2;
981 if (
nl -
ni <= 0)
goto L5;
991 if (i -
n >= 0)
goto L12;
995 nk = k * (k - 1) / 2;
1007 if (
l - i <= 0)
goto L9;
1015 if (
l <= 0)
goto L10;
1019 if (k - i - 1 <= 0)
goto L11;
1025 for (i = 1; i <=
n; ++i) {
1026 for (k = i; k <=
n; ++k) {
1027 nl = k * (k - 1) / 2;
1030 for (
l = k;
l <=
n; ++
l) {
1036 ki = k * (k - 1) / 2 + i;
1045 for (i = 1; i <= k; ++i) {
1065 Warning(
"IsFixed",
"Illegal parameter number :%d",ipar);
1074 std::cout <<
name <<
" : {";
1075 for (
int i = 0; i <
n; i++)
1076 std::cout <<
" " <<
x[i];
1077 std::cout <<
" }\n";
1081 std::cout <<
name <<
" : \n";
1083 for (
int i = 0; i <
n; i++) {
1084 for (
int j = 0;
j <= i;
j++) {
1085 std::cout <<
" " <<
x[
index];
1088 std::cout << std::endl;
1123 for( i = 0; i <
fNpar; i++) {
1152 for( i=0; i <
n; i++) {
1169 std::cout <<
"New iteration - nfcn " <<
fNfcn <<
" nn1 = " <<
nn1 <<
" fGT " <<
fGT <<
"\n";
1179 for( i = 0; i <
n; i++) {
1192 for( i=0; i <
nn0; i++)
fZ[i]=0.;
1204 if(!
ijkl)
return 10;
1212 for( i=0; i <
nn0; i++)
fZ0[i] =
fZ[i];
1219 if (
fDEBUG) std::cout <<
" factor t is " << -
fGT/t << std::endl;
1220 if( 0.59*t < -
fGT)
goto L19;
1222 if (t < 0.25 ) t = 0.25;
1230 for( i = 0; i <
n; i++) {
1240 std::cout <<
"change all PL and steps by factor t " << t << std::endl;
1249 std::cout <<
"exit iteration (L19) t = " << t <<
" fGT = " <<
fGT << std::endl;
1254 printf(
"trying to execute an illegal jump at L85\n");
1265 for( i = 0; i <
n; i++) {
1272 if ((
fA[i] >=
fAMX[i] &&
fGr[i] < 0.) ||
1275 std::cout <<
"Fix parameters with values outside boundary and negative derivative " << std::endl;
1281 for(
j=0;
j <= i;
j++) {
1303 for( i = 0; i <
n; i++) {
1320 std::cout <<
"Some problems inverting the matrix - go back and try reducing again" << std::endl;
1330 PrintMatrix(
"Approximate Covariance matrix (inverse of Hessian ) ",
n0,
fZ);
1337 for( i = 0; i <
n; i++) {
1341 for(
l = 0;
l <
n;
l++) {
1364 for( i = 0; i <
n; i++)
1382 std::cout <<
"Parameter " << i <<
" is outside bounds "
1396 std::cout <<
"Parameter " <<
ifix <<
" is the worst - fix it and repeat step calculation " << std::endl;
1410 for( i = 0; i <
n; i++) {
1427 std::cout <<
"Reduce parallelepide for "
1428 << i <<
" from " <<
fPL[i] <<
" to " <<
bi << std::endl;
1436 std::cout <<
"step out of bound for " << i <<
" reduce to " <<
al << std::endl;
1450 std::cout <<
"Compute now corrected step - min found correction factor " <<
alambd <<
" max of akappa " <<
fAKAPPA <<
" nn2 " <<
nn2 << std::endl;
1456 for( i = 0; i <
n; i++) {
1461 std::cout <<
"increase parallelipid 4-times for " << i << std::endl;
1474 std::cout <<
"after applying step reduction of " <<
alambd <<
" expected function change is " <<
fGT << std::endl;
1497 std::cout <<
"We have fixed some params - released and repeat " << std::endl;
1536 for ( i = 0; i <
n; i++)
fA[i] =
fA[i] +
fDA[i];
1559 std::cout <<
"Continue and repeat iteration " << std::endl;
1585 xsexpl=
"****\n* FUNCTION IS NOT DECREASING OR BAD DERIVATIVES\n****";
1589 xsexpl=
"****\n* ESTIMATED ERRORS ARE INfiNITE\n****";
1593 xsexpl=
"****\n* MAXIMUM NUMBER OF ITERATIONS IS EXCEEDED\n****";
1597 xsexpl=
"****\n* PROBABILITY OF LIKLIHOOD FUNCTION IS NEGATIVE OR ZERO\n****";
1601 xsexpl=
"****\n* fiT IS IN PROGRESS\n****";
1609 colhdl[1] =
" NEGATIVE ";
1610 colhdl[2] =
" POSITIVE ";
1615 colhdu[1] =
" INTERNAL ";
1616 colhdl[1] =
" STEP SIZE ";
1617 colhdu[2] =
" INTERNAL ";
1626 colhdl[2] =
" DERIVATIVE";
1629 colhdu[0] =
" PARABOLIC ";
1633 colhdl[1] =
" NEGATIVE ";
1634 colhdl[2] =
" POSITIVE ";
1637 Printf(
" FCN=%g FROM FUMILI STATUS=%-10s %9d CALLS OF FCN",
1640 Printf(
" EXT PARAMETER %-14s%-14s%-14s",
1641 (
const char*)
colhdu[0].Data()
1642 ,(
const char*)
colhdu[1].Data()
1643 ,(
const char*)
colhdu[2].Data());
1644 Printf(
" NO. NAME VALUE %-14s%-14s%-14s",
1645 (
const char*)
colhdl[0].Data()
1646 ,(
const char*)
colhdl[1].Data()
1647 ,(
const char*)
colhdl[2].Data());
1664 cx2 =
" *undefined* ";
1665 cx3 =
" *undefined* ";
1668 Printf(
"%4d %-11s%14.5e%14.5e%-14s%-14s",i+1
1678 if(ipar>=0 && ipar<
fNpar &&
fPL0[ipar]<=0.) {
1798 fS =
fS + (
y*
y/(sig*sig))*.5;
1801 for (i=0;i<
fNpar;i++) {
1804 fGr[i] += df[
n]*(
y/sig);
1811 fZ[
l++] += df[i]*df[
j];
1848 if(
flag == 9)
return;
1859 if (nd > 2)
x[2] = cache[4];
1860 if (nd > 1)
x[1] = cache[3];
1882 zik[
l++] += df[
j]*df[k];
1915 if(
flag == 9)
return;
1929 fu =
f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
1930 }
else if (nd < 3) {
1931 fu = ((
TF2*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5])/(cache[3]*cache[5]);
1933 fu = ((
TF3*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5],cache[6] - 0.5*cache[7],cache[6] + 0.5*cache[7])/(cache[3]*cache[5]*cache[7]);
1952 zik[
l++] += df[
j]*df[k];
1996 if(
flag == 9)
return;
2005 if (nd > 2)
x[2] = cache[4];
2006 if (nd > 1)
x[1] = cache[3];
2018 if (
fu < 1.e-9)
fu = 1.e-9;
2039 zik[
l++] += df[
j]*df[k];
2081 if(
flag == 9) {
delete [] df;
return;}
2089 if (nd > 2)
x[2] = cache[4];
2090 if (nd > 1)
x[1] = cache[3];
2095 fu =
f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
2096 }
else if (nd < 3) {
2097 fu = ((
TF2*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5])/(cache[3]*cache[5]);
2099 fu = ((
TF3*)
f1)->Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3],cache[4] - 0.5*cache[5],cache[4] + 0.5*cache[5],cache[6] - 0.5*cache[7],cache[6] + 0.5*cache[7])/(cache[3]*cache[5]*cache[7]);
2108 if (
fu < 1.e-9)
fu = 1.e-9;
2129 zik[
l++] += df[
j]*df[k];
2222 if(
flag == 9)
return;
2230 for (bin=0;bin<
n;bin++) {
2248 if (
exh > 0 &&
exl > 0) {
2254 if (eu <= 0) eu = 1;
2260 for (i=0;i<
npar;i++) {
2271 zik[
l++] += df[i]*df[
j];
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
static const Double_t gMAXDOUBLE
void H1FitChisquareFumili(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method.
void PrintMatrix(const char *name, int n, double *x)
void GraphFitChisquareFumili(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for Graphs using a Chisquare method.
void H1FitLikelihoodFumili(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method.
static const Double_t gMINDOUBLE
void PrintVector(const char *name, int n, double *x)
R__EXTERN TFumili * gFumili
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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 GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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.
static void RejectPoint(Bool_t reject=kTRUE)
Static function to set the global flag to reject points the fgRejectPoint global flag is tested by al...
virtual Double_t Derivative(Double_t x, Double_t *params=nullptr, Double_t epsilon=0.001) const
Returns the first derivative of the function at point x, computed by Richardson's extrapolation metho...
virtual Int_t GetNpar() const
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
IntegralOneDim or analytical integral.
virtual void SetNumberFitPoints(Int_t npfits)
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=nullptr)
Evaluate function with given coordinates and parameters.
static Bool_t RejectedPoint()
See TF1::RejectPoint above.
virtual void SetParameters(const Double_t *params)
virtual Bool_t IsInside(const Double_t *x) const
return kTRUE if the point is inside the function range
A 2-Dim function with parameters.
A 3-Dim function with parameters.
Double_t GetParameter(Int_t ipar) const override
Return current value of parameter ipar.
void DeleteArrays()
Deallocates memory. Called from destructor TFumili::~TFumili.
Bool_t fNumericDerivatives
Double_t GetParError(Int_t ipar) const override
Return error of parameter ipar.
Bool_t IsFixed(Int_t ipar) const override
Return kTRUE if parameter ipar is fixed, kFALSE otherwise)
Int_t fNED2
K - Length of vector X plus 2 (for chi2)
Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const override
Return element i,j from the covariance matrix.
Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs) override
Execute MINUIT commands.
Int_t fNpar
fNpar - number of parameters
void PrintResults(Int_t k, Double_t p) const override
Prints fit results.
Int_t GetNumberFreeParameters() const override
Return the number of free parameters.
Int_t GetNumberTotalParameters() const override
Return the total number of parameters (free + fixed)
Double_t * GetCovarianceMatrix() const override
Return a pointer to the covariance matrix.
virtual void FitLikelihood(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method.
~TFumili() override
TFumili destructor.
Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const override
Return global fit parameters.
Double_t * fEXDA
[fNED12] experimental data poInt_ter
Int_t SGZ()
Evaluates objective function ( chi-square ), gradients and Z-matrix using data provided by user via T...
void ReleaseParameter(Int_t ipar) override
Releases parameter number ipar.
virtual void FitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method.
const char * GetParName(Int_t ipar) const override
Return name of parameter ipar.
void FixParameter(Int_t ipar) override
Fixes parameter number ipar.
void Derivatives(Double_t *, Double_t *)
Calculates partial derivatives of theoretical function.
Double_t * fAMN
[fMaxParam] Minimum param value
TString * fANames
[fMaxParam] Parameter names
Double_t * GetPL0() const
Double_t * fPL
[fMaxParam] Limits for parameters step. If <0, then parameter is fixed
Int_t Eval(Int_t &npar, Double_t *grad, Double_t &fval, Double_t *par, Int_t flag)
Evaluate the minimisation function.
void SetParNumber(Int_t ParNum)
void SetData(Double_t *, Int_t, Int_t)
Sets pointer to data array provided by user.
Int_t fINDFLG[5]
internal flags;
Double_t EvalTFN(Double_t *, Double_t *)
Evaluate theoretical function.
Double_t * fParamError
[fMaxParam] Parameter errors
Double_t Chisquare(Int_t npar, Double_t *params) const override
return a chisquare equivalent
Int_t fENDFLG
End flag of fit.
Double_t * fR
[fMaxParam] Correlation factors
Double_t * fDA
[fMaxParam] Parameter step
void SetFitMethod(const char *name) override
ret fit method (chisquare or log-likelihood)
Int_t fNstepDec
fNstepDec - maximum number of step decreasing counter
Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const override
Return errors after MINOs not implemented.
Double_t * fZ0
[fMaxParam2] Matrix of approximate second derivatives of objective function This matrix is diagonal a...
Double_t * fPL0
[fMaxParam] Step initial bounds
Double_t * fA
[fMaxParam] Fit parameter array
Int_t Minimize()
Main minimization procedure.
Int_t fNmaxIter
fNmaxIter - maximum number of iterations
Int_t ExecuteSetCommand(Int_t)
Called from TFumili::ExecuteCommand in case of "SET xxx" and "SHOW xxx".
Double_t fS
fS - objective function value (return)
Double_t fEPS
fEPS - required precision of parameters. If fEPS<0 then
virtual void FitChisquareI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method.
Int_t fNfcn
Number of FCN calls;.
Int_t fLastFixed
Last fixed parameter number.
void BuildArrays()
Allocates memory for internal arrays.
Double_t * fZ
[fMaxParam2] Inverse fZ0 matrix - covariance matrix
Bool_t fLogLike
LogLikelihood flag.
Int_t fNED1
Number of experimental vectors X=(x1,x2,...xK)
void Clear(Option_t *opt="") override
Resets all parameter names, values and errors to zero.
Double_t * fGr
[fMaxParam] Gradients of objective function
Double_t fGT
Expected function change in next iteration.
Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh) override
Sets for parameter number ipar initial parameter value, name parname, initial error verr and limits v...
TString fCword
Command string.
virtual void FitLikelihoodI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method.
Double_t fRP
Precision of fit ( machine zero on CDC 6000) quite old yeh?
Double_t * fCmPar
[fMaxParam] parameters of commands
Double_t * fDF
[fMaxParam] First derivatives of theoretical function
Double_t GetSumLog(Int_t) override
Return Sum(log(i) i=0,n used by log-likelihood fits.
Double_t * fSumLog
[fNlog]
Double_t * fAMX
[fMaxParam] Maximum param value
Int_t fNlimMul
fNlimMul - after fNlimMul successful iterations permits four-fold increasing of fPL
Bool_t fGRAD
user calculated gradients
void InvertZ(Int_t)
Inverts packed diagonal matrix Z by square-root method.
Double_t GetErrorY(Int_t bin) const override
It returns the error along Y at point i.
Double_t GetErrorXhigh(Int_t bin) const override
It returns the error along X at point i.
Double_t GetErrorXlow(Int_t bin) const override
It returns the error along X at point i.
A TGraph is an object made of two arrays X and Y with npoints each.
TH1 is the base class of all histogram classes in ROOT.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kInvalidObject
if object ctor succeeded but object should not be used
const char * Data() const
void ToUpper()
Change string to upper case.
Int_t fPointSize
Number of words per point in the cache.
virtual TObject * GetObjectFit() const
TObject * fUserFunc
Pointer to user theoretical function (a TF1*)
virtual Foption_t GetFitOption() const
virtual void SetFCN(void(*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t))
To set the address of the minimization objective function called by the native compiler (see function...
Double_t * fCache
[fCacheSize] Array of points data (fNpoints*fPointSize < fCacheSize words)
void(* fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual TObject * GetUserFunc() const
Int_t fNpoints
Number of points to fit.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.