Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMinimizer.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * AL, Alfio Lazzaro, INFN Milan, alfio.lazzaro@mi.infn.it *
9 * PB, Patrick Bos, NL eScience Center, p.bos@esciencecenter.nl *
10 * *
11 * Redistribution and use in source and binary forms, *
12 * with or without modification, are permitted according to the terms *
13 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
14 *****************************************************************************/
15
16/**
17\file RooMinimizer.cxx
18\class RooMinimizer
19\ingroup Roofitcore
20
21Wrapper class around ROOT::Math::Minimizer that
22provides a seamless interface between the minimizer functionality
23and the native RooFit interface.
24By default the Minimizer is Minuit 2.
25RooMinimizer can minimize any RooAbsReal function with respect to
26its parameters. Usual choices for minimization are the object returned by
27RooAbsPdf::createNLL() or RooAbsReal::createChi2().
28RooMinimizer has methods corresponding to MINUIT functions like
29hesse(), migrad(), minos() etc. In each of these function calls
30the state of the MINUIT engine is synchronized with the state
31of the RooFit variables: any change in variables, change
32in the constant status etc is forwarded to MINUIT prior to
33execution of the MINUIT call. Afterwards the RooFit objects
34are resynchronized with the output state of MINUIT: changes
35parameter values, errors are propagated.
36Various methods are available to control verbosity, profiling,
37automatic PDF optimization.
38**/
39
40#include "RooMinimizer.h"
41
42#include "RooAbsMinimizerFcn.h"
43#include "RooArgSet.h"
44#include "RooArgList.h"
45#include "RooAbsReal.h"
46#include "RooDataSet.h"
47#include "RooRealVar.h"
48#include "RooSentinel.h"
49#include "RooMsgService.h"
50#include "RooPlot.h"
51#include "RooHelpers.h"
52#include "RooMinimizerFcn.h"
53#include "RooFitResult.h"
57#ifdef ROOFIT_MULTIPROCESS
60#endif
61
62#include <Fit/BasicFCN.h>
63#include <Math/Minimizer.h>
64#include <TClass.h>
65#include <TGraph.h>
66#include <TMarker.h>
67
68#include <fstream>
69#include <iostream>
70#include <stdexcept> // logic_error
71
72namespace {
73
74class FreezeDisconnectedParametersRAII {
75public:
76 FreezeDisconnectedParametersRAII(RooMinimizer const *minimizer, RooAbsMinimizerFcn const &fcn)
77 : _minimizer{minimizer}, _frozen{fcn.freezeDisconnectedParameters()}
78 {
79 if (!_frozen.empty()) {
80 oocoutI(_minimizer, Minimization) << "Freezing disconnected parameters: " << _frozen << std::endl;
81 }
82 }
84 {
85 if (!_frozen.empty()) {
86 oocoutI(_minimizer, Minimization) << "Unfreezing disconnected parameters: " << _frozen << std::endl;
87 }
88 RooHelpers::setAllConstant(_frozen, false);
89 }
90
91private:
92 RooMinimizer const *_minimizer = nullptr;
93 RooArgSet _frozen;
94};
95
96} // namespace
97
98////////////////////////////////////////////////////////////////////////////////
99/// Construct MINUIT interface to given function. Function can be anything,
100/// but is typically a -log(likelihood) implemented by RooNLLVar or a chi^2
101/// (implemented by RooChi2Var). Other frequent use cases are a RooAddition
102/// of a RooNLLVar plus a penalty or constraint term. This class propagates
103/// all RooFit information (floating parameters, their values and errors)
104/// to MINUIT before each MINUIT call and propagates all MINUIT information
105/// back to the RooFit object at the end of each call (updated parameter
106/// values, their (asymmetric errors) etc. The default MINUIT error level
107/// for HESSE and MINOS error analysis is taken from the defaultErrorLevel()
108/// value of the input function.
109
110/// Constructor that accepts all configuration in struct with RooAbsReal likelihood
111RooMinimizer::RooMinimizer(RooAbsReal &function, Config const &cfg) : _cfg(cfg)
112{
114 auto nll_real = dynamic_cast<RooFit::TestStatistics::RooRealL *>(&function);
115 if (nll_real != nullptr) {
116 if (_cfg.parallelize != 0) { // new test statistic with multiprocessing library with
117 // parallel likelihood or parallel gradient
118#ifdef ROOFIT_MULTIPROCESS
120 // Note that this is necessary because there is currently no serial-mode LikelihoodGradientWrapper.
121 // We intend to repurpose RooGradMinimizerFcn to build such a LikelihoodGradientSerial class.
122 coutI(InputArguments) << "Modular likelihood detected and likelihood parallelization requested, "
123 << "also setting parallel gradient calculation mode." << std::endl;
125 }
126 // If _cfg.parallelize is larger than zero set the number of workers to that value. Otherwise do not do
127 // anything and let RooFit::MultiProcess handle the number of workers
128 if (_cfg.parallelize > 0)
131
132 _fcn = std::make_unique<RooFit::TestStatistics::MinuitFcnGrad>(
133 nll_real->getRooAbsL(), this, _config.ParamsSettings(),
135 static_cast<RooFit::TestStatistics::LikelihoodMode>(int(_cfg.enableParallelDescent))},
137#else
138 throw std::logic_error(
139 "Parallel minimization requested, but ROOT was not compiled with multiprocessing enabled, "
140 "please recompile with -Droofit_multiprocess=ON for parallel evaluation");
141#endif
142 } else { // modular test statistic non parallel
143 coutW(InputArguments)
144 << "Requested modular likelihood without gradient parallelization, some features such as offsetting "
145 << "may not work yet. Non-modular likelihoods are more reliable without parallelization." << std::endl;
146 // The RooRealL that is used in the case where the modular likelihood is being passed to a RooMinimizerFcn does
147 // not have offsetting implemented. Therefore, offsetting will not work in this case. Other features might also
148 // not work since the RooRealL was not intended for minimization. Further development is required to make the
149 // MinuitFcnGrad also handle serial gradient minimization. The MinuitFcnGrad accepts a RooAbsL and has
150 // offsetting implemented, thus omitting the need for RooRealL minimization altogether.
151 _fcn = std::make_unique<RooMinimizerFcn>(&function, this);
152 }
153 } else {
154 if (_cfg.parallelize != 0) { // Old test statistic with parallel likelihood or gradient
155 throw std::logic_error("In RooMinimizer constructor: Selected likelihood evaluation but a "
156 "non-modular likelihood was given. Please supply ModularL(true) as an "
157 "argument to createNLL for modular likelihoods to use likelihood "
158 "or gradient parallelization.");
159 }
160 _fcn = std::make_unique<RooMinimizerFcn>(&function, this);
161 }
162 initMinimizerFcnDependentPart(function.defaultErrorLevel());
163};
164
165/// Initialize the part of the minimizer that is independent of the function to be minimized
167{
168 RooSentinel::activate();
170
172 setEps(1.0); // default tolerance
173}
174
175/// Initialize the part of the minimizer that is dependent on the function to be minimized
177{
178 // default max number of calls
179 _config.MinimizerOptions().SetMaxIterations(500 * _fcn->getNDim());
181
182 // Shut up for now
183 setPrintLevel(-1);
184
185 // Use +0.5 for 1-sigma errors
186 setErrorLevel(defaultErrorLevel);
187
188 // Declare our parameters to MINUIT
189 _fcn->Synchronize(_config.ParamsSettings());
190
191 // Now set default verbosity
192 setPrintLevel(RooMsgService::instance().silentMode() ? -1 : 1);
193
194 // Set user defined and default _fcn config
196
197 // Likelihood holds information on offsetting in old style, so do not set here unless explicitly set by user
198 if (_cfg.offsetting != -1) {
200 }
201}
202
203////////////////////////////////////////////////////////////////////////////////
204/// Destructor
205
207
208////////////////////////////////////////////////////////////////////////////////
209/// Change MINUIT strategy to istrat. Accepted codes
210/// are 0,1,2 and represent MINUIT strategies for dealing
211/// most efficiently with fast FCNs (0), expensive FCNs (2)
212/// and 'intermediate' FCNs (1)
213
218
219////////////////////////////////////////////////////////////////////////////////
220/// Change maximum number of MINUIT iterations
221/// (RooMinimizer default 500 * #%parameters)
222
227
228////////////////////////////////////////////////////////////////////////////////
229/// Change maximum number of likelihood function class from MINUIT
230/// (RooMinimizer default 500 * #%parameters)
231
236
237////////////////////////////////////////////////////////////////////////////////
238/// Set the level for MINUIT error analysis to the given
239/// value. This function overrides the default value
240/// that is taken in the RooMinimizer constructor from
241/// the defaultErrorLevel() method of the input function
242
244{
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Change MINUIT epsilon
250
251void RooMinimizer::setEps(double eps)
252{
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Enable internal likelihood offsetting for enhanced numeric precision
258
260{
262 _fcn->setOffsetting(_cfg.offsetting);
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Choose the minimizer algorithm.
267///
268/// Passing an empty string selects the default minimizer type returned by
269/// ROOT::Math::MinimizerOptions::DefaultMinimizerType().
270
271void RooMinimizer::setMinimizerType(std::string const &type)
272{
274
275 if ((_cfg.parallelize != 0) && _cfg.minimizerType != "Minuit2") {
276 std::stringstream ss;
277 ss << "In RooMinimizer::setMinimizerType: only Minuit2 is supported when not using classic function mode!";
278 if (type.empty()) {
279 ss << "\nPlease set it as your default minimizer via "
280 "ROOT::Math::MinimizerOptions::SetDefaultMinimizer(\"Minuit2\").";
281 }
282 throw std::invalid_argument(ss.str());
283 }
284}
285
287{
288 // Minuit-given status:
289 _status = fitterReturnValue ? _result->fStatus : -1;
290
291 // RooFit-based additional failed state information:
292 if (evalCounter() <= _fcn->GetNumInvalidNLL()) {
293 coutE(Minimization) << "RooMinimizer: all function calls during minimization gave invalid NLL values!"
294 << std::endl;
295 }
296}
297
298////////////////////////////////////////////////////////////////////////////////
299/// Minimise the function passed in the constructor.
300/// \param[in] type Type of fitter to use, e.g. "Minuit" "Minuit2". Passing an
301/// empty string will select the default minimizer type of the
302/// RooMinimizer, as returned by
303/// ROOT::Math::MinimizerOptions::DefaultMinimizerType().
304/// \attention This overrides the default fitter of this RooMinimizer.
305/// \param[in] alg Fit algorithm to use. (Optional)
306int RooMinimizer::minimize(const char *type, const char *alg)
307{
308 FreezeDisconnectedParametersRAII freeze(this, *_fcn);
309
310 if (_cfg.timingAnalysis) {
311#ifdef ROOFIT_MULTIPROCESS
313#else
314 throw std::logic_error("ProcessTimer, but ROOT was not compiled with multiprocessing enabled, "
315 "please recompile with -Droofit_multiprocess=ON for logging with the "
316 "ProcessTimer.");
317#endif
318 }
319 _fcn->Synchronize(_config.ParamsSettings());
320
323
324 profileStart();
325 {
326 auto ctx = makeEvalErrorContext();
327
328 bool ret = fitFCN(*_fcn->getMultiGenFcn());
330 }
331 profileStop();
332 _fcn->BackProp();
333
334 saveStatus("MINIMIZE", _status);
335
336 return _status;
337}
338
339////////////////////////////////////////////////////////////////////////////////
340/// Execute MIGRAD. Changes in parameter values
341/// and calculated errors are automatically
342/// propagated back the RooRealVars representing
343/// the floating parameters in the MINUIT operation.
344
346{
347 return exec("migrad", "MIGRAD");
348}
349
350int RooMinimizer::exec(std::string const &algoName, std::string const &statusName)
351{
352 FreezeDisconnectedParametersRAII freeze(this, *_fcn);
353
354 _fcn->Synchronize(_config.ParamsSettings());
355 profileStart();
356 {
357 auto ctx = makeEvalErrorContext();
358
359 bool ret = false;
360 if (algoName == "hesse") {
361 // HESSE has a special entry point in the ROOT::Math::Fitter
364 } else if (algoName == "minos") {
365 // MINOS has a special entry point in the ROOT::Math::Fitter
368 } else {
370 ret = fitFCN(*_fcn->getMultiGenFcn());
371 }
373 }
374 profileStop();
375 _fcn->BackProp();
376
377 saveStatus(statusName.c_str(), _status);
378
379 return _status;
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// Execute HESSE. Changes in parameter values
384/// and calculated errors are automatically
385/// propagated back the RooRealVars representing
386/// the floating parameters in the MINUIT operation.
387
389{
390 if (_minimizer == nullptr) {
391 coutW(Minimization) << "RooMinimizer::hesse: Error, run Migrad before Hesse!" << std::endl;
392 _status = -1;
393 return _status;
394 }
395
396 return exec("hesse", "HESSE");
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Execute MINOS. Changes in parameter values
401/// and calculated errors are automatically
402/// propagated back the RooRealVars representing
403/// the floating parameters in the MINUIT operation.
404
406{
407 if (_minimizer == nullptr) {
408 coutW(Minimization) << "RooMinimizer::minos: Error, run Migrad before Minos!" << std::endl;
409 _status = -1;
410 return _status;
411 }
412
413 return exec("minos", "MINOS");
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Execute MINOS for given list of parameters. Changes in parameter values
418/// and calculated errors are automatically
419/// propagated back the RooRealVars representing
420/// the floating parameters in the MINUIT operation.
421
423{
424 if (_minimizer == nullptr) {
425 coutW(Minimization) << "RooMinimizer::minos: Error, run Migrad before Minos!" << std::endl;
426 _status = -1;
427 } else if (!minosParamList.empty()) {
428 FreezeDisconnectedParametersRAII freeze(this, *_fcn);
429
430 _fcn->Synchronize(_config.ParamsSettings());
431 profileStart();
432 {
433 auto ctx = makeEvalErrorContext();
434
435 // get list of parameters for Minos
436 std::vector<unsigned int> paramInd;
437 RooArgList floatParams = _fcn->floatParams();
438 for (RooAbsArg *arg : minosParamList) {
439 RooAbsArg *par = floatParams.find(arg->GetName());
440 if (par && !par->isConstant()) {
441 int index = floatParams.index(par);
442 paramInd.push_back(index);
443 }
444 }
445
446 if (!paramInd.empty()) {
447 // set the parameter indices
449
451 bool ret = calculateMinosErrors();
453 // to avoid that following minimization computes automatically the Minos errors
454 _config.SetMinosErrors(false);
455 }
456 }
457 profileStop();
458 _fcn->BackProp();
459
460 saveStatus("MINOS", _status);
461 }
462
463 return _status;
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Execute SEEK. Changes in parameter values
468/// and calculated errors are automatically
469/// propagated back the RooRealVars representing
470/// the floating parameters in the MINUIT operation.
471
473{
474 return exec("seek", "SEEK");
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Execute SIMPLEX. Changes in parameter values
479/// and calculated errors are automatically
480/// propagated back the RooRealVars representing
481/// the floating parameters in the MINUIT operation.
482
484{
485 return exec("simplex", "SIMPLEX");
486}
487
488////////////////////////////////////////////////////////////////////////////////
489/// Execute IMPROVE. Changes in parameter values
490/// and calculated errors are automatically
491/// propagated back the RooRealVars representing
492/// the floating parameters in the MINUIT operation.
493
495{
496 return exec("migradimproved", "IMPROVE");
497}
498
499////////////////////////////////////////////////////////////////////////////////
500/// Change the MINUIT internal printing level
501
506
507////////////////////////////////////////////////////////////////////////////////
508/// Get the MINUIT internal printing level
509
514
515////////////////////////////////////////////////////////////////////////////////
516/// If flag is true, perform constant term optimization on
517/// function being minimized.
518
520{
521 _fcn->setOptimizeConst(flag);
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Save and return a RooFitResult snapshot of current minimizer status.
526/// This snapshot contains the values of all constant parameters,
527/// the value of all floating parameters at RooMinimizer construction and
528/// after the last MINUIT operation, the MINUIT status, variance quality,
529/// EDM setting, number of calls with evaluation problems, the minimized
530/// function value and the full correlation matrix.
531
533{
534 if (_minimizer == nullptr) {
535 coutW(Minimization) << "RooMinimizer::save: Error, run minimization before!" << std::endl;
536 return nullptr;
537 }
538
539 std::string name = userName ? std::string{userName} : _fcn->getFunctionName();
540 std::string title = userTitle ? std::string{userTitle} : _fcn->getFunctionTitle();
541 auto fitRes = std::make_unique<RooFitResult>(name.c_str(), title.c_str());
542
543 fitRes->setConstParList(_fcn->constParams());
544
545 fitRes->setNumInvalidNLL(_fcn->GetNumInvalidNLL());
546
547 fitRes->setStatus(_status);
548 fitRes->setCovQual(_minimizer->CovMatrixStatus());
549 fitRes->setMinNLL(_result->fVal - _fcn->getOffset());
550 fitRes->setEDM(_result->fEdm);
551
552 fitRes->setInitParList(_fcn->initFloatParams());
553 fitRes->setFinalParList(_fcn->floatParams());
554
555 if (!_extV) {
557 } else {
558 fitRes->setCovarianceMatrix(*_extV);
559 }
560
561 fitRes->setStatusHistory(_statusHistory);
562
563 return RooFit::makeOwningPtr(std::move(fitRes));
564}
565
566namespace {
567
568/// retrieve covariance matrix element
569double covMatrix(std::vector<double> const &covMat, unsigned int i, unsigned int j)
570{
571 if (covMat.empty())
572 return 0; // no matrix is available in case of non-valid fits
573 return j < i ? covMat[j + i * (i + 1) / 2] : covMat[i + j * (j + 1) / 2];
574}
575
576/// retrieve correlation elements
577double correlation(std::vector<double> const &covMat, unsigned int i, unsigned int j)
578{
579 if (covMat.empty())
580 return 0; // no matrix is available in case of non-valid fits
581 double tmp = covMatrix(covMat, i, i) * covMatrix(covMat, j, j);
582 return tmp > 0 ? covMatrix(covMat, i, j) / std::sqrt(tmp) : 0;
583}
584
585} // namespace
586
588{
589 const std::size_t nParams = _fcn->getNDim();
590 std::vector<double> globalCC;
593 for (std::size_t ic = 0; ic < nParams; ic++) {
594 globalCC.push_back(_result->fGlobalCC[ic]);
595 for (std::size_t ii = 0; ii < nParams; ii++) {
596 corrs(ic, ii) = correlation(_result->fCovMatrix, ic, ii);
597 covs(ic, ii) = covMatrix(_result->fCovMatrix, ic, ii);
598 }
599 }
600 fitRes.fillCorrMatrix(globalCC, corrs, covs);
601}
602
603////////////////////////////////////////////////////////////////////////////////
604/// Create and draw a TH2 with the error contours in the parameters `var1` and `var2`.
605/// \param[in] var1 The first parameter (x axis).
606/// \param[in] var2 The second parameter (y axis).
607/// \param[in] n1 First contour.
608/// \param[in] n2 Optional contour. 0 means don't draw.
609/// \param[in] n3 Optional contour. 0 means don't draw.
610/// \param[in] n4 Optional contour. 0 means don't draw.
611/// \param[in] n5 Optional contour. 0 means don't draw.
612/// \param[in] n6 Optional contour. 0 means don't draw.
613/// \param[in] npoints Number of points for evaluating the contour.
614///
615/// Up to six contours can be drawn using the arguments `n1` to `n6` to request the desired
616/// coverage in units of \f$ \sigma = n^2 \cdot \mathrm{ErrorDef} \f$.
617/// See ROOT::Math::Minimizer::ErrorDef().
618
619RooPlot *RooMinimizer::contour(RooRealVar &var1, RooRealVar &var2, double n1, double n2, double n3, double n4,
620 double n5, double n6, unsigned int npoints)
621{
622 RooArgList params = _fcn->floatParams();
624 params.snapshot(paramSave);
625
626 // Verify that both variables are floating parameters of PDF
627 int index1 = params.index(&var1);
628 if (index1 < 0) {
629 coutE(Minimization) << "RooMinimizer::contour(" << GetName() << ") ERROR: " << var1.GetName()
630 << " is not a floating parameter of " << _fcn->getFunctionName() << std::endl;
631 return nullptr;
632 }
633
634 int index2 = params.index(&var2);
635 if (index2 < 0) {
636 coutE(Minimization) << "RooMinimizer::contour(" << GetName() << ") ERROR: " << var2.GetName()
637 << " is not a floating parameter of PDF " << _fcn->getFunctionName() << std::endl;
638 return nullptr;
639 }
640
641 // create and draw a frame
642 RooPlot *frame = new RooPlot(var1, var2);
643
644 // draw a point at the current parameter values
645 TMarker *point = new TMarker(var1.getVal(), var2.getVal(), 8);
646 frame->addObject(point);
647
648 // check first if a inimizer is available. If not means
649 // the minimization is not done , so do it
650 if (_minimizer == nullptr) {
651 coutW(Minimization) << "RooMinimizer::contour: Error, run Migrad before contours!" << std::endl;
652 return frame;
653 }
654
655 // remember our original value of ERRDEF
656 double errdef = _minimizer->ErrorDef();
657
658 double n[6];
659 n[0] = n1;
660 n[1] = n2;
661 n[2] = n3;
662 n[3] = n4;
663 n[4] = n5;
664 n[5] = n6;
665
666 for (int ic = 0; ic < 6; ic++) {
667 if (n[ic] > 0) {
668
669 // set the value corresponding to an n1-sigma contour
670 _minimizer->SetErrorDef(n[ic] * n[ic] * errdef);
671
672 // calculate and draw the contour
673 std::vector<double> xcoor(npoints + 1);
674 std::vector<double> ycoor(npoints + 1);
675 bool ret = _minimizer->Contour(index1, index2, npoints, xcoor.data(), ycoor.data());
676
677 if (!ret) {
678 coutE(Minimization) << "RooMinimizer::contour(" << GetName()
679 << ") ERROR: MINUIT did not return a contour graph for n=" << n[ic] << std::endl;
680 } else {
681 xcoor[npoints] = xcoor[0];
682 ycoor[npoints] = ycoor[0];
683 TGraph *graph = new TGraph(npoints + 1, xcoor.data(), ycoor.data());
684
685 std::stringstream name;
686 name << "contour_" << _fcn->getFunctionName() << "_n" << n[ic];
687 graph->SetName(name.str().c_str());
688 graph->SetLineStyle(ic + 1);
689 graph->SetLineWidth(2);
690 graph->SetLineColor(kBlue);
691 frame->addObject(graph, "L");
692 }
693 }
694 }
695
696 // restore the original ERRDEF
697 _minimizer->SetErrorDef(errdef);
698
699 // restore parameter values
700 params.assign(paramSave);
701
702 return frame;
703}
704
705////////////////////////////////////////////////////////////////////////////////
706/// Add parameters in metadata field to process timer
707
709{
710#ifdef ROOFIT_MULTIPROCESS
711 // parameter indices for use in timing heat matrix
712 std::vector<std::string> parameter_names;
713 for (RooAbsArg *parameter : _fcn->floatParams()) {
714 parameter_names.push_back(parameter->GetName());
715 if (_cfg.verbose) {
716 coutI(Minimization) << "parameter name: " << parameter_names.back() << std::endl;
717 }
718 }
720#else
721 coutI(Minimization) << "Not adding parameters to processtimer because multiprocessing is not enabled." << std::endl;
722#endif
723}
724
725////////////////////////////////////////////////////////////////////////////////
726/// Start profiling timer
727
729{
730 if (_cfg.profile) {
731 _timer.Start();
732 _cumulTimer.Start(_profileStart ? false : true);
733 _profileStart = true;
734 }
735}
736
737////////////////////////////////////////////////////////////////////////////////
738/// Stop profiling timer and report results of last session
739
741{
742 if (_cfg.profile) {
743 _timer.Stop();
745 coutI(Minimization) << "Command timer: ";
746 _timer.Print();
747 coutI(Minimization) << "Session timer: ";
749 }
750}
751
753{
754 return _fcn->getMultiGenFcn();
755}
756
757////////////////////////////////////////////////////////////////////////////////
758/// Apply results of given external covariance matrix. i.e. propagate its errors
759/// to all RRV parameter representations and give this matrix instead of the
760/// HESSE matrix at the next save() call
761
763{
764 _extV.reset(static_cast<TMatrixDSym *>(V.Clone()));
765 _fcn->ApplyCovarianceMatrix(*_extV);
766}
767
769{
770 // Import the results of the last fit performed, interpreting
771 // the fit parameters as the given varList of parameters.
772
773 if (_minimizer == nullptr) {
774 oocoutE(nullptr, InputArguments) << "RooMinimizer::save: Error, run minimization before!" << std::endl;
775 return nullptr;
776 }
777
778 auto res = std::make_unique<RooFitResult>("lastMinuitFit", "Last MINUIT fit");
779
780 // Extract names of fit parameters
781 // and construct corresponding RooRealVars
782 RooArgList constPars("constPars");
783 RooArgList floatPars("floatPars");
784
785 const RooArgList floatParsFromFcn = _fcn->floatParams();
786
787 for (unsigned int i = 0; i < _fcn->getNDim(); ++i) {
788
789 TString varName(floatParsFromFcn.at(i)->GetName());
790 bool isConst(_result->isParameterFixed(i));
791
792 double xlo = _config.ParSettings(i).LowerLimit();
793 double xhi = _config.ParSettings(i).UpperLimit();
794 double xerr = _result->error(i);
795 double xval = _result->fParams[i];
796
797 std::unique_ptr<RooRealVar> var;
798
799 if ((xlo < xhi) && !isConst) {
800 var = std::make_unique<RooRealVar>(varName, varName, xval, xlo, xhi);
801 } else {
802 var = std::make_unique<RooRealVar>(varName, varName, xval);
803 }
804 var->setConstant(isConst);
805
806 if (isConst) {
807 constPars.addOwned(std::move(var));
808 } else {
809 var->setError(xerr);
810 floatPars.addOwned(std::move(var));
811 }
812 }
813
814 res->setConstParList(constPars);
815 res->setInitParList(floatPars);
816 res->setFinalParList(floatPars);
817 res->setMinNLL(_result->fVal);
818 res->setEDM(_result->fEdm);
819 res->setCovQual(_minimizer->CovMatrixStatus());
820 res->setStatus(_result->fStatus);
821 fillCorrMatrix(*res);
822
823 return RooFit::makeOwningPtr(std::move(res));
824}
825
826/// Try to recover from invalid function values. When invalid function values
827/// are encountered, a penalty term is returned to the minimiser to make it
828/// back off. This sets the strength of this penalty. \note A strength of zero
829/// is equivalent to a constant penalty (= the gradient vanishes, ROOT < 6.24).
830/// Positive values lead to a gradient pointing away from the undefined
831/// regions. Use ~10 to force the minimiser away from invalid function values.
836
837bool RooMinimizer::setLogFile(const char *logf)
838{
839 _cfg.logf = logf;
840 return _cfg.logf ? _fcn->SetLogFile(_cfg.logf) : false;
841}
842
844{
845 return _fcn->evalCounter();
846}
848{
849 _fcn->zeroEvalCount();
850}
851
853{
854 return _fcn->getNDim();
855}
856
857std::ofstream *RooMinimizer::logfile()
858{
859 return _fcn->GetLogFile();
860}
862{
863 return _fcn->GetMaxFCN();
864}
866{
867 return _fcn->getOffset();
868}
869
870std::unique_ptr<RooAbsReal::EvalErrorContext> RooMinimizer::makeEvalErrorContext() const
871{
873 // If evaluation error printing is disabled, we don't need to collect the
874 // errors and only need to count them. This significantly reduces the
875 // performance overhead when having evaluation errors.
877 return std::make_unique<RooAbsReal::EvalErrorContext>(m);
878}
879
881{
882 // fit a user provided FCN function
883 // create fit parameter settings
884 unsigned int npar = fcn.NDim();
885 if (npar == 0) {
886 coutE(Minimization) << "RooMinimizer::fitFCN(): FCN function has zero parameters" << std::endl;
887 return false;
888 }
889
890 // init the minimizer
892 // perform the minimization
893
894 // perform the minimization (assume we have already initialized the minimizer)
895
896 bool isValid = _minimizer->Minimize();
897
898 if (!_result)
899 _result = std::make_unique<FitResult>();
900
901 fillResult(isValid);
902
903 // set also new parameter values and errors in FitConfig
904 if (isValid)
906
907 return isValid;
908}
909
911{
912 // compute the Hesse errors according to configuration
913 // set in the parameters and append value in fit result
914
915 // update minimizer (recreate if not done or if name has changed
916 if (!updateMinimizerOptions()) {
917 coutE(Minimization) << "RooMinimizer::calculateHessErrors() Error re-initializing the minimizer" << std::endl;
918 return false;
919 }
920
921 // run Hesse
922 bool ret = _minimizer->Hesse();
923 if (!ret)
924 coutE(Minimization) << "RooMinimizer::calculateHessErrors() Error when calculating Hessian" << std::endl;
925
926 // update minimizer results with what comes out from Hesse
927 // in case is empty - create from a FitConfig
928 if (_result->fParams.empty())
929 _result = std::make_unique<FitResult>(_config);
930
931 // re-give a minimizer instance in case it has been changed
932 ret |= update(ret);
933
934 // set also new errors in FitConfig
935 if (ret)
937
938 return ret;
939}
940
942{
943 // compute the Minos errors according to configuration
944 // set in the parameters and append value in fit result
945 // normally Minos errors are computed just after the minimization
946 // (in DoMinimization) aftewr minimizing if the
947 // FitConfig::MinosErrors() flag is set
948
949 // update minimizer (but cannot re-create in this case). Must use an existing one
950 if (!updateMinimizerOptions(false)) {
951 coutE(Minimization) << "RooMinimizer::calculateHessErrors() Error re-initializing the minimizer" << std::endl;
952 return false;
953 }
954
955 const std::vector<unsigned int> &ipars = _config.MinosParams();
956 unsigned int n = (!ipars.empty()) ? ipars.size() : _fcn->getNDim();
957 bool ok = false;
958
959 int iparNewMin = 0;
960 int iparMax = n;
961 int iter = 0;
962 // rerun minos for the parameters run before a new Minimum has been found
963 do {
964 if (iparNewMin > 0)
965 coutI(Minimization) << "RooMinimizer::calculateMinosErrors() Run again Minos for some parameters because a "
966 "new Minimum has been found"
967 << std::endl;
968 iparNewMin = 0;
969 for (int i = 0; i < iparMax; ++i) {
970 double elow, eup;
971 unsigned int index = (!ipars.empty()) ? ipars[i] : i;
972 bool ret = _minimizer->GetMinosError(index, elow, eup);
973 // flags case when a new minimum has been found
974 if ((_minimizer->MinosStatus() & 8) != 0) {
975 iparNewMin = i;
976 }
977 if (ret)
978 _result->fMinosErrors.emplace(index, std::make_pair(elow, eup));
979 ok |= ret;
980 }
981
983 iter++; // to avoid infinite looping
984 } while (iparNewMin > 0 && iter < 10);
985 if (!ok) {
986 coutE(Minimization)
987 << "RooMinimizer::calculateMinosErrors() Minos error calculation failed for all the selected parameters"
988 << std::endl;
989 }
990
991 // re-give a minimizer instance in case it has been changed
992 // but maintain previous valid status. Do not set result to false if minos failed
993 ok &= update(_result->fValid);
994
995 return ok;
996}
997
999{
1000 _minimizer = std::unique_ptr<ROOT::Math::Minimizer>(_config.CreateMinimizer());
1001 _minimizer->SetFunction(*getMultiGenFcn());
1003
1005 std::vector<double> v;
1006 for (std::size_t i = 0; i < _fcn->getNDim(); ++i) {
1007 RooRealVar &param = _fcn->floatableParam(i);
1008 v.push_back(param.getError() * param.getError());
1009 }
1010 _minimizer->SetCovarianceDiag(v, v.size());
1011 }
1012}
1013
1015{
1016 // update minimizer options when re-doing a Fit or computing Hesse or Minos errors
1017
1018 // create a new minimizer if it is different type
1019 // minimizer type string stored in FitResult is "minimizer name" + " / " + minimizer algo
1020 std::string newMinimType = _config.MinimizerName();
1021 if (_minimizer && _result && newMinimType != _result->fMinimType) {
1022 // if a different minimizer is allowed (e.g. when calling Hesse)
1023 if (canDifferentMinim) {
1024 std::string msg = "Using now " + newMinimType;
1025 coutI(Minimization) << "RooMinimizer::updateMinimizerOptions(): " << msg << std::endl;
1026 initMinimizer();
1027 } else {
1028 std::string msg = "Cannot change minimizer. Continue using " + _result->fMinimType;
1029 coutW(Minimization) << "RooMinimizer::updateMinimizerOptions() " << msg << std::endl;
1030 }
1031 }
1032
1033 // create minimizer if it was not done before
1034 if (!_minimizer) {
1035 initMinimizer();
1036 }
1037
1038 // set new minimizer options (but not functions and parameters)
1039 _minimizer->SetOptions(_config.MinimizerOptions());
1040 return true;
1041}
1042
1044{
1045 // update the fit configuration after a fit using the obtained result
1046 if (_result->fParams.empty() || !_result->fValid)
1047 return;
1048 for (unsigned int i = 0; i < _config.NPar(); ++i) {
1050 par.SetValue(_result->fParams[i]);
1051 if (_result->error(i) > 0)
1052 par.SetStepSize(_result->error(i));
1053 }
1054}
1055
1057 : fStatus(-99), // use this special convention to flag it when printing result
1058 fCovStatus(0),
1059 fParams(fconfig.NPar()),
1060 fErrors(fconfig.NPar())
1061{
1062 // create a Fit result from a fit config (i.e. with initial parameter values
1063 // and errors equal to step values
1064 // The model function is NULL in this case
1065
1066 // set minimizer type and algorithm
1067 fMinimType = fconfig.MinimizerType();
1068 // append algorithm name for minimizer that support it
1069 if ((fMinimType.find("Fumili") == std::string::npos) && (fMinimType.find("GSLMultiFit") == std::string::npos)) {
1070 if (!fconfig.MinimizerAlgoType().empty())
1071 fMinimType += " / " + fconfig.MinimizerAlgoType();
1072 }
1073
1074 // get parameter values and errors (step sizes)
1075 for (unsigned int i = 0; i < fconfig.NPar(); ++i) {
1076 const ROOT::Fit::ParameterSettings &par = fconfig.ParSettings(i);
1077 fParams[i] = par.Value();
1078 fErrors[i] = par.StepSize();
1079 if (par.IsFixed())
1080 fFixedParams[i] = true;
1081 }
1082}
1083
1085{
1088
1089 // Fill the FitResult after minimization using result from Minimizers
1090
1091 _result->fValid = isValid;
1092 _result->fStatus = min.Status();
1093 _result->fCovStatus = min.CovMatrixStatus();
1094 _result->fVal = min.MinValue();
1095 _result->fEdm = min.Edm();
1096
1097 _result->fMinimType = fconfig.MinimizerName();
1098
1099 const unsigned int npar = min.NDim();
1100 if (npar == 0)
1101 return;
1102
1103 if (min.X())
1104 _result->fParams = std::vector<double>(min.X(), min.X() + npar);
1105 else {
1106 // case minimizer does not provide minimum values (it failed) take from configuration
1107 _result->fParams.resize(npar);
1108 for (unsigned int i = 0; i < npar; ++i) {
1109 _result->fParams[i] = (fconfig.ParSettings(i).Value());
1110 }
1111 }
1112
1113 // check for fixed or limited parameters
1114 for (unsigned int ipar = 0; ipar < npar; ++ipar) {
1115 if (fconfig.ParSettings(ipar).IsFixed())
1116 _result->fFixedParams[ipar] = true;
1117 }
1118
1119 // fill error matrix
1120 // if minimizer provides error provides also error matrix
1121 // clear in case of re-filling an existing result
1122 _result->fCovMatrix.clear();
1123 _result->fGlobalCC.clear();
1124
1125 if (min.Errors() != nullptr) {
1126 updateErrors();
1127 }
1128}
1129
1130bool RooMinimizer::update(bool isValid)
1131{
1134
1135 // update fit result with new status from minimizer
1136 // ncalls if it is not zero is used instead of value from minimizer
1137
1138 // in case minimizer changes
1139 _result->fMinimType = fconfig.MinimizerName();
1140
1141 const std::size_t npar = _result->fParams.size();
1142
1143 _result->fValid = isValid;
1144 // update minimum value
1145 _result->fVal = min.MinValue();
1146 _result->fEdm = min.Edm();
1147 _result->fStatus = min.Status();
1148 _result->fCovStatus = min.CovMatrixStatus();
1149
1150 // copy parameter value and errors
1151 std::copy(min.X(), min.X() + npar, _result->fParams.begin());
1152
1153 if (min.Errors() != nullptr) {
1154 updateErrors();
1155 }
1156 return true;
1157}
1158
1160{
1162 const std::size_t npar = _result->fParams.size();
1163
1164 _result->fErrors.resize(npar);
1165 std::copy(min.Errors(), min.Errors() + npar, _result->fErrors.begin());
1166
1167 if (_result->fCovStatus != 0) {
1168
1169 // update error matrix
1170 unsigned int r = npar * (npar + 1) / 2;
1171 _result->fCovMatrix.resize(r);
1172 unsigned int l = 0;
1173 for (unsigned int i = 0; i < npar; ++i) {
1174 for (unsigned int j = 0; j <= i; ++j)
1175 _result->fCovMatrix[l++] = min.CovMatrix(i, j);
1176 }
1177 }
1178 // minos errors are set separately when calling Fitter::CalculateMinosErrors()
1179
1180 // update global CC
1181 _result->fGlobalCC.resize(npar);
1182 for (unsigned int i = 0; i < npar; ++i) {
1183 double globcc = min.GlobalCC(i);
1184 if (globcc < 0) {
1185 _result->fGlobalCC.clear();
1186 break; // it is not supported by that minimizer
1187 }
1188 _result->fGlobalCC[i] = globcc;
1189 }
1190}
1191
1192double RooMinimizer::FitResult::lowerError(unsigned int i) const
1193{
1194 // return lower Minos error for parameter i
1195 // return the parabolic error if Minos error has not been calculated for the parameter i
1196 auto itr = fMinosErrors.find(i);
1197 return (itr != fMinosErrors.end()) ? itr->second.first : error(i);
1198}
1199
1200double RooMinimizer::FitResult::upperError(unsigned int i) const
1201{
1202 // return upper Minos error for parameter i
1203 // return the parabolic error if Minos error has not been calculated for the parameter i
1204 auto itr = fMinosErrors.find(i);
1205 return (itr != fMinosErrors.end()) ? itr->second.second : error(i);
1206}
1207
1209{
1210 return fFixedParams.find(ipar) != fFixedParams.end();
1211}
1212
1214{
1215 const size_t nParams = fParams.size();
1216 covs.ResizeTo(nParams, nParams);
1217 for (std::size_t ic = 0; ic < nParams; ic++) {
1218 for (std::size_t ii = 0; ii < nParams; ii++) {
1219 covs(ic, ii) = covMatrix(fCovMatrix, ic, ii);
1220 }
1221 }
1222}
#define coutI(a)
#define coutW(a)
#define oocoutE(o, a)
#define oocoutI(o, a)
#define coutE(a)
@ kBlue
Definition Rtypes.h:67
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 char Point_t Rectangle_t WindowAttributes_t Float_t r
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 char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
Definition FitConfig.h:49
const std::vector< unsigned int > & MinosParams() const
return vector of parameter indices for which the Minos Error will be computed
Definition FitConfig.h:222
void SetMinimizer(const char *type, const char *algo=nullptr)
set minimizer type and algorithm
Definition FitConfig.h:183
void SetMinosErrors(bool on=true)
set Minos errors computation to be performed after fitting
Definition FitConfig.h:233
unsigned int NPar() const
number of parameters settings
Definition FitConfig.h:98
std::string MinimizerName() const
return Minimizer full name (type / algorithm)
const std::vector< ROOT::Fit::ParameterSettings > & ParamsSettings() const
get the vector of parameter settings (const method)
Definition FitConfig.h:88
ROOT::Math::Minimizer * CreateMinimizer()
create a new minimizer according to chosen configuration
const ParameterSettings & ParSettings(unsigned int i) const
get the parameter settings for the i-th parameter (const method)
Definition FitConfig.h:78
ROOT::Math::MinimizerOptions & MinimizerOptions()
access to the minimizer control parameter (non const method)
Definition FitConfig.h:169
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
bool IsFixed() const
check if is fixed
void SetValue(double val)
set the value
void SetStepSize(double err)
set the step size
double Value() const
return parameter value
double StepSize() const
return step size
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:63
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
void SetStrategy(int stra)
set the strategy
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
static const std::string & DefaultMinimizerType()
int PrintLevel() const
non-static methods for retrieving options
void SetErrorDef(double err)
set error def
void SetPrintLevel(int level)
set print level
void SetTolerance(double tol)
set the tolerance
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Definition Minimizer.h:124
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
bool isConstant() const
Check if the "Constant" attribute is set.
Definition RooAbsArg.h:283
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
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 bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
static void setDefaultNWorkers(unsigned int N_workers)
Definition Config.cxx:67
static void setTimingAnalysis(bool timingAnalysis)
Definition Config.cxx:78
static void add_metadata(json data)
RooAbsReal that wraps RooAbsL likelihoods for use in RooFit outside of the RooMinimizer context.
Definition RooRealL.h:28
Wrapper class around ROOT::Math::Minimizer that provides a seamless interface between the minimizer f...
void setRecoverFromNaNStrength(double strength)
Try to recover from invalid function values.
int getPrintLevel()
Get the MINUIT internal printing level.
void optimizeConst(int flag)
If flag is true, perform constant term optimization on function being minimized.
void initMinimizerFirstPart()
Initialize the part of the minimizer that is independent of the function to be minimized.
std::ofstream * logfile()
int simplex()
Execute SIMPLEX.
std::unique_ptr< TMatrixDSym > _extV
void setMinimizerType(std::string const &type)
Choose the minimizer algorithm.
RooFit::OwningPtr< RooFitResult > save(const char *name=nullptr, const char *title=nullptr)
Save and return a RooFitResult snapshot of current minimizer status.
std::vector< std::pair< std::string, int > > _statusHistory
void profileStart()
Start profiling timer.
RooPlot * contour(RooRealVar &var1, RooRealVar &var2, double n1=1.0, double n2=2.0, double n3=0.0, double n4=0.0, double n5=0.0, double n6=0.0, unsigned int npoints=50)
Create and draw a TH2 with the error contours in the parameters var1 and var2.
std::unique_ptr< ROOT::Math::Minimizer > _minimizer
! pointer to used minimizer
bool setLogFile(const char *logf=nullptr)
void initMinimizerFcnDependentPart(double defaultErrorLevel)
Initialize the part of the minimizer that is dependent on the function to be minimized.
void fillCorrMatrix(RooFitResult &fitRes)
double & fcnOffset() const
ROOT::Fit::FitConfig _config
fitter configuration (options and parameter settings)
void profileStop()
Stop profiling timer and report results of last session.
int minos()
Execute MINOS.
double & maxFCN()
bool calculateHessErrors()
int hesse()
Execute HESSE.
bool calculateMinosErrors()
void setErrorLevel(double level)
Set the level for MINUIT error analysis to the given value.
void determineStatus(bool fitterReturnValue)
int migrad()
Execute MIGRAD.
bool update(bool isValid)
int seek()
Execute SEEK.
bool updateMinimizerOptions(bool canDifferentMinim=true)
void setEps(double eps)
Change MINUIT epsilon.
void setPrintLevel(int newLevel)
Change the MINUIT internal printing level.
void fillResult(bool isValid)
int exec(std::string const &algoName, std::string const &statusName)
int improve()
Execute IMPROVE.
void setOffsetting(bool flag)
Enable internal likelihood offsetting for enhanced numeric precision.
TStopwatch _timer
RooMinimizer::Config _cfg
bool fitFCN(const ROOT::Math::IMultiGenFunction &fcn)
std::unique_ptr< FitResult > _result
! pointer to the object containing the result of the fit
RooFit::OwningPtr< RooFitResult > lastMinuitFit()
void saveStatus(const char *label, int status)
~RooMinimizer() override
Destructor.
int minimize(const char *type, const char *alg=nullptr)
Minimise the function passed in the constructor.
ROOT::Math::IMultiGenFunction * getMultiGenFcn() const
std::unique_ptr< RooAbsReal::EvalErrorContext > makeEvalErrorContext() const
RooMinimizer(RooAbsReal &function, Config const &cfg={})
Construct MINUIT interface to given function.
void setMaxFunctionCalls(int n)
Change maximum number of likelihood function class from MINUIT (RooMinimizer default 500 * #parameter...
void setStrategy(int istrat)
Change MINUIT strategy to istrat.
int evalCounter() const
TStopwatch _cumulTimer
int getNPar() const
void setMaxIterations(int n)
Change maximum number of MINUIT iterations (RooMinimizer default 500 * #parameters)
void addParamsToProcessTimer()
Add parameters in metadata field to process timer.
std::unique_ptr< RooAbsMinimizerFcn > _fcn
void applyCovarianceMatrix(TMatrixDSym const &V)
Apply results of given external covariance matrix.
static RooMsgService & instance()
Return reference to singleton instance.
Plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:43
void addObject(TObject *obj, Option_t *drawOptions="", bool invisible=false)
Add a generic object to this plot.
Definition RooPlot.cxx:325
Variable that can be changed from the outside.
Definition RooRealVar.h:37
double getError() const
Definition RooRealVar.h:59
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:44
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:45
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:42
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
void SetName(const char *name="") override
Set graph name.
Definition TGraph.cxx:2330
Manages Markers.
Definition TMarker.h:22
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:458
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.
Basic string class.
Definition TString.h:138
const Int_t n
Definition legend1.C:16
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:35
OwningPtr< T > makeOwningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
Definition Config.h:40
bool setAllConstant(const RooAbsCollection &coll, bool constant=true)
set all RooRealVars to constants. return true if at least one changed status
Config argument to RooMinimizer constructor.
std::string minimizerType
double upperError(unsigned int i) const
std::string fMinimType
string indicating type of minimizer
std::vector< double > fErrors
errors
std::vector< double > fParams
parameter values. Size is total number of parameters
void GetCovarianceMatrix(TMatrixDSym &cov) const
std::map< unsigned int, bool > fFixedParams
list of fixed parameters
bool isParameterFixed(unsigned int ipar) const
double lowerError(unsigned int i) const
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4