GammaLib
2.0.0
|
COMPTEL event bin class. More...
#include <GCOMEventBin.hpp>
Public Member Functions | |
GCOMEventBin (void) | |
Void constructor. More... | |
GCOMEventBin (const GCOMEventBin &bin) | |
Copy constructor. More... | |
virtual | ~GCOMEventBin (void) |
Destructor. More... | |
virtual GCOMEventBin & | operator= (const GCOMEventBin &bin) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear instance. More... | |
virtual GCOMEventBin * | clone (void) const |
Clone instance. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual double | size (void) const |
Return size of event bin. More... | |
virtual const GCOMInstDir & | dir (void) const |
Return instrument direction of event bin. More... | |
virtual const GEnergy & | energy (void) const |
Return energy of event bin. More... | |
virtual const GTime & | time (void) const |
Return time of event bin. More... | |
virtual double | counts (void) const |
Return number of counts in event bin. More... | |
virtual double | error (void) const |
Return error in number of counts. More... | |
virtual void | counts (const double &counts) |
Set number of counts in event bin. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print event information. More... | |
const int & | index (void) const |
Return bin index. More... | |
const double & | solidangle (void) const |
Return solid angle of event bin. More... | |
const GEnergy & | ewidth (void) const |
Return energy width of event bin. More... | |
const double & | ontime (void) const |
Return ontime of event bin. More... | |
void | index (const int &index) |
Set bin index. More... | |
void | dir (const GCOMInstDir &dir) |
Set instrument direction of event bin. More... | |
void | energy (const GEnergy &energy) |
Set energy of event bin. More... | |
void | time (const GTime &time) |
Set time of event bin. More... | |
void | solidangle (const double &solidangle) |
Set solid angle of event bin. More... | |
void | ewidth (const GEnergy &ewidth) |
Set energy width of event bin. More... | |
void | ontime (const double &ontime) |
Set ontime of event bin. More... | |
Public Member Functions inherited from GEventBin | |
GEventBin (void) | |
Void constructor. More... | |
GEventBin (const GEventBin &bin) | |
Copy constructor. More... | |
virtual | ~GEventBin (void) |
Destructor. More... | |
virtual GEventBin & | operator= (const GEventBin &bin) |
Assignment operator. More... | |
bool | is_atom (void) const |
Signal if event is an atom. More... | |
bool | is_bin (void) const |
Signal if event is a bin. More... | |
Public Member Functions inherited from GEvent | |
GEvent (void) | |
Void constructor. More... | |
GEvent (const GEvent &event) | |
Copy constructor. More... | |
virtual | ~GEvent (void) |
Destructor. More... | |
virtual GEvent & | operator= (const GEvent &event) |
Assignment operator. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GCOMEventBin &bin) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from GEventBin | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEventBin &bin) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from GEvent | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEvent &event) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
bool | m_alloc |
Signals proper memory allocation. More... | |
int | m_index |
Dataspace index. More... | |
GCOMInstDir * | m_dir |
Pointer to bin direction. More... | |
GTime * | m_time |
Pointer to bin time. More... | |
GEnergy * | m_energy |
Pointer to bin energy. More... | |
GEnergy * | m_ewidth |
Pointer to energy width of bin. More... | |
double * | m_counts |
Pointer to number of counts. More... | |
double * | m_solidangle |
Pointer to solid angle of pixel (sr) More... | |
double * | m_ontime |
Pointer to ontime of bin (seconds) More... | |
Friends | |
class | GCOMEventCube |
COMPTEL event bin class.
This class defines an event bin of the COMPTEL data space. The class holds pointers to the bin attributes, and allocates memory so that all bin attributes have an associated memory space. With this technique, the class can be used to hold information that is external to GCOMEventBin. The GCOMEventCube class will use this property to directly manipulate the pointers of the bin.
Definition at line 49 of file GCOMEventBin.hpp.
GCOMEventBin::GCOMEventBin | ( | void | ) |
Void constructor.
Definition at line 68 of file GCOMEventBin.cpp.
References init_members().
Referenced by clone().
GCOMEventBin::GCOMEventBin | ( | const GCOMEventBin & | bin | ) |
Copy constructor.
[in] | bin | Event bin. |
Definition at line 83 of file GCOMEventBin.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GEventBin.
Definition at line 114 of file GCOMEventBin.hpp.
|
virtual |
Clear instance.
This method properly resets the instance to an initial state.
Implements GEventBin.
Definition at line 156 of file GCOMEventBin.cpp.
References free_members(), GEventBin::free_members(), GEvent::free_members(), init_members(), GEventBin::init_members(), and GEvent::init_members().
Referenced by GCOMEventCube::init_members().
|
virtual |
Clone instance.
Implements GEventBin.
Definition at line 178 of file GCOMEventBin.cpp.
References GCOMEventBin().
|
protected |
Copy class members.
[in] | bin | Event bin. |
Definition at line 642 of file GCOMEventBin.cpp.
References free_members(), m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_index, m_ontime, m_solidangle, and m_time.
Referenced by GCOMEventBin(), and operator=().
|
virtual |
Return number of counts in event bin.
GCTAException::invalid_value | Invalid counts pointer. |
Returns reference to the number of counts in the event bin.
Implements GEventBin.
Definition at line 285 of file GCOMEventBin.cpp.
References G_COUNTS_GET, and m_counts.
Referenced by counts(), GCOMObservation::drm(), error(), and print().
|
virtual |
Set number of counts in event bin.
[in] | counts | Number of counts. |
GException::invalid_value | No memory available to hold counts. |
Set the number of counts in the event bin.
Implements GEventBin.
Definition at line 478 of file GCOMEventBin.cpp.
References counts(), G_COUNTS_SET, and m_counts.
|
virtual |
Return instrument direction of event bin.
GException::invalid_value | Invalid instrument direction pointer. |
Returns reference to the instrument direction of the event bin.
Implements GEventBin.
Definition at line 216 of file GCOMEventBin.cpp.
References G_DIR_GET, and m_dir.
Referenced by dir(), GCOMModelDRBPhibarNodes::eval(), com_radial_kerns_omega::eval(), com_elliptical_kerns_omega::eval(), GCOMResponse::irf(), GCOMResponse::irf_diffuse(), GCOMResponse::irf_elliptical(), GCOMResponse::irf_ptsrc(), and GCOMResponse::irf_radial().
void GCOMEventBin::dir | ( | const GCOMInstDir & | dir | ) |
Set instrument direction of event bin.
[in] | dir | Instrument direction of event bin |
GException::invalid_value | No memory available to hold instrument direction. |
Sets the instrument direction of the event bin.
Definition at line 400 of file GCOMEventBin.cpp.
|
virtual |
Return energy of event bin.
GException::invalid_value | Invalid energy pointer. |
Returns reference to the energy of the event bin.
Implements GEventBin.
Definition at line 239 of file GCOMEventBin.cpp.
References G_ENERGY_GET, and m_energy.
Referenced by energy(), com_radial_kerns_rho::eval(), com_elliptical_kerns_omega::eval(), and GCOMResponse::irf_diffuse().
void GCOMEventBin::energy | ( | const GEnergy & | energy | ) |
Set energy of event bin.
[in] | energy | Energy of event bin |
GException::invalid_value | No memory available to hold energy. |
Sets the energy of the event bin.
Definition at line 426 of file GCOMEventBin.cpp.
References energy(), G_ENERGY_SET, and m_energy.
|
virtual |
Return error in number of counts.
Returns \(\sqrt(counts+delta)\) as the uncertainty in the number of counts in the bin. Adding delta avoids uncertainties of 0 which will lead in the optimisation step to the exlusion of the corresponding bin. In the actual implementation delta=1e-50.
Implements GEventBin.
Definition at line 311 of file GCOMEventBin.cpp.
const GEnergy & GCOMEventBin::ewidth | ( | void | ) | const |
Return energy width of event bin.
GException::invalid_value | Invalid energy width pointer. |
Returns reference to the energy width of the event bin.
Definition at line 354 of file GCOMEventBin.cpp.
References G_EWIDTH_GET, and m_ewidth.
void GCOMEventBin::ewidth | ( | const GEnergy & | ewidth | ) |
Set energy width of event bin.
[in] | ewidth | Energy width of event bin |
GException::invalid_value | No memory available to hold energy width. |
Sets the energy width of the event bin.
Definition at line 530 of file GCOMEventBin.cpp.
References ewidth(), G_EWIDTH_SET, and m_ewidth.
|
protected |
Delete class members.
This method frees all memory of the class attributes and sets the member pointers to NULL. This method should only be called if new memory is allocated immediately afterwards (for example by cloning another event bin), or upon destruction of the object.
Note that some logic has been implemented that frees only memory that also has indeed been allocated by the class. Thus if the class only serves as container to hold memory pointer allocated by someone else (for example the GCOMEventCube class), no memory is freed.
Definition at line 680 of file GCOMEventBin.cpp.
References m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_ontime, m_solidangle, and m_time.
Referenced by clear(), copy_members(), GCOMEventCube::init_bin(), operator=(), and ~GCOMEventBin().
|
inline |
Return bin index.
Returns the index of the event bin if the bin is part of an event cube. If the event is not part of an event cube, -1 is returned.
Definition at line 129 of file GCOMEventBin.hpp.
References m_index.
Referenced by GCOMModelDRM::eval(), GCOMModelDRBPhibarBins::eval(), GCOMModelDRBPhibarNodes::eval(), and index().
|
inline |
Set bin index.
[in] | index | Bin index. |
Set the index of the event bin if the bin is part of an event cube. If the event is not part of an event cube the index should be set to -1.
Definition at line 144 of file GCOMEventBin.hpp.
|
protected |
Initialise class members.
This method allocates memory for all event bin attributes and intialises the attributes to well defined initial values.
The method assumes that on entry no memory is hold by the member pointers.
Definition at line 610 of file GCOMEventBin.cpp.
References GCOMInstDir::clear(), GEnergy::clear(), GTime::clear(), m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_index, m_ontime, m_solidangle, and m_time.
Referenced by clear(), GCOMEventBin(), and operator=().
const double & GCOMEventBin::ontime | ( | void | ) | const |
Return ontime of event bin.
GException::invalid_value | Invalid ontime pointer. |
Returns reference to the ontime of the event bin.
Definition at line 377 of file GCOMEventBin.cpp.
References G_ONTIME_GET, and m_ontime.
void GCOMEventBin::ontime | ( | const double & | ontime | ) |
Set ontime of event bin.
[in] | ontime | Ontime of event bin (sec). |
GException::invalid_value | No memory available to hold ontime. |
Sets the ontime of the event bin.
Definition at line 556 of file GCOMEventBin.cpp.
References G_ONTIME_SET, m_ontime, and ontime().
|
virtual |
Assignment operator.
[in] | bin | Event bin. |
Definition at line 121 of file GCOMEventBin.cpp.
References copy_members(), free_members(), init_members(), and GEventBin::operator=().
Print event information.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GEventBin.
Definition at line 578 of file GCOMEventBin.cpp.
References counts(), SILENT, and gammalib::str().
|
virtual |
Return size of event bin.
The size of the event bin (units: sr MeV s) is given by
\[size = \Omega \times \Delta E \times \Delta T\]
where \(\Omega\) is the size of the spatial bin in sr, \(\Delta E\) is the size of the energy bin in MeV, and \(\Delta T\) is the ontime of the observation in seconds.
Implements GEventBin.
Definition at line 196 of file GCOMEventBin.cpp.
References ewidth(), GEnergy::MeV(), ontime(), and solidangle().
Referenced by GCOMObservation::drm(), GCOMModelDRM::eval(), GCOMModelDRBPhibarBins::eval(), and GCOMModelDRBPhibarNodes::eval().
const double & GCOMEventBin::solidangle | ( | void | ) | const |
Return solid angle of event bin.
GException::invalid_value | Invalid solid angle pointer. |
Returns reference to the solid angle of the event bin.
Definition at line 331 of file GCOMEventBin.cpp.
References G_SOLIDANGLE_GET, and m_solidangle.
Referenced by size(), and solidangle().
void GCOMEventBin::solidangle | ( | const double & | solidangle | ) |
Set solid angle of event bin.
[in] | solidangle | Solid angle of event bin |
GException::invalid_value | No memory available to hold solid angle. |
Sets the solid angle of the event bin.
Definition at line 504 of file GCOMEventBin.cpp.
References G_SOLIDANGLE_SET, m_solidangle, and solidangle().
|
virtual |
Return time of event bin.
GException::invalid_value | Invalid time pointer. |
Returns reference to the time of the event bin.
Implements GEventBin.
Definition at line 262 of file GCOMEventBin.cpp.
References G_TIME_GET, m_energy, and m_time.
Referenced by com_radial_kerns_rho::eval(), com_elliptical_kerns_omega::eval(), GCOMResponse::irf_diffuse(), and time().
void GCOMEventBin::time | ( | const GTime & | time | ) |
Set time of event bin.
[in] | time | Time of event bin |
GException::invalid_value | No memory available to hold instrument direction. |
Sets the time of the event bin.
Definition at line 452 of file GCOMEventBin.cpp.
References G_TIME_SET, m_time, and time().
|
friend |
Definition at line 52 of file GCOMEventBin.hpp.
|
protected |
Signals proper memory allocation.
Definition at line 96 of file GCOMEventBin.hpp.
Referenced by copy_members(), free_members(), and init_members().
|
protected |
Pointer to number of counts.
Definition at line 102 of file GCOMEventBin.hpp.
Referenced by copy_members(), counts(), free_members(), GCOMEventCube::init_bin(), init_members(), and GCOMEventCube::set_bin().
|
protected |
Pointer to bin direction.
Definition at line 98 of file GCOMEventBin.hpp.
Referenced by copy_members(), dir(), free_members(), GCOMEventCube::init_bin(), and init_members().
|
protected |
Pointer to bin energy.
Definition at line 100 of file GCOMEventBin.hpp.
Referenced by copy_members(), energy(), free_members(), GCOMEventCube::init_bin(), init_members(), and time().
|
protected |
Pointer to energy width of bin.
Definition at line 101 of file GCOMEventBin.hpp.
Referenced by copy_members(), ewidth(), free_members(), GCOMEventCube::init_bin(), and init_members().
|
protected |
Dataspace index.
Definition at line 97 of file GCOMEventBin.hpp.
Referenced by copy_members(), index(), init_members(), and GCOMEventCube::set_bin().
|
protected |
Pointer to ontime of bin (seconds)
Definition at line 104 of file GCOMEventBin.hpp.
Referenced by copy_members(), free_members(), GCOMEventCube::init_bin(), init_members(), and ontime().
|
protected |
Pointer to solid angle of pixel (sr)
Definition at line 103 of file GCOMEventBin.hpp.
Referenced by copy_members(), free_members(), GCOMEventCube::init_bin(), init_members(), GCOMEventCube::set_bin(), and solidangle().
|
protected |
Pointer to bin time.
Definition at line 99 of file GCOMEventBin.hpp.
Referenced by copy_members(), free_members(), GCOMEventCube::init_bin(), init_members(), and time().