Commit 473d708f08016e9cce68bbbb2bc58542a7685c12
1 parent
90a9bcb5
Do not process an empty event file.
The processing for empty event files is skipped. The file is simply written out empty again.
Showing
1 changed file
with
11 additions
and
1 deletions
src/ctselect/ctselect.cpp
| @@ -268,6 +268,16 @@ void ctselect::run(void) | @@ -268,6 +268,16 @@ void ctselect::run(void) | ||
| 268 | // Save event file name (for possible saving) | 268 | // Save event file name (for possible saving) |
| 269 | m_infiles[i] = obs->eventfile(); | 269 | m_infiles[i] = obs->eventfile(); |
| 270 | 270 | ||
| 271 | + // Fall through in case that the event file is empty | ||
| 272 | + if (obs->events()->size() == 0) { | ||
| 273 | + if (logTerse()) { | ||
| 274 | + log << " Warning: No events in event file \""; | ||
| 275 | + log << m_infiles[i] << "\". Event selection skipped."; | ||
| 276 | + log << std::endl; | ||
| 277 | + } | ||
| 278 | + continue; | ||
| 279 | + } | ||
| 280 | + | ||
| 271 | // Get temporary file name | 281 | // Get temporary file name |
| 272 | #if G_USE_MKSTEMP | 282 | #if G_USE_MKSTEMP |
| 273 | char tpl[] = "ctselectXXXXXX"; | 283 | char tpl[] = "ctselectXXXXXX"; |
| @@ -837,7 +847,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | @@ -837,7 +847,7 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) | ||
| 837 | int nevents = file.table("EVENTS")->nrows(); | 847 | int nevents = file.table("EVENTS")->nrows(); |
| 838 | 848 | ||
| 839 | // If the selected event list is empty or if removal of all events | 849 | // If the selected event list is empty or if removal of all events |
| 840 | - // has been requesten then append an empty event list to the observation. | 850 | + // has been requested then append an empty event list to the observation. |
| 841 | if ((nevents < 1) || (remove_all)) { | 851 | if ((nevents < 1) || (remove_all)) { |
| 842 | 852 | ||
| 843 | // Create empty event list | 853 | // Create empty event list |