Commit d414a9caa327dfe8dad68645ce04831be886eed0
Merge branch '1298-add-exception-if-RoI-is-missing' into integration
Showing
3 changed files
with
44 additions
and
0 deletions
inst/cta/src/GCTACubeBackground.cpp
| @@ -45,6 +45,7 @@ | @@ -45,6 +45,7 @@ | ||
| 45 | /* __ Method name definitions ____________________________________________ */ | 45 | /* __ Method name definitions ____________________________________________ */ |
| 46 | #define G_READ "GCTACubeBackground::read(GFits&)" | 46 | #define G_READ "GCTACubeBackground::read(GFits&)" |
| 47 | #define G_MC "GCTACubeBackground::mc(GEnergy&, GTime&, GRan&)" | 47 | #define G_MC "GCTACubeBackground::mc(GEnergy&, GTime&, GRan&)" |
| 48 | +#define G_FILL "GCTACubeBackground::fill(GObservations&, GLog*)" | ||
| 48 | 49 | ||
| 49 | /* __ Macros _____________________________________________________________ */ | 50 | /* __ Macros _____________________________________________________________ */ |
| 50 | 51 | ||
| @@ -326,6 +327,14 @@ void GCTACubeBackground::fill(const GObservations& obs, GLog* log) | @@ -326,6 +327,14 @@ void GCTACubeBackground::fill(const GObservations& obs, GLog* log) | ||
| 326 | // Extract region of interest from CTA observation | 327 | // Extract region of interest from CTA observation |
| 327 | GCTARoi roi = cta->roi(); | 328 | GCTARoi roi = cta->roi(); |
| 328 | 329 | ||
| 330 | + // Check for RoI sanity | ||
| 331 | + if (!roi.is_valid()) { | ||
| 332 | + std::string msg = "No RoI information found in input observation " | ||
| 333 | + "\""+cta->name()+"\". Run ctselect to specify " | ||
| 334 | + "an RoI for this observation"; | ||
| 335 | + throw GException::invalid_value(G_FILL, msg); | ||
| 336 | + } | ||
| 337 | + | ||
| 329 | // Set GTI of actual observations as the GTI of the event cube | 338 | // Set GTI of actual observations as the GTI of the event cube |
| 330 | eventcube.gti(cta->gti()); | 339 | eventcube.gti(cta->gti()); |
| 331 | 340 |
inst/cta/src/GCTACubeExposure.cpp
| @@ -37,6 +37,8 @@ | @@ -37,6 +37,8 @@ | ||
| 37 | #include "GLog.hpp" | 37 | #include "GLog.hpp" |
| 38 | 38 | ||
| 39 | /* __ Method name definitions ____________________________________________ */ | 39 | /* __ Method name definitions ____________________________________________ */ |
| 40 | +#define G_SET "GCTACubeExposure::set(GCTAObservation&)" | ||
| 41 | +#define G_FILL "GCTACubeExposure::fill(GObservations&, GLog*)" | ||
| 40 | 42 | ||
| 41 | /* __ Macros _____________________________________________________________ */ | 43 | /* __ Macros _____________________________________________________________ */ |
| 42 | 44 | ||
| @@ -311,6 +313,14 @@ void GCTACubeExposure::set(const GCTAObservation& obs) | @@ -311,6 +313,14 @@ void GCTACubeExposure::set(const GCTAObservation& obs) | ||
| 311 | // Extract region of interest from CTA observation | 313 | // Extract region of interest from CTA observation |
| 312 | GCTARoi roi = obs.roi(); | 314 | GCTARoi roi = obs.roi(); |
| 313 | 315 | ||
| 316 | + // Check for RoI sanity | ||
| 317 | + if (!roi.is_valid()) { | ||
| 318 | + std::string msg = "No RoI information found in input observation " | ||
| 319 | + "\""+obs.name()+"\". Run ctselect to specify " | ||
| 320 | + "an RoI for this observation"; | ||
| 321 | + throw GException::invalid_value(G_SET, msg); | ||
| 322 | + } | ||
| 323 | + | ||
| 314 | // Get references on CTA response and pointing direction | 324 | // Get references on CTA response and pointing direction |
| 315 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(obs.response()); | 325 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(obs.response()); |
| 316 | const GSkyDir& pnt = obs.pointing().dir(); | 326 | const GSkyDir& pnt = obs.pointing().dir(); |
| @@ -413,6 +423,14 @@ void GCTACubeExposure::fill(const GObservations& obs, GLog* log) | @@ -413,6 +423,14 @@ void GCTACubeExposure::fill(const GObservations& obs, GLog* log) | ||
| 413 | // Extract region of interest from CTA observation | 423 | // Extract region of interest from CTA observation |
| 414 | GCTARoi roi = cta->roi(); | 424 | GCTARoi roi = cta->roi(); |
| 415 | 425 | ||
| 426 | + // Check for RoI sanity | ||
| 427 | + if (!roi.is_valid()) { | ||
| 428 | + std::string msg = "No RoI information found in input observation " | ||
| 429 | + "\""+cta->name()+"\". Run ctselect to specify " | ||
| 430 | + "an RoI for this observation"; | ||
| 431 | + throw GException::invalid_value(G_FILL, msg); | ||
| 432 | + } | ||
| 433 | + | ||
| 416 | // Get references on CTA response and pointing direction | 434 | // Get references on CTA response and pointing direction |
| 417 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(cta->response()); | 435 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(cta->response()); |
| 418 | const GSkyDir& pnt = cta->pointing().dir(); | 436 | const GSkyDir& pnt = cta->pointing().dir(); |
inst/cta/src/GCTACubePsf.cpp
| @@ -38,6 +38,7 @@ | @@ -38,6 +38,7 @@ | ||
| 38 | 38 | ||
| 39 | /* __ Method name definitions ____________________________________________ */ | 39 | /* __ Method name definitions ____________________________________________ */ |
| 40 | #define G_SET "GCTACubePsf::set(GCTAObservation&)" | 40 | #define G_SET "GCTACubePsf::set(GCTAObservation&)" |
| 41 | +#define G_FILL "GCTACubePsf::fill(GObservations&, GLog*)" | ||
| 41 | 42 | ||
| 42 | /* __ Macros _____________________________________________________________ */ | 43 | /* __ Macros _____________________________________________________________ */ |
| 43 | 44 | ||
| @@ -372,6 +373,14 @@ void GCTACubePsf::set(const GCTAObservation& obs) | @@ -372,6 +373,14 @@ void GCTACubePsf::set(const GCTAObservation& obs) | ||
| 372 | } | 373 | } |
| 373 | const GCTARoi& roi = list->roi(); | 374 | const GCTARoi& roi = list->roi(); |
| 374 | 375 | ||
| 376 | + // Check for RoI sanity | ||
| 377 | + if (!roi.is_valid()) { | ||
| 378 | + std::string msg = "No RoI information found in input observation " | ||
| 379 | + "\""+obs.name()+"\". Run ctselect to specify " | ||
| 380 | + "an RoI for this observation"; | ||
| 381 | + throw GException::invalid_value(G_SET, msg); | ||
| 382 | + } | ||
| 383 | + | ||
| 375 | // Get references on CTA response and pointing direction | 384 | // Get references on CTA response and pointing direction |
| 376 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(obs.response()); | 385 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(obs.response()); |
| 377 | const GSkyDir& pnt = obs.pointing().dir(); | 386 | const GSkyDir& pnt = obs.pointing().dir(); |
| @@ -478,6 +487,14 @@ void GCTACubePsf::fill(const GObservations& obs, GLog* log) | @@ -478,6 +487,14 @@ void GCTACubePsf::fill(const GObservations& obs, GLog* log) | ||
| 478 | // Extract region of interest from CTA observation | 487 | // Extract region of interest from CTA observation |
| 479 | GCTARoi roi = cta->roi(); | 488 | GCTARoi roi = cta->roi(); |
| 480 | 489 | ||
| 490 | + // Check for RoI sanity | ||
| 491 | + if (!roi.is_valid()) { | ||
| 492 | + std::string msg = "No RoI information found in input observation " | ||
| 493 | + "\""+cta->name()+"\". Run ctselect to specify " | ||
| 494 | + "an RoI for this observation"; | ||
| 495 | + throw GException::invalid_value(G_FILL, msg); | ||
| 496 | + } | ||
| 497 | + | ||
| 481 | // Get references on CTA response and pointing direction | 498 | // Get references on CTA response and pointing direction |
| 482 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(cta->response()); | 499 | const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(cta->response()); |
| 483 | const GSkyDir& pnt = cta->pointing().dir(); | 500 | const GSkyDir& pnt = cta->pointing().dir(); |