ctools  2.0.0
 All Classes Namespaces Files Functions Variables Macros Pages
ctobservation.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * ctobservation - Base class for observation tools *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2016-2022 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 ctobservation.hpp
23  * @brief Observation tool base class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef CTOBSERVATION_HPP
28 #define CTOBSERVATION_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include "ctool.hpp"
32 
33 /* __Definitions _________________________________________________________ */
34 
35 
36 /***********************************************************************//**
37  * @class ctobservation
38  *
39  * @brief Base class for observation tools
40  *
41  * This is the baseclass for observation tools. Observation tools are ctools
42  * that hold an observation container.
43  ***************************************************************************/
44 class ctobservation : public ctool {
45 
46 public:
47  // Constructors and destructors
48  ctobservation(const std::string& name,
49  const std::string& version);
50  ctobservation(const std::string& name,
51  const std::string& version,
52  const GApplicationPars& pars);
53  ctobservation(const std::string& name,
54  const std::string& version,
55  int argc,
56  char* argv[]);
57  ctobservation(const std::string& name,
58  const std::string& version,
59  const GObservations& obs);
61  virtual ~ctobservation(void);
62 
63  // Operators
65 
66  // Pure virtual methods
67  virtual void clear(void) = 0;
68  virtual void process(void) = 0;
69  virtual void save(void) = 0;
70 
71  // Methods
72  void obs(const GObservations& obs);
73  const GObservations& obs(void) const;
74 
75 #ifndef SWIG
76 protected:
77 #endif
78  // Protected methods
79  GCTAObservation* first_unbinned_observation(void);
80  GCTAObservation* next_unbinned_observation(void);
81  const GCTAObservation* first_unbinned_observation(void) const;
82  const GCTAObservation* next_unbinned_observation(void) const;
83  void read_ogip_keywords(GFitsHDU* hdu) const;
84  void write_ogip_keywords(GFitsHDU* hdu) const;
85  void set_obs_statistic(const std::string& statistic);
86  void set_obs_bounds();
87  void save_events_fits(void);
88  void save_events_xml(void);
89 
90 protected:
91  // Protected methods
92  void init_members(void);
93  void copy_members(const ctobservation& app);
94  void free_members(void);
95 
96  // Protected members
97  GObservations m_obs; //!< Observation container
98 
99 private:
100  // Private members
101  mutable std::string m_ogip_telescope; //!< Name of telescope
102  mutable GTime m_ogip_tstart; //!< Start time for OGIP keywords
103  mutable GTime m_ogip_tstop; //!< Stop time for OGIP keywords
104  mutable double m_ogip_telapse; //!< Elapsed time
105  mutable double m_ogip_exposure; //!< Exposure time
106  mutable double m_ogip_ontime; //!< Ontime for OGIP keywords
107  mutable double m_ogip_livetime; //!< Livetime for OGIP keywords
108  mutable int m_index_unbinned; //!< Current index of unbinned observation
109 };
110 
111 
112 /***********************************************************************//**
113  * @brief Set observation container
114  *
115  * @param[in] obs Observation container.
116  *
117  * Set observation container.
118  ***************************************************************************/
119 inline
120 void ctobservation::obs(const GObservations& obs)
121 {
122  m_obs = obs;
123  return;
124 }
125 
126 
127 /***********************************************************************//**
128  * @brief Return observation container
129  *
130  * @return Reference to observation container.
131  *
132  * Returns a reference to the observation container.
133  ***************************************************************************/
134 inline
135 const GObservations& ctobservation::obs(void) const
136 {
137  return m_obs;
138 }
139 
140 
141 /***********************************************************************//**
142  * @brief Return first unbinned CTA observation
143  *
144  * @return Pointer to first unbinned CTA observation
145  *
146  * Returns a pointer to the first unbinned CTA observation in the container.
147  * If no CTA observation exists a NULL pointer is returned.
148  *
149  * The method calls next_unbinned_observation(). See the method for details.
150  ***************************************************************************/
151 inline
153 {
154  return (const_cast<GCTAObservation*>
155  (static_cast<const ctobservation&>
156  (*this).first_unbinned_observation()));
157 }
158 
159 
160 /***********************************************************************//**
161  * @brief Return next unbinned CTA observation
162  *
163  * @return Pointer to next unbinned CTA observation
164  *
165  * Returns a pointer to the next unbinned CTA observation in the container.
166  * If no CTA observation exists any more a NULL pointer is returned.
167  *
168  * The method writes for each encountered observation a level 3 header into
169  * the logger. It will also signal when an observation was skipped because
170  * it either was not a CTA observation or not an unbinned observation.
171  ***************************************************************************/
172 inline
174 {
175  return (const_cast<GCTAObservation*>
176  (static_cast<const ctobservation&>
177  (*this).next_unbinned_observation()));
178 }
179 
180 #endif /* CTOBSERVATION_HPP */
const GObservations & obs(void) const
Return observation container.
Base class for ctools.
Definition: ctool.hpp:50
GCTAObservation * next_unbinned_observation(void)
Return next unbinned CTA observation.
GTime m_ogip_tstop
Stop time for OGIP keywords.
virtual void process(void)=0
virtual void clear(void)=0
void copy_members(const ctobservation &app)
Copy class members.
double m_ogip_ontime
Ontime for OGIP keywords.
ctobservation(const std::string &name, const std::string &version)
Name constructor.
void set_obs_statistic(const std::string &statistic)
Set fit statistic for CTA observations.
double m_ogip_telapse
Elapsed time.
double m_ogip_exposure
Exposure time.
ctool base class implementation
double m_ogip_livetime
Livetime for OGIP keywords.
int m_index_unbinned
Current index of unbinned observation.
Base class for observation tools.
void read_ogip_keywords(GFitsHDU *hdu) const
Read OGIP keywords from FITS HDU.
void save_events_fits(void)
Save event list in FITS format.
virtual void save(void)=0
virtual ~ctobservation(void)
Destructor.
GTime m_ogip_tstart
Start time for OGIP keywords.
void free_members(void)
Delete class members.
std::string m_ogip_telescope
Name of telescope.
void write_ogip_keywords(GFitsHDU *hdu) const
Write OGIP keywords in FITS HDU.
void set_obs_bounds()
Set observation boundaries for CTA observations.
void init_members(void)
Initialise class members.
GCTAObservation * first_unbinned_observation(void)
Return first unbinned CTA observation.
ctobservation & operator=(const ctobservation &app)
Assignment operator.
GObservations m_obs
Observation container.
void save_events_xml(void)
Save event list(s) in XML format.