GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEventAtom.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GEventAtom.hpp - Abstract event atom base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-2014 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 GEventAtom.hpp
23  * @brief Abstract event atom base class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GEVENTATOM_HPP
28 #define GEVENTATOM_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GEvent.hpp"
33 #include "GInstDir.hpp"
34 #include "GEnergy.hpp"
35 #include "GTime.hpp"
36 
37 
38 /***********************************************************************//**
39  * @class GEventAtom
40  *
41  * @brief Abstract interface for the event atom class.
42  *
43  * An event atom is a single event occurring in an instrument. Event atoms
44  * are used for unbinned analysis.
45  *
46  * Each event has 3 attributes: energy, instrument direction and time.
47  * These attributes can be accessed and changed through the energy(),
48  * dir(), and time() methods.
49  *
50  * The counts() and error() methods return the number of counts and the
51  * error in this number for each event. For event atoms the number of
52  * counts is 1 and the error is 0.
53  *
54  * The size() method returns the size of an event bin ,which is the
55  * quantity that has to be multiplied by the probability for an event to
56  * occur to predict the number of events in a bin. For event atoms this
57  * quantity is by definition 1.
58  *
59  * The GEventAtom class does not hold any data members. Data members are
60  * stored in the derived classes.
61  ***************************************************************************/
62 class GEventAtom : public GEvent {
63 
64  // Friend classes
65  friend class GEvents;
66 
67 public:
68  // Constructors and destructors
69  GEventAtom(void);
70  GEventAtom(const GEventAtom& atom);
71  virtual ~GEventAtom(void);
72 
73  // Operators
74  virtual GEventAtom& operator=(const GEventAtom& atom);
75 
76  // Pure virtual methods
77  virtual void clear(void) = 0;
78  virtual GEvent* clone(void) const = 0;
79  virtual std::string classname(void) const = 0;
80  virtual double size(void) const;
81  virtual const GInstDir& dir(void) const = 0;
82  virtual const GEnergy& energy(void) const = 0;
83  virtual const GTime& time(void) const = 0;
84  virtual double counts(void) const;
85  virtual double error(void) const;
86  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
87 
88  // Other methods
89  bool is_atom(void) const;
90  bool is_bin(void) const;
91 
92 protected:
93  // Protected methods
94  void init_members(void);
95  void copy_members(const GEventAtom& atom);
96  void free_members(void);
97 };
98 
99 
100 /***********************************************************************//**
101  * @brief Return size of an event atom
102  *
103  * @return Event size, fixed to 1.0 for an event atom.
104  *
105  * Returns the size of an event atom. The size is only useful for event bins,
106  * for which it is defined as the quantity that needs to be multiplied by the
107  * event probability to give the predicted number of events in a bin. For
108  * event atoms, the size is fixed to 1.0.
109  ***************************************************************************/
110 inline
111 double GEventAtom::size(void) const
112 {
113  return (1.0);
114 }
115 
116 
117 /***********************************************************************//**
118  * @brief Return number of counts in event atom
119  *
120  * @return Number of counts, fixed to 1.0 for an event atom.
121  ***************************************************************************/
122 inline
123 double GEventAtom::counts(void) const
124 {
125  return (1.0);
126 }
127 
128 
129 /***********************************************************************//**
130  * @brief Return error in number of counts in event atom
131  *
132  * @return Error in number of counts, fixed to 0.0 for an event atom.
133  ***************************************************************************/
134 inline
135 double GEventAtom::error(void) const
136 {
137  return (0.0);
138 }
139 
140 
141 /***********************************************************************//**
142  * @brief Signal if event is an atom
143  *
144  * @return True.
145  ***************************************************************************/
146 inline
147 bool GEventAtom::is_atom(void) const
148 {
149  return (true);
150 }
151 
152 
153 /***********************************************************************//**
154  * @brief Signal if event is a bin
155  *
156  * @return False.
157  ***************************************************************************/
158 inline
159 bool GEventAtom::is_bin(void) const
160 {
161  return (false);
162 }
163 
164 #endif /* GEVENTATOM_HPP */
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual const GEnergy & energy(void) const =0
Abstract instrument direction base class definition.
virtual double size(void) const
Return size of an event atom.
Definition: GEventAtom.hpp:111
Energy value class definition.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
virtual double error(void) const
Return error in number of counts in event atom.
Definition: GEventAtom.hpp:135
Time class.
Definition: GTime.hpp:55
void init_members(void)
Initialise class members.
Definition: GEventAtom.cpp:143
Abstract instrument direction base class.
Definition: GInstDir.hpp:51
virtual void clear(void)=0
Clear object.
virtual GEventAtom & operator=(const GEventAtom &atom)
Assignment operator.
Definition: GEventAtom.cpp:104
bool is_atom(void) const
Signal if event is an atom.
Definition: GEventAtom.hpp:147
Abstract event base class definition.
GChatter
Definition: GTypemaps.hpp:33
void copy_members(const GEventAtom &atom)
Copy class members.
Definition: GEventAtom.cpp:155
virtual const GTime & time(void) const =0
GEventAtom(void)
Void constructor.
Definition: GEventAtom.cpp:51
Abstract event container class.
Definition: GEvents.hpp:66
void free_members(void)
Delete class members.
Definition: GEventAtom.cpp:165
virtual GEvent * clone(void) const =0
Clones object.
virtual ~GEventAtom(void)
Destructor.
Definition: GEventAtom.cpp:82
bool is_bin(void) const
Signal if event is a bin.
Definition: GEventAtom.hpp:159
Time class interface definition.
virtual double counts(void) const
Return number of counts in event atom.
Definition: GEventAtom.hpp:123
virtual const GInstDir & dir(void) const =0
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
Abstract interface for the event atom class.
Definition: GEventAtom.hpp:62
virtual std::string classname(void) const =0
Return class name.