Commit 80498d086e00e710f2174691b2b5e9fa521e04d4
1 parent
f332ce84
Do some minor code reformatting to apply to coding standards.
Showing
3 changed files
with
30 additions
and
21 deletions
include/GModelSpectralLogParabola.hpp
| ... | ... | @@ -58,7 +58,9 @@ class GModelSpectralLogParabola : public GModelSpectral { |
| 58 | 58 | public: |
| 59 | 59 | // Constructors and destructors |
| 60 | 60 | GModelSpectralLogParabola(void); |
| 61 | - explicit GModelSpectralLogParabola(const double& norm, const double& index, const double &curvature); | |
| 61 | + explicit GModelSpectralLogParabola(const double& norm, | |
| 62 | + const double& index, | |
| 63 | + const double &curvature); | |
| 62 | 64 | explicit GModelSpectralLogParabola(const GXmlElement& xml); |
| 63 | 65 | GModelSpectralLogParabola(const GModelSpectralLogParabola& model); |
| 64 | 66 | virtual ~GModelSpectralLogParabola(void); |
| ... | ... | @@ -142,7 +144,7 @@ protected: |
| 142 | 144 | mutable double m_mc_exponent; //!< Exponent (index+1) |
| 143 | 145 | mutable double m_mc_pow_emin; //!< Power of minimum energy |
| 144 | 146 | mutable double m_mc_pow_ewidth; //!< Power of energy width |
| 145 | - mutable double m_mc_norm; //!< Norm of powerlaw model at logparabola pivot energy | |
| 147 | + mutable double m_mc_norm; //!< Norm of powerlaw model at logparabola pivot energy | |
| 146 | 148 | }; |
| 147 | 149 | |
| 148 | 150 | #endif /* GMODELSPECTRALLOGPARABOLA_HPP */ | ... | ... |
pyext/GModelSpectralLogParabola.i
| ... | ... | @@ -39,7 +39,9 @@ class GModelSpectralLogParabola : public GModelSpectral { |
| 39 | 39 | public: |
| 40 | 40 | // Constructors and destructors |
| 41 | 41 | GModelSpectralLogParabola(void); |
| 42 | - explicit GModelSpectralLogParabola(const double& norm, const double& index,const double& curvature); | |
| 42 | + explicit GModelSpectralLogParabola(const double& norm, | |
| 43 | + const double& index, | |
| 44 | + const double& curvature); | |
| 43 | 45 | explicit GModelSpectralLogParabola(const GXmlElement& xml); |
| 44 | 46 | GModelSpectralLogParabola(const GModelSpectralLogParabola& model); |
| 45 | 47 | virtual ~GModelSpectralLogParabola(void); | ... | ... |
src/model/GModelSpectralLogParabola.cpp
| ... | ... | @@ -599,7 +599,8 @@ void GModelSpectralLogParabola::read(const GXmlElement& xml) |
| 599 | 599 | m_index.read(*par); |
| 600 | 600 | npar[1]++; |
| 601 | 601 | } |
| 602 | - // change sign if index is defined Fermi-like | |
| 602 | + | |
| 603 | + // Change sign if index is defined Fermi-like | |
| 603 | 604 | else if(par->attribute("name") == "alpha") { |
| 604 | 605 | m_index.read(*par); |
| 605 | 606 | m_index.scale(-m_index.scale()); |
| ... | ... | @@ -611,7 +612,8 @@ void GModelSpectralLogParabola::read(const GXmlElement& xml) |
| 611 | 612 | m_curvature.read(*par); |
| 612 | 613 | npar[2]++; |
| 613 | 614 | } |
| 614 | - // change sign if curvature is defined Fermi-like | |
| 615 | + | |
| 616 | + // Change sign if curvature is defined Fermi-like | |
| 615 | 617 | else if(par->attribute("name") == "beta") { |
| 616 | 618 | m_curvature.read(*par); |
| 617 | 619 | m_curvature.scale(-m_curvature.scale()); |
| ... | ... | @@ -821,7 +823,7 @@ void GModelSpectralLogParabola::init_members(void) |
| 821 | 823 | m_mc_exponent = 0.0; |
| 822 | 824 | m_mc_pow_emin = 0.0; |
| 823 | 825 | m_mc_pow_ewidth = 0.0; |
| 824 | - m_mc_norm = 0.0; | |
| 826 | + m_mc_norm = 0.0; | |
| 825 | 827 | |
| 826 | 828 | // Return |
| 827 | 829 | return; |
| ... | ... | @@ -854,7 +856,7 @@ void GModelSpectralLogParabola::copy_members(const GModelSpectralLogParabola& mo |
| 854 | 856 | m_mc_exponent = model.m_mc_exponent; |
| 855 | 857 | m_mc_pow_emin = model.m_mc_pow_emin; |
| 856 | 858 | m_mc_pow_ewidth = model.m_mc_pow_ewidth; |
| 857 | - m_mc_norm = model.m_mc_norm; | |
| 859 | + m_mc_norm = model.m_mc_norm; | |
| 858 | 860 | |
| 859 | 861 | // Return |
| 860 | 862 | return; |
| ... | ... | @@ -884,24 +886,28 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy& emin, |
| 884 | 886 | { |
| 885 | 887 | // Only update if boundaries have changed |
| 886 | 888 | if(emin.MeV() != m_mc_emin || emax.MeV() != m_mc_emax){ |
| 887 | - m_mc_emin = emin.MeV(); | |
| 888 | - m_mc_emax = emax.MeV(); | |
| 889 | 889 | |
| 890 | - // Find a corresponding power law with the criterion: Plaw > LogParabola in the given interval | |
| 890 | + // Store energy boundaries | |
| 891 | + m_mc_emin = emin.MeV(); | |
| 892 | + m_mc_emax = emax.MeV(); | |
| 893 | + | |
| 894 | + // Find a corresponding power law with the criterion | |
| 895 | + // Plaw > LogParabola in the given interval | |
| 891 | 896 | double index_pl; |
| 892 | 897 | |
| 893 | - // checking the sign of spectrum curvature | |
| 894 | - if(curvature() < 0){ | |
| 898 | + // Checking the sign of spectrum curvature | |
| 899 | + if (curvature() < 0) { | |
| 895 | 900 | |
| 896 | 901 | // Use the spectral index at the pivot energy of the LogParabola |
| 897 | - index_pl = index(); | |
| 902 | + index_pl = index(); | |
| 898 | 903 | m_mc_norm = norm(); |
| 899 | 904 | } |
| 905 | + else { | |
| 906 | + // Use a power law which connects the ends of the convex, | |
| 907 | + // curved model | |
| 900 | 908 | |
| 901 | - else{ | |
| 902 | - // Use a power law which connects the ends of the convex, curved model | |
| 903 | - | |
| 904 | - // Plaw index defined by the slope of a straight line in the log-log-plane | |
| 909 | + // Plaw index defined by the slope of a straight line in the | |
| 910 | + // log-log-plane | |
| 905 | 911 | index_pl = std::log(eval(emin)/eval(emax))/std::log(emin.MeV()/emax.MeV()); |
| 906 | 912 | |
| 907 | 913 | // Plaw norm defined such that Plaw = LogParabola at emin |
| ... | ... | @@ -909,12 +915,12 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy& emin, |
| 909 | 915 | |
| 910 | 916 | } |
| 911 | 917 | |
| 912 | - if(index_pl != -1.0){ | |
| 913 | - m_mc_exponent = index_pl + 1.0; | |
| 918 | + // Set precomputation cache | |
| 919 | + if (index_pl != -1.0) { | |
| 920 | + m_mc_exponent = index_pl + 1.0; | |
| 914 | 921 | m_mc_pow_emin = std::pow(emin.MeV(), m_mc_exponent); |
| 915 | 922 | m_mc_pow_ewidth = std::pow(emax.MeV(), m_mc_exponent) - m_mc_pow_emin; |
| 916 | 923 | } |
| 917 | - | |
| 918 | 924 | else { |
| 919 | 925 | m_mc_exponent = 0.0; |
| 920 | 926 | m_mc_pow_emin = std::log(emin.MeV()); |
| ... | ... | @@ -926,4 +932,3 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy& emin, |
| 926 | 932 | // Return |
| 927 | 933 | return; |
| 928 | 934 | } |
| 929 | - | ... | ... |