[root] / trunk / math / mathcore / inc / Fit / ParameterSettings.h Repository:
ViewVC logotype

View of /trunk/math/mathcore/inc/Fit/ParameterSettings.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25486 - (download) (as text) (annotate)
Mon Sep 22 12:43:03 2008 UTC (6 years, 4 months ago) by moneta
File size: 5646 byte(s)
import changes from math development branches for subdirectory math. List of changes in detail: 

mathcore: 
---------
  MinimizerOptions: 
	new  class for storing Minimizer option, with static default values that can be 
	changed by the user

  FitConfig: 
   	- use default values from MinimizerOption class
   	- rename method to create parameter settings from a function

  FitUtil.cxx:   
    	improve the derivative calculations used in the effective chi2 and in Fumili and 
	fix a bug for evaluation of likelihood or chi2 terms. 
	In  EvaluatePdf() work and return  the log of the pdf. 
      
  FitResult:
	- improve the class by adding extra information like, num. of free parameters, 
	minimizer status, global correlation coefficients, information about fixed 
	and bound parameters. 
   	- add method for getting fit confidence intervals 
  	- improve print method   

  DataRange: 
	add method SetRange to distinguish from AddRange. SetRange deletes the existing 
	ranges. 

  ParamsSettings: make few methods const

  FCN functions (Chi2FCN, LogLikelihoodFCN, etc..) 
	move some common methods and data members in base class (FitMethodFunction)

  RootFinder: add template Solve() for any callable function.  

mathmore:
--------
  minimizer classes: fill status information
  GSLNLSMinimizer: return error and covariance matrix 

minuit2: 
-------
  Minuit2Minimizer: fill  status information 
  DavidonErrorUpdator: check that delgam or gvg are not zero ( can happen when dg = 0)
  FumiliFCNAdapter: work on the log of pdf

minuit:
------- 
  TLinearMinimizer: add support for robust fitting
  TMinuitMinimizer: fill status information and fix a bug in filling the correlation matrix. 
 fumili:
 ------ 
  add TFumiliMinimizer: 
	wrapper class for TFumili using Minimizer interface

// @(#)root/mathcore:$Id$
// Author: L. Moneta Thu Sep 21 16:21:48 2006

/**********************************************************************
 *                                                                    *
 * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
 *                                                                    *
 *                                                                    *
 **********************************************************************/

// Header file for class ParameterSettings

#ifndef ROOT_Fit_ParameterSettings
#define ROOT_Fit_ParameterSettings

#include <string>

namespace ROOT { 

   namespace Fit { 


//___________________________________________________________________________________
/** 
   Class, describing value, limits and step size of the parameters 
   Provides functionality also to set/retrieve values, step sizes, limits and fix the 
   parameters. 

   To be done: add constraints (equality and inequality) as functions of the parameters

   @ingroup FitMain
*/ 
class ParameterSettings {

public: 

   /** 
      Default constructor
   */ 
   ParameterSettings () :  
    fValue(0.), fStepSize(0.1), fFix(false), 
    fLowerLimit(0.), fUpperLimit(0.), fHasLowerLimit(false), fHasUpperLimit(false), 
    fName("") 
   {}

  
  ///constructor for unlimited named Parameter
   ParameterSettings(const std::string & name, double val, double err) :
    fValue(val), fStepSize(err), fFix(false), 
    fLowerLimit(0.), fUpperLimit(0.), fHasLowerLimit(false), fHasUpperLimit(false), 
    fName(name) 
   {}
  
   ///constructor for double limited Parameter
   ParameterSettings(const std::string &  name, double val, double err, 
		  double min, double max) : 
      fValue(val), fStepSize(err), fFix(false), fName(name) 
   { 
      SetLimits(min,max); 
   }

   ///constructor for fixed Parameter
   ParameterSettings(const std::string &  name, double val) : 
    fValue(val), fStepSize(0), fFix(true), 
    fLowerLimit(0.), fUpperLimit(0.), fHasLowerLimit(false), fHasUpperLimit(false), 
    fName(name)  
   {}




   /// set value and name (unlimited parameter) 
   void Set(const std::string & name, double value, double step) { 
      SetName(name); 
      SetValue(value); 
      SetStepSize(step);
   }

   /// set a limited parameter
   void Set(const std::string & name, double value, double step, double lower, double upper ) { 
      SetName(name); 
      SetValue(value); 
      SetStepSize(step);
      SetLimits(lower,upper);  
   }

   /// set a fixed parameter
   void Set(const std::string & name, double value) { 
      SetName(name); 
      SetValue(value); 
      Fix();
   }


   /** 
      Destructor (no operations)
   */ 
   ~ParameterSettings ()  {}  

   /// copy constructor and assignment operators (leave them to the compiler) 

public: 

   /// return parameter value
   double Value() const { return fValue; } 
   /// return step size 
   double StepSize() const { return fStepSize; } 
   /// return lower limit value
   double LowerLimit() const {return fLowerLimit;}
   /// return lower limit value
   double UpperLimit() const {return fUpperLimit;}
   /// check if is fixed 
   bool IsFixed() const { return fFix; }
   /// check if parameter has lower limit
   bool HasLowerLimit() const {return fHasLowerLimit; }
   /// check if parameter has upper limit
   bool HasUpperLimit() const {return fHasUpperLimit; }
   /// check if is bound
   bool IsBound() const { return fHasLowerLimit || fHasUpperLimit;  } 
   /// check if is double bound (upper AND lower limit) 
   bool IsDoubleBound() const { return fHasLowerLimit && fHasUpperLimit;  } 
   /// return name 
   const std::string & Name() const { return fName; }  

   /** interaction **/

   /// set name
   void SetName(const std::string & name ) { fName = name; }

   /// fix  the parameter
   void Fix() {fFix = true;}
   /// release the parameter
   void Release() {fFix = false;}
   /// set the value
   void SetValue(double val) {fValue = val;}
   /// set the step size 
   void SetStepSize(double err) {fStepSize = err;}
   /// set a double side limit, 
   /// if low == up the parameter is fixedm if low > up the limits are removed
   void SetLimits(double low, double up) {
      if (low == up) { 
         Fix();           
         return; 
      }
      else if ( low > up ) { 
         RemoveLimits(); 
         return; 
      }
      fLowerLimit = low; 
      fUpperLimit = up;
      fHasLowerLimit = true; 
      fHasUpperLimit = true;
   }
   /// set a single upper limit
   void SetUpperLimit(double up) {
    fLowerLimit = 0.; 
    fUpperLimit = up;
    fHasLowerLimit = false; 
    fHasUpperLimit = true;
   }
   /// set a single lower limit 
   void SetLowerLimit(double low) {
      fLowerLimit = low; 
      fUpperLimit = 0.;
      fHasLowerLimit = true; 
      fHasUpperLimit = false;
   }

   /// remove all limit
   void RemoveLimits() {
      fLowerLimit = 0.; 
      fUpperLimit = 0.;
      fHasLowerLimit = false; 
      fHasUpperLimit = false;
   }
  
      

protected: 


private: 

   double fValue;        // parameter value
   double fStepSize;     // parameter step size (used by minimizer)
   bool fFix;            // flag to control if parameter is fixed 
   double fLowerLimit;   // lower parameter limit
   double fUpperLimit;   // upper parameter limit
   bool fHasLowerLimit;  // flag to control lower parameter limit
   bool fHasUpperLimit;  // flag to control upper parameter limit

   std::string fName;    // parameter name

}; 

   } // end namespace Fit

} // end namespace ROOT


#endif /* ROOT_Fit_ParameterSettings */

Subversion Admin
ViewVC Help
Powered by ViewVC 1.0.9