114   assert (npar == (
int) minpar.size() );
 
  117   for (
int i =0; i < npar; ++i) {
 
  118      diff += std::abs( params[i] - minpar[i] );
 
  122   if (diff > s * 1.E-12 ) 
Warning(
"Chisquare",
"given parameter values are not at minimum - chi2 at minimum is returned");
 
  123   return fFitter->Result().Chi2();
 
  138   std::cout<<
"Execute command= "<<command<<std::endl;
 
  150         Error(
"ExecuteCommand",
"FCN must set before executing this command");
 
  156      return  (ret) ? 0 : -1;
 
  164         Error(
"ExecuteCommand",
"FCN must set before executing this command");
 
  168      return  (ret) ? 0 : -1;
 
  174         Error(
"ExecuteCommand",
"FCN must set before executing this command");
 
  180      return  (ret) ? 0 : -1;
 
  186         Error(
"ExecuteCommand",
"FCN must set before executing this command");
 
  192      return  (ret) ? 0 : -1;
 
  195   else if (scommand.
Contains(
"MINO"))   {
 
  197      if (
fFitter->Config().MinosErrors() ) 
return 0;
 
  200         Error(
"ExecuteCommand",
"FCN must set before executing this command");
 
  204      fFitter->Config().SetMinosErrors(
true);
 
  209      return  (ret) ? 0 : -1;
 
  213   else if (scommand.
Contains(
"HES"))   {
 
  215      if (
fFitter->Config().ParabErrors() ) 
return 0;
 
  218         Error(
"ExecuteCommand",
"FCN must set before executing this command");
 
  223      fFitter->Config().SetParabErrors(
true);
 
  226      return  (ret) ? 0 : -1;
 
  230   else if (scommand.
Contains(
"FIX"))   {
 
  231      for(
int i = 0; i < nargs; i++) {
 
  237   else if (scommand.
Contains(
"SET LIM"))   {
 
  239         Error(
"ExecuteCommand",
"Invalid parameters given in SET LIMIT");
 
  242      int ipar = 
int(args[0]);
 
  244      double low = args[1];
 
  246      fFitter->Config().ParSettings(ipar).SetLimits(low,up);
 
  250   else if (scommand.
Contains(
"SET PRIN"))   {
 
  251      if (nargs < 1) 
return -1;
 
  252      fFitter->Config().MinimizerOptions().SetPrintLevel(
int(args[0]) );
 
  256   else if (scommand.
Contains(
"SET ERR"))   {
 
  257      if (nargs < 1) 
return -1;
 
  258      fFitter->Config().MinimizerOptions().SetPrintLevel(
int( args[0]) );
 
  262   else if (scommand.
Contains(
"SET STR"))   {
 
  263      if (nargs < 1) 
return -1;
 
  264      fFitter->Config().MinimizerOptions().SetStrategy(
int(args[0]) );
 
  268   else if (scommand.
Contains(
"SET GRA"))   {
 
  274   else if (scommand.
Contains(
"SET NOW"))   {
 
  280   else if (scommand.
Contains(
"CALL FCN"))   {
 
  283      if (nargs < 1 || 
fFCN == 0 ) 
return -1;
 
  286      std::vector<double> params(npar);
 
  287      for (
int i = 0; i < npar; ++i)
 
  291      (*fFCN)(npar, 0, fval, ¶ms[0],
int(args[0]) ) ;
 
  296      Error(
"ExecuteCommand",
"Invalid or not supported command given %s",command);
 
  305   int nps  = 
fFitter->Config().ParamsSettings().size();
 
  306   if (ipar  < 0 || ipar >= nps ) {
 
  308      Error(
"ValidParameterIndex",
"%s",msg.c_str());
 
  319      fFitter->Config().ParSettings(ipar).Fix();
 
  335   if (!
fFitter->Result().IsValid()) {
 
  336      Error(
"GetConfidenceIntervals",
"Cannot compute confidence intervals with an invalide fit result");
 
  340   fFitter->Result().GetConfidenceIntervals(
n,ndim,1,
x,ci,cl,
false);
 
  370   if (!
fFitter->Result().IsValid() ) {
 
  371      Error(
"GetConfidenceIntervals",
"Cannot compute confidence intervals with an invalide fit result");
 
  379      Error(
"GetConfidenceIntervals",
"Cannot compute confidence intervals without a fitting object");
 
  383   if (fitobj->
InheritsFrom(TGraph2D::Class())) datadim = 2;
 
  385      TH1 * 
h1 = 
dynamic_cast<TH1*
>(fitobj);
 
  392         Error(
"GetConfidenceIntervals", 
"Invalid object passed for storing confidence level data, must be a TGraphErrors or a TH1");
 
  398         Error(
"GetConfidenceIntervals", 
"Invalid object passed for storing confidence level data, must be a TGraph2DErrors or a TH2");
 
  404         Error(
"GetConfidenceIntervals", 
"Invalid object passed for storing confidence level data, must be a TH3");
 
  423   unsigned int n = data.
Size();
 
  425   std::vector<double> ci( 
n );
 
  427   fFitter->Result().GetConfidenceIntervals(data,&ci[0],cl,
false);
 
  433   for (
unsigned int i = 0; i < 
n; ++i) {
 
  434      const double * 
x = data.
Coords(i);
 
  435      double y = (*func)( 
x ); 
 
  450         TH1 * 
h1 = 
dynamic_cast<TH1 *
> (obj);
 
  471   if (
fCovar.size() !=  nfreepar*nfreepar )
 
  472      fCovar.resize(nfreepar*nfreepar);
 
  474   if (!
fFitter->Result().IsValid() ) {
 
  475      Warning(
"GetCovarianceMatrix",
"Invalid fit result");
 
  480   for (
unsigned int i = 0; i < ntotpar; ++i) {
 
  481      if (
fFitter->Config().ParSettings(i).IsFixed() ) 
continue;
 
  483      for (
unsigned int j = 0; j < ntotpar; ++j) {
 
  484         if (
fFitter->Config().ParSettings(j).IsFixed() ) 
continue;
 
  485         unsigned int index = nfreepar*
l + 
m;
 
  486         assert(index < 
fCovar.size() );
 
  499   unsigned int np2 = 
fCovar.size();
 
  501   if ( np2 == 0 || np2 != npar *npar ) {
 
  503      if (
c == 0) 
return 0;
 
  505   return fCovar[i*npar + j];
 
  516      Warning(
"GetErrors",
"Invalid fit result");
 
  520   eparab = result.
Error(ipar);
 
  531   return fFitter->Result().NTotalParameters();
 
  535   return fFitter->Result().NFreeParameters();
 
  542   if (
fFitter->Result().IsEmpty() ) {
 
  546   return fFitter->Result().Error(ipar);
 
  553   if (
fFitter->Result().IsEmpty() ) {
 
  557   return fFitter->Result().Value(ipar);
 
  567   const std::string & pname = 
fFitter->Config().ParSettings(ipar).Name();
 
  568   const char * 
c = pname.c_str();
 
  569   std::copy(
c,
c + pname.size(),
name);
 
  571   if (
fFitter->Result().IsEmpty() ) {
 
  572      value = 
fFitter->Config().ParSettings(ipar).Value();
 
  573      verr  = 
fFitter->Config().ParSettings(ipar).Value();  
 
  574      vlow  = 
fFitter->Config().ParSettings(ipar).LowerLimit();  
 
  575      vhigh   = 
fFitter->Config().ParSettings(ipar).UpperLimit();  
 
  579      value =  
fFitter->Result().Value(ipar);
 
  580      verr = 
fFitter->Result().Error(ipar);
 
  581      vlow = 
fFitter->Result().LowerError(ipar);
 
  582      vhigh = 
fFitter->Result().UpperError(ipar);
 
  594   return fFitter->Config().ParSettings(ipar).Name().c_str();
 
  604   errdef = 
fFitter->Config().MinimizerOptions().ErrorDef();
 
  614   Warning(
"GetSumLog",
"Dummy  method - returned 0");
 
  625   return fFitter->Config().ParSettings(ipar).IsFixed();
 
  633   if (
fFitter->GetMinimizer() && 
fFitter->Config().MinimizerType() == 
"Minuit")
 
  634      fFitter->GetMinimizer()->PrintResults();
 
  636      if (level > 0) 
fFitter->Result().Print(std::cout);
 
  637      if (level > 1)  
fFitter->Result().PrintCovMatrix(std::cout);
 
  647      fFitter->Config().ParSettings(ipar).Release();
 
  655   Info(
"SetFitMethod",
"non supported method");
 
  664   std::vector<ROOT::Fit::ParameterSettings> & parlist = 
fFitter->Config().ParamsSettings();
 
  665   if ( ipar >= (
int) parlist.size() ) parlist.resize(ipar+1);
 
  667   if (verr == 0) ps.
Fix();
 
  668   if (vlow < vhigh) ps.
SetLimits(vlow, vhigh);
 
  692   if (
fFitter->Result().FittedFunction() != 0) {
 
  716      Error(
"SetMinimizerFunction",
"cannot create minimizer %s",
fFitter->Config().MinimizerType().c_str() );
 
  720         Error(
"SetMinimizerFunction",
"Object Function pointer is NULL");
 
  758   int ndim = 
fFitter->Config().ParamsSettings().size();
 
  781   return fFitter->GetMinimizer();
 
  800   if (!
gr) 
return false;
 
  803      Error(
"Scan",
"Minimizer is not available - cannot scan before fitting");
 
  807   unsigned int npoints = 
gr->
GetN();
 
  813   if ((
int) npoints < gr->GetN() ) 
gr->
Set(npoints);
 
  853   if (!
gr) 
return false;
 
  856      Error(
"Scan",
"Minimizer is not available - cannot scan before fitting");
 
  861   double upScale = 
fFitter->Config().MinimizerOptions().ErrorDef();
 
  868   unsigned int npoints = 
gr->
GetN();
 
  874   if ((
int) npoints < gr->GetN() ) 
gr->
Set(npoints);
 
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
 
Chi2FCN class for binnned fits using the least square methods.
 
void SetDimension(int dim)
 
unsigned int Size() const
return number of fit points
 
const DataOptions & Opt() const
access to options
 
const double * Coords(unsigned int ipoint) const
return a pointer to the coordinates data for the given fit point
 
class containg the result of the fit and all the related information (fitted parameter values,...
 
bool IsValid() const
True if fit successful, otherwise false.
 
double UpperError(unsigned int i) const
upper Minos error. If Minos has not run for parameter i return the parabolic error
 
double Error(unsigned int i) const
parameter error by index
 
double LowerError(unsigned int i) const
lower Minos error. If Minos has not run for parameter i return the parabolic error
 
double MinFcnValue() const
Return value of the objective function (chi2 or likelihood) used in the fit.
 
double Edm() const
Expected distance from minimum.
 
unsigned int NTotalParameters() const
get total number of parameters
 
unsigned int NFreeParameters() const
get total number of free parameters
 
double GlobalCC(unsigned int i) const
parameter global correlation coefficient
 
LogLikelihoodFCN class for likelihood fits.
 
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
 
void SetLimits(double low, double up)
set a double side limit, if low == up the parameter is fixed if low > up the limits are removed The c...
 
void Fix()
fix the parameter
 
class evaluating the log likelihood for binned Poisson likelihood fits it is template to distinguish ...
 
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
 
Documentation for the abstract class IBaseFunctionMultiDim.
 
virtual IBaseFunctionMultiDimTempl< T > * Clone() const =0
Clone a function.
 
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
 
virtual const double * Parameters() const =0
Access the parameter values.
 
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
 
void SetErrorDef(double up)
set scale for calculating the errors
 
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize
 
virtual bool Contour(unsigned int ivar, unsigned int jvar, unsigned int &npoints, double *xi, double *xj)
find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum The c...
 
virtual bool Scan(unsigned int ivar, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0)
scan function minimum for variable i.
 
Backward compatible implementation of TVirtualFitter.
 
ROOT::Math::Minimizer * fMinimizer
pointer to fitter object
 
void DoSetDimension()
Private method to set dimension in objective function.
 
virtual void SetFCN(void(*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t))
Override setFCN to use the Adapter to Minuit2 FCN interface To set the address of the minimization fu...
 
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)
Set (add) a new fit parameter passing initial value, step size (verr) and parameter limits if vlow > ...
 
virtual Double_t Chisquare(Int_t npar, Double_t *params) const
Do chisquare calculations in case of likelihood fits Do evaluation a the minimum only.
 
virtual Int_t GetNumberFreeParameters() const
 
ROOT::Math::Minimizer * GetMinimizer() const
Return a pointer to the minimizer.
 
virtual void PrintResults(Int_t level, Double_t amin) const
Print the fit result.
 
virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const
Get error matrix element (return all zero if matrix is not available)
 
virtual ~TBackCompFitter()
Destructor - delete the managed objects.
 
virtual Double_t GetParError(Int_t ipar) const
Parameter error.
 
TBackCompFitter()
Constructor needed by TVirtualFitter interface.
 
virtual Double_t GetSumLog(Int_t i)
Sum of log (un-needed)
 
virtual void ReleaseParameter(Int_t ipar)
Release a fit parameter.
 
virtual Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const
Get fit errors.
 
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.
 
std::shared_ptr< ROOT::Fit::FitData > fFitData
 
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const
Get fit statistical information.
 
virtual void Clear(Option_t *option="")
Clear resources for consecutive fits.
 
ROOT::Math::IParamMultiFunction * fModelFunc
 
virtual Int_t GetNumberTotalParameters() const
Number of total parameters.
 
virtual Double_t GetParameter(Int_t ipar) const
Parameter value.
 
TFitResult * GetTFitResult() const
Return a new copy of the TFitResult object which needs to be deleted later by the user.
 
void ReCreateMinimizer()
Recreate a minimizer instance using the function and data set objective function in minimizers functi...
 
std::shared_ptr< ROOT::Fit::Fitter > fFitter
data of the fit
 
virtual void SetFitMethod(const char *name)
Set fit method (chi2 or likelihood).
 
std::vector< double > fCovar
 
bool ValidParameterIndex(int ipar) const
Check if ipar is a valid parameter index.
 
virtual Bool_t IsFixed(Int_t ipar) const
Query if parameter ipar is fixed.
 
bool Contour(unsigned int ipar, unsigned int jpar, TGraph *gr, double confLevel=0.683)
Create a 2D contour around the minimum for the parameter ipar and jpar if a minimum does not exist or...
 
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
Execute the command (Fortran Minuit compatible interface)
 
virtual const char * GetParName(Int_t ipar) const
Return name of parameter ipar.
 
virtual void FixParameter(Int_t ipar)
Fix the parameter.
 
ROOT::Math::IMultiGenFunction * GetObjFunction() const
Return a pointer to the objective function (FCN) If fitting directly using TBackCompFitter the pointe...
 
virtual void SetObjFunction(ROOT::Math::IMultiGenFunction *f)
Set the objective function for fitting Needed if fitting directly using TBackCompFitter class The cla...
 
virtual Double_t * GetCovarianceMatrix() const
Get the error matrix in a pointer to a NxN array.
 
bool Scan(unsigned int ipar, TGraph *gr, double xmin=0, double xmax=0)
Scan parameter ipar between value of xmin and xmax A graph must be given which will be on return fill...
 
ROOT::Math::IMultiGenFunction * fObjFunc
 
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
 
Graph 2D class with errors.
 
Graphics object made of three arrays X, Y and Z with the same number of points each.
 
A TGraphErrors is a TGraph with error bars.
 
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
 
A TGraph is an object made of two arrays X and Y with npoints each.
 
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
 
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
 
TH1 is the base class of all histogram classes in ROOT.
 
virtual Int_t GetDimension() const
 
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
 
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...
 
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Return Global bin number corresponding to x,y,z.
 
virtual void SetName(const char *name)
Set the name of the TNamed.
 
virtual TObject * Clone(const char *newname="") const
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 Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
 
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
 
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
 
void ToUpper()
Change string to upper case.
 
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
 
virtual TObject * GetObjectFit() const
 
virtual Foption_t GetFitOption() const
 
static const char * GetDefaultFitter()
static: return the name of the default fitter
 
void(* fFCN)(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
 
void FillData(BinData &dv, const TH1 *hist, TF1 *func=0)
fill the data vector from a TH1.
 
std::string ToString(const T &val)
Utility function for conversion to strings.
 
Double_t ChisquareQuantile(Double_t p, Double_t ndf)
Evaluate the quantiles of the chi-squared probability distribution function.
 
bool fUseEmpty
normalize data by a normalized the bin volume (bin volume divided by a reference value)