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