ctools  2.0.0
 All Classes Namespaces Files Functions Variables Macros Pages
ctbin Class Reference

Event binning tool. More...

#include <ctbin.hpp>

Inheritance diagram for ctbin:
ctobservation ctool GApplication

Public Member Functions

 ctbin (void)
 Void constructor. More...
 
 ctbin (const GObservations &obs)
 Observations constructor. More...
 
 ctbin (int argc, char *argv[])
 Command line constructor. More...
 
 ctbin (const ctbin &app)
 Copy constructor. More...
 
virtual ~ctbin (void)
 Destructor. More...
 
ctbinoperator= (const ctbin &app)
 Assignment operator. More...
 
void clear (void)
 Clear event binning tool. More...
 
void process (void)
 Process the event binning tool. More...
 
int cubes (void) const
 Return number of event cubes. More...
 
const GCTAEventCube & cube (const int &index=0) const
 Return event cube at index. More...
 
void save (void)
 Save counts cube. More...
 
void publish (const std::string &name="")
 Publish counts cube. More...
 
- Public Member Functions inherited from ctobservation
 ctobservation (const std::string &name, const std::string &version)
 Name constructor. More...
 
 ctobservation (const std::string &name, const std::string &version, const GApplicationPars &pars)
 Application parameters constructor. More...
 
 ctobservation (const std::string &name, const std::string &version, int argc, char *argv[])
 Command line constructor. More...
 
 ctobservation (const std::string &name, const std::string &version, const GObservations &obs)
 Observations constructor. More...
 
 ctobservation (const ctobservation &app)
 Copy constructor. More...
 
virtual ~ctobservation (void)
 Destructor. More...
 
ctobservationoperator= (const ctobservation &app)
 Assignment operator. More...
 
void obs (const GObservations &obs)
 Set observation container. More...
 
const GObservations & obs (void) const
 Return observation container. More...
 
- Public Member Functions inherited from ctool
 ctool (const std::string &name, const std::string &version)
 Name constructor. More...
 
 ctool (const std::string &name, const std::string &version, const GApplicationPars &pars)
 Application parameter constructor. More...
 
 ctool (const std::string &name, const std::string &version, int argc, char *argv[])
 Command line constructor. More...
 
 ctool (const ctool &app)
 Copy constructor. More...
 
virtual ~ctool (void)
 Destructor. More...
 
ctooloperator= (const ctool &app)
 Assignment operator. More...
 
virtual void run (void)
 Run ctool. More...
 
virtual void execute (void)
 Execute ctool. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const ctbin &app)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void get_parameters (void)
 Get application parameters. More...
 
void init_sky_dir_cache (void)
 Initialise sky direction cache for cube stack. More...
 
GSkyMap create_cube (const GCTAObservation *obs)
 Create counts cube sky map for current observation. More...
 
void fill_cube (const GCTAObservation *obs, GSkyMap &counts)
 Fill events into counts cube. More...
 
void set_weights (const GCTAObservation *obs, GSkyMap &weights)
 Set counts cube weights for a given observation. More...
 
void obs_cube_stacked (void)
 Create output observation container. More...
 
- Protected Member Functions inherited from ctobservation
GCTAObservation * first_unbinned_observation (void)
 Return first unbinned CTA observation. More...
 
GCTAObservation * next_unbinned_observation (void)
 Return next unbinned CTA observation. More...
 
const GCTAObservation * first_unbinned_observation (void) const
 Return first unbinned CTA observation (const version) More...
 
const GCTAObservation * next_unbinned_observation (void) const
 Return next unbinned CTA observation (const version) More...
 
void read_ogip_keywords (GFitsHDU *hdu) const
 Read OGIP keywords from FITS HDU. More...
 
void write_ogip_keywords (GFitsHDU *hdu) const
 Write OGIP keywords in FITS HDU. More...
 
void set_obs_statistic (const std::string &statistic)
 Set fit statistic for CTA observations. More...
 
void set_obs_bounds ()
 Set observation boundaries for CTA observations. More...
 
void save_events_fits (void)
 Save event list in FITS format. More...
 
void save_events_xml (void)
 Save event list(s) in XML format. More...
 
void init_members (void)
 Initialise class members. More...
 
void copy_members (const ctobservation &app)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from ctool
void init_members (void)
 Initialise class members. More...
 
void copy_members (const ctool &app)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void sync_pfiles (void)
 Synchronise parameter files. More...
 
const bool & read_ahead (void) const
 Signal whether parameters should be read ahead. More...
 
void setup_observations (GObservations &obs, const bool &response=true, const bool &list=true, const bool &cube=true)
 Setup observation container. More...
 
void setup_models (GObservations &obs, const std::string &name="")
 Setup model container. More...
 
GEbounds create_ebounds (void)
 Create energy boundaries from user parameters. More...
 
GEnergies create_energies (void)
 Create energies from user parameters. More...
 
GSkyMap create_map (const GObservations &obs)
 Create a skymap from user parameters. More...
 
GCTAEventCube create_cube (const GObservations &obs)
 Create a CTA event cube from user parameters. More...
 
GCTAObservation create_cta_obs (void)
 Create a CTA observation from User parameters. More...
 
void require_inobs (const std::string &method)
 Throws exception if inobs parameter is not valid. More...
 
void require_inobs_nolist (const std::string &method)
 
void require_inobs_nocube (const std::string &method)
 Throws exception if inobs parameter is a counts cube. More...
 
GCTARoi get_roi (const GCTAPointing &pnt=GCTAPointing())
 Return RoI from User parameters. More...
 
GEbounds get_ebounds (void)
 Return energy boundaries from User parameters. More...
 
GGti get_gti (const GTimeReference &ref)
 Return Good Time Intervals from User parameter. More...
 
GCTAPointing get_pointing (void)
 Return CTA pointing from User parameters. More...
 
GSkyDir get_skydir (void)
 Return sky direction from User parameters. More...
 
std::string set_outfile_name (const std::string &filename)
 Set output file name. More...
 
bool is_stacked (void)
 Query user parameters for stacked analysis. More...
 
bool is_onoff (void)
 Query user parameters for On/Off analysis. More...
 
void log_parameters (const GChatter &chatter)
 Log application parameters. More...
 
void log_observations (const GChatter &chatter, const GObservations &obs, const std::string &what="Observation")
 Log observation container. More...
 
void log_models (const GChatter &chatter, const GModels &models, const std::string &what="Model")
 Log model container. More...
 
void set_response (GObservations &obs)
 Set response for all CTA observations in container. More...
 
std::vector< bool > set_edisp (GObservations &obs, const bool &edisp) const
 Set energy dispersion to CTA observations. More...
 
void restore_edisp (GObservations &obs, const std::vector< bool > &edisp) const
 Restore energy dispersion flags of CTA observations. More...
 
void set_obs_response (GCTAObservation *obs)
 Set response for CTA observation. More...
 
GObservations get_observations (const bool &get_response=true)
 Get observation container. More...
 
GSkyDir get_mean_pointing (const GObservations &obs)
 Derives mean pointing from CTA observations. More...
 
size_t get_current_rss (void)
 Get current resident set size (physical memory use) in Bytes. More...
 
std::string get_obs_header (const GObservation *obs) const
 Return observation header string. More...
 
GEnergies insert_energy_boundaries (const GEnergies &energies, const GCTAObservation &obs)
 Insert observation energy boundaries into list of energies. More...
 
std::vector< bool > cube_layer_usage (const GEbounds &cube_ebounds, const GEbounds &list_ebounds) const
 Determine the counts cube layer usage. More...
 
std::string get_gtiname (const std::string &filename, const std::string &evtname) const
 Get Good Time Intervals extension name. More...
 
void save_event_list (const GCTAObservation *obs, const std::string &infile, const std::string &evtname, const std::string &gtiname, const std::string &outfile) const
 Save event list into FITS file. More...
 
std::string warn_too_few_energies (const GEnergies &energies) const
 Set warning string if there are too few energies. More...
 
std::string warn_xml_suffix (const GFilename &filename) const
 Set warning string if file has no .xml suffix. More...
 
void provide_help (void) const
 Dump help text in the console. More...
 

Protected Attributes

bool m_stack
 Output one stacked cube or multiple cubes. More...
 
std::string m_prefix
 Prefix for multiple cubes. More...
 
bool m_publish
 Publish counts cube? More...
 
GChatter m_chatter
 Chattiness. More...
 
std::vector< GCTAEventCube > m_cubes
 Event cubes. More...
 
std::vector< GSkyMap > m_counts
 List of event cube counts. More...
 
std::vector< GSkyMap > m_weights
 List of event cube weights. More...
 
GSkyDir m_mean_pnt
 Mean pointing. More...
 
GEbounds m_ebounds
 Energy boundaries. More...
 
GGti m_gti
 Stacked Good time intervals. More...
 
double m_ontime
 Total ontime. More...
 
double m_livetime
 Total livetime. More...
 
std::vector< GSkyDir > m_dirs
 Cached GSkyDir for all pixels. More...
 
- Protected Attributes inherited from ctobservation
GObservations m_obs
 Observation container. More...
 
- Protected Attributes inherited from ctool
bool m_read_ahead
 Read ahead output parameters. More...
 
bool m_use_xml
 Use XML file instead of FITS file for observations. More...
 

Detailed Description

Event binning tool.

This class bins event list(s) into counts cubes. The class can operate on predefined observation containers, on individual event list FITS files, and on observation definition XML files.

If multiple event lists are specified in the observation container or the XML definition file, the class will upon request stack these events into a single counts cube.

If the hidden parameter stack=no is used, one counts cube is generated for each individual observation. These cubes are saved to a path that can be specified by the hidden parameter prefix, followed by the corresponding observation id. An observation definition XML file containing the paths to the newly generated counts cubes is written to path given in the parameter outcube.

Results are stored in an observation container that can be written to disk in form of a single FITS file. On output, the observation container will have merged the input event lists into a single observation.

WARNING: Note that the pointing direction of the counts cube will be set to the skymap centre used for the counts cube definition. If usepnt=yes is used, the pointing direction will be extracted from the first observation encountered in the list. Ultimately, pointing direction information should not be removed from the counts cube and exposure and PSF cubes should be used for response computation. This is however not yet fully implemented.

Definition at line 69 of file ctbin.hpp.

Constructor & Destructor Documentation

ctbin::ctbin ( void  )

Void constructor.

Constructs an empty event binning tool.

Definition at line 64 of file ctbin.cpp.

References init_members().

ctbin::ctbin ( const GObservations &  obs)
explicit

Observations constructor.

param[in] obs Observation container.

Constructs event binning tool from an observation container.

Definition at line 81 of file ctbin.cpp.

References init_members().

ctbin::ctbin ( int  argc,
char *  argv[] 
)

Command line constructor.

Parameters
[in]argcNumber of arguments in command line.
[in]argvArray of command line arguments.

Constructs event binning tool using command line arguments for user parameter setting.

Definition at line 101 of file ctbin.cpp.

References init_members().

ctbin::ctbin ( const ctbin app)

Copy constructor.

Parameters
[in]appEvent binning tool.

Constructs event binning tool from another event binning tool.

Definition at line 119 of file ctbin.cpp.

References copy_members(), and init_members().

ctbin::~ctbin ( void  )
virtual

Destructor.

Destructs event binning tool.

Definition at line 137 of file ctbin.cpp.

References free_members().

Member Function Documentation

void ctbin::clear ( void  )
virtual

Clear event binning tool.

Clears event binning tool.

Implements ctobservation.

Definition at line 196 of file ctbin.cpp.

References ctool::free_members(), free_members(), ctobservation::free_members(), ctool::init_members(), init_members(), and ctobservation::init_members().

void ctbin::copy_members ( const ctbin app)
protected

Copy class members.

Parameters
[in]appApplication.

Definition at line 632 of file ctbin.cpp.

References m_chatter, m_counts, m_cubes, m_dirs, m_ebounds, m_gti, m_livetime, m_mean_pnt, m_ontime, m_prefix, m_publish, m_stack, and m_weights.

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

GSkyMap ctbin::create_cube ( const GCTAObservation *  obs)
protected

Create counts cube sky map for current observation.

Parameters
[in]obsCTA observation.

Creates a counts cube sky map for current observations.

Definition at line 757 of file ctbin.cpp.

References ctool::create_ebounds(), cube(), m_mean_pnt, and m_stack.

Referenced by process().

const GCTAEventCube & ctbin::cube ( const int &  index = 0) const

Return event cube at index.

Parameters
[in]indexCube index (0,...,cubes()-1).
Returns
Reference to event cube.
Exceptions
GException::out_of_rangeEvent cube index out of range.

Returns a reference to the event cube at the given index.

Definition at line 460 of file ctbin.cpp.

References cubes(), G_CUBE, and m_cubes.

Referenced by cscripts.obsutils::create_counts_cube(), create_cube(), get_parameters(), and obs_cube_stacked().

int ctbin::cubes ( void  ) const
inline

Return number of event cubes.

Returns
Number of event cubes.

Returns number of event cubes.

Definition at line 130 of file ctbin.hpp.

References m_cubes.

Referenced by cube(), and publish().

void ctbin::fill_cube ( const GCTAObservation *  obs,
GSkyMap &  counts 
)
protected

Fill events into counts cube.

Parameters
[in]obsCTA observation.
[in,out]countsCounts cube
Exceptions
GException::invalid_valueNo event list or valid RoI found in observation.

Fills the events from an event list into the counts cube.

Definition at line 837 of file ctbin.cpp.

References ctool::cube_layer_usage(), G_FILL_CUBE, ctool::get_obs_header(), and m_ebounds.

Referenced by process().

void ctbin::free_members ( void  )
protected

Delete class members.

Definition at line 662 of file ctbin.cpp.

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

void ctbin::get_parameters ( void  )
protected

Get application parameters.

Get all task parameters from parameter file or (if required) by querying the user. Most parameters are only required if no observation exists so far in the observation container. In this case, a single CTA observation will be added to the container, using the definition provided in the parameter file.

Definition at line 678 of file ctbin.cpp.

References ctool::create_cube(), cube(), ctool::log_parameters(), m_chatter, m_ebounds, ctobservation::m_obs, m_prefix, m_publish, m_stack, cscripts.mputils::nthreads(), ctool::read_ahead(), and ctool::setup_observations().

Referenced by process().

void ctbin::init_members ( void  )
protected

Initialise class members.

Definition at line 600 of file ctbin.cpp.

References m_chatter, m_counts, m_cubes, m_dirs, m_ebounds, m_gti, m_livetime, m_mean_pnt, m_ontime, m_prefix, m_publish, m_stack, and m_weights.

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

void ctbin::init_sky_dir_cache ( void  )
protected

Initialise sky direction cache for cube stack.

Initialises a cache that holds the sky directions of each counts cube pixel for a stacked analysis. This will speed up the computations later.

If no stacking is requested, the method does nothing.

Definition at line 727 of file ctbin.cpp.

References ctool::create_map(), m_dirs, ctobservation::m_obs, and m_stack.

Referenced by process().

void ctbin::obs_cube_stacked ( void  )
protected

Create output observation container.

Creates an output observation container that combines all input CTA observation into a single stacked observation. All non-CTA observations and all binned CTA observations that were present in the observation container are append to the observation container so that they can be used by other tools. The method furthermore conserves any response information in case that a single CTA observation is provided to support binned analysis.

< Dummy

< Dummy

Definition at line 1029 of file ctbin.cpp.

References cube(), m_counts, m_cubes, m_ebounds, m_gti, m_livetime, ctobservation::m_obs, m_ontime, m_weights, and ctobservation::obs().

Referenced by process().

ctbin & ctbin::operator= ( const ctbin app)

Assignment operator.

Parameters
[in]appEvent binning tool.
Returns
Event binning tool.

Assigns event binning tool.

Definition at line 161 of file ctbin.cpp.

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

void ctbin::process ( void  )
virtual

Process the event binning tool.

Gets the user parameters and loops over all CTA observations in the observation container to bin the events into either a single or a set of counts cube. All observations in the observation container that do not contain CTA event lists will be skipped.

Implements ctobservation.

Definition at line 227 of file ctbin.cpp.

References create_cube(), ctool::cube_layer_usage(), fill_cube(), ctobservation::first_unbinned_observation(), get_parameters(), init_sky_dir_cache(), ctool::log_observations(), m_counts, m_cubes, m_ebounds, m_gti, m_livetime, m_mean_pnt, ctobservation::m_obs, m_ontime, m_prefix, m_publish, m_stack, m_weights, ctobservation::next_unbinned_observation(), ctobservation::obs(), obs_cube_stacked(), publish(), and set_weights().

void ctbin::publish ( const std::string &  name = "")

Publish counts cube.

Parameters
[in]nameCounts cube name.

Definition at line 567 of file ctbin.cpp.

References CTBIN_NAME, cubes(), and m_counts.

Referenced by process().

void ctbin::save ( void  )
virtual

Save counts cube.

Saves the counts cube. If the counts cube was stacked single FITS file will be written. Otherwise each generated counts cube will be written into a FITS file, and an observation definition XML file will be written out that contains an observation for each counts cube.

Implements ctobservation.

Definition at line 480 of file ctbin.cpp.

References ctobservation::m_obs, m_stack, ctobservation::obs(), and ctool::warn_xml_suffix().

void ctbin::set_weights ( const GCTAObservation *  obs,
GSkyMap &  weights 
)
protected

Set counts cube weights for a given observation.

Parameters
[in]obsCTA observation.
[in,out]weightsCounts cube weights.
Exceptions
GException::invalid_valueNo event list or valid RoI found in observation.

Sets the counts cube weights for all bins that are considered for the specific observation to unity.

Definition at line 959 of file ctbin.cpp.

References ctool::cube_layer_usage(), G_SET_WEIGHTS, m_dirs, m_ebounds, and m_stack.

Referenced by process().

Member Data Documentation

GChatter ctbin::m_chatter
protected

Chattiness.

Definition at line 105 of file ctbin.hpp.

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

std::vector<GSkyMap> ctbin::m_counts
protected

List of event cube counts.

Definition at line 109 of file ctbin.hpp.

Referenced by copy_members(), init_members(), obs_cube_stacked(), process(), and publish().

std::vector<GCTAEventCube> ctbin::m_cubes
protected

Event cubes.

Definition at line 108 of file ctbin.hpp.

Referenced by copy_members(), cube(), cubes(), init_members(), obs_cube_stacked(), and process().

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

Cached GSkyDir for all pixels.

Definition at line 118 of file ctbin.hpp.

Referenced by copy_members(), init_members(), init_sky_dir_cache(), and set_weights().

GEbounds ctbin::m_ebounds
protected

Energy boundaries.

Definition at line 112 of file ctbin.hpp.

Referenced by copy_members(), fill_cube(), get_parameters(), init_members(), obs_cube_stacked(), process(), and set_weights().

GGti ctbin::m_gti
protected

Stacked Good time intervals.

Definition at line 113 of file ctbin.hpp.

Referenced by copy_members(), init_members(), obs_cube_stacked(), and process().

double ctbin::m_livetime
protected

Total livetime.

Definition at line 115 of file ctbin.hpp.

Referenced by copy_members(), init_members(), obs_cube_stacked(), and process().

GSkyDir ctbin::m_mean_pnt
protected

Mean pointing.

Definition at line 111 of file ctbin.hpp.

Referenced by copy_members(), create_cube(), init_members(), and process().

double ctbin::m_ontime
protected

Total ontime.

Definition at line 114 of file ctbin.hpp.

Referenced by copy_members(), init_members(), obs_cube_stacked(), and process().

std::string ctbin::m_prefix
protected

Prefix for multiple cubes.

Definition at line 103 of file ctbin.hpp.

Referenced by copy_members(), get_parameters(), init_members(), and process().

bool ctbin::m_publish
protected

Publish counts cube?

Definition at line 104 of file ctbin.hpp.

Referenced by copy_members(), get_parameters(), init_members(), and process().

bool ctbin::m_stack
protected

Output one stacked cube or multiple cubes.

Definition at line 102 of file ctbin.hpp.

Referenced by copy_members(), create_cube(), get_parameters(), init_members(), init_sky_dir_cache(), process(), save(), and set_weights().

std::vector<GSkyMap> ctbin::m_weights
protected

List of event cube weights.

Definition at line 110 of file ctbin.hpp.

Referenced by copy_members(), init_members(), obs_cube_stacked(), and process().


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