Logo ROOT  
Reference Guide
RooMinuit.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 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooMinuit.cxx
19\class RooMinuit
20\ingroup Roofitlegacy
21
22RooMinuit is a wrapper class around TFitter/TMinuit that
23provides a seamless interface between the MINUIT functionality
24and the native RooFit interface.
25RooMinuit can minimize any RooAbsReal function with respect to
26its parameters. Usual choices for minimization are RooNLLVar
27and RooChi2Var
28RooMinuit 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
41
42#include "TClass.h"
43
44#include <iostream>
45#include <fstream>
46#include <iomanip>
47#include "TMarker.h"
48#include "TGraph.h"
49#include "TStopwatch.h"
50#include "TFitter.h"
51#include "TMinuit.h"
52#include "TMatrixDSym.h"
53#include "RooArgSet.h"
54#include "RooArgList.h"
55#include "RooAbsReal.h"
56#include "RooAbsRealLValue.h"
57#include "RooRealVar.h"
58#include "RooFitResult.h"
59#include "RooAbsPdf.h"
60#include "RooSentinel.h"
61#include "RooMsgService.h"
62#include "RooPlot.h"
63
64
65#if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
66char* operator+( streampos&, char* );
67#endif
68
69using namespace std;
70
72
74
75
76
77////////////////////////////////////////////////////////////////////////////////
78/// Cleanup method called by atexit handler installed by RooSentinel
79/// to delete all global heap objects when the program is terminated
80
82{
83 if (_theFitter) {
84 delete _theFitter ;
85 _theFitter =0 ;
86 }
87}
88
89
90
91////////////////////////////////////////////////////////////////////////////////
92/// Construct MINUIT interface to given function. Function can be anything,
93/// but is typically a -log(likelihood) implemented by RooNLLVar or a chi^2
94/// (implemented by RooChi2Var). Other frequent use cases are a RooAddition
95/// of a RooNLLVar plus a penalty or constraint term. This class propagates
96/// all RooFit information (floating parameters, their values and errors)
97/// to MINUIT before each MINUIT call and propagates all MINUIT information
98/// back to the RooFit object at the end of each call (updated parameter
99/// values, their (asymmetric errors) etc. The default MINUIT error level
100/// for HESSE and MINOS error analysis is taken from the defaultErrorLevel()
101/// value of the input function.
102
104{
106
107 // Store function reference
108 _evalCounter = 0 ;
109 _extV = 0 ;
110 _func = &function ;
111 _logfile = 0 ;
112 _optConst = false ;
113 _verbose = false ;
114 _profile = false ;
115 _handleLocalErrors = true ;
116 _printLevel = 1 ;
117 _printEvalErrors = 10 ;
118 _warnLevel = -999 ;
119 _maxEvalMult = 500 ;
120 _doEvalErrorWall = true ;
121
122 // Examine parameter list
123 RooArgSet* paramSet = function.getParameters(RooArgSet()) ;
124 RooArgList paramList(*paramSet) ;
125 delete paramSet ;
126
127 _floatParamList = (RooArgList*) paramList.selectByAttrib("Constant",false) ;
128 if (_floatParamList->getSize()>1) {
130 }
131 _floatParamList->setName("floatParamList") ;
132
133 _constParamList = (RooArgList*) paramList.selectByAttrib("Constant",true) ;
134 if (_constParamList->getSize()>1) {
136 }
137 _constParamList->setName("constParamList") ;
138
139 // Remove all non-RooRealVar parameters from list (MINUIT cannot handle them)
140 for (RooAbsArg * arg : *_floatParamList) {
141 if (!arg->IsA()->InheritsFrom(RooAbsRealLValue::Class())) {
142 coutW(Minimization) << "RooMinuit::RooMinuit: removing parameter " << arg->GetName()
143 << " from list because it is not of type RooRealVar" << endl ;
144 _floatParamList->remove(*arg) ;
145 }
146 }
148
150
151 // Save snapshot of initial lists
154
155 // Initialize MINUIT
157 if (_theFitter) delete _theFitter ;
158 _theFitter = new TFitter(nPar*2+1) ; //WVE Kludge, nPar*2 works around TMinuit memory allocation bug
159 _theFitter->SetObjectFit(this) ;
160
161 // Shut up for now
162 setPrintLevel(-1) ;
163 _theFitter->Clear();
164
165 // Tell MINUIT to use our global glue function
167
168 // Use +0.5 for 1-sigma errors
169 setErrorLevel(function.defaultErrorLevel()) ;
170
171 // Declare our parameters to MINUIT
172 synchronize(false) ;
173
174 // Reset the *largest* negative log-likelihood value we have seen so far
175 _maxFCN= -1e30 ;
176 _numBadNLL = 0 ;
177
178 // Now set default verbosity
179 if (RooMsgService::instance().silentMode()) {
180 setWarnLevel(-1) ;
181 setPrintLevel(-1) ;
182 } else {
183 setWarnLevel(1) ;
184 setPrintLevel(1) ;
185 }
186}
187
188
189
190////////////////////////////////////////////////////////////////////////////////
191/// Destructor
192
194{
195 delete _floatParamList ;
196 delete _initFloatParamList ;
197 delete _constParamList ;
198 delete _initConstParamList ;
199 if (_extV) {
200 delete _extV ;
201 }
202}
203
204
205
206////////////////////////////////////////////////////////////////////////////////
207/// Change MINUIT strategy to istrat. Accepted codes
208/// are 0,1,2 and represent MINUIT strategies for dealing
209/// most efficiently with fast FCNs (0), expensive FCNs (2)
210/// and 'intermediate' FCNs (1)
211
213{
214 double stratArg(istrat) ;
215 _theFitter->ExecuteCommand("SET STR",&stratArg,1) ;
216}
217
218
219
220////////////////////////////////////////////////////////////////////////////////
221/// Set the level for MINUIT error analysis to the given
222/// value. This function overrides the default value
223/// that is taken in the RooMinuit constructor from
224/// the defaultErrorLevel() method of the input function
225
226void RooMinuit::setErrorLevel(double level)
227{
228 _theFitter->ExecuteCommand("SET ERR",&level,1);
229}
230
231
232
233////////////////////////////////////////////////////////////////////////////////
234/// Change MINUIT epsilon
235
236void RooMinuit::setEps(double eps)
237{
238 _theFitter->ExecuteCommand("SET EPS",&eps,1) ;
239}
240
241
242
243////////////////////////////////////////////////////////////////////////////////
244/// Enable internal likelihood offsetting for enhanced numeric precision
245
247{
248 _func->enableOffsetting(flag) ;
249}
250
251
252////////////////////////////////////////////////////////////////////////////////
253/// Parse traditional RooAbsPdf::fitTo driver options
254///
255/// s - Run Hesse first to estimate initial step size
256/// m - Run Migrad only
257/// h - Run Hesse to estimate errors
258/// v - Verbose mode
259/// l - Log parameters after each Minuit steps to file
260/// t - Activate profile timer
261/// r - Save fit result
262/// 0 - Run Migrad with strategy 0
263
264RooFitResult* RooMinuit::fit(const char* options)
265{
266 if (_floatParamList->empty()) {
267 return 0 ;
268 }
269
270 _theFitter->SetObjectFit(this) ;
271
272 TString opts(options) ;
273 opts.ToLower() ;
274
275 // Initial configuration
276 if (opts.Contains("v")) setVerbose(1) ;
277 if (opts.Contains("t")) setProfile(1) ;
278 if (opts.Contains("l")) setLogFile(Form("%s.log",_func->GetName())) ;
279 if (opts.Contains("c")) optimizeConst(1) ;
280
281 // Fitting steps
282 if (opts.Contains("s")) hesse() ;
283 if (opts.Contains("0")) setStrategy(0) ;
284 migrad() ;
285 if (opts.Contains("0")) setStrategy(1) ;
286 if (opts.Contains("h")||!opts.Contains("m")) hesse() ;
287 if (!opts.Contains("m")) minos() ;
288
289 return (opts.Contains("r")) ? save() : 0 ;
290}
291
292
293
294////////////////////////////////////////////////////////////////////////////////
295/// Execute MIGRAD. Changes in parameter values
296/// and calculated errors are automatically
297/// propagated back the RooRealVars representing
298/// the floating parameters in the MINUIT operation
299
301{
302 if (_floatParamList->empty()) {
303 return -1 ;
304 }
305
306 _theFitter->SetObjectFit(this) ;
307
308 double arglist[2];
309 arglist[0]= _maxEvalMult*_nPar; // maximum iterations
310 arglist[1]= 1.0; // tolerance
311
313 profileStart() ;
316 _status= _theFitter->ExecuteCommand("MIGRAD",arglist,2);
318 profileStop() ;
319 backProp() ;
320
321 saveStatus("MIGRAD",_status) ;
322
323 return _status ;
324}
325
326
327
328////////////////////////////////////////////////////////////////////////////////
329/// Execute HESSE. Changes in parameter values
330/// and calculated errors are automatically
331/// propagated back the RooRealVars representing
332/// the floating parameters in the MINUIT operation
333
335{
336 if (_floatParamList->empty()) {
337 return -1 ;
338 }
339
340 _theFitter->SetObjectFit(this) ;
341
342 double arglist[2];
343 arglist[0]= _maxEvalMult*_nPar; // maximum iterations
344
346 profileStart() ;
349 _status= _theFitter->ExecuteCommand("HESSE",arglist,1);
351 profileStop() ;
352 backProp() ;
353
354 saveStatus("HESSE",_status) ;
355
356 return _status ;
357}
358
359
360
361////////////////////////////////////////////////////////////////////////////////
362/// Execute MINOS. Changes in parameter values
363/// and calculated errors are automatically
364/// propagated back the RooRealVars representing
365/// the floating parameters in the MINUIT operation
366
368{
369 if (_floatParamList->empty()) {
370 return -1 ;
371 }
372
373 _theFitter->SetObjectFit(this) ;
374
375 double arglist[2];
376 arglist[0]= _maxEvalMult*_nPar; // maximum iterations
377
379 profileStart() ;
382 _status= _theFitter->ExecuteCommand("MINOS",arglist,1);
383 // check also the status of Minos looking at fCstatu
384 if (_status == 0 && gMinuit->fCstatu != "SUCCESSFUL") {
385 if (gMinuit->fCstatu == "FAILURE" ||
386 gMinuit->fCstatu == "PROBLEMS") _status = 5;
387 _status = 6;
388 }
389
391 profileStop() ;
392 backProp() ;
393
394 saveStatus("MINOS",_status) ;
395 return _status ;
396}
397
398
399// added FMV, 08/18/03
400
401////////////////////////////////////////////////////////////////////////////////
402/// Execute MINOS for given list of parameters. Changes in parameter values
403/// and calculated errors are automatically
404/// propagated back the RooRealVars representing
405/// the floating parameters in the MINUIT operation
406
407Int_t RooMinuit::minos(const RooArgSet& minosParamList)
408{
409 if (_floatParamList->empty()) {
410 return -1 ;
411 }
412
413 _theFitter->SetObjectFit(this) ;
414
415 Int_t nMinosPar(0) ;
416 double* arglist = new double[_nPar+1];
417
418 if (minosParamList.getSize()>0) {
419 for(RooAbsArg * arg : minosParamList) {
420 RooAbsArg* par = _floatParamList->find(arg->GetName());
421 if (par && !par->isConstant()) {
423 nMinosPar++;
424 arglist[nMinosPar]=index+1;
425 }
426 }
427 }
428 arglist[0]= _maxEvalMult*_nPar; // maximum iterations
429
431 profileStart() ;
434 _status= _theFitter->ExecuteCommand("MINOS",arglist,1+nMinosPar);
435 // check also the status of Minos looking at fCstatu
436 if (_status == 0 && gMinuit->fCstatu != "SUCCESSFUL") {
437 if (gMinuit->fCstatu == "FAILURE" ||
438 gMinuit->fCstatu == "PROBLEMS") _status = 5;
439 _status = 6;
440 }
442 profileStop() ;
443 backProp() ;
444
445 delete[] arglist ;
446
447 saveStatus("MINOS",_status) ;
448
449 return _status ;
450}
451
452
453
454////////////////////////////////////////////////////////////////////////////////
455/// Execute SEEK. Changes in parameter values
456/// and calculated errors are automatically
457/// propagated back the RooRealVars representing
458/// the floating parameters in the MINUIT operation
459
461{
462 if (_floatParamList->empty()) {
463 return -1 ;
464 }
465
466 _theFitter->SetObjectFit(this) ;
467
468 double arglist[2];
469 arglist[0]= _maxEvalMult*_nPar; // maximum iterations
470
472 profileStart() ;
475 _status= _theFitter->ExecuteCommand("SEEK",arglist,1);
477 profileStop() ;
478 backProp() ;
479
480 saveStatus("SEEK",_status) ;
481
482 return _status ;
483}
484
485
486
487////////////////////////////////////////////////////////////////////////////////
488/// Execute SIMPLEX. Changes in parameter values
489/// and calculated errors are automatically
490/// propagated back the RooRealVars representing
491/// the floating parameters in the MINUIT operation
492
494{
495 if (_floatParamList->empty()) {
496 return -1 ;
497 }
498
499 _theFitter->SetObjectFit(this) ;
500
501 double arglist[2];
502 arglist[0]= _maxEvalMult*_nPar; // maximum iterations
503 arglist[1]= 1.0; // tolerance
504
506 profileStart() ;
509 _status= _theFitter->ExecuteCommand("SIMPLEX",arglist,2);
511 profileStop() ;
512 backProp() ;
513
514 saveStatus("SIMPLEX",_status) ;
515
516 return _status ;
517}
518
519
520
521////////////////////////////////////////////////////////////////////////////////
522/// Execute IMPROVE. Changes in parameter values
523/// and calculated errors are automatically
524/// propagated back the RooRealVars representing
525/// the floating parameters in the MINUIT operation
526
528{
529 if (_floatParamList->empty()) {
530 return -1 ;
531 }
532
533 _theFitter->SetObjectFit(this) ;
534
535 double arglist[2];
536 arglist[0]= _maxEvalMult*_nPar; // maximum iterations
537
539 profileStart() ;
542 _status= _theFitter->ExecuteCommand("IMPROVE",arglist,1);
544 profileStop() ;
545 backProp() ;
546
547 saveStatus("IMPROVE",_status) ;
548
549 return _status ;
550}
551
552
553
554////////////////////////////////////////////////////////////////////////////////
555/// Change the MINUIT internal printing level
556
558{
559 Int_t ret = _printLevel ;
560 double arg(newLevel) ;
561 _theFitter->ExecuteCommand("SET PRINT",&arg,1);
562 _printLevel = newLevel ;
563 return ret ;
564}
565
566
567
568////////////////////////////////////////////////////////////////////////////////
569/// Instruct MINUIT to suppress warnings
570
572{
573 double arg(0) ;
574 _theFitter->ExecuteCommand("SET NOWARNINGS",&arg,1);
575 _warnLevel = -1 ;
576}
577
578
579
580////////////////////////////////////////////////////////////////////////////////
581/// Set MINUIT warning level to given level
582
584{
585 if (newLevel==_warnLevel) {
586 return _warnLevel ;
587 }
588
589 Int_t ret = _warnLevel ;
590 double arg(newLevel) ;
591
592 if (newLevel>=0) {
593 _theFitter->ExecuteCommand("SET WARNINGS",&arg,1);
594 } else {
595 double arg2(0) ;
596 _theFitter->ExecuteCommand("SET NOWARNINGS",&arg2,1);
597 }
598 _warnLevel = newLevel ;
599
600 return ret ;
601}
602
603
604
605////////////////////////////////////////////////////////////////////////////////
606/// Internal function to synchronize TMinuit with current
607/// information in RooAbsReal function parameters
608
610{
611 Int_t oldPrint = setPrintLevel(-1) ;
612 gMinuit->fNwrmes[0] = 0; // to clear buffer
613 Int_t oldWarn = setWarnLevel(-1) ;
614
615 bool constValChange(false) ;
616 bool constStatChange(false) ;
617
618 Int_t index(0) ;
619
620 // Handle eventual migrations from constParamList -> floatParamList
621 for(index= 0; index < _constParamList->getSize() ; index++) {
622 RooRealVar *par= dynamic_cast<RooRealVar*>(_constParamList->at(index)) ;
623 if (!par) continue ;
624
625 RooRealVar *oldpar= dynamic_cast<RooRealVar*>(_initConstParamList->at(index)) ;
626 if (!oldpar) continue ;
627
628 // Test if constness changed
629 if (!par->isConstant()) {
630
631 // Remove from constList, add to floatList
632 _constParamList->remove(*par) ;
633 _floatParamList->add(*par) ;
634 _initFloatParamList->addClone(*oldpar) ;
635 _initConstParamList->remove(*oldpar) ;
636 constStatChange=true ;
637 _nPar++ ;
638
639 if (verbose) {
640 coutI(Minimization) << "RooMinuit::synchronize: parameter " << par->GetName() << " is now floating." << endl ;
641 }
642 }
643
644 // Test if value changed
645 if (par->getVal()!= oldpar->getVal()) {
646 constValChange=true ;
647 if (verbose) {
648 coutI(Minimization) << "RooMinuit::synchronize: value of constant parameter " << par->GetName()
649 << " changed from " << oldpar->getVal() << " to " << par->getVal() << endl ;
650 }
651 }
652
653 }
654
655 // Update reference list
657
658
659 // Synchronize MINUIT with function state
660 for(index= 0; index < _nPar; index++) {
661 RooRealVar *par= dynamic_cast<RooRealVar*>(_floatParamList->at(index)) ;
662 if (!par) continue ;
663
664 double pstep(0) ;
665 double pmin(0) ;
666 double pmax(0) ;
667
668 if(!par->isConstant()) {
669
670 // Verify that floating parameter is indeed of type RooRealVar
671 if (!par->IsA()->InheritsFrom(RooRealVar::Class())) {
672 coutW(Minimization) << "RooMinuit::fit: Error, non-constant parameter " << par->GetName()
673 << " is not of type RooRealVar, skipping" << endl ;
674 continue ;
675 }
676
677 // Set the limits, if not infinite
678 if (par->hasMin() && par->hasMax()) {
679 pmin = par->getMin();
680 pmax = par->getMax();
681 }
682
683 // Calculate step size
684 pstep= par->getError();
685 if(pstep <= 0) {
686 // Floating parameter without error estitimate
687 if (par->hasMin() && par->hasMax()) {
688 pstep= 0.1*(pmax-pmin);
689
690 // Trim default choice of error if within 2 sigma of limit
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 ;
695 }
696
697 // If trimming results in zero error, restore default
698 if (pstep==0) {
699 pstep= 0.1*(pmax-pmin);
700 }
701
702 } else {
703 pstep=1 ;
704 }
705 if(_verbose) {
706 coutW(Minimization) << "RooMinuit::synchronize: WARNING: no initial error estimate available for "
707 << par->GetName() << ": using " << pstep << endl;
708 }
709 }
710 } else {
711 pmin = par->getVal() ;
712 pmax = par->getVal() ;
713 }
714
715 // Extract previous information
716 double oldVar,oldVerr,oldVlo,oldVhi ;
717 char oldParname[100] ;
718 Int_t ierr = _theFitter->GetParameter(index,oldParname,oldVar,oldVerr,oldVlo,oldVhi) ;
719
720 // Determine if parameters is currently fixed in MINUIT
721
722 Int_t ix ;
723 bool oldFixed(false) ;
724 if (ierr>=0) {
725 for (ix = 1; ix <= gMinuit->fNpfix; ++ix) {
726 if (gMinuit->fIpfix[ix-1] == index+1) oldFixed=true ;
727 }
728 }
729
730 if (par->isConstant() && !oldFixed) {
731
732 // Parameter changes floating -> constant : update only value if necessary
733 if (oldVar!=par->getVal()) {
734 double arglist[2] ;
735 arglist[0] = index+1 ;
736 arglist[1] = par->getVal() ;
737 _theFitter->ExecuteCommand("SET PAR",arglist,2) ;
738 if (verbose) {
739 coutI(Minimization) << "RooMinuit::synchronize: value of parameter " << par->GetName() << " changed from " << oldVar << " to " << par->getVal() << endl ;
740 }
741 }
742
744 constStatChange=true ;
745 if (verbose) {
746 coutI(Minimization) << "RooMinuit::synchronize: parameter " << par->GetName() << " is now fixed." << endl ;
747 }
748
749 } else if (par->isConstant() && oldFixed) {
750
751 // Parameter changes constant -> constant : update only value if necessary
752 if (oldVar!=par->getVal()) {
753 double arglist[2] ;
754 arglist[0] = index+1 ;
755 arglist[1] = par->getVal() ;
756 _theFitter->ExecuteCommand("SET PAR",arglist,2) ;
757 constValChange=true ;
758
759 if (verbose) {
760 coutI(Minimization) << "RooMinuit::synchronize: value of fixed parameter " << par->GetName() << " changed from " << oldVar << " to " << par->getVal() << endl ;
761 }
762 }
763
764 } else {
765
766 if (!par->isConstant() && oldFixed) {
768 constStatChange=true ;
769
770 if (verbose) {
771 coutI(Minimization) << "RooMinuit::synchronize: parameter " << par->GetName() << " is now floating." << endl ;
772 }
773 }
774
775 // Parameter changes constant -> floating : update all if necessary
776 if (oldVar!=par->getVal() || oldVlo!=pmin || oldVhi != pmax || oldVerr!=pstep) {
777 _theFitter->SetParameter(index, par->GetName(), par->getVal(), pstep, pmin, pmax);
778 }
779
780 // Inform user about changes in verbose mode
781 if (verbose && ierr>=0) {
782 // if ierr<0, par was moved from the const list and a message was already printed
783
784 if (oldVar!=par->getVal()) {
785 coutI(Minimization) << "RooMinuit::synchronize: value of parameter " << par->GetName() << " changed from " << oldVar << " to " << par->getVal() << endl ;
786 }
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 ;
790 }
791
792 // If oldVerr=0, then parameter was previously fixed
793 if (oldVerr!=pstep && oldVerr!=0) {
794 coutI(Minimization) << "RooMinuit::synchronize: error/step size of parameter " << par->GetName() << " changed from " << oldVerr << " to " << pstep << endl ;
795 }
796 }
797 }
798 }
799
800
801 gMinuit->fNwrmes[0] = 0; // to clear buffer
802 oldWarn = setWarnLevel(oldWarn) ;
803 oldPrint = setPrintLevel(oldPrint) ;
804
805 if (_optConst) {
806 if (constStatChange) {
807
809
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 ;
815 }
816
818
819 }
820
822
823 return 0 ;
824}
825
826
827
828
829////////////////////////////////////////////////////////////////////////////////
830/// If flag is true, perform constant term optimization on
831/// function being minimized.
832
834{
836
837 if (_optConst && !flag){
838 if (_printLevel>-1) coutI(Minimization) << "RooMinuit::optimizeConst: deactivating const optimization" << endl ;
840 _optConst = flag ;
841 } else if (!_optConst && flag) {
842 if (_printLevel>-1) coutI(Minimization) << "RooMinuit::optimizeConst: activating const optimization" << endl ;
844 _optConst = flag ;
845 } else if (_optConst && flag) {
846 if (_printLevel>-1) coutI(Minimization) << "RooMinuit::optimizeConst: const optimization already active" << endl ;
847 } else {
848 if (_printLevel>-1) coutI(Minimization) << "RooMinuit::optimizeConst: const optimization wasn't active" << endl ;
849 }
850
852
853}
854
855
856
857////////////////////////////////////////////////////////////////////////////////
858/// Save and return a RooFitResult snaphot of current minimizer status.
859/// This snapshot contains the values of all constant parameters,
860/// the value of all floating parameters at RooMinuit construction and
861/// after the last MINUIT operation, the MINUIT status, variance quality,
862/// EDM setting, number of calls with evaluation problems, the minimized
863/// function value and the full correlation matrix
864
865RooFitResult* RooMinuit::save(const char* userName, const char* userTitle)
866{
867 TString name,title ;
868 name = userName ? userName : Form("%s", _func->GetName()) ;
869 title = userTitle ? userTitle : Form("%s", _func->GetTitle()) ;
870
871 if (_floatParamList->empty()) {
872 RooFitResult* fitRes = new RooFitResult(name,title) ;
874 fitRes->setInitParList(RooArgList()) ;
875 fitRes->setFinalParList(RooArgList()) ;
876 fitRes->setStatus(-999) ;
877 fitRes->setCovQual(-999) ;
878 fitRes->setMinNLL(_func->getVal()) ;
879 fitRes->setNumInvalidNLL(0) ;
880 fitRes->setEDM(-999) ;
881 return fitRes ;
882 }
883
884 RooFitResult* fitRes = new RooFitResult(name,title) ;
885
886 // Move eventual fixed parameters in floatList to constList
887 Int_t i ;
888 RooArgList saveConstList(*_constParamList) ;
889 RooArgList saveFloatInitList(*_initFloatParamList) ;
890 RooArgList saveFloatFinalList(*_floatParamList) ;
891 for (i=0 ; i<_floatParamList->getSize() ; i++) {
892 RooAbsArg* par = _floatParamList->at(i) ;
893 if (par->isConstant()) {
894 saveFloatInitList.remove(*saveFloatInitList.find(par->GetName()),true) ;
895 saveFloatFinalList.remove(*par) ;
896 saveConstList.add(*par) ;
897 }
898 }
899 saveConstList.sort() ;
900
901 fitRes->setConstParList(saveConstList) ;
902 fitRes->setInitParList(saveFloatInitList) ;
903
904 double edm, errdef, minVal;
905 Int_t nvpar, nparx;
906 Int_t icode = _theFitter->GetStats(minVal, edm, errdef, nvpar, nparx);
907 fitRes->setStatus(_status) ;
908 fitRes->setCovQual(icode) ;
909 fitRes->setMinNLL(minVal) ;
911 fitRes->setEDM(edm) ;
912 fitRes->setFinalParList(saveFloatFinalList) ;
913 if (!_extV) {
914 fitRes->fillCorrMatrix() ;
915 } else {
916 fitRes->setCovarianceMatrix(*_extV) ;
917 }
918
920
921 return fitRes ;
922}
923
924
925
926
927////////////////////////////////////////////////////////////////////////////////
928/// Create and draw a TH2 with the error contours in parameters var1 and v2 at up to 6 'sigma' settings
929/// where 'sigma' is calculated as n*n*errorLevel
930
931RooPlot* RooMinuit::contour(RooRealVar& var1, RooRealVar& var2, double n1, double n2, double n3, double n4, double n5, double n6)
932{
933
934 _theFitter->SetObjectFit(this) ;
935
936 RooArgList* paramSave = (RooArgList*) _floatParamList->snapshot() ;
937
938 // Verify that both variables are floating parameters of PDF
939 Int_t index1= _floatParamList->index(&var1);
940 if(index1 < 0) {
941 coutE(Minimization) << "RooMinuit::contour(" << GetName()
942 << ") ERROR: " << var1.GetName() << " is not a floating parameter of " << _func->GetName() << endl ;
943 return 0;
944 }
945
946 Int_t index2= _floatParamList->index(&var2);
947 if(index2 < 0) {
948 coutE(Minimization) << "RooMinuit::contour(" << GetName()
949 << ") ERROR: " << var2.GetName() << " is not a floating parameter of PDF " << _func->GetName() << endl ;
950 return 0;
951 }
952
953 // create and draw a frame
954 RooPlot* frame = new RooPlot(var1,var2) ;
955
956 // draw a point at the current parameter values
957 TMarker *point= new TMarker(var1.getVal(), var2.getVal(), 8);
958 frame->addObject(point) ;
959
960 // remember our original value of ERRDEF
961 double errdef= gMinuit->fUp;
962
963 double n[6] ;
964 n[0] = n1 ; n[1] = n2 ; n[2] = n3 ; n[3] = n4 ; n[4] = n5 ; n[5] = n6 ;
965
966
967 for (Int_t ic = 0 ; ic<6 ; ic++) {
968 if(n[ic] > 0) {
969 // set the value corresponding to an n1-sigma contour
970 gMinuit->SetErrorDef(n[ic]*n[ic]*errdef);
971 // calculate and draw the contour
972 TGraph* graph= (TGraph*)gMinuit->Contour(50, index1, index2);
973 if (!graph) {
974 coutE(Minimization) << "RooMinuit::contour(" << GetName() << ") ERROR: MINUIT did not return a contour graph for n=" << n[ic] << endl ;
975 } else {
976 graph->SetName(Form("contour_%s_n%f",_func->GetName(),n[ic])) ;
977 graph->SetLineStyle(ic+1) ;
978 graph->SetLineWidth(2) ;
979 graph->SetLineColor(kBlue) ;
980 frame->addObject(graph,"L") ;
981 }
982 }
983 }
984
985 // restore the original ERRDEF
986 gMinuit->SetErrorDef(errdef);
987
988 // restore parameter values
989 _floatParamList->assign(*paramSave) ;
990 delete paramSave ;
991
992
993 return frame ;
994}
995
996
997
998////////////////////////////////////////////////////////////////////////////////
999/// Change the file name for logging of a RooMinuit of all MINUIT steppings
1000/// through the parameter space. If inLogfile is null, the current log file
1001/// is closed and logging is stopped.
1002
1003bool RooMinuit::setLogFile(const char* inLogfile)
1004{
1005 if (_logfile) {
1006 coutI(Minimization) << "RooMinuit::setLogFile: closing previous log file" << endl ;
1007 _logfile->close() ;
1008 delete _logfile ;
1009 _logfile = 0 ;
1010 }
1011 _logfile = new ofstream(inLogfile) ;
1012 if (!_logfile->good()) {
1013 coutI(Minimization) << "RooMinuit::setLogFile: cannot open file " << inLogfile << endl ;
1014 _logfile->close() ;
1015 delete _logfile ;
1016 _logfile= 0;
1017 }
1018 return false ;
1019}
1020
1021
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Access PDF parameter value by ordinal index (needed by MINUIT)
1025
1027{
1028 return ((RooRealVar*)_floatParamList->at(index))->getVal() ;
1029}
1030
1031
1032
1033////////////////////////////////////////////////////////////////////////////////
1034/// Access PDF parameter error by ordinal index (needed by MINUIT)
1035
1037{
1038 return ((RooRealVar*)_floatParamList->at(index))->getError() ;
1039}
1040
1041
1042
1043////////////////////////////////////////////////////////////////////////////////
1044/// Modify PDF parameter value by ordinal index (needed by MINUIT)
1045
1047{
1048 //RooRealVar* par = (RooRealVar*)_floatParamList->at(index) ;
1050
1051 if (par->getVal()!=value) {
1052 if (verbose) cout << par->GetName() << "=" << value << ", " ;
1053 par->setVal(value) ;
1054 return true ;
1055 }
1056
1057 return false ;
1058}
1059
1060
1061
1062////////////////////////////////////////////////////////////////////////////////
1063/// Modify PDF parameter error by ordinal index (needed by MINUIT)
1064
1066{
1067 ((RooRealVar*)_floatParamList->at(index))->setError(value) ;
1068}
1069
1070
1071
1072////////////////////////////////////////////////////////////////////////////////
1073/// Modify PDF parameter error by ordinal index (needed by MINUIT)
1074
1076{
1077 ((RooRealVar*)_floatParamList->at(index))->removeAsymError() ;
1078}
1079
1080
1081////////////////////////////////////////////////////////////////////////////////
1082/// Modify PDF parameter error by ordinal index (needed by MINUIT)
1083
1084void RooMinuit::setPdfParamErr(Int_t index, double loVal, double hiVal)
1085{
1086 ((RooRealVar*)_floatParamList->at(index))->setAsymError(loVal,hiVal) ;
1087}
1088
1089
1090
1091////////////////////////////////////////////////////////////////////////////////
1092/// Start profiling timer
1093
1095{
1096 if (_profile) {
1097 _timer.Start() ;
1098 _cumulTimer.Start(false) ;
1099 }
1100}
1101
1102
1103
1104
1105////////////////////////////////////////////////////////////////////////////////
1106/// Stop profiling timer and report results of last session
1107
1109{
1110 if (_profile) {
1111 _timer.Stop() ;
1112 _cumulTimer.Stop() ;
1113 coutI(Minimization) << "Command timer: " ; _timer.Print() ;
1114 coutI(Minimization) << "Session timer: " ; _cumulTimer.Print() ;
1115 }
1116}
1117
1118
1119
1120
1121
1122////////////////////////////////////////////////////////////////////////////////
1123/// Transfer MINUIT fit results back into RooFit objects
1124
1126{
1127 double val,err,vlo,vhi, eplus, eminus, eparab, globcc;
1128 char buffer[64000];
1129 Int_t index ;
1130 for(index= 0; index < _nPar; index++) {
1131 _theFitter->GetParameter(index, buffer, val, err, vlo, vhi);
1132 setPdfParamVal(index, val);
1133 _theFitter->GetErrors(index, eplus, eminus, eparab, globcc);
1134
1135 // Set the parabolic error
1136 setPdfParamErr(index, err);
1137
1138 if(eplus > 0 || eminus < 0) {
1139 // Store the asymmetric error, if it is available
1140 setPdfParamErr(index, eminus,eplus);
1141 } else {
1142 // Clear the asymmetric error
1144 }
1145 }
1146}
1147
1148
1149////////////////////////////////////////////////////////////////////////////////
1150
1152{
1153 _floatParamVec.clear() ;
1155 Int_t i(0) ;
1156 for (auto* arg : *_floatParamList) {
1157 _floatParamVec[i++] = arg ;
1158 }
1159}
1160
1161
1162
1163////////////////////////////////////////////////////////////////////////////////
1164/// Apply results of given external covariance matrix. i.e. propagate its errors
1165/// to all RRV parameter representations and give this matrix instead of the
1166/// HESSE matrix at the next save() call
1167
1169{
1170 _extV = (TMatrixDSym*) V.Clone() ;
1171
1172 for (Int_t i=0 ; i<getNPar() ; i++) {
1173 // Skip fixed parameters
1174 if (_floatParamList->at(i)->isConstant()) {
1175 continue ;
1176 }
1177 RooMinuit* context = (RooMinuit*) RooMinuit::_theFitter->GetObjectFit() ;
1178 if (context && context->_verbose)
1179 cout << "setting parameter " << i << " error to " << sqrt((*_extV)(i,i)) << endl ;
1180 setPdfParamErr(i, sqrt((*_extV)(i,i))) ;
1181 }
1182
1183}
1184
1185
1186
1187
1188void RooMinuitGlue(Int_t& /*np*/, double* /*gin*/,
1189 double &f, double *par, Int_t /*flag*/)
1190{
1191 // Static function that interfaces minuit with RooMinuit
1192
1193 // Retrieve fit context and its components
1194 RooMinuit* context = (RooMinuit*) RooMinuit::_theFitter->GetObjectFit() ;
1195 ofstream* logf = context->logfile() ;
1196 double& maxFCN = context->maxFCN() ;
1197 bool verbose = context->_verbose ;
1198
1199 // Set the parameter values for this iteration
1200 Int_t nPar= context->getNPar();
1201 for(Int_t index= 0; index < nPar; index++) {
1202 if (logf) (*logf) << par[index] << " " ;
1203 context->setPdfParamVal(index, par[index],verbose);
1204 }
1205
1206 // Calculate the function for these parameters
1208 f= context->_func->getVal() ;
1210 context->_evalCounter++ ;
1211 if (RooAbsReal::numEvalErrors()>0 || f>1e30) {
1212
1213 if (context->_printEvalErrors>=0) {
1214
1215 if (context->_doEvalErrorWall) {
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 ;
1219 } else {
1220 oocoutW(context,Minimization) << "RooMinuitGlue: Minimized function has error status but is ignored" << endl ;
1221 }
1222
1223 bool first(true) ;
1224 ooccoutW(context,Minimization) << "Parameter values: " ;
1225 for(auto * var : static_range_cast<RooRealVar*>(*context->_floatParamList)) {
1226 if (first) { first = false ; } else ooccoutW(context,Minimization) << ", " ;
1227 ooccoutW(context,Minimization) << var->GetName() << "=" << var->getVal() ;
1228 }
1229 ooccoutW(context,Minimization) << endl ;
1230
1232 ooccoutW(context,Minimization) << endl ;
1233 }
1234
1235 if (context->_doEvalErrorWall) {
1236 f = maxFCN+1 ;
1237 }
1238
1240 context->_numBadNLL++ ;
1241 } else if (f>maxFCN) {
1242 maxFCN = f ;
1243 }
1244
1245 // Optional logging
1246 if (logf) (*logf) << setprecision(15) << f << setprecision(4) << endl;
1247 if (verbose) {
1248 cout << "\nprevFCN" << (context->_func->isOffsetting()?"-offset":"") << " = " << setprecision(10) << f << setprecision(4) << " " ;
1249 cout.flush() ;
1250 }
1251}
#define f(i)
Definition: RSha256.hxx:104
void RooMinuitGlue(Int_t &, double *, double &f, double *par, Int_t)
Definition: RooMinuit.cxx:1188
#define coutI(a)
Definition: RooMsgService.h:34
#define oocoutW(o, a)
Definition: RooMsgService.h:51
#define coutW(a)
Definition: RooMsgService.h:36
#define coutE(a)
Definition: RooMsgService.h:37
#define ooccoutW(o, a)
Definition: RooMsgService.h:59
#define ClassImp(name)
Definition: Rtypes.h:375
@ kBlue
Definition: Rtypes.h:66
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
char name[80]
Definition: TGX11.cxx:110
R__EXTERN TMinuit * gMinuit
Definition: TMinuit.h:271
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition: TString.cxx:2452
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
Definition: TString.cxx:1504
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:71
bool isConstant() const
Check if the "Constant" attribute is set.
Definition: RooAbsArg.h:377
virtual void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true)
Interface function signaling a request to perform constant term optimization.
Definition: RooAbsArg.cxx:1831
@ DeActivate
Definition: RooAbsArg.h:403
@ ValueChange
Definition: RooAbsArg.h:403
@ ConfigChange
Definition: RooAbsArg.h:403
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.
bool empty() const
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.
static TClass * Class()
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...
Definition: RooAbsReal.h:62
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
virtual bool isOffsetting() const
Definition: RooAbsReal.h:369
virtual void enableOffsetting(bool)
Definition: RooAbsReal.h:368
static void setHideOffset(bool flag)
Definition: RooAbsReal.cxx:120
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.
Definition: RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition: RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
void fillCorrMatrix()
Internal utility method to extract the correlation matrix and the global correlation coefficients fro...
void setCovQual(Int_t val)
Definition: RooFitResult.h:172
void setMinNLL(double val)
Definition: RooFitResult.h:169
void setNumInvalidNLL(Int_t val)
Definition: RooFitResult.h:173
void setStatus(Int_t val)
Definition: RooFitResult.h:171
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)
Definition: RooFitResult.h:178
void setInitParList(const RooArgList &list)
Fill the list of initial values of the floating parameters.
void setEDM(double val)
Definition: RooFitResult.h:170
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...
Definition: RooMinuit.h:41
Int_t _numBadNLL
Definition: RooMinuit.h:122
Int_t hesse()
Execute HESSE.
Definition: RooMinuit.cxx:334
Int_t _nPar
Definition: RooMinuit.h:123
void setEps(double eps)
Change MINUIT epsilon.
Definition: RooMinuit.cxx:236
RooMinuit(RooAbsReal &function)
Construct MINUIT interface to given function.
Definition: RooMinuit.cxx:103
void setProfile(bool flag=true)
Definition: RooMinuit.h:76
Int_t _optConst
Definition: RooMinuit.h:119
RooArgList * _floatParamList
Definition: RooMinuit.h:127
Int_t _printEvalErrors
Definition: RooMinuit.h:124
void setOffsetting(bool flag)
Enable internal likelihood offsetting for enhanced numeric precision.
Definition: RooMinuit.cxx:246
~RooMinuit() override
Destructor.
Definition: RooMinuit.cxx:193
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
Definition: RooMinuit.cxx:833
bool synchronize(bool verbose)
Internal function to synchronize TMinuit with current information in RooAbsReal function parameters.
Definition: RooMinuit.cxx:609
bool _verbose
Definition: RooMinuit.h:136
virtual bool setPdfParamVal(Int_t index, double value, bool verbose=false)
Modify PDF parameter value by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1046
Int_t getNPar() const
Definition: RooMinuit.h:98
void setErrorLevel(double level)
Set the level for MINUIT error analysis to the given value.
Definition: RooMinuit.cxx:226
static void cleanup()
Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects wh...
Definition: RooMinuit.cxx:81
Int_t seek()
Execute SEEK.
Definition: RooMinuit.cxx:460
bool _doEvalErrorWall
Definition: RooMinuit.h:125
std::ofstream * _logfile
Definition: RooMinuit.h:135
Int_t simplex()
Execute SIMPLEX.
Definition: RooMinuit.cxx:493
TStopwatch _cumulTimer
Definition: RooMinuit.h:138
RooFitResult * save(const char *name=nullptr, const char *title=nullptr)
Save and return a RooFitResult snaphot of current minimizer status.
Definition: RooMinuit.cxx:865
bool _handleLocalErrors
Definition: RooMinuit.h:121
void saveStatus(const char *label, Int_t status)
Definition: RooMinuit.h:109
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
Definition: RooMinuit.cxx:212
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
Definition: RooMinuit.cxx:557
std::vector< std::pair< std::string, int > > _statusHistory
Definition: RooMinuit.h:144
Int_t _warnLevel
Definition: RooMinuit.h:117
std::vector< RooAbsArg * > _floatParamVec
Definition: RooMinuit.h:128
double _maxFCN
Definition: RooMinuit.h:134
Int_t migrad()
Execute MIGRAD.
Definition: RooMinuit.cxx:300
Int_t _printLevel
Definition: RooMinuit.h:116
std::ofstream * logfile() const
Definition: RooMinuit.h:99
bool setLogFile(const char *logfile=nullptr)
Change the file name for logging of a RooMinuit of all MINUIT steppings through the parameter space.
Definition: RooMinuit.cxx:1003
double getPdfParamVal(Int_t index)
Access PDF parameter value by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1026
Int_t setWarnLevel(Int_t newLevel)
Set MINUIT warning level to given level.
Definition: RooMinuit.cxx:583
void applyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
Definition: RooMinuit.cxx:1168
Int_t _status
Definition: RooMinuit.h:118
void backProp()
Transfer MINUIT fit results back into RooFit objects.
Definition: RooMinuit.cxx:1125
double getPdfParamErr(Int_t index)
Access PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1036
RooArgList * _initConstParamList
Definition: RooMinuit.h:131
double & maxFCN()
Definition: RooMinuit.h:100
void updateFloatVec()
Definition: RooMinuit.cxx:1151
bool _profile
Definition: RooMinuit.h:120
friend void RooMinuitGlue(Int_t &np, double *gin, double &f, double *par, Int_t flag)
Definition: RooMinuit.cxx:1188
RooArgList * _initFloatParamList
Definition: RooMinuit.h:129
void setPdfParamErr(Int_t index, double value)
Modify PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1065
void profileStop()
Stop profiling timer and report results of last session.
Definition: RooMinuit.cxx:1108
TMatrixDSym * _extV
Definition: RooMinuit.h:140
TStopwatch _timer
Definition: RooMinuit.h:137
Int_t minos()
Execute MINOS.
Definition: RooMinuit.cxx:367
void clearPdfParamAsymErr(Int_t index)
Modify PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1075
Int_t improve()
Execute IMPROVE.
Definition: RooMinuit.cxx:527
void profileStart()
Start profiling timer.
Definition: RooMinuit.cxx:1094
void setNoWarn()
Instruct MINUIT to suppress warnings.
Definition: RooMinuit.cxx:571
RooArgList * _constParamList
Definition: RooMinuit.h:130
void setVerbose(bool flag=true)
Definition: RooMinuit.h:75
Int_t _evalCounter
Definition: RooMinuit.h:115
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...
Definition: RooMinuit.cxx:931
RooFitResult * fit(const char *options)
Parse traditional RooAbsPdf::fitTo driver options.
Definition: RooMinuit.cxx:264
RooAbsReal * _func
Definition: RooMinuit.h:132
Int_t _maxEvalMult
Definition: RooMinuit.h:126
static TVirtualFitter * _theFitter
Definition: RooMinuit.h:142
static RooMsgService & instance()
Return reference to singleton instance.
A RooPlot is a 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:410
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
void setVal(double value) override
Set value of variable to 'value'.
Definition: RooRealVar.cxx:254
static TClass * Class()
double getError() const
Definition: RooRealVar.h:62
TClass * IsA() const override
Definition: RooRealVar.h:175
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
Definition: RooSentinel.cxx:54
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4863
<div class="legacybox"><h2>Legacy Code</h2> TFitter is a legacy interface: it is not recommended to u...
Definition: TFitter.h:19
A TGraph is an object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
Manages Markers.
Definition: TMarker.h:22
virtual Int_t SetErrorDef(Double_t up)
To get the n-sigma contour the error def parameter "up" has to set to n^2.
Definition: TMinuit.cxx:907
Double_t fUp
Definition: TMinuit.h:50
TString fCstatu
Definition: TMinuit.h:167
Int_t fNwrmes[2]
Definition: TMinuit.h:151
Int_t fNpfix
Definition: TMinuit.h:37
Int_t * fIpfix
Definition: TMinuit.h:129
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.
Definition: TMinuit.cxx:652
const char * GetName() const override
Returns name of object.
Definition: TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:363
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:146
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:58
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:77
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
Definition: TStopwatch.cxx:219
Basic string class.
Definition: TString.h:136
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1155
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
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
const Int_t n
Definition: legend1.C:16
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)
Definition: RExports.h:167
@ Minimization
Definition: RooGlobalFunc.h:63
static constexpr double eplus
Definition: first.py:1
Definition: graph.py:1