123 if (npar_real != npar){
124 fixed =
new Bool_t[npar_real];
125 memset(fixed,0,npar_real*
sizeof(
Bool_t));
127 for (
Int_t ipar=0; ipar<npar_real; ipar++){
130 if (al*bl != 0 && al >= bl) {
143 Int_t igrad, ifree=0;
144 for (
Int_t ipoint=0; ipoint<
n; ipoint++){
148 for (
Int_t irow=0; irow<npar; irow++){
151 for (
Int_t icol=0; icol<npar; icol++){
156 while (ifree<icol+1){
157 if (fixed[igrad]==0) ifree++;
165 sum_vector[irow]+=matr[irow*npar_real+icol]*grad[igrad];
169 for (
Int_t i=0; i<npar; i++){
174 if (fixed[igrad]==0) ifree++;
181 c+=grad[igrad]*sum_vector[i];
185 ci[ipoint]=c*t*chidf;
189 delete [] sum_vector;
221 Error(
"GetConfidenceIntervals",
"A TGraphErrors should be passed instead of a graph");
225 Error(
"GetConfidenceIntervals",
"A TGraph2DErrors should be passed instead of a graph");
230 Error(
"GetConfidenceIntervals",
"A TGraph2DErrors or a TH23 should be passed instead of a graph");
243 Error(
"GetConfidenceIntervals",
"A TGraph2DErrors should be passed instead of a TGraph2D");
247 Error(
"GetConfidenceIntervals",
"A TGraphErrors should be passed instead of a TGraph2D");
252 Error(
"GetConfidenceIntervals",
"A TGraphErrors or a TH1 should be passed instead of a graph");
268 for (
Int_t ipoint=0; ipoint<
np; ipoint++){
274 for (
Int_t icol=0; icol<npar; icol++)
275 sum_vector[irow]+=matr[irow*npar+icol]*grad[icol];
278 for (
Int_t i=0; i<npar; i++)
279 c+=grad[i]*sum_vector[i];
282 gr2->
GetEZ()[ipoint]=c*t*chidf;
286 delete [] sum_vector;
292 if (((
TH1*)obj)->GetDimension()>1){
293 Error(
"GetConfidenceIntervals",
"Fitted graph and passed histogram have different number of dimensions");
298 if (((
TH1*)obj)->GetDimension()!=2){
299 Error(
"GetConfidenceIntervals",
"Fitted graph and passed histogram have different number of dimensions");
305 Error(
"GetConfidenceIntervals",
"Fitted and passed histograms have different number of dimensions");
332 for (
Int_t binz=hzfirst; binz<=hzlast; binz++){
334 for (
Int_t biny=hyfirst; biny<=hylast; biny++) {
336 for (
Int_t binx=hxfirst; binx<=hxlast; binx++) {
339 for (
Int_t irow=0; irow<npar; irow++){
341 for (
Int_t icol=0; icol<npar; icol++)
342 sum_vector[irow]+=matr[irow*npar+icol]*grad[icol];
345 for (
Int_t i=0; i<npar; i++)
346 c+=grad[i]*sum_vector[i];
354 delete [] sum_vector;
357 Error(
"GetConfidenceIntervals",
"This object type is not supported");
382 if (i < 0 || i >= npars || j < 0 || j >= npars) {
383 Error(
"GetCovarianceMatrixElement",
"Illegal arguments i=%d, j=%d",i,j);
465 strcpy(parname,pname.
Data());
622 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
628 if (nd > 2) x[2] = cache[4];
629 if (nd > 1) x[1] = cache[3];
637 for (j=0;j<npar;j++) dersum[j] += 1;
638 for (j=0;j<npar;j++) grad[j] += dersum[j]*(fu-cu)/
eu; dersum[j] = 0;
670 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
680 fu = f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
682 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]);
684 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]);
689 for (j=0;j<npar;j++) dersum[j] += 1;
690 for (j=0;j<npar;j++) grad[j] += dersum[j]*(fu-cu)/
eu; dersum[j] = 0;
732 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
738 if (nd > 2) x[2] = cache[4];
739 if (nd > 1) x[1] = cache[3];
746 for (j=0;j<npar;j++) {
751 if (fu < 1.e-9) fu = 1.e-9;
752 if (fitOption.
Like == 1) {
798 if (flag == 2)
for (j=0;j<npar;j++) dersum[j] = gin[j] = 0;
804 if (nd > 2) x[2] = cache[6];
805 if (nd > 1) x[1] = cache[4];
811 fu = f1->
Integral(cache[2] - 0.5*cache[3],cache[2] + 0.5*cache[3])/cache[3];
813 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]);
815 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]);
819 for (j=0;j<npar;j++) {
824 if (fu < 1.e-9) fu = 1.e-9;
825 if (fitOption.
Like == 1) {
926 for (bin=0;bin<
n;bin++) {
947 if (exl < 0) exl = 0;
948 if (exh < 0) exh = 0;
950 if (exh > 0 || exl > 0) {
962 eux = 0.5*(exl + exh)*f1->
Derivative(x[0], u);
981 Double_t cu,
eu,
ex,
ey,ez,eux,euy,
fu,fsum,fm,fp;
1001 for (bin=0;bin<
n;bin++) {
1024 xm = x[0] -
ex;
if (xm < fxmin) xm = fxmin;
1025 xp = x[0] +
ex;
if (xp > fxmax) xp = fxmax;
1026 x[0] = xm; fm = f2->
EvalPar(x,u);
1027 x[0] = xp; fp = f2->
EvalPar(x,u);
1032 ym = x[1] -
ey;
if (ym < fymin) ym = fxmin;
1033 yp = x[1] +
ey;
if (yp > fymax) yp = fymax;
1034 x[1] = ym; fm = f2->
EvalPar(x,u);
1035 x[1] = yp; fp = f2->
EvalPar(x,u);
1038 eu = ez*ez+eux*eux+euy*euy;
1039 if (eu <= 0) eu = 1;
1075 for (bin=0;bin<
n;bin++) {
1092 if (exl < 0) exl = 0;
1093 if (exh < 0) exh = 0;
1095 if (exh > 0 && exl > 0) {
1107 eux = 0.5*(exl + exh)*f1->
Derivative(x[0], u);
1111 if (eu <= 0) eu = 1;
void GraphFitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
*-*-*-*-*-*Minimization function for Graphs using a Chisquare method*-*-*-*-* *-* ===================...
Int_t GetFirst() const
Return first bin on the axis i.e.
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 mnprin(Int_t inkode, Double_t fval)
*-*-*-*Prints the values of the parameters at the time of the call*-*-*-*-* *-* =====================...
virtual void FitChisquareI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method The "I"ntegral method is used for each point t...
virtual void SetParameters(const Double_t *params)
ClassImp(TFitter) TFitter
*-*-*-*-*-*-*-*-*-*-*default constructor*-*-*-*-*-*-*-*-*-*-*-*-* *-* =================== ...
virtual Double_t GetErrorYhigh(Int_t bin) const
This function is called by GraphFitChisquare.
void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
Implementation in C++ of the Minuit package written by F.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void FitLikelihood(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method*-*-*-*-*-* Basically, it forms the likelihood...
virtual Double_t GetYmax() const
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
virtual void mnemat(Double_t *emat, Int_t ndim)
Calculates the external error matrix from the internal matrix.
TList * GetListOfGraphs() const
virtual Int_t GetNumberFreeParameters() const
Return the number of free parameters.
virtual Foption_t GetFitOption() const
Double_t StudentQuantile(Double_t p, Double_t ndf, Bool_t lower_tail=kTRUE)
Computes quantiles of the Student's t-distribution 1st argument is the probability, at which the quantile is computed 2nd argument - the number of degrees of freedom of the Student distribution When the 3rd argument lower_tail is kTRUE (default)- the algorithm returns such x0, that P(x < x0)=p upper tail (lower_tail is kFALSE)- the algorithm returns such x0, that P(x > x0)=p the algorithm was taken from G.W.Hill, "Algorithm 396, Student's t-quantiles" "Communications of the ACM", 13(10), October 1970.
virtual Int_t GetDimension() const
virtual void FitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method Default method (function evaluated at center o...
virtual void PrintResults(Int_t level, Double_t amin) const
Print fit results.
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual Double_t GetParError(Int_t ipar) const
return error of parameter ipar
virtual TObject * GetUserFunc() const
virtual void SetNumberFitPoints(Int_t npfits)
virtual Int_t GetNumberTotalParameters() const
return the total number of parameters (free + fixed)
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
Execute a fitter command; command : command string args : list of nargs command arguments.
virtual void SetFCN(void *fcn)
To set the address of the minimization objective function.
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
IntegralOneDim or analytical integral.
virtual Int_t GetNDF() const
Return the number of degrees of freedom in the fit the fNDF parameter has been previously computed du...
virtual Double_t GetXmin() const
virtual Int_t GetNumPars() const
returns the total number of parameters that have been defined as fixed or free.
virtual Double_t * GetEY() const
virtual Double_t GetErrorXhigh(Int_t bin) const
This function is called by GraphFitChisquare.
virtual Int_t FixParameter(Int_t parNo)
fix a parameter
virtual ~TFitter()
*-*-*-*-*-*-*-*-*-*-*default destructor*-*-*-*-*-*-*-*-*-*-*-*-*-* *-* ================== ...
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
const char * Data() const
virtual void SetFCN(void *fcn)
*-*-*-*-*-*-*To set the address of the minimization function*-*-*-*-*-*-*-* *-* =====================...
virtual Double_t GetParameter(Int_t ipar) const
return current value of parameter ipar
Double_t GetChisquare() const
int GetDimension(const TH1 *h1)
virtual void ReleaseParameter(Int_t ipar)
Release parameter ipar.
virtual Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const
return current errors for a parameter ipar : parameter number eplus : upper error eminus : lower erro...
virtual void mnrn15(Double_t &val, Int_t &inseed)
*-*-*-*-*-*-*This is a super-portable random number generator*-*-*-*-*-*-* *-* ======================...
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const
return global fit parameters amin : chisquare edm : estimated distance to minimum errdef nvpar : numb...
virtual Double_t Chisquare(Int_t npar, Double_t *params) const
return a chisquare equivalent
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SetBinError(Int_t bin, Double_t error)
see convention for numbering bins in TH1::GetBin
virtual Double_t * GetEZ() const
void H1FitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Chisquare method
virtual Double_t GetXmax() const
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
virtual Double_t GradientPar(Int_t ipar, const Double_t *x, Double_t eps=0.01)
Compute the gradient (derivative) wrt a parameter ipar.
virtual Double_t GetErrorXlow(Int_t bin) const
This function is called by GraphFitChisquare.
virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const
return element i,j from the covariance matrix
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
TString * fCpnam
Character to be plotted at the X,Y contour positions.
Class to manage histogram axis.
virtual void mncler()
*-*-*-*-*-*-*-*-*-*-*Resets the parameter list to UNDEFINED*-*-*-*-*-*-*-* *-* ======================...
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*-*-*-*-*-*-*-*-*-*-*-* *-* =====================...
A 3-Dim function with parameters.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
static TVirtualFitter * GetFitter()
static: return the current Fitter
static void RejectPoint(Bool_t reject=kTRUE)
Static function to set the global flag to reject points the fgRejectPoint global flag is tested by al...
virtual Bool_t IsFixed(Int_t ipar) const
return kTRUE if parameter ipar is fixed, kFALSE othersise)
A 2-Dim function with parameters.
virtual void SetFCN(void *fcn)
Specify the address of the fitting algorithm (from the interpreter)
virtual void mnerrs(Int_t number, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &gcc)
*-*-*-*-*-*-*-*-*-*Utility routine to get MINOS errors*-*-*-*-*-*-*-*-*-*-* *-* =====================...
void MultiGraphFitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
virtual const char * GetParName(Int_t ipar) const
return name of parameter ipar
virtual Double_t Derivative(Double_t x, Double_t *params=0, Double_t epsilon=0.001) const
Returns the first derivative of the function at point x, computed by Richardson's extrapolation metho...
virtual void SetFitMethod(const char *name)
ret fit method (chisquare or loglikelihood)
virtual Double_t GetErrorYlow(Int_t bin) const
This function is called by GraphFitChisquare.
virtual Double_t GetYmin() const
virtual Int_t GetNumberFreeParameters() const
return the number of free parameters
virtual Double_t GetSumLog(Int_t i)
return Sum(log(i) i=0,n used by log likelihood fits
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
void F2Fit(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
virtual Int_t Release(Int_t parNo)
release a parameter
virtual Double_t * GetCovarianceMatrix() const
return a pointer to the covariance matrix
virtual void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95)
Computes point-by-point confidence intervals for the fitted function Parameters: n - number of points...
virtual void mnexcm(const char *comand, Double_t *plist, Int_t llist, Int_t &ierflg)
*-*-*-*-*-*Interprets a command and takes appropriate action*-*-*-*-*-*-*-* *-* =====================...
virtual void FixParameter(Int_t ipar)
Fix parameter ipar.
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
Abstract Base Class for Fitting.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Mother of all ROOT objects.
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
virtual Double_t * GetParameters() const
virtual Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
void Graph2DFitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
*-*-*-*-*Minimization function for 2D Graphs using a Chisquare method*-*-*-*-* *-* ==================...
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
static Bool_t RejectedPoint()
See TF1::RejectPoint above.
virtual void Clear(Option_t *option="")
reset the fitter environment
virtual TObject * GetObjectFit() const
A Graph is a graphics object made of two arrays X and Y with npoints each.
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
void H1FitLikelihood(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
-*-*-*-*Minimization function for H1s using a Likelihood method*-*-*-*-*-* Basically, it forms the likelihood by determining the Poisson probability that given a number of entries in a particular bin, the fit would predict it's value.
virtual Bool_t IsInside(const Double_t *x) const
Return kTRUE is the point is inside the function range.
Double_t Sqrt(Double_t x)
void F3Fit(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Graphics object made of three arrays X, Y and Z with the same number of points each.
virtual Bool_t IsInside(const Double_t *x) const
return kTRUE if the point is inside the function range
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
virtual Int_t GetNpar() const
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 void FitLikelihoodI(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Minimization function for H1s using a Likelihood method*-*-*-*-*-* Basically, it forms the likelihood...
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)
set initial values for a parameter ipar : parameter number parname : parameter name value : initial p...