00001 /*************************************************************************** 00002 * GModelSpectral.hpp - Abstract spectral model base class * 00003 * ----------------------------------------------------------------------- * 00004 * copyright (C) 2009-2016 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 GModelSpectral.hpp 00023 * @brief Abstract spectral model base class interface definition 00024 * @author Juergen Knoedlseder 00025 */ 00026 00027 #ifndef GMODELSPECTRAL_HPP 00028 #define GMODELSPECTRAL_HPP 00029 00030 /* __ Includes ___________________________________________________________ */ 00031 #include <string> 00032 #include <vector> 00033 #include "GBase.hpp" 00034 #include "GTime.hpp" 00035 00036 /* __ Forward declaration ________________________________________________ */ 00037 class GEnergy; 00038 class GRan; 00039 class GModelPar; 00040 class GXmlElement; 00041 00042 00043 /***********************************************************************//** 00044 * @class GModelSpectral 00045 * 00046 * @brief Abstract spectral model base class 00047 * 00048 * This class implements the spectral component of the factorized source 00049 * model 00050 * 00051 * \f[ 00052 * S_{\rm E}(E | t) 00053 * \f] 00054 * 00055 * where 00056 * \f$E\f$ is the true photon energy, and 00057 * \f$t\f$ is the true photon arrival time. 00058 * 00059 * The spectral component describes the spatially integrated time dependent 00060 * spectral distribution of the source. It satisfies 00061 * \f[ 00062 * \int_{E} S_{\rm E}(E | t) dE = \Phi 00063 * \f] 00064 * for all \f$t\f$, where \f$\Phi\f$ is the spatially and spectrally 00065 * integrated total source flux. The spectral component does not impact 00066 * the temporal properties of the integrated flux \f$\Phi\f$. 00067 ***************************************************************************/ 00068 class GModelSpectral : public GBase { 00069 00070 public: 00071 // Constructors and destructors 00072 GModelSpectral(void); 00073 GModelSpectral(const GModelSpectral& model); 00074 virtual ~GModelSpectral(void); 00075 00076 // Operators 00077 virtual GModelSpectral& operator=(const GModelSpectral& model); 00078 virtual GModelPar& operator[](const int& index); 00079 virtual const GModelPar& operator[](const int& index) const; 00080 virtual GModelPar& operator[](const std::string& name); 00081 virtual const GModelPar& operator[](const std::string& name) const; 00082 00083 // Pure virtual methods 00084 virtual void clear(void) = 0; 00085 virtual GModelSpectral* clone(void) const = 0; 00086 virtual std::string classname(void) const = 0; 00087 virtual std::string type(void) const = 0; 00088 virtual double eval(const GEnergy& srcEng, 00089 const GTime& srcTime = GTime(), 00090 const bool& gradients = false) const = 0; 00091 virtual double flux(const GEnergy& emin, 00092 const GEnergy& emax) const = 0; 00093 virtual double eflux(const GEnergy& emin, 00094 const GEnergy& emax) const = 0; 00095 virtual GEnergy mc(const GEnergy& emin, const GEnergy& emax, 00096 const GTime& time, GRan& ran) const = 0; 00097 virtual void read(const GXmlElement& xml) = 0; 00098 virtual void write(GXmlElement& xml) const = 0; 00099 virtual std::string print(const GChatter& chatter = NORMAL) const = 0; 00100 00101 // Methods 00102 GModelPar& at(const int& index); 00103 const GModelPar& at(const int& index) const; 00104 bool has_par(const std::string& name) const; 00105 int size(void) const; 00106 void autoscale(void); 00107 00108 protected: 00109 // Protected methods 00110 void init_members(void); 00111 void copy_members(const GModelSpectral& model); 00112 void free_members(void); 00113 00114 // Proteced members 00115 std::vector<GModelPar*> m_pars; //!< Parameter pointers 00116 }; 00117 00118 00119 /***********************************************************************//** 00120 * @brief Returns model parameter 00121 * 00122 * @param[in] index Parameter index [0,...,size()-1]. 00123 * @return Model parameter. 00124 * 00125 * Returns model parameter without @p index range checking. 00126 ***************************************************************************/ 00127 inline 00128 GModelPar& GModelSpectral::operator[](const int& index) 00129 { 00130 return *(m_pars[index]); 00131 } 00132 00133 00134 /***********************************************************************//** 00135 * @brief Returns model parameter (const version) 00136 * 00137 * @param[in] index Parameter index [0,...,size()-1]. 00138 * @return Model parameter. 00139 * 00140 * Returns model parameter without @p index range checking. 00141 ***************************************************************************/ 00142 inline 00143 const GModelPar& GModelSpectral::operator[](const int& index) const 00144 { 00145 return *(m_pars[index]); 00146 } 00147 00148 00149 /***********************************************************************//** 00150 * @brief Return number of parameters 00151 * 00152 * @return Number of parameters in spectral model component. 00153 * 00154 * Returns the number of parameters in the spectral model component. 00155 ***************************************************************************/ 00156 inline 00157 int GModelSpectral::size(void) const 00158 { 00159 return (int)m_pars.size(); 00160 } 00161 00162 #endif /* GMODELSPECTRAL_HPP */