|
GammaLib 2.2.0.dev
|
COSI event bin class. More...
#include <GCOSEventBin.hpp>
Public Member Functions | |
| GCOSEventBin (void) | |
| Void constructor. | |
| GCOSEventBin (const GCOSEventBin &bin) | |
| Copy constructor. | |
| virtual | ~GCOSEventBin (void) |
| Destructor. | |
| virtual GCOSEventBin & | operator= (const GCOSEventBin &bin) |
| Assignment operator. | |
| virtual void | clear (void) |
| Clear COSI event bin. | |
| virtual GCOSEventBin * | clone (void) const |
| Clone event bin. | |
| virtual std::string | classname (void) const |
| Return class name. | |
| virtual double | size (void) const |
| Return size of event bin. | |
| virtual const GCOSInstDir & | dir (void) const |
| Return instrument direction of event bin. | |
| virtual const GEnergy & | energy (void) const |
| Return energy of event bin. | |
| virtual const GTime & | time (void) const |
| Return time of event bin. | |
| virtual double | counts (void) const |
| Return number of counts in event bin. | |
| virtual double | error (void) const |
| Return error in number of counts. | |
| virtual void | counts (const double &counts) |
| Set number of counts in event bin. | |
| virtual std::string | print (const GChatter &chatter=NORMAL) const |
| Print event information. | |
| const int & | index (void) const |
| Return bin index. | |
| double | chi (void) const |
| Return Galactic longitude of event bin scatter direction Chi. | |
| double | psi (void) const |
| Return Galactic longitude of event bin scatter direction Psi. | |
| const double & | phi (void) const |
| Return event bin scatter angle Phi. | |
| const double & | solidangle (void) const |
| Return solid angle of event bin. | |
| const double & | phiwidth (void) const |
| Return Phi width of event bin. | |
| const GEnergy & | ewidth (void) const |
| Return energy width of event bin. | |
| const double & | ontime (void) const |
| Return ontime of event bin. | |
| void | index (const int &index) |
| Set bin index. | |
| void | dir (const GCOSInstDir &dir) |
| Set instrument direction of event bin. | |
| void | dir (const double &chi, const double &psi, const double &phi) |
| Set Chi, Psi and Phi of event bin. | |
| void | energy (const GEnergy &energy) |
| Set energy of event bin. | |
| void | time (const GTime &time) |
| Set time of event bin. | |
| void | solidangle (const double &solidangle) |
| Set solid angle of event bin. | |
| void | phiwidth (const double &phiwidth) |
| Set Phi width of event bin. | |
| void | ewidth (const GEnergy &ewidth) |
| Set energy width of event bin. | |
| void | ontime (const double &ontime) |
| Set ontime of event bin. | |
Public Member Functions inherited from GEventBin | |
| GEventBin (void) | |
| Void constructor. | |
| GEventBin (const GEventBin &bin) | |
| Copy constructor. | |
| virtual | ~GEventBin (void) |
| Destructor. | |
| virtual GEventBin & | operator= (const GEventBin &bin) |
| Assignment operator. | |
| bool | is_atom (void) const |
| Signal if event is an atom. | |
| bool | is_bin (void) const |
| Signal if event is a bin. | |
Public Member Functions inherited from GEvent | |
| GEvent (void) | |
| Void constructor. | |
| GEvent (const GEvent &event) | |
| Copy constructor. | |
| virtual | ~GEvent (void) |
| Destructor. | |
| virtual GEvent & | operator= (const GEvent &event) |
| Assignment operator. | |
Public Member Functions inherited from GBase | |
| virtual | ~GBase (void) |
| Destructor. | |
Protected Member Functions | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GCOSEventBin &bin) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
Protected Member Functions inherited from GEventBin | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GEventBin &bin) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
Protected Member Functions inherited from GEvent | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GEvent &event) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
Protected Attributes | |
| bool | m_alloc |
| Signals proper memory allocation. | |
| int | m_index |
| Dataspace index. | |
| double * | m_counts |
| Pointer to number of counts. | |
| GCOSInstDir * | m_dir |
| Pointer to bin direction. | |
| double * | m_solidangle |
| Pointer to solid angle of pixel (sr) | |
| GTime * | m_time |
| Pointer to bin time. | |
| double * | m_ontime |
| Pointer to ontime of bin (seconds) | |
| double * | m_phiwidth |
| Pointer to Phi width. | |
| GEnergy * | m_energy |
| Pointer to bin energy. | |
| GEnergy * | m_ewidth |
| Pointer to energy width of bin. | |
Friends | |
| class | GCOSEventCube |
COSI event bin class.
This class defines an event bin of the COSI event cube.
Since many event bins share the same attributes (for example many bins will actually have the same energy), it would be a waste of memory to store all bin attributes together with the bin. Therefore, the GCOSEventBin class implements it's own memory management. Either the class allocates memory for all attributes, or it takes pointers to GCOSEventCube class members that store the information in an efficient way.
The data member m_alloc signals in which mode the bin operates. If true, GCOSEventBin has allocated itself the memory for all attributes, and hence has to take care about the memory allocation upon destruction. Otherwise the pointers are just released.
Definition at line 61 of file GCOSEventBin.hpp.
| GCOSEventBin::GCOSEventBin | ( | void | ) |
Void constructor.
Creates an empty COSI event bin.
Definition at line 76 of file GCOSEventBin.cpp.
References init_members().
Referenced by clone().
| GCOSEventBin::GCOSEventBin | ( | const GCOSEventBin & | bin | ) |
Copy constructor.
| [in] | bin | COSI event bin. |
Definition at line 91 of file GCOSEventBin.cpp.
References copy_members(), and init_members().
|
virtual |
| double GCOSEventBin::chi | ( | void | ) | const |
Return Galactic longitude of event bin scatter direction Chi.
| GException::invalid_value | Invalid instrument direction pointer. |
Returns Galactic longitude of event bin scatter direction Chi in degrees.
Definition at line 249 of file GCOSEventBin.cpp.
References GCOSInstDir::dir(), G_CHI_GET, and m_dir.
Referenced by dir().
|
inlinevirtual |
Return class name.
Implements GEventBin.
Definition at line 133 of file GCOSEventBin.hpp.
|
virtual |
Clear COSI event bin.
Clears COSI event bin by resetting all class members to an initial state. Any information that was present before will be lost.
Implements GEventBin.
Definition at line 165 of file GCOSEventBin.cpp.
References free_members(), GEvent::free_members(), GEventBin::free_members(), init_members(), GEvent::init_members(), and GEventBin::init_members().
Referenced by GCOSEventCube::init_members().
|
virtual |
Clone event bin.
Implements GEventBin.
Definition at line 187 of file GCOSEventBin.cpp.
References GCOSEventBin().
|
protected |
Copy class members.
| [in] | bin | COSI event bin. |
Definition at line 823 of file GCOSEventBin.cpp.
References free_members(), m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_index, m_ontime, m_phiwidth, m_solidangle, and m_time.
Referenced by GCOSEventBin(), and operator=().
|
virtual |
Set number of counts in event bin.
| [in] | counts | Number of counts. |
| GException::invalid_value | No memory allocated to store counts. |
Set the number of counts in the event bin.
Implements GEventBin.
Definition at line 629 of file GCOSEventBin.cpp.
References counts(), G_COUNTS_SET, and m_counts.
|
virtual |
Return number of counts in event bin.
| GCTAException::invalid_value | Invalid counts pointer. |
Returns the number of counts in the event bin.
Implements GEventBin.
Definition at line 369 of file GCOSEventBin.cpp.
References G_COUNTS_GET, and m_counts.
| void GCOSEventBin::dir | ( | const double & | chi, |
| const double & | psi, | ||
| const double & | phi ) |
Set Chi, Psi and Phi of event bin.
| [in] | chi | Galactic longitude of scatter direction Chi (deg). |
| [in] | psi | Galactic longitude of scatter direction Psi (deg). |
| [in] | phi | Scatter angle Phi (deg). |
| GException::invalid_value | No memory allocated to hold Chi, Psi and Phi values. |
Sets the scatter direction and scatter angle of the event bin.
Note that this method does not set the scatter direction in local coordinates. Use the dir(GCOSInstDir&) method to also set the scatter direction in local coordinates.
Definition at line 545 of file GCOSEventBin.cpp.
References chi(), dir(), GCOSInstDir::dir(), G_DIR_SET2, m_dir, phi(), GCOSInstDir::phi(), and psi().
| void GCOSEventBin::dir | ( | const GCOSInstDir & | dir | ) |
Set instrument direction of event bin.
| [in] | dir | Instrument direction of event bin. |
| GException::invalid_value | No memory allocated to hold instrument direction. |
Sets the instrument direction of the event bin.
Definition at line 512 of file GCOSEventBin.cpp.
References dir(), G_DIR_SET1, and m_dir.
|
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 225 of file GCOSEventBin.cpp.
| void GCOSEventBin::energy | ( | const GEnergy & | energy | ) |
Set energy of event bin.
| [in] | energy | Energy of event bin. |
| GException::invalid_value | No memory allocated to store the energy. |
Sets the energy of the event bin.
Definition at line 577 of file GCOSEventBin.cpp.
References energy(), G_ENERGY_SET, and m_energy.
|
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 321 of file GCOSEventBin.cpp.
References G_ENERGY_GET, and m_energy.
Referenced by 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 396 of file GCOSEventBin.cpp.
References counts(), and error().
Referenced by error().
| void GCOSEventBin::ewidth | ( | const GEnergy & | ewidth | ) |
Set energy width of event bin.
| [in] | ewidth | Energy width of event bin. |
| GException::invalid_value | No memory allocated to store energy width. |
Sets the energy width of the event bin.
Definition at line 708 of file GCOSEventBin.cpp.
References ewidth(), G_EWIDTH_SET, and m_ewidth.
| const GEnergy & GCOSEventBin::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 464 of file GCOSEventBin.cpp.
References G_EWIDTH_GET, 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 GCOSEventCube class), no memory is freed.
Definition at line 862 of file GCOSEventBin.cpp.
References m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_ontime, m_phiwidth, m_solidangle, and m_time.
Referenced by clear(), copy_members(), GCOSEventCube::init_bin(), operator=(), and ~GCOSEventBin().
|
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 163 of file GCOSEventBin.hpp.
|
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 148 of file GCOSEventBin.hpp.
References m_index.
Referenced by index().
|
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 789 of file GCOSEventBin.cpp.
References GCOSInstDir::clear(), GEnergy::clear(), GTime::clear(), m_alloc, m_counts, m_dir, m_energy, m_ewidth, m_index, m_ontime, m_phiwidth, m_solidangle, and m_time.
Referenced by clear(), GCOSEventBin(), GCOSEventBin(), and operator=().
| void GCOSEventBin::ontime | ( | const double & | ontime | ) |
Set ontime of event bin.
| [in] | ontime | Ontime of event bin (sec). |
| GException::invalid_value | No memory allocated to store ontime. |
Sets the ontime of the event bin.
Definition at line 735 of file GCOSEventBin.cpp.
References G_ONTIME_SET, m_ontime, and ontime().
| const double & GCOSEventBin::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 488 of file GCOSEventBin.cpp.
References G_ONTIME_GET, and m_ontime.
|
virtual |
Assignment operator.
| [in] | bin | COSI event bin. |
Definition at line 129 of file GCOSEventBin.cpp.
References copy_members(), free_members(), init_members(), and GEventBin::operator=().
| const double & GCOSEventBin::phi | ( | void | ) | const |
Return event bin scatter angle Phi.
| GException::invalid_value | Invalid instrument direction pointer. |
Returns Galactic longitude of event bin scatter angle Phi in degrees.
Definition at line 297 of file GCOSEventBin.cpp.
References G_PHI_GET, m_dir, and GCOSInstDir::phi().
Referenced by dir().
| void GCOSEventBin::phiwidth | ( | const double & | phiwidth | ) |
Set Phi width of event bin.
| [in] | phiwidth | Energy width of event bin (deg). |
| GException::invalid_value | No memory allocated to store Phi width. |
Sets the Phi width of the event bin.
Definition at line 682 of file GCOSEventBin.cpp.
References G_PHIWIDTH_SET, m_phiwidth, and phiwidth().
| const double & GCOSEventBin::phiwidth | ( | void | ) | const |
Return Phi width of event bin.
| GException::invalid_value | Invalid Phi width pointer. |
Returns reference to the Phi width of the event bin.
Definition at line 440 of file GCOSEventBin.cpp.
References G_PHIWIDTH_GET, and m_phiwidth.
Referenced by phiwidth().
Print event information.
| [in] | chatter | Chattiness. |
Implements GEventBin.
Definition at line 757 of file GCOSEventBin.cpp.
References counts(), SILENT, and gammalib::str().
| double GCOSEventBin::psi | ( | void | ) | const |
Return Galactic longitude of event bin scatter direction Psi.
| GException::invalid_value | Invalid instrument direction pointer. |
Returns Galactic longitude of event bin scatter direction Psi in degrees.
Definition at line 273 of file GCOSEventBin.cpp.
References GCOSInstDir::dir(), G_PSI_GET, and m_dir.
Referenced by dir().
|
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 205 of file GCOSEventBin.cpp.
References ewidth(), GEnergy::MeV(), ontime(), size(), and solidangle().
Referenced by size().
| void GCOSEventBin::solidangle | ( | const double & | solidangle | ) |
Set solid angle of event bin.
| [in] | solidangle | Solid angle of event bin (sr). |
| GException::invalid_value | No memory allocated to store solid angle. |
Sets the solid angle of the event bin.
Definition at line 655 of file GCOSEventBin.cpp.
References G_SOLIDANGLE_SET, m_solidangle, and solidangle().
| const double & GCOSEventBin::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 416 of file GCOSEventBin.cpp.
References G_SOLIDANGLE_GET, and m_solidangle.
Referenced by size(), and solidangle().
| void GCOSEventBin::time | ( | const GTime & | time | ) |
Set time of event bin.
| [in] | time | Time of event bin. |
| GException::invalid_value | No memory allocated to store the time. |
Sets the time of the event bin.
Definition at line 603 of file GCOSEventBin.cpp.
References G_TIME_SET, m_time, and time().
|
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 345 of file GCOSEventBin.cpp.
References G_TIME_GET, m_energy, and m_time.
Referenced by time().
|
friend |
Definition at line 64 of file GCOSEventBin.hpp.
|
protected |
Signals proper memory allocation.
Definition at line 114 of file GCOSEventBin.hpp.
Referenced by copy_members(), free_members(), and init_members().
|
protected |
Pointer to number of counts.
Definition at line 116 of file GCOSEventBin.hpp.
Referenced by copy_members(), counts(), counts(), free_members(), GCOSEventCube::init_bin(), init_members(), and GCOSEventCube::set_bin().
|
protected |
Pointer to bin direction.
Definition at line 117 of file GCOSEventBin.hpp.
Referenced by chi(), copy_members(), dir(), dir(), dir(), free_members(), GCOSEventCube::init_bin(), init_members(), phi(), and psi().
|
protected |
Pointer to bin energy.
Definition at line 122 of file GCOSEventBin.hpp.
Referenced by copy_members(), energy(), energy(), free_members(), GCOSEventCube::init_bin(), init_members(), GCOSEventCube::set_bin(), and time().
|
protected |
Pointer to energy width of bin.
Definition at line 123 of file GCOSEventBin.hpp.
Referenced by copy_members(), ewidth(), ewidth(), free_members(), GCOSEventCube::init_bin(), init_members(), and GCOSEventCube::set_bin().
|
protected |
Dataspace index.
Definition at line 115 of file GCOSEventBin.hpp.
Referenced by copy_members(), index(), index(), init_members(), and GCOSEventCube::set_bin().
|
protected |
Pointer to ontime of bin (seconds)
Definition at line 120 of file GCOSEventBin.hpp.
Referenced by copy_members(), free_members(), GCOSEventCube::init_bin(), init_members(), ontime(), and ontime().
|
protected |
Pointer to Phi width.
Definition at line 121 of file GCOSEventBin.hpp.
Referenced by copy_members(), free_members(), GCOSEventCube::init_bin(), init_members(), phiwidth(), phiwidth(), and GCOSEventCube::set_bin().
|
protected |
Pointer to solid angle of pixel (sr)
Definition at line 118 of file GCOSEventBin.hpp.
Referenced by copy_members(), free_members(), GCOSEventCube::init_bin(), init_members(), solidangle(), and solidangle().
|
protected |
Pointer to bin time.
Definition at line 119 of file GCOSEventBin.hpp.
Referenced by copy_members(), free_members(), GCOSEventCube::init_bin(), init_members(), time(), and time().