Commit 80498d086e00e710f2174691b2b5e9fa521e04d4

Authored by Jürgen Knödlseder
1 parent f332ce84

Do some minor code reformatting to apply to coding standards.

include/GModelSpectralLogParabola.hpp
@@ -58,7 +58,9 @@ class GModelSpectralLogParabola : public GModelSpectral { @@ -58,7 +58,9 @@ class GModelSpectralLogParabola : public GModelSpectral {
58 public: 58 public:
59 // Constructors and destructors 59 // Constructors and destructors
60 GModelSpectralLogParabola(void); 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 explicit GModelSpectralLogParabola(const GXmlElement& xml); 64 explicit GModelSpectralLogParabola(const GXmlElement& xml);
63 GModelSpectralLogParabola(const GModelSpectralLogParabola& model); 65 GModelSpectralLogParabola(const GModelSpectralLogParabola& model);
64 virtual ~GModelSpectralLogParabola(void); 66 virtual ~GModelSpectralLogParabola(void);
@@ -142,7 +144,7 @@ protected: @@ -142,7 +144,7 @@ protected:
142 mutable double m_mc_exponent; //!< Exponent (index+1) 144 mutable double m_mc_exponent; //!< Exponent (index+1)
143 mutable double m_mc_pow_emin; //!< Power of minimum energy 145 mutable double m_mc_pow_emin; //!< Power of minimum energy
144 mutable double m_mc_pow_ewidth; //!< Power of energy width 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 #endif /* GMODELSPECTRALLOGPARABOLA_HPP */ 150 #endif /* GMODELSPECTRALLOGPARABOLA_HPP */
pyext/GModelSpectralLogParabola.i
@@ -39,7 +39,9 @@ class GModelSpectralLogParabola : public GModelSpectral { @@ -39,7 +39,9 @@ class GModelSpectralLogParabola : public GModelSpectral {
39 public: 39 public:
40 // Constructors and destructors 40 // Constructors and destructors
41 GModelSpectralLogParabola(void); 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 explicit GModelSpectralLogParabola(const GXmlElement& xml); 45 explicit GModelSpectralLogParabola(const GXmlElement& xml);
44 GModelSpectralLogParabola(const GModelSpectralLogParabola& model); 46 GModelSpectralLogParabola(const GModelSpectralLogParabola& model);
45 virtual ~GModelSpectralLogParabola(void); 47 virtual ~GModelSpectralLogParabola(void);
src/model/GModelSpectralLogParabola.cpp
@@ -599,7 +599,8 @@ void GModelSpectralLogParabola::read(const GXmlElement&amp; xml) @@ -599,7 +599,8 @@ void GModelSpectralLogParabola::read(const GXmlElement&amp; xml)
599 m_index.read(*par); 599 m_index.read(*par);
600 npar[1]++; 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 else if(par->attribute("name") == "alpha") { 604 else if(par->attribute("name") == "alpha") {
604 m_index.read(*par); 605 m_index.read(*par);
605 m_index.scale(-m_index.scale()); 606 m_index.scale(-m_index.scale());
@@ -611,7 +612,8 @@ void GModelSpectralLogParabola::read(const GXmlElement&amp; xml) @@ -611,7 +612,8 @@ void GModelSpectralLogParabola::read(const GXmlElement&amp; xml)
611 m_curvature.read(*par); 612 m_curvature.read(*par);
612 npar[2]++; 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 else if(par->attribute("name") == "beta") { 617 else if(par->attribute("name") == "beta") {
616 m_curvature.read(*par); 618 m_curvature.read(*par);
617 m_curvature.scale(-m_curvature.scale()); 619 m_curvature.scale(-m_curvature.scale());
@@ -821,7 +823,7 @@ void GModelSpectralLogParabola::init_members(void) @@ -821,7 +823,7 @@ void GModelSpectralLogParabola::init_members(void)
821 m_mc_exponent = 0.0; 823 m_mc_exponent = 0.0;
822 m_mc_pow_emin = 0.0; 824 m_mc_pow_emin = 0.0;
823 m_mc_pow_ewidth = 0.0; 825 m_mc_pow_ewidth = 0.0;
824 - m_mc_norm = 0.0; 826 + m_mc_norm = 0.0;
825 827
826 // Return 828 // Return
827 return; 829 return;
@@ -854,7 +856,7 @@ void GModelSpectralLogParabola::copy_members(const GModelSpectralLogParabola&amp; mo @@ -854,7 +856,7 @@ void GModelSpectralLogParabola::copy_members(const GModelSpectralLogParabola&amp; mo
854 m_mc_exponent = model.m_mc_exponent; 856 m_mc_exponent = model.m_mc_exponent;
855 m_mc_pow_emin = model.m_mc_pow_emin; 857 m_mc_pow_emin = model.m_mc_pow_emin;
856 m_mc_pow_ewidth = model.m_mc_pow_ewidth; 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 // Return 861 // Return
860 return; 862 return;
@@ -884,24 +886,28 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy&amp; emin, @@ -884,24 +886,28 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy&amp; emin,
884 { 886 {
885 // Only update if boundaries have changed 887 // Only update if boundaries have changed
886 if(emin.MeV() != m_mc_emin || emax.MeV() != m_mc_emax){ 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 double index_pl; 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 // Use the spectral index at the pivot energy of the LogParabola 901 // Use the spectral index at the pivot energy of the LogParabola
897 - index_pl = index(); 902 + index_pl = index();
898 m_mc_norm = norm(); 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 index_pl = std::log(eval(emin)/eval(emax))/std::log(emin.MeV()/emax.MeV()); 911 index_pl = std::log(eval(emin)/eval(emax))/std::log(emin.MeV()/emax.MeV());
906 912
907 // Plaw norm defined such that Plaw = LogParabola at emin 913 // Plaw norm defined such that Plaw = LogParabola at emin
@@ -909,12 +915,12 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy&amp; emin, @@ -909,12 +915,12 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy&amp; 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 m_mc_pow_emin = std::pow(emin.MeV(), m_mc_exponent); 921 m_mc_pow_emin = std::pow(emin.MeV(), m_mc_exponent);
915 m_mc_pow_ewidth = std::pow(emax.MeV(), m_mc_exponent) - m_mc_pow_emin; 922 m_mc_pow_ewidth = std::pow(emax.MeV(), m_mc_exponent) - m_mc_pow_emin;
916 } 923 }
917 -  
918 else { 924 else {
919 m_mc_exponent = 0.0; 925 m_mc_exponent = 0.0;
920 m_mc_pow_emin = std::log(emin.MeV()); 926 m_mc_pow_emin = std::log(emin.MeV());
@@ -926,4 +932,3 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy&amp; emin, @@ -926,4 +932,3 @@ void GModelSpectralLogParabola::update_mc_cache(const GEnergy&amp; emin,
926 // Return 932 // Return
927 return; 933 return;
928 } 934 }
929 -