diff --git a/src/ctmodel/ctmodel.cpp b/src/ctmodel/ctmodel.cpp index 32b7176..1c2618a 100644 --- a/src/ctmodel/ctmodel.cpp +++ b/src/ctmodel/ctmodel.cpp @@ -246,6 +246,18 @@ void ctmodel::run(void) log << std::endl; } + // Set energy dispersion flag for all CTA observations and save old + // values in save_edisp vector + std::vector save_edisp; + save_edisp.assign(m_obs.size(), false); + for (int i = 0; i < m_obs.size(); ++i) { + GCTAObservation* obs = dynamic_cast(m_obs[i]); + if (obs != NULL) { + save_edisp[i] = obs->response().apply_edisp(); + obs->response().apply_edisp(m_apply_edisp); + } + } + // Write observation(s) into logger if (logTerse()) { log << std::endl; @@ -325,6 +337,14 @@ void ctmodel::run(void) log << m_obs << std::endl; } + // Restore energy dispersion flag for all CTA observations + for (int i = 0; i < m_obs.size(); ++i) { + GCTAObservation* obs = dynamic_cast(m_obs[i]); + if (obs != NULL) { + obs->response().apply_edisp(save_edisp[i]); + } + } + // Return return; } @@ -436,6 +456,9 @@ void ctmodel::get_parameters(void) } } + // Get other parameters + m_apply_edisp = (*this)["edisp"].boolean(); + // Return return; } @@ -686,19 +709,20 @@ void ctmodel::init_members(void) m_srcmdl.clear(); m_proj.clear(); m_coordsys.clear(); - m_ra = 0.0; - m_dec = 0.0; - m_deadc = 1.0; - m_tmin = 0.0; - m_tmax = 0.0; - m_emin = 0.0; - m_emax = 0.0; - m_enumbins = 0; - m_xref = 0.0; - m_yref = 0.0; - m_binsz = 0.0; - m_nxpix = 0; - m_nypix = 0; + m_ra = 0.0; + m_dec = 0.0; + m_deadc = 1.0; + m_tmin = 0.0; + m_tmax = 0.0; + m_emin = 0.0; + m_emax = 0.0; + m_enumbins = 0; + m_xref = 0.0; + m_yref = 0.0; + m_binsz = 0.0; + m_nxpix = 0; + m_nypix = 0; + m_apply_edisp = false; // Initialise protected members m_obs.clear(); @@ -722,27 +746,28 @@ void ctmodel::init_members(void) void ctmodel::copy_members(const ctmodel& app) { // Copy attributes - m_infile = app.m_infile; - m_outfile = app.m_outfile; - m_prefix = app.m_prefix; - m_caldb = app.m_caldb; - m_irf = app.m_irf; - m_srcmdl = app.m_srcmdl; - m_proj = app.m_proj; - m_coordsys = app.m_coordsys; - m_ra = app.m_ra; - m_dec = app.m_dec; - m_deadc = app.m_deadc; - m_tmin = app.m_tmin; - m_tmax = app.m_tmax; - m_emin = app.m_emin; - m_emax = app.m_emax; - m_enumbins = app.m_enumbins; - m_xref = app.m_xref; - m_yref = app.m_yref; - m_binsz = app.m_binsz; - m_nxpix = app.m_nxpix; - m_nypix = app.m_nypix; + m_infile = app.m_infile; + m_outfile = app.m_outfile; + m_prefix = app.m_prefix; + m_caldb = app.m_caldb; + m_irf = app.m_irf; + m_srcmdl = app.m_srcmdl; + m_proj = app.m_proj; + m_coordsys = app.m_coordsys; + m_ra = app.m_ra; + m_dec = app.m_dec; + m_deadc = app.m_deadc; + m_tmin = app.m_tmin; + m_tmax = app.m_tmax; + m_emin = app.m_emin; + m_emax = app.m_emax; + m_enumbins = app.m_enumbins; + m_xref = app.m_xref; + m_yref = app.m_yref; + m_binsz = app.m_binsz; + m_nxpix = app.m_nxpix; + m_nypix = app.m_nypix; + m_apply_edisp = app.m_apply_edisp; // Copy protected members m_obs = app.m_obs; diff --git a/src/ctmodel/ctmodel.hpp b/src/ctmodel/ctmodel.hpp index b3b93dd..ed91be2 100644 --- a/src/ctmodel/ctmodel.hpp +++ b/src/ctmodel/ctmodel.hpp @@ -61,7 +61,7 @@ public: virtual ~ctmodel(void); // Operators - ctmodel& operator= (const ctmodel& app); + ctmodel& operator=(const ctmodel& app); // Methods void clear(void); @@ -85,27 +85,28 @@ protected: const std::string& outfile) const; // User parameters - std::string m_infile; //!< Input counts map or XML file - std::string m_outfile; //!< Output model map or XML file - std::string m_prefix; //!< Prefix for multiple model maps - std::string m_caldb; //!< Calibration database - std::string m_irf; //!< Instrument response functions - std::string m_srcmdl; //!< Source model - double m_ra; //!< RA of pointing direction - double m_dec; //!< DEC of pointing direction - double m_deadc; //!< Deadtime correction factor - double m_tmin; //!< Start time - double m_tmax; //!< Stop time - double m_emin; //!< Lower energy - double m_emax; //!< Upper energy - int m_enumbins; //!< Number of energy bins - std::string m_proj; //!< WCS projection - std::string m_coordsys; //!< Coordinate system - double m_xref; //!< Longitude reference coordinate - double m_yref; //!< Latitude reference coordinate - double m_binsz; //!< Pixel size - int m_nxpix; //!< Number of pixels in longitude - int m_nypix; //!< Number of pixels in latitude + std::string m_infile; //!< Input counts map or XML file + std::string m_outfile; //!< Output model map or XML file + std::string m_prefix; //!< Prefix for multiple model maps + std::string m_caldb; //!< Calibration database + std::string m_irf; //!< Instrument response functions + std::string m_srcmdl; //!< Source model + double m_ra; //!< RA of pointing direction + double m_dec; //!< DEC of pointing direction + double m_deadc; //!< Deadtime correction factor + double m_tmin; //!< Start time + double m_tmax; //!< Stop time + double m_emin; //!< Lower energy + double m_emax; //!< Upper energy + int m_enumbins; //!< Number of energy bins + std::string m_proj; //!< WCS projection + std::string m_coordsys; //!< Coordinate system + double m_xref; //!< Longitude reference coordinate + double m_yref; //!< Latitude reference coordinate + double m_binsz; //!< Pixel size + int m_nxpix; //!< Number of pixels in longitude + int m_nypix; //!< Number of pixels in latitude + bool m_apply_edisp; //!< Apply energy dispersion? // Protected members GObservations m_obs; //!< Observation container