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

GCTAEventBin class interface definition. More...

#include <GCTAEventBin.hpp>

Inheritance diagram for GCTAEventBin:
GEventBin GEvent GBase

Public Member Functions

 GCTAEventBin (void)
 Void constructor. More...
 
 GCTAEventBin (const GCTAEventBin &bin)
 Copy constructor. More...
 
virtual ~GCTAEventBin (void)
 Destructor. More...
 
virtual GCTAEventBinoperator= (const GCTAEventBin &bin)
 Assignment operator. More...
 
virtual void clear (void)
 Clear eventbin. More...
 
virtual GCTAEventBinclone (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 GCTAInstDirdir (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 & 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...
 
const GEnergyewidth (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 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 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...
 
GCTAInstDirm_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...
 
double * m_weight
 Pointer to weight of bin. More...
 

Friends

class GCTAEventCube
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
[in]binEvent bin.

Definition at line 86 of file GCTAEventBin.cpp.

References copy_members(), and init_members().

GCTAEventBin::~GCTAEventBin ( void  )
virtual

Destructor.

Definition at line 102 of file GCTAEventBin.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GEventBin.

Definition at line 123 of file GCTAEventBin.hpp.

void GCTAEventBin::clear ( void  )
virtual
GCTAEventBin * GCTAEventBin::clone ( void  ) const
virtual

Clone event bin.

Returns
Pointer to deep copy of event bin.

Implements GEventBin.

Definition at line 179 of file GCTAEventBin.cpp.

References GCTAEventBin().

void GCTAEventBin::copy_members ( const GCTAEventBin bin)
protected

Copy class members.

Parameters
[in]binEvent bin.

Definition at line 694 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=().

double GCTAEventBin::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 GCTAEventBin.cpp.

References G_COUNTS_GET, and m_counts.

Referenced by counts(), error(), GCTACubeBackground::fill(), and print().

void GCTAEventBin::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 501 of file GCTAEventBin.cpp.

References counts(), G_COUNTS_SET, and m_counts.

const GCTAInstDir & GCTAEventBin::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 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.

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 423 of file GCTAEventBin.cpp.

References dir(), G_DIR_SET, and m_dir.

const GEnergy & GCTAEventBin::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 GCTAEventBin.cpp.

References G_ENERGY, and m_energy.

Referenced by 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.

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 449 of file GCTAEventBin.cpp.

References energy(), G_ENERGY_SET, and m_energy.

double GCTAEventBin::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 GCTAEventBin.cpp.

References counts(), and sqrt().

const GEnergy & GCTAEventBin::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 GCTAEventBin.cpp.

References G_EWIDTH, and m_ewidth.

Referenced by ewidth(), and size().

void GCTAEventBin::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 553 of file GCTAEventBin.cpp.

References ewidth(), G_EWIDTH_SET, and m_ewidth.

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

Definition at line 734 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().

const int & GCTAEventBin::ieng ( void  ) const
inline

Return the energy layer index.

Returns
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 168 of file GCTAEventBin.hpp.

References m_ieng.

Referenced by ieng().

void GCTAEventBin::ieng ( const int &  ieng)
inline

Set the energy layer index.

Parameters
[in]iengEnergy layer index.

Sets the energy layer of the event bin in the event cube.

Definition at line 182 of file GCTAEventBin.hpp.

References ieng(), and m_ieng.

void GCTAEventBin::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.

< Not part of an event cube

< Not part of an event cube

Definition at line 659 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=().

const int & GCTAEventBin::ipix ( void  ) const
inline

Return the spatial pixel index.

Returns
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 138 of file GCTAEventBin.hpp.

References m_ipix.

Referenced by ipix().

void GCTAEventBin::ipix ( const int &  ipix)
inline

Set the spatial pixel index.

Parameters
[in]ipixSpatial pixel index.

Sets the spatial index of the event bin in the event cube.

Definition at line 152 of file GCTAEventBin.hpp.

References ipix(), and m_ipix.

const double & GCTAEventBin::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 GCTAEventBin.cpp.

References G_ONTIME, and m_ontime.

Referenced by ontime(), and size().

void GCTAEventBin::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 579 of file GCTAEventBin.cpp.

References G_ONTIME_SET, m_ontime, and ontime().

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

Assignment operator.

Parameters
[in]binEvent bin.
Returns
Event bin.

Definition at line 124 of file GCTAEventBin.cpp.

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

std::string GCTAEventBin::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 627 of file GCTAEventBin.cpp.

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

double GCTAEventBin::size ( void  ) const
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.

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 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.

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 527 of file GCTAEventBin.cpp.

References G_SOLIDANGLE_SET, m_solidangle, and solidangle().

const GTime & GCTAEventBin::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 GCTAEventBin.cpp.

References G_TIME, m_energy, 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.

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 475 of file GCTAEventBin.cpp.

References G_TIME_SET, m_time, and time().

const double & GCTAEventBin::weight ( void  ) const

Return weight of event bin.

Returns
Weight of event bin
Exceptions
GException::invalid_valueInvalid weight pointer.

Returns reference to the weight of the event bin.

Definition at line 400 of file GCTAEventBin.cpp.

References G_WEIGHT, and m_weight.

Referenced by size(), and weight().

void GCTAEventBin::weight ( const double &  weight)

Set weight of event bin.

Parameters
[in]weightWeight angle of event bin
Exceptions
GException::invalid_valueNo memory available to hold weight.

Sets the weight of the event bin.

Definition at line 605 of file GCTAEventBin.cpp.

References G_WEIGHT_SET, m_weight, and weight().

Friends And Related Function Documentation

friend class GCTAEventCube
friend

Definition at line 55 of file GCTAEventBin.hpp.

Member Data Documentation

bool GCTAEventBin::m_alloc
protected

Signals proper memory allocation.

Definition at line 103 of file GCTAEventBin.hpp.

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

double* GCTAEventBin::m_counts
protected

Pointer to number of counts.

Definition at line 110 of file GCTAEventBin.hpp.

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

GCTAInstDir* GCTAEventBin::m_dir
protected

Pointer to bin direction.

Definition at line 106 of file GCTAEventBin.hpp.

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

GEnergy* GCTAEventBin::m_energy
protected

Pointer to bin energy.

Definition at line 108 of file GCTAEventBin.hpp.

Referenced by copy_members(), energy(), free_members(), init_members(), GCTAEventCube::set_bin(), and time().

GEnergy* GCTAEventBin::m_ewidth
protected

Pointer to energy width of bin.

Definition at line 109 of file GCTAEventBin.hpp.

Referenced by copy_members(), ewidth(), free_members(), init_members(), and GCTAEventCube::set_bin().

int GCTAEventBin::m_ieng
protected

Index of energy layer.

Definition at line 105 of file GCTAEventBin.hpp.

Referenced by copy_members(), ieng(), init_members(), and GCTAEventCube::set_bin().

int GCTAEventBin::m_ipix
protected

Index in spatial map.

Definition at line 104 of file GCTAEventBin.hpp.

Referenced by copy_members(), init_members(), ipix(), and GCTAEventCube::set_bin().

double* GCTAEventBin::m_ontime
protected

Pointer to ontime of bin (seconds)

Definition at line 112 of file GCTAEventBin.hpp.

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

double* GCTAEventBin::m_solidangle
protected

Pointer to solid angle of pixel (sr)

Definition at line 111 of file GCTAEventBin.hpp.

Referenced by copy_members(), free_members(), init_members(), GCTAEventCube::set_bin(), and solidangle().

GTime* GCTAEventBin::m_time
protected

Pointer to bin time.

Definition at line 107 of file GCTAEventBin.hpp.

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

double* GCTAEventBin::m_weight
protected

Pointer to weight of bin.

Definition at line 113 of file GCTAEventBin.hpp.

Referenced by copy_members(), free_members(), init_members(), GCTAEventCube::set_bin(), and weight().


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