Logo ROOT   6.08/07
Reference Guide
FitConfig.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: L. Moneta Thu Sep 21 16:21:29 2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class FitConfig
12 
13 #ifndef ROOT_Fit_FitConfig
14 #define ROOT_Fit_FitConfig
15 
16 
17 #ifndef ROOT_Fit_ParameterSettings
18 #include "Fit/ParameterSettings.h"
19 #endif
20 
21 #ifndef ROOT_Math_MinimizerOptions
22 #include "Math/MinimizerOptions.h"
23 #endif
24 
25 #ifndef ROOT_Math_IParamFunctionfwd
26 #include "Math/IParamFunctionfwd.h"
27 #endif
28 
29 
30 #include <vector>
31 
32 namespace ROOT {
33 
34  namespace Math {
35 
36  class Minimizer;
37  class MinimizerOptions;
38  }
39 
40  namespace Fit {
41 
42  class FitResult;
43 
44 //___________________________________________________________________________________
45 /**
46  Class describing the configuration of the fit, options and parameter settings
47  using the ROOT::Fit::ParameterSettings class
48 
49  @ingroup FitMain
50 */
51 class FitConfig {
52 
53 public:
54 
55  /**
56  Default constructor
57  */
58  FitConfig (unsigned int npar = 0);
59 
60 
61  /*
62  Copy constructor
63  */
64  FitConfig(const FitConfig & rhs);
65 
66  /**
67  Destructor
68  */
69  ~FitConfig ();
70 
71  /*
72  Assignment operator
73  */
74  FitConfig & operator= (const FitConfig & rhs);
75 
76 
77  /**
78  get the parameter settings for the i-th parameter (const method)
79  */
80  const ParameterSettings & ParSettings(unsigned int i) const { return fSettings.at(i); }
81 
82  /**
83  get the parameter settings for the i-th parameter (non-const method)
84  */
85  ParameterSettings & ParSettings(unsigned int i) { return fSettings.at(i); }
86 
87  /**
88  get the vector of parameter settings (const method)
89  */
90  const std::vector<ROOT::Fit::ParameterSettings> & ParamsSettings() const { return fSettings; }
91 
92  /**
93  get the vector of parameter settings (non-const method)
94  */
95  std::vector<ROOT::Fit::ParameterSettings> & ParamsSettings() { return fSettings; }
96 
97  /**
98  number of parameters settings
99  */
100  unsigned int NPar() const { return fSettings.size(); }
101 
102  /**
103  set the parameter settings from a model function.
104  Create always new parameter setting list from a given model function
105  */
106  void CreateParamsSettings(const ROOT::Math::IParamMultiFunction & func);
107 
108  /**
109  set the parameter settings from number of parameters and a vector of values and optionally step values. If there are not existing or number of parameters does not match existing one, create a new parameter setting list.
110  */
111  void SetParamsSettings(unsigned int npar, const double * params, const double * vstep = 0);
112 
113  /*
114  Set the parameter settings from a vector of parameter settings
115  */
116  void SetParamsSettings (const std::vector<ROOT::Fit::ParameterSettings>& pars ) {
117  fSettings = pars;
118  }
119 
120 
121  /*
122  Set the parameter settings from a fit Result
123  */
124  void SetFromFitResult (const FitResult & rhs);
125 
126 
127 
128  /**
129  create a new minimizer according to chosen configuration
130  */
131  ROOT::Math::Minimizer * CreateMinimizer();
132 
133 
134 
135  /**
136  access to the minimizer control parameter (non const method)
137  */
138  ROOT::Math::MinimizerOptions & MinimizerOptions() { return fMinimizerOpts; }
139 
140 
141 #ifndef __CINT__ // this method fails on Windows
142  /**
143  set all the minimizer options using class MinimizerOptions
144  */
145  void SetMinimizerOptions(const ROOT::Math::MinimizerOptions & minopt);
146 #endif
147 
148 
149  /**
150  set minimizer type
151  */
152  void SetMinimizer(const char * type, const char * algo = 0) {
153  if (type) fMinimizerOpts.SetMinimizerType(type);
154  if (algo) fMinimizerOpts.SetMinimizerAlgorithm(algo);
155  }
156 
157  /**
158  return type of minimizer package
159  */
160  const std::string & MinimizerType() const { return fMinimizerOpts.MinimizerType(); }
161 
162  /**
163  return type of minimizer algorithms
164  */
165  const std::string & MinimizerAlgoType() const { return fMinimizerOpts.MinimizerAlgorithm(); }
166 
167 
168  /**
169  flag to check if resulting errors are be normalized according to chi2/ndf
170  */
171  bool NormalizeErrors() const { return fNormErrors; }
172 
173  ///do analysis for parabolic errors
174  bool ParabErrors() const { return fParabErrors; }
175 
176  ///do minos errros analysis on the parameters
177  bool MinosErrors() const { return fMinosErrors; }
178 
179  ///Update configuration after a fit using the FitResult
180  bool UpdateAfterFit() const { return fUpdateAfterFit; }
181 
182  ///Apply Weight correction for error matrix computation
183  bool UseWeightCorrection() const { return fWeightCorr; }
184 
185 
186  /// return vector of parameter indeces for which the Minos Error will be computed
187  const std::vector<unsigned int> & MinosParams() const { return fMinosParams; }
188 
189  /**
190  set the option to normalize the error on the result according to chi2/ndf
191  */
192  void SetNormErrors(bool on = true) { fNormErrors= on; }
193 
194  ///set parabolic erros
195  void SetParabErrors(bool on = true) { fParabErrors = on; }
196 
197  ///set Minos erros computation to be performed after fitting
198  void SetMinosErrors(bool on = true) { fMinosErrors = on; }
199 
200  ///apply the weight correction for error matric computation
201  void SetWeightCorrection(bool on = true) { fWeightCorr = on; }
202 
203  /// set parameter indeces for running Minos
204  /// this can be used for running Minos on a subset of parameters - otherwise is run on all of them
205  /// if MinosErrors() is set
206  void SetMinosErrors(const std::vector<unsigned int> & paramInd ) {
207  fMinosErrors = true;
208  fMinosParams = paramInd;
209  }
210 
211  ///Update configuration after a fit using the FitResult
212  void SetUpdateAfterFit(bool on = true) { fUpdateAfterFit = on; }
213 
214 
215  /**
216  static function to control default minimizer type and algorithm
217  */
218  static void SetDefaultMinimizer(const char * type, const char * algo = 0);
219 
220 
221 
222 
223 protected:
224 
225 
226 private:
227 
228  bool fNormErrors; // flag for error normalization
229  bool fParabErrors; // get correct parabolic errors estimate (call Hesse after minimizing)
230  bool fMinosErrors; // do full error analysis using Minos
231  bool fUpdateAfterFit; // update the configuration after a fit using the result
232  bool fWeightCorr; // apply correction to errors for weights fits
233 
234  std::vector<ROOT::Fit::ParameterSettings> fSettings; // vector with the parameter settings
235  std::vector<unsigned int> fMinosParams; // vector with the parameter indeces for running Minos
236 
237  ROOT::Math::MinimizerOptions fMinimizerOpts; //minimizer control parameters including name and algo type
238 
239 };
240 
241  } // end namespace Fit
242 
243 } // end namespace ROOT
244 
245 
246 #endif /* ROOT_Fit_FitConfig */
void SetMinosErrors(const std::vector< unsigned int > &paramInd)
set parameter indeces for running Minos this can be used for running Minos on a subset of parameters ...
Definition: FitConfig.h:206
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
void SetUpdateAfterFit(bool on=true)
Update configuration after a fit using the FitResult.
Definition: FitConfig.h:212
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
bool NormalizeErrors() const
flag to check if resulting errors are be normalized according to chi2/ndf
Definition: FitConfig.h:171
const std::vector< unsigned int > & MinosParams() const
return vector of parameter indeces for which the Minos Error will be computed
Definition: FitConfig.h:187
unsigned int NPar() const
number of parameters settings
Definition: FitConfig.h:100
ROOT::Math::MinimizerOptions fMinimizerOpts
Definition: FitConfig.h:237
ROOT::Math::MinimizerOptions & MinimizerOptions()
access to the minimizer control parameter (non const method)
Definition: FitConfig.h:138
const ParameterSettings & ParSettings(unsigned int i) const
get the parameter settings for the i-th parameter (const method)
Definition: FitConfig.h:80
bool UseWeightCorrection() const
Apply Weight correction for error matrix computation.
Definition: FitConfig.h:183
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2, Minuit, GSL, etc..) Plug-in&#39;s exist in ROOT to be able to instantiate the derived classes like ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the plug-in manager.
Definition: Minimizer.h:86
bool UpdateAfterFit() const
Update configuration after a fit using the FitResult.
Definition: FitConfig.h:180
bool ParabErrors() const
do analysis for parabolic errors
Definition: FitConfig.h:174
ParameterSettings & ParSettings(unsigned int i)
get the parameter settings for the i-th parameter (non-const method)
Definition: FitConfig.h:85
void SetMinosErrors(bool on=true)
set Minos erros computation to be performed after fitting
Definition: FitConfig.h:198
void SetMinimizer(const char *type, const char *algo=0)
set minimizer type
Definition: FitConfig.h:152
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
RooCmdArg Minimizer(const char *type, const char *alg=0)
const std::vector< ROOT::Fit::ParameterSettings > & ParamsSettings() const
get the vector of parameter settings (const method)
Definition: FitConfig.h:90
class containg the result of the fit and all the related information (fitted parameter values...
Definition: FitResult.h:52
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:134
int type
Definition: TGX11.cxx:120
void SetWeightCorrection(bool on=true)
apply the weight correction for error matric computation
Definition: FitConfig.h:201
const std::string & MinimizerType() const
return type of minimizer package
Definition: FitConfig.h:160
double func(double *x, double *p)
Definition: stressTF1.cxx:213
std::vector< ROOT::Fit::ParameterSettings > & ParamsSettings()
get the vector of parameter settings (non-const method)
Definition: FitConfig.h:95
Namespace for new Math classes and functions.
bool MinosErrors() const
do minos errros analysis on the parameters
Definition: FitConfig.h:177
void SetParamsSettings(const std::vector< ROOT::Fit::ParameterSettings > &pars)
Definition: FitConfig.h:116
void SetNormErrors(bool on=true)
set the option to normalize the error on the result according to chi2/ndf
Definition: FitConfig.h:192
std::vector< ROOT::Fit::ParameterSettings > fSettings
Definition: FitConfig.h:234
void SetParabErrors(bool on=true)
set parabolic erros
Definition: FitConfig.h:195
std::vector< unsigned int > fMinosParams
Definition: FitConfig.h:235
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
Definition: FitConfig.h:51
const std::string & MinimizerAlgoType() const
return type of minimizer algorithms
Definition: FitConfig.h:165