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