GammaLib 2.0.0
Loading...
Searching...
No Matches
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 _______________________________________________ */
40class GTime;
41class GFits;
42class GFitsHDU;
43class GResponse;
44class GXmlElement;
45class GCaldb;
46class GGti;
48class GCTACubePsf;
49class GCTACubeEdisp;
51class GCTARoi;
52
53
54/***********************************************************************//**
55 * @class GCTAObservation
56 *
57 * @brief CTA observation class
58 *
59 * This class implements a CTA observation.
60 ***************************************************************************/
62
63 // Friends
65
66public:
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);
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;
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
156protected:
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 ***************************************************************************/
191inline
192std::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 ***************************************************************************/
203inline
204void GCTAObservation::instrument(const std::string& instrument)
205{
207 return;
208}
209
210
211/***********************************************************************//**
212 * @brief Return instrument name
213 *
214 * @return Instrument name.
215 ***************************************************************************/
216inline
217std::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 ***************************************************************************/
228inline
229double GCTAObservation::ontime(void) const
230{
231 return (m_ontime);
232}
233
234
235/***********************************************************************//**
236 * @brief Return livetime
237 *
238 * @return Livetime in seconds.
239 ***************************************************************************/
240inline
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 ***************************************************************************/
260inline
261double 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 ***************************************************************************/
272inline
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 ***************************************************************************/
284inline
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 ***************************************************************************/
296inline
298{
299 return m_pointing;
300}
301
302
303/***********************************************************************//**
304 * @brief Set CTA pointing
305 *
306 * @param[in] pointing CTA pointing.
307 ***************************************************************************/
308inline
310{
312 return;
313}
314
315
316/***********************************************************************//**
317 * @brief Return sky off regions
318 *
319 * @return Sky off regions
320 ***************************************************************************/
321inline
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 ***************************************************************************/
333inline
335{
337 return;
338}
339
340
341/***********************************************************************//**
342 * @brief Set CTA observation object name
343 *
344 * @param[in] object Object name.
345 ***************************************************************************/
346inline
347void GCTAObservation::object(const std::string& object)
348{
350 return;
351}
352
353
354/***********************************************************************//**
355 * @brief Return CTA observation object
356 *
357 * @return Object name.
358 ***************************************************************************/
359inline
360const 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 ***************************************************************************/
371inline
372void 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 ***************************************************************************/
384inline
385const 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 ***************************************************************************/
396inline
397void 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 ***************************************************************************/
409inline
410const 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 ***************************************************************************/
421inline
422void GCTAObservation::ontime(const double& ontime)
423{
425 return;
426}
427
428
429/***********************************************************************//**
430 * @brief Set livetime
431 *
432 * @param[in] livetime Livetime.
433 ***************************************************************************/
434inline
435void 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 ***************************************************************************/
447inline
448void 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 ***************************************************************************/
460inline
462{
463 m_eventfile = filename;
464 return;
465}
466
467
468/***********************************************************************//**
469 * @brief Return event file name
470 *
471 * @return Event file name.
472 ***************************************************************************/
473inline
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 ***************************************************************************/
485inline
486void 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 ***************************************************************************/
498inline
499const 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 ***************************************************************************/
510inline
511void 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 ***************************************************************************/
523inline
524const 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 ***************************************************************************/
535inline
536void 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 ***************************************************************************/
548inline
549const int& GCTAObservation::n_tels(void) const
550{
551 return m_n_tels;
552}
553
554#endif /* GCTAOBSERVATION_HPP */
CTA event list class interface definition.
CTA pointing class interface definition.
CTA response abstract base class definition.
Filename class interface definition.
Abstract observation base class interface definition.
Sky regions container class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
CTA cube background class.
CTA energy dispersion for stacked analysis.
CTA exposure cube class.
CTA point spread function for cube analysis.
CTA cube background model class.
CTA observation class.
double m_ra_obj
Right Ascension of object (degrees)
GCTAResponse * m_response
Pointer to instrument response functions.
const std::string & object(void) const
Return CTA observation object.
GGti gti(void) const
Get Good Time Intervals.
virtual GCTAObservation * clone(void) const
Clone CTA observation.
const int & n_tels(void) const
Return number of telescopes.
GFilename m_eventfile
Event filename.
void load(const GFilename &filename)
Load unbinned or binned analysis data.
virtual std::string classname(void) const
Return class name.
double m_hi_user_thres
User defined upper energy boundary.
virtual double livetime(void) const
Return livetime.
void write_attributes(GFitsHDU &hdu) const
Write observation attributes.
std::string m_instrument
Instrument name.
std::string eventtype(void) const
Return event type string.
const double & dec_obj(void) const
Return CTA object Declination.
int m_n_tels
Number of telescopes.
void free_members(void)
Delete class members.
virtual const GCTAResponse * response(void) const
Return pointer to CTA response function.
const GSkyRegions & off_regions(void) const
Return sky off regions.
const GFilename & eventfile(void) const
Return event file name.
virtual ~GCTAObservation(void)
Destructor.
double m_deadc
Deadtime correction (livetime/ontime)
double m_lo_user_thres
User defined lower energy threshold.
const GCTAPointing & pointing(void) const
Return CTA pointing.
std::string m_bgdfile
Background filename.
const double & hi_user_thres(void) const
Return user high energy threshold.
void init_members(void)
Initialise class members.
void copy_members(const GCTAObservation &obs)
Copy class members.
GSkyRegions m_off_regions
Off regions.
virtual std::string instrument(void) const
Return instrument name.
void save(const GFilename &filename, const bool &clobber=false) const
Save CTA observation into FITS file.
double m_livetime
Livetime (seconds)
GCTARoi roi(void) const
Get Region of Interest.
virtual void write(GXmlElement &xml) const
Write observation into XML element.
bool has_response(void) const
Signal if CTA observation contains response information.
const double & lo_user_thres(void) const
Return user low energy threshold.
GCTAObservation(void)
Void constructor.
virtual void clear(void)
Clear CTA observation.
virtual void read(const GXmlElement &xml)
Read observation from XML element.
void dispose_events(void)
Dispose events.
void read_attributes(const GFitsHDU &hdu)
Read observation attributes.
GCTAPointing m_pointing
Pointing direction.
virtual double ontime(void) const
Return ontime.
virtual double deadc(const GTime &time=GTime()) const
Return deadtime correction factor.
std::string m_object
Object name.
const double & ra_obj(void) const
Return CTA object Right Ascension.
GEbounds ebounds(void) const
Get energy boundaries.
double m_ontime
Ontime (seconds)
bool has_events(void) const
Signal if CTA observation contains events.
GCTAObservation & operator=(const GCTAObservation &obs)
Assignment operator.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA observation information.
double m_dec_obj
Declination of object (degrees)
CTA pointing class.
CTA instrument response function class.
virtual bool is_valid(void) const =0
Interface for the CTA region of interest class.
Definition GCTARoi.hpp:49
Calibration database class.
Definition GCaldb.hpp:66
Energy boundaries container class.
Definition GEbounds.hpp:60
Filename class.
Definition GFilename.hpp:62
int length(void) const
Return length of filename.
Abstract FITS extension base class.
Definition GFitsHDU.hpp:51
FITS file class.
Definition GFits.hpp:63
Good Time Interval class.
Definition GGti.hpp:62
Abstract observation base class.
GEvents * m_events
Pointer to event container.
Abstract instrument response base class.
Definition GResponse.hpp:77
Sky region container class.
Time class.
Definition GTime.hpp:55
XML element node class.
const std::string extname_gti
Definition GGti.hpp:44
const std::string extname_cta_events