ctools  2.0.0
 All Classes Namespaces Files Functions Variables Macros Pages
ctool Class Referenceabstract

Base class for ctools. More...

#include <ctool.hpp>

Inheritance diagram for ctool:
GApplication ctmapcube ctobservation ctool_base ctbin ctbkgcube ctcubemask ctedispcube ctexpcube ctfindvar ctlikelihood ctmodel ctobssim ctool_obs ctphase ctprob ctpsfcube ctselect ctskymap

Public Member Functions

 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 clear (void)=0
 
virtual void process (void)=0
 
virtual void save (void)=0
 
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 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_read_ahead
 Read ahead output parameters. More...
 
bool m_use_xml
 Use XML file instead of FITS file for observations. More...
 

Detailed Description

Base class for ctools.

This class is the generic base class for all ctools. It enforces implementation of the clear(), run() and save() methods by all ctools, and it implements the execute() method.

The class also provides a number of helper methods for ctools.

Definition at line 50 of file ctool.hpp.

Constructor & Destructor Documentation

ctool::ctool ( const std::string &  name,
const std::string &  version 
)

Name constructor.

Parameters
[in]nameApplication name.
[in]versionApplication version.

Constructs a ctool from the name and version. The constructor uses the equivalent GApplication constructor to set the parameter filename to "<name>.par" and the log filename to "<name>".log. The parameters will be loaded from the parameter file.

No log file will be opened. To open the log file an explicit call to the logFileOpen() method is required.

This constructor should be used for using a ctool from Python.

Definition at line 90 of file ctool.cpp.

References init_members(), and sync_pfiles().

ctool::ctool ( const std::string &  name,
const std::string &  version,
const GApplicationPars &  pars 
)

Application parameter constructor.

Parameters
[in]nameApplication name.
[in]versionApplication version.
[in]parsApplication parameters.

Constructs a ctool from the name, version and application parameters pars. The constructor uses the equivalent GApplication constructor to set the parameter filename to "<name>.par" and the log filename to "<name>".log. The constructor opens the log file.

Definition at line 116 of file ctool.cpp.

References init_members().

ctool::ctool ( const std::string &  name,
const std::string &  version,
int  argc,
char *  argv[] 
)

Command line constructor.

Parameters
[in]nameApplication name.
[in]versionApplication version.
[in]argcNumber of arguments in command line.
[in]argvArray of command line arguments.

Constructs a ctool from the name, version and command line arguments. The constructor uses the equivalent GApplication constructor to set the parameter filename to "<name>.par" and the log filename to "<name>".log. The parameters will be loaded from the parameter file. In addition, the constructor opens the log file.

If the "--help" option is provided as command line argument a help text about the usage of the ctool will be shown in the console and the ctool will exit. No log file will be opened in that case.

Definition at line 149 of file ctool.cpp.

References init_members(), provide_help(), and sync_pfiles().

ctool::ctool ( const ctool app)

Copy constructor.

Parameters
[in]appApplication.

Construct a ctools from another ctool instance.

Definition at line 181 of file ctool.cpp.

References copy_members(), and init_members().

ctool::~ctool ( void  )
virtual

Destructor.

Definition at line 197 of file ctool.cpp.

References free_members().

Member Function Documentation

void ctool::copy_members ( const ctool app)
protected

Copy class members.

Parameters
[in]appApplication.

Definition at line 343 of file ctool.cpp.

References m_read_ahead, and m_use_xml.

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

GCTAObservation ctool::create_cta_obs ( void  )
protected

Create a CTA observation from User parameters.

Creates an empty CTA observation from User parameters. An empty event list including RoI, GTI and energy boundary information is attached to the observation. The method also sets the pointing direction using the ra and dec parameter, the ROI based on ra, dec and rad, a single GTI based on tmin and tmax, and a single energy boundary based on emin and emax. The method furthermore sets the ontime, livetime and deadtime correction factor.

The following parameters are read

 ra:         Right Ascension of pointing and RoI centre (deg)
 dec:        Declination of pointing and RoI centre (deg)
 rad:        Radius of RoI (deg)
 deadc:      Deadtime correction factor
 tmin:       Start time
 tmax:       Stop time
 emin:       Minimum energy (TeV)
 emax:       Maximum energy (TeV)
 mjdref:     Time reference (optional)
 instrument: Name of Cherenkov Telescope (optional)

If the time reference parametere "mjdref" is not available, the CTA time reference will be assumed.

Definition at line 1056 of file ctool.cpp.

References get_ebounds(), get_gti(), get_pointing(), and get_roi().

Referenced by ctmodel::get_obs(), and get_observations().

GCTAEventCube ctool::create_cube ( const GObservations &  obs)
protected

Create a CTA event cube from user parameters.

Parameters
[in]obsObservation container.

Creates an empty CTA event cube from input user parameters. The reference coordinate is extracted from the mean pointing of the CTA observations in the observation container (see get_mean_pointing()). This method will be used if a ctool has the input parameter usepnt=true. The method appends a dummy GTI to the event cube.

The following parameters are read: proj - Coordinate projection coordsys - Coordinate system binsz - Bin size (deg) nxpix - Number of pixels in Right Ascension or longitude nypix - Number of pixels in Declination or latitude ebinalg - Energy binning algorithm emin - Minimum energy (if ebinalg != FILE) emax - Maximum energy (if ebinalg != FILE) enumbins - Number of energy bins (if ebinalg != FILE)

Definition at line 1006 of file ctool.cpp.

References create_ebounds(), and create_map().

Referenced by ctedispcube::get_parameters(), ctpsfcube::get_parameters(), ctexpcube::get_parameters(), ctmodel::get_parameters(), and ctbin::get_parameters().

GEbounds ctool::create_ebounds ( void  )
protected

Create energy boundaries from user parameters.

Exceptions
GException::invalid_valueNo valid energy boundary extension found or invalid extension name.

Get the energy boundaries according to the user parameters. The method supports loading of energy boundary information from the EBOUNDS or ENERGYBINS extension, loading of energy value information from the ENERGIES extension, or setting energy boundaries using a linear or logarithmical spacing.

The following parameters are read:

 ebinalg - Energy binning algorithm
 ebinfile - Name of file with energy binning
 emin - Minimum energy (if ebinalg != FILE)
 emax - Maximum energy (if ebinalg != FILE)
 enumbins - Number of energy bins (if ebinalg != FILE)

Definition at line 612 of file ctool.cpp.

References G_CREATE_EBOUNDS.

Referenced by ctbin::create_cube(), create_cube(), ctmodel::get_obs(), ctmapcube::get_parameters(), and ctbutterfly::get_parameters().

GEnergies ctool::create_energies ( void  )
protected

Create energies from user parameters.

Exceptions
GException::invalid_valueNo valid energies extension found or invalid extension name.

Get the energy boundaries according to the user parameters. The method supports loading of energy node information from the ENERGIES extension, loading energy nodes from energy the boundary extensions EBOUNDS or ENERGYBINS extension, or setting energy nodes using a linear or logarithmical spacing.

The following parameters are read:

 ebinalg - Energy binning algorithm
 ebinfile - Name of file with energy binning (if ebinalg == FILE)
 emin - Minimum energy (if ebinalg != FILE)
 emax - Maximum energy (if ebinalg != FILE)
 enumbins - Number of energy bins (if ebinalg != FILE)
 ebingamma - Power law index (if ebinalg == POW)

Definition at line 776 of file ctool.cpp.

References G_CREATE_ENERGIES.

GSkyMap ctool::create_map ( const GObservations &  obs)
protected

Create a skymap from user parameters.

Parameters
[in]obsObservation container.

Creates an empty skymap from input user parameters. The reference coordinate is extracted from the mean pointing of the CTA observations in the observation container (see get_mean_pointing()).

The following parameters are read: usepnt - Use pointing for reference coordinate? xref - Reference in Right Ascension or longitude (if usepnt=no) yref - Reference in Declination or latitude (if usepnt=no) proj - Coordinate projection coordsys - Coordinate system binsz - Bin size (deg) nxpix - Number of pixels in Right Ascension or longitude nypix - Number of pixels in Declination or latitude

Definition at line 937 of file ctool.cpp.

References get_mean_pointing().

Referenced by ctfindvar::create_cube(), create_cube(), ctfindvar::get_parameters(), ctskymap::get_parameters(), cttsmap::get_parameters(), and ctbin::init_sky_dir_cache().

std::vector< bool > ctool::cube_layer_usage ( const GEbounds &  cube_ebounds,
const GEbounds &  list_ebounds 
) const
protected

Determine the counts cube layer usage.

Parameters
[in]cube_eboundsEnergy boundaries of the counts cube.
[in]list_eboundsEnergy boundaries of the event list.
Returns
Vector of usage flags.

Determines a vector of counts cube layer usage flags that signal whether an event should actually be filled in the counts cube or not. This makes sure that no partially filled bins will exist in the counts cube.

Definition at line 2194 of file ctool.cpp.

Referenced by ctmodel::fill_cube(), ctbin::fill_cube(), ctbin::process(), and ctbin::set_weights().

void ctool::execute ( void  )
virtual

Execute ctool.

This method executes a ctool by calling the process() and save() methods of a ctool. The method signals that some parameters should be read ahead and switches on screen dump in case that the debug parameter is true.

Definition at line 285 of file ctool.cpp.

References m_read_ahead, process(), and save().

Referenced by execute_ctool().

size_t ctool::get_current_rss ( void  )
protected

Get current resident set size (physical memory use) in Bytes.

Returns
Physical memory use in Bytes.
Todo:
This method is currently not used and can be removed if we do not use it

Definition at line 2035 of file ctool.cpp.

GEbounds ctool::get_ebounds ( void  )
protected

Return energy boundaries from User parameters.

Returns
Energy boundaries.

Returns energy boundaries from the User parameters emin and emax. If one of emin or emax is not valid, an empty energy boundaries object is returned. If emin is not valid, emax is not queried.

Definition at line 1378 of file ctool.cpp.

Referenced by create_cta_obs(), and ctobssim::simulate_source().

GGti ctool::get_gti ( const GTimeReference &  ref)
protected

Return Good Time Intervals from User parameter.

Parameters
[in]refTime reference.
Returns
Good Time Intervals.

Returns Good Time Intervals from the User parameters tmin and tmax, taking into account the transformation into the CTA reference time system. If one of tmin or tmax is not valid, an empty Good Time Interval object is returned. If tmin is not valid, tmax is not queried.

Definition at line 1415 of file ctool.cpp.

Referenced by create_cta_obs(), ctselect::get_parameters(), and ctselect::select_events().

std::string ctool::get_gtiname ( const std::string &  filename,
const std::string &  evtname 
) const
protected

Get Good Time Intervals extension name.

Parameters
[in]filenameInput file name.
[in]evtnameEvents extension name.

Extracts the Good Time Intervals extension name from the event file. We do this by loading the events and accessing the Good Time Intervals extension name using the GCTAEventList::gtiname() method. If the file name is empty, the method returns GTI.

Definition at line 2352 of file ctool.cpp.

Referenced by ctselect::process(), and ctobservation::save_events_xml().

GSkyDir ctool::get_mean_pointing ( const GObservations &  obs)
protected

Derives mean pointing from CTA observations.

Parameters
[in]obsObservation container.
Returns
Pointing direction.

Computes the mean pointing direction from all CTA observations in the observation container.

Todo:
This method does not work properly for wrap arounds in Right Ascension. It certainly will also lead to bad results near the celestial pole.

Definition at line 1979 of file ctool.cpp.

References G_GET_MEAN_POINTING.

Referenced by create_map().

std::string ctool::get_obs_header ( const GObservation *  obs) const
protected

Return observation header string.

Parameters
[in]obsPointer to observation.
Returns
String containing observation information.

Returns a string that contains observation information, including the instrument name, the observation name, and the observation ID. The format of the string is

 XXX observation "name" (id=YYYYY)

Definition at line 2090 of file ctool.cpp.

Referenced by ctfindvar::fill_cube(), ctmodel::fill_cube(), ctbin::fill_cube(), ctskymap::fill_maps_acceptance(), ctskymap::fill_maps_counts(), ctfindvar::get_alphas(), ctobservation::next_unbinned_observation(), ctselect::process(), ctcubemask::process(), ctobssim::process(), and ctmodel::process().

GObservations ctool::get_observations ( const bool &  get_response = true)
protected

Get observation container.

Parameters
[in]get_responseIndicates whether response information should be loaded (default: true)

Get an observation container according to the user parameters. The method supports loading of a individual FITS file or an observation definition file in XML format. If the input filename is empty, parameters are read to build a CTA observation from scratch.

Definition at line 1885 of file ctool.cpp.

References create_cta_obs(), m_use_xml, set_obs_response(), and set_response().

Referenced by ctobssim::get_parameters().

GCTAPointing ctool::get_pointing ( void  )
protected

Return CTA pointing from User parameters.

Returns
CTA pointing.

Returns CTA pointing from the User parameters ra and dec.

Definition at line 1445 of file ctool.cpp.

References get_skydir().

Referenced by create_cta_obs().

GCTARoi ctool::get_roi ( const GCTAPointing &  pnt = GCTAPointing())
protected

Return RoI from User parameters.

Parameters
[in]pntPointing direction.
Returns
Region of Interest.

Returns Region of Interest (RoI) from the User parameters ra, dec and rad. If any of the parameters ra, dec or rad is not valid an invalid RoI is returned.

If the usepnt parameter exists and is set to yes, the RoI centre will be taken from the specified pointing direction instead of the ra and dec parameters. Make sure to provide a valid pointing direction in case that you want to use the usepnt User parameter.

Definition at line 1325 of file ctool.cpp.

References get_skydir().

Referenced by ctcubemask::apply_mask(), create_cta_obs(), ctselect::get_parameters(), ctcubemask::get_parameters(), and ctselect::select_events().

GSkyDir ctool::get_skydir ( void  )
protected

Return sky direction from User parameters.

Returns
Sky direction.

Returns sky direction from the User parameters ra and dec.

Definition at line 1465 of file ctool.cpp.

Referenced by get_pointing(), and get_roi().

GEnergies ctool::insert_energy_boundaries ( const GEnergies &  energies,
const GCTAObservation &  obs 
)
protected

Insert observation energy boundaries into list of energies.

Parameters
[in]energiesEnergies.
[in]obsObservation container.
Returns
Energies.

Inserts the energy boundaries of an observation in a list of energies.

Definition at line 2119 of file ctool.cpp.

Referenced by ctedispcube::init_cube(), ctpsfcube::init_cube(), and ctexpcube::init_cube().

bool ctool::is_onoff ( void  )
protected

Query user parameters for On/Off analysis.

Returns
True if an On/Off analysis should be done.

Queries the parameter "method", and if this is "ONOFF" signal that an On/ Off analysis is requested. In that case, all necessary input parameters of csphagen are queried: "inexclusion", "emin", "emax", "enumbins", "coordsys", "xref", "yref", "srcshape", "rad", "bkgmethod", "bkgregmin", "maxoffset", "etruemin", "etruemax", and "etruebins".

Using this method assures that the parameters are always queried in the same order.

Definition at line 1571 of file ctool.cpp.

bool ctool::is_stacked ( void  )
protected

Query user parameters for stacked analysis.

Returns
True if a stacked analysis should be done.

Queries the user parameters emin, emax and enumbins, and if enumbins is positive, signal that a stacked analysis is requested. In that case, also the coordsys, proj, xref, yref, nxpix, nypix and binsz parameters are queried.

Using this method assures that the parameters are always queried in the same order.

Definition at line 1531 of file ctool.cpp.

void ctool::log_models ( const GChatter &  chatter,
const GModels &  models,
const std::string &  what = "Model" 
)
protected

Log model container.

Parameters
[in]chatterMinimum required chattiness
[in]modelsModel container
[in]whatString specifying the container content

Log models if chattiness is at least chatter.

Definition at line 1285 of file ctool.cpp.

Referenced by ctmapcube::process(), ctbkgcube::process(), and ctmodel::process().

void ctool::log_observations ( const GChatter &  chatter,
const GObservations &  obs,
const std::string &  what = "Observation" 
)
protected

Log observation container.

Parameters
[in]chatterMinimum required chattiness
[in]obsObservation container
[in]whatString specifying the container content

Log observations if chattiness is at least chatter.

Definition at line 1251 of file ctool.cpp.

Referenced by ctskymap::fill_maps(), cterror::process(), ctlike::process(), ctool_like::process(), ctool_obs::process(), ctedispcube::process(), ctbkgcube::process(), ctexpcube::process(), ctpsfcube::process(), ctfindvar::process(), ctprob::process(), ctselect::process(), ctcubemask::process(), ctphase::process(), ctulimit::process(), ctobssim::process(), ctmodel::process(), cttsmap::process(), ctbutterfly::process(), and ctbin::process().

void ctool::log_parameters ( const GChatter &  chatter)
protected
ctool & ctool::operator= ( const ctool app)

Assignment operator.

Parameters
[in]appApplication.
Returns
Application.

Assigns one ctool application to another.

Definition at line 221 of file ctool.cpp.

References copy_members(), free_members(), and init_members().

Referenced by ctool_base::operator=(), ctmapcube::operator=(), and ctobservation::operator=().

void ctool::provide_help ( void  ) const
protected

Dump help text in the console.

Dumps the help text for the ctool into the console. The help text is located in the folder

 $CTOOLS//share/help/

of the ctools installation and the help file has the name "name().txt", where name() stands for the name of the ctool.

Definition at line 2467 of file ctool.cpp.

References G_PROVIDE_HELP.

Referenced by ctool().

const bool & ctool::read_ahead ( void  ) const
inlineprotected

Signal whether parameters should be read ahead.

Returns
True if parameters should be read ahead

Ahead reading of parameter is useful in case that some parameters are only required in a late stage of the processing. By reading them ahead it is assured that these parameters will be queried at the beginning of the tool execution.

Definition at line 177 of file ctool.hpp.

References m_read_ahead.

Referenced by cterror::get_parameters(), ctpsfcube::get_parameters(), ctedispcube::get_parameters(), ctfindvar::get_parameters(), ctlike::get_parameters(), ctmapcube::get_parameters(), ctexpcube::get_parameters(), ctselect::get_parameters(), ctprob::get_parameters(), ctbkgcube::get_parameters(), ctcubemask::get_parameters(), ctphase::get_parameters(), ctskymap::get_parameters(), ctobssim::get_parameters(), ctbutterfly::get_parameters(), ctmodel::get_parameters(), cttsmap::get_parameters(), ctbin::get_parameters(), and ctobssim::process().

void ctool::require_inobs ( const std::string &  method)
protected

Throws exception if inobs parameter is not valid.

Parameters
[in]methodMethod name.

Throw an exception if the "inobs" parameter is either "NONE" or an empty string.

Todo:
This method is only used by csobsinfo, csresmap and csspec. We should try to get rid of it

Definition at line 1119 of file ctool.cpp.

void ctool::require_inobs_nocube ( const std::string &  method)
protected

Throws exception if inobs parameter is a counts cube.

Parameters
[in]methodMethod name.

Throw an exception if the inobs parameter is a counts cube.

Todo:
This method is only used by ctobssim. We should try to get rid of it

Definition at line 1149 of file ctool.cpp.

Referenced by ctobssim::get_parameters().

void ctool::require_inobs_nolist ( const std::string &  method)
protected
void ctool::restore_edisp ( GObservations &  obs,
const std::vector< bool > &  edisp 
) const
protected

Restore energy dispersion flags of CTA observations.

Parameters
[in]obsObservation container.
[in]edispVector of energy dispersion flags.

Restores energy dispersion flags that have previously been returned by the set_edisp() method. The number of observations between the calls of the set_edisp() and this method has to be the same.

Definition at line 1689 of file ctool.cpp.

References G_RESTORE_EDISP.

Referenced by cterror::process(), ctlike::process(), ctprob::process(), ctobssim::process(), ctulimit::process(), ctmodel::process(), and cttsmap::process().

void ctool::run ( void  )
virtual

Run ctool.

This method runs a ctool by calling the process() method of a ctool. The method switches on screen dump in case that the debug parameter is true.

Definition at line 257 of file ctool.cpp.

References process().

Referenced by cscripts.obsutils::create_counts_cube().

void ctool::save_event_list ( const GCTAObservation *  obs,
const std::string &  infile,
const std::string &  evtname,
const std::string &  gtiname,
const std::string &  outfile 
) const
protected

Save event list into FITS file.

Parameters
[in]obsPointer to CTA observation.
[in]infileInput file name.
[in]evtnameEvent extension name.
[in]gtinameGTI extension name.
[in]outfileOutput file name.

Saves an event list and the corresponding Good Time Intervals into a FITS file and copy all others extensions from the input file to the output file.

If an extension name is specified in the outfile argument, the events and eventually also the Good Time Intervals will be extracted from the argument and used for writing the events. The format is

 <filename>[<event extension name;GTI extension name>]

where <filename> needs to be replaced by the name of the FITS file, and <event extension name;GTI extension name> by the name of the events and Good Time Intervals extensions. For example

 myfits.fits[EVENTS1;GTI1]

will write the selected events into the EVENTS1 extension and the Good Time Intervals into the GTI1 extension of the myfits.fits FITS file. If the Good Time Intervals extension name is skipped, e.g.

 myfits.fits[EVENTS1]

the original extension name for the Good Time Intervals will be kept. Analogously, only the Good Time Intervals extension name can be changed by specifying

 myfits.fits[;GTI1]

In none of the cases will the original events and Good Time Intervals be copied over to the output file.

Definition at line 2266 of file ctool.cpp.

Referenced by ctobservation::save_events_fits(), ctobservation::save_events_xml(), ctselect::save_fits(), and ctselect::save_xml().

std::vector< bool > ctool::set_edisp ( GObservations &  obs,
const bool &  edisp 
) const
protected

Set energy dispersion to CTA observations.

Parameters
[in]obsObservation container.
[in]edispRequested energy dispersion flag.
Returns
Vector of old energy dispersion flags.

Applies energy dispersion to all CTA observations. The method returns a vector with the old energy dispersion flags.

Definition at line 1649 of file ctool.cpp.

Referenced by cterror::process(), ctlike::process(), ctprob::process(), ctobssim::process(), ctulimit::process(), ctmodel::process(), and cttsmap::process().

void ctool::set_obs_response ( GCTAObservation *  obs)
protected

Set response for CTA observation.

Parameters
[in,out]obsCTA observation
Exceptions
GException::invalid_valueEnergy dispersion requested but not energy dispersion cube given

Set the response for one CTA observation. If the CTA observation contains a counts cube the method first attempts to set the response information using the following user parameters

 expcube:   Exposure cube file
 psfcube:   Point spread function cube file
 edispcube: Energy dispersion cube file (optional)
 bkgcube:   Background cube file

If none of the expcube, psfcube and bkgcube parameters is "NONE" or empty, the method will allocate a stacked response for the observation. In case that an energy dispersion cube is provided using the edispcube parameter, this energy dispersion cube is also loaded and attached to the stacked response function.

In case that any of the expcube, psfcube and bkgcube parameters is "NONE" or empty, the method will assume that a IRF response should be used, and will attempty to set the response information using the following user parameters

 caldb:     Calibration database
 irf:       Instrument response function

Definition at line 1752 of file ctool.cpp.

References G_SET_OBS_RESPONSE.

Referenced by ctmodel::get_obs(), get_observations(), and set_response().

std::string ctool::set_outfile_name ( const std::string &  filename)
protected

Set output file name.

Parameters
[in]filenameInput file name.
Returns
Output file name.

Converts an input file name into an output filename by prepending the prefix specified by the prefix parameter to the input file name. Any path as well as extension will be stripped from the input file name. Also a trailing .gz will be stripped as one cannot write into gzipped files.

Definition at line 1491 of file ctool.cpp.

Referenced by ctobservation::save_events_xml(), and ctselect::save_xml().

void ctool::set_response ( GObservations &  obs)
protected

Set response for all CTA observations in container.

Parameters
[in,out]obsObservation container

Set the response for all CTA observations in the container that so far have no response information available. See the set_obs_response() method for more information about the user parameters that are read.

Definition at line 1614 of file ctool.cpp.

References set_obs_response().

Referenced by ctmodel::get_obs(), get_observations(), ctskymap::get_parameters(), and setup_observations().

void ctool::setup_models ( GObservations &  obs,
const std::string &  name = "" 
)
protected

Setup model container.

Parameters
[in]obsObservation container
[in]nameMandatory model name
Exceptions
GException::invalid_valueModel definiton XML filename not valid or mandatory model name not found in model container.

Setup a model container by loading the models from the "inmodel" parameter.

If the model container in the observation container obs is empty, the method will extract the model container filename from the "inmodel" parameter, load the model container and assign it to the observations container. If the filename is either empty or "NONE" the method will throw an exception.

If a mandatory model name is specified, the method will further check whether a model with the name exists in the model container. If it does not exist, an exception is thrown.

Definition at line 545 of file ctool.cpp.

References G_SETUP_MODELS.

Referenced by cterror::get_parameters(), ctbkgcube::get_parameters(), ctulimit::get_parameters(), ctbutterfly::get_parameters(), and cttsmap::get_parameters().

void ctool::setup_observations ( GObservations &  obs,
const bool &  response = true,
const bool &  list = true,
const bool &  cube = true 
)
protected

Setup observation container.

Parameters
[in]obsObservation container
[in]responseRequire response
[in]listAccept event list as "inobs" parameter
[in]cubeAccept counts cube as "inobs" parameter
Exceptions
GException::invalid_valueInvalid "inobs" parameter encountered.

Setup an observation container by extracting all required missing information from user parameters.

If the observation container obs is empty, the method will extract the filename from the "inobs" parameter and load the observation container from the specified file. If the filename is either empty or "NONE" the method will throw an exception.

If the "inobs" file is a FITS file, and depending on the information that is found in the FITS file, the method will append a single CTA observation to the observation container, containing either an event list or a counts cube. It will set the m_use_xml member to false to signal that no observation XML file should be used for saving. The list and cube parameters can be used to specify whether the method actually should accept event lists or counts cube. If it shouldn't the method will throw an exception.

If the "inobs" file is not a FITS file, the method assumes that an observation definition XML file has been specified, and will load that file into the observation container. It will set the m_use_xml member to true to signal that an observation XML file should be used for saving. No checking on event list or counts cubes will be done on the observation container.

By default, the method will also setup the response for all CTA observations in the container. In case that no response information is required, the response argument should be set to false. See the set_response() method for details.

Definition at line 431 of file ctool.cpp.

References G_SETUP_OBSERVATION, m_use_xml, and set_response().

Referenced by cterror::get_parameters(), ctedispcube::get_parameters(), ctpsfcube::get_parameters(), ctfindvar::get_parameters(), ctlike::get_parameters(), ctexpcube::get_parameters(), ctprob::get_parameters(), ctselect::get_parameters(), ctbkgcube::get_parameters(), ctcubemask::get_parameters(), ctphase::get_parameters(), ctskymap::get_parameters(), ctulimit::get_parameters(), ctobssim::get_parameters(), ctbutterfly::get_parameters(), ctmodel::get_parameters(), cttsmap::get_parameters(), and ctbin::get_parameters().

void ctool::sync_pfiles ( void  )
protected

Synchronise parameter files.

Make sure that the structure of the parameter files in the syspfiles folder is used as a reference.

Definition at line 370 of file ctool.cpp.

Referenced by ctool().

std::string ctool::warn_too_few_energies ( const GEnergies &  energies) const
protected

Set warning string if there are too few energies.

Parameters
[in]energiesEnergies.
Returns
Warning string.

Sets a warning string if there are too few energies in the container. For a binned or stacked analysis to be accurate, at least 25 bins per decade are required. If the provided number of energies is less than this number a warning string will be returned. Otherwise an empty string will be returned.

Definition at line 2386 of file ctool.cpp.

Referenced by ctexpcube::process().

std::string ctool::warn_xml_suffix ( const GFilename &  filename) const
protected

Set warning string if file has no .xml suffix.

Parameters
[in]filenameFilename.
Returns
Warning string.

Sets a warning string if the filename has not ".xml" suffix.

Definition at line 2427 of file ctool.cpp.

Referenced by ctbin::save(), ctobservation::save_events_xml(), ctcubemask::save_xml(), ctselect::save_xml(), and ctobssim::save_xml().

Member Data Documentation

bool ctool::m_read_ahead
protected

Read ahead output parameters.

Definition at line 155 of file ctool.hpp.

Referenced by copy_members(), execute(), init_members(), and read_ahead().


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