Commit 0b1c5b6e7dcaf2afd273e5f3f7f20bb827ca843e
1 parent
be754c83
Add checks on suitability of observations (#1970)
Added check on whether observation is null or a CountsCube, which was done automatically before when calling 'next_unbinned_observation', but needs to be done explicitly now.
Showing
1 changed file
with
37 additions
and
16 deletions
src/ctbin/ctbin.cpp
| @@ -240,6 +240,22 @@ void ctbin::run(void) | @@ -240,6 +240,22 @@ void ctbin::run(void) | ||
| 240 | for (int o=0; o<m_obs.size(); o++) { | 240 | for (int o=0; o<m_obs.size(); o++) { |
| 241 | GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[o]); | 241 | GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[o]); |
| 242 | 242 | ||
| 243 | + // Skip if the observation is NULL. This can happen if the observation | ||
| 244 | + // isn't a CTA observation | ||
| 245 | + if (obs == NULL) { | ||
| 246 | + std::string msg = " Skipping "+obs->instrument()+" observation"; | ||
| 247 | + log_string(NORMAL, msg); | ||
| 248 | + continue; | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + // Skip observation if we have a binned observation | ||
| 252 | + if (obs->eventtype() == "CountsCube") { | ||
| 253 | + obs = NULL; | ||
| 254 | + std::string msg = " Skipping binned "+obs->instrument()+" observation"; | ||
| 255 | + log_string(NORMAL, msg); | ||
| 256 | + continue; | ||
| 257 | + } | ||
| 258 | + | ||
| 243 | // Fill the cube | 259 | // Fill the cube |
| 244 | fill_cube(obs); | 260 | fill_cube(obs); |
| 245 | 261 | ||
| @@ -266,6 +282,8 @@ void ctbin::run(void) | @@ -266,6 +282,8 @@ void ctbin::run(void) | ||
| 266 | publish(); | 282 | publish(); |
| 267 | } | 283 | } |
| 268 | 284 | ||
| 285 | +log_string(NORMAL, "RUNNING HAS FINISHED"); | ||
| 286 | + | ||
| 269 | // Return | 287 | // Return |
| 270 | return; | 288 | return; |
| 271 | } | 289 | } |
| @@ -550,22 +568,25 @@ void ctbin::fill_cube(GCTAObservation* obs) | @@ -550,22 +568,25 @@ void ctbin::fill_cube(GCTAObservation* obs) | ||
| 550 | 568 | ||
| 551 | } // endfor: looped over all events | 569 | } // endfor: looped over all events |
| 552 | 570 | ||
| 553 | - // Append GTIs | ||
| 554 | - m_gti.extend(events->gti()); | ||
| 555 | - | ||
| 556 | - // Update ontime and livetime | ||
| 557 | - m_ontime += obs->ontime(); | ||
| 558 | - m_livetime += obs->livetime(); | ||
| 559 | - | ||
| 560 | - // Log filling results | ||
| 561 | - log_header3(TERSE, get_obs_header(obs)); | ||
| 562 | - log_value(NORMAL, "Events in list", obs->events()->size()); | ||
| 563 | - log_value(NORMAL, "Events in cube", num_in_map); | ||
| 564 | - log_value(NORMAL, "Events outside RoI", num_outside_roi); | ||
| 565 | - log_value(NORMAL, "Events with invalid WCS", num_invalid_wcs); | ||
| 566 | - log_value(NORMAL, "Events outside cube area", num_outside_map); | ||
| 567 | - log_value(NORMAL, "Events outside energy bins", num_outside_ebds); | ||
| 568 | - | 571 | + #pragma omp critical |
| 572 | + { | ||
| 573 | + // Append GTIs | ||
| 574 | + m_gti.extend(events->gti()); | ||
| 575 | + | ||
| 576 | + // Update ontime and livetime | ||
| 577 | + m_ontime += obs->ontime(); | ||
| 578 | + m_livetime += obs->livetime(); | ||
| 579 | + | ||
| 580 | + // Log filling results | ||
| 581 | + log_header3(TERSE, get_obs_header(obs)); | ||
| 582 | + log_value(NORMAL, "Events in list", obs->events()->size()); | ||
| 583 | + log_value(NORMAL, "Events in cube", num_in_map); | ||
| 584 | + log_value(NORMAL, "Events outside RoI", num_outside_roi); | ||
| 585 | + log_value(NORMAL, "Events with invalid WCS", num_invalid_wcs); | ||
| 586 | + log_value(NORMAL, "Events outside cube area", num_outside_map); | ||
| 587 | + log_value(NORMAL, "Events outside energy bins", num_outside_ebds); | ||
| 588 | + } | ||
| 589 | + | ||
| 569 | // Return | 590 | // Return |
| 570 | return; | 591 | return; |
| 571 | } | 592 | } |