Commit 894632b773898eeacb2e37fcf7743db7331cd240

Authored by Nathan Kelley-Hoskins
1 parent 80ab3706

added warning message and zero normalization when encountering bad king function params

Showing 1 changed file with 16 additions and 3 deletions
inst/cta/src/GCTAPsfKing.cpp
@@ -594,9 +594,22 @@ void GCTAPsfKing::update(const double& logE, const double& theta) const @@ -594,9 +594,22 @@ void GCTAPsfKing::update(const double& logE, const double& theta) const
594 m_par_sigma = pars[1]; 594 m_par_sigma = pars[1];
595 m_par_sigma2 = m_par_sigma * m_par_sigma; 595 m_par_sigma2 = m_par_sigma * m_par_sigma;
596 596
597 - // Determine normalisation for given parameters  
598 - m_par_norm = 1.0 / gammalib::twopi * (1.0 - 1.0 / m_par_gamma) /  
599 - m_par_sigma2; 597 + // Check for parameter sanity
  598 + if (m_par_gamma <= 0.0 || m_par_sigma <= 0.0) {
  599 + m_par_norm = 0.0;
  600 + std::string msg = " King function parameters m_par_gamma and"
  601 + " m_par_sigma are zero (for "
  602 + " parameter space logE=" +
  603 + gammalib::str(logE) + " and theta=" +
  604 + gammalib::str(theta) +
  605 + "), setting normalization m_norm to zero.";
  606 + gammalib::warning(G_UPDATE, msg);
  607 + }
  608 + else {
  609 + // Determine normalisation for given parameters
  610 + m_par_norm = 1.0 / gammalib::twopi * (1.0 - 1.0 / m_par_gamma) /
  611 + m_par_sigma2;
  612 + }
600 613
601 // Optionally correct for fixed delta_max 614 // Optionally correct for fixed delta_max
602 #if defined(G_FIX_DELTA_MAX) 615 #if defined(G_FIX_DELTA_MAX)