FitConfig.h

Go to the documentation of this file.
00001 // @(#)root/mathcore:$Id: FitConfig.h 29513 2009-07-17 15:30:07Z moneta $
00002 // Author: L. Moneta Thu Sep 21 16:21:29 2006
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
00007  *                                                                    *
00008  *                                                                    *
00009  **********************************************************************/
00010 
00011 // Header file for class FitConfig
00012 
00013 #ifndef ROOT_Fit_FitConfig
00014 #define ROOT_Fit_FitConfig
00015 
00016 
00017 #ifndef ROOT_Fit_ParameterSettings
00018 #include "Fit/ParameterSettings.h"
00019 #endif
00020 
00021 #ifndef ROOT_Math_MinimizerOptions
00022 #include "Math/MinimizerOptions.h"
00023 #endif
00024 
00025 #ifndef ROOT_Math_IParamFunctionfwd
00026 #include "Math/IParamFunctionfwd.h"
00027 #endif
00028 
00029 
00030 #include <vector>
00031 
00032 namespace ROOT { 
00033 
00034    namespace Math { 
00035 
00036       class Minimizer;
00037       class MinimizerOptions; 
00038    }
00039 
00040    namespace Fit { 
00041 
00042 //___________________________________________________________________________________
00043 /** 
00044    Class describing the configuration of the fit, options and parameter settings
00045    using the ROOT::Fit::ParameterSettings class 
00046 
00047    @ingroup FitMain
00048 */ 
00049 class FitConfig {
00050 
00051 public: 
00052 
00053    /** 
00054       Default constructor
00055    */ 
00056    FitConfig (unsigned int npar = 0); 
00057 
00058 
00059    /*
00060      Copy constructor 
00061     */
00062    FitConfig(const FitConfig & rhs);
00063 
00064    /** 
00065       Destructor 
00066    */ 
00067    ~FitConfig ();  
00068 
00069    /*
00070      Assignment operator 
00071    */
00072    FitConfig & operator= (const FitConfig & rhs);
00073 
00074 
00075    /**
00076       get the parameter settings for the i-th parameter (const method)
00077    */
00078    const ParameterSettings & ParSettings(unsigned int i) const { return fSettings.at(i); }
00079 
00080    /**
00081       get the parameter settings for the i-th parameter (non-const method)
00082    */
00083    ParameterSettings & ParSettings(unsigned int i) { return fSettings.at(i); }
00084 
00085    /**
00086       get the vector of parameter settings  (const method)
00087    */
00088    const std::vector<ROOT::Fit::ParameterSettings> & ParamsSettings() const { return fSettings; }
00089 
00090    /**
00091       get the vector of parameter settings  (non-const method)
00092    */
00093    std::vector<ROOT::Fit::ParameterSettings> & ParamsSettings() { return fSettings; }
00094 
00095 
00096    /**
00097       set the parameter settings from a model function. 
00098       Create always new parameter setting list from a given model function  
00099    */
00100    void CreateParamsSettings(const ROOT::Math::IParamMultiFunction & func); 
00101 
00102    /**
00103       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. 
00104    */
00105    void SetParamsSettings(unsigned int npar, const double * params, const double * vstep = 0); 
00106 
00107 
00108    /**
00109       create a new minimizer according to chosen configuration
00110    */
00111    ROOT::Math::Minimizer * CreateMinimizer(); 
00112 
00113 
00114 
00115    /**
00116       access to the minimizer  control parameter (non const method) 
00117    */
00118    ROOT::Math::MinimizerOptions & MinimizerOptions()  { return fMinimizerOpts; } 
00119 
00120 
00121 #ifndef __CINT__   // this method fails on Windows
00122    /**
00123       set all the minimizer options using class MinimizerOptions
00124     */
00125    void SetMinimizerOptions(const ROOT::Math::MinimizerOptions & minopt); 
00126 #endif
00127 
00128    
00129    /**
00130       set minimizer type 
00131    */
00132    void SetMinimizer(const char * type, const char * algo = 0) { 
00133       if (type) fMinimizerOpts.SetMinimizerType(type); 
00134       if (algo) fMinimizerOpts.SetMinimizerAlgorithm(algo); 
00135    } 
00136 
00137    /**
00138       return type of minimizer package
00139    */
00140    const std::string & MinimizerType() const { return fMinimizerOpts.MinimizerType(); } 
00141 
00142    /**
00143       return type of minimizer algorithms 
00144    */
00145    const std::string & MinimizerAlgoType() const { return fMinimizerOpts.MinimizerAlgorithm(); }  
00146 
00147 
00148    /**
00149       flag to check if resulting errors are be normalized according to chi2/ndf 
00150    */
00151    bool NormalizeErrors() const { return fNormErrors; } 
00152 
00153    ///do analysis for parabolic errors
00154    bool ParabErrors() const { return fParabErrors; }
00155 
00156    ///do minos errros analysis on the  parameters
00157    bool MinosErrors() const { return fMinosErrors; }
00158 
00159    /// return vector of parameter indeces for which the Minos Error will be computed
00160    const std::vector<unsigned int> & MinosParams() const { return fMinosParams; }
00161 
00162    /**
00163       set the option to normalize the error on the result  according to chi2/ndf
00164    */
00165    void SetNormErrors(bool on = true) { fNormErrors= on; }
00166 
00167    ///set parabolic erros
00168    void SetParabErrors(bool on = true) { fParabErrors = on; } 
00169 
00170    ///set Minos erros
00171    void SetMinosErrors(bool on = true) { fMinosErrors = on; } 
00172 
00173    /// set parameter indeces for running Minos
00174    /// this can be used for running Minos on a subset of parameters - otherwise is run on all of them 
00175    /// if MinosErrors() is set 
00176    void SetMinosErrors(const std::vector<unsigned int> & paramInd ) { 
00177       fMinosErrors = true; 
00178       fMinosParams = paramInd; 
00179    }
00180 
00181 
00182 
00183    /**
00184       static function to control default minimizer type and algorithm
00185    */
00186    static void SetDefaultMinimizer(const char * type, const char * algo = 0); 
00187 
00188 
00189 protected: 
00190 
00191 
00192 private: 
00193 
00194    bool fNormErrors;    // flag for error normalization
00195    bool fParabErrors;   // get correct parabolic errors estimate (call Hesse after minimizing)  
00196    bool fMinosErrors;   // do full error analysis using Minos
00197 
00198 
00199    std::vector<ROOT::Fit::ParameterSettings> fSettings;  // vector with the parameter settings
00200    std::vector<unsigned int> fMinosParams;               // vector with the parameter indeces for running Minos
00201 
00202    ROOT::Math::MinimizerOptions fMinimizerOpts;   //minimizer control parameters including name and algo type
00203 
00204 }; 
00205 
00206    } // end namespace Fit
00207 
00208 } // end namespace ROOT
00209 
00210 
00211 #endif /* ROOT_Fit_FitConfig */

Generated on Tue Jul 5 14:24:59 2011 for ROOT_528-00b_version by  doxygen 1.5.1