inst/cta/include/GCTAOnOffObservations.hpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *    GCTAOnOffObservations.hpp - CTA on-off observation container class   *
00003  * ----------------------------------------------------------------------- *
00004  *  copyright (C) 2013-2016 by Pierrick Martin                             *
00005  * ----------------------------------------------------------------------- *
00006  *                                                                         *
00007  *  This program is free software: you can redistribute it and/or modify   *
00008  *  it under the terms of the GNU General Public License as published by   *
00009  *  the Free Software Foundation, either version 3 of the License, or      *
00010  *  (at your option) any later version.                                    *
00011  *                                                                         *
00012  *  This program is distributed in the hope that it will be useful,        *
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00015  *  GNU General Public License for more details.                           *
00016  *                                                                         *
00017  *  You should have received a copy of the GNU General Public License      *
00018  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
00019  *                                                                         *
00020  ***************************************************************************/
00021 /**
00022  * @file GCTAOnOffObservations.hpp
00023  * @brief CTA on-off observation container class definition
00024  * @author Pierrick Martin
00025  */
00026 
00027 #ifndef GCTAONOFFOBSERVATIONS_HPP
00028 #define GCTAONOFFOBSERVATIONS_HPP
00029 
00030 /* __ Includes ___________________________________________________________ */
00031 #include <string>
00032 #include <vector>
00033 #include "GContainer.hpp"
00034 #include "GCTAOnOffObservation.hpp"
00035 #include "GModels.hpp"
00036 
00037 /* __ Forward declarations _______________________________________________ */
00038 class GFilename;
00039 
00040 
00041 /***********************************************************************//**
00042  * @class GCTAOnOffObservations
00043  *
00044  * @brief ON/OFF Observation container class
00045  *
00046  * This class in a container of GCTAOnOffObservation objects. Still some
00047  * work to do and things to be clarified...
00048  ***************************************************************************/
00049 class GCTAOnOffObservations : public GContainer {
00050 
00051 public:
00052     // Constructors and destructors
00053     GCTAOnOffObservations(void);
00054     GCTAOnOffObservations(const GCTAOnOffObservations& obs);
00055     explicit GCTAOnOffObservations(const GFilename& filename);
00056     virtual ~GCTAOnOffObservations(void);
00057 
00058     // Operators
00059     GCTAOnOffObservations&      operator=(const GCTAOnOffObservations& obs);
00060     GCTAOnOffObservation*       operator[](const int& index);
00061     const GCTAOnOffObservation* operator[](const int& index) const;
00062 
00063     // Methods
00064     void                        clear(void);
00065     GCTAOnOffObservations*      clone(void) const;
00066     std::string                 classname(void) const;
00067     GCTAOnOffObservation*       at(const int& index);
00068     const GCTAOnOffObservation* at(const int& index) const;
00069     int                         size(void) const;
00070     bool                        is_empty(void) const;
00071     GCTAOnOffObservation*       set(const int& index, const GCTAOnOffObservation& obs);
00072     GCTAOnOffObservation*       append(const GCTAOnOffObservation& obs);
00073     GCTAOnOffObservation*       insert(const int& index, const GCTAOnOffObservation& obs);
00074     void                        remove(const int& index);
00075     void                        reserve(const int& num);
00076     void                        extend(const GCTAOnOffObservations& obs);
00077     bool                        contains(const std::string& instrument,
00078                                          const std::string& id) const;
00079     void                        load(const GFilename& filename);
00080     void                        save(const GFilename& filename) const;
00081     void                        read(const GXml& xml);
00082     void                        write(GXml& xml) const;
00083     void                        models(const GModels& models);
00084     void                        models(const GFilename& filename);
00085     const GModels&              models(void) const; 
00086     std::string                 print(const GChatter& chatter = NORMAL) const;  
00087     
00088     /*
00089     // To do
00090     Implement fit functions for both cases summed over runs or not ? 
00091     Implement significance or have it at ctool level ?
00092     Implement flux points computation and fit of a spectral function ?  
00093     // Do we want that ? If yes, need to retrieve inline functions from GObservations...
00094     double              npred(void) const;  
00095     // Left aside at the moment
00096     void                          optimize(GOptimizer& opt);
00097      */
00098     
00099 protected:
00100     // Protected methods
00101     void init_members(void);
00102     void copy_members(const GCTAOnOffObservations& obs);
00103     void free_members(void);
00104     int  get_index(const std::string& instrument,
00105                    const std::string& id) const;
00106 
00107     // Protected members
00108     std::vector<GCTAOnOffObservation*> m_obs;    //!< List of observations
00109     GModels                            m_models; //!< List of models
00110 };
00111 
00112 
00113 /***********************************************************************//**
00114  * @brief Return class name
00115  *
00116  * @return String containing the class name ("GCTAOnOffObservations").
00117  ***************************************************************************/
00118 inline
00119 std::string GCTAOnOffObservations::classname(void) const
00120 {
00121     return ("GCTAOnOffObservations");
00122 }
00123 
00124 
00125 /***********************************************************************//**
00126  * @brief Return pointer to observation
00127  *
00128  * @param[in] index Observation index [0,...,size()-1].
00129  * @return Observation.
00130  *
00131  * Returns a pointer to the observation with specified @p index.
00132  ***************************************************************************/
00133 inline
00134 GCTAOnOffObservation* GCTAOnOffObservations::operator[](const int& index)
00135 {
00136     return m_obs[index];
00137 }
00138 
00139 
00140 /***********************************************************************//**
00141  * @brief Return pointer to observation (const version)
00142  *
00143  * @param[in] index Observation index [0,...,size()-1].
00144  *
00145  * Returns a const pointer to the observation with specified @p index.
00146  ***************************************************************************/
00147 inline
00148 const GCTAOnOffObservation* GCTAOnOffObservations::operator[](const int& index) const
00149 {
00150     return m_obs[index];
00151 }
00152 
00153 
00154 /***********************************************************************//**
00155  * @brief Return number of observations in container
00156  *
00157  * @return Number of observations in container.
00158  *
00159  * Returns the number of observations in the observation container.
00160  ***************************************************************************/
00161 inline
00162 int GCTAOnOffObservations::size(void) const
00163 {
00164     return (int)m_obs.size();
00165 }
00166 
00167 
00168 /***********************************************************************//**
00169  * @brief Signals if there are no observations in container
00170  *
00171  * @return True if container is empty, false otherwise.
00172  *
00173  * Signals if the observation container does not contain any observation.
00174  ***************************************************************************/
00175 inline
00176 bool GCTAOnOffObservations::is_empty(void) const
00177 {
00178     return (m_obs.empty());
00179 }
00180 
00181 
00182 /***********************************************************************//**
00183  * @brief Reserves space for observations in container
00184  *
00185  * @param[in] num Number of observations.
00186  *
00187  * Reserves space for @p num observations in the container.
00188  ***************************************************************************/
00189 inline
00190 void GCTAOnOffObservations::reserve(const int& num)
00191 {
00192     m_obs.reserve(num);
00193     return;
00194 }
00195 
00196 
00197 /***********************************************************************//**
00198  * @brief Set model container
00199  *
00200  * @param[in] models Model container.
00201  *
00202  * Sets the model container for the observations.
00203  ***************************************************************************/
00204 inline
00205 void GCTAOnOffObservations::models(const GModels& models)
00206 {
00207     m_models = models;
00208     return;
00209 }
00210 
00211 
00212 /***********************************************************************//**
00213  * @brief Return model container
00214  *
00215  * @return Model container.
00216  *
00217  * Returns the model container of the observations.
00218  ***************************************************************************/
00219 inline
00220 const GModels& GCTAOnOffObservations::models(void) const
00221 {
00222     return m_models;
00223 }
00224 
00225 #endif /* GCTAONOFFOBSERVATIONS_HPP */

Generated on Mon May 30 22:15:02 2016 for GammaLib by  doxygen 1.4.7