We demonstrate improved recovery from disallowed parameters. For this, we use a polynomial PDF of the form  
\[
  \mathrm{Pol2} = \mathcal{N} \left( c + a_1 \cdot x + a_2 \cdot x^2 + 0.01 \cdot x^3 \right),
\]
 where \( \mathcal{N} \) is a normalisation factor. Unless the parameters are chosen carefully, this function can be negative, and hence, it cannot be used as a PDF. In this case, RooFit passes an error to the minimiser, which might try to recover.
 
 
 
 
  
  
  
 
  
  std::unique_ptr<RooDataSet> 
data(pdf.generate(
x, 10000));
 
 
  
  
  
 
  
  
 
 
  
  
  
  
 
  
 
  
 
 
 
 
  
  
  
  
  std::cout << "\n\n\n-------------- Starting second fit ---------------\n\n" << std::endl;
 
  
 
  
                                               
 
 
 
 
  
  
  
  
  std::cout << 
"Without recovery, the fitter encountered " << 
fitWithoutRecovery->numInvalidNLL()
 
      << " invalid function values. The parameters are unchanged." << std::endl;
 
  std::cout << 
"With recovery, the fitter encountered " << 
fitWithRecovery->numInvalidNLL()
 
      << " invalid function values, but the parameters are fitted." << std::endl;
 
  legend->AddEntry(
"data", 
"Data", 
"P");
 
  legend->AddEntry(
"noRecovery", 
"Without recovery (cannot be plotted)", 
"L");
 
  legend->AddEntry(
"recovery", 
"With recovery", 
"L");
 
}
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
 
RooArgSet is a container object that can hold multiple RooAbsArg objects.
 
static RooMsgService & instance()
Return reference to singleton instance.
 
Plot frame and a container for graphics objects within that frame.
 
static RooPlot * frame(const RooAbsRealLValue &var, double xmin, double xmax, Int_t nBins)
Create a new frame for a given variable in x.
 
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
 
RooPolynomial implements a polynomial p.d.f of the form.
 
Variable that can be changed from the outside.
 
This class displays a legend box (TPaveText) containing several legend entries.
 
RooCmdArg Save(bool flag=true)
 
RooCmdArg PrintEvalErrors(Int_t numErrors)
 
RooCmdArg PrintLevel(Int_t code)
 
RooCmdArg RecoverFromUndefinedRegions(double strength)
When parameters are chosen such that a PDF is undefined, try to indicate to the minimiser how to leav...
 
RooCmdArg LineColor(Color_t color)
 
RooCmdArg Name(const char *name)
 
   
[#1] INFO:Fitting -- RooAbsPdf::fitTo(pol3_over_pol3_Int[x]) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- using CPU computation library compiled with -mavx512
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_pol3_over_pol3_Int[x]_pol3Data) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
[#0] ERROR:Minimization -- RooMinimizer: all function calls during minimization gave invalid NLL values!
[#0] ERROR:Minimization -- RooMinimizer: all function calls during minimization gave invalid NLL values!
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
[#0] ERROR:Eval -- RooAbsReal::logEvalError(pol3) evaluation error, 
 origin       : RooPolynomial::pol3[ x=x coefList=(a1,a2,a3) ]
 message      : p.d.f normalization integral is zero or negative: -2220.000000
 server values: x=x=0, coefList=(a1 = 10 +/- 0,a2 = -1 +/- 0,a3 = 0.01)
 
 
 
-------------- Starting second fit ---------------
 
 
[#1] INFO:Fitting -- RooAbsPdf::fitTo(pol3_over_pol3_Int[x]) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting -- RooAddition::defaultErrorLevel(nll_pol3_over_pol3_Int[x]_pol3Data) Summation contains a RooNLLVar, using its error level
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: activating const optimization
Minuit2Minimizer: Minimize with max-calls 1000 convergence for edm < 1 strategy 1
Minuit2Minimizer : Valid minimum - status = 0
FVAL  = -1002.22625939860154
Edm   = 1.70291335762746681e-07
Nfcn  = 245
a1   = -0.49816    +/-  0.0227243   (limited)
a2   = 0.198318    +/-  0.00564929  (limited)
[#1] INFO:Minimization -- RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization
 
  RooFitResult: minimized FCN value: 0, estimated distance to minimum: 0
                covariance matrix quality: Not calculated at all
                Status : MINIMIZE=-1 HESSE=302 
 
    Floating Parameter    FinalValue +/-  Error   
  --------------------  --------------------------
                    a1    1.0000e+01 +/-  0.00e+00
                    a2   -1.0000e+00 +/-  0.00e+00
 
Without recovery, the fitter encountered 23 invalid function values. The parameters are unchanged.
 
  RooFitResult: minimized FCN value: 29650.9, estimated distance to minimum: 1.70451e-07
                covariance matrix quality: Full, accurate covariance matrix
                Status : MINIMIZE=0 HESSE=0 
 
    Floating Parameter    FinalValue +/-  Error   
  --------------------  --------------------------
                    a1   -4.9816e-01 +/-  2.27e-02
                    a2    1.9832e-01 +/-  5.65e-03
 
With recovery, the fitter encountered 76 invalid function values, but the parameters are fitted.