GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMEventList.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMEventList.hpp - COMPTEL event list class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-2021 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 GCOMEventList.hpp
23  * @brief COMPTEL event list class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCOMEVENTLIST_HPP
28 #define GCOMEVENTLIST_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GEventList.hpp"
34 #include "GCOMEventAtom.hpp"
35 #include "GCOMRoi.hpp"
36 
37 /* __ Forward declarations _______________________________________________ */
38 class GRoi;
39 class GFits;
40 class GFilename;
41 class GFitsTable;
42 
43 /* __ Constants __________________________________________________________ */
44 
45 
46 /***********************************************************************//**
47  * @class GCOMEventList
48  *
49  * @brief COMPTEL event list class
50  ***************************************************************************/
51 class GCOMEventList : public GEventList {
52 
53 public:
54  // Constructors and destructors
55  GCOMEventList(void);
56  explicit GCOMEventList(const GFilename& filename);
57  GCOMEventList(const GCOMEventList& list);
58  virtual ~GCOMEventList(void);
59 
60  // Operators
61  virtual GCOMEventList& operator=(const GCOMEventList& list);
62  virtual GCOMEventAtom* operator[](const int& index);
63  virtual const GCOMEventAtom* operator[](const int& index) const;
64 
65  // Implemented pure virtual base class methods
66  virtual void clear(void);
67  virtual GCOMEventList* clone(void) const;
68  virtual std::string classname(void) const;
69  virtual int size(void) const;
70  virtual void load(const GFilename& filename);
71  virtual void save(const GFilename& filename,
72  const bool& clobber = false) const;
73  virtual void read(const GFits& file);
74  virtual void write(GFits& file) const;
75  virtual int number(void) const;
76  virtual void roi(const GRoi& roi);
77  virtual const GCOMRoi& roi(void) const;
78  virtual std::string print(const GChatter& chatter = NORMAL) const;
79 
80  // Other methods
81  void append(const GCOMEventAtom& event);
82  void reserve(const int& number);
83  void remove(const int& index, const int& number = 1);
84 
85 protected:
86  // Protected methods
87  void init_members(void);
88  void copy_members(const GCOMEventList& list);
89  void free_members(void);
90  virtual void set_energies(void);
91  virtual void set_times(void);
92  void read_events(const GFitsTable& table);
93  double tofcor(const double& d1e, const double& d2e, double tof) const;
94 
95  // Protected members
96  GCOMRoi m_roi; //!< Region of interest
97  std::vector<GCOMEventAtom> m_events; //!< Events
98 };
99 
100 
101 /***********************************************************************//**
102  * @brief Return class name
103  *
104  * @return String containing the class name ("GCOMEventList").
105  ***************************************************************************/
106 inline
107 std::string GCOMEventList::classname(void) const
108 {
109  return ("GCOMEventList");
110 }
111 
112 
113 /***********************************************************************//**
114  * @brief Return number of events in list
115  *
116  * @return Number of events in list.
117  ***************************************************************************/
118 inline
119 int GCOMEventList::size(void) const
120 {
121  return (int)m_events.size();
122 }
123 
124 
125 /***********************************************************************//**
126  * @brief Return number of events in list
127  *
128  * @return Number of events in list.
129  ***************************************************************************/
130 inline
131 int GCOMEventList::number(void) const
132 {
133  return (int)m_events.size();
134 }
135 
136 
137 /***********************************************************************//**
138  * @brief Return Region of Interest
139  *
140  * @return Region of Interest.
141  ***************************************************************************/
142 inline
143 const GCOMRoi& GCOMEventList::roi(void) const
144 {
145  return m_roi;
146 }
147 
148 
149 /***********************************************************************//**
150  * @brief Reserves space for events
151  *
152  * @param[in] number Number of events.
153  *
154  * Reserves space for a @p number events in the event list.
155  ***************************************************************************/
156 inline
158 {
159  m_events.reserve(number);
160  return;
161 }
162 
163 
164 /***********************************************************************//**
165  * @brief Set energies
166  *
167  * Sets energies.
168  ***************************************************************************/
169 inline
171 {
172  return;
173 }
174 
175 
176 /***********************************************************************//**
177  * @brief Set times
178  *
179  * Sets times.
180  ***************************************************************************/
181 inline
183 {
184  return;
185 }
186 
187 #endif /* GLATEVENTLIST_HPP */
void free_members(void)
Delete class members.
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
Definition: GTools.cpp:1167
virtual void set_times(void)
Set times.
virtual const GCOMRoi & roi(void) const
Return Region of Interest.
Abstract event atom container class.
Definition: GEventList.hpp:49
COMPTEL event atom class definition.
virtual void set_energies(void)
Set energies.
void read_events(const GFitsTable &table)
Read COMPTEL events from FITS table.
FITS file class.
Definition: GFits.hpp:63
COMPTEL region of interest class definition.
virtual GCOMEventList & operator=(const GCOMEventList &list)
Assignment operator.
Abstract event atom container class interface definition.
GCOMRoi m_roi
Region of interest.
virtual GCOMEventList * clone(void) const
Clone event list.
virtual void load(const GFilename &filename)
Load COMPTEL events from FITS file.
virtual int size(void) const
Return number of events in list.
virtual std::string classname(void) const
Return class name.
void reserve(const int &number)
Reserves space for events.
Filename class.
Definition: GFilename.hpp:62
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save COMPTEL events.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
void append(const GCOMEventAtom &event)
Append event to event list.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL event list information.
void copy_members(const GCOMEventList &list)
Copy class members.
COMPTEL region of interest class.
Definition: GCOMRoi.hpp:44
virtual void write(GFits &file) const
Write COMPTEL event list into FITS file.
virtual GCOMEventAtom * operator[](const int &index)
COMPTEL event atom access operator.
virtual void clear(void)
Clear COMPTEL event list.
std::vector< GCOMEventAtom > m_events
Events.
GCOMEventList(void)
Void constructor.
virtual int number(void) const
Return number of events in list.
COMPTEL event list class.
virtual void read(const GFits &file)
Read COMPTEL events from FITS file.
Interface for the region of interest classes.
Definition: GRoi.hpp:48
double tofcor(const double &d1e, const double &d2e, double tof) const
Compute TOF correction.
void init_members(void)
Initialise class members.
virtual ~GCOMEventList(void)
Destructor.
COMPTEL event atom class.