GammaLib  2.1.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-2021 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 class GXmlElement;
38 
39 
40 /***********************************************************************//**
41  * @class GCTARoi
42  *
43  * @brief Interface for the CTA region of interest class.
44  *
45  * The CTA region of interest class defines the region of photon arrival
46  * directions that is used for unbinned data analysis. A circular ROI has
47  * been implemented.
48  ***************************************************************************/
49 class GCTARoi : public GRoi {
50 
51 public:
52  // Constructors and destructors
53  GCTARoi(void);
54  explicit GCTARoi(const GXmlElement& xml);
55  GCTARoi(const GCTAInstDir& centre, const double& radius);
56  GCTARoi(const GCTARoi& roi);
57  virtual ~GCTARoi(void);
58 
59  // Operators
60  GCTARoi& operator=(const GCTARoi& roi);
61 
62  // Implemented pure virtual base class methods
63  virtual void clear(void);
64  virtual GCTARoi* clone(void) const;
65  virtual std::string classname(void) const;
66  virtual bool contains(const GEvent& event) const;
67  virtual std::string print(const GChatter& chatter = NORMAL) const;
68 
69  // Other methods
70  bool is_valid(void) const;
71  bool contains(const GCTAInstDir& dir) const;
72  const GCTAInstDir& centre(void) const;
73  const double& radius(void) const;
74  void centre(const GCTAInstDir& centre);
75  void radius(const double& radius);
76  void read(const GXmlElement& xml);
77  void write(GXmlElement& xml) const;
78 
79 protected:
80  // Protected methods
81  void init_members(void);
82  void copy_members(const GCTARoi& roi);
83  void free_members(void);
84 
85  // Protected members
86  GCTAInstDir m_centre; //!< Centre of ROI in instrument coordinates
87  double m_radius; //!< Radius of ROI in degrees
88 };
89 
90 
91 /***********************************************************************//**
92  * @brief Return class name
93  *
94  * @return String containing the class name ("GCTARoi").
95  ***************************************************************************/
96 inline
97 std::string GCTARoi::classname(void) const
98 {
99  return ("GCTARoi");
100 }
101 
102 
103 /***********************************************************************//**
104  * @brief Returns region of interest centre
105  *
106  * @return Region of interest centre sky direction.
107  *
108  * Returns the sky direction of the region of interest centre.
109  ***************************************************************************/
110 inline
111 const GCTAInstDir& GCTARoi::centre(void) const
112 {
113  return (m_centre);
114 }
115 
116 
117 /***********************************************************************//**
118  * @brief Returns radius of region of interest in degrees
119  *
120  * @return Region of interest radius (degrees).
121  *
122  * Returns the radius of the region of interest in degrees.
123  ***************************************************************************/
124 inline
125 const double& GCTARoi::radius(void) const
126 {
127  return (m_radius);
128 }
129 
130 
131 /***********************************************************************//**
132  * @brief Set region of interest centre
133  *
134  * @param[in] centre Region of interest centre sky direction.
135  *
136  * Set the sky direction of the region of interest centre.
137  ***************************************************************************/
138 inline
140 {
141  m_centre = centre;
142  return;
143 }
144 
145 
146 /***********************************************************************//**
147  * @brief Checks if RoI is valid
148  *
149  * @return Bool flag if ROI information is valid.
150  ***************************************************************************/
151 inline
152 bool GCTARoi::is_valid(void) const
153 {
154  return (m_radius > 0.0);
155 }
156 
157 
158 #endif /* GCTAROI_HPP */
virtual std::string print(const GChatter &chatter=NORMAL) const
Print ROI information.
Definition: GCTARoi.cpp:338
virtual ~GCTARoi(void)
Destructor.
Definition: GCTARoi.cpp:129
void free_members(void)
Delete class members.
Definition: GCTARoi.cpp:427
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:125
XML element node class.
Definition: GXmlElement.hpp:48
Interface for the CTA region of interest class.
Definition: GCTARoi.hpp:49
void write(GXmlElement &xml) const
Write region of interest into XML element.
Definition: GCTARoi.cpp:312
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:1118
void copy_members(const GCTARoi &roi)
Copy class members.
Definition: GCTARoi.cpp:413
GCTARoi(void)
Void constructor.
Definition: GCTARoi.cpp:58
const GCTAInstDir & centre(void) const
Returns region of interest centre.
Definition: GCTARoi.hpp:111
virtual GCTARoi * clone(void) const
Clone instance.
Definition: GCTARoi.cpp:204
CTA instrument direction class interface definition.
virtual bool contains(const GEvent &event) const
Check if region of interest contains an event.
Definition: GCTARoi.cpp:215
virtual void clear(void)
Clear instance.
Definition: GCTARoi.cpp:184
GChatter
Definition: GTypemaps.hpp:33
double m_radius
Radius of ROI in degrees.
Definition: GCTARoi.hpp:87
bool is_valid(void) const
Checks if RoI is valid.
Definition: GCTARoi.hpp:152
CTA instrument direction class.
Definition: GCTAInstDir.hpp:63
virtual std::string classname(void) const
Return class name.
Definition: GCTARoi.hpp:97
GCTARoi & operator=(const GCTARoi &roi)
Assignment operator.
Definition: GCTARoi.cpp:151
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:265
void init_members(void)
Initialise class members.
Definition: GCTARoi.cpp:397
GCTAInstDir m_centre
Centre of ROI in instrument coordinates.
Definition: GCTARoi.hpp:86