00001 /*************************************************************************** 00002 * GModelPar.hpp - Model parameter class * 00003 * ----------------------------------------------------------------------- * 00004 * copyright (C) 2009-2014 by Juergen Knoedlseder * 00005 * ----------------------------------------------------------------------- * 00006 * * 00007 * This program is free software: you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation, either version 3 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 00019 * * 00020 ***************************************************************************/ 00021 /** 00022 * @file GModelPar.hpp 00023 * @brief Model parameter class interface definition 00024 * @author Juergen Knoedlseder 00025 */ 00026 00027 #ifndef GMODELPAR_HPP 00028 #define GMODELPAR_HPP 00029 00030 /* __ Includes ___________________________________________________________ */ 00031 #include <string> 00032 #include "GOptimizerPar.hpp" 00033 #include "GXmlElement.hpp" 00034 00035 00036 /***********************************************************************//** 00037 * @class GModelPar 00038 * 00039 * @brief Model parameter class 00040 * 00041 * This class implements a model parameter. A model parameter is a numerical 00042 * value that is used to describe a model. A model parameter has the 00043 * following attributes: 00044 * - @p value gives the numerical value of the parameter 00045 * - @p error gives the statistical uncertainty in the parameter value 00046 * - @p gradient gives the gradient of a the model with respect to the 00047 * parameter 00048 * - @p min gives the minimum value that the parameter value can take 00049 * - @p max gives the maximum value that the parameter value can take 00050 * 00051 * The parameter attributes are set and retrieved using the value(), 00052 * error(), gradient(), min() and max() methods, respectively. Furthermore, 00053 * the range() method is used to simultaneously set the minimum and maximum 00054 * value of a parameter. 00055 * 00056 * The minimum and maximum values are optional, and existence of these 00057 * attributes is tested using the has_min() and has_max() methods, 00058 * respectively. The minimum value, maximum value are removed using the 00059 * remove_min() and remove_max() methods. Simultaneous removal of minimum 00060 * and maximum values is done using the remove_range() method. 00061 * 00062 * Each parameter has furthermore the following properties: 00063 * - @p free specifies whether the parameter should be fitted 00064 * - @p grad specifies whether the parameter gradient is computed 00065 * analytically (true) or numerically (false) 00066 * 00067 * The parameter property @p free is set using the free() and fix() 00068 * methods and it is retrieved using the is_free() and is_fixed() methods. 00069 * The attribute @p grad is set and retrieved using the has has_grad() 00070 * methods. 00071 * 00072 * Each model parameter is factorized into a @p factor and a @p scale 00073 * term. The GModelPar class stores the factors and the scale factor has 00074 * data members, and the true values are computed using the following 00075 * relations: 00076 * 00077 * value = m_factor_value * m_scale 00078 * error = m_factor_error * m_scale 00079 * gradient = m_factor_gradient * m_scale 00080 * min = m_factor_min * m_scale 00081 * max = m_factor_max * m_scale 00082 * 00083 * The @p factor and @p scale terms can be set and retrieved using the 00084 * factor_value(), factor_error(), factor_gradient(), factor_min(), 00085 * factor_max() and scale() methods. 00086 ***************************************************************************/ 00087 class GModelPar : public GOptimizerPar { 00088 00089 public: 00090 // Constructors and destructors 00091 GModelPar(void); 00092 GModelPar(const std::string& name, const double& value); 00093 GModelPar(const std::string& name, const double& factor, 00094 const double& scale); 00095 GModelPar(const GModelPar& par); 00096 virtual ~GModelPar(void); 00097 00098 // Operators 00099 GModelPar& operator=(const GModelPar& par); 00100 00101 // Methods 00102 GModelPar* clone(void) const; 00103 std::string classname(void) const; 00104 void read(const GXmlElement& xml); 00105 void write(GXmlElement& xml) const; 00106 00107 protected: 00108 // Protected methods 00109 void init_members(void); 00110 void copy_members(const GModelPar& par); 00111 void free_members(void); 00112 }; 00113 00114 00115 /***********************************************************************//** 00116 * @brief Return class name 00117 * 00118 * @return String containing the class name ("GModelPar"). 00119 ***************************************************************************/ 00120 inline 00121 std::string GModelPar::classname(void) const 00122 { 00123 return ("GModelPar"); 00124 } 00125 00126 #endif /* GMODELPAR_HPP */