GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEventBin.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GEventBin.cpp - Abstract event bin base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-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 GEventBin.cpp
23  * @brief Abstract event bin base class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include <cmath>
32 #include "GEventBin.hpp"
33 
34 /* __ Method name definitions ____________________________________________ */
35 
36 /* __ Macros _____________________________________________________________ */
37 
38 /* __ Coding definitions _________________________________________________ */
39 
40 /* __ Debug definitions __________________________________________________ */
41 
42 
43 /*==========================================================================
44  = =
45  = Constructors/destructors =
46  = =
47  ==========================================================================*/
48 
49 /***********************************************************************//**
50  * @brief Void constructor
51  ***************************************************************************/
53 {
54  // Initialise class members for clean destruction
55  init_members();
56 
57  // Return
58  return;
59 }
60 
61 
62 /***********************************************************************//**
63  * @brief Copy constructor
64  *
65  * @param[in] bin Event bin.
66  ***************************************************************************/
68 {
69  // Initialise class members for clean destruction
70  init_members();
71 
72  // Copy members
73  copy_members(bin);
74 
75  // Return
76  return;
77 }
78 
79 
80 /***********************************************************************//**
81  * @brief Destructor
82  ***************************************************************************/
84 {
85  // Free members
86  free_members();
87 
88  // Return
89  return;
90 }
91 
92 
93 /*==========================================================================
94  = =
95  = Operators =
96  = =
97  ==========================================================================*/
98 
99 /***********************************************************************//**
100  * @brief Assignment operator
101  *
102  * @param[in] bin Event bin.
103  * @return Event bin.
104  ***************************************************************************/
106 {
107  // Execute only if object is not identical
108  if (this != &bin) {
109 
110  // Copy base class members
111  this->GEvent::operator=(bin);
112 
113  // Free members
114  free_members();
115 
116  // Initialise private members for clean destruction
117  init_members();
118 
119  // Copy members
120  copy_members(bin);
121 
122  } // endif: object was not identical
123 
124  // Return this object
125  return *this;
126 }
127 
128 
129 /*==========================================================================
130  = =
131  = Public methods =
132  = =
133  ==========================================================================*/
134 
135 /***********************************************************************//**
136  * @brief Return error in number of counts
137  *
138  * Returns \f$\sqrt(counts)\f$ as the uncertainty in the number of counts
139  * in the bin. If counts <= 0 then zero is returned.
140  ***************************************************************************/
141 double GEventBin::error(void) const
142 {
143  // Compute uncertainty
144  double error = sqrt(counts());
145 
146  // Return error
147  return error;
148 }
149 
150 
151 /*==========================================================================
152  = =
153  = Private methods =
154  = =
155  ==========================================================================*/
156 
157 /***********************************************************************//**
158  * @brief Initialise class members
159  ***************************************************************************/
161 {
162  // Return
163  return;
164 }
165 
166 
167 /***********************************************************************//**
168  * @brief Copy class members
169  *
170  * @param[in] bin Event bin.
171  ***************************************************************************/
173 {
174  // Return
175  return;
176 }
177 
178 
179 /***********************************************************************//**
180  * @brief Delete class members
181  ***************************************************************************/
183 {
184  // Return
185  return;
186 }
virtual double error(void) const =0
Return error in number of counts.
Definition: GEventBin.cpp:141
Abstract interface for the event bin class.
Definition: GEventBin.hpp:64
Abstract event bin base class definition.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
virtual double counts(void) const =0
virtual ~GEventBin(void)
Destructor.
Definition: GEventBin.cpp:83
virtual GEvent & operator=(const GEvent &event)
Assignment operator.
Definition: GEvent.cpp:105
GEventBin(void)
Void constructor.
Definition: GEventBin.cpp:52
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
Definition: GVector.cpp:1268
void free_members(void)
Delete class members.
Definition: GEventBin.cpp:182
virtual GEventBin & operator=(const GEventBin &bin)
Assignment operator.
Definition: GEventBin.cpp:105
void init_members(void)
Initialise class members.
Definition: GEventBin.cpp:160
void copy_members(const GEventBin &bin)
Copy class members.
Definition: GEventBin.cpp:172