GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMInstDir.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMInstDir.cpp - COMPTEL instrument direction class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-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 GCOMInstDir.cpp
23  * @brief COMPTEL 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 "GCOMInstDir.hpp"
32 #include "GTools.hpp"
33 
34 /* __ Method name definitions ____________________________________________ */
35 
36 /* __ Macros _____________________________________________________________ */
37 
38 /* __ Coding definitions _________________________________________________ */
39 
40 /* __ Debug definitions __________________________________________________ */
41 
42 /* __ Prototypes _________________________________________________________ */
43 
44 /*==========================================================================
45  = =
46  = Constructors/destructors =
47  = =
48  ==========================================================================*/
49 
50 /***********************************************************************//**
51  * @brief Void constructor
52  ***************************************************************************/
54 {
55  // Initialise class members
56  init_members();
57 
58  // Return
59  return;
60 }
61 
62 
63 /***********************************************************************//**
64  * @brief Copy constructor
65  *
66  * @param[in] dir Instrument direction.
67  ***************************************************************************/
69 {
70  // Initialise class members
71  init_members();
72 
73  // Copy members
74  copy_members(dir);
75 
76  // Return
77  return;
78 }
79 
80 
81 /***********************************************************************//**
82  * @brief Instrument direction constructor
83  *
84  * @param[in] dir Sky direction.
85  * @param[in] phibar Phibar.
86  *
87  * Constructs a COMPTEL instrument direction from a sky direction and a
88  * phibar value.
89  ***************************************************************************/
90 GCOMInstDir::GCOMInstDir(const GSkyDir& dir, const double& phibar) : GInstDir()
91 {
92  // Initialise class members
93  init_members();
94 
95  // Set class members
96  this->dir(dir);
97  this->phibar(phibar);
98 
99  // Return
100  return;
101 }
102 
103 
104 /***********************************************************************//**
105  * @brief Destructor
106  ***************************************************************************/
108 {
109  // Free members
110  free_members();
111 
112  // Return
113  return;
114 }
115 
116 
117 /*==========================================================================
118  = =
119  = Operators =
120  = =
121  ==========================================================================*/
122 
123 /***********************************************************************//**
124  * @brief Assignment operator
125  *
126  * @param[in] dir Instrument direction.
127  * @return Instrument direction.
128  ***************************************************************************/
130 {
131  // Execute only if object is not identical
132  if (this != &dir) {
133 
134  // Copy base class members
135  this->GInstDir::operator=(dir);
136 
137  // Free members
138  free_members();
139 
140  // Initialise private members
141  init_members();
142 
143  // Copy members
144  copy_members(dir);
145 
146  } // endif: object was not identical
147 
148  // Return this object
149  return *this;
150 }
151 
152 
153 /*==========================================================================
154  = =
155  = Public methods =
156  = =
157  ==========================================================================*/
158 
159 /***********************************************************************//**
160  * @brief Clear instance
161  ***************************************************************************/
163 {
164  // Free members
165  free_members();
166  this->GInstDir::free_members();
167 
168  // Initialise private members
169  this->GInstDir::init_members();
170  init_members();
171 
172  // Return
173  return;
174 }
175 
176 
177 /***********************************************************************//**
178  * @brief Clone instance
179  *
180  * @return Pointer to deep copy of instrument direction.
181  ***************************************************************************/
183 {
184  return new GCOMInstDir(*this);
185 }
186 
187 
188 /***********************************************************************//**
189  * @brief Print instrument direction information
190  *
191  * @param[in] chatter Chattiness (defaults to NORMAL).
192  * @return String containing instrument direction information.
193  ***************************************************************************/
194 std::string GCOMInstDir::print(const GChatter& chatter) const
195 {
196  // Initialise result string
197  std::string result;
198 
199  // Continue only if chatter is not silent
200  if (chatter != SILENT) {
201 
202  // Append header
203  result.append("=== GCOMInstDir ===");
204 
205  // Append information
206  result.append("\n"+gammalib::parformat("Sky direction (Chi,Psi)"));
207  result.append(m_dir.print(chatter));
208  result.append("\n"+gammalib::parformat("Scatter angle (Phibar)"));
209  result.append(gammalib::str(m_phibar));
210 
211  } // endif: chatter was not silent
212 
213  // Return result
214  return result;
215 }
216 
217 
218 /*==========================================================================
219  = =
220  = Private methods =
221  = =
222  ==========================================================================*/
223 
224 /***********************************************************************//**
225  * @brief Initialise class members
226  ***************************************************************************/
228 {
229  // Initialise members
230  m_dir.clear();
231  m_phibar = 0.0;
232 
233  // Return
234  return;
235 }
236 
237 
238 /***********************************************************************//**
239  * @brief Copy class members
240  *
241  * @param[in] dir Instrument direction.
242  ***************************************************************************/
244 {
245  // Copy members
246  m_dir = dir.m_dir;
247  m_phibar = dir.m_phibar;
248 
249  // Return
250  return;
251 }
252 
253 
254 /***********************************************************************//**
255  * @brief Delete class members
256  ***************************************************************************/
258 {
259  // Return
260  return;
261 }
void init_members(void)
Initialise class members.
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
std::string print(const GChatter &chatter=NORMAL) const
Print sky direction information.
Definition: GSkyDir.cpp:1108
Abstract instrument direction base class.
Definition: GInstDir.hpp:47
virtual std::string print(const GChatter &chatter=NORMAL) const
Print instrument direction information.
GChatter
Definition: GTypemaps.hpp:33
virtual GCOMInstDir * clone(void) const
Clone instance.
const double & phibar(void) const
Return event Compton scatter angle.
const GSkyDir & dir(void) const
Return event scatter direction.
Definition: GCOMInstDir.hpp:97
void clear(void)
Clear sky direction.
Definition: GSkyDir.cpp:142
virtual void clear(void)
Clear instance.
GSkyDir m_dir
Observed scatter direction of event.
Definition: GCOMInstDir.hpp:72
virtual ~GCOMInstDir(void)
Destructor.
double m_phibar
Observed scatter angle of event.
Definition: GCOMInstDir.hpp:73
void init_members(void)
Initialise class members.
Definition: GInstDir.cpp:141
void copy_members(const GCOMInstDir &dir)
Copy class members.
GCOMInstDir & operator=(const GCOMInstDir &dir)
Assignment operator.
COMPTEL instrument direction class definition.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1022
Sky direction class.
Definition: GSkyDir.hpp:62
GCOMInstDir(void)
Void constructor.
Definition: GCOMInstDir.cpp:53
void free_members(void)
Delete class members.
Interface for the COMPTEL instrument direction class.
Definition: GCOMInstDir.hpp:41
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:413