Commit 28bffd7d9bc7d36594cf5a8b548f1e8fe53d8cbd

Authored by knodlseder
1 parent 4062c155

improve logging

Showing 1 changed file with 32 additions and 11 deletions
src/ctbin/ctbin.cpp
@@ -113,6 +113,10 @@ void ctbin::run(void) @@ -113,6 +113,10 @@ void ctbin::run(void)
113 // Bin data 113 // Bin data
114 bin(); 114 bin();
115 115
  116 + // Write separator into logger
  117 + if (logTerse())
  118 + log << std::endl;
  119 +
116 // Return 120 // Return
117 return; 121 return;
118 } 122 }
@@ -146,7 +150,7 @@ void ctbin::get_parameters(void) @@ -146,7 +150,7 @@ void ctbin::get_parameters(void)
146 150
147 151
148 /***********************************************************************//** 152 /***********************************************************************//**
149 - * @brief Run gtbin application 153 + * @brief Bin the data
150 ***************************************************************************/ 154 ***************************************************************************/
151 void ctbin::bin(void) 155 void ctbin::bin(void)
152 { 156 {
@@ -161,15 +165,8 @@ void ctbin::bin(void) @@ -161,15 +165,8 @@ void ctbin::bin(void)
161 emax.TeV(m_emax); 165 emax.TeV(m_emax);
162 obs.ebounds()->setlog(emin, emax, m_enumbins); 166 obs.ebounds()->setlog(emin, emax, m_enumbins);
163 167
164 - // Setup time range covered by data  
165 - GTime tstart;  
166 - GTime tstop;  
167 - tstart.met(0.0);  
168 - tstop.met(10000.0);  
169 - obs.gti()->add(tstart, tstop);  
170 -  
171 // Log observation 168 // Log observation
172 - if (logExplicit()) { 169 + if (logTerse()) {
173 log << std::endl; 170 log << std::endl;
174 log.header1("Observation"); 171 log.header1("Observation");
175 log << obs << std::endl; 172 log << obs << std::endl;
@@ -180,6 +177,11 @@ void ctbin::bin(void) @@ -180,6 +177,11 @@ void ctbin::bin(void)
180 m_xref, m_yref, m_binsz, m_binsz, 177 m_xref, m_yref, m_binsz, m_binsz,
181 m_nxpix, m_nypix, m_enumbins); 178 m_nxpix, m_nypix, m_enumbins);
182 179
  180 + // Initialise binning statistics
  181 + int num_outside_map = 0;
  182 + int num_outside_ebds = 0;
  183 + int num_in_map = 0;
  184 +
183 // Fill sky map 185 // Fill sky map
184 GCTAEventList* events = (GCTAEventList*)obs.events(); 186 GCTAEventList* events = (GCTAEventList*)obs.events();
185 for (GCTAEventList::iterator event = events->begin(); event != events->end(); ++event) { 187 for (GCTAEventList::iterator event = events->begin(); event != events->end(); ++event) {
@@ -191,19 +193,38 @@ void ctbin::bin(void) @@ -191,19 +193,38 @@ void ctbin::bin(void)
191 193
192 // Skip if pixel is out of range 194 // Skip if pixel is out of range
193 if (pixel.x() < -0.5 || pixel.x() > (m_nxpix-0.5) || 195 if (pixel.x() < -0.5 || pixel.x() > (m_nxpix-0.5) ||
194 - pixel.y() < -0.5 || pixel.y() > (m_nypix-0.5)) 196 + pixel.y() < -0.5 || pixel.y() > (m_nypix-0.5)) {
  197 + num_outside_map++;
195 continue; 198 continue;
  199 + }
196 200
197 // Determine energy bin. Skip if we are outside the energy range 201 // Determine energy bin. Skip if we are outside the energy range
198 int index = obs.ebounds()->index(event->energy()); 202 int index = obs.ebounds()->index(event->energy());
199 - if (index == -1) 203 + if (index == -1) {
  204 + num_outside_ebds++;
200 continue; 205 continue;
  206 + }
201 207
202 // Fill event in skymap 208 // Fill event in skymap
203 map(pixel, index) += 1.0; 209 map(pixel, index) += 1.0;
  210 + num_in_map++;
204 211
205 } // endfor: looped over all events 212 } // endfor: looped over all events
206 213
  214 + // Log binning results
  215 + if (logTerse()) {
  216 + log << std::endl;
  217 + log.header1("Binning");
  218 + log << parformat("Events in list");
  219 + log << obs.events()->size() << std::endl;
  220 + log << parformat("Events in map");
  221 + log << num_in_map << std::endl;
  222 + log << parformat("Events outside map area");
  223 + log << num_outside_map << std::endl;
  224 + log << parformat("Events outside energy bins");
  225 + log << num_outside_ebds << std::endl;
  226 + }
  227 +
207 // Log observation 228 // Log observation
208 if (logTerse()) { 229 if (logTerse()) {
209 log << std::endl; 230 log << std::endl;