Commit fe605e26843d6e71bdc8f4bd0fb937d87c4f7d87
1 parent
69af2a8e
add specific Aeff and Edisp modules
Showing
7 changed files
with
439 additions
and
172 deletions
include/GLATResponse.hpp
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | ***************************************************************************/ |
| 13 | 13 | /** |
| 14 | 14 | * @file GLATResponse.hpp |
| 15 | - * @brief GLATResponse class definition. | |
| 15 | + * @brief GLATResponse class interface definition. | |
| 16 | 16 | * @author J. Knodlseder |
| 17 | 17 | */ |
| 18 | 18 | |
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | #include "GSkyDir.hpp" |
| 26 | 26 | #include "GResponse.hpp" |
| 27 | 27 | #include "GLATResponseTable.hpp" |
| 28 | +#include "GFits.hpp" | |
| 28 | 29 | #include "GFitsHDU.hpp" |
| 29 | 30 | |
| 30 | 31 | /* __ Namespaces _________________________________________________________ */ |
| ... | ... | @@ -52,19 +53,19 @@ public: |
| 52 | 53 | const GSkyDir& instPntDir, const double& instPosAng, |
| 53 | 54 | const double& time); |
| 54 | 55 | |
| 55 | - // PSF Methods | |
| 56 | - double psf(const GSkyDir& obsDir, const double& obsEng, | |
| 56 | + // Aeff Methods | |
| 57 | + double aeff(const GSkyDir& obsDir, const double& obsEng, | |
| 57 | 58 | const GSkyDir& srcDir, const double& srcEng, |
| 58 | 59 | const GSkyDir& instPntDir, const double& instPosAng, |
| 59 | 60 | const double& time); |
| 60 | - double psf(const double& delta, const double& logE, const double& ctheta); | |
| 61 | - GVector psf(const GVector& delta, const double& logE, const double& ctheta); | |
| 62 | 61 | |
| 63 | - // Aeff Methods | |
| 64 | - double aeff(const GSkyDir& obsDir, const double& obsEng, | |
| 62 | + // PSF Methods | |
| 63 | + double psf(const GSkyDir& obsDir, const double& obsEng, | |
| 65 | 64 | const GSkyDir& srcDir, const double& srcEng, |
| 66 | 65 | const GSkyDir& instPntDir, const double& instPosAng, |
| 67 | 66 | const double& time); |
| 67 | + double psf(const double& delta, const double& logE, const double& ctheta); | |
| 68 | + GVector psf(const GVector& delta, const double& logE, const double& ctheta); | |
| 68 | 69 | |
| 69 | 70 | // Edisp Methods |
| 70 | 71 | double edisp(const GSkyDir& obsDir, const double& obsEng, |
| ... | ... | @@ -80,7 +81,11 @@ public: |
| 80 | 81 | |
| 81 | 82 | private: |
| 82 | 83 | // Private Effective Area methods |
| 83 | - void aeff_init(void); | |
| 84 | + void aeff_init(void); | |
| 85 | + void aeff_append(GFits& file) const; | |
| 86 | + void aeff_init_members(void); | |
| 87 | + void aeff_copy_members(const GLATResponse& rsp); | |
| 88 | + void aeff_free_members(void); | |
| 84 | 89 | |
| 85 | 90 | // Private PSF methods |
| 86 | 91 | void psf_init(void); |
| ... | ... | @@ -93,26 +98,36 @@ private: |
| 93 | 98 | void psf_copy_members(const GLATResponse& rsp); |
| 94 | 99 | void psf_free_members(void); |
| 95 | 100 | |
| 96 | - // Private PSF data | |
| 97 | - GLATResponseTable m_psf_bins; //!< Energy and cos theta binning | |
| 98 | - GNodeArray m_psf_angle; //!< PSF vector binning | |
| 99 | - double m_psf_angle_max; //!< Maximum angular distance covered | |
| 100 | - double* m_psf; //!< PSF vector array | |
| 101 | - double* m_norm; //!< PSF normalization array | |
| 102 | - double* m_sigma; //!< PSF sigma array | |
| 103 | - | |
| 104 | 101 | // Private energy dissipation methods |
| 105 | - void edisp_init(void); | |
| 102 | + void edisp_init(void); | |
| 103 | + void edisp_append(GFits& file) const; | |
| 104 | + void edisp_init_members(void); | |
| 105 | + void edisp_copy_members(const GLATResponse& rsp); | |
| 106 | + void edisp_free_members(void); | |
| 106 | 107 | |
| 107 | - // Private methods | |
| 108 | + // Other private methods | |
| 108 | 109 | void init_members(void); |
| 109 | 110 | void copy_members(const GLATResponse& rsp); |
| 110 | 111 | void free_members(void); |
| 111 | 112 | GVector get_fits_vector(const GFitsHDU* hdu, const std::string& colname, int row = 0); |
| 112 | 113 | |
| 113 | - // Private data area | |
| 114 | - std::string m_rsptype; | |
| 115 | - int m_section; // 0=front, 1=back | |
| 114 | + // Private Aeff data | |
| 115 | + GLATResponseTable m_aeff_bins; //!< Aeff energy and cos theta binning | |
| 116 | + | |
| 117 | + // Private PSF data | |
| 118 | + GLATResponseTable m_psf_bins; //!< PSF energy and cos theta binning | |
| 119 | + GNodeArray m_psf_angle; //!< PSF vector binning | |
| 120 | + double m_psf_angle_max; //!< PSF maximum angular distance covered | |
| 121 | + double* m_psf; //!< PSF vector array | |
| 122 | + double* m_norm; //!< PSF normalization array | |
| 123 | + double* m_sigma; //!< PSF sigma array | |
| 124 | + | |
| 125 | + // Private Edisp data | |
| 126 | + GLATResponseTable m_edisp_bins; //!< Edisp energy and cos theta binning | |
| 127 | + | |
| 128 | + // Other private data | |
| 129 | + std::string m_rsptype; //!< Response type ('front','back') | |
| 130 | + int m_section; //!< PSF section (0=front, 1=back) | |
| 116 | 131 | |
| 117 | 132 | }; |
| 118 | 133 | ... | ... |
src/Makefile.am
| ... | ... | @@ -16,7 +16,9 @@ files = GException.cpp \ |
| 16 | 16 | rsp/GResponse.cpp \ |
| 17 | 17 | rsp/GLATResponse.cpp \ |
| 18 | 18 | rsp/GLATResponseTable.cpp \ |
| 19 | + rsp/GLATAeff.cpp \ | |
| 19 | 20 | rsp/GLATPsf.cpp \ |
| 21 | + rsp/GLATEdisp.cpp \ | |
| 20 | 22 | obs/GObservation.cpp \ |
| 21 | 23 | fits/GFitsHeaderCard.cpp \ |
| 22 | 24 | fits/GFitsHeader.cpp \ | ... | ... |
src/Makefile.in
| ... | ... | @@ -121,7 +121,9 @@ files = GException.cpp \ |
| 121 | 121 | rsp/GResponse.cpp \ |
| 122 | 122 | rsp/GLATResponse.cpp \ |
| 123 | 123 | rsp/GLATResponseTable.cpp \ |
| 124 | + rsp/GLATAeff.cpp \ | |
| 124 | 125 | rsp/GLATPsf.cpp \ |
| 126 | + rsp/GLATEdisp.cpp \ | |
| 125 | 127 | obs/GObservation.cpp \ |
| 126 | 128 | fits/GFitsHeaderCard.cpp \ |
| 127 | 129 | fits/GFitsHeader.cpp \ |
| ... | ... | @@ -162,13 +164,14 @@ LTLIBRARIES = $(lib_LTLIBRARIES) |
| 162 | 164 | libgamma_la_LIBADD = |
| 163 | 165 | am__objects_1 = GException.lo GTools.lo GSkyDir.lo GNodeArray.lo \ |
| 164 | 166 | GData.lo GResponse.lo GLATResponse.lo GLATResponseTable.lo \ |
| 165 | - GLATPsf.lo GObservation.lo GFitsHeaderCard.lo GFitsHeader.lo \ | |
| 166 | - GFitsData.lo GFitsImage.lo GFitsDblImage.lo GFitsTable.lo \ | |
| 167 | - GFitsAsciiTable.lo GFitsBinTable.lo GFitsTableCol.lo \ | |
| 168 | - GFitsTableStrCol.lo GFitsTableShtCol.lo GFitsTableLngCol.lo \ | |
| 169 | - GFitsTableFltCol.lo GFitsTableDblCol.lo GFitsHDU.lo GFits.lo \ | |
| 170 | - GFitPar.lo GVector.lo GMatrixBase.lo GMatrix.lo GSymMatrix.lo \ | |
| 171 | - GSparseMatrix.lo GSparseSymbolic.lo GSparseNumeric.lo | |
| 167 | + GLATAeff.lo GLATPsf.lo GLATEdisp.lo GObservation.lo \ | |
| 168 | + GFitsHeaderCard.lo GFitsHeader.lo GFitsData.lo GFitsImage.lo \ | |
| 169 | + GFitsDblImage.lo GFitsTable.lo GFitsAsciiTable.lo \ | |
| 170 | + GFitsBinTable.lo GFitsTableCol.lo GFitsTableStrCol.lo \ | |
| 171 | + GFitsTableShtCol.lo GFitsTableLngCol.lo GFitsTableFltCol.lo \ | |
| 172 | + GFitsTableDblCol.lo GFitsHDU.lo GFits.lo GFitPar.lo GVector.lo \ | |
| 173 | + GMatrixBase.lo GMatrix.lo GSymMatrix.lo GSparseMatrix.lo \ | |
| 174 | + GSparseSymbolic.lo GSparseNumeric.lo | |
| 172 | 175 | am_libgamma_la_OBJECTS = $(am__objects_1) |
| 173 | 176 | libgamma_la_OBJECTS = $(am_libgamma_la_OBJECTS) |
| 174 | 177 | |
| ... | ... | @@ -233,7 +236,9 @@ GData.lo: data/GData.cpp |
| 233 | 236 | GResponse.lo: rsp/GResponse.cpp |
| 234 | 237 | GLATResponse.lo: rsp/GLATResponse.cpp |
| 235 | 238 | GLATResponseTable.lo: rsp/GLATResponseTable.cpp |
| 239 | +GLATAeff.lo: rsp/GLATAeff.cpp | |
| 236 | 240 | GLATPsf.lo: rsp/GLATPsf.cpp |
| 241 | +GLATEdisp.lo: rsp/GLATEdisp.cpp | |
| 237 | 242 | GObservation.lo: obs/GObservation.cpp |
| 238 | 243 | GFitsHeaderCard.lo: fits/GFitsHeaderCard.cpp |
| 239 | 244 | GFitsHeader.lo: fits/GFitsHeader.cpp |
| ... | ... | @@ -313,6 +318,15 @@ GLATResponseTable.obj: rsp/GLATResponseTable.cpp |
| 313 | 318 | GLATResponseTable.lo: rsp/GLATResponseTable.cpp |
| 314 | 319 | $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATResponseTable.lo `test -f 'rsp/GLATResponseTable.cpp' || echo '$(srcdir)/'`rsp/GLATResponseTable.cpp |
| 315 | 320 | |
| 321 | +GLATAeff.o: rsp/GLATAeff.cpp | |
| 322 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATAeff.o `test -f 'rsp/GLATAeff.cpp' || echo '$(srcdir)/'`rsp/GLATAeff.cpp | |
| 323 | + | |
| 324 | +GLATAeff.obj: rsp/GLATAeff.cpp | |
| 325 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATAeff.obj `cygpath -w rsp/GLATAeff.cpp` | |
| 326 | + | |
| 327 | +GLATAeff.lo: rsp/GLATAeff.cpp | |
| 328 | + $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATAeff.lo `test -f 'rsp/GLATAeff.cpp' || echo '$(srcdir)/'`rsp/GLATAeff.cpp | |
| 329 | + | |
| 316 | 330 | GLATPsf.o: rsp/GLATPsf.cpp |
| 317 | 331 | $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATPsf.o `test -f 'rsp/GLATPsf.cpp' || echo '$(srcdir)/'`rsp/GLATPsf.cpp |
| 318 | 332 | |
| ... | ... | @@ -322,6 +336,15 @@ GLATPsf.obj: rsp/GLATPsf.cpp |
| 322 | 336 | GLATPsf.lo: rsp/GLATPsf.cpp |
| 323 | 337 | $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATPsf.lo `test -f 'rsp/GLATPsf.cpp' || echo '$(srcdir)/'`rsp/GLATPsf.cpp |
| 324 | 338 | |
| 339 | +GLATEdisp.o: rsp/GLATEdisp.cpp | |
| 340 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATEdisp.o `test -f 'rsp/GLATEdisp.cpp' || echo '$(srcdir)/'`rsp/GLATEdisp.cpp | |
| 341 | + | |
| 342 | +GLATEdisp.obj: rsp/GLATEdisp.cpp | |
| 343 | + $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATEdisp.obj `cygpath -w rsp/GLATEdisp.cpp` | |
| 344 | + | |
| 345 | +GLATEdisp.lo: rsp/GLATEdisp.cpp | |
| 346 | + $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GLATEdisp.lo `test -f 'rsp/GLATEdisp.cpp' || echo '$(srcdir)/'`rsp/GLATEdisp.cpp | |
| 347 | + | |
| 325 | 348 | GObservation.o: obs/GObservation.cpp |
| 326 | 349 | $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o GObservation.o `test -f 'obs/GObservation.cpp' || echo '$(srcdir)/'`obs/GObservation.cpp |
| 327 | 350 | ... | ... |
src/rsp/GLATAeff.cpp
0 โ 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GLATAeff.cpp - GLAST LAT Response class Aeff methods * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright : (C) 2008 by Jurgen Knodlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software; you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation; either version 2 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * ----------------------------------------------------------------------- * | |
| 13 | + ***************************************************************************/ | |
| 14 | +/** | |
| 15 | + * @file GLATAeff.cpp | |
| 16 | + * @brief GLATResponse class effective area implementation. | |
| 17 | + * @author J. Knodlseder | |
| 18 | + */ | |
| 19 | + | |
| 20 | +/* __ Includes ___________________________________________________________ */ | |
| 21 | +#include <iostream> | |
| 22 | +#include "GTools.hpp" | |
| 23 | +#include "GException.hpp" | |
| 24 | +#include "GLATResponse.hpp" | |
| 25 | +#include "GFitsDblImage.hpp" | |
| 26 | +#include "GFitsTableFltCol.hpp" | |
| 27 | + | |
| 28 | +/* __ Namespaces _________________________________________________________ */ | |
| 29 | + | |
| 30 | +/* __ Method name definitions ____________________________________________ */ | |
| 31 | +#define G_INIT_AEFF "GLATResponse::init_aeff()" | |
| 32 | + | |
| 33 | +/* __ Macros _____________________________________________________________ */ | |
| 34 | + | |
| 35 | +/* __ Coding definitions _________________________________________________ */ | |
| 36 | + | |
| 37 | +/* __ Debug definitions __________________________________________________ */ | |
| 38 | + | |
| 39 | +/* __ Constants __________________________________________________________ */ | |
| 40 | + | |
| 41 | + | |
| 42 | +/*========================================================================== | |
| 43 | + = = | |
| 44 | + = Public methods = | |
| 45 | + = = | |
| 46 | + ==========================================================================*/ | |
| 47 | + | |
| 48 | +/***********************************************************************//** | |
| 49 | + * @brief Return effective area | |
| 50 | + * | |
| 51 | + * @param[in] obsDir Observed photon direction | |
| 52 | + * @param[in] obsEng Observed energy of photon | |
| 53 | + * @param[in] srcDir True photon direction | |
| 54 | + * @param[in] srcEng True energy of photon | |
| 55 | + * @param[in] instPntDir Instrument pointing direction (e.g. z-axis) | |
| 56 | + * @param[in] instPosAng Instrument position angle | |
| 57 | + * @param[in] time Photon arrival time | |
| 58 | + ***************************************************************************/ | |
| 59 | +double GLATResponse::aeff(const GSkyDir& obsDir, const double& obsEng, | |
| 60 | + const GSkyDir& srcDir, const double& srcEng, | |
| 61 | + const GSkyDir& instPntDir, const double& instPosAng, | |
| 62 | + const double& time) | |
| 63 | +{ | |
| 64 | + // Return Aeff value | |
| 65 | + return 0.0; //!< @todo Not yet implemented | |
| 66 | +} | |
| 67 | + | |
| 68 | + | |
| 69 | +/*========================================================================== | |
| 70 | + = = | |
| 71 | + = Private methods = | |
| 72 | + = = | |
| 73 | + ==========================================================================*/ | |
| 74 | + | |
| 75 | +/***********************************************************************//** | |
| 76 | + * @brief Initialise effective area | |
| 77 | + ***************************************************************************/ | |
| 78 | +void GLATResponse::aeff_init(void) | |
| 79 | +{ | |
| 80 | + // Build filename | |
| 81 | + std::string filename = "aeff_" + m_rspname + "_" + m_rsptype + ".fits"; | |
| 82 | + | |
| 83 | + // Open FITS file | |
| 84 | + GFits file; | |
| 85 | + file.open(m_caldb + "/" + filename); | |
| 86 | + | |
| 87 | + // Get pointer to effective area HDU | |
| 88 | + GFitsHDU* hdu = file.hdu("EFFECTIVE AREA"); | |
| 89 | + if (hdu == NULL) | |
| 90 | + throw GException::fits_hdu_not_found(G_INIT_AEFF, "EFFECTIVE AREA"); | |
| 91 | + | |
| 92 | + // Get the energy and cos(theta) bins | |
| 93 | + m_aeff_bins.load(hdu); | |
| 94 | + | |
| 95 | + // Get the data | |
| 96 | + GVector effarea = get_fits_vector(hdu, "EFFAREA"); | |
| 97 | + | |
| 98 | + // Return | |
| 99 | + return; | |
| 100 | +} | |
| 101 | + | |
| 102 | + | |
| 103 | +/***********************************************************************//** | |
| 104 | + * @brief Append Aeff HDUs tu FOTS file | |
| 105 | + * | |
| 106 | + * @param[in] file FITS file into which the Aeff HDUs will be appended | |
| 107 | + * | |
| 108 | + * Append 2 HDUs to the FITS file: | |
| 109 | + * ABOUNDS (Aeff energy and zenith angle boundaries) | |
| 110 | + * AEFF (Aeff array) | |
| 111 | + ***************************************************************************/ | |
| 112 | +void GLATResponse::aeff_append(GFits& file) const | |
| 113 | +{ | |
| 114 | + // Get Aeff boundary table | |
| 115 | + GFitsHDU hdu_bounds; | |
| 116 | + m_aeff_bins.save(&hdu_bounds); | |
| 117 | + hdu_bounds.extname("ABOUNDS"); | |
| 118 | + | |
| 119 | + // Append HDUs to FITS file | |
| 120 | + file.append_hdu(hdu_bounds); | |
| 121 | + | |
| 122 | + // Return | |
| 123 | + return; | |
| 124 | +} | |
| 125 | + | |
| 126 | + | |
| 127 | +/***********************************************************************//** | |
| 128 | + * @brief Initialise class members | |
| 129 | + ***************************************************************************/ | |
| 130 | +void GLATResponse::aeff_init_members(void) | |
| 131 | +{ | |
| 132 | + // Initialise Aeff members | |
| 133 | + | |
| 134 | + // Return | |
| 135 | + return; | |
| 136 | +} | |
| 137 | + | |
| 138 | + | |
| 139 | +/***********************************************************************//** | |
| 140 | + * @brief Copy class members | |
| 141 | + ***************************************************************************/ | |
| 142 | +void GLATResponse::aeff_copy_members(const GLATResponse& rsp) | |
| 143 | +{ | |
| 144 | + // Return | |
| 145 | + return; | |
| 146 | +} | |
| 147 | + | |
| 148 | + | |
| 149 | +/***********************************************************************//** | |
| 150 | + * @brief Delete class members | |
| 151 | +***************************************************************************/ | |
| 152 | +void GLATResponse::aeff_free_members(void) | |
| 153 | +{ | |
| 154 | + // Return | |
| 155 | + return; | |
| 156 | +} | ... | ... |
src/rsp/GLATEdisp.cpp
0 โ 100644
| 1 | +/*************************************************************************** | |
| 2 | + * GLATEdisp.cpp - GLAST LAT Response class Edisp methods * | |
| 3 | + * ----------------------------------------------------------------------- * | |
| 4 | + * copyright : (C) 2008 by Jurgen Knodlseder * | |
| 5 | + * ----------------------------------------------------------------------- * | |
| 6 | + * * | |
| 7 | + * This program is free software; you can redistribute it and/or modify * | |
| 8 | + * it under the terms of the GNU General Public License as published by * | |
| 9 | + * the Free Software Foundation; either version 2 of the License, or * | |
| 10 | + * (at your option) any later version. * | |
| 11 | + * * | |
| 12 | + * ----------------------------------------------------------------------- * | |
| 13 | + ***************************************************************************/ | |
| 14 | +/** | |
| 15 | + * @file GLATEdisp.cpp | |
| 16 | + * @brief GLATResponse class energy dispersion implementation. | |
| 17 | + * @author J. Knodlseder | |
| 18 | + */ | |
| 19 | + | |
| 20 | +/* __ Includes ___________________________________________________________ */ | |
| 21 | +#include <iostream> | |
| 22 | +#include "GTools.hpp" | |
| 23 | +#include "GException.hpp" | |
| 24 | +#include "GLATResponse.hpp" | |
| 25 | +#include "GFitsDblImage.hpp" | |
| 26 | +#include "GFitsTableFltCol.hpp" | |
| 27 | + | |
| 28 | +/* __ Namespaces _________________________________________________________ */ | |
| 29 | + | |
| 30 | +/* __ Method name definitions ____________________________________________ */ | |
| 31 | +#define G_INIT_EDISP "GLATResponse::init_edisp()" | |
| 32 | + | |
| 33 | +/* __ Macros _____________________________________________________________ */ | |
| 34 | + | |
| 35 | +/* __ Coding definitions _________________________________________________ */ | |
| 36 | + | |
| 37 | +/* __ Debug definitions __________________________________________________ */ | |
| 38 | + | |
| 39 | +/* __ Constants __________________________________________________________ */ | |
| 40 | + | |
| 41 | + | |
| 42 | +/*========================================================================== | |
| 43 | + = = | |
| 44 | + = Public methods = | |
| 45 | + = = | |
| 46 | + ==========================================================================*/ | |
| 47 | + | |
| 48 | +/***********************************************************************//** | |
| 49 | + * @brief Return value of energy dispersion | |
| 50 | + * | |
| 51 | + * @param[in] obsDir Observed photon direction | |
| 52 | + * @param[in] obsEng Observed energy of photon | |
| 53 | + * @param[in] srcDir True photon direction | |
| 54 | + * @param[in] srcEng True energy of photon | |
| 55 | + * @param[in] instPntDir Instrument pointing direction (e.g. z-axis) | |
| 56 | + * @param[in] instPosAng Instrument position angle | |
| 57 | + * @param[in] time Photon arrival time | |
| 58 | + ***************************************************************************/ | |
| 59 | +double GLATResponse::edisp(const GSkyDir& obsDir, const double& obsEng, | |
| 60 | + const GSkyDir& srcDir, const double& srcEng, | |
| 61 | + const GSkyDir& instPntDir, const double& instPosAng, | |
| 62 | + const double& time) | |
| 63 | +{ | |
| 64 | + // Return Edisp value | |
| 65 | + return 0.0; //!< @todo Not yet implemented | |
| 66 | +} | |
| 67 | + | |
| 68 | + | |
| 69 | +/*========================================================================== | |
| 70 | + = = | |
| 71 | + = Private methods = | |
| 72 | + = = | |
| 73 | + ==========================================================================*/ | |
| 74 | + | |
| 75 | +/***********************************************************************//** | |
| 76 | + * @brief Initialise energy dispersion | |
| 77 | + ***************************************************************************/ | |
| 78 | +void GLATResponse::edisp_init(void) | |
| 79 | +{ | |
| 80 | + // Build filename | |
| 81 | + std::string filename = "edisp_" + m_rspname + "_" + m_rsptype + ".fits"; | |
| 82 | + | |
| 83 | + // Open FITS file | |
| 84 | + GFits file; | |
| 85 | + file.open(m_caldb + "/" + filename); | |
| 86 | + | |
| 87 | + // Get pointer towards energy dispersion HDU | |
| 88 | + GFitsHDU* hdu = file.hdu("ENERGY DISPERSION"); | |
| 89 | + if (hdu == NULL) | |
| 90 | + throw GException::fits_hdu_not_found(G_INIT_EDISP, "ENERGY DISPERSION"); | |
| 91 | + | |
| 92 | + // Get the energy and cos(theta) bins | |
| 93 | + m_edisp_bins.load(hdu); | |
| 94 | + | |
| 95 | + // Get the data | |
| 96 | + GVector dnorm = get_fits_vector(hdu, "DNORM"); | |
| 97 | + GVector ltail = get_fits_vector(hdu, "LTAIL"); | |
| 98 | + GVector rwidth = get_fits_vector(hdu, "RWIDTH"); | |
| 99 | + GVector nr2 = get_fits_vector(hdu, "NR2"); | |
| 100 | + GVector lt2 = get_fits_vector(hdu, "LT2"); | |
| 101 | + GVector rt2 = get_fits_vector(hdu, "RT2"); | |
| 102 | + | |
| 103 | + // ... | |
| 104 | + | |
| 105 | + // Return | |
| 106 | + return; | |
| 107 | +} | |
| 108 | + | |
| 109 | + | |
| 110 | +/***********************************************************************//** | |
| 111 | + * @brief Append Edisp HDUs tu FOTS file | |
| 112 | + * | |
| 113 | + * @param[in] file FITS file into which the Edisp HDUs will be appended | |
| 114 | + * | |
| 115 | + * Append ? HDUs to the FITS file: | |
| 116 | + * EBOUNDS (Edisp energy and zenith angle boundaries) | |
| 117 | + * ... | |
| 118 | + ***************************************************************************/ | |
| 119 | +void GLATResponse::edisp_append(GFits& file) const | |
| 120 | +{ | |
| 121 | + // Get Edisp boundary table | |
| 122 | + GFitsHDU hdu_bounds; | |
| 123 | + m_edisp_bins.save(&hdu_bounds); | |
| 124 | + hdu_bounds.extname("EBOUNDS"); | |
| 125 | + | |
| 126 | + // Append HDUs to FITS file | |
| 127 | + file.append_hdu(hdu_bounds); | |
| 128 | + | |
| 129 | + // Return | |
| 130 | + return; | |
| 131 | +} | |
| 132 | + | |
| 133 | + | |
| 134 | +/***********************************************************************//** | |
| 135 | + * @brief Initialise class members | |
| 136 | + ***************************************************************************/ | |
| 137 | +void GLATResponse::edisp_init_members(void) | |
| 138 | +{ | |
| 139 | + // Initialise Edisp members | |
| 140 | + | |
| 141 | + // Return | |
| 142 | + return; | |
| 143 | +} | |
| 144 | + | |
| 145 | + | |
| 146 | +/***********************************************************************//** | |
| 147 | + * @brief Copy class members | |
| 148 | + ***************************************************************************/ | |
| 149 | +void GLATResponse::edisp_copy_members(const GLATResponse& rsp) | |
| 150 | +{ | |
| 151 | + // Return | |
| 152 | + return; | |
| 153 | +} | |
| 154 | + | |
| 155 | + | |
| 156 | +/***********************************************************************//** | |
| 157 | + * @brief Delete class members | |
| 158 | +***************************************************************************/ | |
| 159 | +void GLATResponse::edisp_free_members(void) | |
| 160 | +{ | |
| 161 | + // Return | |
| 162 | + return; | |
| 163 | +} | ... | ... |
src/rsp/GLATPsf.cpp
| ... | ... | @@ -11,15 +11,17 @@ |
| 11 | 11 | * * |
| 12 | 12 | * ----------------------------------------------------------------------- * |
| 13 | 13 | ***************************************************************************/ |
| 14 | +/** | |
| 15 | + * @file GLATPsf.cpp | |
| 16 | + * @brief GLATResponse class PSF implementation. | |
| 17 | + * @author J. Knodlseder | |
| 18 | + */ | |
| 14 | 19 | |
| 15 | 20 | /* __ Includes ___________________________________________________________ */ |
| 16 | 21 | #include <iostream> |
| 17 | 22 | #include "GTools.hpp" |
| 18 | 23 | #include "GException.hpp" |
| 19 | -#include "GVector.hpp" | |
| 20 | 24 | #include "GLATResponse.hpp" |
| 21 | -#include "GFits.hpp" | |
| 22 | -#include "GFitsHDU.hpp" | |
| 23 | 25 | #include "GFitsDblImage.hpp" |
| 24 | 26 | #include "GFitsTableFltCol.hpp" |
| 25 | 27 | |
| ... | ... | @@ -70,7 +72,7 @@ double GLATResponse::psf(const GSkyDir& obsDir, const double& obsEng, |
| 70 | 72 | const double& time) |
| 71 | 73 | { |
| 72 | 74 | // Return PSF value |
| 73 | - return 0.0; | |
| 75 | + return 0.0; //!< @todo Not yet implemented | |
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | |
| ... | ... | @@ -354,31 +356,30 @@ void GLATResponse::psf_init(void) |
| 354 | 356 | void GLATResponse::psf_append(GFits& file) const |
| 355 | 357 | { |
| 356 | 358 | // Get PSF boundary table |
| 357 | - GFitsHDU hdu_psf_bounds; | |
| 358 | - m_psf_bins.save(&hdu_psf_bounds); | |
| 359 | - hdu_psf_bounds.extname("PBOUNDS"); | |
| 359 | + GFitsHDU hdu_bounds; | |
| 360 | + m_psf_bins.save(&hdu_bounds); | |
| 361 | + hdu_bounds.extname("PBOUNDS"); | |
| 360 | 362 | |
| 361 | 363 | // Build PSF tables and images |
| 362 | - int naxes_psf2[] = {m_psf_bins.num_energy(), m_psf_bins.num_ctheta()}; | |
| 363 | - int naxes_psf3[] = {angle_num, m_psf_bins.num_energy(), | |
| 364 | - m_psf_bins.num_ctheta()}; | |
| 365 | - GFitsDblImage image_psf_norm(2, naxes_psf2, m_norm); | |
| 366 | - GFitsDblImage image_psf_sigma(2, naxes_psf2, m_sigma); | |
| 367 | - GFitsDblImage image_psf_psf(3, naxes_psf3, m_psf); | |
| 364 | + int naxes2[] = {m_psf_bins.num_energy(), m_psf_bins.num_ctheta()}; | |
| 365 | + int naxes3[] = {angle_num, m_psf_bins.num_energy(), m_psf_bins.num_ctheta()}; | |
| 366 | + GFitsDblImage image_norm(2, naxes2, m_norm); | |
| 367 | + GFitsDblImage image_sigma(2, naxes2, m_sigma); | |
| 368 | + GFitsDblImage image_psf(3, naxes3, m_psf); | |
| 368 | 369 | |
| 369 | 370 | // Construct PSF HDUs |
| 370 | - GFitsHDU hdu_psf_norm(image_psf_norm); | |
| 371 | - GFitsHDU hdu_psf_sigma(image_psf_sigma); | |
| 372 | - GFitsHDU hdu_psf_psf(image_psf_psf); | |
| 373 | - hdu_psf_norm.extname("PNORM"); | |
| 374 | - hdu_psf_sigma.extname("PSIGMA"); | |
| 375 | - hdu_psf_psf.extname("PSF"); | |
| 371 | + GFitsHDU hdu_norm(image_norm); | |
| 372 | + GFitsHDU hdu_sigma(image_sigma); | |
| 373 | + GFitsHDU hdu_psf(image_psf); | |
| 374 | + hdu_norm.extname("PNORM"); | |
| 375 | + hdu_sigma.extname("PSIGMA"); | |
| 376 | + hdu_psf.extname("PSF"); | |
| 376 | 377 | |
| 377 | 378 | // Append HDUs to FITS file |
| 378 | - file.append_hdu(hdu_psf_bounds); | |
| 379 | - file.append_hdu(hdu_psf_norm); | |
| 380 | - file.append_hdu(hdu_psf_sigma); | |
| 381 | - file.append_hdu(hdu_psf_psf); | |
| 379 | + file.append_hdu(hdu_bounds); | |
| 380 | + file.append_hdu(hdu_norm); | |
| 381 | + file.append_hdu(hdu_sigma); | |
| 382 | + file.append_hdu(hdu_psf); | |
| 382 | 383 | |
| 383 | 384 | // Return |
| 384 | 385 | return; |
| ... | ... | @@ -514,7 +515,7 @@ GVector GLATResponse::psf_base_vector(const GVector& u, const double& gamma) con |
| 514 | 515 | |
| 515 | 516 | |
| 516 | 517 | /***********************************************************************//** |
| 517 | - * @brief Initialise PSF class members | |
| 518 | + * @brief Initialise class members | |
| 518 | 519 | ***************************************************************************/ |
| 519 | 520 | void GLATResponse::psf_init_members(void) |
| 520 | 521 | { |
| ... | ... | @@ -530,7 +531,7 @@ void GLATResponse::psf_init_members(void) |
| 530 | 531 | |
| 531 | 532 | |
| 532 | 533 | /***********************************************************************//** |
| 533 | - * @brief Copy PSF class members | |
| 534 | + * @brief Copy class members | |
| 534 | 535 | ***************************************************************************/ |
| 535 | 536 | void GLATResponse::psf_copy_members(const GLATResponse& rsp) |
| 536 | 537 | { |
| ... | ... | @@ -567,9 +568,9 @@ void GLATResponse::psf_copy_members(const GLATResponse& rsp) |
| 567 | 568 | void GLATResponse::psf_free_members(void) |
| 568 | 569 | { |
| 569 | 570 | // Free PSF memory |
| 570 | - if (m_psf != NULL) delete [] m_psf; | |
| 571 | - if (m_norm != NULL) delete [] m_norm; | |
| 572 | - if (m_sigma != NULL) delete [] m_sigma; | |
| 571 | + if (m_psf != NULL) delete [] m_psf; | |
| 572 | + if (m_norm != NULL) delete [] m_norm; | |
| 573 | + if (m_sigma != NULL) delete [] m_sigma; | |
| 573 | 574 | |
| 574 | 575 | // Signal that PSF memory is free |
| 575 | 576 | m_psf = NULL; | ... | ... |
src/rsp/GLATResponse.cpp
| ... | ... | @@ -11,6 +11,11 @@ |
| 11 | 11 | * * |
| 12 | 12 | * ----------------------------------------------------------------------- * |
| 13 | 13 | ***************************************************************************/ |
| 14 | +/** | |
| 15 | + * @file GLATResponse.cpp | |
| 16 | + * @brief GLATResponse class implementation. | |
| 17 | + * @author J. Knodlseder | |
| 18 | + */ | |
| 14 | 19 | |
| 15 | 20 | /* __ Includes ___________________________________________________________ */ |
| 16 | 21 | #include <iostream> |
| ... | ... | @@ -26,8 +31,6 @@ |
| 26 | 31 | |
| 27 | 32 | /* __ Method name definitions ____________________________________________ */ |
| 28 | 33 | #define G_LOAD "load(const std::string&, const std::string&)" |
| 29 | -#define G_INIT_AEFF "GLATResponse::init_aeff()" | |
| 30 | -#define G_INIT_EDISP "GLATResponse::init_edisp()" | |
| 31 | 34 | #define G_GET_FITS_VECTOR "GLATResponse::get_fits_vector(const GFitsHDU*, const std::string&, int)" |
| 32 | 35 | |
| 33 | 36 | /* __ Macros _____________________________________________________________ */ |
| ... | ... | @@ -139,33 +142,7 @@ double GLATResponse::irf(const GSkyDir& obsDir, const double& obsEng, |
| 139 | 142 | const double& time) |
| 140 | 143 | { |
| 141 | 144 | // Return IRF value |
| 142 | - return 0.0; | |
| 143 | -} | |
| 144 | - | |
| 145 | - | |
| 146 | -/***********************************************************************//** | |
| 147 | - * @brief Return effective area | |
| 148 | - ***************************************************************************/ | |
| 149 | -double GLATResponse::aeff(const GSkyDir& obsDir, const double& obsEng, | |
| 150 | - const GSkyDir& srcDir, const double& srcEng, | |
| 151 | - const GSkyDir& instPntDir, const double& instPosAng, | |
| 152 | - const double& time) | |
| 153 | -{ | |
| 154 | - // Return Aeff value | |
| 155 | - return 0.0; | |
| 156 | -} | |
| 157 | - | |
| 158 | - | |
| 159 | -/***********************************************************************//** | |
| 160 | - * @brief Return value of energy dispersion | |
| 161 | - ***************************************************************************/ | |
| 162 | -double GLATResponse::edisp(const GSkyDir& obsDir, const double& obsEng, | |
| 163 | - const GSkyDir& srcDir, const double& srcEng, | |
| 164 | - const GSkyDir& instPntDir, const double& instPosAng, | |
| 165 | - const double& time) | |
| 166 | -{ | |
| 167 | - // Return Edisp value | |
| 168 | - return 0.0; | |
| 145 | + return 0.0; //!< @todo Not yet implemented | |
| 169 | 146 | } |
| 170 | 147 | |
| 171 | 148 | |
| ... | ... | @@ -179,7 +156,7 @@ double GLATResponse::edisp(const GSkyDir& obsDir, const double& obsEng, |
| 179 | 156 | void GLATResponse::set_caldb(const std::string& caldb) |
| 180 | 157 | { |
| 181 | 158 | // Simply copy path |
| 182 | - // NOTE: Some check should be done on whether the path exists !!! | |
| 159 | + /// @todo Some check should be done on whether the path exists | |
| 183 | 160 | m_caldb = caldb; |
| 184 | 161 | |
| 185 | 162 | // Return |
| ... | ... | @@ -240,11 +217,13 @@ void GLATResponse::save(const std::string& rspname) const |
| 240 | 217 | file.open(rspname); |
| 241 | 218 | |
| 242 | 219 | // Save effective area |
| 220 | + aeff_append(file); | |
| 243 | 221 | |
| 244 | 222 | // Append PSF HDUs |
| 245 | 223 | psf_append(file); |
| 246 | 224 | |
| 247 | 225 | // Save energy dispersions |
| 226 | + edisp_append(file); | |
| 248 | 227 | |
| 249 | 228 | // Save FITS file |
| 250 | 229 | file.save(); |
| ... | ... | @@ -256,83 +235,6 @@ void GLATResponse::save(const std::string& rspname) const |
| 256 | 235 | |
| 257 | 236 | /*========================================================================== |
| 258 | 237 | = = |
| 259 | - = GLATResponse private effective area methods = | |
| 260 | - = = | |
| 261 | - ==========================================================================*/ | |
| 262 | - | |
| 263 | -/***********************************************************************//** | |
| 264 | - * @brief Initialise effective area | |
| 265 | - ***************************************************************************/ | |
| 266 | -void GLATResponse::aeff_init(void) | |
| 267 | -{ | |
| 268 | - // Build filename | |
| 269 | - std::string filename = "aeff_" + m_rspname + "_" + m_rsptype + ".fits"; | |
| 270 | - | |
| 271 | - // Open FITS file | |
| 272 | - GFits file; | |
| 273 | - file.open(m_caldb + "/" + filename); | |
| 274 | - | |
| 275 | - // Get pointer to effective area HDU | |
| 276 | - GFitsHDU* hdu = file.hdu("EFFECTIVE AREA"); | |
| 277 | - if (hdu == NULL) | |
| 278 | - throw GException::fits_hdu_not_found(G_INIT_AEFF, "EFFECTIVE AREA"); | |
| 279 | - | |
| 280 | - // Get the data | |
| 281 | - GVector energ_lo = get_fits_vector(hdu, "ENERG_LO"); | |
| 282 | - GVector energ_hi = get_fits_vector(hdu, "ENERG_HI"); | |
| 283 | - GVector ctheta_lo = get_fits_vector(hdu, "CTHETA_LO"); | |
| 284 | - GVector ctheta_hi = get_fits_vector(hdu, "CTHETA_HI"); | |
| 285 | - GVector effarea = get_fits_vector(hdu, "EFFAREA"); | |
| 286 | - | |
| 287 | - // Return | |
| 288 | - return; | |
| 289 | -} | |
| 290 | - | |
| 291 | - | |
| 292 | -/*========================================================================== | |
| 293 | - = = | |
| 294 | - = GLATResponse private energy dispersion methods = | |
| 295 | - = = | |
| 296 | - ==========================================================================*/ | |
| 297 | - | |
| 298 | -/***********************************************************************//** | |
| 299 | - * @brief Initialise energy dispersion | |
| 300 | - ***************************************************************************/ | |
| 301 | -void GLATResponse::edisp_init(void) | |
| 302 | -{ | |
| 303 | - // Build filename | |
| 304 | - std::string filename = "edisp_" + m_rspname + "_" + m_rsptype + ".fits"; | |
| 305 | - | |
| 306 | - // Open FITS file | |
| 307 | - GFits file; | |
| 308 | - file.open(m_caldb + "/" + filename); | |
| 309 | - | |
| 310 | - // Get pointer towards energy dispersion HDU | |
| 311 | - GFitsHDU* hdu = file.hdu("ENERGY DISPERSION"); | |
| 312 | - if (hdu == NULL) | |
| 313 | - throw GException::fits_hdu_not_found(G_INIT_EDISP, "ENERGY DISPERSION"); | |
| 314 | - | |
| 315 | - // Get the data | |
| 316 | - GVector energ_lo = get_fits_vector(hdu, "ENERG_LO"); | |
| 317 | - GVector energ_hi = get_fits_vector(hdu, "ENERG_HI"); | |
| 318 | - GVector ctheta_lo = get_fits_vector(hdu, "CTHETA_LO"); | |
| 319 | - GVector ctheta_hi = get_fits_vector(hdu, "CTHETA_HI"); | |
| 320 | - GVector dnorm = get_fits_vector(hdu, "DNORM"); | |
| 321 | - GVector ltail = get_fits_vector(hdu, "LTAIL"); | |
| 322 | - GVector rwidth = get_fits_vector(hdu, "RWIDTH"); | |
| 323 | - GVector nr2 = get_fits_vector(hdu, "NR2"); | |
| 324 | - GVector lt2 = get_fits_vector(hdu, "LT2"); | |
| 325 | - GVector rt2 = get_fits_vector(hdu, "RT2"); | |
| 326 | - | |
| 327 | - // ... | |
| 328 | - | |
| 329 | - // Return | |
| 330 | - return; | |
| 331 | -} | |
| 332 | - | |
| 333 | - | |
| 334 | -/*========================================================================== | |
| 335 | - = = | |
| 336 | 238 | = GLATResponse private methods = |
| 337 | 239 | = = |
| 338 | 240 | ==========================================================================*/ |
| ... | ... | @@ -343,11 +245,13 @@ void GLATResponse::edisp_init(void) |
| 343 | 245 | void GLATResponse::init_members(void) |
| 344 | 246 | { |
| 345 | 247 | // Initialise effective area members |
| 248 | + aeff_init_members(); | |
| 346 | 249 | |
| 347 | 250 | // Initialise PSF members |
| 348 | 251 | psf_init_members(); |
| 349 | 252 | |
| 350 | 253 | // Initialize energy dispersion members |
| 254 | + edisp_init_members(); | |
| 351 | 255 | |
| 352 | 256 | // By default use HANDOFF response database. |
| 353 | 257 | char* handoff = getenv("HANDOFF_IRF_DIR"); |
| ... | ... | @@ -367,11 +271,13 @@ void GLATResponse::init_members(void) |
| 367 | 271 | void GLATResponse::copy_members(const GLATResponse& rsp) |
| 368 | 272 | { |
| 369 | 273 | // Copy effective area members |
| 274 | + aeff_copy_members(rsp); | |
| 370 | 275 | |
| 371 | 276 | // Copy PSF members |
| 372 | 277 | psf_copy_members(rsp); |
| 373 | 278 | |
| 374 | 279 | // Copy energy dispersion members |
| 280 | + edisp_copy_members(rsp); | |
| 375 | 281 | |
| 376 | 282 | // Copy remaining members |
| 377 | 283 | m_caldb = rsp.m_caldb; |
| ... | ... | @@ -386,15 +292,16 @@ void GLATResponse::copy_members(const GLATResponse& rsp) |
| 386 | 292 | ***************************************************************************/ |
| 387 | 293 | void GLATResponse::free_members(void) |
| 388 | 294 | { |
| 389 | - // Free PSF memory | |
| 390 | - if (m_psf != NULL) delete [] m_psf; | |
| 391 | - if (m_norm != NULL) delete [] m_norm; | |
| 392 | - if (m_sigma != NULL) delete [] m_sigma; | |
| 393 | - | |
| 394 | - // Signal that PSF memory is free | |
| 395 | - m_psf = NULL; | |
| 396 | - m_norm = NULL; | |
| 397 | - m_sigma = NULL; | |
| 295 | + // Free effective area members | |
| 296 | + aeff_free_members(); | |
| 297 | + | |
| 298 | + // Free PSF members | |
| 299 | + psf_free_members(); | |
| 300 | + | |
| 301 | + // Free energy dispersion members | |
| 302 | + edisp_free_members(); | |
| 303 | + | |
| 304 | + // Free remaining members | |
| 398 | 305 | |
| 399 | 306 | // Return |
| 400 | 307 | return; | ... | ... |