/***********************************************************************//** * @brief Computes the maximum radius (in degrees) around a given source * direction that fits spatially into the event cube * * @param[in] srcDir Source direction. * @return Maximum radius in degrees that fully fits into event cube. * * By computing the sky directions of the event cube boundaries, the maximum * radius is computed that fits fully within the event cube. This method is * used for PSF normalization. ***************************************************************************/ double GLATEventCube::maxrad(const GSkyDir& srcDir) const { // Initialise radius double radius = 0.0; // Continue only if sky direction is within sky map if (m_map.contains(srcDir)) { // Set to largest possible radius radius = 180.0; // Move along upper edge in longitude int iy = 0; for (int ix = 0; ix < nx(); ++ix) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } // Move along lower edge in longitude iy = ny()-1; for (int ix = 0; ix < nx(); ++ix) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } // Move along left edge in latitude int ix = 0; for (int iy = 0; iy < ny(); ++iy) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } // Move along right edge in latitude ix = nx()-1; for (int iy = 0; iy < ny(); ++iy) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } } // endif: sky direction within sky map // Return radius return radius; }
/***********************************************************************//** * @brief Computes the maximum radius (in degrees) around a given source * direction that fits spatially into the event cube * * @param[in] srcDir Source direction. * @return Maximum radius in degrees that fully fits into event cube. * * By computing the sky directions of the event cube boundaries, the maximum * radius is computed that fits fully within the event cube. This method is * used for PSF normalization. ***************************************************************************/ double GLATEventCube::maxrad(const GSkyDir& srcDir) const { // Initialise radius double radius = 180.0; // Move along upper edge in longitude int iy = 0; for (int ix = 0; ix < nx(); ++ix) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } // Move along lower edge in longitude iy = ny()-1; for (int ix = 0; ix < nx(); ++ix) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } // Move along left edge in latitude int ix = 0; for (int iy = 0; iy < ny(); ++iy) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } // Move along right edge in latitude ix = nx()-1; for (int iy = 0; iy < ny(); ++iy) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); double distance = m_map.pix2dir(pixel).dist_deg(srcDir); if (distance < radius) { radius = distance; } } // Return radius return radius; }
/***********************************************************************//** * @brief Set sky directions and solid angles of events cube. * * @exception GLATException::no_sky * No sky pixels found in event cube. * * This method computes the sky directions and solid angles for all event * cube pixels. Sky directions are stored in an array of GLATInstDir objects * while solid angles are stored in units of sr in a double precision array. ***************************************************************************/ void GLATEventCube::set_directions(void) { // Throw an error if we have no sky pixels if (npix() < 1) { throw GLATException::no_sky(G_SET_DIRECTIONS, "Every LAT event cube" " needs a definition of the sky pixels."); } // Clear old pixel directions and solid angle m_dirs.clear(); m_solidangle.clear(); // Reserve space for pixel directions and solid angles m_dirs.reserve(npix()); m_solidangle.reserve(npix()); // Set pixel directions and solid angles for (int iy = 0; iy < ny(); ++iy) { for (int ix = 0; ix < nx(); ++ix) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); m_dirs.push_back(GLATInstDir(m_map.pix2dir(pixel))); m_solidangle.push_back(m_map.solidangle(pixel)); } } // Return return; }