GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAObservation.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAObservation.hpp - CTA Observation class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2021 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 GCTAObservation.hpp
23  * @brief CTA observation class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAOBSERVATION_HPP
28 #define GCTAOBSERVATION_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GFilename.hpp"
33 #include "GObservation.hpp"
34 #include "GSkyRegions.hpp"
35 #include "GCTAResponse.hpp"
36 #include "GCTAPointing.hpp"
37 #include "GCTAEventList.hpp"
38 
39 /* __ Forward declarations _______________________________________________ */
40 class GTime;
41 class GFits;
42 class GFitsHDU;
43 class GResponse;
44 class GXmlElement;
45 class GCaldb;
46 class GGti;
47 class GCTACubeExposure;
48 class GCTACubePsf;
49 class GCTACubeEdisp;
50 class GCTACubeBackground;
51 class GCTARoi;
52 
53 
54 /***********************************************************************//**
55  * @class GCTAObservation
56  *
57  * @brief CTA observation class
58  *
59  * This class implements a CTA observation.
60  ***************************************************************************/
61 class GCTAObservation : public GObservation {
62 
63  // Friends
65 
66 public:
67  // Constructors and destructors
68  GCTAObservation(void);
69  GCTAObservation(const bool& dummy, const std::string& instrument);
70  explicit GCTAObservation(const GFilename& filename);
71  GCTAObservation(const GFilename& cntcube,
72  const GFilename& expcube,
73  const GFilename& psfcube,
74  const GFilename& bkgcube);
75  GCTAObservation(const GFilename& cntcube,
76  const GFilename& expcube,
77  const GFilename& psfcube,
78  const GFilename& edispcube,
79  const GFilename& bkgcube);
80  GCTAObservation(const GCTAObservation& obs);
81  virtual ~GCTAObservation(void);
82 
83  // Operators
85 
86  // Implemented pure virtual base class methods
87  virtual void clear(void);
88  virtual GCTAObservation* clone(void) const;
89  virtual std::string classname(void) const;
90  virtual void response(const GResponse& rsp);
91  virtual const GCTAResponse* response(void) const;
92  virtual std::string instrument(void) const;
93  virtual double ontime(void) const;
94  virtual double livetime(void) const;
95  virtual double deadc(const GTime& time = GTime()) const;
96  virtual void read(const GXmlElement& xml);
97  virtual void write(GXmlElement& xml) const;
98  virtual std::string print(const GChatter& chatter = NORMAL) const;
99 
100  // Other methods
101  void instrument(const std::string& instrument);
102  bool has_response(void) const;
103  bool has_events(void) const;
104  void read(const GFits& fits);
105  void write(GFits& fits,
106  const std::string& evtname = gammalib::extname_cta_events,
107  const std::string& gtiname = gammalib::extname_gti) const;
108  void load(const GFilename& filename);
109  void load(const GFilename& cntcube,
110  const GFilename& expcube,
111  const GFilename& psfcube,
112  const GFilename& bkgcube);
113  void load(const GFilename& cntcube,
114  const GFilename& expcube,
115  const GFilename& psfcube,
116  const GFilename& edispcube,
117  const GFilename& bkgcube);
118  void save(const GFilename& filename,
119  const bool& clobber = false) const;
120  void response(const std::string& rspname,
121  const GCaldb& caldb);
122  void response(const GCTACubeExposure& expcube,
123  const GCTACubePsf& psfcube,
124  const GCTACubeBackground& bkgcube);
125  void response(const GCTACubeExposure& expcube,
126  const GCTACubePsf& psfcube,
127  const GCTACubeEdisp& edispcube,
128  const GCTACubeBackground& bkgcube);
129  void pointing(const GCTAPointing& pointing);
130  const GCTAPointing& pointing(void) const;
131  void off_regions(const GSkyRegions& off_regions);
132  const GSkyRegions& off_regions(void) const;
133  GCTARoi roi(void) const;
134  GGti gti(void) const;
135  GEbounds ebounds(void) const;
136  void object(const std::string& object);
137  const std::string& object(void) const;
138  void ra_obj(const double& ra);
139  const double& ra_obj(void) const;
140  void dec_obj(const double& dec);
141  const double& dec_obj(void) const;
142  void ontime(const double& ontime);
143  void livetime(const double& livetime);
144  void deadc(const double& deadc);
145  void eventfile(const GFilename& filename);
146  const GFilename& eventfile(void) const;
147  std::string eventtype(void) const;
148  void dispose_events(void);
149  void lo_user_thres(const double& lo_user_thres);
150  const double& lo_user_thres(void) const;
151  void hi_user_thres(const double& hi_user_thres);
152  const double& hi_user_thres(void) const;
153  void n_tels(const int& tels);
154  const int& n_tels(void) const;
155 
156 protected:
157  // Protected methods
158  void init_members(void);
159  void copy_members(const GCTAObservation& obs);
160  void free_members(void);
161  void read_attributes(const GFitsHDU& hdu);
162  void write_attributes(GFitsHDU& hdu) const;
163 
164  // Protected members
165  std::string m_instrument; //!< Instrument name
166  GFilename m_eventfile; //!< Event filename
167  GCTAResponse* m_response; //!< Pointer to instrument response functions
168  GCTAPointing m_pointing; //!< Pointing direction
169  GSkyRegions m_off_regions; //!< Off regions
170  double m_ontime; //!< Ontime (seconds)
171  double m_livetime; //!< Livetime (seconds)
172  double m_deadc; //!< Deadtime correction (livetime/ontime)
173  double m_ra_obj; //!< Right Ascension of object (degrees)
174  double m_dec_obj; //!< Declination of object (degrees)
175  double m_lo_user_thres; //!< User defined lower energy threshold
176  double m_hi_user_thres; //!< User defined upper energy boundary
177  int m_n_tels; //!< Number of telescopes
178 
179  // Put those late as for some unknown reason putting them earlier
180  // corrupts memory on Mac OS X
181  std::string m_object; //!< Object name
182  std::string m_bgdfile; //!< Background filename
183 };
184 
185 
186 /***********************************************************************//**
187  * @brief Return class name
188  *
189  * @return String containing the class name ("GCTAObservation").
190  ***************************************************************************/
191 inline
192 std::string GCTAObservation::classname(void) const
193 {
194  return ("GCTAObservation");
195 }
196 
197 
198 /***********************************************************************//**
199  * @brief Set instrument name
200  *
201  * @param[in] instrument Instrument name.
202  ***************************************************************************/
203 inline
204 void GCTAObservation::instrument(const std::string& instrument)
205 {
207  return;
208 }
209 
210 
211 /***********************************************************************//**
212  * @brief Return instrument name
213  *
214  * @return Instrument name.
215  ***************************************************************************/
216 inline
217 std::string GCTAObservation::instrument(void) const
218 {
219  return m_instrument;
220 }
221 
222 
223 /***********************************************************************//**
224  * @brief Return ontime
225  *
226  * @return Ontime in seconds.
227  ***************************************************************************/
228 inline
229 double GCTAObservation::ontime(void) const
230 {
231  return (m_ontime);
232 }
233 
234 
235 /***********************************************************************//**
236  * @brief Return livetime
237  *
238  * @return Livetime in seconds.
239  ***************************************************************************/
240 inline
241 double GCTAObservation::livetime(void) const
242 {
243  return (m_livetime);
244 }
245 
246 
247 /***********************************************************************//**
248  * @brief Return deadtime correction factor
249  *
250  * @param[in] time Time (default: GTime()).
251  * @return Deadtime correction factor.
252  *
253  * Returns the deadtime correction factor. Optionally, this method takes a
254  * @p time argument that takes provision for returning the deadtime
255  * correction factor as function of time.
256  *
257  * The deadtime correction factor is defined as the livetime divided by the
258  * ontime.
259  ***************************************************************************/
260 inline
261 double GCTAObservation::deadc(const GTime& time) const
262 {
263  return (m_deadc);
264 }
265 
266 
267 /***********************************************************************//**
268  * @brief Signal if CTA observation contains response information
269  *
270  * @return True if CTA observation contains response information.
271  ***************************************************************************/
272 inline
274 {
275  return ((m_response != NULL) && (m_response->is_valid()));
276 }
277 
278 
279 /***********************************************************************//**
280  * @brief Signal if CTA observation contains events
281  *
282  * @return True if CTA observation contains events.
283  ***************************************************************************/
284 inline
286 {
287  return ((m_events != NULL) || (m_eventfile.length() > 0));
288 }
289 
290 
291 /***********************************************************************//**
292  * @brief Return CTA pointing
293  *
294  * @return CTA pointing
295  ***************************************************************************/
296 inline
298 {
299  return m_pointing;
300 }
301 
302 
303 /***********************************************************************//**
304  * @brief Set CTA pointing
305  *
306  * @param[in] pointing CTA pointing.
307  ***************************************************************************/
308 inline
310 {
312  return;
313 }
314 
315 
316 /***********************************************************************//**
317  * @brief Return sky off regions
318  *
319  * @return Sky off regions
320  ***************************************************************************/
321 inline
323 {
324  return m_off_regions;
325 }
326 
327 
328 /***********************************************************************//**
329  * @brief Set sky off regions
330  *
331  * @param[in] off_regions Sky off regions.
332  ***************************************************************************/
333 inline
335 {
337  return;
338 }
339 
340 
341 /***********************************************************************//**
342  * @brief Set CTA observation object name
343  *
344  * @param[in] object Object name.
345  ***************************************************************************/
346 inline
347 void GCTAObservation::object(const std::string& object)
348 {
349  m_object = object;
350  return;
351 }
352 
353 
354 /***********************************************************************//**
355  * @brief Return CTA observation object
356  *
357  * @return Object name.
358  ***************************************************************************/
359 inline
360 const std::string& GCTAObservation::object(void) const
361 {
362  return m_object;
363 }
364 
365 
366 /***********************************************************************//**
367  * @brief Set CTA object Right Ascension
368  *
369  * @param[in] ra Object Right Ascension.
370  ***************************************************************************/
371 inline
372 void GCTAObservation::ra_obj(const double& ra)
373 {
374  m_ra_obj = ra;
375  return;
376 }
377 
378 
379 /***********************************************************************//**
380  * @brief Return CTA object Right Ascension
381  *
382  * @return Object Right Ascension.
383  ***************************************************************************/
384 inline
385 const double& GCTAObservation::ra_obj(void) const
386 {
387  return m_ra_obj;
388 }
389 
390 
391 /***********************************************************************//**
392  * @brief Set CTA object Declination
393  *
394  * @param[in] dec Object Declination.
395  ***************************************************************************/
396 inline
397 void GCTAObservation::dec_obj(const double& dec)
398 {
399  m_dec_obj = dec;
400  return;
401 }
402 
403 
404 /***********************************************************************//**
405  * @brief Return CTA object Declination
406  *
407  * @return Object Declination.
408  ***************************************************************************/
409 inline
410 const double& GCTAObservation::dec_obj(void) const
411 {
412  return m_dec_obj;
413 }
414 
415 
416 /***********************************************************************//**
417  * @brief Set ontime
418  *
419  * @param[in] ontime Ontime.
420  ***************************************************************************/
421 inline
422 void GCTAObservation::ontime(const double& ontime)
423 {
424  m_ontime = ontime;
425  return;
426 }
427 
428 
429 /***********************************************************************//**
430  * @brief Set livetime
431  *
432  * @param[in] livetime Livetime.
433  ***************************************************************************/
434 inline
435 void GCTAObservation::livetime(const double& livetime)
436 {
438  return;
439 }
440 
441 
442 /***********************************************************************//**
443  * @brief Set deadtime correction
444  *
445  * @param[in] deadc Deadtime correction.
446  ***************************************************************************/
447 inline
448 void GCTAObservation::deadc(const double& deadc)
449 {
450  m_deadc = deadc;
451  return;
452 }
453 
454 
455 /***********************************************************************//**
456  * @brief Set event file name
457  *
458  * @param[in] filename Event file name.
459  ***************************************************************************/
460 inline
462 {
463  m_eventfile = filename;
464  return;
465 }
466 
467 
468 /***********************************************************************//**
469  * @brief Return event file name
470  *
471  * @return Event file name.
472  ***************************************************************************/
473 inline
475 {
476  return m_eventfile;
477 }
478 
479 
480 /***********************************************************************//**
481  * @brief Set user low energy threshold
482  *
483  * @param[in] lo_user_thres User low energy threshold.
484  ***************************************************************************/
485 inline
486 void GCTAObservation::lo_user_thres(const double& lo_user_thres)
487 {
489  return;
490 }
491 
492 
493 /***********************************************************************//**
494  * @brief Return user low energy threshold
495  *
496  * @return User low energy threshold.
497  ***************************************************************************/
498 inline
499 const double& GCTAObservation::lo_user_thres(void) const
500 {
501  return m_lo_user_thres;
502 }
503 
504 
505 /***********************************************************************//**
506  * @brief Set user high energy threshold
507  *
508  * @param[in] hi_user_thres User high energy threshold.
509  ***************************************************************************/
510 inline
511 void GCTAObservation::hi_user_thres(const double& hi_user_thres)
512 {
514  return;
515 }
516 
517 
518 /***********************************************************************//**
519  * @brief Return user high energy threshold
520  *
521  * @return User high energy threshold.
522  ***************************************************************************/
523 inline
524 const double& GCTAObservation::hi_user_thres(void) const
525 {
526  return m_hi_user_thres;
527 }
528 
529 
530 /***********************************************************************//**
531  * @brief Set number of telescopes
532  *
533  * @param[in] tels Number of telescopes.
534  ***************************************************************************/
535 inline
536 void GCTAObservation::n_tels(const int& tels)
537 {
538  m_n_tels = tels;
539  return;
540 }
541 
542 
543 /***********************************************************************//**
544  * @brief Return number of telescopes
545  *
546  * @return Number of telescopes.
547  ***************************************************************************/
548 inline
549 const int& GCTAObservation::n_tels(void) const
550 {
551  return m_n_tels;
552 }
553 
554 #endif /* GCTAOBSERVATION_HPP */
const GSkyRegions & off_regions(void) const
Return sky off regions.
bool has_response(void) const
Signal if CTA observation contains response information.
virtual ~GCTAObservation(void)
Destructor.
CTA exposure cube class.
const GFilename & eventfile(void) const
Return event file name.
CTA event list class interface definition.
virtual bool is_valid(void) const =0
void save(const GFilename &filename, const bool &clobber=false) const
Save CTA observation into FITS file.
double m_ontime
Ontime (seconds)
GFilename m_eventfile
Event filename.
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
virtual void read(const GXmlElement &xml)
Read observation from XML element.
CTA cube background class.
Sky regions container class definition.
GEvents * m_events
Pointer to event container.
GEbounds ebounds(void) const
Get energy boundaries.
void load(const GFilename &filename)
Load unbinned or binned analysis data.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA observation information.
const GCTAPointing & pointing(void) const
Return CTA pointing.
XML element node class.
Definition: GXmlElement.hpp:48
CTA pointing class interface definition.
int length(void) const
Return length of filename.
Definition: GFilename.hpp:174
void dispose_events(void)
Dispose events.
const int & n_tels(void) const
Return number of telescopes.
Interface for the CTA region of interest class.
Definition: GCTARoi.hpp:49
Time class.
Definition: GTime.hpp:55
FITS file class.
Definition: GFits.hpp:63
const std::string extname_gti
Definition: GGti.hpp:44
double m_lo_user_thres
User defined lower energy threshold.
bool has_events(void) const
Signal if CTA observation contains events.
virtual double deadc(const GTime &time=GTime()) const
Return deadtime correction factor.
double m_hi_user_thres
User defined upper energy boundary.
virtual double ontime(void) const
Return ontime.
virtual double livetime(void) const
Return livetime.
Calibration database class.
Definition: GCaldb.hpp:66
Energy boundaries container class.
Definition: GEbounds.hpp:60
GCTARoi roi(void) const
Get Region of Interest.
virtual void clear(void)
Clear CTA observation.
double m_deadc
Deadtime correction (livetime/ontime)
Filename class.
Definition: GFilename.hpp:62
GGti gti(void) const
Get Good Time Intervals.
const double & dec_obj(void) const
Return CTA object Declination.
std::string m_object
Object name.
const double & ra_obj(void) const
Return CTA object Right Ascension.
const std::string extname_cta_events
virtual std::string instrument(void) const
Return instrument name.
CTA cube background model class.
CTA pointing class.
CTA energy dispersion for stacked analysis.
GChatter
Definition: GTypemaps.hpp:33
GCTAResponse * m_response
Pointer to instrument response functions.
GCTAObservation & operator=(const GCTAObservation &obs)
Assignment operator.
Good Time Interval class.
Definition: GGti.hpp:62
virtual void write(GXmlElement &xml) const
Write observation into XML element.
Abstract observation base class.
void copy_members(const GCTAObservation &obs)
Copy class members.
CTA response abstract base class definition.
virtual const GCTAResponse * response(void) const
Return pointer to CTA response function.
Abstract observation base class interface definition.
CTA instrument response function class.
Sky region container class.
Definition: GSkyRegions.hpp:56
const double & lo_user_thres(void) const
Return user low energy threshold.
void free_members(void)
Delete class members.
CTA point spread function for cube analysis.
Definition: GCTACubePsf.hpp:62
const double & hi_user_thres(void) const
Return user high energy threshold.
void init_members(void)
Initialise class members.
void write_attributes(GFitsHDU &hdu) const
Write observation attributes.
double m_dec_obj
Declination of object (degrees)
double m_ra_obj
Right Ascension of object (degrees)
const std::string & object(void) const
Return CTA observation object.
std::string eventtype(void) const
Return event type string.
GCTAPointing m_pointing
Pointing direction.
void read_attributes(const GFitsHDU &hdu)
Read observation attributes.
virtual GCTAObservation * clone(void) const
Clone CTA observation.
CTA observation class.
Abstract instrument response base class.
Definition: GResponse.hpp:77
GSkyRegions m_off_regions
Off regions.
std::string m_instrument
Instrument name.
Filename class interface definition.
virtual std::string classname(void) const
Return class name.
int m_n_tels
Number of telescopes.
GCTAObservation(void)
Void constructor.
double m_livetime
Livetime (seconds)
std::string m_bgdfile
Background filename.