Commit 86548a09ca2d64130325136641b6c2ea631e9214
1 parent
57ab5a21
Also enhance logging in ctselect.
Showing
1 changed file
with
59 additions
and
26 deletions
src/ctselect/ctselect.cpp
| ... | ... | @@ -243,6 +243,18 @@ void ctselect::run(void) |
| 243 | 243 | // Loop over all observation in the container |
| 244 | 244 | for (int i = 0; i < m_obs.size(); ++i) { |
| 245 | 245 | |
| 246 | + // Write header for observation | |
| 247 | + if (logTerse()) { | |
| 248 | + std::string header = m_obs[i]->instrument() + " observation"; | |
| 249 | + if (m_obs[i]->name().length() > 1) { | |
| 250 | + header += " \"" + m_obs[i]->name() + "\""; | |
| 251 | + } | |
| 252 | + if (m_obs[i]->id().length() > 1) { | |
| 253 | + header += " (id=" + m_obs[i]->id() +")"; | |
| 254 | + } | |
| 255 | + log.header3(header); | |
| 256 | + } | |
| 257 | + | |
| 246 | 258 | // Initialise event input and output filenames |
| 247 | 259 | m_infiles.push_back(""); |
| 248 | 260 | |
| ... | ... | @@ -252,9 +264,9 @@ void ctselect::run(void) |
| 252 | 264 | // Skip observation if it's not CTA |
| 253 | 265 | if (obs == NULL) { |
| 254 | 266 | if (logTerse()) { |
| 255 | - log << "Warning: Skipping "+m_obs[i]->instrument(); | |
| 256 | - log << " observation \""; | |
| 257 | - log << m_obs[i]->name() << "\"" << std::endl; | |
| 267 | + log << " Skipping "; | |
| 268 | + log << m_obs[i]->instrument(); | |
| 269 | + log << " observation" << std::endl; | |
| 258 | 270 | } |
| 259 | 271 | continue; |
| 260 | 272 | } |
| ... | ... | @@ -262,22 +274,13 @@ void ctselect::run(void) |
| 262 | 274 | // Skip observation if we have a binned observation |
| 263 | 275 | if (obs->eventtype() == "CountsCube") { |
| 264 | 276 | if (logTerse()) { |
| 265 | - log << "Warning: Skipping binned observation \""; | |
| 266 | - log << obs->name()+"\"" << std::endl; | |
| 277 | + log << " Skipping binned "; | |
| 278 | + log << obs->instrument(); | |
| 279 | + log << " observation" << std::endl; | |
| 267 | 280 | } |
| 268 | 281 | continue; |
| 269 | 282 | } |
| 270 | 283 | |
| 271 | - // Write header for observation | |
| 272 | - if (logTerse()) { | |
| 273 | - if (obs->name().length() > 1) { | |
| 274 | - log.header3("Observation "+obs->name()); | |
| 275 | - } | |
| 276 | - else { | |
| 277 | - log.header3("Observation"); | |
| 278 | - } | |
| 279 | - } | |
| 280 | - | |
| 281 | 284 | // Increment counter |
| 282 | 285 | n_observations++; |
| 283 | 286 | |
| ... | ... | @@ -1149,8 +1152,23 @@ void ctselect::save_fits(void) |
| 1149 | 1152 | // Get CTA observation from observation container |
| 1150 | 1153 | GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[0]); |
| 1151 | 1154 | |
| 1152 | - // Save event list | |
| 1153 | - save_event_list(obs, m_infiles[0], m_outobs); | |
| 1155 | + // Save only if it's a CTA observation | |
| 1156 | + if (obs != NULL) { | |
| 1157 | + | |
| 1158 | + // Save only if filename is non-empty | |
| 1159 | + if (m_infiles[0].length() > 0) { | |
| 1160 | + | |
| 1161 | + // Dump filename | |
| 1162 | + if (logTerse()) { | |
| 1163 | + log << "Save \""+m_infiles[0]+"\"" << std::endl; | |
| 1164 | + } | |
| 1165 | + | |
| 1166 | + // Save event list | |
| 1167 | + save_event_list(obs, m_infiles[0], m_outobs); | |
| 1168 | + | |
| 1169 | + } // endif: filename was non empty | |
| 1170 | + | |
| 1171 | + } // endif: observation was CTA observation | |
| 1154 | 1172 | |
| 1155 | 1173 | // Return |
| 1156 | 1174 | return; |
| ... | ... | @@ -1191,22 +1209,37 @@ void ctselect::save_xml(void) |
| 1191 | 1209 | // Get CTA observation |
| 1192 | 1210 | GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]); |
| 1193 | 1211 | |
| 1194 | - // Handle only CTA observations | |
| 1195 | - if (obs != NULL) { | |
| 1212 | + // Skip observations that are no CTA observations | |
| 1213 | + if (obs == NULL) { | |
| 1214 | + continue; | |
| 1215 | + } | |
| 1196 | 1216 | |
| 1197 | - // Set event output file name | |
| 1198 | - std::string outfile = set_outfile_name(m_infiles[i]); | |
| 1217 | + // Skip observations that have empty names | |
| 1218 | + if (m_infiles[i].length() == 0) { | |
| 1219 | + continue; | |
| 1220 | + } | |
| 1199 | 1221 | |
| 1200 | - // Store output file name in observation | |
| 1201 | - obs->eventfile(outfile); | |
| 1222 | + // Set event output file name | |
| 1223 | + std::string outfile = set_outfile_name(m_infiles[i]); | |
| 1202 | 1224 | |
| 1203 | - // Save event list | |
| 1204 | - save_event_list(obs, m_infiles[i], outfile); | |
| 1225 | + // Dump filename | |
| 1226 | + if (logTerse()) { | |
| 1227 | + log << "Save \""+outfile+"\"" << std::endl; | |
| 1228 | + } | |
| 1205 | 1229 | |
| 1206 | - } // endif: observation was a CTA observations | |
| 1230 | + // Store output file name in observation | |
| 1231 | + obs->eventfile(outfile); | |
| 1232 | + | |
| 1233 | + // Save event list | |
| 1234 | + save_event_list(obs, m_infiles[i], outfile); | |
| 1207 | 1235 | |
| 1208 | 1236 | } // endfor: looped over observations |
| 1209 | 1237 | |
| 1238 | + // Dump filename | |
| 1239 | + if (logTerse()) { | |
| 1240 | + log << "Save \""+m_outobs+"\"" << std::endl; | |
| 1241 | + } | |
| 1242 | + | |
| 1210 | 1243 | // Save observations in XML file |
| 1211 | 1244 | m_obs.save(m_outobs); |
| 1212 | 1245 | ... | ... |