Commit 2311ec860ebb8eeeff1550ef65fc89d7039a8148

Authored by Michael Mayer
1 parent 9b861497

Added exception if RoI is not valid in fill-method

inst/cta/src/GCTACubeBackground.cpp
... ... @@ -45,6 +45,7 @@
45 45 /* __ Method name definitions ____________________________________________ */
46 46 #define G_READ "GCTACubeBackground::read(GFits&)"
47 47 #define G_MC "GCTACubeBackground::mc(GEnergy&, GTime&, GRan&)"
  48 +#define G_FILL_CUBE "GCTACubeBackground::fill_cube(GObservations&)"
48 49  
49 50 /* __ Macros _____________________________________________________________ */
50 51  
... ... @@ -311,6 +312,14 @@ void GCTACubeBackground::fill(const GObservations& obs, GLog* log)
311 312 // Extract region of interest from CTA observation
312 313 GCTARoi roi = cta->roi();
313 314  
  315 + // Check for RoI sanity
  316 + if (!roi.is_valid()) {
  317 + std::string msg = "No RoI information found in input observation "
  318 + "\""+cta->name()+"\". Run ctselect to specify "
  319 + "an RoI for this observation";
  320 + throw GException::invalid_value(G_FILL_CUBE, msg);
  321 + }
  322 +
314 323 // Set GTI of actual observations as the GTI of the event cube
315 324 eventcube.gti(cta->gti());
316 325  
... ...
inst/cta/src/GCTACubeExposure.cpp
... ... @@ -37,6 +37,8 @@
37 37 #include "GLog.hpp"
38 38  
39 39 /* __ Method name definitions ____________________________________________ */
  40 +#define G_SET "GCTACubeExposure::set(GCTAObservation&)"
  41 +#define G_FILL_CUBE "GCTACubeExposure::fill_cube(GObservations&)"
40 42  
41 43 /* __ Macros _____________________________________________________________ */
42 44  
... ... @@ -311,6 +313,14 @@ void GCTACubeExposure::set(const GCTAObservation& obs)
311 313 // Extract region of interest from CTA observation
312 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 324 // Get references on CTA response and pointing direction
315 325 const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(obs.response());
316 326 const GSkyDir& pnt = obs.pointing().dir();
... ... @@ -407,6 +417,14 @@ void GCTACubeExposure::fill(const GObservations&amp; obs, GLog* log)
407 417 // Extract region of interest from CTA observation
408 418 GCTARoi roi = cta->roi();
409 419  
  420 + // Check for RoI sanity
  421 + if (!roi.is_valid()) {
  422 + std::string msg = "No RoI information found in input observation "
  423 + "\""+cta->name()+"\". Run ctselect to specify "
  424 + "an RoI for this observation";
  425 + throw GException::invalid_value(G_FILL_CUBE, msg);
  426 + }
  427 +
410 428 // Get references on CTA response and pointing direction
411 429 const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(cta->response());
412 430 const GSkyDir& pnt = cta->pointing().dir();
... ...
inst/cta/src/GCTACubePsf.cpp
... ... @@ -38,6 +38,7 @@
38 38  
39 39 /* __ Method name definitions ____________________________________________ */
40 40 #define G_SET "GCTACubePsf::set(GCTAObservation&)"
  41 +#define G_FILL_CUBE "GCTACubePsf::fill_cube(GObservations&)"
41 42  
42 43 /* __ Macros _____________________________________________________________ */
43 44  
... ... @@ -372,6 +373,14 @@ void GCTACubePsf::set(const GCTAObservation&amp; obs)
372 373 }
373 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 384 // Get references on CTA response and pointing direction
376 385 const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(obs.response());
377 386 const GSkyDir& pnt = obs.pointing().dir();
... ... @@ -472,6 +481,14 @@ void GCTACubePsf::fill(const GObservations&amp; obs, GLog* log)
472 481 // Extract region of interest from CTA observation
473 482 GCTARoi roi = cta->roi();
474 483  
  484 + // Check for RoI sanity
  485 + if (!roi.is_valid()) {
  486 + std::string msg = "No RoI information found in input observation "
  487 + "\""+cta->name()+"\". Run ctselect to specify "
  488 + "an RoI for this observation";
  489 + throw GException::invalid_value(G_FILL_CUBE, msg);
  490 + }
  491 +
475 492 // Get references on CTA response and pointing direction
476 493 const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>(cta->response());
477 494 const GSkyDir& pnt = cta->pointing().dir();
... ...