ctools 2.2.0.dev
Loading...
Searching...
No Matches
ctobservation.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * ctobservation - Base class for observation tools *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2016-2025 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 ***************************************************************************/
44class ctobservation : public ctool {
45
46public:
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);
60 ctobservation(const ctobservation& app);
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 void models(const GModels& models);
75 const GModels& models(void) const;
76
77#ifndef SWIG
78protected:
79#endif
80 // Protected methods
81 GCTAObservation* first_unbinned_observation(void);
82 GCTAObservation* next_unbinned_observation(void);
83 const GCTAObservation* first_unbinned_observation(void) const;
84 const GCTAObservation* next_unbinned_observation(void) const;
85 void read_ogip_keywords(GFitsHDU* hdu) const;
86 void write_ogip_keywords(GFitsHDU* hdu) const;
87 void set_obs_statistic(const std::string& statistic);
88 void set_obs_bounds();
89 void save_events_fits(void);
90 void save_events_xml(void);
91
92protected:
93 // Protected methods
94 void init_members(void);
95 void copy_members(const ctobservation& app);
96 void free_members(void);
97
98 // Protected members
99 GObservations m_obs; //!< Observation container
100
101private:
102 // Private members
103 mutable std::string m_ogip_telescope; //!< Name of telescope
104 mutable GTime m_ogip_tstart; //!< Start time for OGIP keywords
105 mutable GTime m_ogip_tstop; //!< Stop time for OGIP keywords
106 mutable double m_ogip_telapse; //!< Elapsed time
107 mutable double m_ogip_exposure; //!< Exposure time
108 mutable double m_ogip_ontime; //!< Ontime for OGIP keywords
109 mutable double m_ogip_livetime; //!< Livetime for OGIP keywords
110 mutable int m_index_unbinned; //!< Current index of unbinned observation
111};
112
113
114/***********************************************************************//**
115 * @brief Set observation container
116 *
117 * @param[in] obs Observation container.
118 *
119 * Set observation container.
120 ***************************************************************************/
121inline
122void ctobservation::obs(const GObservations& obs)
123{
124 m_obs = obs;
125 return;
126}
127
128
129/***********************************************************************//**
130 * @brief Return observation container
131 *
132 * @return Reference to observation container.
133 *
134 * Returns a reference to the observation container.
135 ***************************************************************************/
136inline
137const GObservations& ctobservation::obs(void) const
138{
139 return m_obs;
140}
141
142
143/***********************************************************************//**
144 * @brief Set model container
145 *
146 * @param[in] models Model container.
147 *
148 * Set model container.
149 ***************************************************************************/
150inline
151void ctobservation::models(const GModels& models)
152{
153 m_obs.models(models);
154 return;
155}
156
157
158/***********************************************************************//**
159 * @brief Return model container
160 *
161 * @return Reference to model container.
162 *
163 * Returns a reference to the model container.
164 ***************************************************************************/
165inline
166const GModels& ctobservation::models(void) const
167{
168 return (m_obs.models());
169}
170
171
172/***********************************************************************//**
173 * @brief Return first unbinned CTA observation
174 *
175 * @return Pointer to first unbinned CTA observation
176 *
177 * Returns a pointer to the first unbinned CTA observation in the container.
178 * If no CTA observation exists a NULL pointer is returned.
179 *
180 * The method calls next_unbinned_observation(). See the method for details.
181 ***************************************************************************/
182inline
184{
185 return (const_cast<GCTAObservation*>
186 (static_cast<const ctobservation&>
187 (*this).first_unbinned_observation()));
188}
189
190
191/***********************************************************************//**
192 * @brief Return next unbinned CTA observation
193 *
194 * @return Pointer to next unbinned CTA observation
195 *
196 * Returns a pointer to the next unbinned CTA observation in the container.
197 * If no CTA observation exists any more a NULL pointer is returned.
198 *
199 * The method writes for each encountered observation a level 3 header into
200 * the logger. It will also signal when an observation was skipped because
201 * it either was not a CTA observation or not an unbinned observation.
202 ***************************************************************************/
203inline
205{
206 return (const_cast<GCTAObservation*>
207 (static_cast<const ctobservation&>
208 (*this).next_unbinned_observation()));
209}
210
211#endif /* CTOBSERVATION_HPP */
Base class for observation tools.
GTime m_ogip_tstop
Stop time for OGIP keywords.
void free_members(void)
Delete class members.
ctobservation(const std::string &name, const std::string &version)
Name constructor.
ctobservation & operator=(const ctobservation &app)
Assignment operator.
GTime m_ogip_tstart
Start time for OGIP keywords.
GCTAObservation * next_unbinned_observation(void)
Return next unbinned CTA observation.
GObservations m_obs
Observation container.
void read_ogip_keywords(GFitsHDU *hdu) const
Read OGIP keywords from FITS HDU.
GCTAObservation * first_unbinned_observation(void)
Return first unbinned CTA observation.
double m_ogip_livetime
Livetime for OGIP keywords.
virtual ~ctobservation(void)
Destructor.
void write_ogip_keywords(GFitsHDU *hdu) const
Write OGIP keywords in FITS HDU.
const GModels & models(void) const
Return model container.
virtual void process(void)=0
double m_ogip_exposure
Exposure time.
void save_events_fits(void)
Save event list in FITS format.
double m_ogip_telapse
Elapsed time.
const GObservations & obs(void) const
Return observation container.
void save_events_xml(void)
Save event list(s) in XML format.
double m_ogip_ontime
Ontime for OGIP keywords.
void set_obs_bounds()
Set observation boundaries for CTA observations.
void copy_members(const ctobservation &app)
Copy class members.
void init_members(void)
Initialise class members.
std::string m_ogip_telescope
Name of telescope.
virtual void clear(void)=0
int m_index_unbinned
Current index of unbinned observation.
void set_obs_statistic(const std::string &statistic)
Set fit statistic for CTA observations.
virtual void save(void)=0
Base class for ctools.
Definition ctool.hpp:50
ctool base class implementation