GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMObservation.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMObservation.hpp - COMPTEL observation class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2019 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 GCOMObservation.hpp
23  * @brief COMPTEL observation class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCOMOBSERVATION_HPP
28 #define GCOMOBSERVATION_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GObservation.hpp"
33 #include "GTime.hpp"
34 #include "GFilename.hpp"
35 #include "GSkyMap.hpp"
36 #include "GCOMResponse.hpp"
37 #include "GCOMTim.hpp"
38 #include "GCOMOads.hpp"
39 #include "GCOMDri.hpp"
40 #include "GCOMEventList.hpp"
41 #include "GCOMEventCube.hpp"
42 
43 /* __ Forward declarations _______________________________________________ */
44 class GCaldb;
45 class GResponse;
46 class GSource;
47 class GModels;
48 class GXmlElement;
49 class GFitsHDU;
50 class GCOMStatus;
51 
52 
53 /***********************************************************************//**
54  * @class GCOMObservation
55  *
56  * @brief Interface class for COMPTEL observations
57  *
58  * This class implements a COMPTEL observation. Each COMPTEL observation is
59  * defined for a given energy range, and is composed of a DRE, DRB, DRG and
60  * DRX file. The DRE file contains the event data, the DRB file contains a
61  * background model, the DRG file contains geometry factors, and the DRX file
62  * contains the exposure.
63  ***************************************************************************/
64 class GCOMObservation : public GObservation {
65 
66 public:
67  // Constructors and destructors
68  GCOMObservation(void);
69  explicit GCOMObservation(const GXmlElement& xml);
70  GCOMObservation(const GFilename& drename,
71  const GFilename& drbname,
72  const GFilename& drgname,
73  const GFilename& drxname);
74  GCOMObservation(const GFilename& evpname,
75  const GFilename& timname,
76  const std::vector<GFilename>& oadnames);
77  GCOMObservation(const GCOMObservation& obs);
78  virtual ~GCOMObservation(void);
79 
80  // Operators
81  virtual GCOMObservation& operator=(const GCOMObservation& obs);
82 
83  // Implement pure virtual methods
84  virtual void clear(void);
85  virtual GCOMObservation* clone(void) const;
86  virtual std::string classname(void) const;
87  virtual void response(const GResponse& rsp);
88  virtual const GCOMResponse* response(void) const;
89  virtual std::string instrument(void) const;
90  virtual double ontime(void) const;
91  virtual double livetime(void) const;
92  virtual double deadc(const GTime& time = GTime()) const;
93  virtual void read(const GXmlElement& xml);
94  virtual void write(GXmlElement& xml) const;
95  virtual std::string print(const GChatter& chatter = NORMAL) const;
96 
97  // Implement virtual methods
98  virtual void remove_response_cache(const std::string& name);
99 
100  // Other methods
101  bool is_unbinned(void) const;
102  bool is_binned(void) const;
103  void load(const GFilename& drename,
104  const GFilename& drbname,
105  const GFilename& drgname,
106  const GFilename& drxname);
107  void load(const GFilename& evpname,
108  const GFilename& timname,
109  const std::vector<GFilename>& oadnames);
110  void response(const GCaldb& caldb, const std::string& rspname);
111  void obs_id(const double& id);
112  void ontime(const double& ontime);
113  void livetime(const double& livetime);
114  void deadc(const double& deadc);
115  void ewidth(const double& ewidth);
116  const double& obs_id(void) const;
117  const double& ewidth(void) const;
118  const GSkyMap& drb(void) const;
119  const GSkyMap& drg(void) const;
120  const GSkyMap& drx(void) const;
121  const GCOMDri& drm(const GSource& source) const;
122  GCOMDri drm(const GModels& models) const;
123  const GCOMTim& tim(void) const;
124  const GCOMOads& oads(void) const;
125 
126 protected:
127  // Protected methods
128  void init_members(void);
129  void copy_members(const GCOMObservation& obs);
130  void free_members(void);
131  void load_dre(const GFilename& drename);
132  void load_drb(const GFilename& drbname);
133  void load_drg(const GFilename& drgname);
134  void load_drx(const GFilename& drxname);
135  void add_drm(const GSource& source);
136  bool check_map(const GSkyMap& map) const;
137  void read_attributes(const GFitsHDU* hdu);
138  void write_attributes(GFitsHDU* hdu) const;
139 
140  // Protected members
141  std::string m_instrument; //!< Instrument name
142  GCOMResponse m_response; //!< Response functions
143  double m_obs_id; //!< Observation ID
144  double m_ontime; //!< Ontime (sec)
145  double m_livetime; //!< Livetime (sec)
146  double m_deadc; //!< Deadtime correction
147 
148  // Protected members for binned observation
149  GFilename m_drename; //!< DRE filename
150  GFilename m_drbname; //!< DRB filename
151  GFilename m_drgname; //!< DRG filename
152  GFilename m_drxname; //!< DRX filename
153  GSkyMap m_drb; //!< Background model
154  GSkyMap m_drg; //!< Geometry factors
155  GSkyMap m_drx; //!< Exposure map
156  double m_ewidth; //!< Energy width (MeV)
157 
158  // Protected members for unbinned observation
159  GFilename m_evpname; //!< EVP filename
160  GFilename m_timname; //!< TIM filename
161  std::vector<GFilename> m_oadnames; //!< OAD filenames
162  GCOMTim m_tim; //!< COMPTEL Good Time Intervals
163  GCOMOads m_oads; //!< Orbit Aspect Data
164 
165  // Protected members for response cache
166  std::vector<GCOMDri> m_drms; //!< Convolved model cubes
167 };
168 
169 
170 /***********************************************************************//**
171  * @brief Return class name
172  *
173  * @return String containing the class name ("GCOMObservation").
174  ***************************************************************************/
175 inline
176 std::string GCOMObservation::classname(void) const
177 {
178  return ("GCOMObservation");
179 }
180 
181 
182 /***********************************************************************//**
183  * @brief Return response function
184  *
185  * @return Response function.
186  ***************************************************************************/
187 inline
189 {
190  // Return response pointer
191  return &m_response;
192 }
193 
194 
195 /***********************************************************************//**
196  * @brief Return instrument
197  *
198  * @return Instrument name.
199  ***************************************************************************/
200 inline
201 std::string GCOMObservation::instrument(void) const
202 {
203  // Return instrument
204  return (m_instrument);
205 }
206 
207 
208 /***********************************************************************//**
209  * @brief Return ontime
210  *
211  * @return Ontime (seconds).
212  ***************************************************************************/
213 inline
214 double GCOMObservation::ontime(void) const
215 {
216  // Return ontime
217  return (m_ontime);
218 }
219 
220 
221 /***********************************************************************//**
222  * @brief Return livetime
223  *
224  * @return Livetime (seconds).
225  ***************************************************************************/
226 inline
227 double GCOMObservation::livetime(void) const
228 {
229  // Return livetime
230  return (m_livetime);
231 }
232 
233 
234 /***********************************************************************//**
235  * @brief Return deadtime correction factor
236  *
237  * @param[in] time Time.
238  *
239  * @return Deadtime correction factor.
240  ***************************************************************************/
241 inline
242 double GCOMObservation::deadc(const GTime& time) const
243 {
244  // Return livetime
245  return (m_deadc);
246 }
247 
248 
249 /***********************************************************************//**
250  * @brief Set observation ID
251  *
252  * @param[in] id Observation ID.
253  ***************************************************************************/
254 inline
255 void GCOMObservation::obs_id(const double& id)
256 {
257  m_obs_id = id;
258  return;
259 }
260 
261 
262 /***********************************************************************//**
263  * @brief Set ontime
264  *
265  * @param[in] ontime Ontime.
266  ***************************************************************************/
267 inline
268 void GCOMObservation::ontime(const double& ontime)
269 {
270  m_ontime = ontime;
271  return;
272 }
273 
274 
275 /***********************************************************************//**
276  * @brief Set livetime
277  *
278  * @param[in] livetime Livetime.
279  ***************************************************************************/
280 inline
281 void GCOMObservation::livetime(const double& livetime)
282 {
284  return;
285 }
286 
287 
288 /***********************************************************************//**
289  * @brief Set deadtime correction factor
290  *
291  * @param[in] deadc Deadtime correction factor.
292  ***************************************************************************/
293 inline
294 void GCOMObservation::deadc(const double& deadc)
295 {
296  m_deadc = deadc;
297  return;
298 }
299 
300 
301 /***********************************************************************//**
302  * @brief Set energy width
303  *
304  * @param[in] ewidth Energy width (MeV).
305  ***************************************************************************/
306 inline
307 void GCOMObservation::ewidth(const double& ewidth)
308 {
309  m_ewidth = ewidth;
310  return;
311 }
312 
313 
314 /***********************************************************************//**
315  * @brief Return observation ID
316  *
317  * @return Observation ID.
318  ***************************************************************************/
319 inline
320 const double& GCOMObservation::obs_id(void) const
321 {
322  // Return observation ID
323  return (m_obs_id);
324 }
325 
326 
327 /***********************************************************************//**
328  * @brief Return energy width
329  *
330  * @return Energy width (MeV).
331  ***************************************************************************/
332 inline
333 const double& GCOMObservation::ewidth(void) const
334 {
335  // Return energy width
336  return (m_ewidth);
337 }
338 
339 
340 /***********************************************************************//**
341  * @brief Return background model
342  *
343  * @return Background model.
344  ***************************************************************************/
345 inline
346 const GSkyMap& GCOMObservation::drb(void) const
347 {
348  // Return background model
349  return (m_drb);
350 }
351 
352 
353 /***********************************************************************//**
354  * @brief Return geometry factors
355  *
356  * @return Geometry factors.
357  ***************************************************************************/
358 inline
359 const GSkyMap& GCOMObservation::drg(void) const
360 {
361  // Return geometry factors
362  return (m_drg);
363 }
364 
365 
366 /***********************************************************************//**
367  * @brief Return exposure
368  *
369  * @return Exposure.
370  ***************************************************************************/
371 inline
372 const GSkyMap& GCOMObservation::drx(void) const
373 {
374  // Return exposure
375  return (m_drx);
376 }
377 
378 
379 /***********************************************************************//**
380  * @brief Return COMPTEL Good Time Intervals
381  *
382  * @return COMPTEL Good Time Intervals.
383  ***************************************************************************/
384 inline
385 const GCOMTim& GCOMObservation::tim(void) const
386 {
387  // Return COMPTEL Good Time Intervals
388  return (m_tim);
389 }
390 
391 
392 /***********************************************************************//**
393  * @brief Return Orbit Aspect Data
394  *
395  * @return Orbit Aspect Data
396  ***************************************************************************/
397 inline
398 const GCOMOads& GCOMObservation::oads(void) const
399 {
400  // Return Orbit Aspect Data
401  return (m_oads);
402 }
403 
404 
405 /***********************************************************************//**
406  * @brief Check whether observation is unbinned
407  *
408  * @return True if observation is unbinned.
409  ***************************************************************************/
410 inline
412 {
413  return (dynamic_cast<const GCOMEventList*>(m_events) != NULL);
414 }
415 
416 
417 /***********************************************************************//**
418  * @brief Check whether observation is binned
419  *
420  * @return True if observation is unbinned.
421  ***************************************************************************/
422 inline
424 {
425  return (dynamic_cast<const GCOMEventCube*>(m_events) != NULL);
426 }
427 
428 #endif /* GCOMOBSERVATION_HPP */
COMPTEL instrument status class.
Definition: GCOMStatus.hpp:49
virtual void clear(void)
Clear COMPTEL observation.
std::vector< GCOMDri > m_drms
Convolved model cubes.
Sky map class.
Definition: GSkyMap.hpp:89
const GCOMOads & oads(void) const
Return Orbit Aspect Data.
double m_obs_id
Observation ID.
GSkyMap m_drb
Background model.
void copy_members(const GCOMObservation &obs)
Copy class members.
GFilename m_drbname
DRB filename.
void init_members(void)
Initialise class members.
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
double m_deadc
Deadtime correction.
COMPTEL Data Space class definition.
COMPTEL event list class definition.
GFilename m_timname
TIM filename.
std::vector< GFilename > m_oadnames
OAD filenames.
GEvents * m_events
Pointer to event container.
virtual double ontime(void) const
Return ontime.
GFilename m_evpname
EVP filename.
XML element node class.
Definition: GXmlElement.hpp:47
bool is_unbinned(void) const
Check whether observation is unbinned.
Interface for the COMPTEL instrument response function.
Time class.
Definition: GTime.hpp:54
void load_dre(const GFilename &drename)
Load event cube data from DRE file.
void free_members(void)
Delete class members.
COMPTEL Good Time Intervals class definition.
GCOMTim m_tim
COMPTEL Good Time Intervals.
virtual double deadc(const GTime &time=GTime()) const
Return deadtime correction factor.
Sky map class definition.
virtual void remove_response_cache(const std::string &name)
Remove response cache for model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print observation information.
const double & obs_id(void) const
Return observation ID.
void load(const GFilename &drename, const GFilename &drbname, const GFilename &drgname, const GFilename &drxname)
Load data for a binned observation.
virtual const GCOMResponse * response(void) const
Return response function.
const GCOMTim & tim(void) const
Return COMPTEL Good Time Intervals.
Model container class.
Definition: GModels.hpp:150
Calibration database class.
Definition: GCaldb.hpp:66
const std::string & id(void) const
Return observation identifier.
COMPTEL instrument response function class interface definition.
virtual void write(GXmlElement &xml) const
Write observation into XML element.
virtual void read(const GXmlElement &xml)
Read observation from XML element.
Filename class.
Definition: GFilename.hpp:62
void load_drb(const GFilename &drbname)
Load background model from DRB file.
double m_ontime
Ontime (sec)
bool is_binned(void) const
Check whether observation is binned.
const std::string & name(void) const
Return observation name.
void read_attributes(const GFitsHDU *hdu)
Read observation attributes.
bool check_map(const GSkyMap &map) const
Check if sky map is compatible with event cube.
virtual std::string instrument(void) const
Return instrument.
GChatter
Definition: GTypemaps.hpp:33
double m_livetime
Livetime (sec)
Abstract observation base class.
virtual GCOMObservation * clone(void) const
Clone COMPTEL observation.
void add_drm(const GSource &source)
Add DRM cube to observation response cache.
virtual std::string classname(void) const
Return class name.
Abstract observation base class interface definition.
GSkyMap m_drg
Geometry factors.
const GSkyMap & drx(void) const
Return exposure.
double m_ewidth
Energy width (MeV)
GCOMOads m_oads
Orbit Aspect Data.
void load_drx(const GFilename &drxname)
Load exposure from DRX file.
Interface class for COMPTEL observations.
COMPTEL Data Space class.
Definition: GCOMDri.hpp:60
virtual double livetime(void) const
Return livetime.
COMPTEL Orbit Aspect Data container class.
Definition: GCOMOads.hpp:51
const double & ewidth(void) const
Return energy width.
void write_attributes(GFitsHDU *hdu) const
Write observation attributes.
const GSkyMap & drb(void) const
Return background model.
COMPTEL Good Time Intervals class.
Definition: GCOMTim.hpp:50
GSkyMap m_drx
Exposure map.
Abstract instrument response base class.
Definition: GResponse.hpp:67
COMPTEL event bin container class interface definition.
virtual GCOMObservation & operator=(const GCOMObservation &obs)
Assignment operator.
Class that handles gamma-ray sources.
Definition: GSource.hpp:53
GCOMObservation(void)
Void constructor.
const GCOMDri & drm(const GSource &source) const
Return source model DRM cube.
Time class interface definition.
GFilename m_drxname
DRX filename.
virtual ~GCOMObservation(void)
Destructor.
void load_drg(const GFilename &drgname)
Load geometry factors from DRG file.
GCOMResponse m_response
Response functions.
Filename class interface definition.
GFilename m_drgname
DRG filename.
COMPTEL Orbit Aspect Data container class definition.
std::string m_instrument
Instrument name.
const GSkyMap & drg(void) const
Return geometry factors.
GFilename m_drename
DRE filename.