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