GammaLib
2.0.0
|
GCTAEventBin class interface definition. More...
#include <GCTAEventBin.hpp>
Public Member Functions | |
GCTAEventBin (void) | |
Void constructor. More... | |
GCTAEventBin (const GCTAEventBin &bin) | |
Copy constructor. More... | |
virtual | ~GCTAEventBin (void) |
Destructor. More... | |
virtual GCTAEventBin & | operator= (const GCTAEventBin &bin) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear eventbin. More... | |
virtual GCTAEventBin * | clone (void) const |
Clone event bin. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual double | size (void) const |
Return size of event bin. More... | |
virtual const GCTAInstDir & | 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 & | ipix (void) const |
Return the spatial pixel index. More... | |
const int & | ieng (void) const |
Return the energy layer index. More... | |
const double & | solidangle (void) const |
Return solid angle of event bin. More... | |
GEnergy | emin (void) const |
Return minimum energy of event bin. More... | |
GEnergy | emax (void) const |
Return maximum energy 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... | |
const double & | weight (void) const |
Return weight of event bin. More... | |
void | dir (const GCTAInstDir &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 | ipix (const int &ipix) |
Set the spatial pixel index. More... | |
void | ieng (const int &ieng) |
Set the energy layer index. 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... | |
void | weight (const double &weight) |
Set weight 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 GCTAEventBin &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_ipix |
Index in spatial map. More... | |
int | m_ieng |
Index of energy layer. More... | |
GCTAInstDir * | 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... | |
double * | m_weight |
Pointer to weight of bin. More... | |
Friends | |
class | GCTAEventCube |
GCTAEventBin class interface definition.
This class implements a CTA event bin. The event bin is a collection of pointers that points to the relevant information in memory. The class itself does not allocate any memory, it just is a vector to collect all relevant event information in a single place. This avoids duplication of information.
Setting up the pointers is done by the corresponding event bin container class (GCTAEventCube).
Definition at line 52 of file GCTAEventBin.hpp.
GCTAEventBin::GCTAEventBin | ( | void | ) |
Void constructor.
Definition at line 71 of file GCTAEventBin.cpp.
References init_members().
Referenced by clone().
GCTAEventBin::GCTAEventBin | ( | const GCTAEventBin & | bin | ) |
Copy constructor.
[in] | bin | Event bin. |
Definition at line 86 of file GCTAEventBin.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GEventBin.
Definition at line 125 of file GCTAEventBin.hpp.
|
virtual |
Clear eventbin.
Implements GEventBin.
Definition at line 157 of file GCTAEventBin.cpp.
References GEventBin::free_members(), GEvent::free_members(), free_members(), GEventBin::init_members(), GEvent::init_members(), and init_members().
Referenced by GCTAEventCube::init_members().
|
virtual |
Clone event bin.
Implements GEventBin.
Definition at line 179 of file GCTAEventBin.cpp.
References GCTAEventBin().
|
protected |
Copy class members.
[in] | bin | Event bin. |
Definition at line 736 of file GCTAEventBin.cpp.
References free_members(), m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_ieng, m_ipix, m_ontime, m_solidangle, m_time, and m_weight.
Referenced by GCTAEventBin(), and operator=().
|
virtual |
Return number of counts in event bin.
GException::invalid_value | Invalid counts pointer. |
Returns reference to the number of counts in the event bin.
Implements GEventBin.
Definition at line 288 of file GCTAEventBin.cpp.
References G_COUNTS_GET, and m_counts.
Referenced by counts(), error(), GCTACubeBackground::fill(), 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 543 of file GCTAEventBin.cpp.
References counts(), G_COUNTS_SET, and m_counts.
|
virtual |
Return instrument direction of event bin.
GException::invalid_value | Invalid instrument direction pointer encountered. |
Returns reference to the instrument direction of the event bin.
Implements GEventBin.
Definition at line 216 of file GCTAEventBin.cpp.
References G_DIR_GET, and m_dir.
Referenced by GCTAOnOffObservation::compute_arf(), dir(), GCTACubeBackground::fill(), GCTAResponseCube::irf_diffuse(), GCTAResponseCube::irf_elliptical(), GCTAResponseCube::irf_ptsrc(), and GCTAResponseCube::irf_radial().
void GCTAEventBin::dir | ( | const GCTAInstDir & | 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 465 of file GCTAEventBin.cpp.
|
inline |
Return maximum energy of event bin.
Returns the maximum energy of event bin.
Definition at line 199 of file GCTAEventBin.hpp.
GEnergy GCTAEventBin::emin | ( | void | ) | const |
Return minimum energy of event bin.
Returns minimum energy of event bin, computed using
\[ E_{\rm min} = \frac{-\Delta E + sqrt{\Delta E^2 + 4 E^2}}{2} \]
where \(\Delta E\) is the energy bin width, returned by ewidth() and \(E\) is the energy, returned by energy().
Definition at line 364 of file GCTAEventBin.cpp.
References energy(), ewidth(), GEnergy::MeV(), and sqrt().
Referenced by emax(), and GCTAModelIrfBackground::eval().
|
virtual |
Return energy of event bin.
GException::invalid_value | Invalid energy pointer encountered. |
Returns reference to the energy of the event bin.
Implements GEventBin.
Definition at line 240 of file GCTAEventBin.cpp.
References G_ENERGY, and m_energy.
Referenced by emin(), energy(), GCTACubeBackground::fill(), GCTAResponseCube::irf_diffuse(), GCTAResponseCube::irf_elliptical(), GCTAResponseCube::irf_ptsrc(), and GCTAResponseCube::irf_radial().
void GCTAEventBin::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 491 of file GCTAEventBin.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 315 of file GCTAEventBin.cpp.
const GEnergy & GCTAEventBin::ewidth | ( | void | ) | const |
Return energy width of event bin.
GException::invalid_value | Invalid energy width pointer encountered. |
Returns reference to the energy width of the event bin.
Definition at line 393 of file GCTAEventBin.cpp.
References G_EWIDTH, and m_ewidth.
Referenced by emax(), emin(), GCTAModelIrfBackground::eval(), ewidth(), and size().
void GCTAEventBin::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 595 of file GCTAEventBin.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 GCTAEventCube class), no memory is freed.
Definition at line 776 of file GCTAEventBin.cpp.
References m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_ontime, m_solidangle, m_time, and m_weight.
Referenced by clear(), copy_members(), GCTAEventCube::init_bin(), operator=(), and ~GCTAEventBin().
|
inline |
Return the energy layer index.
Returns the energy layer of the event bin in the event cube. If the event is not part of an event cube, -1 is returned.
Definition at line 170 of file GCTAEventBin.hpp.
References m_ieng.
Referenced by ieng(), and GCTAResponseCube::irf_spatial().
|
inline |
Set the energy layer index.
[in] | ieng | Energy layer index. |
Sets the energy layer of the event bin in the event cube.
Definition at line 184 of file GCTAEventBin.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.
< Not part of an event cube
< Not part of an event cube
Definition at line 701 of file GCTAEventBin.cpp.
References GCTAInstDir::clear(), GEnergy::clear(), GTime::clear(), m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_ieng, m_ipix, m_ontime, m_solidangle, m_time, and m_weight.
Referenced by clear(), GCTAEventBin(), and operator=().
|
inline |
Return the spatial pixel index.
Returns the spatial index of the event bin in the event cube. If the event is not part of an event cube, -1 is returned.
Definition at line 140 of file GCTAEventBin.hpp.
References m_ipix.
Referenced by ipix(), and GCTAResponseCube::irf_spatial().
|
inline |
Set the spatial pixel index.
[in] | ipix | Spatial pixel index. |
Sets the spatial index of the event bin in the event cube.
Definition at line 154 of file GCTAEventBin.hpp.
const double & GCTAEventBin::ontime | ( | void | ) | const |
Return ontime of event bin.
GException::invalid_value | Invalid ontime pointer encountered. |
Returns reference to the ontime of the event bin.
Definition at line 417 of file GCTAEventBin.cpp.
void GCTAEventBin::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 621 of file GCTAEventBin.cpp.
References G_ONTIME_SET, m_ontime, and ontime().
|
virtual |
Assignment operator.
[in] | bin | Event bin. |
Definition at line 124 of file GCTAEventBin.cpp.
References copy_members(), free_members(), init_members(), and GEventBin::operator=().
Print event information.
[in] | chatter | Chattiness. |
Implements GEventBin.
Definition at line 669 of file GCTAEventBin.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 \times W\]
where \(\Omega\) is the size of the spatial bin in sr, \(\Delta E\) is the size of the energy bin in MeV, \(\Delta T\) is the ontime of the observation in seconds, and \(W\) is the weight of the bin.
Implements GEventBin.
Definition at line 196 of file GCTAEventBin.cpp.
References ewidth(), GEnergy::MeV(), ontime(), solidangle(), and weight().
const double & GCTAEventBin::solidangle | ( | void | ) | const |
Return solid angle of event bin.
GException::invalid_value | Invalid solid angle pointer encountered. |
Returns reference to the solid angle of the event bin.
Definition at line 335 of file GCTAEventBin.cpp.
References G_SOLIDANGLE, and m_solidangle.
Referenced by size(), and solidangle().
void GCTAEventBin::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 569 of file GCTAEventBin.cpp.
References G_SOLIDANGLE_SET, m_solidangle, and solidangle().
|
virtual |
Return time of event bin.
GException::invalid_value | Invalid time pointer encountered. |
Returns reference to the time of the event bin.
Implements GEventBin.
Definition at line 264 of file GCTAEventBin.cpp.
References G_TIME, and m_time.
Referenced by GCTAResponseCube::irf_diffuse(), GCTAResponseCube::irf_elliptical(), GCTAResponseCube::irf_radial(), and time().
void GCTAEventBin::time | ( | const GTime & | time | ) |
Set time of event bin.
[in] | time | Time of event bin |
GException::invalid_value | No memory available to hold time. |
Sets the time of the event bin.
Definition at line 517 of file GCTAEventBin.cpp.
References G_TIME_SET, m_time, and time().
const double & GCTAEventBin::weight | ( | void | ) | const |
Return weight of event bin.
GException::invalid_value | Invalid weight pointer encountered. |
Returns reference to the weight of the event bin.
Definition at line 441 of file GCTAEventBin.cpp.
void GCTAEventBin::weight | ( | const double & | weight | ) |
Set weight of event bin.
[in] | weight | Weight angle of event bin |
GException::invalid_value | No memory available to hold weight. |
Sets the weight of the event bin.
Definition at line 647 of file GCTAEventBin.cpp.
References G_WEIGHT_SET, m_weight, and weight().
|
friend |
Definition at line 55 of file GCTAEventBin.hpp.
|
protected |
Signals proper memory allocation.
Definition at line 105 of file GCTAEventBin.hpp.
Referenced by copy_members(), free_members(), and init_members().
|
protected |
Pointer to number of counts.
Definition at line 112 of file GCTAEventBin.hpp.
Referenced by copy_members(), counts(), free_members(), init_members(), and GCTAEventCube::set_bin().
|
protected |
Pointer to bin direction.
Definition at line 108 of file GCTAEventBin.hpp.
Referenced by copy_members(), dir(), free_members(), init_members(), and GCTAEventCube::set_bin().
|
protected |
Pointer to bin energy.
Definition at line 110 of file GCTAEventBin.hpp.
Referenced by copy_members(), energy(), free_members(), init_members(), and GCTAEventCube::set_bin().
|
protected |
Pointer to energy width of bin.
Definition at line 111 of file GCTAEventBin.hpp.
Referenced by copy_members(), ewidth(), free_members(), init_members(), and GCTAEventCube::set_bin().
|
protected |
Index of energy layer.
Definition at line 107 of file GCTAEventBin.hpp.
Referenced by copy_members(), ieng(), init_members(), and GCTAEventCube::set_bin().
|
protected |
Index in spatial map.
Definition at line 106 of file GCTAEventBin.hpp.
Referenced by copy_members(), init_members(), ipix(), and GCTAEventCube::set_bin().
|
protected |
Pointer to ontime of bin (seconds)
Definition at line 114 of file GCTAEventBin.hpp.
Referenced by copy_members(), free_members(), GCTAEventCube::init_bin(), init_members(), and ontime().
|
protected |
Pointer to solid angle of pixel (sr)
Definition at line 113 of file GCTAEventBin.hpp.
Referenced by copy_members(), free_members(), init_members(), GCTAEventCube::set_bin(), and solidangle().
|
protected |
Pointer to bin time.
Definition at line 109 of file GCTAEventBin.hpp.
Referenced by copy_members(), free_members(), GCTAEventCube::init_bin(), init_members(), and time().
|
protected |
Pointer to weight of bin.
Definition at line 115 of file GCTAEventBin.hpp.
Referenced by copy_members(), free_members(), init_members(), GCTAEventCube::set_bin(), and weight().