00001 /***************************************************************************** 00002 * Project: RooFit * 00003 * Package: RooFitCore * 00004 * @(#)root/roofitcore:$Id: RooMinimizerFcn.h 30408 2009-09-24 15:03:37Z wouter $ 00005 * Authors: * 00006 * AL, Alfio Lazzaro, INFN Milan, alfio.lazzaro@mi.infn.it * 00007 * * 00008 * * 00009 * Redistribution and use in source and binary forms, * 00010 * with or without modification, are permitted according to the terms * 00011 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) * 00012 *****************************************************************************/ 00013 00014 #ifndef __ROOFIT_NOROOMINIMIZER 00015 00016 #ifndef ROO_MINIMIZER_FCN 00017 #define ROO_MINIMIZER_FCN 00018 00019 #include "Math/IFunction.h" 00020 #include "Fit/ParameterSettings.h" 00021 #include "Fit/FitResult.h" 00022 00023 #include "TMatrixDSym.h" 00024 00025 #include "RooAbsReal.h" 00026 #include "RooArgList.h" 00027 00028 #include <iostream> 00029 #include <fstream> 00030 00031 class RooMinimizer; 00032 00033 class RooMinimizerFcn : public ROOT::Math::IBaseFunctionMultiDim { 00034 00035 public: 00036 00037 RooMinimizerFcn(RooAbsReal *funct, RooMinimizer *context, 00038 bool verbose = false); 00039 virtual ~RooMinimizerFcn(); 00040 00041 virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const; 00042 virtual unsigned int NDim() const { return _nDim; } 00043 00044 RooArgList* GetFloatParamList() { return _floatParamList; } 00045 RooArgList* GetConstParamList() { return _constParamList; } 00046 RooArgList* GetInitFloatParamList() { return _initFloatParamList; } 00047 RooArgList* GetInitConstParamList() { return _initConstParamList; } 00048 00049 void SetEvalErrorWall(Bool_t flag) { _doEvalErrorWall = flag ; } 00050 void SetPrintEvalErrors(Int_t numEvalErrors) { _printEvalErrors = numEvalErrors ; } 00051 Bool_t SetLogFile(const char* inLogfile); 00052 ofstream* GetLogFile() { return _logfile; } 00053 void SetVerbose(Bool_t flag=kTRUE) { _verbose = flag ; } 00054 00055 Double_t& GetMaxFCN() { return _maxFCN; } 00056 Int_t GetNumInvalidNLL() { return _numBadNLL; } 00057 00058 Bool_t Synchronize(std::vector<ROOT::Fit::ParameterSettings>& parameters, 00059 Bool_t optConst, Bool_t verbose); 00060 void BackProp(const ROOT::Fit::FitResult &results); 00061 void ApplyCovarianceMatrix(TMatrixDSym& V); 00062 00063 private: 00064 00065 Double_t GetPdfParamVal(Int_t index); 00066 Double_t GetPdfParamErr(Int_t index); 00067 void SetPdfParamErr(Int_t index, Double_t value); 00068 void ClearPdfParamAsymErr(Int_t index); 00069 void SetPdfParamErr(Int_t index, Double_t loVal, Double_t hiVal); 00070 00071 inline Bool_t SetPdfParamVal(const Int_t &index, const Double_t &value) const; 00072 00073 00074 virtual double DoEval(const double * x) const; 00075 00076 private: 00077 00078 RooAbsReal *_funct; 00079 RooMinimizer *_context; 00080 00081 mutable double _maxFCN; 00082 mutable int _numBadNLL; 00083 mutable int _printEvalErrors; 00084 Bool_t _doEvalErrorWall; 00085 00086 int _nDim; 00087 ofstream *_logfile; 00088 bool _verbose; 00089 00090 RooArgList* _floatParamList; 00091 RooArgList* _constParamList; 00092 RooArgList* _initFloatParamList; 00093 RooArgList* _initConstParamList; 00094 00095 }; 00096 00097 #endif 00098 #endif