Commit 4e68eef58bc386d716c79dcc2a5e7e6e1350954b
1 parent
acbc0e16
enhance interface for full model handling
Showing
3 changed files
with
88 additions
and
49 deletions
include/GEvent.hpp
| ... | ... | @@ -22,15 +22,35 @@ |
| 22 | 22 | /* __ Includes ___________________________________________________________ */ |
| 23 | 23 | #include "GModels.hpp" |
| 24 | 24 | #include "GVector.hpp" |
| 25 | -#include "GSkyDir.hpp" | |
| 25 | +#include "GInstDir.hpp" | |
| 26 | 26 | #include "GEnergy.hpp" |
| 27 | 27 | #include "GTime.hpp" |
| 28 | +#include "GPointing.hpp" | |
| 29 | +#include "GResponse.hpp" | |
| 28 | 30 | |
| 29 | 31 | |
| 30 | 32 | /***********************************************************************//** |
| 31 | 33 | * @class GEvent |
| 32 | 34 | * |
| 33 | 35 | * @brief Abstract interface for the event classes. |
| 36 | + * | |
| 37 | + * This class provides an abstract interface to a event. A event can be | |
| 38 | + * either a physical event occuring in the instrument (called an event | |
| 39 | + * atom) or a collection of events with similar properties (called an | |
| 40 | + * event bin). While event atoms are used for unbinned analysis, event bins | |
| 41 | + * are used for binned analysis. The methods isatom() and isbin() inform | |
| 42 | + * whether an event is either an atom or a bin. | |
| 43 | + * The counts() method returns the number of event atoms in a event bin. | |
| 44 | + * For an event atom, this method returns by definition 1. | |
| 45 | + * The model() methods returns either the probability for an event atom | |
| 46 | + * to occur (unbinned analysis) or the expected number of counts for an | |
| 47 | + * event bin (binned analysis). | |
| 48 | + * Attributes of an event atom or bin can be accessed through the dir(), | |
| 49 | + * energy(), time(), pnt(), rsp() methods that all return const pointers | |
| 50 | + * to the relevant information. | |
| 51 | + * | |
| 52 | + * This method does not hold any data members. Data members are stored in | |
| 53 | + * the derived classes. | |
| 34 | 54 | ***************************************************************************/ |
| 35 | 55 | class GEvent { |
| 36 | 56 | |
| ... | ... | @@ -39,24 +59,24 @@ class GEvent { |
| 39 | 59 | |
| 40 | 60 | public: |
| 41 | 61 | // Constructors and destructors |
| 42 | - GEvent(); | |
| 62 | + GEvent(void); | |
| 43 | 63 | GEvent(const GEvent& event); |
| 44 | - virtual ~GEvent(); | |
| 64 | + virtual ~GEvent(void); | |
| 45 | 65 | |
| 46 | 66 | // Operators |
| 47 | 67 | virtual GEvent& operator= (const GEvent& event); |
| 48 | 68 | |
| 49 | 69 | // Virtual methods |
| 50 | - virtual double counts(void) const = 0; | |
| 51 | - virtual double model(GModels& models) = 0; | |
| 52 | - virtual double model(GModels& models, GVector* gradient) = 0; | |
| 53 | - virtual GSkyDir* dir(void) = 0; | |
| 54 | - virtual GEnergy* energy(void) = 0; | |
| 55 | - virtual GTime* time(void) = 0; | |
| 56 | - virtual bool isatom(void) const = 0; | |
| 57 | - virtual bool isbin(void) const = 0; | |
| 58 | - | |
| 59 | - // Implemented methods | |
| 70 | + virtual bool isatom(void) const = 0; | |
| 71 | + virtual bool isbin(void) const = 0; | |
| 72 | + virtual double counts(void) const = 0; | |
| 73 | + virtual double model(GModels& models) = 0; | |
| 74 | + virtual double model(GModels& models, GVector* gradient) = 0; | |
| 75 | + virtual const GInstDir* dir(void) const = 0; | |
| 76 | + virtual const GEnergy* energy(void) const = 0; | |
| 77 | + virtual const GTime* time(void) const = 0; | |
| 78 | + virtual const GPointing* pnt(void) const = 0; | |
| 79 | + virtual const GResponse* rsp(void) const = 0; | |
| 60 | 80 | |
| 61 | 81 | protected: |
| 62 | 82 | // Protected methods |
| ... | ... | @@ -65,8 +85,6 @@ protected: |
| 65 | 85 | void free_members(void); |
| 66 | 86 | virtual GEvent* clone(void) const = 0; |
| 67 | 87 | |
| 68 | - // Protected data area | |
| 69 | - | |
| 70 | 88 | private: |
| 71 | 89 | }; |
| 72 | 90 | ... | ... |
include/GEventAtom.hpp
| ... | ... | @@ -21,46 +21,50 @@ |
| 21 | 21 | |
| 22 | 22 | /* __ Includes ___________________________________________________________ */ |
| 23 | 23 | #include "GEvent.hpp" |
| 24 | -#include "GTime.hpp" | |
| 25 | -#include "GEnergy.hpp" | |
| 26 | -#include "GSkyDir.hpp" | |
| 27 | 24 | #include "GModels.hpp" |
| 28 | 25 | #include "GVector.hpp" |
| 26 | +#include "GEnergy.hpp" | |
| 27 | +#include "GTime.hpp" | |
| 29 | 28 | |
| 30 | 29 | |
| 31 | 30 | /***********************************************************************//** |
| 32 | 31 | * @class GEventAtom |
| 33 | 32 | * |
| 34 | - * @brief Abstract interface for the event atom class | |
| 33 | + * @brief Abstract interface for the event atom class. | |
| 34 | + * | |
| 35 | + * An event atom is a single event occuring in an instrument. It has two | |
| 36 | + * generic attributes (m_time and m_energy) that can be access via the | |
| 37 | + * energy() and time() methods (both methods return constant pointers). | |
| 38 | + * Furthermore, the counts() method returns the number of atoms in the event, | |
| 39 | + * which by definition is 1. | |
| 35 | 40 | ***************************************************************************/ |
| 36 | 41 | class GEventAtom : public GEvent { |
| 37 | 42 | |
| 38 | 43 | // Friend classes |
| 39 | 44 | friend class GEvents; |
| 40 | 45 | |
| 41 | - // I/O friends | |
| 42 | - friend std::ostream& operator<< (std::ostream& os, const GEventAtom& atom); | |
| 43 | - | |
| 44 | 46 | public: |
| 45 | 47 | // Constructors and destructors |
| 46 | - GEventAtom(); | |
| 48 | + GEventAtom(void); | |
| 47 | 49 | GEventAtom(const GEventAtom& atom); |
| 48 | - virtual ~GEventAtom(); | |
| 50 | + virtual ~GEventAtom(void); | |
| 49 | 51 | |
| 50 | 52 | // Operators |
| 51 | 53 | virtual GEventAtom& operator= (const GEventAtom& atom); |
| 52 | 54 | |
| 53 | - // Virtual methods | |
| 54 | - virtual double model(GModels& models) = 0; | |
| 55 | - virtual double model(GModels& models, GVector* gradient) = 0; | |
| 55 | + // Pure virtual methods | |
| 56 | + virtual double model(GModels& models) = 0; | |
| 57 | + virtual double model(GModels& models, GVector* gradient) = 0; | |
| 58 | + virtual const GInstDir* dir(void) const = 0; | |
| 59 | + virtual const GPointing* pnt(void) const = 0; | |
| 60 | + virtual const GResponse* rsp(void) const = 0; | |
| 56 | 61 | |
| 57 | 62 | // Implemented methods |
| 58 | - double counts(void) const { return 1.0; } | |
| 59 | - GSkyDir* dir(void) { return &m_dir; } | |
| 60 | - GEnergy* energy(void) { return &m_energy; } | |
| 61 | - GTime* time(void) { return &m_time; } | |
| 62 | - bool isatom(void) const { return true; } | |
| 63 | - bool isbin(void) const { return false; } | |
| 63 | + bool isatom(void) const { return true; } | |
| 64 | + bool isbin(void) const { return false; } | |
| 65 | + double counts(void) const { return 1.0; } | |
| 66 | + const GEnergy* energy(void) const { return &m_energy; } | |
| 67 | + const GTime* time(void) const { return &m_time; } | |
| 64 | 68 | |
| 65 | 69 | protected: |
| 66 | 70 | // Protected methods |
| ... | ... | @@ -70,9 +74,8 @@ protected: |
| 70 | 74 | virtual GEventAtom* clone(void) const = 0; |
| 71 | 75 | |
| 72 | 76 | // Protected data area |
| 73 | - GTime m_time; //!< Event time | |
| 74 | - GEnergy m_energy; //!< Event energy | |
| 75 | - GSkyDir m_dir; //!< Arrivial direction | |
| 77 | + GTime m_time; //!< Event time | |
| 78 | + GEnergy m_energy; //!< Event energy | |
| 76 | 79 | |
| 77 | 80 | private: |
| 78 | 81 | }; | ... | ... |
include/GEventBin.hpp
| ... | ... | @@ -23,15 +23,28 @@ |
| 23 | 23 | #include "GEvent.hpp" |
| 24 | 24 | #include "GModels.hpp" |
| 25 | 25 | #include "GVector.hpp" |
| 26 | -#include "GSkyDir.hpp" | |
| 27 | 26 | #include "GEnergy.hpp" |
| 28 | 27 | #include "GTime.hpp" |
| 28 | +#include "GInstDir.hpp" | |
| 29 | +#include "GPointing.hpp" | |
| 30 | +#include "GResponse.hpp" | |
| 29 | 31 | |
| 30 | 32 | |
| 31 | 33 | /***********************************************************************//** |
| 32 | 34 | * @class GEventBin |
| 33 | 35 | * |
| 34 | - * @brief Abstract interface for the event bin class | |
| 36 | + * @brief Abstract interface for the event bin class. | |
| 37 | + * | |
| 38 | + * An event bin is a collection of event atoms with similar properties. | |
| 39 | + * It has three generic attributes (m_counts, m_time and m_energy) that can | |
| 40 | + * be accessed through the counts(), energy() and time() methods. The | |
| 41 | + * counts() method returns a double precision value, while the energy() and | |
| 42 | + * time() methods return const pointers. | |
| 43 | + * | |
| 44 | + * The event bin class does not actually allocate memory for event bins | |
| 45 | + * but handles pointers that point the information that is relevant for | |
| 46 | + * analysis. Filling of the information is handled by the pointer() method of | |
| 47 | + * the corresponding event cube. | |
| 35 | 48 | ***************************************************************************/ |
| 36 | 49 | class GEventBin : public GEvent { |
| 37 | 50 | |
| ... | ... | @@ -40,24 +53,26 @@ class GEventBin : public GEvent { |
| 40 | 53 | |
| 41 | 54 | public: |
| 42 | 55 | // Constructors and destructors |
| 43 | - GEventBin(); | |
| 56 | + GEventBin(void); | |
| 44 | 57 | GEventBin(const GEventBin& bin); |
| 45 | - virtual ~GEventBin(); | |
| 58 | + virtual ~GEventBin(void); | |
| 46 | 59 | |
| 47 | 60 | // Operators |
| 48 | 61 | virtual GEventBin& operator= (const GEventBin& bin); |
| 49 | 62 | |
| 50 | - // Virtual methods | |
| 51 | - virtual double counts(void) const = 0; | |
| 52 | - virtual double model(GModels& models) = 0; | |
| 53 | - virtual double model(GModels& models, GVector* gradient) = 0; | |
| 54 | - virtual GSkyDir* dir(void) = 0; | |
| 55 | - virtual GEnergy* energy(void) = 0; | |
| 56 | - virtual GTime* time(void) = 0; | |
| 63 | + // Pure virtual methods | |
| 64 | + virtual double model(GModels& models) = 0; | |
| 65 | + virtual double model(GModels& models, GVector* gradient) = 0; | |
| 66 | + virtual const GInstDir* dir(void) const = 0; | |
| 67 | + virtual const GPointing* pnt(void) const = 0; | |
| 68 | + virtual const GResponse* rsp(void) const = 0; | |
| 57 | 69 | |
| 58 | 70 | // Implemented methods |
| 59 | - bool isatom(void) const { return false; } | |
| 60 | - bool isbin(void) const { return true; } | |
| 71 | + bool isatom(void) const { return false; } | |
| 72 | + bool isbin(void) const { return true; } | |
| 73 | + double counts(void) const { return *m_counts; } | |
| 74 | + const GEnergy* energy(void) const { return m_energy; } | |
| 75 | + const GTime* time(void) const { return m_time; } | |
| 61 | 76 | |
| 62 | 77 | protected: |
| 63 | 78 | // Protected methods |
| ... | ... | @@ -67,6 +82,9 @@ protected: |
| 67 | 82 | virtual GEventBin* clone(void) const = 0; |
| 68 | 83 | |
| 69 | 84 | // Protected data area |
| 85 | + double* m_counts; //!< Pointer to number of counts | |
| 86 | + GTime* m_time; //!< Pointer to bin time | |
| 87 | + GEnergy* m_energy; //!< Pointer to bin energy | |
| 70 | 88 | |
| 71 | 89 | private: |
| 72 | 90 | }; | ... | ... |