GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEvents.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GEvents.hpp - Abstract event container class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-2016 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 GEvents.hpp
23  * @brief Abstract event container class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GEVENTS_HPP
28 #define GEVENTS_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GEvent.hpp"
34 #include "GFits.hpp"
35 #include "GEbounds.hpp"
36 #include "GGti.hpp"
37 #include "GRoi.hpp"
38 
39 /* __ Forward declarations _______________________________________________ */
40 class GFilename;
41 
42 
43 /***********************************************************************//**
44  * @class GEvents
45  *
46  * @brief Abstract event container class
47  *
48  * This class is an abstract container base class for events. It also holds
49  * the energy boundaries and the Good Time Intervals (GTIs) that define the
50  * data space. Access to the energy boundaries is provided by the ebounds()
51  * methods, the GTI can be accessed by the gti() methods. Furthermore, the
52  * emin() and emax() methods return the lowest and highest energy covered
53  * by the event container, while the tstart() and tstop() methods return
54  * the first and the last time.
55  *
56  * Access to events (in form of atoms or bins) is provided through the
57  * element access operator[].
58  *
59  * The size() method gives the number of event atoms or bins that is found
60  * in the container. The number() method provides the total number of events
61  * in the container.
62  *
63  * An event iterator allows iterating over the event atoms or bins of the
64  * container.
65  ***************************************************************************/
66 class GEvents : public GBase {
67 
68 public:
69  // Constructors and destructors
70  GEvents(void);
71  GEvents(const GEvents& events);
72  virtual ~GEvents(void);
73 
74  // Operators
75  virtual GEvents& operator=(const GEvents& events);
76  virtual GEvent* operator[](const int& index) = 0;
77  virtual const GEvent* operator[](const int& index) const = 0;
78 
79  // Pure virtual methods
80  virtual void clear(void) = 0;
81  virtual GEvents* clone(void) const = 0;
82  virtual std::string classname(void) const = 0;
83  virtual int size(void) const = 0;
84  virtual void load(const GFilename& filename) = 0;
85  virtual void save(const GFilename& filename,
86  const bool& clobber = false) const = 0;
87  virtual void read(const GFits& file) = 0;
88  virtual void write(GFits& file) const = 0;
89  virtual int number(void) const = 0;
90  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
91 
92  // Implemented methods
93  void ebounds(const GEbounds& ebounds);
94  void gti(const GGti& gti);
95  const GEbounds& ebounds(void) const;
96  const GGti& gti(void) const;
97  const GTime& tstart(void) const;
98  const GTime& tstop(void) const;
99  const GEnergy& emin(void) const;
100  const GEnergy& emax(void) const;
101 
102 protected:
103  // Protected methods
104  void init_members(void);
105  void copy_members(const GEvents& events);
106  void free_members(void);
107  virtual void set_energies(void) = 0;
108  virtual void set_times(void) = 0;
109 
110  // Protected members
111  GEbounds m_ebounds; //!< Energy boundaries covered by events
112  GGti m_gti; //!< Good time intervals covered by events
113 };
114 
115 
116 /***********************************************************************//**
117  * @brief Return energy boundaries
118  *
119  * @return Energy boundaries.
120  ***************************************************************************/
121 inline
122 const GEbounds& GEvents::ebounds(void) const
123 {
124  return (m_ebounds);
125 }
126 
127 
128 /***********************************************************************//**
129  * @brief Return Good Time Intervals
130  *
131  * @return Good Time Intervals.
132  ***************************************************************************/
133 inline
134 const GGti& GEvents::gti(void) const
135 {
136  return (m_gti);
137 }
138 
139 
140 /***********************************************************************//**
141  * @brief Return start time
142  *
143  * @return Start time.
144  ***************************************************************************/
145 inline
146 const GTime& GEvents::tstart(void) const
147 {
148  return (m_gti.tstart());
149 }
150 
151 
152 /***********************************************************************//**
153  * @brief Return stop time
154  *
155  * @return Stop time.
156  ***************************************************************************/
157 inline
158 const GTime& GEvents::tstop(void) const
159 {
160  return (m_gti.tstop());
161 }
162 
163 
164 /***********************************************************************//**
165  * @brief Return minimum energy
166  *
167  * @return Minimum energy.
168  ***************************************************************************/
169 inline
170 const GEnergy& GEvents::emin(void) const
171 {
172  return (m_ebounds.emin());
173 }
174 
175 
176 /***********************************************************************//**
177  * @brief Return maximum energy
178  *
179  * @return Maximum energy.
180  ***************************************************************************/
181 inline
182 const GEnergy& GEvents::emax(void) const
183 {
184  return (m_ebounds.emax());
185 }
186 
187 #endif /* GEVENTS_HPP */
virtual void save(const GFilename &filename, const bool &clobber=false) const =0
const GGti & gti(void) const
Return Good Time Intervals.
Definition: GEvents.hpp:134
void init_members(void)
Initialise class members.
Definition: GEvents.cpp:176
const GTime & tstop(void) const
Return stop time.
Definition: GEvents.hpp:158
Abstract interface for the event classes.
Definition: GEvent.hpp:71
Definition of interface for all GammaLib classes.
GEbounds m_ebounds
Energy boundaries covered by events.
Definition: GEvents.hpp:111
virtual GEvents & operator=(const GEvents &events)
Assignment operator.
Definition: GEvents.cpp:104
Time class.
Definition: GTime.hpp:54
FITS file class.
Definition: GFits.hpp:63
FITS file class interface definition.
Abstract Region of interest base class definition.
Good time interval class interface definition.
virtual void load(const GFilename &filename)=0
virtual void read(const GFits &file)=0
Energy boundaries container class.
Definition: GEbounds.hpp:60
virtual void set_times(void)=0
void copy_members(const GEvents &events)
Copy class members.
Definition: GEvents.cpp:192
Filename class.
Definition: GFilename.hpp:62
void free_members(void)
Delete class members.
Definition: GEvents.cpp:206
const GEnergy & emin(void) const
Return minimum energy of all intervals.
Definition: GEbounds.hpp:181
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
virtual ~GEvents(void)
Destructor.
Definition: GEvents.cpp:82
Abstract event base class definition.
GGti m_gti
Good time intervals covered by events.
Definition: GEvents.hpp:112
virtual GEvent * operator[](const int &index)=0
GChatter
Definition: GTypemaps.hpp:33
Good Time Interval class.
Definition: GGti.hpp:62
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
Definition: GGti.hpp:206
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
Definition: GGti.hpp:193
virtual void clear(void)=0
Clear object.
virtual GEvents * clone(void) const =0
Clones object.
virtual void write(GFits &file) const =0
Abstract event container class.
Definition: GEvents.hpp:66
const GEnergy & emin(void) const
Return minimum energy.
Definition: GEvents.hpp:170
GEvents(void)
Void constructor.
Definition: GEvents.cpp:51
Energy boundaries class interface definition.
virtual std::string classname(void) const =0
Return class name.
const GEbounds & ebounds(void) const
Return energy boundaries.
Definition: GEvents.hpp:122
const GEnergy & emax(void) const
Return maximum energy of all intervals.
Definition: GEbounds.hpp:193
virtual void set_energies(void)=0
virtual int number(void) const =0
const GTime & tstart(void) const
Return start time.
Definition: GEvents.hpp:146
const GEnergy & emax(void) const
Return maximum energy.
Definition: GEvents.hpp:182
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual int size(void) const =0