diff --git a/inst/cta/src/GCTACubeBackground.cpp b/inst/cta/src/GCTACubeBackground.cpp index 78da8fa..42f0fb3 100644 --- a/inst/cta/src/GCTACubeBackground.cpp +++ b/inst/cta/src/GCTACubeBackground.cpp @@ -45,6 +45,7 @@ /* __ Method name definitions ____________________________________________ */ #define G_READ "GCTACubeBackground::read(GFits&)" #define G_MC "GCTACubeBackground::mc(GEnergy&, GTime&, GRan&)" +#define G_FILL "GCTACubeBackground::fill(GObservations&, GLog*)" /* __ Macros _____________________________________________________________ */ @@ -326,6 +327,14 @@ void GCTACubeBackground::fill(const GObservations& obs, GLog* log) // Extract region of interest from CTA observation GCTARoi roi = cta->roi(); + // Check for RoI sanity + if (!roi.is_valid()) { + std::string msg = "No RoI information found in input observation " + "\""+cta->name()+"\". Run ctselect to specify " + "an RoI for this observation"; + throw GException::invalid_value(G_FILL, msg); + } + // Set GTI of actual observations as the GTI of the event cube eventcube.gti(cta->gti()); diff --git a/inst/cta/src/GCTACubeExposure.cpp b/inst/cta/src/GCTACubeExposure.cpp index be2aeeb..a7b4d00 100644 --- a/inst/cta/src/GCTACubeExposure.cpp +++ b/inst/cta/src/GCTACubeExposure.cpp @@ -37,6 +37,8 @@ #include "GLog.hpp" /* __ Method name definitions ____________________________________________ */ +#define G_SET "GCTACubeExposure::set(GCTAObservation&)" +#define G_FILL "GCTACubeExposure::fill(GObservations&, GLog*)" /* __ Macros _____________________________________________________________ */ @@ -311,6 +313,14 @@ void GCTACubeExposure::set(const GCTAObservation& obs) // Extract region of interest from CTA observation GCTARoi roi = obs.roi(); + // Check for RoI sanity + if (!roi.is_valid()) { + std::string msg = "No RoI information found in input observation " + "\""+obs.name()+"\". Run ctselect to specify " + "an RoI for this observation"; + throw GException::invalid_value(G_SET, msg); + } + // Get references on CTA response and pointing direction const GCTAResponseIrf* rsp = dynamic_cast(obs.response()); const GSkyDir& pnt = obs.pointing().dir(); @@ -413,6 +423,14 @@ void GCTACubeExposure::fill(const GObservations& obs, GLog* log) // Extract region of interest from CTA observation GCTARoi roi = cta->roi(); + // Check for RoI sanity + if (!roi.is_valid()) { + std::string msg = "No RoI information found in input observation " + "\""+cta->name()+"\". Run ctselect to specify " + "an RoI for this observation"; + throw GException::invalid_value(G_FILL, msg); + } + // Get references on CTA response and pointing direction const GCTAResponseIrf* rsp = dynamic_cast(cta->response()); const GSkyDir& pnt = cta->pointing().dir(); diff --git a/inst/cta/src/GCTACubePsf.cpp b/inst/cta/src/GCTACubePsf.cpp index 4804195..3946915 100644 --- a/inst/cta/src/GCTACubePsf.cpp +++ b/inst/cta/src/GCTACubePsf.cpp @@ -38,6 +38,7 @@ /* __ Method name definitions ____________________________________________ */ #define G_SET "GCTACubePsf::set(GCTAObservation&)" +#define G_FILL "GCTACubePsf::fill(GObservations&, GLog*)" /* __ Macros _____________________________________________________________ */ @@ -372,6 +373,14 @@ void GCTACubePsf::set(const GCTAObservation& obs) } const GCTARoi& roi = list->roi(); + // Check for RoI sanity + if (!roi.is_valid()) { + std::string msg = "No RoI information found in input observation " + "\""+obs.name()+"\". Run ctselect to specify " + "an RoI for this observation"; + throw GException::invalid_value(G_SET, msg); + } + // Get references on CTA response and pointing direction const GCTAResponseIrf* rsp = dynamic_cast(obs.response()); const GSkyDir& pnt = obs.pointing().dir(); @@ -478,6 +487,14 @@ void GCTACubePsf::fill(const GObservations& obs, GLog* log) // Extract region of interest from CTA observation GCTARoi roi = cta->roi(); + // Check for RoI sanity + if (!roi.is_valid()) { + std::string msg = "No RoI information found in input observation " + "\""+cta->name()+"\". Run ctselect to specify " + "an RoI for this observation"; + throw GException::invalid_value(G_FILL, msg); + } + // Get references on CTA response and pointing direction const GCTAResponseIrf* rsp = dynamic_cast(cta->response()); const GSkyDir& pnt = cta->pointing().dir();