GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMEventBin Class Reference

COMPTEL event bin class. More...

#include <GCOMEventBin.hpp>

Inheritance diagram for GCOMEventBin:
GEventBin GEvent GBase

Public Member Functions

 GCOMEventBin (void)
 Void constructor. More...
 
 GCOMEventBin (const GCOMEventBin &bin)
 Copy constructor. More...
 
virtual ~GCOMEventBin (void)
 Destructor. More...
 
virtual GCOMEventBinoperator= (const GCOMEventBin &bin)
 Assignment operator. More...
 
virtual void clear (void)
 Clear instance. More...
 
virtual GCOMEventBinclone (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 GCOMInstDirdir (void) const
 Return instrument direction of event bin. More...
 
virtual const GEnergyenergy (void) const
 Return energy of event bin. More...
 
virtual const GTimetime (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 GEnergyewidth (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 GEventBinoperator= (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 GEventoperator= (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...
 
GCOMInstDirm_dir
 Pointer to bin direction. More...
 
GTimem_time
 Pointer to bin time. More...
 
GEnergym_energy
 Pointer to bin energy. More...
 
GEnergym_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
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]binEvent bin.

Definition at line 83 of file GCOMEventBin.cpp.

References copy_members(), and init_members().

GCOMEventBin::~GCOMEventBin ( void  )
virtual

Destructor.

Definition at line 99 of file GCOMEventBin.cpp.

References free_members().

Member Function Documentation

std::string GCOMEventBin::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GCOMEventBin").

Implements GEventBin.

Definition at line 114 of file GCOMEventBin.hpp.

void GCOMEventBin::clear ( void  )
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().

GCOMEventBin * GCOMEventBin::clone ( void  ) const
virtual

Clone instance.

Returns
Pointer to deep copy of event bin.

Implements GEventBin.

Definition at line 178 of file GCOMEventBin.cpp.

References GCOMEventBin().

void GCOMEventBin::copy_members ( const GCOMEventBin bin)
protected

Copy class members.

Parameters
[in]binEvent 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=().

double GCOMEventBin::counts ( void  ) const
virtual

Return number of counts in event bin.

Returns
Number of counts in event bin
Exceptions
GCTAException::invalid_valueInvalid 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().

void GCOMEventBin::counts ( const double &  counts)
virtual

Set number of counts in event bin.

Parameters
[in]countsNumber of counts.
Exceptions
GException::invalid_valueNo 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.

const GCOMInstDir & GCOMEventBin::dir ( void  ) const
virtual

Return instrument direction of event bin.

Returns
Instrument direction of event bin
Exceptions
GException::invalid_valueInvalid 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.

Parameters
[in]dirInstrument direction of event bin
Exceptions
GException::invalid_valueNo memory available to hold instrument direction.

Sets the instrument direction of the event bin.

Definition at line 400 of file GCOMEventBin.cpp.

References dir(), G_DIR_SET, and m_dir.

const GEnergy & GCOMEventBin::energy ( void  ) const
virtual

Return energy of event bin.

Returns
Energy of event bin
Exceptions
GException::invalid_valueInvalid 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.

Parameters
[in]energyEnergy of event bin
Exceptions
GException::invalid_valueNo 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.

double GCOMEventBin::error ( void  ) const
virtual

Return error in number of counts.

Returns
Error in number of counts in event bin.

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.

Todo:
The choice of delta has been made somewhat arbitrary, mainly because the optimizer routines filter error^2 below 1e-100.

Implements GEventBin.

Definition at line 311 of file GCOMEventBin.cpp.

References counts(), and sqrt().

const GEnergy & GCOMEventBin::ewidth ( void  ) const

Return energy width of event bin.

Returns
Energy width of event bin
Exceptions
GException::invalid_valueInvalid 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.

Referenced by ewidth(), and size().

void GCOMEventBin::ewidth ( const GEnergy ewidth)

Set energy width of event bin.

Parameters
[in]ewidthEnergy width of event bin
Exceptions
GException::invalid_valueNo 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.

void GCOMEventBin::free_members ( void  )
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().

const int & GCOMEventBin::index ( void  ) const
inline

Return bin index.

Returns
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().

void GCOMEventBin::index ( const int &  index)
inline

Set bin index.

Parameters
[in]indexBin 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.

References index(), and m_index.

void GCOMEventBin::init_members ( void  )
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.

Returns
Ontime of event bin
Exceptions
GException::invalid_valueInvalid 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.

Referenced by ontime(), and size().

void GCOMEventBin::ontime ( const double &  ontime)

Set ontime of event bin.

Parameters
[in]ontimeOntime of event bin (sec).
Exceptions
GException::invalid_valueNo 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().

GCOMEventBin & GCOMEventBin::operator= ( const GCOMEventBin bin)
virtual

Assignment operator.

Parameters
[in]binEvent bin.
Returns
Event bin.

Definition at line 121 of file GCOMEventBin.cpp.

References copy_members(), free_members(), init_members(), and GEventBin::operator=().

std::string GCOMEventBin::print ( const GChatter chatter = NORMAL) const
virtual

Print event information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing event information.

Implements GEventBin.

Definition at line 578 of file GCOMEventBin.cpp.

References counts(), SILENT, and gammalib::str().

double GCOMEventBin::size ( void  ) const
virtual

Return size of event bin.

Returns
Size of event bin (sr MeV s)

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.

Returns
Solid angle of event bin
Exceptions
GException::invalid_valueInvalid 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.

Parameters
[in]solidangleSolid angle of event bin
Exceptions
GException::invalid_valueNo 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().

const GTime & GCOMEventBin::time ( void  ) const
virtual

Return time of event bin.

Returns
Time of event bin
Exceptions
GException::invalid_valueInvalid 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.

Parameters
[in]timeTime of event bin
Exceptions
GException::invalid_valueNo 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().

Friends And Related Function Documentation

friend class GCOMEventCube
friend

Definition at line 52 of file GCOMEventBin.hpp.

Member Data Documentation

bool GCOMEventBin::m_alloc
protected

Signals proper memory allocation.

Definition at line 96 of file GCOMEventBin.hpp.

Referenced by copy_members(), free_members(), and init_members().

double* GCOMEventBin::m_counts
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().

GCOMInstDir* GCOMEventBin::m_dir
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().

GEnergy* GCOMEventBin::m_energy
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().

GEnergy* GCOMEventBin::m_ewidth
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().

int GCOMEventBin::m_index
protected

Dataspace index.

Definition at line 97 of file GCOMEventBin.hpp.

Referenced by copy_members(), index(), init_members(), and GCOMEventCube::set_bin().

double* GCOMEventBin::m_ontime
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().

double* GCOMEventBin::m_solidangle
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().

GTime* GCOMEventBin::m_time
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().


The documentation for this class was generated from the following files: