Commit 80d8ec04d80e49d1cffef8912146ed3837d01759

Authored by Jürgen Knödlseder
1 parent b125c5f1

Add GCTAResponse::isvalid() method that checks if a response has been loaded.

... ... @@ -21,6 +21,9 @@ The following classes have been renamed:
21 21 The GObservation::response() method now returns a pointer to GResponse
22 22 instead of a reference.
23 23  
  24 +The GCTAObservation::load(GFits&) and GCTAObservation::save(GFits&)
  25 +methods have been remaned to read() and write().
  26 +
24 27  
25 28 3. Configuration
26 29 -----------------
... ...
gammalib.pc.in
... ... @@ -6,7 +6,7 @@ includedir=${prefix}/include
6 6 Name: GammaLib
7 7 Description: Versatile toolbox for analysis of astronomical gamma-ray data
8 8 URL: http://gammalib.sourceforge.net/
9   -Version: 0.8.1
  9 +Version: 0.9.0
10 10 Requires:
11 11 Requires.private: @CFITSIO@
12 12 Conflicts:
... ...
inst/cta/include/GCTAResponse.hpp
... ... @@ -65,8 +65,11 @@ public:
65 65 // Pure virtual methods
66 66 virtual void clear(void) = 0;
67 67 virtual GCTAResponse* clone(void) const = 0;
  68 + virtual bool isvalid(void) const = 0;
68 69 virtual bool use_edisp(void) const = 0;
69 70 virtual bool use_tdisp(void) const = 0;
  71 + virtual bool apply_edisp(void) const = 0;
  72 + virtual void apply_edisp(const bool& apply_edisp) const = 0;
70 73 virtual double irf(const GEvent& event,
71 74 const GPhoton& photon,
72 75 const GObservation& obs) const = 0;
... ...
inst/cta/include/GCTAResponseCube.hpp
... ... @@ -63,8 +63,11 @@ public:
63 63 // Implement pure virtual base class methods
64 64 virtual void clear(void);
65 65 virtual GCTAResponseCube* clone(void) const;
  66 + virtual bool isvalid(void) const;
66 67 virtual bool use_edisp(void) const;
67 68 virtual bool use_tdisp(void) const;
  69 + virtual bool apply_edisp(void) const;
  70 + virtual void apply_edisp(const bool& apply_edisp) const;
68 71 virtual double irf(const GEvent& event,
69 72 const GPhoton& photon,
70 73 const GObservation& obs) const;
... ... @@ -89,10 +92,25 @@ private:
89 92 // Private data members
90 93 GCTAExposure m_exposure; //!< Exposure cube
91 94 GCTAMeanPsf m_psf; //!< Mean point spread function
  95 + mutable bool m_apply_edisp; //!< Apply energy dispersion
92 96 };
93 97  
94 98  
95 99 /***********************************************************************//**
  100 + * @brief Signal if response is valid
  101 + *
  102 + * @return True if response is valid
  103 + *
  104 + * @todo: To be implemented (check if GCTAExposure and GCTAMeanPsf is loaded)
  105 + ***************************************************************************/
  106 +inline
  107 +bool GCTAResponseCube::isvalid(void) const
  108 +{
  109 + return (true);
  110 +}
  111 +
  112 +
  113 +/***********************************************************************//**
96 114 * @brief Signal if response uses energy dispersion
97 115 *
98 116 * @return True if response uses energy dispersion
... ... @@ -121,6 +139,30 @@ bool GCTAResponseCube::use_tdisp(void) const
121 139  
122 140  
123 141 /***********************************************************************//**
  142 + * @brief Signal if energy dispersion should be applied
  143 + *
  144 + * @return True if energy dispersion should be applied
  145 + ***************************************************************************/
  146 +inline
  147 +bool GCTAResponseCube::apply_edisp(void) const
  148 +{
  149 + return m_apply_edisp;
  150 +}
  151 +
  152 +/***********************************************************************//**
  153 + * @brief Signal if energy dispersion should be applied
  154 + *
  155 + * @param[in] apply_edisp Set true if energy dispersion should be applied
  156 + ***************************************************************************/
  157 +inline
  158 +void GCTAResponseCube::apply_edisp(const bool& apply_edisp) const
  159 +{
  160 + m_apply_edisp = apply_edisp;
  161 + return;
  162 +}
  163 +
  164 +
  165 +/***********************************************************************//**
124 166 * @brief Return exposure cube
125 167 *
126 168 * @return Reference to exposure cube.
... ...
inst/cta/include/GCTAResponseIrf.hpp
... ... @@ -74,8 +74,11 @@ public:
74 74 // Implement pure virtual base class methods
75 75 virtual void clear(void);
76 76 virtual GCTAResponseIrf* clone(void) const;
  77 + virtual bool isvalid(void) const;
77 78 virtual bool use_edisp(void) const;
78 79 virtual bool use_tdisp(void) const;
  80 + virtual bool apply_edisp(void) const;
  81 + virtual void apply_edisp(const bool& apply_edisp) const;
79 82 virtual double irf(const GEvent& event,
80 83 const GPhoton& photon,
81 84 const GObservation& obs) const;
... ... @@ -104,8 +107,6 @@ public:
104 107 virtual GEbounds ebounds_src(const GEnergy& obsEnergy) const;
105 108  
106 109 // Other Methods
107   - bool apply_edisp(void) const;
108   - void apply_edisp(const bool& apply_edisp) const;
109 110 GCTAEventAtom* mc(const double& area, const GPhoton& photon,
110 111 const GObservation& obs, GRan& ran) const;
111 112 void caldb(const GCaldb& caldb);
... ... @@ -196,6 +197,18 @@ private:
196 197  
197 198  
198 199 /***********************************************************************//**
  200 + * @brief Signal if response is valid
  201 + *
  202 + * @return True if response is valid
  203 + ***************************************************************************/
  204 +inline
  205 +bool GCTAResponseIrf::isvalid(void) const
  206 +{
  207 + return ((m_aeff != NULL) && (m_psf != NULL));
  208 +}
  209 +
  210 +
  211 +/***********************************************************************//**
199 212 * @brief Signal if response uses energy dispersion
200 213 *
201 214 * @return True if response uses energy dispersion
... ...
inst/cta/src/GCTAResponseCube.cpp
... ... @@ -43,6 +43,7 @@
43 43 /* __ Method name definitions ____________________________________________ */
44 44 #define G_IRF "GCTAResponseCube::irf(GEvent&, GPhoton& GObservation&)"
45 45 #define G_NPRED_DIFFUSE "GCTAResponseCube::npred(GPhoton&, GObservation&)"
  46 +#define G_READ "GCTAResponseCube::read(GXmlElement&)"
46 47  
47 48 /* __ Macros _____________________________________________________________ */
48 49  
... ... @@ -330,7 +331,6 @@ double GCTAResponseCube::npred(const GPhoton&amp; photon,
330 331 * </observation>
331 332 *
332 333 ***************************************************************************/
333   -#define G_READ "GCTAResponseCube::read(GXmlElement&)"
334 334 void GCTAResponseCube::read(const GXmlElement& xml)
335 335 {
336 336 // Determine number of parameter nodes in XML element
... ... @@ -419,74 +419,6 @@ void GCTAResponseCube::write(GXmlElement&amp; xml) const
419 419  
420 420  
421 421 /***********************************************************************//**
422   - * @brief Load CTA response
423   - *
424   - * @param[in] rspname CTA response name.
425   - *
426   - * Loads the CTA response with specified name @p rspname. The method first
427   - * searchs for an appropriate response in the calibration database. If no
428   - * appropriate response is found, the method takes the database root path
429   - * and response name to build the full path to the response file, and tries
430   - * to load the response from these paths.
431   - ***************************************************************************/
432   -/*
433   -void GCTAResponseCube::load(const std::string& rspname)
434   -{
435   - // Clear instance but conserve calibration database
436   - GCaldb caldb = m_caldb;
437   - clear();
438   - m_caldb = caldb;
439   -
440   - // First attempt reading the response using the GCaldb interface
441   - std::string expr = "NAME("+rspname+")";
442   - std::string aeffname = m_caldb.filename("","","EFF_AREA","","",expr);
443   - std::string psfname = m_caldb.filename("","","RPSF","","",expr);
444   - std::string edispname = m_caldb.filename("","","EDISP","","",expr);
445   - std::string bgdname = m_caldb.filename("","","BGD","","",expr);
446   -
447   - // If filenames are empty then build filenames from CALDB root path and
448   - // response name
449   - if (aeffname.length() < 1) {
450   - aeffname = irf_filename(gammalib::filepath(m_caldb.rootdir(), rspname));
451   - }
452   - if (psfname.length() < 1) {
453   - psfname = irf_filename(gammalib::filepath(m_caldb.rootdir(), rspname));
454   - }
455   - if (edispname.length() < 1) {
456   - edispname = irf_filename(gammalib::filepath(m_caldb.rootdir(), rspname));
457   - }
458   - if (bgdname.length() < 1) {
459   - bgdname = irf_filename(gammalib::filepath(m_caldb.rootdir(), rspname));
460   - }
461   -
462   - // Load effective area
463   - load_aeff(aeffname);
464   -
465   - // Load point spread function
466   - load_psf(psfname);
467   -
468   - // Load energy dispersion
469   - load_edisp(edispname);
470   -
471   - // Load background
472   - load_background(bgdname);
473   -
474   - // Remove theta cut
475   - GCTAAeffArf* arf = const_cast<GCTAAeffArf*>(dynamic_cast<const GCTAAeffArf*>(m_aeff));
476   - if (arf != NULL) {
477   - arf->remove_thetacut(*this);
478   - }
479   -
480   - // Store response name
481   - m_rspname = rspname;
482   -
483   - // Return
484   - return;
485   -}
486   -*/
487   -
488   -
489   -/***********************************************************************//**
490 422 * @brief Print CTA response information
491 423 *
492 424 * @param[in] chatter Chattiness (defaults to NORMAL).
... ... @@ -503,6 +435,20 @@ std::string GCTAResponseCube::print(const GChatter&amp; chatter) const
503 435 // Append header
504 436 result.append("=== GCTAResponseCube ===");
505 437  
  438 + // Append response information
  439 + result.append("\n"+gammalib::parformat("Energy dispersion"));
  440 + if (use_edisp()) {
  441 + result.append("Used");
  442 + }
  443 + else {
  444 + if (apply_edisp()) {
  445 + result.append("Not available");
  446 + }
  447 + else {
  448 + result.append("Not used");
  449 + }
  450 + }
  451 +
506 452 // Append exposure cube information
507 453 result.append("\n"+m_exposure.print(chatter));
508 454  
... ... @@ -544,6 +490,7 @@ void GCTAResponseCube::init_members(void)
544 490 // Initialise members
545 491 m_exposure.clear();
546 492 m_psf.clear();
  493 + m_apply_edisp = false;
547 494  
548 495 // Return
549 496 return;
... ... @@ -558,8 +505,9 @@ void GCTAResponseCube::init_members(void)
558 505 void GCTAResponseCube::copy_members(const GCTAResponseCube& rsp)
559 506 {
560 507 // Copy members
561   - m_exposure = rsp.m_exposure;
562   - m_psf = rsp.m_psf;
  508 + m_exposure = rsp.m_exposure;
  509 + m_psf = rsp.m_psf;
  510 + m_apply_edisp = rsp.m_apply_edisp;
563 511  
564 512 // Return
565 513 return;
... ...