Commit ce98da1ec38ccf9f68caa6f65cfaae1f7d596184

Authored by Josh Cardenzana
1 parent 3705c8a9

Added base code for "RING" bkg subtraction (#2207)

Fixed the method names for G_BIN_EVENTS and G_BKG_SUBTRACT_IRF, which were incorrectly set to older method name values.
Added G_BKG_SUBTRACT_RING definition for the ring background subtraction method.
Added definition of parameters in 'ctskymap::get_parameters()'.
Added method for computing the ring background subtraction (skeleton).
Added parameters for defining the ring and integration source region integration radius.
Added configuration parameters to parameter file.
- roiradius: Region of interest radius
- inradius: Inner ring radius
- outradius: Outer ring radius
- regfile: Region file (or FITS mask file) for exclusion regions.
src/ctskymap/ctskymap.cpp
@@ -32,9 +32,10 @@ @@ -32,9 +32,10 @@
32 #include "ctskymap.hpp" 32 #include "ctskymap.hpp"
33 33
34 /* __ Method name definitions ____________________________________________ */ 34 /* __ Method name definitions ____________________________________________ */
35 -#define G_INIT_MAP "ctskymap::init_map(GCTAObservation* obs)"  
36 -#define G_BIN_EVENTS "ctskymap::bin_events(GCTAObservation*)"  
37 -#define G_BKG_SUBTRACT_IRF "ctskymap::bkg_subtract_irf(GCTAObservation*)" 35 +#define G_INIT_MAP "ctskymap::init_map(GCTAObservation* obs)"
  36 +#define G_BIN_EVENTS "ctskymap::map_events(GCTAObservation*)"
  37 +#define G_BKG_SUBTRACT_IRF "ctskymap::map_background_irf(GCTAObservation*)"
  38 +#define G_BKG_SUBTRACT_RING "ctskymap::map_background_ring(GCTAObservation*)"
38 39
39 /* __ Debug definitions __________________________________________________ */ 40 /* __ Debug definitions __________________________________________________ */
40 41
@@ -441,6 +442,9 @@ void ctskymap::get_parameters(void) @@ -441,6 +442,9 @@ void ctskymap::get_parameters(void)
441 // Read ahead parameters 442 // Read ahead parameters
442 if (read_ahead()) { 443 if (read_ahead()) {
443 m_outmap = (*this)["outmap"].filename(); 444 m_outmap = (*this)["outmap"].filename();
  445 + m_roiradius = (this)["roiradius"].real();
  446 + m_inradius = (this)["m_inradius"].real();
  447 + m_outradius = (this)["m_outradius"].real();
444 } 448 }
445 449
446 // Create background map and significance map if background subtraction 450 // Create background map and significance map if background subtraction
@@ -448,6 +452,11 @@ void ctskymap::get_parameters(void) @@ -448,6 +452,11 @@ void ctskymap::get_parameters(void)
448 if (m_bkgsubtract != "NONE") { 452 if (m_bkgsubtract != "NONE") {
449 m_bkgmap = create_map(m_obs); 453 m_bkgmap = create_map(m_obs);
450 m_sigmap = create_map(m_obs); 454 m_sigmap = create_map(m_obs);
  455 +
  456 + // If doing a ring background subtraction, generate an alpha map
  457 + if (m_bkgsubtract == "RING") {
  458 + m_alphamap = create_map(m_obs);
  459 + }
451 } 460 }
452 461
453 // Write parameters into logger 462 // Write parameters into logger
@@ -566,6 +575,8 @@ void ctskymap::map_background(GCTAObservation* obs) @@ -566,6 +575,8 @@ void ctskymap::map_background(GCTAObservation* obs)
566 // Dispatch to appropriate background estimation method 575 // Dispatch to appropriate background estimation method
567 if (m_bkgsubtract == "IRF") { 576 if (m_bkgsubtract == "IRF") {
568 map_background_irf(obs); 577 map_background_irf(obs);
  578 + } else if (m_bkgsubtract == "RING") {
  579 + map_background_ring(obs);
569 } 580 }
570 581
571 // Return 582 // Return
@@ -673,6 +684,23 @@ void ctskymap::map_background_irf(GCTAObservation* obs) @@ -673,6 +684,23 @@ void ctskymap::map_background_irf(GCTAObservation* obs)
673 684
674 685
675 /***********************************************************************//** 686 /***********************************************************************//**
  687 + * @brief Estimates the background in sky map based on the ring background method
  688 + *
  689 + * @param[in] obs CTA observation.
  690 + *
  691 + * @exception GException::invalid_value
  692 + * No response information available for observation.
  693 + * No background template available in instrument response function.
  694 + *
  695 + * Estimates the background in the sky map by summing the events within a ring
  696 + * centered at a given pixel's position. The pixels in the ring are weighted
  697 + * also by the background IRF value
  698 + ***************************************************************************/
  699 +void ctskymap::map_background_ring(GCTAObservation* obs)
  700 +{}
  701 +
  702 +
  703 +/***********************************************************************//**
676 * @brief Estimates the background in sky map based on IRF template 704 * @brief Estimates the background in sky map based on IRF template
677 * 705 *
678 * @param[in] lnE Natural logarithm of energy in MeV. 706 * @param[in] lnE Natural logarithm of energy in MeV.
src/ctskymap/ctskymap.hpp
@@ -71,6 +71,7 @@ protected: @@ -71,6 +71,7 @@ protected:
71 void map_events(GCTAObservation* obs); 71 void map_events(GCTAObservation* obs);
72 void map_background(GCTAObservation* obs); 72 void map_background(GCTAObservation* obs);
73 void map_background_irf(GCTAObservation* obs); 73 void map_background_irf(GCTAObservation* obs);
  74 + void map_background_ring(GCTAObservation* obs);
74 75
75 // Background integration kernel 76 // Background integration kernel
76 class irf_kern : public GFunction { 77 class irf_kern : public GFunction {
@@ -92,11 +93,15 @@ protected: @@ -92,11 +93,15 @@ protected:
92 std::string m_bkgsubtract; //!< Background subtraction method 93 std::string m_bkgsubtract; //!< Background subtraction method
93 bool m_publish; //!< Publish sky map? 94 bool m_publish; //!< Publish sky map?
94 GChatter m_chatter; //!< Chattiness 95 GChatter m_chatter; //!< Chattiness
95 - 96 + double m_roiradius; //!< Region of interest radius
  97 + double m_inradius; //!< Inner ring radius
  98 + double m_outradius; //!< Outer ring radius
  99 +
96 // Protected members 100 // Protected members
97 GSkyMap m_skymap; //!< Sky map 101 GSkyMap m_skymap; //!< Sky map
98 GSkyMap m_bkgmap; //!< Background map 102 GSkyMap m_bkgmap; //!< Background map
99 GSkyMap m_sigmap; //!< Significance map 103 GSkyMap m_sigmap; //!< Significance map
  104 + GSkyMap m_alphamap; //!< Alpha map (if doing "RING" bkg subtraction)
100 }; 105 };
101 106
102 107
src/ctskymap/ctskymap.par
@@ -42,7 +42,11 @@ yref, r, a, 22.01,-90,90, &quot;Second coordinate of image center in degrees (DEC @@ -42,7 +42,11 @@ yref, r, a, 22.01,-90,90, &quot;Second coordinate of image center in degrees (DEC
42 # 42 #
43 # Background subtraction parameters 43 # Background subtraction parameters
44 #================================== 44 #==================================
45 -bkgsubtract, s, a, NONE, NONE|IRF,, "Background subtraction method" 45 +bkgsubtract, s, a, NONE, NONE|IRF|RING,, "Background subtraction method"
  46 +roiradius, r, h, 0.0,,, "Region of interest radius"
  47 +inradius, r, h, 0.6,,, "Inner ring radius"
  48 +outradius, r, h, 0.8,,, "Outer ring radius"
  49 +regfile, f, h, NONE,,, "Exclusion regions definition file"
46 50
47 # 51 #
48 # Standard parameters 52 # Standard parameters