GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATInstDir.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATInstDir.cpp - Fermi/LAT instrument direction class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2013 by Jurgen Knodlseder *
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 GLATInstDir.cpp
23  * @brief Fermi/LAT instrument direction class implementation
24  * @author Juergen Knodlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GLATInstDir.hpp"
32 #include "GTools.hpp"
33 #include "GMath.hpp"
34 
35 /* __ Method name definitions ____________________________________________ */
36 
37 /* __ Macros _____________________________________________________________ */
38 
39 /* __ Coding definitions _________________________________________________ */
40 
41 /* __ Debug definitions __________________________________________________ */
42 
43 /* __ Prototypes _________________________________________________________ */
44 
45 /*==========================================================================
46  = =
47  = Constructors/destructors =
48  = =
49  ==========================================================================*/
50 
51 /***********************************************************************//**
52  * @brief Void constructor
53  ***************************************************************************/
55 {
56  // Initialise class members
57  init_members();
58 
59  // Return
60  return;
61 }
62 
63 
64 /***********************************************************************//**
65  * @brief GSkyDir constructor
66  *
67  * @param[in] dir Sky direction.
68  *
69  * Construct LAT instrument direction from sky direction.
70  ***************************************************************************/
72 {
73  // Initialise class members
74  init_members();
75 
76  // Assign sky direction
77  m_dir = dir;
78 
79  // Return
80  return;
81 }
82 
83 
84 /***********************************************************************//**
85  * @brief Copy constructor
86  *
87  * @param[in] dir Instrument direction.
88  ***************************************************************************/
90 {
91  // Initialise class members
92  init_members();
93 
94  // Copy members
95  copy_members(dir);
96 
97  // Return
98  return;
99 }
100 
101 
102 /***********************************************************************//**
103  * @brief Destructor
104  ***************************************************************************/
106 {
107  // Free members
108  free_members();
109 
110  // Return
111  return;
112 }
113 
114 
115 /*==========================================================================
116  = =
117  = Operators =
118  = =
119  ==========================================================================*/
120 
121 /***********************************************************************//**
122  * @brief Assignment operator
123  *
124  * @param[in] dir Instrument direction.
125  * @return Instrument direction.
126  ***************************************************************************/
128 {
129  // Execute only if object is not identical
130  if (this != &dir) {
131 
132  // Copy base class members
133  this->GInstDir::operator=(dir);
134 
135  // Free members
136  free_members();
137 
138  // Initialise private members
139  init_members();
140 
141  // Copy members
142  copy_members(dir);
143 
144  } // endif: object was not identical
145 
146  // Return this object
147  return *this;
148 }
149 
150 
151 /*==========================================================================
152  = =
153  = Public methods =
154  = =
155  ==========================================================================*/
156 
157 /***********************************************************************//**
158  * @brief Clear Fermi/LAT instrument direction
159  ***************************************************************************/
161 {
162  // Free members
163  free_members();
164  this->GInstDir::free_members();
165 
166  // Initialise private members
167  this->GInstDir::init_members();
168  init_members();
169 
170  // Return
171  return;
172 }
173 
174 
175 /***********************************************************************//**
176  * @brief Clone Fermi/LAT instrument direction
177  *
178  * @return Pointer to deep copy of Fermi/LAT instrument direction.
179  ***************************************************************************/
181 {
182  return new GLATInstDir(*this);
183 }
184 
185 
186 /***********************************************************************//**
187  * @brief Print instrument direction information
188  *
189  * @param[in] chatter Chattiness (defaults to NORMAL).
190  * @return String containing instrument direction information.
191  ***************************************************************************/
192 std::string GLATInstDir::print(const GChatter& chatter) const
193 {
194  // Initialise result string
195  std::string result;
196 
197  // Continue only if chatter is not silent
198  if (chatter != SILENT) {
199 
200  // Append instrument direction
201  result.append("RA="+gammalib::str(dir().ra_deg()) +
202  ", DEC="+gammalib::str(dir().dec_deg()));
203 
204  } // endif: chatter was not silent
205 
206  // Return result
207  return result;
208 }
209 
210 
211 /*==========================================================================
212  = =
213  = Private methods =
214  = =
215  ==========================================================================*/
216 
217 /***********************************************************************//**
218  * @brief Initialise class members
219  ***************************************************************************/
221 {
222  // Initialise members
223  m_dir.clear();
224 
225  // Return
226  return;
227 }
228 
229 
230 /***********************************************************************//**
231  * @brief Copy class members
232  *
233  * @param[in] dir Instrument direction.
234  ***************************************************************************/
236 {
237  // Copy attributes
238  m_dir = dir.m_dir;
239 
240  // Return
241  return;
242 }
243 
244 
245 /***********************************************************************//**
246  * @brief Delete class members
247  ***************************************************************************/
249 {
250  // Return
251  return;
252 }
GSkyDir & dir(void)
Returns reference to sky direction.
Definition: GLATInstDir.hpp:98
Fermi/LAT instrument direction class.
Definition: GLATInstDir.hpp:44
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
GSkyDir m_dir
Observed incident direction of event.
Definition: GLATInstDir.hpp:74
GLATInstDir(void)
Void constructor.
Definition: GLATInstDir.cpp:54
Abstract instrument direction base class.
Definition: GInstDir.hpp:47
virtual void clear(void)
Clear Fermi/LAT instrument direction.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
virtual ~GLATInstDir(void)
Destructor.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print instrument direction information.
GChatter
Definition: GTypemaps.hpp:33
virtual GLATInstDir * clone(void) const
Clone Fermi/LAT instrument direction.
GLATInstDir & operator=(const GLATInstDir &dir)
Assignment operator.
void copy_members(const GLATInstDir &dir)
Copy class members.
void clear(void)
Clear sky direction.
Definition: GSkyDir.cpp:142
void init_members(void)
Initialise class members.
Definition: GInstDir.cpp:141
Fermi/LAT instrument direction class definition.
Sky direction class.
Definition: GSkyDir.hpp:62
Mathematical function definitions.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:413