Commit c0406cf295cdcd69ff71aa08159e6f350648bcb2

Authored by Jürgen Knödlseder
1 parent f037610f

Correct pointing computation in ctbin

Showing 1 changed file with 48 additions and 13 deletions
src/ctbin/ctbin.cpp
@@ -291,8 +291,16 @@ void ctbin::run(void) @@ -291,8 +291,16 @@ void ctbin::run(void)
291 m_cubes.clear(); 291 m_cubes.clear();
292 } 292 }
293 293
  294 + // Set mean pointing usage
  295 + std::string use;
  296 + if (m_stack && nobs > 0) {
  297 + use = (*this)["usepnt"].boolean() ? "yes" : "no";
  298 + }
  299 + else {
  300 + use = "no";
  301 + }
  302 +
294 // Log observation selection results 303 // Log observation selection results
295 - std::string use = (*this)["usepnt"].boolean() ? "yes" : "no";  
296 log_header3(NORMAL, "Summary"); 304 log_header3(NORMAL, "Summary");
297 log_value(NORMAL, "Number of observations", nobs); 305 log_value(NORMAL, "Number of observations", nobs);
298 log_value(NORMAL, "Mean pointing", m_mean_pnt.print()); 306 log_value(NORMAL, "Mean pointing", m_mean_pnt.print());
@@ -767,20 +775,47 @@ GSkyMap ctbin::create_cube(const GCTAObservation* obs) @@ -767,20 +775,47 @@ GSkyMap ctbin::create_cube(const GCTAObservation* obs)
767 std::string coordsys = (*this)["coordsys"].string(); 775 std::string coordsys = (*this)["coordsys"].string();
768 std::string proj = (*this)["proj"].string(); 776 std::string proj = (*this)["proj"].string();
769 777
770 - // Read sky map reference  
771 - double xref = 0.0;  
772 - double yref = 0.0;  
773 - bool usepnt = (*this)["usepnt"].boolean();  
774 - if (usepnt) {  
775 - if (gammalib::toupper(coordsys) == "GAL") {  
776 - xref = m_mean_pnt.l_deg();  
777 - yref = m_mean_pnt.b_deg(); 778 + // Initialise sky map reference
  779 + double xref = 0.0;
  780 + double yref = 0.0;
  781 +
  782 + // If pointing direction should be used then extract sky map reference
  783 + // from observation(s)
  784 + if ((*this)["usepnt"].boolean()) {
  785 +
  786 + // If stacking is requested then use the mean pointing direction
  787 + if (m_stack) {
  788 + if (gammalib::toupper(coordsys) == "GAL") {
  789 + xref = m_mean_pnt.l_deg();
  790 + yref = m_mean_pnt.b_deg();
  791 + }
  792 + else {
  793 + xref = m_mean_pnt.ra_deg();
  794 + yref = m_mean_pnt.dec_deg();
  795 + }
778 } 796 }
  797 +
  798 + // ... otherwise use the pointing direction of the observation
779 else { 799 else {
780 - xref = m_mean_pnt.ra_deg();  
781 - yref = m_mean_pnt.dec_deg();  
782 - }  
783 - } 800 +
  801 + // Get pointing
  802 + const GCTAPointing& pnt = obs->pointing();
  803 +
  804 + // Extract coordinates
  805 + if (gammalib::toupper(coordsys) == "GAL") {
  806 + xref = pnt.dir().l_deg();
  807 + yref = pnt.dir().b_deg();
  808 + }
  809 + else {
  810 + xref = pnt.dir().ra_deg();
  811 + yref = pnt.dir().dec_deg();
  812 + }
  813 +
  814 + } // endelse: use pointing direction of observation
  815 +
  816 + } // endif: use pointing direction
  817 +
  818 + // ... otherwise use User defined sky map reference
784 else { 819 else {
785 xref = (*this)["xref"].real(); 820 xref = (*this)["xref"].real();
786 yref = (*this)["yref"].real(); 821 yref = (*this)["yref"].real();