Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RooMinimizerFcn.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * AL, Alfio Lazzaro, INFN Milan, alfio.lazzaro@mi.infn.it *
7  * *
8  * *
9  * Redistribution and use in source and binary forms, *
10  * with or without modification, are permitted according to the terms *
11  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
12  *****************************************************************************/
13 
14 #ifndef __ROOFIT_NOROOMINIMIZER
15 
16 #ifndef ROO_MINIMIZER_FCN
17 #define ROO_MINIMIZER_FCN
18 
19 #include "Math/IFunction.h"
20 #include "Fit/ParameterSettings.h"
21 #include "Fit/FitResult.h"
22 
23 #include "TMatrixDSym.h"
24 
25 #include "RooAbsReal.h"
26 #include "RooArgList.h"
27 
28 #include <iostream>
29 #include <fstream>
30 
31 class RooMinimizer;
32 
33 class RooMinimizerFcn : public ROOT::Math::IBaseFunctionMultiDim {
34 
35  public:
36 
37  RooMinimizerFcn(RooAbsReal *funct, RooMinimizer *context,
38  bool verbose = false);
39  RooMinimizerFcn(const RooMinimizerFcn& other);
40  virtual ~RooMinimizerFcn();
41 
42  virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const;
43  virtual unsigned int NDim() const { return _nDim; }
44 
45  RooArgList* GetFloatParamList() { return _floatParamList; }
46  RooArgList* GetConstParamList() { return _constParamList; }
47  RooArgList* GetInitFloatParamList() { return _initFloatParamList; }
48  RooArgList* GetInitConstParamList() { return _initConstParamList; }
49 
50  void SetEvalErrorWall(Bool_t flag) { _doEvalErrorWall = flag ; }
51  void SetPrintEvalErrors(Int_t numEvalErrors) { _printEvalErrors = numEvalErrors ; }
52  Bool_t SetLogFile(const char* inLogfile);
53  std::ofstream* GetLogFile() { return _logfile; }
54  void SetVerbose(Bool_t flag=kTRUE) { _verbose = flag ; }
55 
56  Double_t& GetMaxFCN() { return _maxFCN; }
57  Int_t GetNumInvalidNLL() { return _numBadNLL; }
58 
59  Bool_t Synchronize(std::vector<ROOT::Fit::ParameterSettings>& parameters,
60  Bool_t optConst, Bool_t verbose);
61  void BackProp(const ROOT::Fit::FitResult &results);
62  void ApplyCovarianceMatrix(TMatrixDSym& V);
63 
64  Int_t evalCounter() const { return _evalCounter ; }
65  void zeroEvalCount() { _evalCounter = 0 ; }
66 
67 
68  private:
69 
70  Double_t GetPdfParamVal(Int_t index);
71  Double_t GetPdfParamErr(Int_t index);
72  void SetPdfParamErr(Int_t index, Double_t value);
73  void ClearPdfParamAsymErr(Int_t index);
74  void SetPdfParamErr(Int_t index, Double_t loVal, Double_t hiVal);
75 
76  inline Bool_t SetPdfParamVal(const Int_t &index, const Double_t &value) const;
77 
78 
79  virtual double DoEval(const double * x) const;
80  void updateFloatVec() ;
81 
82 private:
83 
84  mutable Int_t _evalCounter ;
85 
86  RooAbsReal *_funct;
87  RooMinimizer *_context;
88 
89  mutable double _maxFCN;
90  mutable int _numBadNLL;
91  mutable int _printEvalErrors;
92  Bool_t _doEvalErrorWall;
93 
94  int _nDim;
95  std::ofstream *_logfile;
96  bool _verbose;
97 
98  RooArgList* _floatParamList;
99  std::vector<RooAbsArg*> _floatParamVec ;
100  RooArgList* _constParamList;
101  RooArgList* _initFloatParamList;
102  RooArgList* _initConstParamList;
103 
104 };
105 
106 #endif
107 #endif