Commit f932137edd07fe78e4e87beead8636c1de18e10c

Authored by knodlseder
1 parent 44f157c1

update to support standardized Python interface

pyext/ctobssim.i
... ... @@ -31,15 +31,19 @@ class ctobssim : public GApplication {
31 31 public:
32 32 // Constructors and destructors
33 33 ctobssim(void);
  34 + explicit ctobssim(GObservations obs);
34 35 ctobssim(int argc, char *argv[]);
35   - ~ctobssim(void);
  36 + virtual ~ctobssim(void);
36 37  
37 38 // Methods
  39 + void clear(void);
38 40 void run(void);
  41 + void save(void);
  42 + GObservations& obs(void);
39 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 25  
26 26 /* __Definitions _________________________________________________________ */
27 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 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 42 class ctobssim : public GApplication {
37 43 public:
38 44 // Constructors and destructors
39 45 ctobssim(void);
  46 + explicit ctobssim(GObservations obs);
40 47 ctobssim(int argc, char *argv[]);
41   - ~ctobssim(void);
  48 + virtual ~ctobssim(void);
42 49  
43 50 // Methods
  51 + void clear(void);
44 52 void run(void);
  53 + void save(void);
  54 + GObservations& obs(void) { return m_obs; }
45 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 60 protected:
52 61 // Protected methods
... ... @@ -54,23 +63,23 @@ protected:
54 63 void free_members(void);
55 64  
56 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 85 #endif /* CTOBSSIM_HPP */
... ...
src/ctobssim/main.cpp
... ... @@ -20,15 +20,15 @@
20 20 #ifdef HAVE_CONFIG_H
21 21 #include <config.h>
22 22 #endif
23   -#include <stdio.h>
  23 +#include <cstdio>
24 24 #include "ctobssim.hpp"
25 25  
26 26  
27 27 /***********************************************************************//**
28 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 33 int main (int argc, char *argv[])
34 34 {
... ... @@ -40,7 +40,13 @@ int main (int argc, char *argv[])
40 40  
41 41 // Run application
42 42 try {
  43 + // Run application
43 44 application.run();
  45 +
  46 + // Save results
  47 + application.save();
  48 +
  49 + // Signal success
44 50 rc = 0;
45 51 }
46 52 catch (std::exception &e) {
... ... @@ -48,7 +54,7 @@ int main (int argc, char *argv[])
48 54 // Extract error message
49 55 std::string message = e.what();
50 56 std::string signal = "*** ERROR encounterted in the execution of"
51   - " ctobssim. Run aborted ...";
  57 + " ctobssim. Run aborted ...";
52 58  
53 59 // Write error in logger
54 60 application.log << signal << std::endl;
... ...