ctools  2.0.0
 All Classes Namespaces Files Functions Variables Macros Pages
ctmodel.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * ctmodel - Model cube generation tool *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2012 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 ctmodel.hpp
23  * @brief Model cube generation tool definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef CTMODEL_HPP
28 #define CTMODEL_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include "GammaLib.hpp"
32 #include "GCTALib.hpp"
33 #include "ctobservation.hpp"
34 
35 /* __Definitions _________________________________________________________ */
36 #define CTMODEL_NAME "ctmodel"
37 
38 
39 /***********************************************************************//**
40  * @class ctmodel
41  *
42  * @brief Model cube generation tool
43  *
44  * This class creates counts model map(s). The definition of the counts model
45  * can be taken from a predefined observation container, from the counts maps
46  * found in an observation definition XML file, from an individual counts
47  * map, or from the parameter definition.
48  *
49  * Results are stored in an observation container that can be written to disk
50  * in form of FITS files (model maps) and an updated observation definition
51  * XML file.
52  ***************************************************************************/
53 class ctmodel : public ctobservation {
54 
55 public:
56  // Constructors and destructors
57  ctmodel(void);
58  explicit ctmodel(const GObservations& obs);
59  ctmodel(int argc, char *argv[]);
60  ctmodel(const ctmodel& app);
61  virtual ~ctmodel(void);
62 
63  // Operators
64  ctmodel& operator=(const ctmodel& app);
65 
66  // Methods
67  void clear(void);
68  void process(void);
69  void save(void);
70  void publish(const std::string& name = "");
71  const GCTAEventCube& cube(void) const;
72  void cube(const GCTAEventCube& cube);
73  void models(const GModels& models);
74 
75 protected:
76  // Protected methods
77  void init_members(void);
78  void copy_members(const ctmodel& app);
79  void free_members(void);
80  void get_parameters(void);
81  void get_obs(void);
82  void extract_cube_properties(void);
83  void fill_cube(const GCTAObservation* obs, GModels& models);
84  bool has_cube(void) const;
85  GModels trim_models(GModels& all_models, const GCTARoi& roi);
86 
87  // User parameters
88  GFilename m_outcube; //!< Output model cube
89  bool m_apply_edisp; //!< Apply energy dispersion?
90  bool m_publish; //!< Publish model cube?
91  GChatter m_chatter; //!< Chattiness
92 
93  // Protected members
94  GCTAEventCube m_cube; //!< Model cube
95  GGti m_gti; //!< Model cube GTIs
96  bool m_has_cube; //!< Signal if cube exists
97  bool m_append_cube; //!< Signal to append cube
98  bool m_binned; //!< Signal binned mode
99  std::vector<GCTAInstDir> m_dir; //!< Cube directions
100  std::vector<double> m_solidangle; //!< Cube solid angles
101  std::vector<GEnergy> m_energy; //!< Cube energies
102  std::vector<GEnergy> m_ewidth; //!< Cube energy widths
103  GTime m_time; //!< Cube time
104  double m_ra_pnt; //!< Right Ascension of pointing
105  double m_dec_pnt; //!< Declination Ascension of pointing
106 };
107 
108 
109 /***********************************************************************//**
110  * @brief Return model cube
111  *
112  * @return Reference to model cube.
113  ***************************************************************************/
114 inline
115 const GCTAEventCube& ctmodel::cube(void) const
116 {
117  return m_cube;
118 }
119 
120 
121 /***********************************************************************//**
122  * @brief Signal if cube has been set or loaded
123  *
124  * @return True if cube has been set or loaded.
125  ***************************************************************************/
126 inline
127 bool ctmodel::has_cube(void) const
128 {
129  return m_has_cube;
130 }
131 
132 
133 /***********************************************************************//**
134  * @brief Set models
135  *
136  * @param[in] models Model container.
137  *
138  * Set model container that should be used for model generation.
139  ***************************************************************************/
140 inline
141 void ctmodel::models(const GModels& models)
142 {
143  m_obs.models(models);
144  return;
145 }
146 
147 #endif /* CTMODEL_HPP */
bool m_append_cube
Signal to append cube.
Definition: ctmodel.hpp:97
void process(void)
Generate the model map(s)
Definition: ctmodel.cpp:217
std::vector< GCTAInstDir > m_dir
Cube directions.
Definition: ctmodel.hpp:99
bool m_apply_edisp
Apply energy dispersion?
Definition: ctmodel.hpp:89
void clear(void)
Clear ctmodel tool.
Definition: ctmodel.cpp:187
bool m_has_cube
Signal if cube exists.
Definition: ctmodel.hpp:96
ctmodel(void)
Void constructor.
Definition: ctmodel.cpp:62
GFilename m_outcube
Output model cube.
Definition: ctmodel.hpp:88
void free_members(void)
Delete class members.
Definition: ctmodel.cpp:473
const GObservations & obs(void) const
Return observation container.
std::vector< double > m_solidangle
Cube solid angles.
Definition: ctmodel.hpp:100
void models(const GModels &models)
Set models.
Definition: ctmodel.hpp:141
Model cube generation tool.
Definition: ctmodel.hpp:53
GCTAEventCube m_cube
Model cube.
Definition: ctmodel.hpp:94
double m_dec_pnt
Declination Ascension of pointing.
Definition: ctmodel.hpp:105
void get_obs(void)
Get observation container.
Definition: ctmodel.cpp:648
bool m_publish
Publish model cube?
Definition: ctmodel.hpp:90
void publish(const std::string &name="")
Publish model cube.
Definition: ctmodel.cpp:355
double m_ra_pnt
Right Ascension of pointing.
Definition: ctmodel.hpp:104
Observation tool base class interface definition.
void init_members(void)
Initialise class members.
Definition: ctmodel.cpp:411
void copy_members(const ctmodel &app)
Copy class members.
Definition: ctmodel.cpp:443
Base class for observation tools.
GTime m_time
Cube time.
Definition: ctmodel.hpp:103
GChatter m_chatter
Chattiness.
Definition: ctmodel.hpp:91
void save(void)
Save model cube.
Definition: ctmodel.cpp:311
std::vector< GEnergy > m_energy
Cube energies.
Definition: ctmodel.hpp:101
bool has_cube(void) const
Signal if cube has been set or loaded.
Definition: ctmodel.hpp:127
void extract_cube_properties(void)
Extract cube properties in data members.
Definition: ctmodel.cpp:803
GModels trim_models(GModels &all_models, const GCTARoi &roi)
Find the models falling inside a defined region of interest.
Definition: ctmodel.cpp:1017
const GCTAEventCube & cube(void) const
Return model cube.
Definition: ctmodel.hpp:115
virtual ~ctmodel(void)
Destructor.
Definition: ctmodel.cpp:130
bool m_binned
Signal binned mode.
Definition: ctmodel.hpp:98
void fill_cube(const GCTAObservation *obs, GModels &models)
Fill models into model cube.
Definition: ctmodel.cpp:864
GObservations m_obs
Observation container.
ctmodel & operator=(const ctmodel &app)
Assignment operator.
Definition: ctmodel.cpp:152
void get_parameters(void)
Get application parameters.
Definition: ctmodel.cpp:486
GGti m_gti
Model cube GTIs.
Definition: ctmodel.hpp:95
std::vector< GEnergy > m_ewidth
Cube energy widths.
Definition: ctmodel.hpp:102