Commit b24969ce6d43bf45a7e6d6cd1fc952a931cc5cdc

Authored by Jürgen Knödlseder
1 parent 3a3d9ecd

Add energy dispersion handling.

The edisp parameter now allows to switch on or off the handling of energy dispersion. By default, energy dispersion is switched off.
src/ctmodel/ctmodel.cpp
... ... @@ -246,6 +246,18 @@ void ctmodel::run(void)
246 246 log << std::endl;
247 247 }
248 248  
  249 + // Set energy dispersion flag for all CTA observations and save old
  250 + // values in save_edisp vector
  251 + std::vector<bool> save_edisp;
  252 + save_edisp.assign(m_obs.size(), false);
  253 + for (int i = 0; i < m_obs.size(); ++i) {
  254 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);
  255 + if (obs != NULL) {
  256 + save_edisp[i] = obs->response().apply_edisp();
  257 + obs->response().apply_edisp(m_apply_edisp);
  258 + }
  259 + }
  260 +
249 261 // Write observation(s) into logger
250 262 if (logTerse()) {
251 263 log << std::endl;
... ... @@ -325,6 +337,14 @@ void ctmodel::run(void)
325 337 log << m_obs << std::endl;
326 338 }
327 339  
  340 + // Restore energy dispersion flag for all CTA observations
  341 + for (int i = 0; i < m_obs.size(); ++i) {
  342 + GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[i]);
  343 + if (obs != NULL) {
  344 + obs->response().apply_edisp(save_edisp[i]);
  345 + }
  346 + }
  347 +
328 348 // Return
329 349 return;
330 350 }
... ... @@ -436,6 +456,9 @@ void ctmodel::get_parameters(void)
436 456 }
437 457 }
438 458  
  459 + // Get other parameters
  460 + m_apply_edisp = (*this)["edisp"].boolean();
  461 +
439 462 // Return
440 463 return;
441 464 }
... ... @@ -686,19 +709,20 @@ void ctmodel::init_members(void)
686 709 m_srcmdl.clear();
687 710 m_proj.clear();
688 711 m_coordsys.clear();
689   - m_ra = 0.0;
690   - m_dec = 0.0;
691   - m_deadc = 1.0;
692   - m_tmin = 0.0;
693   - m_tmax = 0.0;
694   - m_emin = 0.0;
695   - m_emax = 0.0;
696   - m_enumbins = 0;
697   - m_xref = 0.0;
698   - m_yref = 0.0;
699   - m_binsz = 0.0;
700   - m_nxpix = 0;
701   - m_nypix = 0;
  712 + m_ra = 0.0;
  713 + m_dec = 0.0;
  714 + m_deadc = 1.0;
  715 + m_tmin = 0.0;
  716 + m_tmax = 0.0;
  717 + m_emin = 0.0;
  718 + m_emax = 0.0;
  719 + m_enumbins = 0;
  720 + m_xref = 0.0;
  721 + m_yref = 0.0;
  722 + m_binsz = 0.0;
  723 + m_nxpix = 0;
  724 + m_nypix = 0;
  725 + m_apply_edisp = false;
702 726  
703 727 // Initialise protected members
704 728 m_obs.clear();
... ... @@ -722,27 +746,28 @@ void ctmodel::init_members(void)
722 746 void ctmodel::copy_members(const ctmodel& app)
723 747 {
724 748 // Copy attributes
725   - m_infile = app.m_infile;
726   - m_outfile = app.m_outfile;
727   - m_prefix = app.m_prefix;
728   - m_caldb = app.m_caldb;
729   - m_irf = app.m_irf;
730   - m_srcmdl = app.m_srcmdl;
731   - m_proj = app.m_proj;
732   - m_coordsys = app.m_coordsys;
733   - m_ra = app.m_ra;
734   - m_dec = app.m_dec;
735   - m_deadc = app.m_deadc;
736   - m_tmin = app.m_tmin;
737   - m_tmax = app.m_tmax;
738   - m_emin = app.m_emin;
739   - m_emax = app.m_emax;
740   - m_enumbins = app.m_enumbins;
741   - m_xref = app.m_xref;
742   - m_yref = app.m_yref;
743   - m_binsz = app.m_binsz;
744   - m_nxpix = app.m_nxpix;
745   - m_nypix = app.m_nypix;
  749 + m_infile = app.m_infile;
  750 + m_outfile = app.m_outfile;
  751 + m_prefix = app.m_prefix;
  752 + m_caldb = app.m_caldb;
  753 + m_irf = app.m_irf;
  754 + m_srcmdl = app.m_srcmdl;
  755 + m_proj = app.m_proj;
  756 + m_coordsys = app.m_coordsys;
  757 + m_ra = app.m_ra;
  758 + m_dec = app.m_dec;
  759 + m_deadc = app.m_deadc;
  760 + m_tmin = app.m_tmin;
  761 + m_tmax = app.m_tmax;
  762 + m_emin = app.m_emin;
  763 + m_emax = app.m_emax;
  764 + m_enumbins = app.m_enumbins;
  765 + m_xref = app.m_xref;
  766 + m_yref = app.m_yref;
  767 + m_binsz = app.m_binsz;
  768 + m_nxpix = app.m_nxpix;
  769 + m_nypix = app.m_nypix;
  770 + m_apply_edisp = app.m_apply_edisp;
746 771  
747 772 // Copy protected members
748 773 m_obs = app.m_obs;
... ...
src/ctmodel/ctmodel.hpp
... ... @@ -61,7 +61,7 @@ public:
61 61 virtual ~ctmodel(void);
62 62  
63 63 // Operators
64   - ctmodel& operator= (const ctmodel& app);
  64 + ctmodel& operator=(const ctmodel& app);
65 65  
66 66 // Methods
67 67 void clear(void);
... ... @@ -85,27 +85,28 @@ protected:
85 85 const std::string& outfile) const;
86 86  
87 87 // User parameters
88   - std::string m_infile; //!< Input counts map or XML file
89   - std::string m_outfile; //!< Output model map or XML file
90   - std::string m_prefix; //!< Prefix for multiple model maps
91   - std::string m_caldb; //!< Calibration database
92   - std::string m_irf; //!< Instrument response functions
93   - std::string m_srcmdl; //!< Source model
94   - double m_ra; //!< RA of pointing direction
95   - double m_dec; //!< DEC of pointing direction
96   - double m_deadc; //!< Deadtime correction factor
97   - double m_tmin; //!< Start time
98   - double m_tmax; //!< Stop time
99   - double m_emin; //!< Lower energy
100   - double m_emax; //!< Upper energy
101   - int m_enumbins; //!< Number of energy bins
102   - std::string m_proj; //!< WCS projection
103   - std::string m_coordsys; //!< Coordinate system
104   - double m_xref; //!< Longitude reference coordinate
105   - double m_yref; //!< Latitude reference coordinate
106   - double m_binsz; //!< Pixel size
107   - int m_nxpix; //!< Number of pixels in longitude
108   - int m_nypix; //!< Number of pixels in latitude
  88 + std::string m_infile; //!< Input counts map or XML file
  89 + std::string m_outfile; //!< Output model map or XML file
  90 + std::string m_prefix; //!< Prefix for multiple model maps
  91 + std::string m_caldb; //!< Calibration database
  92 + std::string m_irf; //!< Instrument response functions
  93 + std::string m_srcmdl; //!< Source model
  94 + double m_ra; //!< RA of pointing direction
  95 + double m_dec; //!< DEC of pointing direction
  96 + double m_deadc; //!< Deadtime correction factor
  97 + double m_tmin; //!< Start time
  98 + double m_tmax; //!< Stop time
  99 + double m_emin; //!< Lower energy
  100 + double m_emax; //!< Upper energy
  101 + int m_enumbins; //!< Number of energy bins
  102 + std::string m_proj; //!< WCS projection
  103 + std::string m_coordsys; //!< Coordinate system
  104 + double m_xref; //!< Longitude reference coordinate
  105 + double m_yref; //!< Latitude reference coordinate
  106 + double m_binsz; //!< Pixel size
  107 + int m_nxpix; //!< Number of pixels in longitude
  108 + int m_nypix; //!< Number of pixels in latitude
  109 + bool m_apply_edisp; //!< Apply energy dispersion?
109 110  
110 111 // Protected members
111 112 GObservations m_obs; //!< Observation container
... ...