GammaLib  1.7.0.dev
 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-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 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  // Implement virtual methods
101  virtual void remove_response_cache(const std::string& name);
102 
103  // Other methods
104  void instrument(const std::string& instrument);
105  bool has_response(void) const;
106  bool has_events(void) const;
107  void read(const GFits& fits);
108  void write(GFits& fits,
109  const std::string& evtname = gammalib::extname_cta_events,
110  const std::string& gtiname = gammalib::extname_gti) const;
111  void load(const GFilename& filename);
112  void load(const GFilename& cntcube,
113  const GFilename& expcube,
114  const GFilename& psfcube,
115  const GFilename& bkgcube);
116  void load(const GFilename& cntcube,
117  const GFilename& expcube,
118  const GFilename& psfcube,
119  const GFilename& edispcube,
120  const GFilename& bkgcube);
121  void save(const GFilename& filename,
122  const bool& clobber = false) const;
123  void response(const std::string& rspname,
124  const GCaldb& caldb);
125  void response(const GCTACubeExposure& expcube,
126  const GCTACubePsf& psfcube,
127  const GCTACubeBackground& bkgcube);
128  void response(const GCTACubeExposure& expcube,
129  const GCTACubePsf& psfcube,
130  const GCTACubeEdisp& edispcube,
131  const GCTACubeBackground& bkgcube);
132  void pointing(const GCTAPointing& pointing);
133  const GCTAPointing& pointing(void) const;
134  void off_regions(const GSkyRegions& off_regions);
135  const GSkyRegions& off_regions(void) const;
136  GCTARoi roi(void) const;
137  GGti gti(void) const;
138  GEbounds ebounds(void) const;
139  void object(const std::string& object);
140  const std::string& object(void) const;
141  void ra_obj(const double& ra);
142  const double& ra_obj(void) const;
143  void dec_obj(const double& dec);
144  const double& dec_obj(void) const;
145  void ontime(const double& ontime);
146  void livetime(const double& livetime);
147  void deadc(const double& deadc);
148  void eventfile(const GFilename& filename);
149  const GFilename& eventfile(void) const;
150  std::string eventtype(void) const;
151  void dispose_events(void);
152  void lo_user_thres(const double& lo_user_thres);
153  const double& lo_user_thres(void) const;
154  void hi_user_thres(const double& hi_user_thres);
155  const double& hi_user_thres(void) const;
156  void n_tels(const int& tels);
157  const int& n_tels(void) const;
158 
159 protected:
160  // Protected methods
161  void init_members(void);
162  void copy_members(const GCTAObservation& obs);
163  void free_members(void);
164  void read_attributes(const GFitsHDU& hdu);
165  void write_attributes(GFitsHDU& hdu) const;
166 
167  // Protected members
168  std::string m_instrument; //!< Instrument name
169  GFilename m_eventfile; //!< Event filename
170  GCTAResponse* m_response; //!< Pointer to instrument response functions
171  GCTAPointing m_pointing; //!< Pointing direction
172  GSkyRegions m_off_regions; //!< Off regions
173  double m_ontime; //!< Ontime (seconds)
174  double m_livetime; //!< Livetime (seconds)
175  double m_deadc; //!< Deadtime correction (livetime/ontime)
176  double m_ra_obj; //!< Right Ascension of object (degrees)
177  double m_dec_obj; //!< Declination of object (degrees)
178  double m_lo_user_thres; //!< User defined lower energy threshold
179  double m_hi_user_thres; //!< User defined upper energy boundary
180  int m_n_tels; //!< Number of telescopes
181 
182  // Put those late as for some unknown reason putting them earlier
183  // corrupts memory on Mac OS X
184  std::string m_object; //!< Object name
185  std::string m_bgdfile; //!< Background filename
186 };
187 
188 
189 /***********************************************************************//**
190  * @brief Return class name
191  *
192  * @return String containing the class name ("GCTAObservation").
193  ***************************************************************************/
194 inline
195 std::string GCTAObservation::classname(void) const
196 {
197  return ("GCTAObservation");
198 }
199 
200 
201 /***********************************************************************//**
202  * @brief Set instrument name
203  *
204  * @param[in] instrument Instrument name.
205  ***************************************************************************/
206 inline
207 void GCTAObservation::instrument(const std::string& instrument)
208 {
210  return;
211 }
212 
213 
214 /***********************************************************************//**
215  * @brief Return instrument name
216  *
217  * @return Instrument name.
218  ***************************************************************************/
219 inline
220 std::string GCTAObservation::instrument(void) const
221 {
222  return m_instrument;
223 }
224 
225 
226 /***********************************************************************//**
227  * @brief Return ontime
228  *
229  * @return Ontime in seconds.
230  ***************************************************************************/
231 inline
232 double GCTAObservation::ontime(void) const
233 {
234  return (m_ontime);
235 }
236 
237 
238 /***********************************************************************//**
239  * @brief Return livetime
240  *
241  * @return Livetime in seconds.
242  ***************************************************************************/
243 inline
244 double GCTAObservation::livetime(void) const
245 {
246  return (m_livetime);
247 }
248 
249 
250 /***********************************************************************//**
251  * @brief Return deadtime correction factor
252  *
253  * @param[in] time Time (default: GTime()).
254  * @return Deadtime correction factor.
255  *
256  * Returns the deadtime correction factor. Optionally, this method takes a
257  * @p time argument that takes provision for returning the deadtime
258  * correction factor as function of time.
259  *
260  * The deadtime correction factor is defined as the livetime divided by the
261  * ontime.
262  ***************************************************************************/
263 inline
264 double GCTAObservation::deadc(const GTime& time) const
265 {
266  return (m_deadc);
267 }
268 
269 
270 /***********************************************************************//**
271  * @brief Signal if CTA observation contains response information
272  *
273  * @return True if CTA observation contains response information.
274  ***************************************************************************/
275 inline
277 {
278  return ((m_response != NULL) && (m_response->is_valid()));
279 }
280 
281 
282 /***********************************************************************//**
283  * @brief Signal if CTA observation contains events
284  *
285  * @return True if CTA observation contains events.
286  ***************************************************************************/
287 inline
289 {
290  return ((m_events != NULL) || (m_eventfile.length() > 0));
291 }
292 
293 
294 /***********************************************************************//**
295  * @brief Return CTA pointing
296  *
297  * @return CTA pointing
298  ***************************************************************************/
299 inline
301 {
302  return m_pointing;
303 }
304 
305 
306 /***********************************************************************//**
307  * @brief Set CTA pointing
308  *
309  * @param[in] pointing CTA pointing.
310  ***************************************************************************/
311 inline
313 {
315  return;
316 }
317 
318 
319 /***********************************************************************//**
320  * @brief Return sky off regions
321  *
322  * @return Sky off regions
323  ***************************************************************************/
324 inline
326 {
327  return m_off_regions;
328 }
329 
330 
331 /***********************************************************************//**
332  * @brief Set sky off regions
333  *
334  * @param[in] off_regions Sky off regions.
335  ***************************************************************************/
336 inline
338 {
340  return;
341 }
342 
343 
344 /***********************************************************************//**
345  * @brief Set CTA observation object name
346  *
347  * @param[in] object Object name.
348  ***************************************************************************/
349 inline
350 void GCTAObservation::object(const std::string& object)
351 {
352  m_object = object;
353  return;
354 }
355 
356 
357 /***********************************************************************//**
358  * @brief Return CTA observation object
359  *
360  * @return Object name.
361  ***************************************************************************/
362 inline
363 const std::string& GCTAObservation::object(void) const
364 {
365  return m_object;
366 }
367 
368 
369 /***********************************************************************//**
370  * @brief Set CTA object Right Ascension
371  *
372  * @param[in] ra Object Right Ascension.
373  ***************************************************************************/
374 inline
375 void GCTAObservation::ra_obj(const double& ra)
376 {
377  m_ra_obj = ra;
378  return;
379 }
380 
381 
382 /***********************************************************************//**
383  * @brief Return CTA object Right Ascension
384  *
385  * @return Object Right Ascension.
386  ***************************************************************************/
387 inline
388 const double& GCTAObservation::ra_obj(void) const
389 {
390  return m_ra_obj;
391 }
392 
393 
394 /***********************************************************************//**
395  * @brief Set CTA object Declination
396  *
397  * @param[in] dec Object Declination.
398  ***************************************************************************/
399 inline
400 void GCTAObservation::dec_obj(const double& dec)
401 {
402  m_dec_obj = dec;
403  return;
404 }
405 
406 
407 /***********************************************************************//**
408  * @brief Return CTA object Declination
409  *
410  * @return Object Declination.
411  ***************************************************************************/
412 inline
413 const double& GCTAObservation::dec_obj(void) const
414 {
415  return m_dec_obj;
416 }
417 
418 
419 /***********************************************************************//**
420  * @brief Set ontime
421  *
422  * @param[in] ontime Ontime.
423  ***************************************************************************/
424 inline
425 void GCTAObservation::ontime(const double& ontime)
426 {
427  m_ontime = ontime;
428  return;
429 }
430 
431 
432 /***********************************************************************//**
433  * @brief Set livetime
434  *
435  * @param[in] livetime Livetime.
436  ***************************************************************************/
437 inline
438 void GCTAObservation::livetime(const double& livetime)
439 {
441  return;
442 }
443 
444 
445 /***********************************************************************//**
446  * @brief Set deadtime correction
447  *
448  * @param[in] deadc Deadtime correction.
449  ***************************************************************************/
450 inline
451 void GCTAObservation::deadc(const double& deadc)
452 {
453  m_deadc = deadc;
454  return;
455 }
456 
457 
458 /***********************************************************************//**
459  * @brief Set event file name
460  *
461  * @param[in] filename Event file name.
462  ***************************************************************************/
463 inline
465 {
466  m_eventfile = filename;
467  return;
468 }
469 
470 
471 /***********************************************************************//**
472  * @brief Return event file name
473  *
474  * @return Event file name.
475  ***************************************************************************/
476 inline
478 {
479  return m_eventfile;
480 }
481 
482 
483 /***********************************************************************//**
484  * @brief Set user low energy threshold
485  *
486  * @param[in] lo_user_thres User low energy threshold.
487  ***************************************************************************/
488 inline
489 void GCTAObservation::lo_user_thres(const double& lo_user_thres)
490 {
492  return;
493 }
494 
495 
496 /***********************************************************************//**
497  * @brief Return user low energy threshold
498  *
499  * @return User low energy threshold.
500  ***************************************************************************/
501 inline
502 const double& GCTAObservation::lo_user_thres(void) const
503 {
504  return m_lo_user_thres;
505 }
506 
507 
508 /***********************************************************************//**
509  * @brief Set user high energy threshold
510  *
511  * @param[in] hi_user_thres User high energy threshold.
512  ***************************************************************************/
513 inline
514 void GCTAObservation::hi_user_thres(const double& hi_user_thres)
515 {
517  return;
518 }
519 
520 
521 /***********************************************************************//**
522  * @brief Return user high energy threshold
523  *
524  * @return User high energy threshold.
525  ***************************************************************************/
526 inline
527 const double& GCTAObservation::hi_user_thres(void) const
528 {
529  return m_hi_user_thres;
530 }
531 
532 
533 /***********************************************************************//**
534  * @brief Set number of telescopes
535  *
536  * @param[in] tels Number of telescopes.
537  ***************************************************************************/
538 inline
539 void GCTAObservation::n_tels(const int& tels)
540 {
541  m_n_tels = tels;
542  return;
543 }
544 
545 
546 /***********************************************************************//**
547  * @brief Return number of telescopes
548  *
549  * @return Number of telescopes.
550  ***************************************************************************/
551 inline
552 const int& GCTAObservation::n_tels(void) const
553 {
554  return m_n_tels;
555 }
556 
557 #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:47
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:48
Time class.
Definition: GTime.hpp:54
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.
const std::string & name(void) const
Return observation 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.
virtual void remove_response_cache(const std::string &name)
Remove response cache for model.
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:67
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.