GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
41 class GFilename;
42 class GFitsHDU;
43 class GFitsTable;
44 class GFitsBinTable;
45 class GFitsTableCol;
46 
47 /* __ Constants __________________________________________________________ */
48 namespace 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  ***************************************************************************/
60 class GCTAEventList : public GEventList {
61 
62 public:
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 
110 protected:
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  ***************************************************************************/
148 inline
149 std::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  ***************************************************************************/
160 inline
161 int 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  ***************************************************************************/
172 inline
173 int GCTAEventList::number(void) const
174 {
175  return (m_num_events);
176 }
177 
178 
179 /***********************************************************************//**
180  * @brief Return Region of Interest
181  *
182  * @return Region of Interest.
183  ***************************************************************************/
184 inline
185 const 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  ***************************************************************************/
196 inline
197 const GPhases& GCTAEventList::phases(void) const
198 {
199  return (m_phases);
200 }
201 
202 
203 /***********************************************************************//**
204  * @brief Set phase intervals
205  *
206  * @param[in] phases Phase intervals.
207  ***************************************************************************/
208 inline
209 void GCTAEventList::phases(const GPhases& phases)
210 {
211  m_phases = phases;
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  ***************************************************************************/
223 inline
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  ***************************************************************************/
236 inline
237 const 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  ***************************************************************************/
250 inline
251 void 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  ***************************************************************************/
265 inline
266 void 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  ***************************************************************************/
280 inline
281 void 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  ***************************************************************************/
293 inline
294 const 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  ***************************************************************************/
305 inline
306 const 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  ***************************************************************************/
317 inline
318 const bool& GCTAEventList::has_mc_id() const
319 {
320  return m_has_mc_id;
321 }
322 
323 #endif /* GCTAEVENTLIST_HPP */
bool m_has_mc_id
Signal presence of MC identifier.
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
Definition: GTools.cpp:1167
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save events into FITS file.
void append_column(const GFitsTableCol &column)
Append FITS table column to event list.
GFilename m_filename
Event list file name.
CTA event atom class definition.
void write_events(GFitsBinTable &table) const
Write CTA events into FITS table.
virtual void write(GFits &fits) const
Write CTA events and Good Time Intervals into FITS file.
void set_mc_id_names(const std::vector< int > &ids, const std::vector< std::string > &names)
Set Monte Carlo identifiers and model names.
bool m_has_phase
Signal presence of phase.
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
Abstract event atom container class.
Definition: GEventList.hpp:49
void write_ds_keys(GFitsHDU &hdu, const std::string &gtiname=gammalib::extname_gti) const
Write data sub-space keywords into FITS HDU.
virtual ~GCTAEventList(void)
Destructor.
void append(const GCTAEventAtom &event)
Append event to event list.
const std::string & gtiname(void) const
Return Good Time Interval extension name.
std::string m_gti_extname
GTI extension name.
CTA event list class.
CTA pointing class interface definition.
virtual void clear(void)
Clear event list.
std::vector< std::string > m_mc_id_names
List of model names.
const bool & has_phase() const
void fetch(void) const
Fetch events.
Interface for the CTA region of interest class.
Definition: GCTARoi.hpp:49
void write_mc_ids(GFitsHDU &hdu) const
Write Monte Carlo identifier keywords into FITS HDU.
void copy_members(const GCTAEventList &list)
Copy class members.
FITS file class.
Definition: GFits.hpp:63
const std::string extname_gti
Definition: GGti.hpp:44
GCTARoi m_roi
Region of interest.
Abstract event atom container class interface definition.
std::vector< GCTAEventAtom > m_events
Events.
virtual GCTAEventList * clone(void) const
Clone event list.
Phase intervals class interface definition.
virtual std::string classname(void) const
Return class name.
std::string print(const GChatter &chatter=NORMAL) const
Print event list information.
void reserve(const int &number)
Reserves space for events.
Filename class.
Definition: GFilename.hpp:62
Abstract interface for FITS table column.
const std::string extname_cta_events
CTA pointing class.
void dispose(void) const
Dispose events.
virtual void load(const GFilename &filename)
Load events from FITS file.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
int m_num_events
Number of events.
GChatter
Definition: GTypemaps.hpp:33
virtual void set_times(void)
std::vector< GFitsTableCol * > m_columns
Pointers to optional columns.
virtual GCTAEventAtom * operator[](const int &index)
Event atom access operator.
const bool & has_detxy() const
CTA region of interest class interface definition.
GCTAPointing m_pnt
Pointing direction for DETX/Y conversion.
void read_mc_ids(const GFitsTable &table)
Read Monte Carlo identifier keywords from FITS HDU.
void init_members(void)
Initialise class members.
const GPhases & phases(void) const
Return phase intervals.
FITS binary table class.
CTA event atom class.
virtual void set_energies(void)
std::vector< int > m_mc_ids
List of Monte Carlo IDs.
virtual int size(void) const
Return number of events in list.
GCTAEventList(void)
Void constructor.
void free_members(void)
Delete class members.
Phase Intervals class.
Definition: GPhases.hpp:42
Interface for the region of interest classes.
Definition: GRoi.hpp:48
virtual int number(void) const
Return number of events in list.
const bool & has_mc_id() const
virtual const GCTARoi & roi(void) const
Return Region of Interest.
void read_events(const GFitsTable &table) const
Read CTA events from FITS table.
bool m_has_detxy
Signal presence of detector coordinates.
virtual void read(const GFits &fits)
Read events from FITS file.
Filename class interface definition.
GPhases m_phases
Phase intervals.
virtual GCTAEventList & operator=(const GCTAEventList &list)
Assignment operator.