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

COMPTEL event bin container class. More...

#include <GCOMEventCube.hpp>

Inheritance diagram for GCOMEventCube:
GEventCube GEvents GBase

Public Member Functions

 GCOMEventCube (void)
 Void constructor. More...
 
 GCOMEventCube (const GFilename &filename)
 Load constructor. More...
 
 GCOMEventCube (const GCOMDri &dre)
 DRE constructor. More...
 
 GCOMEventCube (const GCOMEventCube &cube)
 Copy constructor. More...
 
virtual ~GCOMEventCube (void)
 Destructor. More...
 
virtual GCOMEventCubeoperator= (const GCOMEventCube &cube)
 Assignment operator. More...
 
virtual GCOMEventBinoperator[] (const int &index)
 Event bin access operator. More...
 
virtual const GCOMEventBinoperator[] (const int &index) const
 Event bin access operator (const version) More...
 
virtual void clear (void)
 Clear instance. More...
 
virtual GCOMEventCubeclone (void) const
 Clone instance. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual int size (void) const
 Return number of bins in event cube. More...
 
virtual int dim (void) const
 Return dimension of event cube. More...
 
virtual int naxis (const int &axis) const
 Return number of bins in axis. More...
 
virtual void load (const GFilename &filename)
 Load COMPTEL event cube from FITS file. More...
 
virtual void save (const GFilename &filename, const bool &clobber=false) const
 Save COMPTEL event cube into FITS file. More...
 
virtual void read (const GFits &file)
 Read COMPTEL event cube from FITS file. More...
 
virtual void write (GFits &file) const
 Write COMPTEL event cube into FITS file. More...
 
virtual int number (void) const
 Return number of events in cube. More...
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print event cube information. More...
 
const GCOMDridre (void) const
 Return reference to DRE data. More...
 
- Public Member Functions inherited from GEventCube
 GEventCube (void)
 Void constructor. More...
 
 GEventCube (const GEventCube &cube)
 Copy constructor. More...
 
virtual ~GEventCube (void)
 Destructor. More...
 
virtual GEventCubeoperator= (const GEventCube &cube)
 Assignment operator. More...
 
- Public Member Functions inherited from GEvents
 GEvents (void)
 Void constructor. More...
 
 GEvents (const GEvents &events)
 Copy constructor. More...
 
virtual ~GEvents (void)
 Destructor. More...
 
virtual GEventsoperator= (const GEvents &events)
 Assignment operator. More...
 
void ebounds (const GEbounds &ebounds)
 Set energy boundaries. More...
 
void gti (const GGti &gti)
 Set Good Time Intervals. More...
 
const GEboundsebounds (void) const
 Return energy boundaries. More...
 
const GGtigti (void) const
 Return Good Time Intervals. More...
 
const GTimetstart (void) const
 Return start time. More...
 
const GTimetstop (void) const
 Return stop time. More...
 
const GEnergyemin (void) const
 Return minimum energy. More...
 
const GEnergyemax (void) const
 Return maximum energy. 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 GCOMEventCube &cube)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void init_cube (void)
 Initialise event cube. More...
 
void set_scatter_directions (void)
 Set sky directions and solid angles of events cube. More...
 
void set_scatter_angles (void)
 Set Compton scatter angles of event cube. More...
 
virtual void set_energies (void)
 Set log mean energy and energy width of event cube. More...
 
virtual void set_times (void)
 Set mean event time and ontime of event cube. More...
 
void init_bin (void)
 Initialise event bin. More...
 
void set_bin (const int &index)
 Set event bin. More...
 
- Protected Member Functions inherited from GEventCube
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GEventCube &cube)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from GEvents
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GEvents &events)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Protected Attributes

GCOMEventBin m_bin
 Actual event bin. More...
 
GCOMInstDir m_dir
 Actual event direction. More...
 
GCOMDri m_dri
 DRI cube. More...
 
GTime m_time
 Event cube mean time. More...
 
double m_ontime
 Event cube ontime (sec) More...
 
GEnergy m_energy
 Event cube mean energy. More...
 
GEnergy m_ewidth
 Event cube energy bin width. More...
 
int m_npix
 Number of DRI pixels. More...
 
std::vector< GSkyDirm_dirs
 Array of event scatter directions. More...
 
std::vector< double > m_solidangle
 Array of solid angles (sr) More...
 
std::vector< double > m_phibar
 Array of event scatter angles. More...
 
- Protected Attributes inherited from GEvents
GEbounds m_ebounds
 Energy boundaries covered by events. More...
 
GGti m_gti
 Good time intervals covered by events. More...
 

Detailed Description

COMPTEL event bin container class.

This class is a container class for COMPTEL event bins.

Definition at line 54 of file GCOMEventCube.hpp.

Constructor & Destructor Documentation

GCOMEventCube::GCOMEventCube ( void  )

Void constructor.

Constructs an empty event cube.

Definition at line 64 of file GCOMEventCube.cpp.

References init_members().

Referenced by clone().

GCOMEventCube::GCOMEventCube ( const GFilename filename)
explicit

Load constructor.

Parameters
[in]filenameDRE FITS filename.

Constructs an event cube from a DRE FITS file.

Definition at line 81 of file GCOMEventCube.cpp.

References init_members(), and load().

GCOMEventCube::GCOMEventCube ( const GCOMDri dre)
explicit

DRE constructor.

Parameters
[in]dreDRE event cube.

Constructs an event cube from a DRE event cube.

Definition at line 101 of file GCOMEventCube.cpp.

References dre(), init_cube(), init_members(), and m_dri.

GCOMEventCube::GCOMEventCube ( const GCOMEventCube cube)

Copy constructor.

Parameters
[in]cubeEvent cube.

Definition at line 122 of file GCOMEventCube.cpp.

References copy_members(), and init_members().

GCOMEventCube::~GCOMEventCube ( void  )
virtual

Destructor.

Definition at line 138 of file GCOMEventCube.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GEventCube.

Definition at line 121 of file GCOMEventCube.hpp.

void GCOMEventCube::clear ( void  )
virtual

Clear instance.

This method properly resets the object to an initial state.

Implements GEventCube.

Definition at line 235 of file GCOMEventCube.cpp.

References GEventCube::free_members(), free_members(), GEvents::free_members(), GEventCube::init_members(), init_members(), and GEvents::init_members().

Referenced by read().

GCOMEventCube * GCOMEventCube::clone ( void  ) const
virtual

Clone instance.

Returns
Pointer to deep copy of event cube.

Implements GEventCube.

Definition at line 257 of file GCOMEventCube.cpp.

References GCOMEventCube().

void GCOMEventCube::copy_members ( const GCOMEventCube cube)
protected

Copy class members.

Parameters
[in]cubeEvent cube.

This method copies the class members from another event cube in the actual object. It also prepares the event bin member that will be returned in case of an operator access to the class.

Definition at line 541 of file GCOMEventCube.cpp.

References init_bin(), m_dir, m_dirs, m_dri, m_energy, m_ewidth, m_npix, m_ontime, m_phibar, m_solidangle, and m_time.

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

int GCOMEventCube::dim ( void  ) const
virtual

Return dimension of event cube.

Returns
Number of dimensions in event cube.

The dimension of the cube is either 2 or 3, depending on whether several scatter angle layers exist or not.

Implements GEventCube.

Definition at line 271 of file GCOMEventCube.cpp.

References m_dri, and GCOMDri::nphibar().

Referenced by naxis().

const GCOMDri & GCOMEventCube::dre ( void  ) const
inline

Return reference to DRE data.

Returns
Reference to DRE data.

Definition at line 145 of file GCOMEventCube.hpp.

References m_dri.

Referenced by GCOMObservation::add_drm(), GCOMObservation::drm(), and GCOMEventCube().

void GCOMEventCube::free_members ( void  )
protected

Delete class members.

Definition at line 569 of file GCOMEventCube.cpp.

Referenced by clear(), operator=(), and ~GCOMEventCube().

void GCOMEventCube::init_bin ( void  )
protected

Initialise event bin.

This method initialises the event bin. The event bin is cleared and all fixed pointers are set. Only the m_counts and the m_solidangle member of the event bin will be set to NULL, but these will be set by the set_bin method which is called before any event bin access.

< Will be set by set_bin method

< Content will be set by set_bin method

< Will be set by set_bin method

< Fixed content

< Fixed content

< Fixed content

< Fixed content

Definition at line 750 of file GCOMEventCube.cpp.

References GCOMEventBin::free_members(), m_bin, GCOMEventBin::m_counts, GCOMEventBin::m_dir, m_dir, GCOMEventBin::m_energy, m_energy, GCOMEventBin::m_ewidth, m_ewidth, GCOMEventBin::m_ontime, m_ontime, GCOMEventBin::m_solidangle, GCOMEventBin::m_time, and m_time.

Referenced by copy_members(), and init_members().

void GCOMEventCube::init_cube ( void  )
protected

Initialise event cube.

This method needs to be called once a new DRI dataset has been read.

The method copies the energy boundaries and the Good Time Intervals from the DRI cube into the event cube and sets up arrays that will be used for event bin access. In particular, the set_scatter_directions(), set_scatter_angles(), set_energies() and set_times() methods will be called by this method.

Definition at line 587 of file GCOMEventCube.cpp.

References GCOMDri::ebounds(), GEvents::ebounds(), GCOMDri::gti(), GEvents::gti(), m_dri, set_energies(), set_scatter_angles(), set_scatter_directions(), and set_times().

Referenced by GCOMEventCube(), and read().

void GCOMEventCube::init_members ( void  )
protected

Initialise class members.

The method initialises the class members to a well defined state. It also prepares the event bin member that will be returned in case of an operator access to the class. As the event bin member manipulates pointers, it will be possible to directly write to the memory that has been associated with a bin.

Definition at line 509 of file GCOMEventCube.cpp.

References GCOMInstDir::clear(), GCOMEventBin::clear(), GCOMDri::clear(), GEnergy::clear(), GTime::clear(), init_bin(), m_bin, m_dir, m_dirs, m_dri, m_energy, m_ewidth, m_npix, m_ontime, m_phibar, m_solidangle, and m_time.

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

void GCOMEventCube::load ( const GFilename filename)
virtual

Load COMPTEL event cube from FITS file.

Parameters
[in]filenameFITS filename.

Loads the event cube from a DRE FITS file.

Implements GEventCube.

Definition at line 327 of file GCOMEventCube.cpp.

References GFits::close(), and read().

Referenced by GCOMEventCube().

int GCOMEventCube::naxis ( const int &  axis) const
virtual

Return number of bins in axis.

Parameters
[in]axisAxis [0,...,dim()-1].
Returns
Number of bins in axis.
Exceptions
GException::out_of_rangeAxis is out of range.

Returns the number of bins along a given event cube axis.

Implements GEventCube.

Definition at line 292 of file GCOMEventCube.cpp.

References dim(), G_NAXIS, m_dri, GCOMDri::nchi(), GCOMDri::nphibar(), and GCOMDri::npsi().

int GCOMEventCube::number ( void  ) const
virtual

Return number of events in cube.

Returns
Number of events in event cube.

This method returns the number of events in the event cube rounded to the nearest integer.

Implements GEventCube.

Definition at line 418 of file GCOMEventCube.cpp.

References m_dri, and GCOMDri::size().

Referenced by print().

GCOMEventCube & GCOMEventCube::operator= ( const GCOMEventCube cube)
virtual

Assignment operator.

Parameters
[in]cubeEvent cube.
Returns
Event cube.

Definition at line 160 of file GCOMEventCube.cpp.

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

GCOMEventBin * GCOMEventCube::operator[] ( const int &  index)
virtual

Event bin access operator.

Parameters
[in]indexEvent index [0,...,size()-1].
Returns
Pointer to event bin.

Returns pointer to an event bin. Note that the returned pointer is in fact always the same, but the method sets the pointers within the event bin so that they point to the appropriate information.

Implements GEventCube.

Definition at line 194 of file GCOMEventCube.cpp.

References m_bin, and set_bin().

const GCOMEventBin * GCOMEventCube::operator[] ( const int &  index) const
virtual

Event bin access operator (const version)

Parameters
[in]indexEvent index [0,...,size()-1].
Returns
Const pointer to event bin.

Returns pointer to an event bin. Note that the returned pointer is in fact always the same, but the method sets the pointers within the event bin so that they point to the appropriate information.

Implements GEventCube.

Definition at line 214 of file GCOMEventCube.cpp.

References m_bin.

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

Print event cube information.

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

Implements GEventCube.

Definition at line 439 of file GCOMEventCube.cpp.

References gammalib::com_tics(), gammalib::com_tjd(), GEvents::emax(), GEvents::emin(), EXPLICIT, m_dri, m_energy, m_ewidth, m_ontime, m_time, GCOMDri::nchi(), GCOMDri::nphibar(), GCOMDri::npsi(), number(), gammalib::parformat(), GCOMDri::print(), GEnergy::print(), GTime::print(), SILENT, size(), gammalib::str(), GEvents::tstart(), and GEvents::tstop().

void GCOMEventCube::read ( const GFits fits)
virtual

Read COMPTEL event cube from FITS file.

Parameters
[in]fitsFITS file.

Reads an COMPTEL event cube from a DRE FITS file.

Implements GEventCube.

Definition at line 374 of file GCOMEventCube.cpp.

References clear(), GFits::image(), init_cube(), m_dri, and GCOMDri::read().

Referenced by load().

void GCOMEventCube::save ( const GFilename filename,
const bool &  clobber = false 
) const
virtual

Save COMPTEL event cube into FITS file.

Parameters
[in]filenameFITS filename.
[in]clobberOverwrite existing FITS file? (default: false).

Saves the COMPTEL event cube into a DRE FITS file.

Implements GEventCube.

Definition at line 351 of file GCOMEventCube.cpp.

References GFits::saveto(), and write().

void GCOMEventCube::set_bin ( const int &  index)
protected

Set event bin.

Parameters
[in]indexEvent index [0,...,size()-1].
Exceptions
GException::out_of_rangeEvent index is outside valid range.
GException::invalid_valueSky directions and solid angles vectors have not been set up.

This method provides the event attributes to the event bin. The event bin is in fact physically stored in the event cube, and only a single event bin is indeed allocated. This method sets up the pointers in the event bin so that a client can easily access the information of individual bins as if they were stored in an array.

Definition at line 783 of file GCOMEventCube.cpp.

References GCOMInstDir::dir(), G_SET_BIN, m_bin, GCOMEventBin::m_counts, m_dir, m_dirs, m_dri, GCOMEventBin::m_index, m_npix, m_phibar, GCOMEventBin::m_solidangle, m_solidangle, GCOMInstDir::phibar(), and size().

Referenced by operator[]().

void GCOMEventCube::set_energies ( void  )
protectedvirtual

Set log mean energy and energy width of event cube.

Exceptions
GException::invalid_valueNo energy boundaries found.

Computes the mean energy and energy bin width of the event cube.

Reimplemented from GEventCube.

Definition at line 690 of file GCOMEventCube.cpp.

References GEbounds::elogmean(), GEbounds::emax(), GEbounds::emin(), G_SET_ENERGIES, GEvents::m_ebounds, m_energy, m_ewidth, and GEbounds::size().

Referenced by init_cube().

void GCOMEventCube::set_scatter_angles ( void  )
protected

Set Compton scatter angles of event cube.

Sets a vector of the Compton scatter angles.

Definition at line 663 of file GCOMEventCube.cpp.

References m_dri, m_phibar, GCOMDri::nphibar(), GCOMDri::phibin(), and GCOMDri::phimin().

Referenced by init_cube().

void GCOMEventCube::set_scatter_directions ( void  )
protected

Set sky directions and solid angles of events cube.

Exceptions
GException::invalid_valueNo sky pixels have been defined.

This method computes the sky directions and solid angles for all (Chi,Psi) values of the event cube. Sky directions are stored in an array of GSkyDir objects while solid angles are stored in units of sr in an array of double precision variables.

Definition at line 623 of file GCOMEventCube.cpp.

References G_SET_SCATTER_DIRECTIONS, m_dirs, m_dri, m_npix, m_solidangle, GCOMDri::map(), GCOMDri::nchi(), GCOMDri::npsi(), GSkyMap::pix2dir(), and GSkyMap::solidangle().

Referenced by init_cube().

void GCOMEventCube::set_times ( void  )
protectedvirtual

Set mean event time and ontime of event cube.

Exceptions
GException::invalid_valueNo Good Time Intervals found.

Computes the mean time of the event cube by taking the mean between start and stop time. Computes also the ontime by summing up of all good time intervals.

Reimplemented from GEventCube.

Definition at line 721 of file GCOMEventCube.cpp.

References G_SET_TIMES, GEvents::m_gti, m_ontime, m_time, GGti::ontime(), GGti::size(), GGti::tstart(), and GGti::tstop().

Referenced by init_cube().

int GCOMEventCube::size ( void  ) const
inlinevirtual

Return number of bins in event cube.

Returns
Number of bins in event cube.

Implements GEventCube.

Definition at line 133 of file GCOMEventCube.hpp.

References m_dri, and GCOMDri::size().

Referenced by GCOMObservation::drm(), print(), and set_bin().

void GCOMEventCube::write ( GFits file) const
virtual

Write COMPTEL event cube into FITS file.

Parameters
[in]fileFITS file.

Writes the COMPTEL event cube into a DRE FITS file.

Implements GEventCube.

Definition at line 400 of file GCOMEventCube.cpp.

References m_dri, and GCOMDri::write().

Referenced by save().

Member Data Documentation

GCOMEventBin GCOMEventCube::m_bin
protected

Actual event bin.

Definition at line 101 of file GCOMEventCube.hpp.

Referenced by init_bin(), init_members(), operator[](), and set_bin().

GCOMInstDir GCOMEventCube::m_dir
protected

Actual event direction.

Definition at line 102 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_bin(), init_members(), and set_bin().

std::vector<GSkyDir> GCOMEventCube::m_dirs
protected

Array of event scatter directions.

Definition at line 109 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_members(), set_bin(), and set_scatter_directions().

GEnergy GCOMEventCube::m_energy
protected

Event cube mean energy.

Definition at line 106 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_bin(), init_members(), print(), and set_energies().

GEnergy GCOMEventCube::m_ewidth
protected

Event cube energy bin width.

Definition at line 107 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_bin(), init_members(), print(), and set_energies().

int GCOMEventCube::m_npix
protected

Number of DRI pixels.

Definition at line 108 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_members(), set_bin(), and set_scatter_directions().

double GCOMEventCube::m_ontime
protected

Event cube ontime (sec)

Definition at line 105 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_bin(), init_members(), print(), and set_times().

std::vector<double> GCOMEventCube::m_phibar
protected

Array of event scatter angles.

Definition at line 111 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_members(), set_bin(), and set_scatter_angles().

std::vector<double> GCOMEventCube::m_solidangle
protected

Array of solid angles (sr)

Definition at line 110 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_members(), set_bin(), and set_scatter_directions().

GTime GCOMEventCube::m_time
protected

Event cube mean time.

Definition at line 104 of file GCOMEventCube.hpp.

Referenced by copy_members(), init_bin(), init_members(), print(), and set_times().


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