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