Commit 10e1f7cc2c815185cbed72eb39677574eaf382a7
1 parent
f376dd46
Add more logging information
Showing
1 changed file
with
26 additions
and
11 deletions
src/ctlike/ctlike.cpp
| @@ -230,6 +230,15 @@ void ctlike::run(void) | @@ -230,6 +230,15 @@ void ctlike::run(void) | ||
| 230 | // Write input observation container into logger | 230 | // Write input observation container into logger |
| 231 | log_observations(NORMAL, m_obs, "Input observation"); | 231 | log_observations(NORMAL, m_obs, "Input observation"); |
| 232 | 232 | ||
| 233 | + // Compute number of observed events in all observations | ||
| 234 | + m_nobs = 0.0; | ||
| 235 | + for (int i = 0; i < m_obs.size(); ++i) { | ||
| 236 | + double data = m_obs[i]->nobserved(); | ||
| 237 | + if (data >= 0.0) { | ||
| 238 | + m_nobs += data; | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + | ||
| 233 | // Optimize model parameters using LM optimizer | 242 | // Optimize model parameters using LM optimizer |
| 234 | optimize_lm(); | 243 | optimize_lm(); |
| 235 | 244 | ||
| @@ -253,6 +262,16 @@ void ctlike::run(void) | @@ -253,6 +262,16 @@ void ctlike::run(void) | ||
| 253 | // Compute TS values if requested | 262 | // Compute TS values if requested |
| 254 | if (!ts_srcs.empty()) { | 263 | if (!ts_srcs.empty()) { |
| 255 | 264 | ||
| 265 | + // Write general fit results in logger (will be repeated at the | ||
| 266 | + // end) | ||
| 267 | + log_header1(EXPLICIT, "Maximum likelihood optimisation results"); | ||
| 268 | + log_string(EXPLICIT, m_opt.print(m_chatter)); | ||
| 269 | + log_value(EXPLICIT, "Maximum log likelihood", gammalib::str(m_logL,3)); | ||
| 270 | + log_value(EXPLICIT, "Observed events (Nobs)", gammalib::str(m_nobs,3)); | ||
| 271 | + log_value(EXPLICIT, "Predicted events (Npred)", gammalib::str(m_npred,3)+ | ||
| 272 | + " (Nobs - Npred = "+gammalib::str(m_nobs-m_npred)+")"); | ||
| 273 | + log_string(VERBOSE, m_obs.models().print(m_chatter)); | ||
| 274 | + | ||
| 256 | // Store original maximum likelihood and models | 275 | // Store original maximum likelihood and models |
| 257 | double logL_src = m_logL; | 276 | double logL_src = m_logL; |
| 258 | GModels models = m_obs.models(); | 277 | GModels models = m_obs.models(); |
| @@ -307,15 +326,6 @@ void ctlike::run(void) | @@ -307,15 +326,6 @@ void ctlike::run(void) | ||
| 307 | 326 | ||
| 308 | } // endif: requested TS computation | 327 | } // endif: requested TS computation |
| 309 | 328 | ||
| 310 | - // Compute number of observed events in all observations | ||
| 311 | - m_nobs = 0.0; | ||
| 312 | - for (int i = 0; i < m_obs.size(); ++i) { | ||
| 313 | - double data = m_obs[i]->nobserved(); | ||
| 314 | - if (data >= 0.0) { | ||
| 315 | - m_nobs += data; | ||
| 316 | - } | ||
| 317 | - } | ||
| 318 | - | ||
| 319 | // Write results into logger | 329 | // Write results into logger |
| 320 | log_header1(NORMAL, "Maximum likelihood optimisation results"); | 330 | log_header1(NORMAL, "Maximum likelihood optimisation results"); |
| 321 | log_string(NORMAL, m_opt.print(m_chatter)); | 331 | log_string(NORMAL, m_opt.print(m_chatter)); |
| @@ -620,8 +630,13 @@ double ctlike::reoptimize_lm(void) | @@ -620,8 +630,13 @@ double ctlike::reoptimize_lm(void) | ||
| 620 | 630 | ||
| 621 | // Write optimization results | 631 | // Write optimization results |
| 622 | log.indent(0); | 632 | log.indent(0); |
| 623 | - log_header1(NORMAL, "Maximum likelihood re-optimisation results"); | ||
| 624 | - log_string(NORMAL, opt->print(m_chatter)); | 633 | + log_header1(EXPLICIT, "Maximum likelihood re-optimisation results"); |
| 634 | + log_string(EXPLICIT, opt->print(m_chatter)); | ||
| 635 | + log_value(EXPLICIT, "Maximum log likelihood", gammalib::str(logL,3)); | ||
| 636 | + log_value(EXPLICIT, "Observed events (Nobs)", gammalib::str(m_nobs,3)); | ||
| 637 | + log_value(EXPLICIT, "Predicted events (Npred)", gammalib::str(m_obs.npred(),3)+ | ||
| 638 | + " (Nobs - Npred = "+gammalib::str(m_nobs-m_obs.npred())+")"); | ||
| 639 | + log_string(VERBOSE, m_obs.models().print(m_chatter)); | ||
| 625 | 640 | ||
| 626 | // Return | 641 | // Return |
| 627 | return (logL); | 642 | return (logL); |