Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMinimizer Class Reference

RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between the minimizer functionality and the native RooFit interface.

By default the Minimizer is MINUIT for classic FcnMode and MINUIT2 for gradient FcnMode. RooMinimizer can minimize any RooAbsReal function with respect to its parameters. Usual choices for minimization are RooNLLVar and RooChi2Var RooMinimizer has methods corresponding to MINUIT functions like hesse(), migrad(), minos() etc. In each of these function calls the state of the MINUIT engine is synchronized with the state of the RooFit variables: any change in variables, change in the constant status etc is forwarded to MINUIT prior to execution of the MINUIT call. Afterwards the RooFit objects are resynchronized with the output state of MINUIT: changes parameter values, errors are propagated. Various methods are available to control verbosity, profiling, automatic PDF optimization.

Definition at line 51 of file RooMinimizer.h.

Public Types

enum class  FcnMode { classic , gradient , generic_wrapper }
 
enum  PrintLevel {
  None =-1 , Reduced =0 , Normal =1 , ExtraForProblem =2 ,
  Maximum =3
}
 
enum  Strategy { Speed =0 , Balance =1 , Robustness =2 }
 
- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = BIT(0) , kOverwrite = BIT(1) , kWriteDelete = BIT(2) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = BIT(3) }
 
enum  EStatusBits {
  kCanDelete = BIT(0) , kMustCleanup = BIT(3) , kIsReferenced = BIT(4) , kHasUUID = BIT(5) ,
  kCannotPick = BIT(6) , kNoContextMenu = BIT(8) , kInvalidObject = BIT(13)
}
 

Public Member Functions

 RooMinimizer (RooAbsReal &function, FcnMode fcnMode=FcnMode::classic)
 Construct MINUIT interface to given function.
 
 RooMinimizer (std::shared_ptr< RooFit::TestStatistics::RooAbsL > likelihood, RooFit::TestStatistics::LikelihoodMode likelihoodMode=RooFit::TestStatistics::LikelihoodMode::serial, RooFit::TestStatistics::LikelihoodGradientMode likelihoodGradientMode=RooFit::TestStatistics::LikelihoodGradientMode::multiprocess)
 
 ~RooMinimizer () override
 Destructor.
 
RooPlotcontour (RooRealVar &var1, RooRealVar &var2, Double_t n1=1, Double_t n2=2, Double_t n3=0, Double_t n4=0, Double_t n5=0, Double_t n6=0, unsigned int npoints=50)
 Create and draw a TH2 with the error contours in the parameters var1 and var2.
 
Int_t evalCounter () const
 
RooFitResultfit (const char *options) R__DEPRECATED(6
 Parse traditional RooAbsPdf::fitTo driver options.
 
ROOT::Fit::Fitterfitter ()
 Return underlying ROOT fitter object.
 
const ROOT::Fit::Fitterfitter () const
 Return underlying ROOT fitter object.
 
virtual RooFitResultfitTo (RooAbsData &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
 Fit PDF to given dataset.
 
virtual RooFitResultfitTo (RooAbsData &data, const RooLinkedList &cmdList)
 Fit PDF to given dataset.
 
ROOT::Math::IMultiGenFunctiongetFitterMultiGenFcn () const
 
ROOT::Math::IMultiGenFunctiongetMultiGenFcn () const
 
Int_t getNPar () const
 
Int_t getPrintLevel () const
 
Int_t hesse ()
 Execute HESSE.
 
Int_t improve ()
 Execute IMPROVE.
 
Int_t migrad ()
 Execute MIGRAD.
 
Int_t minimize (const char *type, const char *alg=0)
 Minimise the function passed in the constructor.
 
Int_t minos ()
 Execute MINOS.
 
Int_t minos (const RooArgSet &minosParamList)
 Execute MINOS for given list of parameters.
 
void optimizeConst (Int_t flag)
 If flag is true, perform constant term optimization on function being minimized.
 
RooFitResultsave (const char *name=0, const char *title=0)
 Save and return a RooFitResult snapshot of current minimizer status.
 
void saveStatus (const char *label, Int_t status)
 
Int_t seek ()
 Execute SEEK.
 
void setEps (Double_t eps)
 Change MINUIT epsilon.
 
void setErrorLevel (Double_t level)
 Set the level for MINUIT error analysis to the given value.
 
void setEvalErrorWall (Bool_t flag)
 
Bool_t setLogFile (const char *logf=0)
 
void setMaxFunctionCalls (Int_t n)
 Change maximum number of likelihood function calss from MINUIT (RooMinimizer default 500 * #parameters)
 
void setMaxIterations (Int_t n)
 Change maximum number of MINUIT iterations (RooMinimizer default 500 * #parameters)
 
void setMinimizerType (const char *type)
 Choose the minimizer algorithm.
 
void setOffsetting (Bool_t flag)
 Enable internal likelihood offsetting for enhanced numeric precision.
 
void setPrintEvalErrors (Int_t numEvalErrors)
 
Int_t setPrintLevel (Int_t newLevel)
 Change the MINUIT internal printing level.
 
void setProfile (Bool_t flag=kTRUE)
 
void setRecoverFromNaNStrength (double strength)
 Try to recover from invalid function values.
 
void setStrategy (Int_t strat)
 Change MINUIT strategy to istrat.
 
void setVerbose (Bool_t flag=kTRUE)
 
Int_t simplex ()
 Execute SIMPLEX.
 
void zeroEvalCount ()
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility.
 
virtual Int_t Compare (const TObject *obj) const
 Compare abstract method.
 
virtual void Copy (TObject &object) const
 Copy this to obj.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object.
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=0)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py).
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual const char * GetName () const
 Returns name of object.
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py).
 
virtual Option_tGetOption () const
 
virtual const char * GetTitle () const
 Returns title of object.
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
virtual ULong_t Hash () const
 Return hash value for this object.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 IsDestructed.
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 The ls function lists the contents of a class on stdout.
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification.
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual void Print (Option_t *option="") const
 This method must be overridden when a class wants to print itself.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out".
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Static Public Member Functions

static void cleanup ()
 Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects when the program is terminated.
 
static RooFitResultlastMinuitFit (const RooArgList &varList=RooArgList())
 
- Static Public Member Functions inherited from TObject
static Longptr_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 

Protected Member Functions

void applyCovarianceMatrix (TMatrixDSym &V)
 Apply results of given external covariance matrix.
 
bool fitFcn () const
 
RooAbsMinimizerFcnfitterFcn ()
 
const RooAbsMinimizerFcnfitterFcn () const
 
std::ofstream * logfile ()
 
Double_tmaxFCN ()
 
void profileStart ()
 Start profiling timer.
 
void profileStop ()
 Stop profiling timer and report results of last session.
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

Private Member Functions

 RooMinimizer (const RooMinimizer &)
 
void initMinimizerFcnDependentPart (double defaultErrorLevel)
 Initialize the part of the minimizer that is dependent on the function to be minimized.
 
void initMinimizerFirstPart ()
 Initialize the part of the minimizer that is independent of the function to be minimized.
 

Private Attributes

TStopwatch _cumulTimer
 
TMatrixDSym_extV = 0
 
RooAbsMinimizerFcn_fcn
 
FcnMode _fcnMode
 
std::string _minimizerType = "Minuit"
 
Int_t _printLevel = 1
 
Bool_t _profile = kFALSE
 
Bool_t _profileStart = kFALSE
 
Int_t _status = -99
 
std::vector< std::pair< std::string, int > > _statusHistory
 
TStopwatch _timer
 
Bool_t _verbose = kFALSE
 

Static Private Attributes

static ROOT::Fit::Fitter_theFitter = 0
 

Friends

class RooAbsPdf
 

Additional Inherited Members

- Protected Types inherited from TObject
enum  { kOnlyPrepStep = BIT(3) }
 

#include <RooMinimizer.h>

Inheritance diagram for RooMinimizer:
[legend]

Member Enumeration Documentation

◆ FcnMode

enum class RooMinimizer::FcnMode
strong
Enumerator
classic 
gradient 
generic_wrapper 

Definition at line 53 of file RooMinimizer.h.

◆ PrintLevel

Enumerator
None 
Reduced 
Normal 
ExtraForProblem 
Maximum 

Definition at line 65 of file RooMinimizer.h.

◆ Strategy

Enumerator
Speed 
Balance 
Robustness 

Definition at line 64 of file RooMinimizer.h.

Constructor & Destructor Documentation

◆ RooMinimizer() [1/3]

RooMinimizer::RooMinimizer ( RooAbsReal function,
FcnMode  fcnMode = FcnMode::classic 
)
explicit

Construct MINUIT interface to given function.

Function can be anything, but is typically a -log(likelihood) implemented by RooNLLVar or a chi^2 (implemented by RooChi2Var). Other frequent use cases are a RooAddition of a RooNLLVar plus a penalty or constraint term. This class propagates all RooFit information (floating parameters, their values and errors) to MINUIT before each MINUIT call and propagates all MINUIT information back to the RooFit object at the end of each call (updated parameter values, their (asymmetric errors) etc. The default MINUIT error level for HESSE and MINOS error analysis is taken from the defaultErrorLevel() value of the input function.

Definition at line 109 of file RooMinimizer.cxx.

◆ RooMinimizer() [2/3]

◆ ~RooMinimizer()

RooMinimizer::~RooMinimizer ( )
override

Destructor.

Definition at line 189 of file RooMinimizer.cxx.

◆ RooMinimizer() [3/3]

RooMinimizer::RooMinimizer ( const RooMinimizer )
private

Member Function Documentation

◆ applyCovarianceMatrix()

void RooMinimizer::applyCovarianceMatrix ( TMatrixDSym V)
protected

Apply results of given external covariance matrix.

i.e. propagate its errors to all RRV parameter representations and give this matrix instead of the HESSE matrix at the next save() call

Definition at line 944 of file RooMinimizer.cxx.

◆ cleanup()

void RooMinimizer::cleanup ( )
static

Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects when the program is terminated.

Definition at line 87 of file RooMinimizer.cxx.

◆ contour()

RooPlot * RooMinimizer::contour ( RooRealVar var1,
RooRealVar var2,
Double_t  n1 = 1,
Double_t  n2 = 2,
Double_t  n3 = 0,
Double_t  n4 = 0,
Double_t  n5 = 0,
Double_t  n6 = 0,
unsigned int  npoints = 50 
)

Create and draw a TH2 with the error contours in the parameters var1 and var2.

Parameters
[in]var1The first parameter (x axis).
[in]var2The second parameter (y axis).
[in]n1First contour.
[in]n2Optional contour. 0 means don't draw.
[in]n3Optional contour. 0 means don't draw.
[in]n4Optional contour. 0 means don't draw.
[in]n5Optional contour. 0 means don't draw.
[in]n6Optional contour. 0 means don't draw.
[in]npointsNumber of points for evaluating the contour.

Up to six contours can be drawn using the arguments n1 to n6 to request the desired coverage in units of \( \sigma = n^2 \cdot \mathrm{ErrorDef} \). See ROOT::Math::Minimizer::ErrorDef().

Definition at line 758 of file RooMinimizer.cxx.

◆ evalCounter()

Int_t RooMinimizer::evalCounter ( ) const
inline

Definition at line 110 of file RooMinimizer.h.

◆ fit()

RooFitResult * RooMinimizer::fit ( const char *  options)

Parse traditional RooAbsPdf::fitTo driver options.

m - Run Migrad only h - Run Hesse to estimate errors v - Verbose mode l - Log parameters after each Minuit steps to file t - Activate profile timer r - Save fit result 0 - Run Migrad with strategy 0

Definition at line 318 of file RooMinimizer.cxx.

◆ fitFcn()

bool RooMinimizer::fitFcn ( ) const
protected

Definition at line 340 of file RooMinimizer.cxx.

◆ fitter() [1/2]

ROOT::Fit::Fitter * RooMinimizer::fitter ( )

Return underlying ROOT fitter object.

Definition at line 291 of file RooMinimizer.cxx.

◆ fitter() [2/2]

const ROOT::Fit::Fitter * RooMinimizer::fitter ( ) const

Return underlying ROOT fitter object.

Definition at line 300 of file RooMinimizer.cxx.

◆ fitterFcn() [1/2]

RooAbsMinimizerFcn * RooMinimizer::fitterFcn ( )
protected

Definition at line 932 of file RooMinimizer.cxx.

◆ fitterFcn() [2/2]

const RooAbsMinimizerFcn * RooMinimizer::fitterFcn ( ) const
protected

Definition at line 910 of file RooMinimizer.cxx.

◆ fitTo() [1/2]

RooAbsPdf::fitTo ( RooAbsData data,
const RooCmdArg arg1 = RooCmdArg::none(),
const RooCmdArg arg2 = RooCmdArg::none(),
const RooCmdArg arg3 = RooCmdArg::none(),
const RooCmdArg arg4 = RooCmdArg::none(),
const RooCmdArg arg5 = RooCmdArg::none(),
const RooCmdArg arg6 = RooCmdArg::none(),
const RooCmdArg arg7 = RooCmdArg::none(),
const RooCmdArg arg8 = RooCmdArg::none() 
)

Fit PDF to given dataset.

If dataset is unbinned, an unbinned maximum likelihood is performed. If the dataset is binned, a binned maximum likelihood is performed. By default the fit is executed through the MINUIT commands MIGRAD, HESSE in succession.

Parameters
[in]dataData to fit the PDF to
[in]arg1One or more arguments to control the behaviour of the fit
Returns
RooFitResult with fit status and parameters if option Save() is used, nullptr otherwise. The user takes ownership of the fit result.

The following named arguments are supported

Type of CmdArg Options to control construction of -log(L)
ConditionalObservables(Args_t &&... argsOrArgSet) Do not normalize PDF over listed observables.
Extended(Bool_t flag) Add extended likelihood term, off by default
Range(const char* name) Fit only data inside range with given name. Multiple comma-separated range names can be specified. In this case, the unnormalized PDF \(f(x)\) is normalized by the integral over all ranges \(r_i\):

\[ p(x) = \frac{f(x)}{\sum_i \int_{r_i} f(x) dx}. \]

Range(Double_t lo, Double_t hi) Fit only data inside given range. A range named "fit" is created on the fly on all observables.
SumCoefRange(const char* name) Set the range in which to interpret the coefficients of RooAddPdf components
NumCPU(int num, int strat) Parallelize NLL calculation on num CPUs
Strategy Effect
0 = RooFit::BulkPartition (Default) Divide events in N equal chunks
1 = RooFit::Interleave Process event iN in process N. Recommended for binned data with a substantial number of zero-bins, which will be distributed across processes more equitably in this strategy
2 = RooFit::SimComponents Process each component likelihood of a RooSimultaneous fully in a single process and distribute components over processes. This approach can be benificial if normalization calculation time dominates the total computation time of a component (since the normalization calculation must be performed in each process in strategies 0 and 1. However beware that if the RooSimultaneous components do not share many parameters this strategy is inefficient: as most minuit-induced likelihood calculations involve changing a single parameter, only 1 of the N processes will be active most of the time if RooSimultaneous components do not share many parameters
3 = RooFit::Hybrid Follow strategy 0 for all RooSimultaneous components, except those with less than 30 dataset entries, for which strategy 2 is followed.
SplitRange(Bool_t flag) Use separate fit ranges in a simultaneous fit. Actual range name for each subsample is assumed to by rangeName_indexState where indexState is the state of the master index category of the simultaneous fit. Using Range("range"), SplitRange() as switches, different ranges could be set like this:
myVariable.setRange("range_pi0", 135, 210);
myVariable.setRange("range_gamma", 50, 210);
Constrain(const RooArgSet&pars) For p.d.f.s that contain internal parameter constraint terms (that is usually product PDFs, where one term of the product depends on parameters but not on the observable(s),), only apply constraints to the given subset of parameters.
ExternalConstraints(const RooArgSet& ) Include given external constraints to likelihood by multiplying them with the original likelihood.
GlobalObservables(const RooArgSet&) Define the set of normalization observables to be used for the constraint terms. If none are specified the constrained parameters are used.
Offset(Bool_t) Offset likelihood by initial value (so that starting value of FCN in minuit is zero). This can improve numeric stability in simultaneously fits with components with large likelihood values
BatchMode(bool on) Experimental batch evaluation mode. This computes a batch of likelihood values at a time, uses faster math functions and possibly auto vectorisation (this depends on the compiler flags). Depending on hardware capabilities, the compiler flags and whether a batch evaluation function was implemented for the PDFs of the model, likelihood computations are 2x to 10x faster. The relative difference of the single log-likelihoods w.r.t. the legacy mode is usually better than 1.E-12, and fit parameters usually agree to better than 1.E-6.
IntegrateBins(double precision) In binned fits, integrate the PDF over the bins instead of using the probability density at the bin centre. This can reduce the bias observed when fitting functions with high curvature to binned data.
  • precision > 0: Activate bin integration everywhere. Use precision between 0.01 and 1.E-6, depending on binning. Note that a low precision such as 0.01 might yield identical results to 1.E-4, since the integrator might reach 1.E-4 already in its first integration step. If lower precision is desired (more speed), a RooBinSamplingPdf has to be created manually, and its integrator has to be manipulated directly.
  • precision = 0: Activate bin integration only for continuous PDFs fit to a RooDataHist.
  • precision < 0: Deactivate.
    See also
    RooBinSamplingPdf
Options to control flow of fit procedure
Minimizer("<type>", "<algo>")

Choose minimization package and optionally the algorithm to use. Default is MINUIT/MIGRAD through the RooMinimizer interface, but others can be specified (through RooMinimizer interface).

Type Algorithm
Minuit migrad, simplex, minimize (=migrad+simplex), migradimproved (=migrad+improve)
Minuit2 migrad, simplex, minimize, scan
GSLMultiMin conjugatefr, conjugatepr, bfgs, bfgs2, steepestdescent
GSLSimAn -

InitialHesse(Bool_t flag) Flag controls if HESSE before MIGRAD as well, off by default
Optimize(Bool_t flag) Activate constant term optimization of test statistic during minimization (on by default)
Hesse(Bool_t flag) Flag controls if HESSE is run after MIGRAD, on by default
Minos(Bool_t flag) Flag controls if MINOS is run after HESSE, off by default
Minos(const RooArgSet& set) Only run MINOS on given subset of arguments
Save(Bool_t flag) Flag controls if RooFitResult object is produced and returned, off by default
Strategy(Int_t flag) Set Minuit strategy (0 to 2, default is 1)
EvalErrorWall(bool flag=true) When parameters are in disallowed regions (e.g. PDF is negative), return very high value to fitter to force it out of that region. This can, however, mean that the fitter gets lost in this region. If this happens, try switching it off.
RecoverFromUndefinedRegions(double strength) When PDF is invalid (e.g. parameter in undefined region), try to direct minimiser away from that region. strength controls the magnitude of the penalty term. Leaving out this argument defaults to 10. Switch off with strength = 0..
FitOptions(const char* optStr)
Deprecated:
Steer fit with classic options string (for backward compatibility).
Attention
Use of this option excludes use of any of the new style steering options.
SumW2Error(Bool_t flag) Apply correction to errors and covariance matrix. This uses two covariance matrices, one with the weights, the other with squared weights, to obtain the correct errors for weighted likelihood fits. If this option is activated, the corrected covariance matrix is calculated as \( V_\mathrm{corr} = V C^{-1} V \), where \( V \) is the original covariance matrix and \( C \) is the inverse of the covariance matrix calculated using the squared weights. This allows to switch between two interpretations of errors:
SumW2Error Interpretation
true

The errors reflect the uncertainty of the Monte Carlo simulation. Use this if you want to know how much accuracy you can get from the available Monte Carlo statistics.

Example: Simulation with 1000 events, the average weight is 0.1. The errors are as big as if one fitted to 1000 events.

false

The errors reflect the errors of a dataset, which is as big as the sum of weights. Use this if you want to know what statistical errors you would get if you had a dataset with as many events as the (weighted) Monte Carlo simulation represents.

Example (Data as above): The errors are as big as if one fitted to 100 events.

Note
If the SumW2Error correction is enabled, the covariance matrix quality stored in the RooFitResult object will be the minimum of the original covariance matrix quality and the quality of the covariance matrix calculated with the squared weights.
AsymptoticError() Use the asymptotically correct approach to estimate errors in the presence of weights. This is slower but more accurate than SumW2Error. See also https://arxiv.org/abs/1911.01303).
PrefitDataFraction(double fraction) Runs a prefit on a small dataset of size fraction*(actual data size). This can speed up fits by finding good starting values for the parameters for the actual fit.
Warning
Prefitting may give bad results when used in binned analysis.
Options to control informational output
Verbose(Bool_t flag) Flag controls if verbose output is printed (NLL, parameter changes during fit).
Timer(Bool_t flag) Time CPU and wall clock consumption of fit steps, off by default.
PrintLevel(Int_t level) Set Minuit print level (-1 to 3, default is 1). At -1 all RooFit informational messages are suppressed as well. See RooMinimizer::PrintLevel for the meaning of the levels.
Warnings(Bool_t flag) Enable or disable MINUIT warnings (enabled by default)
PrintEvalErrors(Int_t numErr) Control number of p.d.f evaluation errors printed per likelihood evaluation. A negative value suppresses output completely, a zero value will only print the error count per p.d.f component, a positive value will print details of each error up to numErr messages per p.d.f component.

PyROOT

The RooAbsPdf::fitTo() function is pythonized with the command argument pythonization. The keywords must correspond to the CmdArgs of the function.

Definition at line 158 of file RooAbsPdf.cxx.

◆ fitTo() [2/2]

RooFitResult * RooAbsPdf::fitTo ( RooAbsData data,
const RooLinkedList cmdList 
)

Fit PDF to given dataset.

If dataset is unbinned, an unbinned maximum likelihood is performed. If the dataset is binned, a binned maximum likelihood is performed. By default the fit is executed through the MINUIT commands MIGRAD, HESSE and MINOS in succession.

See RooAbsPdf::fitTo(RooAbsData&,RooCmdArg&,RooCmdArg&,RooCmdArg&,RooCmdArg&,RooCmdArg&,RooCmdArg&,RooCmdArg&,RooCmdArg&)

for documentation of options

Definition at line 161 of file RooAbsPdf.cxx.

◆ getFitterMultiGenFcn()

ROOT::Math::IMultiGenFunction * RooMinimizer::getFitterMultiGenFcn ( ) const

Definition at line 881 of file RooMinimizer.cxx.

◆ getMultiGenFcn()

ROOT::Math::IMultiGenFunction * RooMinimizer::getMultiGenFcn ( ) const

Definition at line 887 of file RooMinimizer.cxx.

◆ getNPar()

Int_t RooMinimizer::getNPar ( ) const
inline

Definition at line 119 of file RooMinimizer.h.

◆ getPrintLevel()

Int_t RooMinimizer::getPrintLevel ( ) const

Definition at line 1059 of file RooMinimizer.cxx.

◆ hesse()

Int_t RooMinimizer::hesse ( )

Execute HESSE.

Changes in parameter values and calculated errors are automatically propagated back the RooRealVars representing the floating parameters in the MINUIT operation.

Definition at line 431 of file RooMinimizer.cxx.

◆ improve()

Int_t RooMinimizer::improve ( )

Execute IMPROVE.

Changes in parameter values and calculated errors are automatically propagated back the RooRealVars representing the floating parameters in the MINUIT operation.

Definition at line 623 of file RooMinimizer.cxx.

◆ initMinimizerFcnDependentPart()

void RooMinimizer::initMinimizerFcnDependentPart ( double  defaultErrorLevel)
private

Initialize the part of the minimizer that is dependent on the function to be minimized.

Definition at line 162 of file RooMinimizer.cxx.

◆ initMinimizerFirstPart()

void RooMinimizer::initMinimizerFirstPart ( )
private

Initialize the part of the minimizer that is independent of the function to be minimized.

Definition at line 149 of file RooMinimizer.cxx.

◆ lastMinuitFit()

RooFitResult * RooMinimizer::lastMinuitFit ( const RooArgList varList = RooArgList())
static

Definition at line 953 of file RooMinimizer.cxx.

◆ logfile()

std::ofstream * RooMinimizer::logfile ( )
inlineprotected

Definition at line 129 of file RooMinimizer.h.

◆ maxFCN()

Double_t & RooMinimizer::maxFCN ( )
inlineprotected

Definition at line 130 of file RooMinimizer.h.

◆ migrad()

Int_t RooMinimizer::migrad ( )

Execute MIGRAD.

Changes in parameter values and calculated errors are automatically propagated back the RooRealVars representing the floating parameters in the MINUIT operation.

Definition at line 402 of file RooMinimizer.cxx.

◆ minimize()

Int_t RooMinimizer::minimize ( const char *  type,
const char *  alg = 0 
)

Minimise the function passed in the constructor.

Parameters
[in]typeType of fitter to use, e.g. "Minuit" "Minuit2".
Attention
This overrides the default fitter of this RooMinimizer.
Parameters
[in]algFit algorithm to use. (Optional)

Definition at line 370 of file RooMinimizer.cxx.

◆ minos() [1/2]

Int_t RooMinimizer::minos ( )

Execute MINOS.

Changes in parameter values and calculated errors are automatically propagated back the RooRealVars representing the floating parameters in the MINUIT operation.

Definition at line 468 of file RooMinimizer.cxx.

◆ minos() [2/2]

Int_t RooMinimizer::minos ( const RooArgSet minosParamList)

Execute MINOS for given list of parameters.

Changes in parameter values and calculated errors are automatically propagated back the RooRealVars representing the floating parameters in the MINUIT operation.

Definition at line 506 of file RooMinimizer.cxx.

◆ optimizeConst()

void RooMinimizer::optimizeConst ( Int_t  flag)

If flag is true, perform constant term optimization on function being minimized.

Definition at line 661 of file RooMinimizer.cxx.

◆ profileStart()

void RooMinimizer::profileStart ( )
protected

Start profiling timer.

Definition at line 857 of file RooMinimizer.cxx.

◆ profileStop()

void RooMinimizer::profileStop ( )
protected

Stop profiling timer and report results of last session.

Definition at line 870 of file RooMinimizer.cxx.

◆ save()

RooFitResult * RooMinimizer::save ( const char *  userName = 0,
const char *  userTitle = 0 
)

Save and return a RooFitResult snapshot of current minimizer status.

This snapshot contains the values of all constant parameters, the value of all floating parameters at RooMinimizer construction and after the last MINUIT operation, the MINUIT status, variance quality, EDM setting, number of calls with evaluation problems, the minimized function value and the full correlation matrix.

Definition at line 676 of file RooMinimizer.cxx.

◆ saveStatus()

void RooMinimizer::saveStatus ( const char *  label,
Int_t  status 
)
inline

Definition at line 108 of file RooMinimizer.h.

◆ seek()

Int_t RooMinimizer::seek ( )

Execute SEEK.

Changes in parameter values and calculated errors are automatically propagated back the RooRealVars representing the floating parameters in the MINUIT operation.

Definition at line 565 of file RooMinimizer.cxx.

◆ setEps()

void RooMinimizer::setEps ( Double_t  eps)

Change MINUIT epsilon.

Definition at line 258 of file RooMinimizer.cxx.

◆ setErrorLevel()

void RooMinimizer::setErrorLevel ( Double_t  level)

Set the level for MINUIT error analysis to the given value.

This function overrides the default value that is taken in the RooMinimizer constructor from the defaultErrorLevel() method of the input function

Definition at line 247 of file RooMinimizer.cxx.

◆ setEvalErrorWall()

void RooMinimizer::setEvalErrorWall ( Bool_t  flag)
inline

Definition at line 70 of file RooMinimizer.h.

◆ setLogFile()

Bool_t RooMinimizer::setLogFile ( const char *  logf = 0)
inline

Definition at line 99 of file RooMinimizer.h.

◆ setMaxFunctionCalls()

void RooMinimizer::setMaxFunctionCalls ( Int_t  n)

Change maximum number of likelihood function calss from MINUIT (RooMinimizer default 500 * #parameters)

Definition at line 233 of file RooMinimizer.cxx.

◆ setMaxIterations()

void RooMinimizer::setMaxIterations ( Int_t  n)

Change maximum number of MINUIT iterations (RooMinimizer default 500 * #parameters)

Definition at line 221 of file RooMinimizer.cxx.

◆ setMinimizerType()

void RooMinimizer::setMinimizerType ( const char *  type)

Choose the minimizer algorithm.

Definition at line 277 of file RooMinimizer.cxx.

◆ setOffsetting()

void RooMinimizer::setOffsetting ( Bool_t  flag)

Enable internal likelihood offsetting for enhanced numeric precision.

Definition at line 268 of file RooMinimizer.cxx.

◆ setPrintEvalErrors()

void RooMinimizer::setPrintEvalErrors ( Int_t  numEvalErrors)
inline

Definition at line 96 of file RooMinimizer.h.

◆ setPrintLevel()

Int_t RooMinimizer::setPrintLevel ( Int_t  newLevel)

Change the MINUIT internal printing level.

Definition at line 649 of file RooMinimizer.cxx.

◆ setProfile()

void RooMinimizer::setProfile ( Bool_t  flag = kTRUE)
inline

Definition at line 98 of file RooMinimizer.h.

◆ setRecoverFromNaNStrength()

void RooMinimizer::setRecoverFromNaNStrength ( double  strength)
inline

Try to recover from invalid function values.

When invalid function values are encountered, a penalty term is returned to the minimiser to make it back off. This sets the strength of this penalty.

Note
A strength of zero is equivalent to a constant penalty (= the gradient vanishes, ROOT < 6.24). Positive values lead to a gradient pointing away from the undefined regions. Use ~10 to force the minimiser away from invalid function values.

Definition at line 72 of file RooMinimizer.h.

◆ setStrategy()

void RooMinimizer::setStrategy ( Int_t  istrat)

Change MINUIT strategy to istrat.

Accepted codes are 0,1,2 and represent MINUIT strategies for dealing most efficiently with fast FCNs (0), expensive FCNs (2) and 'intermediate' FCNs (1)

Definition at line 209 of file RooMinimizer.cxx.

◆ setVerbose()

void RooMinimizer::setVerbose ( Bool_t  flag = kTRUE)
inline

Definition at line 97 of file RooMinimizer.h.

◆ simplex()

Int_t RooMinimizer::simplex ( )

Execute SIMPLEX.

Changes in parameter values and calculated errors are automatically propagated back the RooRealVars representing the floating parameters in the MINUIT operation.

Definition at line 594 of file RooMinimizer.cxx.

◆ zeroEvalCount()

void RooMinimizer::zeroEvalCount ( )
inline

Definition at line 111 of file RooMinimizer.h.

Friends And Related Symbol Documentation

◆ RooAbsPdf

friend class RooAbsPdf
friend

Definition at line 123 of file RooMinimizer.h.

Member Data Documentation

◆ _cumulTimer

TStopwatch RooMinimizer::_cumulTimer
private

Definition at line 148 of file RooMinimizer.h.

◆ _extV

TMatrixDSym* RooMinimizer::_extV = 0
private

Definition at line 151 of file RooMinimizer.h.

◆ _fcn

RooAbsMinimizerFcn* RooMinimizer::_fcn
private

Definition at line 153 of file RooMinimizer.h.

◆ _fcnMode

FcnMode RooMinimizer::_fcnMode
private

Definition at line 155 of file RooMinimizer.h.

◆ _minimizerType

std::string RooMinimizer::_minimizerType = "Minuit"
private

Definition at line 154 of file RooMinimizer.h.

◆ _printLevel

Int_t RooMinimizer::_printLevel = 1
private

Definition at line 142 of file RooMinimizer.h.

◆ _profile

Bool_t RooMinimizer::_profile = kFALSE
private

Definition at line 144 of file RooMinimizer.h.

◆ _profileStart

Bool_t RooMinimizer::_profileStart = kFALSE
private

Definition at line 149 of file RooMinimizer.h.

◆ _status

Int_t RooMinimizer::_status = -99
private

Definition at line 143 of file RooMinimizer.h.

◆ _statusHistory

std::vector<std::pair<std::string,int> > RooMinimizer::_statusHistory
private

Definition at line 159 of file RooMinimizer.h.

◆ _theFitter

ROOT::Fit::Fitter * RooMinimizer::_theFitter = 0
staticprivate

Definition at line 157 of file RooMinimizer.h.

◆ _timer

TStopwatch RooMinimizer::_timer
private

Definition at line 147 of file RooMinimizer.h.

◆ _verbose

Bool_t RooMinimizer::_verbose = kFALSE
private

Definition at line 146 of file RooMinimizer.h.

Libraries for RooMinimizer:

The documentation for this class was generated from the following files: