Commit f29c6e7ad1074791bfcb1a6f1bbb00028ee54d8a

Authored by Michael Mayer
1 parent 3b0fd743

ctmodel now takes into account the RoI information when filling the cube

Showing 1 changed file with 22 additions and 2 deletions
src/ctmodel/ctmodel.cpp
... ... @@ -34,6 +34,7 @@
34 34  
35 35 /* __ Method name definitions ____________________________________________ */
36 36 #define G_GET_PARAMETERS "ctmodel::get_parameters()"
  37 +#define G_FILL_CUBE "ctmodel::fill_cube(GCTAObservation*)"
37 38  
38 39 /* __ Debug definitions __________________________________________________ */
39 40  
... ... @@ -585,17 +586,28 @@ void ctmodel::fill_cube(const GCTAObservation* obs)
585 586 // Continue only if observation pointer is valid
586 587 if (obs != NULL) {
587 588  
588   - // Get energy boundaries and GTI references for observation
589   - const GEbounds& ebounds = obs->events()->ebounds();
  589 + // Get GTI references for observation
590 590 const GGti& gti = obs->events()->gti();
591 591  
592 592 // Get the ebounds
593 593 const GEbounds& obs_ebounds = obs->ebounds();
594 594 const GEbounds& cube_ebounds = m_cube.ebounds();
595 595  
  596 + // Extract region of interest from CTA observation
  597 + GCTARoi roi = obs->roi();
  598 +
  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);
  605 + }
  606 +
596 607 // Initialise statistics
597 608 double sum = 0.0;
598 609 int num_outside_ebds = 0;
  610 + int num_outside_roi = 0;
599 611  
600 612 // Setup cube GTIs for this observation
601 613 m_cube.gti(obs->events()->gti());
... ... @@ -615,6 +627,12 @@ void ctmodel::fill_cube(const GCTAObservation* obs)
615 627 continue;
616 628 }
617 629  
  630 + // Skip bin if outside RoI
  631 + if (!roi.contains(*bin)) {
  632 + num_outside_roi++;
  633 + continue;
  634 + }
  635 +
618 636 // Get actual bin value
619 637 double value = bin->counts();
620 638  
... ... @@ -642,6 +660,8 @@ void ctmodel::fill_cube(const GCTAObservation* obs)
642 660 log << sum << std::endl;
643 661 log << gammalib::parformat("Bins outside energy range");
644 662 log << num_outside_ebds << std::endl;
  663 + log << gammalib::parformat("Bins outside RoI");
  664 + log << num_outside_roi << std::endl;
645 665 }
646 666  
647 667 // Log cube
... ...