65#if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
142 coutW(
Minimization) <<
"RooMinuit::RooMinuit: removing parameter " << arg->GetName()
143 <<
" from list because it is not of type RooRealVar" << endl ;
214 double stratArg(istrat) ;
416 double* arglist =
new double[
_nPar+1];
418 if (minosParamList.
getSize()>0) {
424 arglist[nMinosPar]=
index+1;
560 double arg(newLevel) ;
590 double arg(newLevel) ;
615 bool constValChange(
false) ;
616 bool constStatChange(
false) ;
626 if (!oldpar) continue ;
636 constStatChange=true ;
646 constValChange=true ;
649 <<
" changed from " << oldpar->
getVal() <<
" to " << par->
getVal() << endl ;
673 <<
" is not of type RooRealVar, skipping" << endl ;
688 pstep= 0.1*(pmax-pmin);
691 if (pmax - par->
getVal() < 2*pstep) {
692 pstep = (pmax - par->
getVal())/2 ;
693 }
else if (par->
getVal() - pmin < 2*pstep) {
694 pstep = (par->
getVal() - pmin )/2 ;
699 pstep= 0.1*(pmax-pmin);
706 coutW(
Minimization) <<
"RooMinuit::synchronize: WARNING: no initial error estimate available for "
707 << par->
GetName() <<
": using " << pstep << endl;
716 double oldVar,oldVerr,oldVlo,oldVhi ;
717 char oldParname[100] ;
723 bool oldFixed(
false) ;
733 if (oldVar!=par->
getVal()) {
735 arglist[0] =
index+1 ;
736 arglist[1] = par->
getVal() ;
739 coutI(
Minimization) <<
"RooMinuit::synchronize: value of parameter " << par->
GetName() <<
" changed from " << oldVar <<
" to " << par->
getVal() << endl ;
744 constStatChange=true ;
752 if (oldVar!=par->
getVal()) {
754 arglist[0] =
index+1 ;
755 arglist[1] = par->
getVal() ;
757 constValChange=true ;
760 coutI(
Minimization) <<
"RooMinuit::synchronize: value of fixed parameter " << par->
GetName() <<
" changed from " << oldVar <<
" to " << par->
getVal() << endl ;
768 constStatChange=true ;
776 if (oldVar!=par->
getVal() || oldVlo!=pmin || oldVhi != pmax || oldVerr!=pstep) {
784 if (oldVar!=par->
getVal()) {
785 coutI(
Minimization) <<
"RooMinuit::synchronize: value of parameter " << par->
GetName() <<
" changed from " << oldVar <<
" to " << par->
getVal() << endl ;
787 if (oldVlo!=pmin || oldVhi!=pmax) {
788 coutI(
Minimization) <<
"RooMinuit::synchronize: limits of parameter " << par->
GetName() <<
" changed from [" << oldVlo <<
"," << oldVhi
789 <<
"] to [" << pmin <<
"," << pmax <<
"]" << endl ;
793 if (oldVerr!=pstep && oldVerr!=0) {
794 coutI(
Minimization) <<
"RooMinuit::synchronize: error/step size of parameter " << par->
GetName() <<
" changed from " << oldVerr <<
" to " << pstep << endl ;
806 if (constStatChange) {
810 coutI(
Minimization) <<
"RooMinuit::synchronize: set of constant parameters changed, rerunning const optimizer" << endl ;
812 }
else if (constValChange) {
813 coutI(
Minimization) <<
"RooMinuit::synchronize: constant parameter values changed, rerunning const optimizer" << endl ;
895 saveFloatFinalList.
remove(*par) ;
896 saveConstList.
add(*par) ;
899 saveConstList.
sort() ;
904 double edm, errdef, minVal;
942 <<
") ERROR: " << var1.
GetName() <<
" is not a floating parameter of " <<
_func->
GetName() << endl ;
949 <<
") ERROR: " << var2.
GetName() <<
" is not a floating parameter of PDF " <<
_func->
GetName() << endl ;
964 n[0] = n1 ;
n[1] = n2 ;
n[2] = n3 ;
n[3] = n4 ;
n[4] = n5 ;
n[5] = n6 ;
967 for (
Int_t ic = 0 ; ic<6 ; ic++) {
974 coutE(
Minimization) <<
"RooMinuit::contour(" <<
GetName() <<
") ERROR: MINUIT did not return a contour graph for n=" <<
n[ic] << endl ;
977 graph->SetLineStyle(ic+1) ;
978 graph->SetLineWidth(2) ;
1006 coutI(
Minimization) <<
"RooMinuit::setLogFile: closing previous log file" << endl ;
1011 _logfile =
new ofstream(inLogfile) ;
1013 coutI(
Minimization) <<
"RooMinuit::setLogFile: cannot open file " << inLogfile << endl ;
1127 double val,err,vlo,vhi,
eplus, eminus, eparab, globcc;
1138 if(
eplus > 0 || eminus < 0) {
1179 cout <<
"setting parameter " << i <<
" error to " <<
sqrt((*
_extV)(i,i)) << endl ;
1189 double &
f,
double *par,
Int_t )
1195 ofstream* logf = context->
logfile() ;
1196 double& maxFCN = context->
maxFCN() ;
1202 if (logf) (*logf) << par[
index] <<
" " ;
1216 oocoutW(context,
Minimization) <<
"RooMinuitGlue: Minimized function has error status." << endl
1217 <<
"Returning maximum FCN so far (" << maxFCN
1218 <<
") to force MIGRAD to back out of this region. Error log follows" << endl ;
1220 oocoutW(context,
Minimization) <<
"RooMinuitGlue: Minimized function has error status but is ignored" << endl ;
1225 for(
auto * var : static_range_cast<RooRealVar*>(*context->
_floatParamList)) {
1241 }
else if (
f>maxFCN) {
1246 if (logf) (*logf) << setprecision(15) <<
f << setprecision(4) << endl;
1248 cout <<
"\nprevFCN" << (context->
_func->
isOffsetting()?
"-offset":
"") <<
" = " << setprecision(10) <<
f << setprecision(4) <<
" " ;
void RooMinuitGlue(Int_t &, double *, double &f, double *par, Int_t)
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 value
R__EXTERN TMinuit * gMinuit
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
bool isConstant() const
Check if the "Constant" attribute is set.
virtual void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true)
Interface function signaling a request to perform constant term optimization.
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
void sort(bool reverse=false)
Sort collection using std::sort and name comparison.
void setName(const char *name)
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
bool hasMax(const char *name=nullptr) const
Check if variable has an upper bound.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool hasMin(const char *name=nullptr) const
Check if variable has a lower bound.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual bool isOffsetting() const
virtual void enableOffsetting(bool)
static void setHideOffset(bool flag)
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
static void printEvalErrors(std::ostream &os=std::cout, Int_t maxPerNode=10000000)
Print all outstanding logged evaluation error on the given ostream.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
void fillCorrMatrix()
Internal utility method to extract the correlation matrix and the global correlation coefficients fro...
void setCovQual(Int_t val)
void setMinNLL(double val)
void setNumInvalidNLL(Int_t val)
void setStatus(Int_t val)
void setConstParList(const RooArgList &list)
Fill the list of constant parameters.
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
void setStatusHistory(std::vector< std::pair< std::string, int > > &hist)
void setInitParList(const RooArgList &list)
Fill the list of initial values of the floating parameters.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
RooMinuit is a wrapper class around TFitter/TMinuit that provides a seamless interface between the MI...
Int_t hesse()
Execute HESSE.
void setEps(double eps)
Change MINUIT epsilon.
RooMinuit(RooAbsReal &function)
Construct MINUIT interface to given function.
void setProfile(bool flag=true)
RooArgList * _floatParamList
void setOffsetting(bool flag)
Enable internal likelihood offsetting for enhanced numeric precision.
~RooMinuit() override
Destructor.
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
bool synchronize(bool verbose)
Internal function to synchronize TMinuit with current information in RooAbsReal function parameters.
virtual bool setPdfParamVal(Int_t index, double value, bool verbose=false)
Modify PDF parameter value by ordinal index (needed by MINUIT)
void setErrorLevel(double level)
Set the level for MINUIT error analysis to the given value.
static void cleanup()
Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects wh...
Int_t seek()
Execute SEEK.
Int_t simplex()
Execute SIMPLEX.
RooFitResult * save(const char *name=nullptr, const char *title=nullptr)
Save and return a RooFitResult snaphot of current minimizer status.
void saveStatus(const char *label, Int_t status)
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
std::vector< std::pair< std::string, int > > _statusHistory
std::vector< RooAbsArg * > _floatParamVec
Int_t migrad()
Execute MIGRAD.
std::ofstream * logfile() const
bool setLogFile(const char *logfile=nullptr)
Change the file name for logging of a RooMinuit of all MINUIT steppings through the parameter space.
double getPdfParamVal(Int_t index)
Access PDF parameter value by ordinal index (needed by MINUIT)
Int_t setWarnLevel(Int_t newLevel)
Set MINUIT warning level to given level.
void applyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
void backProp()
Transfer MINUIT fit results back into RooFit objects.
double getPdfParamErr(Int_t index)
Access PDF parameter error by ordinal index (needed by MINUIT)
RooArgList * _initConstParamList
friend void RooMinuitGlue(Int_t &np, double *gin, double &f, double *par, Int_t flag)
RooArgList * _initFloatParamList
void setPdfParamErr(Int_t index, double value)
Modify PDF parameter error by ordinal index (needed by MINUIT)
void profileStop()
Stop profiling timer and report results of last session.
Int_t minos()
Execute MINOS.
void clearPdfParamAsymErr(Int_t index)
Modify PDF parameter error by ordinal index (needed by MINUIT)
Int_t improve()
Execute IMPROVE.
void profileStart()
Start profiling timer.
void setNoWarn()
Instruct MINUIT to suppress warnings.
RooArgList * _constParamList
void setVerbose(bool flag=true)
RooPlot * contour(RooRealVar &var1, RooRealVar &var2, double n1=1, double n2=2, double n3=0.0, double n4=0.0, double n5=0.0, double n6=0.0)
Create and draw a TH2 with the error contours in parameters var1 and v2 at up to 6 'sigma' settings w...
RooFitResult * fit(const char *options)
Parse traditional RooAbsPdf::fitTo driver options.
static TVirtualFitter * _theFitter
static RooMsgService & instance()
Return reference to singleton instance.
A RooPlot is a plot frame and a container for graphics objects within that frame.
void addObject(TObject *obj, Option_t *drawOptions="", bool invisible=false)
Add a generic object to this plot.
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
TClass * IsA() const override
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
<div class="legacybox"><h2>Legacy Code</h2> TFitter is a legacy interface: it is not recommended to u...
A TGraph is an object made of two arrays X and Y with npoints each.
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 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.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual const char * GetName() const
Returns name of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
void ToLower()
Change string to lower-case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Abstract Base Class for Fitting.
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const =0
virtual void SetObjectFit(TObject *obj)
virtual void ReleaseParameter(Int_t ipar)=0
void Clear(Option_t *option="") override=0
Set name and title to empty strings ("").
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...
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)=0
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)=0
virtual Double_t GetParameter(Int_t ipar) const =0
virtual void FixParameter(Int_t ipar)=0
virtual Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const =0
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
static constexpr double eplus