From 80498d086e00e710f2174691b2b5e9fa521e04d4 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 11 Jan 2013 00:20:47 +0100 Subject: [PATCH] Do some minor code reformatting to apply to coding standards. --- include/GModelSpectralLogParabola.hpp | 6 ++++-- pyext/GModelSpectralLogParabola.i | 4 +++- src/model/GModelSpectralLogParabola.cpp | 41 +++++++++++++++++++++++------------------ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/GModelSpectralLogParabola.hpp b/include/GModelSpectralLogParabola.hpp index 22da12e..7a96c54 100644 --- a/include/GModelSpectralLogParabola.hpp +++ b/include/GModelSpectralLogParabola.hpp @@ -58,7 +58,9 @@ class GModelSpectralLogParabola : public GModelSpectral { public: // Constructors and destructors GModelSpectralLogParabola(void); - explicit GModelSpectralLogParabola(const double& norm, const double& index, const double &curvature); + explicit GModelSpectralLogParabola(const double& norm, + const double& index, + const double &curvature); explicit GModelSpectralLogParabola(const GXmlElement& xml); GModelSpectralLogParabola(const GModelSpectralLogParabola& model); virtual ~GModelSpectralLogParabola(void); @@ -142,7 +144,7 @@ protected: mutable double m_mc_exponent; //!< Exponent (index+1) mutable double m_mc_pow_emin; //!< Power of minimum energy mutable double m_mc_pow_ewidth; //!< Power of energy width - mutable double m_mc_norm; //!< Norm of powerlaw model at logparabola pivot energy + mutable double m_mc_norm; //!< Norm of powerlaw model at logparabola pivot energy }; #endif /* GMODELSPECTRALLOGPARABOLA_HPP */ diff --git a/pyext/GModelSpectralLogParabola.i b/pyext/GModelSpectralLogParabola.i index 8d71777..336a763 100644 --- a/pyext/GModelSpectralLogParabola.i +++ b/pyext/GModelSpectralLogParabola.i @@ -39,7 +39,9 @@ class GModelSpectralLogParabola : public GModelSpectral { public: // Constructors and destructors GModelSpectralLogParabola(void); - explicit GModelSpectralLogParabola(const double& norm, const double& index,const double& curvature); + explicit GModelSpectralLogParabola(const double& norm, + const double& index, + const double& curvature); explicit GModelSpectralLogParabola(const GXmlElement& xml); GModelSpectralLogParabola(const GModelSpectralLogParabola& model); virtual ~GModelSpectralLogParabola(void); diff --git a/src/model/GModelSpectralLogParabola.cpp b/src/model/GModelSpectralLogParabola.cpp index 07b1c9c..e755dfa 100644 --- a/src/model/GModelSpectralLogParabola.cpp +++ b/src/model/GModelSpectralLogParabola.cpp @@ -599,7 +599,8 @@ void GModelSpectralLogParabola::read(const GXmlElement& xml) m_index.read(*par); npar[1]++; } - // change sign if index is defined Fermi-like + + // Change sign if index is defined Fermi-like else if(par->attribute("name") == "alpha") { m_index.read(*par); m_index.scale(-m_index.scale()); @@ -611,7 +612,8 @@ void GModelSpectralLogParabola::read(const GXmlElement& xml) m_curvature.read(*par); npar[2]++; } - // change sign if curvature is defined Fermi-like + + // Change sign if curvature is defined Fermi-like else if(par->attribute("name") == "beta") { m_curvature.read(*par); m_curvature.scale(-m_curvature.scale()); @@ -821,7 +823,7 @@ void GModelSpectralLogParabola::init_members(void) m_mc_exponent = 0.0; m_mc_pow_emin = 0.0; m_mc_pow_ewidth = 0.0; - m_mc_norm = 0.0; + m_mc_norm = 0.0; // Return return; @@ -854,7 +856,7 @@ void GModelSpectralLogParabola::copy_members(const GModelSpectralLogParabola& mo m_mc_exponent = model.m_mc_exponent; m_mc_pow_emin = model.m_mc_pow_emin; m_mc_pow_ewidth = model.m_mc_pow_ewidth; - m_mc_norm = model.m_mc_norm; + m_mc_norm = model.m_mc_norm; // Return return; @@ -884,24 +886,28 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy& emin, { // Only update if boundaries have changed if(emin.MeV() != m_mc_emin || emax.MeV() != m_mc_emax){ - m_mc_emin = emin.MeV(); - m_mc_emax = emax.MeV(); - // Find a corresponding power law with the criterion: Plaw > LogParabola in the given interval + // Store energy boundaries + m_mc_emin = emin.MeV(); + m_mc_emax = emax.MeV(); + + // Find a corresponding power law with the criterion + // Plaw > LogParabola in the given interval double index_pl; - // checking the sign of spectrum curvature - if(curvature() < 0){ + // Checking the sign of spectrum curvature + if (curvature() < 0) { // Use the spectral index at the pivot energy of the LogParabola - index_pl = index(); + index_pl = index(); m_mc_norm = norm(); } + else { + // Use a power law which connects the ends of the convex, + // curved model - else{ - // Use a power law which connects the ends of the convex, curved model - - // Plaw index defined by the slope of a straight line in the log-log-plane + // Plaw index defined by the slope of a straight line in the + // log-log-plane index_pl = std::log(eval(emin)/eval(emax))/std::log(emin.MeV()/emax.MeV()); // Plaw norm defined such that Plaw = LogParabola at emin @@ -909,12 +915,12 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy& emin, } - if(index_pl != -1.0){ - m_mc_exponent = index_pl + 1.0; + // Set precomputation cache + if (index_pl != -1.0) { + m_mc_exponent = index_pl + 1.0; m_mc_pow_emin = std::pow(emin.MeV(), m_mc_exponent); m_mc_pow_ewidth = std::pow(emax.MeV(), m_mc_exponent) - m_mc_pow_emin; } - else { m_mc_exponent = 0.0; m_mc_pow_emin = std::log(emin.MeV()); @@ -926,4 +932,3 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy& emin, // Return return; } - -- libgit2 0.21.4