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