14#ifndef __ROOFIT_NOROOMINIMIZER
45 _funct(funct), _context(context),
47 _maxFCN(-1e30), _numBadNLL(0),
48 _printEvalErrors(10), _doEvalErrorWall(
kTRUE),
49 _nDim(0), _logfile(0),
79 <<
" from list because it is not of type RooRealVar" << endl;
98 _evalCounter(other._evalCounter),
100 _context(other._context),
101 _maxFCN(other._maxFCN),
102 _numBadNLL(other._numBadNLL),
103 _printEvalErrors(other._printEvalErrors),
104 _doEvalErrorWall(other._doEvalErrorWall),
106 _logfile(other._logfile),
107 _verbose(other._verbose),
108 _floatParamVec(other._floatParamVec)
151 if (!oldpar) continue ;
161 constStatChange=
kTRUE ;
166 << par->
GetName() <<
" is now floating." << endl ;
172 constValChange=
kTRUE ;
176 <<
" changed from " << oldpar->
getVal() <<
" to "
177 << par->
getVal() << endl ;
203 <<
" is not of type RooRealVar, skipping" << endl ;
221 pstep= 0.1*(pmax-pmin);
224 if (pmax - par->
getVal() < 2*pstep) {
225 pstep = (pmax - par->
getVal())/2 ;
226 }
else if (par->
getVal() - pmin < 2*pstep) {
227 pstep = (par->
getVal() - pmin )/2 ;
232 pstep= 0.1*(pmax-pmin);
240 << par->
GetName() <<
": using " << pstep << endl;
249 if (index>=
Int_t(parameters.size())) {
262 parameters.back().SetLowerLimit(pmin);
264 parameters.back().SetUpperLimit(pmax);
271 Bool_t oldFixed = parameters[index].IsFixed();
272 Double_t oldVar = parameters[index].Value();
273 Double_t oldVerr = parameters[index].StepSize();
274 Double_t oldVlo = parameters[index].LowerLimit();
275 Double_t oldVhi = parameters[index].UpperLimit();
280 if (oldVar!=par->
getVal()) {
281 parameters[index].SetValue(par->
getVal());
284 << par->
GetName() <<
" changed from " << oldVar
285 <<
" to " << par->
getVal() << endl ;
288 parameters[index].Fix();
289 constStatChange=
kTRUE ;
292 << par->
GetName() <<
" is now fixed." << endl ;
298 if (oldVar!=par->
getVal()) {
299 parameters[index].SetValue(par->
getVal());
300 constValChange=
kTRUE ;
304 << par->
GetName() <<
" changed from " << oldVar
305 <<
" to " << par->
getVal() << endl ;
312 parameters[index].Release();
313 constStatChange=
kTRUE ;
317 << par->
GetName() <<
" is now floating." << endl ;
322 if (oldVar!=par->
getVal() || oldVlo!=pmin || oldVhi != pmax || oldVerr!=pstep) {
323 parameters[index].SetValue(par->
getVal());
324 parameters[index].SetStepSize(pstep);
326 parameters[index].SetLimits(pmin,pmax);
328 parameters[index].SetLowerLimit(pmin);
330 parameters[index].SetUpperLimit(pmax);
337 if (oldVar!=par->
getVal()) {
339 << par->
GetName() <<
" changed from " << oldVar <<
" to "
340 << par->
getVal() << endl ;
342 if (oldVlo!=pmin || oldVhi!=pmax) {
344 << par->
GetName() <<
" changed from [" << oldVlo <<
"," << oldVhi
345 <<
"] to [" << pmin <<
"," << pmax <<
"]" << endl ;
349 if (oldVerr!=pstep && oldVerr!=0) {
351 << par->
GetName() <<
" changed from " << oldVerr <<
" to " << pstep << endl ;
358 if (constStatChange) {
362 oocoutI(
_context,
Minimization) <<
"RooMinimizerFcn::synchronize: set of constant parameters changed, rerunning const optimizer" << endl ;
364 }
else if (constValChange) {
365 oocoutI(
_context,
Minimization) <<
"RooMinimizerFcn::synchronize: constant parameter values changed, rerunning const optimizer" << endl ;
422 for (
Int_t index= 0; index <
_nDim; index++) {
433 if(
eplus > 0 || eminus < 0) {
456 _logfile =
new ofstream(inLogfile) ;
491 if (par->
getVal()!=value) {
512 while((arg=iter.
next())) {
523 for (
int index = 0; index <
_nDim; index++) {
524 if (
_logfile) (*_logfile) <<
x[index] <<
" " ;
539 <<
"Returning maximum FCN so far (" <<
_maxFCN
540 <<
") to force MIGRAD to back out of this region. Error log follows" << endl ;
573 (*_logfile) << setprecision(15) << fvalue << setprecision(4) << endl;
575 cout <<
"\nprevFCN" << (
_funct->
isOffsetting()?
"-offset":
"") <<
" = " << setprecision(10)
576 << fvalue << setprecision(4) <<
" " ;
class containg the result of the fit and all the related information (fitted parameter values,...
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 Value(unsigned int i) const
parameter value by index
double LowerError(unsigned int i) const
lower Minos error. If Minos has not run for parameter i return the parabolic error
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Interface function signaling a request to perform constant term optimization.
Bool_t isConstant() const
RooFIter fwdIterator() const R__SUGGEST_ALTERNATIVE("begin()
One-time forward iterator.
void sort(Bool_t reverse=false)
Sort collection using std::sort and name comparison.
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsCollection * selectByAttrib(const char *name, Bool_t value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
void setName(const char *name)
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
static Bool_t evalError()
Return the evaluation error flag.
static void clearEvalError()
Clear the evaluation error flag.
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Bool_t hasMax(const char *name=0) const
Check if variable has an upper bound.
Bool_t hasMin(const char *name=0) const
Check if variable has a lower bound.
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual Bool_t isOffsetting() const
static void setHideOffset(Bool_t flag)
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
RooArgList * _floatParamList
void SetPdfParamErr(Int_t index, Double_t value)
RooArgList * _initFloatParamList
virtual double DoEval(const double *x) const
Implementation of the evaluation function.
virtual ROOT::Math::IBaseFunctionMultiDim * Clone() const
Clone a function.
Bool_t SetLogFile(const char *inLogfile)
void ApplyCovarianceMatrix(TMatrixDSym &V)
Double_t GetPdfParamErr(Int_t index)
Double_t GetPdfParamVal(Int_t index)
Bool_t SetPdfParamVal(const Int_t &index, const Double_t &value) const
std::vector< RooAbsArg * > _floatParamVec
virtual ~RooMinimizerFcn()
RooArgList * _constParamList
Bool_t Synchronize(std::vector< ROOT::Fit::ParameterSettings > ¶meters, Bool_t optConst, Bool_t verbose)
void BackProp(const ROOT::Fit::FitResult &results)
RooMinimizerFcn(RooAbsReal *funct, RooMinimizer *context, bool verbose=false)
void ClearPdfParamAsymErr(Int_t index)
RooArgList * _initConstParamList
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
RooRealVar represents a fundamental (non-derived) real valued object.
Double_t getError() const
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Iterator abstract base class.
virtual TObject * Next()=0
virtual const char * GetName() const
Returns name of object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Namespace for new Math classes and functions.
IBaseFunctionMultiDimTempl< double > IBaseFunctionMultiDim
Namespace for new ROOT classes and functions.
static constexpr double eplus