GammaLib 2.2.0.dev
Loading...
Searching...
No Matches
GCOSEventBin Class Reference

COSI event bin class. More...

#include <GCOSEventBin.hpp>

Inheritance diagram for GCOSEventBin:
GEventBin GEvent GBase

Public Member Functions

 GCOSEventBin (void)
 Void constructor.
 
 GCOSEventBin (const GCOSEventBin &bin)
 Copy constructor.
 
virtual ~GCOSEventBin (void)
 Destructor.
 
virtual GCOSEventBinoperator= (const GCOSEventBin &bin)
 Assignment operator.
 
virtual void clear (void)
 Clear COSI event bin.
 
virtual GCOSEventBinclone (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 GCOSInstDirdir (void) const
 Return instrument direction of event bin.
 
virtual const GEnergyenergy (void) const
 Return energy of event bin.
 
virtual const GTimetime (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 GEnergyewidth (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 GEventBinoperator= (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 GEventoperator= (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.
 
GCOSInstDirm_dir
 Pointer to bin direction.
 
double * m_solidangle
 Pointer to solid angle of pixel (sr)
 
GTimem_time
 Pointer to bin time.
 
double * m_ontime
 Pointer to ontime of bin (seconds)
 
double * m_phiwidth
 Pointer to Phi width.
 
GEnergym_energy
 Pointer to bin energy.
 
GEnergym_ewidth
 Pointer to energy width of bin.
 

Friends

class GCOSEventCube
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GCOSEventBin() [1/2]

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() [2/2]

GCOSEventBin::GCOSEventBin ( const GCOSEventBin & bin)

Copy constructor.

Parameters
[in]binCOSI event bin.

Definition at line 91 of file GCOSEventBin.cpp.

References copy_members(), and init_members().

◆ ~GCOSEventBin()

GCOSEventBin::~GCOSEventBin ( void )
virtual

Destructor.

Definition at line 107 of file GCOSEventBin.cpp.

References free_members().

Member Function Documentation

◆ chi()

double GCOSEventBin::chi ( void ) const

Return Galactic longitude of event bin scatter direction Chi.

Returns
Galactic longitude of event bin scatter direction Chi (deg).
Exceptions
GException::invalid_valueInvalid 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().

◆ classname()

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

Return class name.

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

Implements GEventBin.

Definition at line 133 of file GCOSEventBin.hpp.

◆ clear()

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

◆ clone()

GCOSEventBin * GCOSEventBin::clone ( void ) const
virtual

Clone event bin.

Returns
Pointer to deep copy of COSI event bin.

Implements GEventBin.

Definition at line 187 of file GCOSEventBin.cpp.

References GCOSEventBin().

◆ copy_members()

void GCOSEventBin::copy_members ( const GCOSEventBin & bin)
protected

Copy class members.

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

◆ counts() [1/2]

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

Set number of counts in event bin.

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

◆ counts() [2/2]

double GCOSEventBin::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 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.

Referenced by counts(), error(), and print().

◆ dir() [1/3]

void GCOSEventBin::dir ( const double & chi,
const double & psi,
const double & phi )

Set Chi, Psi and Phi of event bin.

Parameters
[in]chiGalactic longitude of scatter direction Chi (deg).
[in]psiGalactic longitude of scatter direction Psi (deg).
[in]phiScatter angle Phi (deg).
Exceptions
GException::invalid_valueNo 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().

◆ dir() [2/3]

void GCOSEventBin::dir ( const GCOSInstDir & dir)

Set instrument direction of event bin.

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

◆ dir() [3/3]

const GCOSInstDir & GCOSEventBin::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 225 of file GCOSEventBin.cpp.

References G_DIR_GET, and m_dir.

Referenced by dir(), and dir().

◆ energy() [1/2]

void GCOSEventBin::energy ( const GEnergy & energy)

Set energy of event bin.

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

◆ energy() [2/2]

const GEnergy & GCOSEventBin::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 321 of file GCOSEventBin.cpp.

References G_ENERGY_GET, and m_energy.

Referenced by energy().

◆ error()

double GCOSEventBin::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 396 of file GCOSEventBin.cpp.

References counts(), and error().

Referenced by error().

◆ ewidth() [1/2]

void GCOSEventBin::ewidth ( const GEnergy & ewidth)

Set energy width of event bin.

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

◆ ewidth() [2/2]

const GEnergy & GCOSEventBin::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 464 of file GCOSEventBin.cpp.

References G_EWIDTH_GET, and m_ewidth.

Referenced by ewidth(), and size().

◆ free_members()

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

◆ index() [1/2]

void GCOSEventBin::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 163 of file GCOSEventBin.hpp.

References index(), and m_index.

◆ index() [2/2]

const int & GCOSEventBin::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 148 of file GCOSEventBin.hpp.

References m_index.

Referenced by index().

◆ init_members()

void GCOSEventBin::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 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=().

◆ ontime() [1/2]

void GCOSEventBin::ontime ( const double & ontime)

Set ontime of event bin.

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

◆ ontime() [2/2]

const double & GCOSEventBin::ontime ( void ) const

Return ontime of event bin.

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

Referenced by ontime(), and size().

◆ operator=()

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

Assignment operator.

Parameters
[in]binCOSI event bin.
Returns
COSI event bin.

Definition at line 129 of file GCOSEventBin.cpp.

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

◆ phi()

const double & GCOSEventBin::phi ( void ) const

Return event bin scatter angle Phi.

Returns
Galactic longitude of event bin scatter angle Phi (deg).
Exceptions
GException::invalid_valueInvalid 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().

◆ phiwidth() [1/2]

void GCOSEventBin::phiwidth ( const double & phiwidth)

Set Phi width of event bin.

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

◆ phiwidth() [2/2]

const double & GCOSEventBin::phiwidth ( void ) const

Return Phi width of event bin.

Returns
Phi width of event bin (deg).
Exceptions
GException::invalid_valueInvalid 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()

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

Print event information.

Parameters
[in]chatterChattiness.
Returns
String containing event information.

Implements GEventBin.

Definition at line 757 of file GCOSEventBin.cpp.

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

◆ psi()

double GCOSEventBin::psi ( void ) const

Return Galactic longitude of event bin scatter direction Psi.

Returns
Galactic longitude of event bin scatter direction Psi (deg).
Exceptions
GException::invalid_valueInvalid 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().

◆ size()

double GCOSEventBin::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 205 of file GCOSEventBin.cpp.

References ewidth(), GEnergy::MeV(), ontime(), size(), and solidangle().

Referenced by size().

◆ solidangle() [1/2]

void GCOSEventBin::solidangle ( const double & solidangle)

Set solid angle of event bin.

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

◆ solidangle() [2/2]

const double & GCOSEventBin::solidangle ( void ) const

Return solid angle of event bin.

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

◆ time() [1/2]

void GCOSEventBin::time ( const GTime & time)

Set time of event bin.

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

◆ time() [2/2]

const GTime & GCOSEventBin::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 345 of file GCOSEventBin.cpp.

References G_TIME_GET, m_energy, and m_time.

Referenced by time().

Friends And Related Symbol Documentation

◆ GCOSEventCube

friend class GCOSEventCube
friend

Definition at line 64 of file GCOSEventBin.hpp.

Member Data Documentation

◆ m_alloc

bool GCOSEventBin::m_alloc
protected

Signals proper memory allocation.

Definition at line 114 of file GCOSEventBin.hpp.

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

◆ m_counts

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

◆ m_dir

GCOSInstDir* GCOSEventBin::m_dir
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().

◆ m_energy

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

◆ m_ewidth

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

◆ m_index

int GCOSEventBin::m_index
protected

Dataspace index.

Definition at line 115 of file GCOSEventBin.hpp.

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

◆ m_ontime

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

◆ m_phiwidth

double* GCOSEventBin::m_phiwidth
protected

◆ m_solidangle

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

◆ m_time

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


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