From e0d12cc9cc766def232f55438bea411600fbe192 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Thu, 2 Jul 2015 11:52:03 +0200 Subject: [PATCH] Also enhance logging for ctskymap. --- src/ctbin/ctbin.cpp | 25 +++++++++++++++++++------ src/ctskymap/ctskymap.cpp | 57 ++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index 221491d..068ad1d 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -325,13 +325,26 @@ void ctbin::save(void) // Get output filename m_outcube = (*this)["outcube"].filename(); - // Get CTA observation from observation container - GCTAObservation* obs = dynamic_cast(m_obs[0]); + // Save only if filename is non-empty + if (m_outcube.length() > 0) { - // Save only if observation is valid - if (obs != NULL) { - obs->save(m_outcube, clobber()); - } + // Get CTA observation from observation container + GCTAObservation* obs = dynamic_cast(m_obs[0]); + + // Save only if observation is valid + if (obs != NULL) { + + // Dump filename + if (logTerse()) { + log << "Save \""+m_outcube+"\"" << std::endl; + } + + // Save cube + obs->save(m_outcube, clobber()); + + } // endif: observation was valid + + } // endif: outcube file was valid // Return return; diff --git a/src/ctskymap/ctskymap.cpp b/src/ctskymap/ctskymap.cpp index c5b9b6d..1158aa5 100644 --- a/src/ctskymap/ctskymap.cpp +++ b/src/ctskymap/ctskymap.cpp @@ -247,15 +247,27 @@ void ctskymap::run(void) // Loop over all observation in the container for (int i = 0; i < m_obs.size(); ++i) { + // Write header for observation + if (logTerse()) { + std::string header = m_obs[i]->instrument() + " observation"; + if (m_obs[i]->name().length() > 1) { + header += " \"" + m_obs[i]->name() + "\""; + } + if (m_obs[i]->id().length() > 1) { + header += " (id=" + m_obs[i]->id() +")"; + } + log.header3(header); + } + // Get CTA observation GCTAObservation* obs = dynamic_cast(m_obs[i]); // Skip observation if it's not CTA if (obs == NULL) { if (logTerse()) { - log << "Warning: Skipping "+m_obs[i]->instrument(); - log << " observation \""; - log << m_obs[i]->name() << "\"" << std::endl; + log << " Skipping "; + log << m_obs[i]->instrument(); + log << " observation" << std::endl; } continue; } @@ -263,22 +275,13 @@ void ctskymap::run(void) // Skip observation if we have a binned observation if (obs->eventtype() == "CountsCube") { if (logTerse()) { - log << "Warning: Skipping binned observation \""; - log << obs->name()+"\"" << std::endl; + log << " Skipping binned "; + log << obs->instrument(); + log << " observation" << std::endl; } continue; } - // Write header for current observation - if (logTerse()) { - if (obs->name().length() > 1) { - log.header3("Observation "+obs->name()); - } - else { - log.header3("Observation"); - } - } - // Map events into sky map map_events(obs); @@ -308,8 +311,18 @@ void ctskymap::save(void) // Get output filename m_outmap = (*this)["outmap"].filename(); - // Save sky map - m_skymap.save(m_outmap, clobber()); + // Save only if filename is non-empty + if (m_outmap.length() > 0) { + + // Dump filename + if (logTerse()) { + log << "Save \""+m_outmap+"\"" << std::endl; + } + + // Save sky map + m_skymap.save(m_outmap, clobber()); + + } // Return return; @@ -424,23 +437,21 @@ void ctskymap::map_events(GCTAObservation* obs) // Log binning results if (logTerse()) { - log << std::endl; - log.header1("Mapping"); log << gammalib::parformat("Events in list"); log << obs->events()->size() << std::endl; log << gammalib::parformat("Events in map"); log << num_in_map << std::endl; log << gammalib::parformat("Events outside map area"); log << num_outside_map << std::endl; - log << gammalib::parformat("Events outside energy range"); + log << gammalib::parformat("Events outside energies"); log << num_outside_erange << std::endl; } // Log map - if (logTerse()) { - log << std::endl; - log.header1("Sky map"); + if (logVerbose()) { + log.indent(1); log << m_skymap << std::endl; + log.indent(0); } } // endif: observation was valid -- libgit2 0.21.4