GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTARoi.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTARoi.hpp - CTA region of interest class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2017 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GCTARoi.hpp
23  * @brief CTA region of interest class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAROI_HPP
28 #define GCTAROI_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GRoi.hpp"
33 #include "GCTAInstDir.hpp"
34 
35 /* __ Forward declarations _______________________________________________ */
36 class GEvent;
37 
38 
39 /***********************************************************************//**
40  * @class GCTARoi
41  *
42  * @brief Interface for the CTA region of interest class.
43  *
44  * The CTA region of interest class defines the region of photon arrival
45  * directions that is used for unbinned data analysis. A circular ROI has
46  * been implemented.
47  ***************************************************************************/
48 class GCTARoi : public GRoi {
49 
50 public:
51  // Constructors and destructors
52  GCTARoi(void);
53  explicit GCTARoi(const GXmlElement& xml);
54  GCTARoi(const GCTAInstDir& centre, const double& radius);
55  GCTARoi(const GCTARoi& roi);
56  virtual ~GCTARoi(void);
57 
58  // Operators
59  GCTARoi& operator=(const GCTARoi& roi);
60 
61  // Implemented pure virtual base class methods
62  virtual void clear(void);
63  virtual GCTARoi* clone(void) const;
64  virtual std::string classname(void) const;
65  virtual bool contains(const GEvent& event) const;
66  virtual std::string print(const GChatter& chatter = NORMAL) const;
67 
68  // Other methods
69  bool is_valid(void) const;
70  bool contains(const GCTAInstDir& dir) const;
71  const GCTAInstDir& centre(void) const;
72  const double& radius(void) const;
73  void centre(const GCTAInstDir& centre);
74  void radius(const double& radius);
75  void read(const GXmlElement& xml);
76  void write(GXmlElement& xml) const;
77 
78 protected:
79  // Protected methods
80  void init_members(void);
81  void copy_members(const GCTARoi& roi);
82  void free_members(void);
83 
84  // Protected members
85  GCTAInstDir m_centre; //!< Centre of ROI in instrument coordinates
86  double m_radius; //!< Radius of ROI in degrees
87 };
88 
89 
90 /***********************************************************************//**
91  * @brief Return class name
92  *
93  * @return String containing the class name ("GCTARoi").
94  ***************************************************************************/
95 inline
96 std::string GCTARoi::classname(void) const
97 {
98  return ("GCTARoi");
99 }
100 
101 
102 /***********************************************************************//**
103  * @brief Returns region of interest centre
104  *
105  * @return Region of interest centre sky direction.
106  *
107  * Returns the sky direction of the region of interest centre.
108  ***************************************************************************/
109 inline
110 const GCTAInstDir& GCTARoi::centre(void) const
111 {
112  return (m_centre);
113 }
114 
115 
116 /***********************************************************************//**
117  * @brief Returns radius of region of interest in degrees
118  *
119  * @return Region of interest radius (degrees).
120  *
121  * Returns the radius of the region of interest in degrees.
122  ***************************************************************************/
123 inline
124 const double& GCTARoi::radius(void) const
125 {
126  return (m_radius);
127 }
128 
129 
130 /***********************************************************************//**
131  * @brief Set region of interest centre
132  *
133  * @param[in] centre Region of interest centre sky direction.
134  *
135  * Set the sky direction of the region of interest centre.
136  ***************************************************************************/
137 inline
139 {
140  m_centre = centre;
141  return;
142 }
143 
144 
145 /***********************************************************************//**
146  * @brief Checks if RoI is valid
147  *
148  * @return Bool flag if ROI information is valid.
149  ***************************************************************************/
150 inline
151 bool GCTARoi::is_valid(void) const
152 {
153  return (m_radius > 0.0);
154 }
155 
156 
157 #endif /* GCTAROI_HPP */
virtual std::string print(const GChatter &chatter=NORMAL) const
Print ROI information.
Definition: GCTARoi.cpp:337
virtual ~GCTARoi(void)
Destructor.
Definition: GCTARoi.cpp:128
void free_members(void)
Delete class members.
Definition: GCTARoi.cpp:426
Abstract interface for the event classes.
Definition: GEvent.hpp:71
const double & radius(void) const
Returns radius of region of interest in degrees.
Definition: GCTARoi.hpp:124
XML element node class.
Definition: GXmlElement.hpp:47
Interface for the CTA region of interest class.
Definition: GCTARoi.hpp:48
void write(GXmlElement &xml) const
Write region of interest into XML element.
Definition: GCTARoi.cpp:311
Abstract Region of interest base class definition.
std::string centre(const std::string &s, const int &n, const char &c= ' ')
Centre string to achieve a length of n characters.
Definition: GTools.cpp:995
void copy_members(const GCTARoi &roi)
Copy class members.
Definition: GCTARoi.cpp:412
GCTARoi(void)
Void constructor.
Definition: GCTARoi.cpp:57
const GCTAInstDir & centre(void) const
Returns region of interest centre.
Definition: GCTARoi.hpp:110
virtual GCTARoi * clone(void) const
Clone instance.
Definition: GCTARoi.cpp:203
CTA instrument direction class interface definition.
virtual bool contains(const GEvent &event) const
Check if region of interest contains an event.
Definition: GCTARoi.cpp:214
virtual void clear(void)
Clear instance.
Definition: GCTARoi.cpp:183
GChatter
Definition: GTypemaps.hpp:33
double m_radius
Radius of ROI in degrees.
Definition: GCTARoi.hpp:86
bool is_valid(void) const
Checks if RoI is valid.
Definition: GCTARoi.hpp:151
CTA instrument direction class.
Definition: GCTAInstDir.hpp:59
virtual std::string classname(void) const
Return class name.
Definition: GCTARoi.hpp:96
GCTARoi & operator=(const GCTARoi &roi)
Assignment operator.
Definition: GCTARoi.cpp:150
Interface for the region of interest classes.
Definition: GRoi.hpp:48
void read(const GXmlElement &xml)
Read region of interest from XML element.
Definition: GCTARoi.cpp:264
void init_members(void)
Initialise class members.
Definition: GCTARoi.cpp:396
GCTAInstDir m_centre
Centre of ROI in instrument coordinates.
Definition: GCTARoi.hpp:85