Commit f30d15f6f31fdd4a8ddfa24ca1dbc5d383eddc04
1 parent
4a618cc0
Fixed bug in ctlike refit logic
Showing
1 changed file
with
16 additions
and
18 deletions
src/ctlike/ctlike.cpp
| ... | ... | @@ -785,33 +785,31 @@ bool ctlike::refit(const GOptimizer* opt) |
| 785 | 785 | double npred = m_obs.npred(); |
| 786 | 786 | double difference = m_nobs - npred; |
| 787 | 787 | if (m_nobs > 0.0) { |
| 788 | - double fraction = difference / m_nobs; | |
| 789 | - if (std::abs(fraction) > 1.0e-4) { | |
| 788 | + double fraction = difference / m_nobs; | |
| 789 | + if (std::abs(fraction) > 1.0e-5) { | |
| 790 | 790 | refit = true; |
| 791 | 791 | log_value(NORMAL, "Refit requested", |
| 792 | 792 | "Difference "+ |
| 793 | - gammalib::str(difference)+ | |
| 793 | + gammalib::str(difference,3)+ | |
| 794 | 794 | " between number of observed events "+ |
| 795 | - gammalib::str(m_nobs)+ | |
| 795 | + gammalib::str(m_nobs,3)+ | |
| 796 | 796 | " and predicted events "+ |
| 797 | - gammalib::str(npred)+ | |
| 798 | - " is larger than +/- 1.0e-4 times the number of"+ | |
| 797 | + gammalib::str(npred,3)+ | |
| 798 | + " is larger than +/- 1.0e-5 times the number of"+ | |
| 799 | 799 | " observed events ("+ |
| 800 | 800 | gammalib::str(fraction)+")."); |
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | - else { | |
| 804 | - if (std::abs(difference) > 10.0) { | |
| 805 | - refit = true; | |
| 806 | - log_value(NORMAL, "Refit requested", | |
| 807 | - "Difference "+ | |
| 808 | - gammalib::str(difference)+ | |
| 809 | - " between number of observed events "+ | |
| 810 | - gammalib::str(m_nobs)+ | |
| 811 | - " and predicted events "+ | |
| 812 | - gammalib::str(npred)+ | |
| 813 | - " is larger than +/- 10."); | |
| 814 | - } | |
| 803 | + if (!refit && std::abs(difference) > 5.0) { | |
| 804 | + refit = true; | |
| 805 | + log_value(NORMAL, "Refit requested", | |
| 806 | + "Difference "+ | |
| 807 | + gammalib::str(difference,3)+ | |
| 808 | + " between number of observed events "+ | |
| 809 | + gammalib::str(m_nobs,3)+ | |
| 810 | + " and predicted events "+ | |
| 811 | + gammalib::str(npred,3)+ | |
| 812 | + " is larger than +/- 5."); | |
| 815 | 813 | } |
| 816 | 814 | } // endelse: check number of events |
| 817 | 815 | ... | ... |