GammaLib 2.0.0
Loading...
Searching...
No Matches
GCOMObservation.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCOMObservation.hpp - COMPTEL observation class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2012-2022 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 "GCOMResponse.hpp"
36#include "GCOMTim.hpp"
37#include "GCOMOads.hpp"
38#include "GCOMBvcs.hpp"
39#include "GCOMDri.hpp"
40#include "GCOMEventList.hpp"
41#include "GCOMEventCube.hpp"
42
43/* __ Forward declarations _______________________________________________ */
44class GCaldb;
45class GResponse;
46class GModelSky;
47class GModels;
48class GXmlElement;
49class GFitsHDU;
50class GSkyMap;
51class GCOMStatus;
52
53
54/***********************************************************************//**
55 * @class GCOMObservation
56 *
57 * @brief Interface class for COMPTEL observations
58 *
59 * This class implements a COMPTEL observation. Each COMPTEL observation is
60 * defined for a given energy range, and is composed of a DRE, DRB, DRG and
61 * DRX file. The DRE file contains the event data, the DRB file contains a
62 * background model, the DRG file contains geometry factors, and the DRX file
63 * contains the exposure.
64 ***************************************************************************/
66
67public:
68 // Constructors and destructors
69 GCOMObservation(void);
70 explicit GCOMObservation(const GXmlElement& xml);
71 GCOMObservation(const GCOMDri& dre,
72 const GCOMDri& drb,
73 const GCOMDri& drg,
74 const GCOMDri& drx);
76 const GFilename& drbname,
77 const GFilename& drgname,
78 const GFilename& drxname);
79 GCOMObservation(const GFilename& evpname,
80 const GFilename& timname,
81 const std::vector<GFilename>& oadnames,
82 const GFilename& bvcname = "");
84 virtual ~GCOMObservation(void);
85
86 // Operators
87 virtual GCOMObservation& operator=(const GCOMObservation& obs);
88
89 // Implement pure virtual methods
90 virtual void clear(void);
91 virtual GCOMObservation* clone(void) const;
92 virtual std::string classname(void) const;
93 virtual void response(const GResponse& rsp);
94 virtual const GCOMResponse* response(void) const;
95 virtual std::string instrument(void) const;
96 virtual double ontime(void) const;
97 virtual double livetime(void) const;
98 virtual double deadc(const GTime& time = GTime()) const;
99 virtual void read(const GXmlElement& xml);
100 virtual void write(GXmlElement& xml) const;
101 virtual std::string print(const GChatter& chatter = NORMAL) const;
102
103 // Other methods
104 bool is_unbinned(void) const;
105 bool is_binned(void) const;
106 void load(const GFilename& drename,
107 const GFilename& drbname,
108 const GFilename& drgname,
109 const GFilename& drxname);
110 void load(const GFilename& evpname,
111 const GFilename& timname,
112 const std::vector<GFilename>& oadnames,
113 const GFilename& bvcname = "");
114 void response(const GCaldb& caldb, const std::string& rspname);
115 void response(const GCOMResponse& response);
116 void obs_id(const double& id);
117 void ontime(const double& ontime);
118 void livetime(const double& livetime);
119 void deadc(const double& deadc);
120 void ewidth(const double& ewidth);
121 const double& obs_id(void) const;
122 const double& ewidth(void) const;
123 const GCOMDri& drb(void) const;
124 const GCOMDri& drg(void) const;
125 const GCOMDri& drx(void) const;
126 GCOMDri drm(const GModels& models) const;
127 const GCOMTim& tim(void) const;
128 void tim(const GCOMTim& tim);
129 const GCOMOads& oads(void) const;
130 void oads(const GCOMOads& oads);
131 const GCOMBvcs& bvcs(void) const;
132 void bvcs(const GCOMBvcs& bvcs);
133 const GFilename& drename(void) const;
134 const GFilename& drbname(void) const;
135 const GFilename& drgname(void) const;
136 const GFilename& drxname(void) const;
137 const int& phi_first(void) const;
138 const int& phi_last(void) const;
139 void drename(const GFilename& drename);
140 void drbname(const GFilename& drbname);
141 void drgname(const GFilename& drgname);
142 void drxname(const GFilename& drxname);
143 void phi_first(const int& phi_first);
144 void phi_last(const int& phi_last);
145 void compute_drb(const std::string& method,
146 const GCOMDri& drm,
147 const int& nrunav = 3,
148 const int& navgr = 3,
149 const int& nincl = 13,
150 const int& nexcl = 0);
151
152protected:
153 // Protected methods
154 void init_members(void);
155 void copy_members(const GCOMObservation& obs);
156 void free_members(void);
157 void load_dre(const GFilename& drename);
158 void load_drb(const GFilename& drbname);
159 void load_drg(const GFilename& drgname);
160 void load_drx(const GFilename& drxname);
161 bool check_dri(const GCOMDri& map) const;
162 void read_attributes(const GFitsHDU* hdu);
163 void write_attributes(GFitsHDU* hdu) const;
164 void compute_drb_phinor(const GCOMDri& drm);
165 void compute_drb_bgdlixa(const GCOMDri& drm,
166 const int& nrunav = 3,
167 const int& navgr = 3,
168 const int& nincl = 13,
169 const int& nexcl = 0);
170 void compute_drb_bgdlixe(const GCOMDri& drm,
171 const int& nrunav = 3,
172 const int& navgr = 3,
173 const int& nincl = 13,
174 const int& nexcl = 0);
175 GSkyMap get_weighted_drg_map(void) const;
176 void get_bgdlixa_phibar_indices(const int& iphibar,
177 const int& nincl,
178 const int& nexcl,
179 int* isel1,
180 int* iex1,
181 int* iex2,
182 int* isel2) const;
183
184 // Overwritten virtual methods
185 virtual bool use_event_for_likelihood(const int& index) const;
186
187 // Protected members
188 std::string m_instrument; //!< Instrument name
189 GCOMResponse m_response; //!< Response functions
190 double m_obs_id; //!< Observation ID
191 double m_ontime; //!< Ontime (sec)
192 double m_livetime; //!< Livetime (sec)
193 double m_deadc; //!< Deadtime correction
194
195 // Protected members for binned observation
196 GFilename m_drename; //!< DRE filename
197 GFilename m_drbname; //!< DRB filename
198 GFilename m_drgname; //!< DRG filename
199 GFilename m_drxname; //!< DRX filename
200 GCOMDri m_drb; //!< Background model
201 GCOMDri m_drg; //!< Geometry factors
202 GCOMDri m_drx; //!< Exposure map
203 double m_ewidth; //!< Energy width (MeV)
204 int m_phi_first; //!< First Phibar layer to use for likelihood
205 int m_phi_last; //!< Last Phibar layer to use for likelihood
206
207 // Protected members for unbinned observation
208 GFilename m_evpname; //!< EVP filename
209 GFilename m_timname; //!< TIM filename
210 std::vector<GFilename> m_oadnames; //!< OAD filenames
211 GFilename m_bvcname; //!< BVC filename
212 GCOMTim m_tim; //!< COMPTEL Good Time Intervals
213 GCOMOads m_oads; //!< Orbit Aspect Data
214 GCOMBvcs m_bvcs; //!< Solar System Barycentre Data
215};
216
217
218/***********************************************************************//**
219 * @brief Return class name
220 *
221 * @return String containing the class name ("GCOMObservation").
222 ***************************************************************************/
223inline
224std::string GCOMObservation::classname(void) const
225{
226 return ("GCOMObservation");
227}
228
229
230/***********************************************************************//**
231 * @brief Return response function
232 *
233 * @return Response function.
234 ***************************************************************************/
235inline
237{
238 // Return response pointer
239 return &m_response;
240}
241
242
243/***********************************************************************//**
244 * @brief Set response function
245 *
246 * @param[in] response Response function.
247 ***************************************************************************/
248inline
250{
252 return;
253}
254
255
256/***********************************************************************//**
257 * @brief Return instrument
258 *
259 * @return Instrument name.
260 ***************************************************************************/
261inline
262std::string GCOMObservation::instrument(void) const
263{
264 // Return instrument
265 return (m_instrument);
266}
267
268
269/***********************************************************************//**
270 * @brief Return ontime
271 *
272 * @return Ontime (seconds).
273 ***************************************************************************/
274inline
275double GCOMObservation::ontime(void) const
276{
277 // Return ontime
278 return (m_ontime);
279}
280
281
282/***********************************************************************//**
283 * @brief Return livetime
284 *
285 * @return Livetime (seconds).
286 ***************************************************************************/
287inline
289{
290 // Return livetime
291 return (m_livetime);
292}
293
294
295/***********************************************************************//**
296 * @brief Return deadtime correction factor
297 *
298 * @param[in] time Time.
299 *
300 * @return Deadtime correction factor.
301 ***************************************************************************/
302inline
303double GCOMObservation::deadc(const GTime& time) const
304{
305 // Return livetime
306 return (m_deadc);
307}
308
309
310/***********************************************************************//**
311 * @brief Set observation ID
312 *
313 * @param[in] id Observation ID.
314 ***************************************************************************/
315inline
316void GCOMObservation::obs_id(const double& id)
317{
318 m_obs_id = id;
319 return;
320}
321
322
323/***********************************************************************//**
324 * @brief Set ontime
325 *
326 * @param[in] ontime Ontime.
327 ***************************************************************************/
328inline
329void GCOMObservation::ontime(const double& ontime)
330{
332 return;
333}
334
335
336/***********************************************************************//**
337 * @brief Set livetime
338 *
339 * @param[in] livetime Livetime.
340 ***************************************************************************/
341inline
342void GCOMObservation::livetime(const double& livetime)
343{
345 return;
346}
347
348
349/***********************************************************************//**
350 * @brief Set deadtime correction factor
351 *
352 * @param[in] deadc Deadtime correction factor.
353 ***************************************************************************/
354inline
355void GCOMObservation::deadc(const double& deadc)
356{
357 m_deadc = deadc;
358 return;
359}
360
361
362/***********************************************************************//**
363 * @brief Set energy width
364 *
365 * @param[in] ewidth Energy width (MeV).
366 ***************************************************************************/
367inline
368void GCOMObservation::ewidth(const double& ewidth)
369{
371 return;
372}
373
374
375/***********************************************************************//**
376 * @brief Return observation ID
377 *
378 * @return Observation ID.
379 ***************************************************************************/
380inline
381const double& GCOMObservation::obs_id(void) const
382{
383 // Return observation ID
384 return (m_obs_id);
385}
386
387
388/***********************************************************************//**
389 * @brief Return energy width
390 *
391 * @return Energy width (MeV).
392 ***************************************************************************/
393inline
394const double& GCOMObservation::ewidth(void) const
395{
396 // Return energy width
397 return (m_ewidth);
398}
399
400
401/***********************************************************************//**
402 * @brief Return background model
403 *
404 * @return Background model.
405 ***************************************************************************/
406inline
408{
409 // Return background model
410 return (m_drb);
411}
412
413
414/***********************************************************************//**
415 * @brief Return geometry factors
416 *
417 * @return Geometry factors.
418 ***************************************************************************/
419inline
421{
422 // Return geometry factors
423 return (m_drg);
424}
425
426
427/***********************************************************************//**
428 * @brief Return exposure
429 *
430 * @return Exposure.
431 ***************************************************************************/
432inline
434{
435 // Return exposure
436 return (m_drx);
437}
438
439
440/***********************************************************************//**
441 * @brief Return COMPTEL Good Time Intervals
442 *
443 * @return COMPTEL Good Time Intervals.
444 ***************************************************************************/
445inline
447{
448 // Return COMPTEL Good Time Intervals
449 return (m_tim);
450}
451
452
453/***********************************************************************//**
454 * @brief Set COMPTEL Good Time Intervals
455 *
456 * @param[in] tim COMPTEL Good Time Intervals.
457 ***************************************************************************/
458inline
460{
461 m_tim = tim;
462 return;
463}
464
465
466/***********************************************************************//**
467 * @brief Return Orbit Aspect Data
468 *
469 * @return Orbit Aspect Data
470 ***************************************************************************/
471inline
473{
474 // Return Orbit Aspect Data
475 return (m_oads);
476}
477
478
479/***********************************************************************//**
480 * @brief Set Orbit Aspect Data
481 *
482 * @param[in] oads Orbit Aspect Data.
483 ***************************************************************************/
484inline
486{
487 m_oads = oads;
488 return;
489}
490
491
492/***********************************************************************//**
493 * @brief Return Solar System Barycentre Data
494 *
495 * @return Solar System Barycentre Data
496 ***************************************************************************/
497inline
499{
500 // Return Solar System Barycentre Data
501 return (m_bvcs);
502}
503
504
505/***********************************************************************//**
506 * @brief Set Solar System Barycentre Data
507 *
508 * @param[in] bvcs Solar System Barycentre Data.
509 ***************************************************************************/
510inline
512{
513 m_bvcs = bvcs;
514 return;
515}
516
517
518/***********************************************************************//**
519 * @brief Check whether observation is unbinned
520 *
521 * @return True if observation is unbinned.
522 ***************************************************************************/
523inline
525{
526 return (dynamic_cast<const GCOMEventList*>(m_events) != NULL);
527}
528
529
530/***********************************************************************//**
531 * @brief Check whether observation is binned
532 *
533 * @return True if observation is unbinned.
534 ***************************************************************************/
535inline
537{
538 return (dynamic_cast<const GCOMEventCube*>(m_events) != NULL);
539}
540
541
542/***********************************************************************//**
543 * @brief Return DRE filename
544 *
545 * @return DRE filename.
546 ***************************************************************************/
547inline
549{
550 // Return DRE filename
551 return (m_drename);
552}
553
554
555/***********************************************************************//**
556 * @brief Return DRB filename
557 *
558 * @return DRB filename.
559 ***************************************************************************/
560inline
562{
563 // Return DRB filename
564 return (m_drbname);
565}
566
567
568/***********************************************************************//**
569 * @brief Return DRG filename
570 *
571 * @return DRG filename.
572 ***************************************************************************/
573inline
575{
576 // Return DRG filename
577 return (m_drgname);
578}
579
580
581/***********************************************************************//**
582 * @brief Return DRX filename
583 *
584 * @return DRX filename.
585 ***************************************************************************/
586inline
588{
589 // Return DRX filename
590 return (m_drxname);
591}
592
593
594/***********************************************************************//**
595 * @brief Return index of first Phibar layer to be used for likelihood fitting
596 *
597 * @return Index of first Phibar layer.
598 ***************************************************************************/
599inline
600const int& GCOMObservation::phi_first(void) const
601{
602 // Return index of first Phibar layer
603 return (m_phi_first);
604}
605
606
607/***********************************************************************//**
608 * @brief Return index of last Phibar layer to be used for likelihood fitting
609 *
610 * @return Index of last Phibar layer.
611 ***************************************************************************/
612inline
613const int& GCOMObservation::phi_last(void) const
614{
615 // Return index of last Phibar layer
616 return (m_phi_last);
617}
618
619
620/***********************************************************************//**
621 * @brief Set DRE filename
622 *
623 * @param[in] drename DRE filename.
624 ***************************************************************************/
625inline
627{
629 return;
630}
631
632
633/***********************************************************************//**
634 * @brief Set DRB filename
635 *
636 * @param[in] drbname DRB filename.
637 ***************************************************************************/
638inline
640{
642 return;
643}
644
645
646/***********************************************************************//**
647 * @brief Set DRG filename
648 *
649 * @param[in] drgname DRG filename.
650 ***************************************************************************/
651inline
653{
655 return;
656}
657
658
659/***********************************************************************//**
660 * @brief Set DRX filename
661 *
662 * @param[in] drxname DRX filename.
663 ***************************************************************************/
664inline
666{
668 return;
669}
670
671
672/***********************************************************************//**
673 * @brief Set index of first Phibar layer to be used for likelihood fitting
674 *
675 * @param[in] phi_first Index of first Phibar layer.
676 ***************************************************************************/
677inline
678void GCOMObservation::phi_first(const int& phi_first)
679{
681 return;
682}
683
684
685/***********************************************************************//**
686 * @brief Set index of last Phibar layer to be used for likelihood fitting
687 *
688 * @param[in] phi_last Index of last Phibar layer.
689 ***************************************************************************/
690inline
691void GCOMObservation::phi_last(const int& phi_last)
692{
694 return;
695}
696
697#endif /* GCOMOBSERVATION_HPP */
COMPTEL Solar System Barycentre Data container class definition.
COMPTEL Data Space class definition.
COMPTEL event bin container class interface definition.
COMPTEL event list class definition.
COMPTEL Orbit Aspect Data container class definition.
COMPTEL instrument response function class interface definition.
COMPTEL Good Time Intervals class definition.
Filename class interface definition.
Abstract observation base class interface definition.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
COMPTEL Solar System Barycentre Data container class.
Definition GCOMBvcs.hpp:54
COMPTEL Data Space class.
Definition GCOMDri.hpp:61
COMPTEL event bin container class.
COMPTEL event list class.
COMPTEL Orbit Aspect Data container class.
Definition GCOMOads.hpp:51
Interface class for COMPTEL observations.
void free_members(void)
Delete class members.
const GCOMTim & tim(void) const
Return COMPTEL Good Time Intervals.
GCOMDri drm(const GModels &models) const
Compute DRM cube.
void init_members(void)
Initialise class members.
const GFilename & drename(void) const
Return DRE filename.
const double & obs_id(void) const
Return observation ID.
GFilename m_drgname
DRG filename.
bool is_unbinned(void) const
Check whether observation is unbinned.
void compute_drb_phinor(const GCOMDri &drm)
Compute DRB cube using PHINOR method.
GFilename m_drxname
DRX filename.
void compute_drb_bgdlixa(const GCOMDri &drm, const int &nrunav=3, const int &navgr=3, const int &nincl=13, const int &nexcl=0)
Compute DRB cube using BGDLIXA method.
const GFilename & drgname(void) const
Return DRG filename.
const GFilename & drxname(void) const
Return DRX filename.
double m_ontime
Ontime (sec)
void get_bgdlixa_phibar_indices(const int &iphibar, const int &nincl, const int &nexcl, int *isel1, int *iex1, int *iex2, int *isel2) const
Compute Phibar index range for BGDLIXA background method.
bool check_dri(const GCOMDri &map) const
Check if DRI is compatible with event cube.
const GCOMDri & drb(void) const
Return background model.
virtual double ontime(void) const
Return ontime.
virtual GCOMObservation * clone(void) const
Clone COMPTEL observation.
GCOMBvcs m_bvcs
Solar System Barycentre Data.
void read_attributes(const GFitsHDU *hdu)
Read observation attributes.
const int & phi_first(void) const
Return index of first Phibar layer to be used for likelihood fitting.
const GCOMOads & oads(void) const
Return Orbit Aspect Data.
int m_phi_last
Last Phibar layer to use for likelihood.
const double & ewidth(void) const
Return energy width.
GFilename m_drename
DRE filename.
void load_drg(const GFilename &drgname)
Load geometry factors from DRG file.
virtual std::string instrument(void) const
Return instrument.
double m_livetime
Livetime (sec)
const GCOMBvcs & bvcs(void) const
Return Solar System Barycentre Data.
virtual void read(const GXmlElement &xml)
Read observation from XML element.
GSkyMap get_weighted_drg_map(void) const
Return weighted DRG map.
virtual void clear(void)
Clear COMPTEL observation.
double m_obs_id
Observation ID.
virtual void write(GXmlElement &xml) const
Write observation into XML element.
GCOMOads m_oads
Orbit Aspect Data.
virtual double deadc(const GTime &time=GTime()) const
Return deadtime correction factor.
int m_phi_first
First Phibar layer to use for likelihood.
GCOMObservation(void)
Void constructor.
GCOMTim m_tim
COMPTEL Good Time Intervals.
GCOMDri m_drg
Geometry factors.
virtual const GCOMResponse * response(void) const
Return response function.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print observation information.
void load(const GFilename &drename, const GFilename &drbname, const GFilename &drgname, const GFilename &drxname)
Load data for a binned observation.
GCOMDri m_drb
Background model.
bool is_binned(void) const
Check whether observation is binned.
void load_dre(const GFilename &drename)
Load event cube data from DRE file.
const int & phi_last(void) const
Return index of last Phibar layer to be used for likelihood fitting.
void write_attributes(GFitsHDU *hdu) const
Write observation attributes.
double m_ewidth
Energy width (MeV)
GFilename m_drbname
DRB filename.
GFilename m_evpname
EVP filename.
virtual bool use_event_for_likelihood(const int &index) const
Check whether bin should be used for likelihood analysis.
void compute_drb_bgdlixe(const GCOMDri &drm, const int &nrunav=3, const int &navgr=3, const int &nincl=13, const int &nexcl=0)
Compute DRB cube using BGDLIXE method.
const GCOMDri & drx(void) const
Return exposure.
double m_deadc
Deadtime correction.
virtual std::string classname(void) const
Return class name.
const GCOMDri & drg(void) const
Return geometry factors.
virtual double livetime(void) const
Return livetime.
const GFilename & drbname(void) const
Return DRB filename.
void compute_drb(const std::string &method, const GCOMDri &drm, const int &nrunav=3, const int &navgr=3, const int &nincl=13, const int &nexcl=0)
Compute DRB cube.
GFilename m_timname
TIM filename.
GCOMResponse m_response
Response functions.
std::vector< GFilename > m_oadnames
OAD filenames.
virtual ~GCOMObservation(void)
Destructor.
std::string m_instrument
Instrument name.
GFilename m_bvcname
BVC filename.
void load_drx(const GFilename &drxname)
Load exposure from DRX file.
void copy_members(const GCOMObservation &obs)
Copy class members.
void load_drb(const GFilename &drbname)
Load background model from DRB file.
virtual GCOMObservation & operator=(const GCOMObservation &obs)
Assignment operator.
GCOMDri m_drx
Exposure map.
Interface for the COMPTEL instrument response function.
COMPTEL instrument status class.
COMPTEL Good Time Intervals class.
Definition GCOMTim.hpp:50
Calibration database class.
Definition GCaldb.hpp:66
Filename class.
Definition GFilename.hpp:62
Abstract FITS extension base class.
Definition GFitsHDU.hpp:51
Sky model class.
Model container class.
Definition GModels.hpp:152
Abstract observation base class.
const std::string & id(void) const
Return observation identifier.
GEvents * m_events
Pointer to event container.
Abstract instrument response base class.
Definition GResponse.hpp:77
Sky map class.
Definition GSkyMap.hpp:89
Time class.
Definition GTime.hpp:55
XML element node class.