Commit 01e9bb4dc903914798f69a6937151ec7720db094

Authored by Michael Mayer
1 parent f29c6e7a

ctmodel respects RoIs in unbinned mode

Showing 1 changed file with 18 additions and 17 deletions
src/ctmodel/ctmodel.cpp
@@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
34 34
35 /* __ Method name definitions ____________________________________________ */ 35 /* __ Method name definitions ____________________________________________ */
36 #define G_GET_PARAMETERS "ctmodel::get_parameters()" 36 #define G_GET_PARAMETERS "ctmodel::get_parameters()"
37 -#define G_FILL_CUBE "ctmodel::fill_cube(GCTAObservation*)"  
38 37
39 /* __ Debug definitions __________________________________________________ */ 38 /* __ Debug definitions __________________________________________________ */
40 39
@@ -586,22 +585,19 @@ void ctmodel::fill_cube(const GCTAObservation* obs) @@ -586,22 +585,19 @@ void ctmodel::fill_cube(const GCTAObservation* obs)
586 // Continue only if observation pointer is valid 585 // Continue only if observation pointer is valid
587 if (obs != NULL) { 586 if (obs != NULL) {
588 587
589 - // Get GTI references for observation 588 + // Get energy boundaries and GTI references for observation
590 const GGti& gti = obs->events()->gti(); 589 const GGti& gti = obs->events()->gti();
591 -  
592 - // Get the ebounds  
593 const GEbounds& obs_ebounds = obs->ebounds(); 590 const GEbounds& obs_ebounds = obs->ebounds();
  591 +
  592 + // Get cube ebounds
594 const GEbounds& cube_ebounds = m_cube.ebounds(); 593 const GEbounds& cube_ebounds = m_cube.ebounds();
595 594
596 - // Extract region of interest from CTA observation  
597 - GCTARoi roi = obs->roi(); 595 + // Initialise empty, invalid RoI
  596 + GCTARoi roi;
598 597
599 - // Check for RoI sanity  
600 - if (!roi.is_valid()) {  
601 - std::string msg = "No RoI information found in input observation "  
602 - "\""+obs->name()+"\". Run ctselect to specify "  
603 - "an RoI for this observation";  
604 - throw GException::invalid_value(G_FILL_CUBE, msg); 598 + // Retrieve RoI in case we have an unbinned observation
  599 + if (obs->eventtype() == "EventList") {
  600 + roi = obs->roi();
605 } 601 }
606 602
607 // Initialise statistics 603 // Initialise statistics
@@ -627,11 +623,16 @@ void ctmodel::fill_cube(const GCTAObservation* obs) @@ -627,11 +623,16 @@ void ctmodel::fill_cube(const GCTAObservation* obs)
627 continue; 623 continue;
628 } 624 }
629 625
630 - // Skip bin if outside RoI  
631 - if (!roi.contains(*bin)) {  
632 - num_outside_roi++;  
633 - continue;  
634 - } 626 + // Check if RoI is valid , i.e. check if we have an unbinned observation
  627 + if (roi.is_valid()) {
  628 +
  629 + // Skip bin if it is outside the RoI of the observation
  630 + if (!roi.contains(*bin)) {
  631 + num_outside_roi++;
  632 + continue;
  633 + } // endif: bin was inside RoI
  634 +
  635 + } // endif: RoI was not valid
635 636
636 // Get actual bin value 637 // Get actual bin value
637 double value = bin->counts(); 638 double value = bin->counts();