ctools  2.1.0.dev
 All Classes Namespaces Files Functions Variables Macros Pages
ctbin.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * ctbin - Event binning tool *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-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 ctbin.hpp
23  * @brief Event binning tool definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef CTBIN_HPP
28 #define CTBIN_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include "ctobservation.hpp"
32 
33 /* __Definitions _________________________________________________________ */
34 #define CTBIN_NAME "ctbin"
35 
36 
37 /***********************************************************************//**
38  * @class ctbin
39  *
40  * @brief Event binning tool
41  *
42  * This class bins event list(s) into counts cubes. The class can
43  * operate on predefined observation containers, on individual event list
44  * FITS files, and on observation definition XML files.
45  *
46  * If multiple event lists are specified in the observation container or the
47  * XML definition file, the class will upon request stack these events into a
48  * single counts cube.
49  *
50  * If the hidden parameter stack=no is used, one counts cube is generated for
51  * each individual observation. These cubes are saved to a path that can be
52  * specified by the hidden parameter prefix, followed by the corresponding
53  * observation id. An observation definition XML file containing the paths
54  * to the newly generated counts cubes is written to path given in the
55  * parameter outcube.
56  *
57  * Results are stored in an observation container that can be written to disk
58  * in form of a single FITS file. On output, the observation container will
59  * have merged the input event lists into a single observation.
60  *
61  * WARNING: Note that the pointing direction of the counts cube will be set
62  * to the skymap centre used for the counts cube definition. If usepnt=yes
63  * is used, the pointing direction will be extracted from the first
64  * observation encountered in the list. Ultimately, pointing direction
65  * information should not be removed from the counts cube and exposure and
66  * PSF cubes should be used for response computation. This is however not
67  * yet fully implemented.
68  ***************************************************************************/
69 class ctbin : public ctobservation {
70 public:
71  // Constructors and destructors
72  ctbin(void);
73  explicit ctbin(const GObservations& obs);
74  ctbin(int argc, char *argv[]);
75  ctbin(const ctbin& app);
76  virtual ~ctbin(void);
77 
78  // Operators
79  ctbin& operator=(const ctbin& app);
80 
81  // Methods
82  void clear(void);
83  void process(void);
84  int cubes(void) const;
85  const GCTAEventCube& cube(const int& index = 0) const;
86  void save(void);
87  void publish(const std::string& name = "");
88 
89 protected:
90  // Protected methods
91  void init_members(void);
92  void copy_members(const ctbin& app);
93  void free_members(void);
94  void get_parameters(void);
95  void init_sky_dir_cache(void);
96  GSkyMap create_cube(const GCTAObservation* obs);
97  void fill_cube(const GCTAObservation* obs, GSkyMap& counts);
98  void set_weights(const GCTAObservation* obs, GSkyMap& weights);
99  void obs_cube_stacked(void);
100 
101  // User parameters
102  bool m_stack; //!< Output one stacked cube or multiple cubes
103  std::string m_prefix; //!< Prefix for multiple cubes
104  bool m_publish; //!< Publish counts cube?
105  GChatter m_chatter; //!< Chattiness
106 
107  // Protected members
108  std::vector<GCTAEventCube> m_cubes; //!< Event cubes
109  std::vector<GSkyMap> m_counts; //!< List of event cube counts
110  std::vector<GSkyMap> m_weights; //!< List of event cube weights
111  GSkyDir m_mean_pnt; //!< Mean pointing
112  GEbounds m_ebounds; //!< Energy boundaries
113  GGti m_gti; //!< Stacked Good time intervals
114  double m_ontime; //!< Total ontime
115  double m_livetime; //!< Total livetime
116 
117  // Cache members
118  std::vector<GSkyDir> m_dirs; //!< Cached GSkyDir for all pixels
119 };
120 
121 
122 /***********************************************************************//**
123  * @brief Return number of event cubes
124  *
125  * @return Number of event cubes.
126  *
127  * Returns number of event cubes.
128  ***************************************************************************/
129 inline
130 int ctbin::cubes(void) const
131 {
132  return ((int)m_cubes.size());
133 }
134 
135 #endif /* CTBIN_HPP */
void init_members(void)
Initialise class members.
Definition: ctbin.cpp:600
void clear(void)
Clear event binning tool.
Definition: ctbin.cpp:196
GEbounds m_ebounds
Energy boundaries.
Definition: ctbin.hpp:112
virtual ~ctbin(void)
Destructor.
Definition: ctbin.cpp:137
const GObservations & obs(void) const
Return observation container.
std::vector< GSkyDir > m_dirs
Cached GSkyDir for all pixels.
Definition: ctbin.hpp:118
void free_members(void)
Delete class members.
Definition: ctbin.cpp:662
Event binning tool.
Definition: ctbin.hpp:69
ctbin(void)
Void constructor.
Definition: ctbin.cpp:64
bool m_stack
Output one stacked cube or multiple cubes.
Definition: ctbin.hpp:102
void set_weights(const GCTAObservation *obs, GSkyMap &weights)
Set counts cube weights for a given observation.
Definition: ctbin.cpp:959
std::vector< GCTAEventCube > m_cubes
Event cubes.
Definition: ctbin.hpp:108
Observation tool base class interface definition.
Base class for observation tools.
void copy_members(const ctbin &app)
Copy class members.
Definition: ctbin.cpp:632
ctbin & operator=(const ctbin &app)
Assignment operator.
Definition: ctbin.cpp:161
GSkyDir m_mean_pnt
Mean pointing.
Definition: ctbin.hpp:111
const GCTAEventCube & cube(const int &index=0) const
Return event cube at index.
Definition: ctbin.cpp:460
void save(void)
Save counts cube.
Definition: ctbin.cpp:480
std::vector< GSkyMap > m_weights
List of event cube weights.
Definition: ctbin.hpp:110
GGti m_gti
Stacked Good time intervals.
Definition: ctbin.hpp:113
void init_sky_dir_cache(void)
Initialise sky direction cache for cube stack.
Definition: ctbin.cpp:727
bool m_publish
Publish counts cube?
Definition: ctbin.hpp:104
int cubes(void) const
Return number of event cubes.
Definition: ctbin.hpp:130
void get_parameters(void)
Get application parameters.
Definition: ctbin.cpp:678
void fill_cube(const GCTAObservation *obs, GSkyMap &counts)
Fill events into counts cube.
Definition: ctbin.cpp:837
double m_ontime
Total ontime.
Definition: ctbin.hpp:114
void publish(const std::string &name="")
Publish counts cube.
Definition: ctbin.cpp:567
void obs_cube_stacked(void)
Create output observation container.
Definition: ctbin.cpp:1029
std::vector< GSkyMap > m_counts
List of event cube counts.
Definition: ctbin.hpp:109
void process(void)
Process the event binning tool.
Definition: ctbin.cpp:227
double m_livetime
Total livetime.
Definition: ctbin.hpp:115
GChatter m_chatter
Chattiness.
Definition: ctbin.hpp:105
GSkyMap create_cube(const GCTAObservation *obs)
Create counts cube sky map for current observation.
Definition: ctbin.cpp:757
std::string m_prefix
Prefix for multiple cubes.
Definition: ctbin.hpp:103