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

Data selection tool. More...

#include <ctselect.hpp>

Inheritance diagram for ctselect:
ctobservation ctool GApplication

Public Member Functions

 ctselect (void)
 Void constructor. More...
 
 ctselect (const GObservations &obs)
 Observations constructor. More...
 
 ctselect (int argc, char *argv[])
 Command line constructor. More...
 
 ctselect (const ctselect &app)
 Copy constructor. More...
 
virtual ~ctselect (void)
 Destructor. More...
 
ctselectoperator= (const ctselect &app)
 Assignment operator. More...
 
void clear (void)
 Clear ctselect tool. More...
 
void process (void)
 Select event data. More...
 
void save (void)
 Save the selected event list(s) More...
 
void publish (const std::string &name="")
 Publish event lists. 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 ctselect &app)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void get_parameters (void)
 Get application parameters. More...
 
void select_events (GCTAObservation *obs, const std::string &filename, const std::string &evtname, const std::string &gtiname)
 Select events. More...
 
GEbounds set_ebounds (GCTAObservation *obs, const GEbounds &ebounds) const
 Return energy boundaries for a given observation. More...
 
std::string check_infile (const std::string &filename, const std::string &evtname) const
 Check input filename. More...
 
void save_fits (void)
 Save event list in FITS format. More...
 
void save_xml (void)
 Save event list(s) in XML format. 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

std::string m_outobs
 Output event list or XML file. More...
 
double m_emin
 Lower energy. More...
 
double m_emax
 Upper energy. More...
 
std::string m_expr
 Selection expression. More...
 
std::string m_usethres
 Energy threshold type. More...
 
GChatter m_chatter
 Chattiness. More...
 
bool m_forcesel
 Enforce RoI selection. More...
 
std::vector< std::string > m_infiles
 Input event filenames. More...
 
std::vector< std::string > m_evtname
 Event extension names. More...
 
std::vector< std::string > m_gtiname
 GTI extension names. More...
 
GPhases m_phases
 Phase intervals. More...
 
bool m_select_energy
 Perform energy selection. More...
 
bool m_select_phase
 Perform phase selection. 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

Data selection tool.

Definition at line 46 of file ctselect.hpp.

Constructor & Destructor Documentation

ctselect::ctselect ( void  )

Void constructor.

Definition at line 56 of file ctselect.cpp.

References init_members().

ctselect::ctselect ( const GObservations &  obs)
explicit

Observations constructor.

param[in] obs Observation container.

Creates an instance of the class that is initialised using the information provided in an observation container.

Definition at line 74 of file ctselect.cpp.

References init_members().

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

Command line constructor.

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

Definition at line 93 of file ctselect.cpp.

References init_members().

ctselect::ctselect ( const ctselect app)

Copy constructor.

Parameters
[in]appApplication.

Definition at line 109 of file ctselect.cpp.

References copy_members(), and init_members().

ctselect::~ctselect ( void  )
virtual

Destructor.

Definition at line 125 of file ctselect.cpp.

References free_members().

Member Function Documentation

std::string ctselect::check_infile ( const std::string &  filename,
const std::string &  evtname 
) const
protected

Check input filename.

Parameters
[in]filenameFile name.
[in]evtnameEvent extension name.

This method checks if the input FITS file is correct.

Definition at line 1234 of file ctselect.cpp.

Referenced by process().

void ctselect::clear ( void  )
virtual

Clear ctselect tool.

Clears ctselect tool.

Implements ctobservation.

Definition at line 182 of file ctselect.cpp.

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

void ctselect::copy_members ( const ctselect app)
protected

Copy class members.

Parameters
[in]appApplication.

Definition at line 476 of file ctselect.cpp.

References m_chatter, m_emax, m_emin, m_evtname, m_expr, m_forcesel, m_gtiname, m_infiles, m_outobs, m_phases, m_select_energy, m_select_phase, and m_usethres.

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

void ctselect::free_members ( void  )
protected

Delete class members.

Definition at line 503 of file ctselect.cpp.

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

void ctselect::get_parameters ( void  )
protected

Get application parameters.

Get all user parameters from parameter file or (if required) by querying the user. Times are assumed to be in the native CTA MJD format.

This method also loads observations if no observations are yet allocated. Observations are either loaded from a single CTA even list, or from a XML file using the metadata information that is stored in that file.

Definition at line 520 of file ctselect.cpp.

References G_GET_PARAMETERS, ctool::get_gti(), ctool::get_roi(), ctool::log_parameters(), m_chatter, m_emax, m_emin, m_expr, m_forcesel, ctobservation::m_obs, m_phases, m_select_energy, m_select_phase, m_usethres, ctool::read_ahead(), and ctool::setup_observations().

Referenced by process().

void ctselect::init_members ( void  )
protected

Initialise class members.

Definition at line 447 of file ctselect.cpp.

References m_chatter, m_emax, m_emin, m_evtname, m_expr, m_forcesel, m_gtiname, m_infiles, m_outobs, m_phases, m_select_energy, m_select_phase, and m_usethres.

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

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

Assignment operator.

Parameters
[in]appApplication.
Returns
Application.

Definition at line 147 of file ctselect.cpp.

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

void ctselect::process ( void  )
virtual

Select event data.

This method reads in the application parameters and loops over all observations that were found to perform an event selection. Event selection is done by writing each observation to a temporary file and re-opening the temporary file using the cfitsio event filter syntax. The temporary file is deleted after this action so that no disk overflow will occur.

Implements ctobservation.

Definition at line 215 of file ctselect.cpp.

References check_infile(), G_PROCESS, ctool::get_gtiname(), ctool::get_obs_header(), get_parameters(), ctool::log_observations(), m_evtname, m_gtiname, m_infiles, ctobservation::m_obs, ctool::m_use_xml, ctobservation::obs(), publish(), and select_events().

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

Publish event lists.

Parameters
[in]nameEvent list name.

Definition at line 389 of file ctselect.cpp.

References CTSELECT_NAME, ctobservation::m_obs, ctool::m_use_xml, and ctobservation::obs().

Referenced by process().

void ctselect::save ( void  )
virtual

Save the selected event list(s)

This method saves the selected event list(s) into FITS file(s). There are two modes, depending on the m_use_xml flag.

If m_use_xml is true, all selected event list(s) will be saved into FITS files, where the output filenames are constructued from the input filenames by prepending the prefix string to name. Any path information will be stripped form the input name, hence event files will be written into the local working directory (unless some path information is present in the prefix). In addition, an XML file will be created that gathers the filename information for the selected event list(s). If an XML file was present on input, all metadata information will be copied from this input file.

If m_use_xml is false, the selected event list will be saved into a FITS file.

Implements ctobservation.

Definition at line 364 of file ctselect.cpp.

References ctobservation::m_obs, ctool::m_use_xml, save_fits(), and save_xml().

void ctselect::save_fits ( void  )
protected

Save event list in FITS format.

Save the event list as a FITS file. The file name of the FITS file is specified by the "outobs" parameter.

Definition at line 1304 of file ctselect.cpp.

References m_evtname, m_gtiname, m_infiles, ctobservation::m_obs, m_outobs, ctobservation::obs(), and ctool::save_event_list().

Referenced by save().

void ctselect::save_xml ( void  )
protected

Save event list(s) in XML format.

Save the event list(s) into FITS files and write the file path information into a XML file. The filename of the XML file is specified by the outfile parameter, the filename(s) of the event lists are built by prepending a prefix to the input event list filenames. Any path present in the input filename will be stripped, i.e. the event list(s) will be written in the local working directory (unless a path is specified in the prefix).

Definition at line 1364 of file ctselect.cpp.

References m_evtname, m_gtiname, m_infiles, ctobservation::m_obs, m_outobs, ctobservation::obs(), ctool::save_event_list(), ctool::set_outfile_name(), and ctool::warn_xml_suffix().

Referenced by save().

void ctselect::select_events ( GCTAObservation *  obs,
const std::string &  filename,
const std::string &  evtname,
const std::string &  gtiname 
)
protected

Select events.

Parameters
[in,out]obsCTA observation.
[in]filenameFile name.
[in]evtnameEvent extension name.
[in]gtinameGTI extension name.
Exceptions
GException::invalid_valueNo events extension found in FITS file.

Select events from a FITS file by making use of the selection possibility of the cfitsio library on loading a file. A selection string is created from the specified criteria that is appended to the filename so that cfitsio will automatically filter the event data. This selection string is then applied when opening the FITS file. The event list in the current observation is replaced by selected event list read from the FITS file.

Good Time Intervals of the observation will be limited to the time interval specified by the User parameters tmin and tmax.

Definition at line 673 of file ctselect.cpp.

References G_PROCESS, G_SELECT_EVENTS, ctool::get_gti(), ctool::get_roi(), m_chatter, m_expr, m_forcesel, m_phases, m_select_energy, m_select_phase, and set_ebounds().

Referenced by process().

GEbounds ctselect::set_ebounds ( GCTAObservation *  obs,
const GEbounds &  ebounds 
) const
protected

Return energy boundaries for a given observation.

Parameters
[in]obsPointer to CTA observation.
[in]eboundsCurrent energy boundaries.
Returns
Energy boundaries.

Returns the energy boundaries for a given observation. Depending on the value of the usethres parameter, the following values will be returned:

NONE:    [max(emin,emin_exist),min(emax,emax_exist)]
DEFAULT: [max(emin,emin_exist,emin_safe),min(emax,emax_exist,emax_safe)]
USER:    [max(emin,emin_exist,emin_user),min(emax,emax_exist,emax_user)]

where

emin is the value of the emin parameter
emax is the value of the emax parameter
emin_exist is the value of any existing minimum boundary
emax_exist is the value of any existing maximum boundary
emin_safe is the lower safe threshold
emax_safe is the upper safe threshold
emin_user is the lower user threshold
emax_user is the upper user threshold

Any threshold value of 0 will be ignored.

Definition at line 1120 of file ctselect.cpp.

References G_SET_EBOUNDS, m_emax, m_emin, and m_usethres.

Referenced by select_events().

Member Data Documentation

GChatter ctselect::m_chatter
protected

Chattiness.

Definition at line 88 of file ctselect.hpp.

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

double ctselect::m_emax
protected

Upper energy.

Definition at line 85 of file ctselect.hpp.

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

double ctselect::m_emin
protected

Lower energy.

Definition at line 84 of file ctselect.hpp.

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

std::vector<std::string> ctselect::m_evtname
protected

Event extension names.

Definition at line 93 of file ctselect.hpp.

Referenced by copy_members(), init_members(), process(), save_fits(), and save_xml().

std::string ctselect::m_expr
protected

Selection expression.

Definition at line 86 of file ctselect.hpp.

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

bool ctselect::m_forcesel
protected

Enforce RoI selection.

Definition at line 89 of file ctselect.hpp.

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

std::vector<std::string> ctselect::m_gtiname
protected

GTI extension names.

Definition at line 94 of file ctselect.hpp.

Referenced by copy_members(), init_members(), process(), save_fits(), and save_xml().

std::vector<std::string> ctselect::m_infiles
protected

Input event filenames.

Definition at line 92 of file ctselect.hpp.

Referenced by copy_members(), init_members(), process(), save_fits(), and save_xml().

std::string ctselect::m_outobs
protected

Output event list or XML file.

Definition at line 83 of file ctselect.hpp.

Referenced by copy_members(), init_members(), save_fits(), and save_xml().

GPhases ctselect::m_phases
protected

Phase intervals.

Definition at line 95 of file ctselect.hpp.

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

bool ctselect::m_select_energy
protected

Perform energy selection.

Definition at line 96 of file ctselect.hpp.

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

bool ctselect::m_select_phase
protected

Perform phase selection.

Definition at line 97 of file ctselect.hpp.

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

std::string ctselect::m_usethres
protected

Energy threshold type.

Definition at line 87 of file ctselect.hpp.

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


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