ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       * 
 * @(#)root/roofitcore:$Id: RooMinimizerFcn.h 30408 2009-09-24 15:03:37Z wouter $
 * Authors:                                                                  *
 *   AL, Alfio Lazzaro,   INFN Milan,        alfio.lazzaro@mi.infn.it        *
 *                                                                           *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/

#ifndef __ROOFIT_NOROOMINIMIZER

#ifndef ROO_MINIMIZER_FCN
#define ROO_MINIMIZER_FCN

#include "Math/IFunction.h"
#include "Fit/ParameterSettings.h"
#include "Fit/FitResult.h"

#include "TMatrixDSym.h"

#include "RooAbsReal.h"
#include "RooArgList.h"

#include <iostream>
#include <fstream>

class RooMinimizer;

class RooMinimizerFcn : public ROOT::Math::IBaseFunctionMultiDim {

 public:

  RooMinimizerFcn(RooAbsReal *funct, RooMinimizer *context, 
	       bool verbose = false);
  virtual ~RooMinimizerFcn();

  virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const;
  virtual unsigned int NDim() const { return _nDim; }

  RooArgList* GetFloatParamList() { return _floatParamList; }
  RooArgList* GetConstParamList() { return _constParamList; }
  RooArgList* GetInitFloatParamList() { return _initFloatParamList; }
  RooArgList* GetInitConstParamList() { return _initConstParamList; }

  void SetEvalErrorWall(Bool_t flag) { _doEvalErrorWall = flag ; }
  void SetPrintEvalErrors(Int_t numEvalErrors) { _printEvalErrors = numEvalErrors ; }
  Bool_t SetLogFile(const char* inLogfile);
  ofstream* GetLogFile() { return _logfile; }
  void SetVerbose(Bool_t flag=kTRUE) { _verbose = flag ; }

  Double_t& GetMaxFCN() { return _maxFCN; }
  Int_t GetNumInvalidNLL() { return _numBadNLL; }

  Bool_t Synchronize(std::vector<ROOT::Fit::ParameterSettings>& parameters, 
		     Bool_t optConst, Bool_t verbose);
  void BackProp(const ROOT::Fit::FitResult &results);  
  void ApplyCovarianceMatrix(TMatrixDSym& V); 

 private:
  
  Double_t GetPdfParamVal(Int_t index);
  Double_t GetPdfParamErr(Int_t index);
  void SetPdfParamErr(Int_t index, Double_t value);
  void ClearPdfParamAsymErr(Int_t index);
  void SetPdfParamErr(Int_t index, Double_t loVal, Double_t hiVal);

  inline Bool_t SetPdfParamVal(const Int_t &index, const Double_t &value) const;


  virtual double DoEval(const double * x) const;  

private:
  
  RooAbsReal *_funct;
  RooMinimizer *_context;

  mutable double _maxFCN;
  mutable int _numBadNLL;
  mutable int _printEvalErrors;
  Bool_t _doEvalErrorWall;

  int _nDim;
  ofstream *_logfile;
  bool _verbose;

  RooArgList* _floatParamList;
  RooArgList* _constParamList;
  RooArgList* _initFloatParamList;
  RooArgList* _initConstParamList;

};

#endif
#endif
 RooMinimizerFcn.h:1
 RooMinimizerFcn.h:2
 RooMinimizerFcn.h:3
 RooMinimizerFcn.h:4
 RooMinimizerFcn.h:5
 RooMinimizerFcn.h:6
 RooMinimizerFcn.h:7
 RooMinimizerFcn.h:8
 RooMinimizerFcn.h:9
 RooMinimizerFcn.h:10
 RooMinimizerFcn.h:11
 RooMinimizerFcn.h:12
 RooMinimizerFcn.h:13
 RooMinimizerFcn.h:14
 RooMinimizerFcn.h:15
 RooMinimizerFcn.h:16
 RooMinimizerFcn.h:17
 RooMinimizerFcn.h:18
 RooMinimizerFcn.h:19
 RooMinimizerFcn.h:20
 RooMinimizerFcn.h:21
 RooMinimizerFcn.h:22
 RooMinimizerFcn.h:23
 RooMinimizerFcn.h:24
 RooMinimizerFcn.h:25
 RooMinimizerFcn.h:26
 RooMinimizerFcn.h:27
 RooMinimizerFcn.h:28
 RooMinimizerFcn.h:29
 RooMinimizerFcn.h:30
 RooMinimizerFcn.h:31
 RooMinimizerFcn.h:32
 RooMinimizerFcn.h:33
 RooMinimizerFcn.h:34
 RooMinimizerFcn.h:35
 RooMinimizerFcn.h:36
 RooMinimizerFcn.h:37
 RooMinimizerFcn.h:38
 RooMinimizerFcn.h:39
 RooMinimizerFcn.h:40
 RooMinimizerFcn.h:41
 RooMinimizerFcn.h:42
 RooMinimizerFcn.h:43
 RooMinimizerFcn.h:44
 RooMinimizerFcn.h:45
 RooMinimizerFcn.h:46
 RooMinimizerFcn.h:47
 RooMinimizerFcn.h:48
 RooMinimizerFcn.h:49
 RooMinimizerFcn.h:50
 RooMinimizerFcn.h:51
 RooMinimizerFcn.h:52
 RooMinimizerFcn.h:53
 RooMinimizerFcn.h:54
 RooMinimizerFcn.h:55
 RooMinimizerFcn.h:56
 RooMinimizerFcn.h:57
 RooMinimizerFcn.h:58
 RooMinimizerFcn.h:59
 RooMinimizerFcn.h:60
 RooMinimizerFcn.h:61
 RooMinimizerFcn.h:62
 RooMinimizerFcn.h:63
 RooMinimizerFcn.h:64
 RooMinimizerFcn.h:65
 RooMinimizerFcn.h:66
 RooMinimizerFcn.h:67
 RooMinimizerFcn.h:68
 RooMinimizerFcn.h:69
 RooMinimizerFcn.h:70
 RooMinimizerFcn.h:71
 RooMinimizerFcn.h:72
 RooMinimizerFcn.h:73
 RooMinimizerFcn.h:74
 RooMinimizerFcn.h:75
 RooMinimizerFcn.h:76
 RooMinimizerFcn.h:77
 RooMinimizerFcn.h:78
 RooMinimizerFcn.h:79
 RooMinimizerFcn.h:80
 RooMinimizerFcn.h:81
 RooMinimizerFcn.h:82
 RooMinimizerFcn.h:83
 RooMinimizerFcn.h:84
 RooMinimizerFcn.h:85
 RooMinimizerFcn.h:86
 RooMinimizerFcn.h:87
 RooMinimizerFcn.h:88
 RooMinimizerFcn.h:89
 RooMinimizerFcn.h:90
 RooMinimizerFcn.h:91
 RooMinimizerFcn.h:92
 RooMinimizerFcn.h:93
 RooMinimizerFcn.h:94
 RooMinimizerFcn.h:95
 RooMinimizerFcn.h:96
 RooMinimizerFcn.h:97
 RooMinimizerFcn.h:98