Commit f54762c925814a56be31968153ee9ffa16d9f68b

Authored by Jürgen Knödlseder
1 parent bc5cda86

Implement specific cache for binned data at the level of GCTAResponseIrf (#3316)

By moving the specific cache from GCTAReponseCube to GResponseIrf, the specific cache is also available for binned analysis.
ChangeLog
@@ -3,7 +3,8 @@ @@ -3,7 +3,8 @@
3 * Bug fix version 1.7.1 released 3 * Bug fix version 1.7.1 released
4 ================================ 4 ================================
5 5
6 - Implement specific response cache for CTA stacked analysis (#3316) 6 + Implement specific response cache for CTA binned and stacked
  7 + analysis (#3316)
7 Speed up model definition XML file writing (#3308) 8 Speed up model definition XML file writing (#3308)
8 Fix automatic type casting in Python interface (#3295) 9 Fix automatic type casting in Python interface (#3295)
9 Make parameter file reading and writing thread safe (#3287) 10 Make parameter file reading and writing thread safe (#3287)
@@ -144,10 +144,10 @@ None @@ -144,10 +144,10 @@ None
144 144
145 20. CTA interface 145 20. CTA interface
146 ----------------- 146 -----------------
147 -A specific response cache was implemented for the stacked analysis that reduces  
148 -the memory requirements by at least a factor of 6. Instead of using the std::map  
149 -cache, the full data-space is cached, avoiding the need for any bookkeeping  
150 -(#3316). 147 +A specific response cache was implemented for the binned and stacked analysis
  148 +that reduces the memory requirements by at least a factor of 6. Instead of
  149 +using the std::map cache, the full data cube is cached, avoiding the need for
  150 +any bookkeeping that takes a lot of memory in the traditional cache (#3316).
151 151
152 152
153 21. COMPTEL interface 153 21. COMPTEL interface
doc/source/admin/release_history/1.7.1.rst
@@ -11,7 +11,7 @@ GammaLib 1.7.1 is a bug fix release for GammaLib release 1.7. @@ -11,7 +11,7 @@ GammaLib 1.7.1 is a bug fix release for GammaLib release 1.7.
11 The following bugs were fixed: 11 The following bugs were fixed:
12 12
13 * [`3316 <https://cta-redmine.irap.omp.eu/issues/3316>`_] - 13 * [`3316 <https://cta-redmine.irap.omp.eu/issues/3316>`_] -
14 - Implement specific response cache for CTA stacked analysis 14 + Implement specific response cache for CTA binned and stacked analysis
15 * [`3308 <https://cta-redmine.irap.omp.eu/issues/3308>`_] - 15 * [`3308 <https://cta-redmine.irap.omp.eu/issues/3308>`_] -
16 Speed up model definition XML file writing 16 Speed up model definition XML file writing
17 * [`3295 <https://cta-redmine.irap.omp.eu/issues/3295>`_] - 17 * [`3295 <https://cta-redmine.irap.omp.eu/issues/3295>`_] -
inst/cta/include/GCTAResponse.hpp
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
29 29
30 /* __ Includes ___________________________________________________________ */ 30 /* __ Includes ___________________________________________________________ */
31 #include <string> 31 #include <string>
  32 +#include "GNdarray.hpp"
32 #include "GResponse.hpp" 33 #include "GResponse.hpp"
33 34
34 /* __ Type definitions ___________________________________________________ */ 35 /* __ Type definitions ___________________________________________________ */
@@ -84,11 +85,20 @@ public: @@ -84,11 +85,20 @@ public:
84 virtual void write(GXmlElement& xml) const = 0; 85 virtual void write(GXmlElement& xml) const = 0;
85 virtual std::string print(const GChatter& chatter = NORMAL) const = 0; 86 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
86 87
  88 + // Overloaded virtual base class methods
  89 + virtual double irf_spatial(const GEvent& event,
  90 + const GSource& source,
  91 + const GObservation& obs) const;
  92 +
87 protected: 93 protected:
88 // Protected methods 94 // Protected methods
89 void init_members(void); 95 void init_members(void);
90 void copy_members(const GCTAResponse& rsp); 96 void copy_members(const GCTAResponse& rsp);
91 void free_members(void); 97 void free_members(void);
  98 +
  99 + // Kludge: cube response cache
  100 + mutable std::vector<std::string> m_cache_names; //!< Model names
  101 + mutable std::vector<GNdarray> m_cache_values; //!< Cached values
92 }; 102 };
93 103
94 #endif /* GCTARESPONSE_HPP */ 104 #endif /* GCTARESPONSE_HPP */
inst/cta/include/GCTAResponseCube.hpp
@@ -30,7 +30,6 @@ @@ -30,7 +30,6 @@
30 /* __ Includes ___________________________________________________________ */ 30 /* __ Includes ___________________________________________________________ */
31 #include <string> 31 #include <string>
32 #include <vector> 32 #include <vector>
33 -#include "GNdarray.hpp"  
34 #include "GCTAResponse.hpp" 33 #include "GCTAResponse.hpp"
35 #include "GCTACubeExposure.hpp" 34 #include "GCTACubeExposure.hpp"
36 #include "GCTACubePsf.hpp" 35 #include "GCTACubePsf.hpp"
@@ -98,11 +97,6 @@ public: @@ -98,11 +97,6 @@ public:
98 virtual void write(GXmlElement& xml) const; 97 virtual void write(GXmlElement& xml) const;
99 virtual std::string print(const GChatter& chatter = NORMAL) const; 98 virtual std::string print(const GChatter& chatter = NORMAL) const;
100 99
101 - // Overloaded virtual base class methods  
102 - virtual double irf_spatial(const GEvent& event,  
103 - const GSource& source,  
104 - const GObservation& obs) const;  
105 -  
106 // Other Methods 100 // Other Methods
107 const GCTACubeExposure& exposure(void) const; 101 const GCTACubeExposure& exposure(void) const;
108 void exposure(const GCTACubeExposure& exposure); 102 void exposure(const GCTACubeExposure& exposure);
@@ -153,10 +147,6 @@ private: @@ -153,10 +147,6 @@ private:
153 GCTACubeEdisp m_edisp; //!< Energy dispersion cube 147 GCTACubeEdisp m_edisp; //!< Energy dispersion cube
154 mutable bool m_apply_edisp; //!< Apply energy dispersion 148 mutable bool m_apply_edisp; //!< Apply energy dispersion
155 mutable bool m_has_edisp; //!< Flag to indicate if energy 149 mutable bool m_has_edisp; //!< Flag to indicate if energy
156 -  
157 - // Kludge: cube response cache  
158 - mutable std::vector<std::string> m_cache_names; //!< Model names  
159 - mutable std::vector<GNdarray> m_cache_values; //!< Cached values  
160 }; 150 };
161 151
162 152
inst/cta/pyext/GCTAResponse.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GCTAResponse.i - CTA response abstract base class * 2 * GCTAResponse.i - CTA response abstract base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2019 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -58,7 +58,10 @@ public: @@ -58,7 +58,10 @@ public:
58 virtual void read(const GXmlElement& xml) = 0; 58 virtual void read(const GXmlElement& xml) = 0;
59 virtual void write(GXmlElement& xml) const = 0; 59 virtual void write(GXmlElement& xml) const = 0;
60 60
61 - // Implemeted methods 61 + // Overloaded virtual base class methods
  62 + virtual double irf_spatial(const GEvent& event,
  63 + const GSource& source,
  64 + const GObservation& obs) const;
62 }; 65 };
63 66
64 67
inst/cta/pyext/GCTAResponseCube.i
@@ -68,11 +68,6 @@ public: @@ -68,11 +68,6 @@ public:
68 virtual void read(const GXmlElement& xml); 68 virtual void read(const GXmlElement& xml);
69 virtual void write(GXmlElement& xml) const; 69 virtual void write(GXmlElement& xml) const;
70 70
71 - // Overloaded virtual base class methods  
72 - virtual double irf_spatial(const GEvent& event,  
73 - const GSource& source,  
74 - const GObservation& obs) const;  
75 -  
76 // Other Methods 71 // Other Methods
77 const GCTACubeExposure& exposure(void) const; 72 const GCTACubeExposure& exposure(void) const;
78 void exposure(const GCTACubeExposure& exposure); 73 void exposure(const GCTACubeExposure& exposure);
inst/cta/pyext/GCTAResponseIrf.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GCTAResponseIrf.i - CTA instrument response function class * 2 * GCTAResponseIrf.i - CTA instrument response function class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2018 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2020 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -60,8 +60,6 @@ public: @@ -60,8 +60,6 @@ public:
60 virtual void read(const GXmlElement& xml); 60 virtual void read(const GXmlElement& xml);
61 virtual void write(GXmlElement& xml) const; 61 virtual void write(GXmlElement& xml) const;
62 62
63 - // Overload virtual base class methods  
64 -  
65 // Other Methods 63 // Other Methods
66 bool apply_edisp(void) const; 64 bool apply_edisp(void) const;
67 void apply_edisp(const bool& apply_edisp) const; 65 void apply_edisp(const bool& apply_edisp) const;
inst/cta/src/GCTAResponse.cpp
@@ -33,6 +33,8 @@ @@ -33,6 +33,8 @@
33 #include "GObservations.hpp" 33 #include "GObservations.hpp"
34 #include "GModelSpatial.hpp" 34 #include "GModelSpatial.hpp"
35 #include "GModelSpatialComposite.hpp" 35 #include "GModelSpatialComposite.hpp"
  36 +#include "GCTAEventCube.hpp" // Kludge
  37 +#include "GCTAEventBin.hpp" // Kludge
36 #include "GCTAResponse.hpp" 38 #include "GCTAResponse.hpp"
37 #include "GCTASupport.hpp" 39 #include "GCTASupport.hpp"
38 40
@@ -151,6 +153,199 @@ GCTAResponse&amp; GCTAResponse::operator=(const GCTAResponse&amp; rsp) @@ -151,6 +153,199 @@ GCTAResponse&amp; GCTAResponse::operator=(const GCTAResponse&amp; rsp)
151 = = 153 = =
152 ==========================================================================*/ 154 ==========================================================================*/
153 155
  156 +/***********************************************************************//**
  157 + * @brief Return instrument response integrated over the spatial model
  158 + *
  159 + * @param[in] event Event.
  160 + * @param[in] source Source.
  161 + * @param[in] obs Observation.
  162 + * @return Instrument response to a spatial model.
  163 + *
  164 + * Returns the instrument response for a given event, source and observation
  165 + * integrated over the spatial model component. The method computes
  166 + *
  167 + * \f[
  168 + * {\tt irf}(p', E', t') = \int_p M_{\rm S}(p | E, t) \,
  169 + * R(p', E', t' | p, E, t) \, d\,p
  170 + * \f]
  171 + *
  172 + * where
  173 + * * \f$M_{\rm S}(p | E, t)\f$ is the spatial model component,
  174 + * * \f$R(p', E', t' | p, E, t)\f$ is the Instrument Response Function (IRF),
  175 + * * \f$p'\f$ is the measured instrument direction,
  176 + * * \f$E'\f$ is the measured or reconstructed energy,
  177 + * * \f$t'\f$ is the measured arrival time,
  178 + * * \f$p\f$ is the true photon arrival direction,
  179 + * * \f$E\f$ is the true photon energy, and
  180 + * * \f$t\f$ is the true trigger time.
  181 + *
  182 + * The integration is done over all relevant true sky directions \f$p\f$.
  183 + *
  184 + * Depending on the type of the source model the method branches to the
  185 + * following methods to perform the actual computations
  186 + *
  187 + * irf_ptsrc() - for the handling of a point source
  188 + * irf_radial() - for radial models
  189 + * irf_elliptical() - for elliptical models
  190 + * irf_diffuse() - for diffuse models
  191 + * irf_composite() - for composite models
  192 + *
  193 + * The method implements a caching mechanism for spatial models that have all
  194 + * parameters fixed. For those models the instrument response for a given
  195 + * event and observation is only computed once and then stored in an internal
  196 + * cache from which it is fetched back in case that the method is called
  197 + * again for the same event and observation.
  198 + ***************************************************************************/
  199 +double GCTAResponse::irf_spatial(const GEvent& event,
  200 + const GSource& source,
  201 + const GObservation& obs) const
  202 +{
  203 + // Initialise IRF value
  204 + double irf = 0.0;
  205 +
  206 + // Set IRF value attributes
  207 + std::string name = obs.id() + "::" + source.name();
  208 + const GInstDir& dir = event.dir();
  209 + const GEnergy& ereco = event.energy();
  210 + const GEnergy& etrue = source.energy();
  211 +
  212 + // Signal if spatial model has free parameters
  213 + bool has_free_pars = source.model()->has_free_pars();
  214 +
  215 + // Kludge: if the response cache should be used, the event is a bin, the
  216 + // model has no free parameters, and there is no energy dispersion then
  217 + // use the special cache for binned or stacked analysis
  218 + bool use_kludge = false;
  219 + if (m_use_irf_cache && event.is_bin() && !has_free_pars && !use_edisp()) {
  220 +
  221 + // Get reference to CTA event bin
  222 + const GCTAEventBin& bin = static_cast<const GCTAEventBin&>(event);
  223 +
  224 + // If pixel and energy indices are valid then proceed with the kludge
  225 + if (bin.ipix() >= 0 && bin.ieng() >=0) {
  226 +
  227 + // Signal that kludge will be used
  228 + use_kludge = true;
  229 +
  230 + // Build unique cache name
  231 + std::string name = obs.id() + "::" + source.name();
  232 +
  233 + // Get index in cache, returns -1 if name is not found in cache
  234 + int index = -1;
  235 + for (int i = 0; i < m_cache_names.size(); ++i) {
  236 + if (m_cache_names[i] == name) {
  237 + index = i;
  238 + break;
  239 + }
  240 + }
  241 +
  242 + // If index was not found then allocate a new cache map
  243 + if (index == -1) {
  244 +
  245 + // Get pointer to event cube
  246 + const GCTAEventCube* cube =
  247 + static_cast<const GCTAEventCube*>(obs.events());
  248 +
  249 + // Allocate cache
  250 + GNdarray cache(cube->nx()*cube->ny(), cube->ebins());
  251 +
  252 + // Initialise all cache values with -1 (not set)
  253 + for (int i = 0; i < cache.size(); ++i) {
  254 + cache(i) = -1.0;
  255 + }
  256 +
  257 + // Insert cache
  258 + m_cache_names.push_back(name);
  259 + m_cache_values.push_back(cache);
  260 +
  261 + // Set index
  262 + index = m_cache_names.size()-1;
  263 +
  264 + } // endif: allocated new cache
  265 +
  266 + // Get cache value
  267 + irf = m_cache_values[index](bin.ipix(), bin.ieng());
  268 +
  269 + // If cache value is not valid then compute IRF
  270 + if (irf < 0.0) {
  271 +
  272 + // Compute IRF for spatial model
  273 + switch (source.model()->code()) {
  274 + case GMODEL_SPATIAL_POINT_SOURCE:
  275 + irf = irf_ptsrc(event, source, obs);
  276 + break;
  277 + case GMODEL_SPATIAL_RADIAL:
  278 + irf = irf_radial(event, source, obs);
  279 + break;
  280 + case GMODEL_SPATIAL_ELLIPTICAL:
  281 + irf = irf_elliptical(event, source, obs);
  282 + break;
  283 + case GMODEL_SPATIAL_DIFFUSE:
  284 + irf = irf_diffuse(event, source, obs);
  285 + break;
  286 + case GMODEL_SPATIAL_COMPOSITE:
  287 + irf = irf_composite(event, source, obs);
  288 + break;
  289 + default:
  290 + break;
  291 + }
  292 +
  293 + // Set cache value
  294 + m_cache_values[index](bin.ipix(), bin.ieng()) = irf;
  295 +
  296 + } // endif: computed IRF
  297 +
  298 + } // endif: event bin was part of cube
  299 +
  300 + } // endif: kludge
  301 +
  302 + // If kludge was not used then use the release 1.7 response cache
  303 + if (!use_kludge) {
  304 +
  305 + // If the spatial model component has free parameters, or the response
  306 + // cache should not be used, or the cache does not contain the requested
  307 + // IRF value then compute the IRF value for the spatial model.
  308 + if (has_free_pars ||
  309 + !m_use_irf_cache ||
  310 + !m_irf_cache.contains(name, dir, ereco, etrue, &irf)) {
  311 +
  312 + // Compute IRF for spatial model
  313 + switch (source.model()->code()) {
  314 + case GMODEL_SPATIAL_POINT_SOURCE:
  315 + irf = irf_ptsrc(event, source, obs);
  316 + break;
  317 + case GMODEL_SPATIAL_RADIAL:
  318 + irf = irf_radial(event, source, obs);
  319 + break;
  320 + case GMODEL_SPATIAL_ELLIPTICAL:
  321 + irf = irf_elliptical(event, source, obs);
  322 + break;
  323 + case GMODEL_SPATIAL_DIFFUSE:
  324 + irf = irf_diffuse(event, source, obs);
  325 + break;
  326 + case GMODEL_SPATIAL_COMPOSITE:
  327 + irf = irf_composite(event, source, obs);
  328 + break;
  329 + default:
  330 + break;
  331 + }
  332 +
  333 + } // endif: computed spatial model
  334 +
  335 + // If the spatial model has no free parameters and the response cache
  336 + // should be used then put the IRF value in the response cache.
  337 + if (!has_free_pars && m_use_irf_cache) {
  338 + m_irf_cache.set(name, dir, ereco, etrue, irf);
  339 + }
  340 +
  341 + } // endelse: used release 1.7 response cache
  342 +
  343 + // Return IRF value
  344 + return irf;
  345 +}
  346 +
  347 +
  348 +
154 /*========================================================================== 349 /*==========================================================================
155 = = 350 = =
156 = Private methods = 351 = Private methods =
@@ -162,6 +357,10 @@ GCTAResponse&amp; GCTAResponse::operator=(const GCTAResponse&amp; rsp) @@ -162,6 +357,10 @@ GCTAResponse&amp; GCTAResponse::operator=(const GCTAResponse&amp; rsp)
162 ***************************************************************************/ 357 ***************************************************************************/
163 void GCTAResponse::init_members(void) 358 void GCTAResponse::init_members(void)
164 { 359 {
  360 + // Kludge: Initialise cube response cache
  361 + m_cache_names.clear();
  362 + m_cache_values.clear();
  363 +
165 // Return 364 // Return
166 return; 365 return;
167 } 366 }
@@ -174,6 +373,10 @@ void GCTAResponse::init_members(void) @@ -174,6 +373,10 @@ void GCTAResponse::init_members(void)
174 ***************************************************************************/ 373 ***************************************************************************/
175 void GCTAResponse::copy_members(const GCTAResponse& rsp) 374 void GCTAResponse::copy_members(const GCTAResponse& rsp)
176 { 375 {
  376 + // Kludge: Copy cube response cache
  377 + m_cache_names = rsp.m_cache_names;
  378 + m_cache_values = rsp.m_cache_values;
  379 +
177 // Return 380 // Return
178 return; 381 return;
179 } 382 }
inst/cta/src/GCTAResponseCube.cpp
@@ -50,8 +50,6 @@ @@ -50,8 +50,6 @@
50 #include "GCTAInstDir.hpp" 50 #include "GCTAInstDir.hpp"
51 #include "GCTAEventBin.hpp" 51 #include "GCTAEventBin.hpp"
52 #include "GCTASupport.hpp" 52 #include "GCTASupport.hpp"
53 -#include "GCTAEventCube.hpp" // Kludge  
54 -#include "GCTAEventBin.hpp" // Kludge  
55 53
56 /* __ Method name definitions ____________________________________________ */ 54 /* __ Method name definitions ____________________________________________ */
57 #define G_IRF "GCTAResponseCube::irf(GEvent&, GPhoton& GObservation&)" 55 #define G_IRF "GCTAResponseCube::irf(GEvent&, GPhoton& GObservation&)"
@@ -445,188 +443,6 @@ GEbounds GCTAResponseCube::ebounds(const GEnergy&amp; obsEng) const @@ -445,188 +443,6 @@ GEbounds GCTAResponseCube::ebounds(const GEnergy&amp; obsEng) const
445 443
446 444
447 /***********************************************************************//** 445 /***********************************************************************//**
448 - * @brief Return instrument response integrated over the spatial model  
449 - *  
450 - * @param[in] event Event.  
451 - * @param[in] source Source.  
452 - * @param[in] obs Observation.  
453 - * @return Instrument response to a spatial model.  
454 - *  
455 - * Returns the instrument response for a given event, source and observation  
456 - * integrated over the spatial model component. The method computes  
457 - *  
458 - * \f[  
459 - * {\tt irf}(p', E', t') = \int_p M_{\rm S}(p | E, t) \,  
460 - * R(p', E', t' | p, E, t) \, d\,p  
461 - * \f]  
462 - *  
463 - * where  
464 - * * \f$M_{\rm S}(p | E, t)\f$ is the spatial model component,  
465 - * * \f$R(p', E', t' | p, E, t)\f$ is the Instrument Response Function (IRF),  
466 - * * \f$p'\f$ is the measured instrument direction,  
467 - * * \f$E'\f$ is the measured or reconstructed energy,  
468 - * * \f$t'\f$ is the measured arrival time,  
469 - * * \f$p\f$ is the true photon arrival direction,  
470 - * * \f$E\f$ is the true photon energy, and  
471 - * * \f$t\f$ is the true trigger time.  
472 - *  
473 - * The integration is done over all relevant true sky directions \f$p\f$.  
474 - *  
475 - * Depending on the type of the source model the method branches to the  
476 - * following methods to perform the actual computations  
477 - *  
478 - * irf_ptsrc() - for the handling of a point source  
479 - * irf_radial() - for radial models  
480 - * irf_elliptical() - for elliptical models  
481 - * irf_diffuse() - for diffuse models  
482 - * irf_composite() - for composite models  
483 - *  
484 - * The method implements a caching mechanism for spatial models that have all  
485 - * parameters fixed. For those models the instrument response for a given  
486 - * event and observation is only computed once and then stored in an internal  
487 - * cache from which it is fetched back in case that the method is called  
488 - * again for the same event and observation.  
489 - ***************************************************************************/  
490 -double GCTAResponseCube::irf_spatial(const GEvent& event,  
491 - const GSource& source,  
492 - const GObservation& obs) const  
493 -{  
494 - // Initialise IRF value  
495 - double irf = 0.0;  
496 -  
497 - // Set IRF value attributes  
498 - std::string name = obs.id() + "::" + source.name();  
499 - const GInstDir& dir = event.dir();  
500 - const GEnergy& ereco = event.energy();  
501 - const GEnergy& etrue = source.energy();  
502 -  
503 - // Signal if spatial model has free parameters  
504 - bool has_free_pars = source.model()->has_free_pars();  
505 -  
506 - // Kludge: the IRF response cache should be used, the model has no  
507 - // free parameters and there is no energy dispersion  
508 - if (m_use_irf_cache && !has_free_pars && !use_edisp()) {  
509 -  
510 - // Build unique cache name  
511 - std::string name = obs.id() + "::" + source.name();  
512 -  
513 - // Get index in cache, returns -1 if name is not found in cache  
514 - int index = -1;  
515 - for (int i = 0; i < m_cache_names.size(); ++i) {  
516 - if (m_cache_names[i] == name) {  
517 - index = i;  
518 - break;  
519 - }  
520 - }  
521 -  
522 - // If index was not found then allocate a new cache map  
523 - if (index == -1) {  
524 -  
525 - // Get pointer to event cube  
526 - const GCTAEventCube* cube =  
527 - static_cast<const GCTAEventCube*>(obs.events());  
528 -  
529 - // Allocate cache  
530 - GNdarray cache(cube->nx()*cube->ny(), cube->ebins());  
531 -  
532 - // Initialise all cache values with -1 (not set)  
533 - for (int i = 0; i < cache.size(); ++i) {  
534 - cache(i) = -1.0;  
535 - }  
536 -  
537 - // Insert cache  
538 - m_cache_names.push_back(name);  
539 - m_cache_values.push_back(cache);  
540 -  
541 - // Set index  
542 - index = m_cache_names.size()-1;  
543 -  
544 - } // endif: allocated new cache  
545 -  
546 - // Get reference to CTA event bin  
547 - const GCTAEventBin& bin = static_cast<const GCTAEventBin&>(event);  
548 -  
549 - // Get cache value  
550 - irf = m_cache_values[index](bin.ipix(), bin.ieng());  
551 -  
552 - // If cache value is not valid then copute IRF  
553 - if (irf < 0.0) {  
554 -  
555 - // Compute IRF for spatial model  
556 - switch (source.model()->code()) {  
557 - case GMODEL_SPATIAL_POINT_SOURCE:  
558 - irf = irf_ptsrc(event, source, obs);  
559 - break;  
560 - case GMODEL_SPATIAL_RADIAL:  
561 - irf = irf_radial(event, source, obs);  
562 - break;  
563 - case GMODEL_SPATIAL_ELLIPTICAL:  
564 - irf = irf_elliptical(event, source, obs);  
565 - break;  
566 - case GMODEL_SPATIAL_DIFFUSE:  
567 - irf = irf_diffuse(event, source, obs);  
568 - break;  
569 - case GMODEL_SPATIAL_COMPOSITE:  
570 - irf = irf_composite(event, source, obs);  
571 - break;  
572 - default:  
573 - break;  
574 - }  
575 -  
576 - // Set cache value  
577 - m_cache_values[index](bin.ipix(), bin.ieng()) = irf;  
578 -  
579 - } // endif: computed IRF  
580 -  
581 - } // endif: kludge  
582 -  
583 - // ... otherwise use release 1.7 response cache  
584 - else {  
585 -  
586 - // If the spatial model component has free parameters, or the response  
587 - // cache should not be used, or the cache does not contain the requested  
588 - // IRF value then compute the IRF value for the spatial model.  
589 - if (has_free_pars ||  
590 - !m_use_irf_cache ||  
591 - !m_irf_cache.contains(name, dir, ereco, etrue, &irf)) {  
592 -  
593 - // Compute IRF for spatial model  
594 - switch (source.model()->code()) {  
595 - case GMODEL_SPATIAL_POINT_SOURCE:  
596 - irf = irf_ptsrc(event, source, obs);  
597 - break;  
598 - case GMODEL_SPATIAL_RADIAL:  
599 - irf = irf_radial(event, source, obs);  
600 - break;  
601 - case GMODEL_SPATIAL_ELLIPTICAL:  
602 - irf = irf_elliptical(event, source, obs);  
603 - break;  
604 - case GMODEL_SPATIAL_DIFFUSE:  
605 - irf = irf_diffuse(event, source, obs);  
606 - break;  
607 - case GMODEL_SPATIAL_COMPOSITE:  
608 - irf = irf_composite(event, source, obs);  
609 - break;  
610 - default:  
611 - break;  
612 - }  
613 -  
614 - } // endif: computed spatial model  
615 -  
616 - // If the spatial model has no free parameters and the response cache  
617 - // should be used then put the IRF value in the response cache.  
618 - if (!has_free_pars && m_use_irf_cache) {  
619 - m_irf_cache.set(name, dir, ereco, etrue, irf);  
620 - }  
621 -  
622 - } // endelse: used release 1.7 response cache  
623 -  
624 - // Return IRF value  
625 - return irf;  
626 -}  
627 -  
628 -  
629 -/***********************************************************************//**  
630 * @brief Read response information from XML element 446 * @brief Read response information from XML element
631 * 447 *
632 * @param[in] xml XML element. 448 * @param[in] xml XML element.
@@ -820,10 +636,6 @@ void GCTAResponseCube::init_members(void) @@ -820,10 +636,6 @@ void GCTAResponseCube::init_members(void)
820 m_apply_edisp = false; 636 m_apply_edisp = false;
821 m_has_edisp = false; 637 m_has_edisp = false;
822 638
823 - // Kludge: Initialise cube response cache  
824 - m_cache_names.clear();  
825 - m_cache_values.clear();  
826 -  
827 // Return 639 // Return
828 return; 640 return;
829 } 641 }
@@ -844,10 +656,6 @@ void GCTAResponseCube::copy_members(const GCTAResponseCube&amp; rsp) @@ -844,10 +656,6 @@ void GCTAResponseCube::copy_members(const GCTAResponseCube&amp; rsp)
844 m_apply_edisp = rsp.m_apply_edisp; 656 m_apply_edisp = rsp.m_apply_edisp;
845 m_has_edisp = rsp.m_has_edisp; 657 m_has_edisp = rsp.m_has_edisp;
846 658
847 - // Kludge: Copy cube response cache  
848 - m_cache_names = rsp.m_cache_names;  
849 - m_cache_values = rsp.m_cache_values;  
850 -  
851 // Return 659 // Return
852 return; 660 return;
853 } 661 }
inst/cta/src/GCTAResponseIrf.cpp
@@ -2131,8 +2131,6 @@ void GCTAResponseIrf::copy_members(const GCTAResponseIrf&amp; rsp) @@ -2131,8 +2131,6 @@ void GCTAResponseIrf::copy_members(const GCTAResponseIrf&amp; rsp)
2131 m_xml_caldb = rsp.m_xml_caldb; 2131 m_xml_caldb = rsp.m_xml_caldb;
2132 m_xml_rspname = rsp.m_xml_rspname; 2132 m_xml_rspname = rsp.m_xml_rspname;
2133 2133
2134 - // Copy nroi cache  
2135 -  
2136 // Clone members 2134 // Clone members
2137 m_aeff = (rsp.m_aeff != NULL) ? rsp.m_aeff->clone() : NULL; 2135 m_aeff = (rsp.m_aeff != NULL) ? rsp.m_aeff->clone() : NULL;
2138 m_psf = (rsp.m_psf != NULL) ? rsp.m_psf->clone() : NULL; 2136 m_psf = (rsp.m_psf != NULL) ? rsp.m_psf->clone() : NULL;