GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAEventList.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAEventList.hpp - CTA event list class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2018 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 GCTAEventList.hpp
23 * @brief CTA event list class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTAEVENTLIST_HPP
28#define GCTAEVENTLIST_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GEventList.hpp"
34#include "GPhases.hpp"
35#include "GFilename.hpp"
36#include "GCTAEventAtom.hpp"
37#include "GCTARoi.hpp"
38#include "GCTAPointing.hpp"
39
40/* __ Forward declarations _______________________________________________ */
41class GFilename;
42class GFitsHDU;
43class GFitsTable;
44class GFitsBinTable;
45class GFitsTableCol;
46
47/* __ Constants __________________________________________________________ */
48namespace gammalib {
49 const std::string extname_cta_events = "EVENTS";
50}
51
52
53/***********************************************************************//**
54 * @class GCTAEventList
55 *
56 * @brief CTA event list class
57 *
58 * This class implements an event list for CTA.
59 ***************************************************************************/
60class GCTAEventList : public GEventList {
61
62public:
63 // Constructors and destructors
64 GCTAEventList(void);
65 explicit GCTAEventList(const GFilename& filename);
66 GCTAEventList(const GCTAEventList& list);
67 virtual ~GCTAEventList(void);
68
69 // Operators
70 virtual GCTAEventList& operator=(const GCTAEventList& list);
71 virtual GCTAEventAtom* operator[](const int& index);
72 virtual const GCTAEventAtom* operator[](const int& index) const;
73
74 // Implemented pure virtual base class methods
75 virtual void clear(void);
76 virtual GCTAEventList* clone(void) const;
77 virtual std::string classname(void) const;
78 virtual int size(void) const;
79 virtual void load(const GFilename& filename);
80 virtual void save(const GFilename& filename,
81 const bool& clobber = false) const;
82 virtual void read(const GFits& fits);
83 virtual void write(GFits& fits) const;
84 virtual int number(void) const;
85 virtual void roi(const GRoi& roi);
86 virtual const GCTARoi& roi(void) const;
87 std::string print(const GChatter& chatter = NORMAL) const;
88
89 // Implement other methods
90 void append(const GCTAEventAtom& event);
91 void append_column(const GFitsTableCol& column);
92 void reserve(const int& number);
93 void remove(const int& index, const int& number = 1);
94 void write(GFits& fits, const std::string& evtname,
95 const std::string& gtiname) const;
96 void fetch(void) const;
97 void dispose(void) const;
98 const GPhases& phases(void) const;
99 void phases(const GPhases& phases);
100 const std::string& gtiname(void) const;
101 void has_phase(const bool& has_phase);
102 void has_detxy(const bool& has_detxy);
103 void has_mc_id(const bool& has_mc_id);
104 const bool& has_phase() const;
105 const bool& has_detxy() const;
106 const bool& has_mc_id() const;
107 void set_mc_id_names(const std::vector<int>& ids,
108 const std::vector<std::string>& names);
109
110protected:
111 // Protected methods
112 void init_members(void);
113 void copy_members(const GCTAEventList& list);
114 void free_members(void);
115 virtual void set_energies(void) { return; }
116 virtual void set_times(void) { return; }
117 void read_events(const GFitsTable& table) const;
118 void read_mc_ids(const GFitsTable& table);
119 void write_events(GFitsBinTable& table) const;
120 void write_ds_keys(GFitsHDU& hdu,
121 const std::string& gtiname = gammalib::extname_gti) const;
122 void write_mc_ids(GFitsHDU& hdu) const;
123
124 // Event list meta data
125 GCTARoi m_roi; //!< Region of interest
126 GCTAPointing m_pnt; //!< Pointing direction for DETX/Y conversion
127 GPhases m_phases; //!< Phase intervals
128 int m_num_events; //!< Number of events
129 std::string m_gti_extname; //!< GTI extension name
130 bool m_has_phase; //!< Signal presence of phase
131 bool m_has_detxy; //!< Signal presence of detector coordinates
132 bool m_has_mc_id; //!< Signal presence of MC identifier
133 std::vector<int> m_mc_ids; //!< List of Monte Carlo IDs
134 std::vector<std::string> m_mc_id_names; //!< List of model names
135
136 // Event list data
137 mutable std::vector<GCTAEventAtom> m_events; //!< Events
138 mutable std::vector<GFitsTableCol*> m_columns; //!< Pointers to optional columns
139 mutable GFilename m_filename; //!< Event list file name
140};
141
142
143/***********************************************************************//**
144 * @brief Return class name
145 *
146 * @return String containing the class name ("GCTAEventList").
147 ***************************************************************************/
148inline
149std::string GCTAEventList::classname(void) const
150{
151 return ("GCTAEventList");
152}
153
154
155/***********************************************************************//**
156 * @brief Return number of events in list
157 *
158 * @return Number of events in list.
159 ***************************************************************************/
160inline
161int GCTAEventList::size(void) const
162{
163 return (m_num_events);
164}
165
166
167/***********************************************************************//**
168 * @brief Return number of events in list
169 *
170 * @return Number of events in list.
171 ***************************************************************************/
172inline
174{
175 return (m_num_events);
176}
177
178
179/***********************************************************************//**
180 * @brief Return Region of Interest
181 *
182 * @return Region of Interest.
183 ***************************************************************************/
184inline
185const GCTARoi& GCTAEventList::roi(void) const
186{
187 return (m_roi);
188}
189
190
191/***********************************************************************//**
192 * @brief Return phase intervals
193 *
194 * @return Phase intervals.
195 ***************************************************************************/
196inline
198{
199 return (m_phases);
200}
201
202
203/***********************************************************************//**
204 * @brief Set phase intervals
205 *
206 * @param[in] phases Phase intervals.
207 ***************************************************************************/
208inline
210{
212 return;
213}
214
215
216/***********************************************************************//**
217 * @brief Reserves space for events
218 *
219 * @param[in] number Number of events.
220 *
221 * Reserves space for number events in the event list.
222 ***************************************************************************/
223inline
224void GCTAEventList::reserve(const int& number)
225{
226 m_events.reserve(number);
227 return;
228}
229
230
231/***********************************************************************//**
232 * @brief Return Good Time Interval extension name
233 *
234 * @return Good Time Interval extension name.
235 ***************************************************************************/
236inline
237const std::string& GCTAEventList::gtiname(void) const
238{
239 return (m_gti_extname);
240}
241
242
243/***********************************************************************//**
244 * @brief Set phase information flag
245 *
246 * @param[in] has_phase Phase information flag.
247 *
248 * Sets the phase information flag of the event list.
249 ***************************************************************************/
250inline
251void GCTAEventList::has_phase(const bool& has_phase)
252{
254 return;
255}
256
257
258/***********************************************************************//**
259 * @brief Set the DETX/DETY information flag
260 *
261 * @param[in] has_detxy DETX/DETY information flag.
262 *
263 * Set the DETX/DETY information flag.
264 ***************************************************************************/
265inline
266void GCTAEventList::has_detxy(const bool& has_detxy)
267{
269 return;
270}
271
272
273/***********************************************************************//**
274 * @brief Set the Monte Carlo identifier flag
275 *
276 * @param[in] has_mc_id Monte Carlo identifier flag.
277 *
278 * Set the Monte Carlo identifier flag.
279 ***************************************************************************/
280inline
281void GCTAEventList::has_mc_id(const bool& has_mc_id)
282{
284 return;
285}
286
287
288/*************************************************************************
289 * @brief Return phase information flag
290 *
291 * @return True if phase information is available, false otherwise.
292 ***************************************************************************/
293inline
294const bool& GCTAEventList::has_phase() const
295{
296 return m_has_phase;
297}
298
299
300/*************************************************************************
301 * @brief Return DETX/DETY information flag
302 *
303 * @return True if DETX/DETY information is available, false otherwise.
304 ***************************************************************************/
305inline
306const bool& GCTAEventList::has_detxy() const
307{
308 return m_has_detxy;
309}
310
311
312/*************************************************************************
313 * @brief Return Monte Carlo identifier flag
314 *
315 * @return True if a Monte Carlo identifier is available, false otherwise.
316 ***************************************************************************/
317inline
318const bool& GCTAEventList::has_mc_id() const
319{
320 return m_has_mc_id;
321}
322
323#endif /* GCTAEVENTLIST_HPP */
CTA event atom class definition.
CTA pointing class interface definition.
CTA region of interest class interface definition.
Abstract event atom container class interface definition.
Filename class interface definition.
Phase intervals class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
CTA event atom class.
CTA event list class.
virtual void clear(void)
Clear event list.
virtual ~GCTAEventList(void)
Destructor.
void append_column(const GFitsTableCol &column)
Append FITS table column to event list.
GCTAPointing m_pnt
Pointing direction for DETX/Y conversion.
const bool & has_mc_id() const
void write_ds_keys(GFitsHDU &hdu, const std::string &gtiname=gammalib::extname_gti) const
Write data sub-space keywords into FITS HDU.
virtual GCTAEventAtom * operator[](const int &index)
Event atom access operator.
void copy_members(const GCTAEventList &list)
Copy class members.
void dispose(void) const
Dispose events.
virtual void read(const GFits &fits)
Read events from FITS file.
virtual void set_energies(void)
virtual const GCTARoi & roi(void) const
Return Region of Interest.
virtual GCTAEventList * clone(void) const
Clone event list.
void init_members(void)
Initialise class members.
const std::string & gtiname(void) const
Return Good Time Interval extension name.
std::vector< std::string > m_mc_id_names
List of model names.
GFilename m_filename
Event list file name.
int m_num_events
Number of events.
bool m_has_phase
Signal presence of phase.
virtual int number(void) const
Return number of events in list.
bool m_has_mc_id
Signal presence of MC identifier.
virtual void set_times(void)
virtual int size(void) const
Return number of events in list.
GCTARoi m_roi
Region of interest.
void fetch(void) const
Fetch events.
GPhases m_phases
Phase intervals.
GCTAEventList(void)
Void constructor.
void read_events(const GFitsTable &table) const
Read CTA events from FITS table.
const GPhases & phases(void) const
Return phase intervals.
virtual GCTAEventList & operator=(const GCTAEventList &list)
Assignment operator.
bool m_has_detxy
Signal presence of detector coordinates.
virtual void write(GFits &fits) const
Write CTA events and Good Time Intervals into FITS file.
void read_mc_ids(const GFitsTable &table)
Read Monte Carlo identifier keywords from FITS HDU.
const bool & has_phase() const
void remove(const int &index, const int &number=1)
Remove events from event list.
void write_mc_ids(GFitsHDU &hdu) const
Write Monte Carlo identifier keywords into FITS HDU.
void write_events(GFitsBinTable &table) const
Write CTA events into FITS table.
void set_mc_id_names(const std::vector< int > &ids, const std::vector< std::string > &names)
Set Monte Carlo identifiers and model names.
std::vector< GFitsTableCol * > m_columns
Pointers to optional columns.
void free_members(void)
Delete class members.
std::string m_gti_extname
GTI extension name.
virtual void load(const GFilename &filename)
Load events from FITS file.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save events into FITS file.
std::string print(const GChatter &chatter=NORMAL) const
Print event list information.
void reserve(const int &number)
Reserves space for events.
std::vector< GCTAEventAtom > m_events
Events.
void append(const GCTAEventAtom &event)
Append event to event list.
std::vector< int > m_mc_ids
List of Monte Carlo IDs.
virtual std::string classname(void) const
Return class name.
const bool & has_detxy() const
CTA pointing class.
Interface for the CTA region of interest class.
Definition GCTARoi.hpp:49
Abstract event atom container class.
Filename class.
Definition GFilename.hpp:62
FITS binary table class.
Abstract FITS extension base class.
Definition GFitsHDU.hpp:51
Abstract interface for FITS table column.
Abstract interface for FITS table.
FITS file class.
Definition GFits.hpp:63
Phase Intervals class.
Definition GPhases.hpp:42
Interface for the region of interest classes.
Definition GRoi.hpp:48
const std::string extname_gti
Definition GGti.hpp:44
const std::string extname_cta_events