GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSPIEventBin Class Reference

INTEGRAL/SPI event bin class. More...

#include <GSPIEventBin.hpp>

Inheritance diagram for GSPIEventBin:
GEventBin GEvent GBase

Public Member Functions

 GSPIEventBin (void)
 Void constructor. More...
 
 GSPIEventBin (const GSPIEventBin &bin)
 Copy constructor. More...
 
virtual ~GSPIEventBin (void)
 Destructor. More...
 
virtual GSPIEventBinoperator= (const GSPIEventBin &bin)
 Assignment operator. More...
 
virtual void clear (void)
 Clear INTEGRAL/SPI event bin. More...
 
virtual GSPIEventBinclone (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 GSPIInstDirdir (void) const
 Return instrument direction. More...
 
virtual const GEnergyenergy (void) const
 Return energy. More...
 
virtual const GTimetime (void) const
 Return time. More...
 
virtual double counts (void) const
 Return number of counts. More...
 
virtual double error (void) const
 Return error in number of counts. More...
 
virtual void counts (const double &counts)
 Set number of counts. More...
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print event information. More...
 
const double & model (const int &index) const
 Return model value. More...
 
const double & ontime (void) const
 Return ontime of event bin. More...
 
const double & livetime (void) const
 Return livetime of event bin. More...
 
const int & index (void) const
 Return event bin index. More...
 
const int & ipt (void) const
 Return event bin pointing index. More...
 
const int & idir (void) const
 Return event bin direction index. More...
 
const int & iebin (void) const
 Return event bin energy index. 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 GSPIEventBin &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...
 
int m_ipt
 Pointing index. More...
 
int m_idir
 Direction index. More...
 
int m_iebin
 Energy bin index. More...
 
int m_num_models
 Number of models in bin. More...
 
GSPIInstDirm_dir
 Pointer to direction of bin. More...
 
GTimem_time
 Pointer to time of bin. More...
 
GEnergym_energy
 Pointer to energy of bin. More...
 
double * m_counts
 Pointer to number of counts. More...
 
double * m_ontime
 Pointer to ontime of bin. More...
 
double * m_livetime
 Pointer to livetime of bin. More...
 
double * m_size
 Pointer to size of bin. More...
 
double * m_models
 Pointer to models of bin. More...
 

Friends

class GSPIEventCube
 

Detailed Description

INTEGRAL/SPI event bin class.

This class defines an event bin of the INTEGRAL/SPI 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 GSPIEventBin class implement it's own memory management. Either the class allocates memory for all attributes, or it takes pointers to GSPIEventCube class member that store the information in an efficient way.

The data member m_alloc signals in which mode the bin operates. I true, GSPIEventBin 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 62 of file GSPIEventBin.hpp.

Constructor & Destructor Documentation

GSPIEventBin::GSPIEventBin ( void  )

Void constructor.

Creates an empty INTEGRAL/SPI event bin.

Definition at line 59 of file GSPIEventBin.cpp.

References init_members().

Referenced by clone().

GSPIEventBin::GSPIEventBin ( const GSPIEventBin bin)

Copy constructor.

Parameters
[in]binINTEGRAL/SPI event bin.

Definition at line 74 of file GSPIEventBin.cpp.

References copy_members(), and init_members().

GSPIEventBin::~GSPIEventBin ( void  )
virtual

Destructor.

Definition at line 90 of file GSPIEventBin.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GEventBin.

Definition at line 128 of file GSPIEventBin.hpp.

void GSPIEventBin::clear ( void  )
virtual

Clear INTEGRAL/SPI event bin.

Clears INTEGRAL/SPI 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 148 of file GSPIEventBin.cpp.

References GEventBin::free_members(), GEvent::free_members(), free_members(), GEventBin::init_members(), GEvent::init_members(), and init_members().

Referenced by GSPIEventCube::init_members().

GSPIEventBin * GSPIEventBin::clone ( void  ) const
virtual

Clone event bin.

Returns
Pointer to deep copy of INTEGRAL/SPI event bin.

Implements GEventBin.

Definition at line 170 of file GSPIEventBin.cpp.

References GSPIEventBin().

void GSPIEventBin::copy_members ( const GSPIEventBin bin)
protected

Copy class members.

Parameters
[in]binINTEGRAL/SPI event bin.

Definition at line 298 of file GSPIEventBin.cpp.

References free_members(), m_alloc, m_counts, m_dir, m_energy, m_idir, m_iebin, m_index, m_ipt, m_livetime, m_models, m_num_models, m_ontime, m_size, and m_time.

Referenced by GSPIEventBin(), and operator=().

double GSPIEventBin::counts ( void  ) const
inlinevirtual

Return number of counts.

Returns
Number of counts.

Returns the number of counts in the event bin.

Implements GEventBin.

Definition at line 184 of file GSPIEventBin.hpp.

References m_counts.

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

void GSPIEventBin::counts ( const double &  counts)
inlinevirtual

Set number of counts.

Parameters
[in]countsNumber of counts.

Set the number of counts in the event bin.

Implements GEventBin.

Definition at line 198 of file GSPIEventBin.hpp.

References counts(), and m_counts.

const GSPIInstDir & GSPIEventBin::dir ( void  ) const
inlinevirtual

Return instrument direction.

Returns
Instrument direction.

Returns the instrument direction of the event bin.

Implements GEventBin.

Definition at line 142 of file GSPIEventBin.hpp.

References m_dir.

Referenced by GSPIResponse::irf_value().

const GEnergy & GSPIEventBin::energy ( void  ) const
inlinevirtual

Return energy.

Returns
Energy.

Returns the energy of the event bin.

Implements GEventBin.

Definition at line 156 of file GSPIEventBin.hpp.

References m_energy.

double GSPIEventBin::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 189 of file GSPIEventBin.cpp.

References counts(), and sqrt().

void GSPIEventBin::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 GSPIEventCube class), no memory is freed.

Definition at line 348 of file GSPIEventBin.cpp.

References m_alloc, m_counts, m_dir, m_energy, m_livetime, m_models, m_ontime, m_size, and m_time.

Referenced by clear(), copy_members(), GSPIEventCube::init_bin(), operator=(), and ~GSPIEventBin().

const int & GSPIEventBin::idir ( void  ) const
inline

Return event bin direction index.

Returns
Event bin direction index

Returns the event bin instrument direction index in the event cube.

Definition at line 282 of file GSPIEventBin.hpp.

References m_idir.

const int & GSPIEventBin::iebin ( void  ) const
inline

Return event bin energy index.

Returns
Event bin energy index

Returns the event bin energy index in the event cube.

Definition at line 296 of file GSPIEventBin.hpp.

References m_iebin.

Referenced by GSPIResponse::irf(), and GSPIResponse::irf_value().

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

Return event bin index.

Returns
Event bin index

Returns the event bin index in the event cube.

Definition at line 254 of file GSPIEventBin.hpp.

References m_index.

Referenced by GSPIModelDataSpace::eval().

void GSPIEventBin::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 261 of file GSPIEventBin.cpp.

References GSPIInstDir::clear(), GEnergy::clear(), GTime::clear(), m_alloc, m_counts, m_dir, m_energy, m_idir, m_iebin, m_index, m_ipt, m_livetime, m_models, m_num_models, m_ontime, m_size, and m_time.

Referenced by clear(), GSPIEventBin(), and operator=().

const int & GSPIEventBin::ipt ( void  ) const
inline

Return event bin pointing index.

Returns
Event bin pointing index

Returns the event bin pointing index in the event cube.

Definition at line 268 of file GSPIEventBin.hpp.

References m_ipt.

Referenced by GSPIResponse::irf_value().

const double & GSPIEventBin::livetime ( void  ) const
inline

Return livetime of event bin.

Returns
Size of livetime of bin (s)

Returns the livetime of the event bin.

Definition at line 240 of file GSPIEventBin.hpp.

References m_livetime.

Referenced by GSPIResponse::irf().

const double & GSPIEventBin::model ( const int &  index) const

Return model value.

Parameters
[in]indexModel index.
Returns
Model value.
Exceptions
GException::out_of_rangeInvalid model index

Definition at line 208 of file GSPIEventBin.cpp.

References G_MODEL, m_models, and m_num_models.

Referenced by GSPIModelDataSpace::eval().

const double & GSPIEventBin::ontime ( void  ) const
inline

Return ontime of event bin.

Returns
Size of ontime of bin (s)

Returns the ontime of the event bin.

Definition at line 226 of file GSPIEventBin.hpp.

References m_ontime.

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

Assignment operator.

Parameters
[in]binINTEGRAL/SPI event bin.
Returns
INTEGRAL/SPI event bin.

Definition at line 112 of file GSPIEventBin.cpp.

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

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

Print event information.

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

Implements GEventBin.

Definition at line 229 of file GSPIEventBin.cpp.

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

double GSPIEventBin::size ( void  ) const
inlinevirtual

Return size of event bin.

Returns
Size of event bin (MeV s)

Returns the size of the event bin.

Implements GEventBin.

Definition at line 212 of file GSPIEventBin.hpp.

References m_size.

Referenced by GSPIModelDataSpace::eval().

const GTime & GSPIEventBin::time ( void  ) const
inlinevirtual

Return time.

Returns
Time.

Returns the time of the event bin.

Implements GEventBin.

Definition at line 170 of file GSPIEventBin.hpp.

References m_time.

Friends And Related Function Documentation

friend class GSPIEventCube
friend

Definition at line 65 of file GSPIEventBin.hpp.

Member Data Documentation

bool GSPIEventBin::m_alloc
protected

Signals proper memory allocation.

Definition at line 105 of file GSPIEventBin.hpp.

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

double* GSPIEventBin::m_counts
protected

Pointer to number of counts.

Definition at line 114 of file GSPIEventBin.hpp.

Referenced by copy_members(), counts(), free_members(), GSPIEventCube::init_bin(), init_members(), and GSPIEventCube::set_bin().

GSPIInstDir* GSPIEventBin::m_dir
protected

Pointer to direction of bin.

Definition at line 111 of file GSPIEventBin.hpp.

Referenced by copy_members(), dir(), free_members(), GSPIEventCube::init_bin(), init_members(), and GSPIEventCube::set_bin().

GEnergy* GSPIEventBin::m_energy
protected

Pointer to energy of bin.

Definition at line 113 of file GSPIEventBin.hpp.

Referenced by copy_members(), energy(), free_members(), GSPIEventCube::init_bin(), init_members(), and GSPIEventCube::set_bin().

int GSPIEventBin::m_idir
protected

Direction index.

Definition at line 108 of file GSPIEventBin.hpp.

Referenced by copy_members(), idir(), GSPIEventCube::init_bin(), init_members(), and GSPIEventCube::set_bin().

int GSPIEventBin::m_iebin
protected

Energy bin index.

Definition at line 109 of file GSPIEventBin.hpp.

Referenced by copy_members(), iebin(), GSPIEventCube::init_bin(), init_members(), and GSPIEventCube::set_bin().

int GSPIEventBin::m_index
protected

Dataspace index.

Definition at line 106 of file GSPIEventBin.hpp.

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

int GSPIEventBin::m_ipt
protected

Pointing index.

Definition at line 107 of file GSPIEventBin.hpp.

Referenced by copy_members(), GSPIEventCube::init_bin(), init_members(), ipt(), and GSPIEventCube::set_bin().

double* GSPIEventBin::m_livetime
protected

Pointer to livetime of bin.

Definition at line 116 of file GSPIEventBin.hpp.

Referenced by copy_members(), free_members(), GSPIEventCube::init_bin(), init_members(), livetime(), and GSPIEventCube::set_bin().

double* GSPIEventBin::m_models
protected

Pointer to models of bin.

Definition at line 118 of file GSPIEventBin.hpp.

Referenced by copy_members(), free_members(), GSPIEventCube::init_bin(), init_members(), model(), and GSPIEventCube::set_bin().

int GSPIEventBin::m_num_models
protected

Number of models in bin.

Definition at line 110 of file GSPIEventBin.hpp.

Referenced by copy_members(), GSPIEventCube::init_bin(), init_members(), model(), and GSPIEventCube::set_bin().

double* GSPIEventBin::m_ontime
protected

Pointer to ontime of bin.

Definition at line 115 of file GSPIEventBin.hpp.

Referenced by copy_members(), free_members(), GSPIEventCube::init_bin(), init_members(), ontime(), and GSPIEventCube::set_bin().

double* GSPIEventBin::m_size
protected

Pointer to size of bin.

Definition at line 117 of file GSPIEventBin.hpp.

Referenced by copy_members(), free_members(), GSPIEventCube::init_bin(), init_members(), GSPIEventCube::set_bin(), and size().

GTime* GSPIEventBin::m_time
protected

Pointer to time of bin.

Definition at line 112 of file GSPIEventBin.hpp.

Referenced by copy_members(), free_members(), GSPIEventCube::init_bin(), init_members(), GSPIEventCube::set_bin(), and time().


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