Commit f932137edd07fe78e4e87beead8636c1de18e10c
1 parent
44f157c1
update to support standardized Python interface
Showing
3 changed files
with
51 additions
and
32 deletions
pyext/ctobssim.i
| @@ -31,15 +31,19 @@ class ctobssim : public GApplication { | @@ -31,15 +31,19 @@ class ctobssim : public GApplication { | ||
| 31 | public: | 31 | public: |
| 32 | // Constructors and destructors | 32 | // Constructors and destructors |
| 33 | ctobssim(void); | 33 | ctobssim(void); |
| 34 | + explicit ctobssim(GObservations obs); | ||
| 34 | ctobssim(int argc, char *argv[]); | 35 | ctobssim(int argc, char *argv[]); |
| 35 | - ~ctobssim(void); | 36 | + virtual ~ctobssim(void); |
| 36 | 37 | ||
| 37 | // Methods | 38 | // Methods |
| 39 | + void clear(void); | ||
| 38 | void run(void); | 40 | void run(void); |
| 41 | + void save(void); | ||
| 42 | + GObservations& obs(void); | ||
| 39 | void get_parameters(void); | 43 | void get_parameters(void); |
| 40 | - GPhotons simulate_photons(void); | ||
| 41 | - GCTAEventList* simulate_events(const GPhotons& photons); | ||
| 42 | - void save_events(const GCTAEventList* events); | 44 | + GPhotons simulate_photons(const GCTAObservation* obs, const GModels& models); |
| 45 | + void simulate_source(GCTAObservation* obs, const GPhotons& photons); | ||
| 46 | + void simulate_background(GCTAObservation* obs, const GModels& models); | ||
| 43 | }; | 47 | }; |
| 44 | 48 | ||
| 45 | 49 |
src/ctobssim/ctobssim.hpp
| @@ -25,28 +25,37 @@ | @@ -25,28 +25,37 @@ | ||
| 25 | 25 | ||
| 26 | /* __Definitions _________________________________________________________ */ | 26 | /* __Definitions _________________________________________________________ */ |
| 27 | #define CTOBSSIM_NAME "ctobssim" | 27 | #define CTOBSSIM_NAME "ctobssim" |
| 28 | -#define CTOBSSIM_VERSION "00-01-00" | 28 | +#define CTOBSSIM_VERSION "00-02-00" |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | /***********************************************************************//** | 31 | /***********************************************************************//** |
| 32 | * @class ctobssim | 32 | * @class ctobssim |
| 33 | * | 33 | * |
| 34 | - * @brief CTA observation simulator tool interface defintion. | 34 | + * @brief CTA observation simulator tool interface defintion |
| 35 | + * | ||
| 36 | + * This class simulates CTA observation(s) using Monte Carlo sampling of the | ||
| 37 | + * source and background models. The class supports simulation of data of | ||
| 38 | + * multiple CTA observations in one shot. If multiple CTA observations are | ||
| 39 | + * processed and the save method is called, events FITS files will be written | ||
| 40 | + * for each observation. | ||
| 35 | ***************************************************************************/ | 41 | ***************************************************************************/ |
| 36 | class ctobssim : public GApplication { | 42 | class ctobssim : public GApplication { |
| 37 | public: | 43 | public: |
| 38 | // Constructors and destructors | 44 | // Constructors and destructors |
| 39 | ctobssim(void); | 45 | ctobssim(void); |
| 46 | + explicit ctobssim(GObservations obs); | ||
| 40 | ctobssim(int argc, char *argv[]); | 47 | ctobssim(int argc, char *argv[]); |
| 41 | - ~ctobssim(void); | 48 | + virtual ~ctobssim(void); |
| 42 | 49 | ||
| 43 | // Methods | 50 | // Methods |
| 51 | + void clear(void); | ||
| 44 | void run(void); | 52 | void run(void); |
| 53 | + void save(void); | ||
| 54 | + GObservations& obs(void) { return m_obs; } | ||
| 45 | void get_parameters(void); | 55 | void get_parameters(void); |
| 46 | - GPhotons simulate_photons(void); | ||
| 47 | - GCTAEventList* simulate_events(const GPhotons& photons); | ||
| 48 | - void save_events(const GCTAEventList* events); | ||
| 49 | - void set_events_keywords(GFits* file); | 56 | + GPhotons simulate_photons(const GCTAObservation* obs, const GModels& models); |
| 57 | + void simulate_source(GCTAObservation* obs, const GPhotons& photons); | ||
| 58 | + void simulate_background(GCTAObservation* obs, const GModels& models); | ||
| 50 | 59 | ||
| 51 | protected: | 60 | protected: |
| 52 | // Protected methods | 61 | // Protected methods |
| @@ -54,23 +63,23 @@ protected: | @@ -54,23 +63,23 @@ protected: | ||
| 54 | void free_members(void); | 63 | void free_members(void); |
| 55 | 64 | ||
| 56 | // User parameters | 65 | // User parameters |
| 57 | - std::string m_infile; //!< Input model | ||
| 58 | - std::string m_outfile; //!< Output events file | ||
| 59 | - std::string m_caldb; //!< Calibration database repository | ||
| 60 | - std::string m_irf; //!< Instrument response function | ||
| 61 | - int m_seed; //!< Random number generator seed | ||
| 62 | - double m_ra; //!< RA of pointing direction | ||
| 63 | - double m_dec; //!< DEC of pointing direction | ||
| 64 | - double m_rad; //!< FOV radius | ||
| 65 | - double m_tmin; //!< Start time (MET) | ||
| 66 | - double m_tmax; //!< Stop time (MET) | ||
| 67 | - double m_emin; //!< Lower energy (TeV) | ||
| 68 | - double m_emax; //!< Upper energy (TeV) | ||
| 69 | - double m_area; //!< Surface area for simulation (cm2) | ||
| 70 | - GRan m_ran; //!< Random number generator | ||
| 71 | - GCTAPointing m_pnt; //!< CTA pointing | ||
| 72 | - GCTAObservation m_obs; //!< CTA observation | ||
| 73 | - GModels m_models; //!< Models | 66 | + std::string m_infile; //!< Input model |
| 67 | + std::string m_outfile; //!< Output events file | ||
| 68 | + std::string m_caldb; //!< Calibration database repository | ||
| 69 | + std::string m_irf; //!< Instrument response function | ||
| 70 | + int m_seed; //!< Random number generator seed | ||
| 71 | + double m_ra; //!< RA of pointing direction | ||
| 72 | + double m_dec; //!< DEC of pointing direction | ||
| 73 | + double m_rad; //!< FOV radius | ||
| 74 | + double m_tmin; //!< Start time (MET) | ||
| 75 | + double m_tmax; //!< Stop time (MET) | ||
| 76 | + double m_emin; //!< Lower energy (TeV) | ||
| 77 | + double m_emax; //!< Upper energy (TeV) | ||
| 78 | + | ||
| 79 | + // Protected members | ||
| 80 | + double m_area; //!< Surface area for simulation (cm2) | ||
| 81 | + GRan m_ran; //!< Random number generator | ||
| 82 | + GObservations m_obs; //!< Observation container | ||
| 74 | }; | 83 | }; |
| 75 | 84 | ||
| 76 | #endif /* CTOBSSIM_HPP */ | 85 | #endif /* CTOBSSIM_HPP */ |
src/ctobssim/main.cpp
| @@ -20,15 +20,15 @@ | @@ -20,15 +20,15 @@ | ||
| 20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
| 21 | #include <config.h> | 21 | #include <config.h> |
| 22 | #endif | 22 | #endif |
| 23 | -#include <stdio.h> | 23 | +#include <cstdio> |
| 24 | #include "ctobssim.hpp" | 24 | #include "ctobssim.hpp" |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | /***********************************************************************//** | 27 | /***********************************************************************//** |
| 28 | * @brief Main entry point | 28 | * @brief Main entry point |
| 29 | * | 29 | * |
| 30 | - * @param[in] argc Number of arguments | ||
| 31 | - * @param[in] argv Arguments | 30 | + * @param[in] argc Number of arguments. |
| 31 | + * @param[in] argv Arguments. | ||
| 32 | ***************************************************************************/ | 32 | ***************************************************************************/ |
| 33 | int main (int argc, char *argv[]) | 33 | int main (int argc, char *argv[]) |
| 34 | { | 34 | { |
| @@ -40,7 +40,13 @@ int main (int argc, char *argv[]) | @@ -40,7 +40,13 @@ int main (int argc, char *argv[]) | ||
| 40 | 40 | ||
| 41 | // Run application | 41 | // Run application |
| 42 | try { | 42 | try { |
| 43 | + // Run application | ||
| 43 | application.run(); | 44 | application.run(); |
| 45 | + | ||
| 46 | + // Save results | ||
| 47 | + application.save(); | ||
| 48 | + | ||
| 49 | + // Signal success | ||
| 44 | rc = 0; | 50 | rc = 0; |
| 45 | } | 51 | } |
| 46 | catch (std::exception &e) { | 52 | catch (std::exception &e) { |
| @@ -48,7 +54,7 @@ int main (int argc, char *argv[]) | @@ -48,7 +54,7 @@ int main (int argc, char *argv[]) | ||
| 48 | // Extract error message | 54 | // Extract error message |
| 49 | std::string message = e.what(); | 55 | std::string message = e.what(); |
| 50 | std::string signal = "*** ERROR encounterted in the execution of" | 56 | std::string signal = "*** ERROR encounterted in the execution of" |
| 51 | - " ctobssim. Run aborted ..."; | 57 | + " ctobssim. Run aborted ..."; |
| 52 | 58 | ||
| 53 | // Write error in logger | 59 | // Write error in logger |
| 54 | application.log << signal << std::endl; | 60 | application.log << signal << std::endl; |