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