From 049485d844c01cc491b26e01fa3fbd13b0eea98d Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 13 Feb 2016 00:09:00 +0100 Subject: [PATCH] Adapt to new GCTAResponseTable interface --- inst/cta/src/GCTABackground3D.cpp | 31 ++++++++++++++++--------------- inst/cta/src/GCTAEdisp2D.cpp | 18 +++++++++--------- inst/cta/src/GCTAPsf2D.cpp | 10 +++++----- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/inst/cta/src/GCTABackground3D.cpp b/inst/cta/src/GCTABackground3D.cpp index b30649d..b9e066b 100644 --- a/inst/cta/src/GCTABackground3D.cpp +++ b/inst/cta/src/GCTABackground3D.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTABackground3D.cpp - CTA 3D background class * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2015 by Juergen Knoedlseder * + * copyright (C) 2014-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -190,9 +190,9 @@ double GCTABackground3D::operator()(const double& logE, // Get background rate #if defined(G_LOG_INTERPOLATION) // Retrieve node arrays - const GNodeArray& detx_nodes = m_background.nodes(0); - const GNodeArray& dety_nodes = m_background.nodes(1); - const GNodeArray& energy_nodes = m_background.nodes(2); + const GNodeArray& detx_nodes = m_background.axis_nodes(0); + const GNodeArray& dety_nodes = m_background.axis_nodes(1); + const GNodeArray& energy_nodes = m_background.axis_nodes(2); // Set values for node arrays detx_nodes.set_value(detx); @@ -225,7 +225,8 @@ double GCTABackground3D::operator()(const double& logE, double wgt_emax = energy_nodes.wgt_right(); // Compute offsets in energy dimension - int npixels = m_background.axis(0) * m_background.axis(1); + int npixels = m_background.axis_bins(0) * + m_background.axis_bins(1); int offset_emin = inx_emin * npixels; int offset_emax = inx_emax * npixels; @@ -496,7 +497,7 @@ GCTAInstDir GCTABackground3D::mc(const GEnergy& energy, " in the range ["+ gammalib::str(m_background.axis_lo(2,0))+ " "+m_background.axis_lo_unit(2)+" - "+ - gammalib::str(m_background.axis_hi(2,m_background.axis(2)-1))+ + gammalib::str(m_background.axis_hi(2,m_background.axis_bins(2)-1))+ " "+m_background.axis_hi_unit(2)+"]."; throw GException::invalid_value(G_MC, msg); } @@ -564,23 +565,23 @@ std::string GCTABackground3D::print(const GChatter& chatter) const // Compute DETX boundaries in deg double detx_min = m_background.axis_lo(0,0); - double detx_max = m_background.axis_hi(0,m_background.axis(0)-1); + double detx_max = m_background.axis_hi(0,m_background.axis_bins(0)-1); // Compute DETY boundaries in deg double dety_min = m_background.axis_lo(1,0); - double dety_max = m_background.axis_hi(1,m_background.axis(1)-1); + double dety_max = m_background.axis_hi(1,m_background.axis_bins(1)-1); // Compute energy boundaries in TeV double emin = m_background.axis_lo(2,0); - double emax = m_background.axis_hi(2,m_background.axis(2)-1); + double emax = m_background.axis_hi(2,m_background.axis_bins(2)-1); // Append information result.append("\n"+gammalib::parformat("Number of DETX bins") + - gammalib::str(m_background.axis(0))); + gammalib::str(m_background.axis_bins(0))); result.append("\n"+gammalib::parformat("Number of DETY bins") + - gammalib::str(m_background.axis(1))); + gammalib::str(m_background.axis_bins(1))); result.append("\n"+gammalib::parformat("Number of energy bins") + - gammalib::str(m_background.axis(2))); + gammalib::str(m_background.axis_bins(2))); result.append("\n"+gammalib::parformat("DETX range")); result.append(gammalib::str(detx_min)+" - "+gammalib::str(detx_max)+" deg"); result.append("\n"+gammalib::parformat("DETX range")); @@ -723,9 +724,9 @@ void GCTABackground3D::init_mc_cache(void) const } // Determine number of response cube pixels and maps - m_mc_nx = m_background.axis(0); - m_mc_ny = m_background.axis(1); - m_mc_nmaps = m_background.axis(2); + m_mc_nx = m_background.axis_bins(0); + m_mc_ny = m_background.axis_bins(1); + m_mc_nmaps = m_background.axis_bins(2); // Compute DETX boundaries and binsize in deg. If DETX binsize is too // coarse then request a finer sampling diff --git a/inst/cta/src/GCTAEdisp2D.cpp b/inst/cta/src/GCTAEdisp2D.cpp index ceb5c77..127d7fe 100644 --- a/inst/cta/src/GCTAEdisp2D.cpp +++ b/inst/cta/src/GCTAEdisp2D.cpp @@ -294,9 +294,9 @@ void GCTAEdisp2D::read(const GFitsTable& table) m_edisp.axis_radians(2); // Get axes dimensions - int etrue_size = m_edisp.axis(0); - int migra_size = m_edisp.axis(1); - int theta_size = m_edisp.axis(2); + int etrue_size = m_edisp.axis_bins(0); + int migra_size = m_edisp.axis_bins(1); + int theta_size = m_edisp.axis_bins(2); // Now normalize the migration matrix vectors. We do this by integrating // for each true energy and offset angle the measured energy. We perform @@ -619,11 +619,11 @@ std::string GCTAEdisp2D::print(const GChatter& chatter) const // Compute energy boundaries in TeV double emin = m_edisp.axis_lo(0,0); - double emax = m_edisp.axis_hi(0,m_edisp.axis(0)-1); + double emax = m_edisp.axis_hi(0,m_edisp.axis_bins(0)-1); // Compute offset angle boundaries in deg double omin = m_edisp.axis_lo(1,0); - double omax = m_edisp.axis_hi(1,m_edisp.axis(1)-1); + double omax = m_edisp.axis_hi(1,m_edisp.axis_bins(1)-1); // Append header result.append("=== GCTAEdisp2D ==="); @@ -631,9 +631,9 @@ std::string GCTAEdisp2D::print(const GChatter& chatter) const // Append information result.append("\n"+gammalib::parformat("Filename")+m_filename); result.append("\n"+gammalib::parformat("Number of energy bins") + - gammalib::str(m_edisp.axis(0))); + gammalib::str(m_edisp.axis_bins(0))); result.append("\n"+gammalib::parformat("Number of offset bins") + - gammalib::str(m_edisp.axis(1))); + gammalib::str(m_edisp.axis_bins(1))); result.append("\n"+gammalib::parformat("Log10(Energy) range")); result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV"); result.append("\n"+gammalib::parformat("Offset angle range")); @@ -744,7 +744,7 @@ void GCTAEdisp2D::compute_ebounds_obs(const double& theta, const double eps = 1.0e-12; // Loop over Esrc - for (int isrc = 0; isrc < m_edisp.axis(0); ++isrc) { + for (int isrc = 0; isrc < m_edisp.axis_bins(0); ++isrc) { // Set Esrc double Esrc = std::sqrt(m_edisp.axis_hi(0,isrc) * @@ -758,7 +758,7 @@ void GCTAEdisp2D::compute_ebounds_obs(const double& theta, bool maxFound = false; // Determine number of MIGRA bins - int n_migra = m_edisp.axis(1); + int n_migra = m_edisp.axis_bins(1); // Find minimum boundary for (int i = 0; i < n_migra; ++i) { diff --git a/inst/cta/src/GCTAPsf2D.cpp b/inst/cta/src/GCTAPsf2D.cpp index 1be3159..6bfc3e6 100644 --- a/inst/cta/src/GCTAPsf2D.cpp +++ b/inst/cta/src/GCTAPsf2D.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAPsf2D.cpp - CTA 2D point spread function class * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -627,11 +627,11 @@ std::string GCTAPsf2D::print(const GChatter& chatter) const // Compute energy boundaries in TeV double emin = m_psf.axis_lo(0,0); - double emax = m_psf.axis_hi(0,m_psf.axis(0)-1); + double emax = m_psf.axis_hi(0,m_psf.axis_bins(0)-1); // Compute offset angle boundaries in deg double omin = m_psf.axis_lo(1,0); - double omax = m_psf.axis_hi(1,m_psf.axis(1)-1); + double omax = m_psf.axis_hi(1,m_psf.axis_bins(1)-1); // Append header result.append("=== GCTAPsf2D ==="); @@ -639,9 +639,9 @@ std::string GCTAPsf2D::print(const GChatter& chatter) const // Append information result.append("\n"+gammalib::parformat("Filename")+m_filename); result.append("\n"+gammalib::parformat("Number of energy bins") + - gammalib::str(m_psf.axis(0))); + gammalib::str(m_psf.axis_bins(0))); result.append("\n"+gammalib::parformat("Number of offset bins") + - gammalib::str(m_psf.axis(1))); + gammalib::str(m_psf.axis_bins(1))); result.append("\n"+gammalib::parformat("Log10(Energy) range")); result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV"); result.append("\n"+gammalib::parformat("Offset angle range")); -- libgit2 0.21.4