GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAInstDir.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAInstDir.cpp - CTA instrument direction class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2018 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 GCTAInstDir.cpp
23  * @brief CTA instrument direction class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GTools.hpp"
32 #include "GMath.hpp"
33 #include "GCTAInstDir.hpp"
34 
35 /* __ Method name definitions ____________________________________________ */
36 
37 /* __ Macros _____________________________________________________________ */
38 
39 /* __ Coding definitions _________________________________________________ */
40 
41 /* __ Debug definitions __________________________________________________ */
42 
43 /* __ Prototypes _________________________________________________________ */
44 
45 
46 /*==========================================================================
47  = =
48  = Constructors/destructors =
49  = =
50  ==========================================================================*/
51 
52 /***********************************************************************//**
53  * @brief Void constructor
54  ***************************************************************************/
56 {
57  // Initialise class members
58  init_members();
59 
60  // Return
61  return;
62 }
63 
64 
65 /***********************************************************************//**
66  * @brief Sky direction constructor
67  *
68  * @param[in] dir Sky direction.
69  *
70  * Construct CTA instrument direction from sky direction.
71  ***************************************************************************/
73 {
74  // Initialise class members
75  init_members();
76 
77  // Assign sky direction
78  this->dir(dir);
79 
80  // Return
81  return;
82 }
83 
84 
85 /***********************************************************************//**
86  * @brief Instrument coordinates constructor
87  *
88  * @param[in] detx Instrument coordinate X (radians).
89  * @param[in] dety Instrument coordinate Y (radians).
90  *
91  * Construct CTA instrument direction from instrument coordinates.
92  ***************************************************************************/
93 GCTAInstDir::GCTAInstDir(const double& detx, const double& dety) : GInstDir()
94 {
95  // Initialise class members
96  init_members();
97 
98  // Assign instrument coordinates
99  this->detx(detx);
100  this->dety(dety);
101 
102  // Return
103  return;
104 }
105 
106 
107 /***********************************************************************//**
108  * @brief Instrument direction constructor
109  *
110  * @param[in] dir Sky direction.
111  * @param[in] detx Instrument coordinate X (radians).
112  * @param[in] dety Instrument coordinate Y (radians).
113  *
114  * Construct CTA instrument direction from sky direction and instrument
115  * coordinates.
116  ***************************************************************************/
118  const double& detx,
119  const double& dety) : GInstDir()
120 {
121  // Initialise class members
122  init_members();
123 
124  // Assign instrument coordinates
125  this->dir(dir);
126  this->detx(detx);
127  this->dety(dety);
128 
129  // Return
130  return;
131 }
132 
133 
134 /***********************************************************************//**
135  * @brief Copy constructor
136  *
137  * @param[in] dir CTA instrument direction.
138  ***************************************************************************/
140 {
141  // Initialise class members
142  init_members();
143 
144  // Copy members
145  copy_members(dir);
146 
147  // Return
148  return;
149 }
150 
151 
152 /***********************************************************************//**
153  * @brief Destructor
154  ***************************************************************************/
156 {
157  // Free members
158  free_members();
159 
160  // Return
161  return;
162 }
163 
164 
165 /*==========================================================================
166  = =
167  = Operators =
168  = =
169  ==========================================================================*/
170 
171 /***********************************************************************//**
172  * @brief Assignment operator
173  *
174  * @param[in] dir CTA instrument direction.
175  * @return CTA instrument direction.
176  ***************************************************************************/
178 {
179  // Execute only if object is not identical
180  if (this != &dir) {
181 
182  // Copy base class members
183  this->GInstDir::operator=(dir);
184 
185  // Free members
186  free_members();
187 
188  // Initialise private members
189  init_members();
190 
191  // Copy members
192  copy_members(dir);
193 
194  } // endif: object was not identical
195 
196  // Return this object
197  return *this;
198 }
199 
200 
201 /*==========================================================================
202  = =
203  = Public methods =
204  = =
205  ==========================================================================*/
206 
207 /***********************************************************************//**
208  * @brief Clear CTA instrument direction
209  ***************************************************************************/
211 {
212  // Free members
213  free_members();
214  this->GInstDir::free_members();
215 
216  // Initialise private members
217  this->GInstDir::init_members();
218  init_members();
219 
220  // Return
221  return;
222 }
223 
224 
225 /***********************************************************************//**
226  * @brief CTA instrument direction
227  *
228  * @return Pointer to deep copy of CTA instrument direction.
229  ***************************************************************************/
231 {
232  return new GCTAInstDir(*this);
233 }
234 
235 
236 /***********************************************************************//**
237  * @brief Print instrument direction information
238  *
239  * @param[in] chatter Chattiness.
240  * @return String containing instrument direction information.
241  ***************************************************************************/
242 std::string GCTAInstDir::print(const GChatter& chatter) const
243 {
244  // Initialise result string
245  std::string result;
246 
247  // Continue only if chatter is not silent
248  if (chatter != SILENT) {
249 
250  // Append instrument direction
251  std::string msg = "RA=" + gammalib::str(m_dir.ra_deg()) +
252  ", DEC=" + gammalib::str(m_dir.dec_deg()) +
253  " [" + gammalib::str(m_detx) +
254  "," + gammalib::str(m_dety) + "]";
255  result.append(msg);
256 
257  } // endif: chatter was not silent
258 
259  // Return result
260  return result;
261 }
262 
263 
264 /*==========================================================================
265  = =
266  = Private methods =
267  = =
268  ==========================================================================*/
269 
270 /***********************************************************************//**
271  * @brief Initialise class members
272  ***************************************************************************/
274 {
275  // Initialise members
276  m_dir.clear();
277  m_detx = 0.0;
278  m_dety = 0.0;
279  m_has_dir = false;
280  m_has_detx = false;
281  m_has_dety = false;
282 
283  // Return
284  return;
285 }
286 
287 
288 /***********************************************************************//**
289  * @brief Copy class members
290  *
291  * @param[in] dir CTA instrument direction.
292  ***************************************************************************/
294 {
295  // Copy attributes
296  m_dir = dir.m_dir;
297  m_detx = dir.m_detx;
298  m_dety = dir.m_dety;
299  m_has_dir = dir.m_has_dir;
300  m_has_detx = dir.m_has_detx;
301  m_has_dety = dir.m_has_dety;
302 
303  // Return
304  return;
305 }
306 
307 
308 /***********************************************************************//**
309  * @brief Delete class members
310  ***************************************************************************/
312 {
313  // Return
314  return;
315 }
bool m_has_detx
Has valid instrument coordinate X.
virtual ~GCTAInstDir(void)
Destructor.
const double & dety(void) const
Return reference to DETY coordinate (in radians)
double dec_deg(void) const
Returns Declination in degrees.
Definition: GSkyDir.hpp:250
bool m_has_dir
Has valid incident direction.
const double & detx(void) const
Return reference to DETX coordinate (in radians)
Gammalib tools definition.
virtual GInstDir & operator=(const GInstDir &dir)
Assignment operator.
Definition: GInstDir.cpp:105
void free_members(void)
Delete class members.
Definition: GInstDir.cpp:163
GCTAInstDir & operator=(const GCTAInstDir &dir)
Assignment operator.
const GSkyDir & dir(void) const
Return reference to sky direction (const version)
Abstract instrument direction base class.
Definition: GInstDir.hpp:47
double m_dety
Instrument coordinate Y (radians)
void init_members(void)
Initialise class members.
double m_detx
Instrument coordinate X (radians)
bool m_has_dety
Has valid instrument coordinate Y.
CTA instrument direction class interface definition.
double ra_deg(void) const
Returns Right Ascension in degrees.
Definition: GSkyDir.hpp:223
GChatter
Definition: GTypemaps.hpp:33
GCTAInstDir(void)
Void constructor.
Definition: GCTAInstDir.cpp:55
virtual std::string print(const GChatter &chatter=NORMAL) const
Print instrument direction information.
virtual GCTAInstDir * clone(void) const
CTA instrument direction.
virtual void clear(void)
Clear CTA instrument direction.
void clear(void)
Clear sky direction.
Definition: GSkyDir.cpp:142
GSkyDir m_dir
Observed incident direction of event.
Definition: GCTAInstDir.hpp:99
void init_members(void)
Initialise class members.
Definition: GInstDir.cpp:141
void copy_members(const GCTAInstDir &dir)
Copy class members.
CTA instrument direction class.
Definition: GCTAInstDir.hpp:59
Sky direction class.
Definition: GSkyDir.hpp:62
void free_members(void)
Delete class members.
Mathematical function definitions.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:413