Commit 9482abe16f421ecfa23b56e6c2e943ab07540781

Authored by Jürgen Knödlseder
1 parent 821c6a4e

Move execute() method to ctool base class and add pure virtual clear(), run() an…

…d scave() methods to ctool interface. Add read_ahead() method to handle reading of task parameters at the beginning of the task execution. Remove all m_read_ahead members from the derived classes.
pyext/ctbin.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GObservations& obs(void) const;
... ...
pyext/ctbkgcube.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GCTAEventCube& cube(void) const;
... ...
pyext/ctcubemask.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GObservations& obs(void) const;
... ...
pyext/ctexpcube.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GCTAExposure& expcube(void) const;
... ...
pyext/ctlike.i
... ... @@ -32,7 +32,7 @@
32 32 /***********************************************************************//**
33 33 * @class ctlike
34 34 *
35   - * @brief CTA maximum likelihood tool Python interface
  35 + * @brief Maximum likelihood fitting tool
36 36 ***************************************************************************/
37 37 class ctlike : public ctool {
38 38 public:
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GObservations& obs(void) const;
... ...
pyext/ctmodel.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GObservations& obs(void) const;
... ...
pyext/ctobssim.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GObservations& obs(void) const;
... ...
pyext/ctool.i
... ... @@ -44,5 +44,11 @@ public:
44 44 ctool(const ctool& app);
45 45 virtual ~ctool(void);
46 46  
47   - // Methods
  47 + // Pure virtual methods
  48 + virtual void clear(void) = 0;
  49 + virtual void run(void) = 0;
  50 + virtual void save(void) = 0;
  51 +
  52 + // Public methods
  53 + virtual void execute(void);
48 54 };
... ...
pyext/ctpsfcube.i
... ... @@ -46,7 +46,6 @@ public:
46 46  
47 47 // Methods
48 48 void clear(void);
49   - void execute(void);
50 49 void run(void);
51 50 void save(void);
52 51 const GCTAMeanPsf& psfcube(void) const;
... ...
pyext/ctselect.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GObservations& obs(void) const;
... ...
pyext/ctskymap.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GSkymap& map(void) const;
... ...
pyext/cttsmap.i
... ... @@ -45,7 +45,6 @@ public:
45 45  
46 46 // Methods
47 47 void clear(void);
48   - void execute(void);
49 48 void run(void);
50 49 void save(void);
51 50 const GObservations& obs(void) const;
... ...
src/ctbin/ctbin.cpp
... ... @@ -192,31 +192,6 @@ void ctbin::clear(void)
192 192  
193 193  
194 194 /***********************************************************************//**
195   - * @brief Execute application
196   - *
197   - * This is the main execution method of the ctbin class. It is invoked when
198   - * the executable is called from command line.
199   - *
200   - * The method reads the task parameters, bins the event list(s) into counts
201   - * map(s), and writes the results into FITS files on disk.
202   - ***************************************************************************/
203   -void ctbin::execute(void)
204   -{
205   - // Signal that some parameters should be read ahead
206   - m_read_ahead = true;
207   -
208   - // Bin the event data
209   - run();
210   -
211   - // Save the counts map into FITS file
212   - save();
213   -
214   - // Return
215   - return;
216   -}
217   -
218   -
219   -/***********************************************************************//**
220 195 * @brief Bin the event data
221 196 *
222 197 * This method loops over all observations found in the observation conatiner
... ... @@ -371,16 +346,12 @@ void ctbin::init_members(void)
371 346  
372 347 // Initialise protected members
373 348 m_obs.clear();
374   - m_read_ahead = false;
375 349 m_cube.clear();
376 350 m_ebounds.clear();
377 351 m_gti.clear();
378 352 m_ontime = 0.0;
379 353 m_livetime = 0.0;
380 354  
381   - // Set logger properties
382   - log.date(true);
383   -
384 355 // Return
385 356 return;
386 357 }
... ... @@ -407,7 +378,6 @@ void ctbin::copy_members(const ctbin& app)
407 378  
408 379 // Copy protected members
409 380 m_obs = app.m_obs;
410   - m_read_ahead = app.m_read_ahead;
411 381 m_cube = app.m_cube;
412 382 m_ebounds = app.m_ebounds;
413 383 m_gti = app.m_gti;
... ... @@ -491,7 +461,7 @@ void ctbin::get_parameters(void)
491 461  
492 462 // Optionally read ahead parameters so that they get correctly
493 463 // dumped into the log file
494   - if (m_read_ahead) {
  464 + if (read_ahead()) {
495 465 m_outfile = (*this)["outfile"].filename();
496 466 }
497 467  
... ...
src/ctbin/ctbin.hpp
... ... @@ -75,7 +75,6 @@ public:
75 75  
76 76 // Methods
77 77 void clear(void);
78   - void execute(void);
79 78 void run(void);
80 79 void save(void);
81 80 const GObservations& obs(void) const;
... ... @@ -105,7 +104,6 @@ protected:
105 104  
106 105 // Protected members
107 106 GObservations m_obs; //!< Observation container
108   - bool m_read_ahead; //!< Read ahead parameters
109 107 GSkymap m_cube; //!< Event cube
110 108 GEbounds m_ebounds; //!< Energy boundaries
111 109 GGti m_gti; //!< Good time intervals
... ...
src/ctbkgcube/ctbkgcube.cpp
... ... @@ -105,7 +105,7 @@ ctbkgcube::ctbkgcube(int argc, char *argv[]) :
105 105 /***********************************************************************//**
106 106 * @brief Copy constructor
107 107 *
108   - * @param[in] app ctbkgcube application.
  108 + * @param[in] app Application.
109 109 ***************************************************************************/
110 110 ctbkgcube::ctbkgcube(const ctbkgcube& app) : ctool(app)
111 111 {
... ... @@ -142,8 +142,8 @@ ctbkgcube::~ctbkgcube(void)
142 142 /***********************************************************************//**
143 143 * @brief Assignment operator
144 144 *
145   - * @param[in] app ctbkgcube application.
146   - * @return Returns ctbkgcube application.
  145 + * @param[in] app Application.
  146 + * @return Returns application.
147 147 ***************************************************************************/
148 148 ctbkgcube& ctbkgcube::operator=(const ctbkgcube& app)
149 149 {
... ... @@ -196,29 +196,6 @@ void ctbkgcube::clear(void)
196 196  
197 197  
198 198 /***********************************************************************//**
199   - * @brief Execute application
200   - *
201   - * This is the main execution method of the ctbkgcube class. It is invoked
202   - * when the executable is called from command line. The method generates
203   - * the background cube and saves the result.
204   - ***************************************************************************/
205   -void ctbkgcube::execute(void)
206   -{
207   - // Signal that some parameters should be read ahead
208   - m_read_ahead = true;
209   -
210   - // Create the background cube
211   - run();
212   -
213   - // Save the background cube into the output FITS file
214   - save();
215   -
216   - // Return
217   - return;
218   -}
219   -
220   -
221   -/***********************************************************************//**
222 199 * @brief Generate the background cube(s).
223 200 *
224 201 * This method reads the task parameters from the parfile, sets up the
... ... @@ -424,16 +401,12 @@ void ctbkgcube::save(void)
424 401 void ctbkgcube::init_members(void)
425 402 {
426 403 // Initialise members
427   - m_read_ahead = false;
428 404 m_obs.clear();
429 405 m_bkgcube.clear();
430 406 m_bkgmdl.clear();
431 407 m_ebounds.clear();
432 408 m_livetime = 0.0;
433 409  
434   - // Set logger properties
435   - log.date(true);
436   -
437 410 // Return
438 411 return;
439 412 }
... ... @@ -447,12 +420,11 @@ void ctbkgcube::init_members(void)
447 420 void ctbkgcube::copy_members(const ctbkgcube& app)
448 421 {
449 422 // Copy members
450   - m_read_ahead = app.m_read_ahead;
451   - m_obs = app.m_obs;
452   - m_bkgcube = app.m_bkgcube;
453   - m_bkgmdl = app.m_bkgmdl;
454   - m_ebounds = app.m_ebounds;
455   - m_livetime = app.m_livetime;
  423 + m_obs = app.m_obs;
  424 + m_bkgcube = app.m_bkgcube;
  425 + m_bkgmdl = app.m_bkgmdl;
  426 + m_ebounds = app.m_ebounds;
  427 + m_livetime = app.m_livetime;
456 428  
457 429 // Return
458 430 return;
... ... @@ -540,7 +512,7 @@ void ctbkgcube::get_parameters(void)
540 512 }
541 513  
542 514 // Read output filename (if needed)
543   - if (m_read_ahead) {
  515 + if (read_ahead()) {
544 516 std::string filename = (*this)["outfile"].filename();
545 517 }
546 518  
... ...
src/ctbkgcube/ctbkgcube.hpp
... ... @@ -57,7 +57,6 @@ public:
57 57  
58 58 // Methods
59 59 void clear(void);
60   - void execute(void);
61 60 void run(void);
62 61 void save(void);
63 62 const GCTAEventCube& cube(void) const;
... ... @@ -73,7 +72,6 @@ protected:
73 72 void fill_cube(GCTAObservation* obs);
74 73  
75 74 // Protected members
76   - bool m_read_ahead; //!< Read ahead parameters
77 75 GObservations m_obs; //!< Observation container
78 76 GCTAEventCube m_bkgcube; //!< Background cube
79 77 GModels m_bkgmdl; //!< CTA background models
... ...
src/ctcubemask/ctcubemask.cpp
... ... @@ -143,6 +143,7 @@ ctcubemask::~ctcubemask(void)
143 143 * @brief Assignment operator
144 144 *
145 145 * @param[in] app Application.
  146 + * @return Application.
146 147 ***************************************************************************/
147 148 ctcubemask& ctcubemask::operator=(const ctcubemask& app)
148 149 {
... ... @@ -195,28 +196,6 @@ void ctcubemask::clear(void)
195 196  
196 197  
197 198 /***********************************************************************//**
198   - * @brief Execute application
199   - *
200   - * This method applies the cube mask and saves the result.
201   - ***************************************************************************/
202   -void ctcubemask::execute(void)
203   -{
204   - // Signal that some parameters should be read ahead
205   - m_read_ahead = true;
206   -
207   - // Perform event selection
208   - run();
209   -
210   - // Save results
211   - save();
212   -
213   - // Return
214   - return;
215   -}
216   -
217   -
218   -
219   -/***********************************************************************//**
220 199 * @brief mask data cube
221 200 *
222 201 * This method reads in the application parameters and loops over all
... ... @@ -416,7 +395,7 @@ void ctcubemask::get_parameters(void)
416 395  
417 396 // Optionally read ahead parameters so that they get correctly
418 397 // dumped into the log file
419   - if (m_read_ahead) {
  398 + if (read_ahead()) {
420 399 m_outfile = (*this)["outfile"].filename();
421 400 }
422 401  
... ... @@ -574,10 +553,6 @@ void ctcubemask::init_members(void)
574 553 m_obs.clear();
575 554 m_infiles.clear();
576 555 m_use_xml = false;
577   - m_read_ahead = false;
578   -
579   - // Set logger properties
580   - log.date(true);
581 556  
582 557 // Return
583 558 return;
... ... @@ -607,7 +582,6 @@ void ctcubemask::copy_members(const ctcubemask&amp; app)
607 582 m_obs = app.m_obs;
608 583 m_infiles = app.m_infiles;
609 584 m_use_xml = app.m_use_xml;
610   - m_read_ahead = app.m_read_ahead;
611 585  
612 586 // Return
613 587 return;
... ... @@ -619,11 +593,6 @@ void ctcubemask::copy_members(const ctcubemask&amp; app)
619 593 ***************************************************************************/
620 594 void ctcubemask::free_members(void)
621 595 {
622   - // Write separator into logger
623   - if (logTerse()) {
624   - log << std::endl;
625   - }
626   -
627 596 // Return
628 597 return;
629 598 }
... ...
src/ctcubemask/ctcubemask.hpp
... ... @@ -59,7 +59,6 @@ public:
59 59  
60 60 // Methods
61 61 void clear(void);
62   - void execute(void);
63 62 void run(void);
64 63 void save(void);
65 64 const GObservations& obs(void) const;
... ... @@ -94,7 +93,6 @@ protected:
94 93 GObservations m_obs; //!< Observations container
95 94 std::vector<std::string> m_infiles; //!< Input event filenames
96 95 bool m_use_xml; //!< Use XML file instead of FITS file
97   - bool m_read_ahead; //!< Read ahead parameters
98 96 };
99 97  
100 98  
... ...
src/ctexpcube/ctexpcube.cpp
... ... @@ -113,7 +113,7 @@ ctexpcube::ctexpcube(int argc, char *argv[]) :
113 113 /***********************************************************************//**
114 114 * @brief Copy constructor
115 115 *
116   - * @param[in] app ctexpcube application.
  116 + * @param[in] app Application.
117 117 ***************************************************************************/
118 118 ctexpcube::ctexpcube(const ctexpcube& app) : ctool(app)
119 119 {
... ... @@ -150,8 +150,8 @@ ctexpcube::~ctexpcube(void)
150 150 /***********************************************************************//**
151 151 * @brief Assignment operator
152 152 *
153   - * @param[in] app ctexpcube application.
154   - * @return Returns ctexpcube application.
  153 + * @param[in] app Application.
  154 + * @return Application.
155 155 ***************************************************************************/
156 156 ctexpcube& ctexpcube::operator=(const ctexpcube& app)
157 157 {
... ... @@ -204,29 +204,6 @@ void ctexpcube::clear(void)
204 204  
205 205  
206 206 /***********************************************************************//**
207   - * @brief Execute application
208   - *
209   - * This is the main execution method of the ctexpcube class. It is invoked
210   - * when the executable is called from command line. The method generates
211   - * the exposure cube and saves the result.
212   - ***************************************************************************/
213   -void ctexpcube::execute(void)
214   -{
215   - // Signal that some parameters should be read ahead
216   - m_read_ahead = true;
217   -
218   - // Create the exposure cube
219   - run();
220   -
221   - // Save the exposure cube into the output FITS file
222   - save();
223   -
224   - // Return
225   - return;
226   -}
227   -
228   -
229   -/***********************************************************************//**
230 207 * @brief Generate the exposure cube(s).
231 208 *
232 209 * This method reads the task parameters from the parfile, sets up the
... ... @@ -333,14 +310,10 @@ void ctexpcube::init_members(void)
333 310 m_apply_edisp = false;
334 311  
335 312 // Initialise protected members
336   - m_read_ahead = false;
337 313 m_obs.clear();
338 314 m_expcube.clear();
339 315 m_ebounds.clear();
340 316  
341   - // Set logger properties
342   - log.date(true);
343   -
344 317 // Return
345 318 return;
346 319 }
... ... @@ -358,7 +331,6 @@ void ctexpcube::copy_members(const ctexpcube&amp; app)
358 331 m_apply_edisp = app.m_apply_edisp;
359 332  
360 333 // Copy protected members
361   - m_read_ahead = app.m_read_ahead;
362 334 m_obs = app.m_obs;
363 335 m_expcube = app.m_expcube;
364 336 m_ebounds = app.m_ebounds;
... ... @@ -433,7 +405,7 @@ void ctexpcube::get_parameters(void)
433 405 }
434 406  
435 407 // Read output filename (if needed)
436   - if (m_read_ahead) {
  408 + if (read_ahead()) {
437 409 m_outfile = (*this)["outfile"].filename();
438 410 }
439 411  
... ...
src/ctexpcube/ctexpcube.hpp
... ... @@ -57,7 +57,6 @@ public:
57 57  
58 58 // Methods
59 59 void clear(void);
60   - void execute(void);
61 60 void run(void);
62 61 void save(void);
63 62 const GCTAExposure& expcube(void) const;
... ... @@ -76,7 +75,6 @@ protected:
76 75 bool m_apply_edisp; //!< Apply energy dispersion?
77 76  
78 77 // Protected members
79   - bool m_read_ahead; //!< Read ahead parameters
80 78 GObservations m_obs; //!< Observation container
81 79 GCTAExposure m_expcube; //!< Exposure cube
82 80 GEbounds m_ebounds; //!< Energy boundaries
... ...
src/ctlike/ctlike.cpp
... ... @@ -138,6 +138,7 @@ ctlike::~ctlike(void)
138 138 * @brief Assignment operator
139 139 *
140 140 * @param[in] app Application.
  141 + * @return Application.
141 142 ***************************************************************************/
142 143 ctlike& ctlike::operator=(const ctlike& app)
143 144 {
... ... @@ -190,28 +191,6 @@ void ctlike::clear(void)
190 191  
191 192  
192 193 /***********************************************************************//**
193   - * @brief Execute application
194   - *
195   - * This method performs a maximum likelihood analysis of a observation given
196   - * in an observation container and saves the results in an XML file.
197   - ***************************************************************************/
198   -void ctlike::execute(void)
199   -{
200   - // Signal that some parameters should be read ahead
201   - m_read_ahead = true;
202   -
203   - // Bin the event data
204   - run();
205   -
206   - // Save the results into XML file
207   - save();
208   -
209   - // Return
210   - return;
211   -}
212   -
213   -
214   -/***********************************************************************//**
215 194 * @brief Run maximum likelihood analysis
216 195 *
217 196 * The following analysis steps are performed:
... ... @@ -442,7 +421,7 @@ void ctlike::get_parameters(void)
442 421  
443 422 // Optionally read ahead parameters so that they get correctly
444 423 // dumped into the log file
445   - if (m_read_ahead) {
  424 + if (read_ahead()) {
446 425 m_outmdl = (*this)["outmdl"].filename();
447 426 }
448 427  
... ... @@ -572,7 +551,6 @@ void ctlike::init_members(void)
572 551 m_max_stall = 10; // Set maximum number of stalls
573 552 m_logL = 0.0;
574 553 m_opt = NULL;
575   - m_read_ahead = false;
576 554 m_apply_edisp = false;
577 555  
578 556 // Set logger properties
... ... @@ -599,7 +577,6 @@ void ctlike::copy_members(const ctlike&amp; app)
599 577 m_max_stall = app.m_max_stall;
600 578 m_logL = app.m_logL;
601 579 m_opt = app.m_opt->clone();
602   - m_read_ahead = app.m_read_ahead;
603 580 m_apply_edisp = app.m_apply_edisp;
604 581  
605 582 // Return
... ... @@ -618,11 +595,6 @@ void ctlike::free_members(void)
618 595 // Mark pointers as free
619 596 m_opt = NULL;
620 597  
621   - // Write separator into logger
622   - if (logTerse()) {
623   - log << std::endl;
624   - }
625   -
626 598 // Return
627 599 return;
628 600 }
... ...
src/ctlike/ctlike.hpp
... ... @@ -58,7 +58,6 @@ public:
58 58  
59 59 // Methods
60 60 void clear(void);
61   - void execute(void);
62 61 void run(void);
63 62 void save(void);
64 63 const GObservations& obs(void) const;
... ... @@ -85,7 +84,6 @@ protected:
85 84 int m_max_stall; //!< Maximum number of stalls
86 85 double m_logL; //!< Maximum log likelihood
87 86 GOptimizer* m_opt; //!< Optimizer
88   - bool m_read_ahead; //!< Read ahead parameters
89 87 };
90 88  
91 89  
... ...
src/ctmodel/ctmodel.cpp
... ... @@ -137,8 +137,8 @@ ctmodel::~ctmodel(void)
137 137 /***********************************************************************//**
138 138 * @brief Assignment operator
139 139 *
140   - * @param[in] app ctmodel application.
141   - * @return Returns ctmodel application.
  140 + * @param[in] app Application.
  141 + * @return Application.
142 142 ***************************************************************************/
143 143 ctmodel& ctmodel::operator=(const ctmodel& app)
144 144 {
... ... @@ -191,29 +191,6 @@ void ctmodel::clear(void)
191 191  
192 192  
193 193 /***********************************************************************//**
194   - * @brief Execute application
195   - *
196   - * This is the main execution method of the ctmodel class. It is invoked
197   - * when the executable is called from command line. The method generates
198   - * the model maps and saves the results.
199   - ***************************************************************************/
200   -void ctmodel::execute(void)
201   -{
202   - // Signal that some parameters should be read ahead
203   - m_read_ahead = true;
204   -
205   - // Create model cube
206   - run();
207   -
208   - // Save model cube into FITS file
209   - save();
210   -
211   - // Return
212   - return;
213   -}
214   -
215   -
216   -/***********************************************************************//**
217 194 * @brief Generate the model map(s)
218 195 *
219 196 * This method reads the task parameters from the parfile, sets up the
... ... @@ -385,10 +362,6 @@ void ctmodel::init_members(void)
385 362 m_cube.clear();
386 363 m_ebounds.clear();
387 364 m_gti.clear();
388   - m_read_ahead = false;
389   -
390   - // Set logger properties
391   - log.date(true);
392 365  
393 366 // Return
394 367 return;
... ... @@ -433,7 +406,6 @@ void ctmodel::copy_members(const ctmodel&amp; app)
433 406 m_cube = app.m_cube;
434 407 m_ebounds = app.m_ebounds;
435 408 m_gti = app.m_gti;
436   - m_read_ahead = app.m_read_ahead;
437 409  
438 410 // Return
439 411 return;
... ... @@ -460,7 +432,7 @@ void ctmodel::get_parameters(void)
460 432 {
461 433 // Read input and optionally output cube filenames
462 434 m_infile = (*this)["infile"].filename();
463   - if (m_read_ahead) {
  435 + if (read_ahead()) {
464 436 m_outfile = (*this)["outfile"].filename();
465 437 }
466 438  
... ...
src/ctmodel/ctmodel.hpp
... ... @@ -66,7 +66,6 @@ public:
66 66  
67 67 // Methods
68 68 void clear(void);
69   - void execute(void);
70 69 void run(void);
71 70 void save(void);
72 71 const GObservations& obs(void) const;
... ... @@ -113,7 +112,6 @@ protected:
113 112 GCTAEventCube m_cube; //!< Model cube
114 113 GEbounds m_ebounds; //!< Energy boundaries
115 114 GGti m_gti; //!< Model cube GTIs
116   - bool m_read_ahead; //!< Read ahead parameters
117 115 };
118 116  
119 117  
... ...
src/ctobssim/ctobssim.cpp
... ... @@ -197,27 +197,6 @@ void ctobssim::clear(void)
197 197  
198 198  
199 199 /***********************************************************************//**
200   - * @brief Execute application
201   - *
202   - * This method runs the simulation and saves the results.
203   - ***************************************************************************/
204   -void ctobssim::execute(void)
205   -{
206   - // Signal that some parameters should be read ahead
207   - m_read_ahead = true;
208   -
209   - // Run the simulation
210   - run();
211   -
212   - // Save results
213   - save();
214   -
215   - // Return
216   - return;
217   -}
218   -
219   -
220   -/***********************************************************************//**
221 200 * @brief Simulate event data
222 201 *
223 202 * This method runs the simulation. Results are not saved by this method.
... ... @@ -489,7 +468,7 @@ void ctobssim::get_parameters(void)
489 468  
490 469 // Optionally read ahead parameters so that they get correctly
491 470 // dumped into the log file
492   - if (m_read_ahead) {
  471 + if (read_ahead()) {
493 472 m_outfile = (*this)["outfile"].filename();
494 473 m_prefix = (*this)["prefix"].string();
495 474 }
... ... @@ -1038,7 +1017,6 @@ void ctobssim::init_members(void)
1038 1017 m_rans.clear();
1039 1018 m_obs.clear();
1040 1019 m_use_xml = false;
1041   - m_read_ahead = false;
1042 1020  
1043 1021 // Set fixed parameters
1044 1022 m_area = 19634954.0 * 1.0e4; //!< pi*(2500^2) m^2
... ... @@ -1052,9 +1030,6 @@ void ctobssim::init_members(void)
1052 1030 // Initialise first event identifier
1053 1031 m_event_id = 1;
1054 1032  
1055   - // Set logger properties
1056   - log.date(true);
1057   -
1058 1033 // Return
1059 1034 return;
1060 1035 }
... ... @@ -1088,7 +1063,6 @@ void ctobssim::copy_members(const ctobssim&amp; app)
1088 1063 m_rans = app.m_rans;
1089 1064 m_obs = app.m_obs;
1090 1065 m_use_xml = app.m_use_xml;
1091   - m_read_ahead = app.m_read_ahead;
1092 1066 m_cta_ref = app.m_cta_ref;
1093 1067 m_event_id = app.m_event_id;
1094 1068  
... ...
src/ctobssim/ctobssim.hpp
... ... @@ -63,7 +63,6 @@ public:
63 63  
64 64 // Methods
65 65 void clear(void);
66   - void execute(void);
67 66 void run(void);
68 67 void save(void);
69 68 const GObservations& obs(void) const;
... ... @@ -107,7 +106,6 @@ protected:
107 106 std::vector<GRan> m_rans; //!< Random number generators
108 107 GObservations m_obs; //!< Observation container
109 108 bool m_use_xml; //!< Use XML file instead of FITS file
110   - bool m_read_ahead; //!< Read ahead parameters
111 109 GTimeReference m_cta_ref; //!< CTA time reference
112 110 int m_event_id; //!< Event identifier
113 111 };
... ...
src/ctpsfcube/ctpsfcube.cpp
... ... @@ -104,7 +104,7 @@ ctpsfcube::ctpsfcube(int argc, char *argv[]) :
104 104 /***********************************************************************//**
105 105 * @brief Copy constructor
106 106 *
107   - * @param[in] app ctpsfcube application.
  107 + * @param[in] app Application.
108 108 ***************************************************************************/
109 109 ctpsfcube::ctpsfcube(const ctpsfcube& app) : ctool(app)
110 110 {
... ... @@ -141,8 +141,8 @@ ctpsfcube::~ctpsfcube(void)
141 141 /***********************************************************************//**
142 142 * @brief Assignment operator
143 143 *
144   - * @param[in] app ctpsfcube application.
145   - * @return Returns ctpsfcube application.
  144 + * @param[in] app Application.
  145 + * @return Application.
146 146 ***************************************************************************/
147 147 ctpsfcube& ctpsfcube::operator=(const ctpsfcube& app)
148 148 {
... ... @@ -195,29 +195,6 @@ void ctpsfcube::clear(void)
195 195  
196 196  
197 197 /***********************************************************************//**
198   - * @brief Execute application
199   - *
200   - * This is the main execution method of the ctpsfcube class. It is invoked
201   - * when the executable is called from command line. The method generates
202   - * the PSF cube and saves the result.
203   - ***************************************************************************/
204   -void ctpsfcube::execute(void)
205   -{
206   - // Signal that some parameters should be read ahead
207   - m_read_ahead = true;
208   -
209   - // Create the PSF cube
210   - run();
211   -
212   - // Save the PSF cube into the output FITS file
213   - save();
214   -
215   - // Return
216   - return;
217   -}
218   -
219   -
220   -/***********************************************************************//**
221 198 * @brief Generate the model map(s)
222 199 *
223 200 * This method reads the task parameters from the parfile, sets up the
... ... @@ -324,14 +301,10 @@ void ctpsfcube::init_members(void)
324 301 m_apply_edisp = false;
325 302  
326 303 // Initialise protected members
327   - m_read_ahead = false;
328 304 m_obs.clear();
329 305 m_psfcube.clear();
330 306 m_ebounds.clear();
331 307  
332   - // Set logger properties
333   - log.date(true);
334   -
335 308 // Return
336 309 return;
337 310 }
... ... @@ -349,7 +322,6 @@ void ctpsfcube::copy_members(const ctpsfcube&amp; app)
349 322 m_apply_edisp = app.m_apply_edisp;
350 323  
351 324 // Copy protected members
352   - m_read_ahead = app.m_read_ahead;
353 325 m_obs = app.m_obs;
354 326 m_psfcube = app.m_psfcube;
355 327 m_ebounds = app.m_ebounds;
... ... @@ -426,7 +398,7 @@ void ctpsfcube::get_parameters(void)
426 398 }
427 399  
428 400 // Read output filename (if needed)
429   - if (m_read_ahead) {
  401 + if (read_ahead()) {
430 402 m_outfile = (*this)["outfile"].filename();
431 403 }
432 404  
... ...
src/ctpsfcube/ctpsfcube.hpp
... ... @@ -57,7 +57,6 @@ public:
57 57  
58 58 // Methods
59 59 void clear(void);
60   - void execute(void);
61 60 void run(void);
62 61 void save(void);
63 62 const GCTAMeanPsf& psfcube(void) const;
... ... @@ -76,7 +75,6 @@ protected:
76 75 bool m_apply_edisp; //!< Apply energy dispersion?
77 76  
78 77 // Protected members
79   - bool m_read_ahead; //!< Read ahead parameters
80 78 GObservations m_obs; //!< Observation container
81 79 GCTAMeanPsf m_psfcube; //!< PSF cube
82 80 GEbounds m_ebounds; //!< Energy boundaries
... ...
src/ctselect/ctselect.cpp
... ... @@ -144,6 +144,7 @@ ctselect::~ctselect(void)
144 144 * @brief Assignment operator
145 145 *
146 146 * @param[in] app Application.
  147 + * @return Application.
147 148 ***************************************************************************/
148 149 ctselect& ctselect::operator=(const ctselect& app)
149 150 {
... ... @@ -196,28 +197,6 @@ void ctselect::clear(void)
196 197  
197 198  
198 199 /***********************************************************************//**
199   - * @brief Execute application
200   - *
201   - * This method performs the event selection and saves the result
202   - ***************************************************************************/
203   -void ctselect::execute(void)
204   -{
205   - // Signal that some parameters should be read ahead
206   - m_read_ahead = true;
207   -
208   - // Perform event selection
209   - run();
210   -
211   - // Save results
212   - save();
213   -
214   - // Return
215   - return;
216   -}
217   -
218   -
219   -
220   -/***********************************************************************//**
221 200 * @brief Select event data
222 201 *
223 202 * This method reads in the application parameters and loops over all
... ... @@ -458,7 +437,7 @@ void ctselect::get_parameters(void)
458 437  
459 438 // Optionally read ahead parameters so that they get correctly
460 439 // dumped into the log file
461   - if (m_read_ahead) {
  440 + if (read_ahead()) {
462 441 m_outfile = (*this)["outfile"].filename();
463 442 m_prefix = (*this)["prefix"].string();
464 443 }
... ... @@ -706,16 +685,12 @@ void ctselect::init_members(void)
706 685 m_timemin.clear();
707 686 m_timemax.clear();
708 687 m_use_xml = false;
709   - m_read_ahead = false;
710 688  
711 689 // Set CTA time reference. G_CTA_MJDREF is the CTA reference MJD,
712 690 // which is defined in GCTALib.hpp. This is somehow a kluge. We need
713 691 // a better mechanism to implement the CTA reference MJD.
714 692 m_cta_ref.set(G_CTA_MJDREF, "s", "TT", "LOCAL");
715 693  
716   - // Set logger properties
717   - log.date(true);
718   -
719 694 // Return
720 695 return;
721 696 }
... ... @@ -748,7 +723,6 @@ void ctselect::copy_members(const ctselect&amp; app)
748 723 m_timemin = app.m_timemin;
749 724 m_timemax = app.m_timemax;
750 725 m_use_xml = app.m_use_xml;
751   - m_read_ahead = app.m_read_ahead;
752 726 m_cta_ref = app.m_cta_ref;
753 727  
754 728 // Return
... ...
src/ctselect/ctselect.hpp
... ... @@ -59,7 +59,6 @@ public:
59 59  
60 60 // Methods
61 61 void clear(void);
62   - void execute(void);
63 62 void run(void);
64 63 void save(void);
65 64 const GObservations& obs(void) const;
... ... @@ -100,7 +99,6 @@ protected:
100 99 GTime m_timemin; //!< Earliest time
101 100 GTime m_timemax; //!< Latest time
102 101 bool m_use_xml; //!< Use XML file instead of FITS file
103   - bool m_read_ahead; //!< Read ahead parameters
104 102 GTimeReference m_cta_ref; //!< CTA time reference
105 103 };
106 104  
... ...
src/ctskymap/ctskymap.cpp
... ... @@ -141,6 +141,7 @@ ctskymap::~ctskymap(void)
141 141 * @brief Assignment operator
142 142 *
143 143 * @param[in] app Application.
  144 + * @return Application.
144 145 ***************************************************************************/
145 146 ctskymap& ctskymap::operator=(const ctskymap& app)
146 147 {
... ... @@ -193,28 +194,6 @@ void ctskymap::clear(void)
193 194  
194 195  
195 196 /***********************************************************************//**
196   - * @brief Execute application
197   - *
198   - * This method creates the sky map and saves the map into a FITS file.
199   - ***************************************************************************/
200   -void ctskymap::execute(void)
201   -{
202   - // Read ahead output filename so that it gets dumped correctly in the
203   - // parameters log
204   - m_outfile = (*this)["outfile"].filename();
205   -
206   - // Create the sky map
207   - run();
208   -
209   - // Save the sky map into FITS file
210   - save();
211   -
212   - // Return
213   - return;
214   -}
215   -
216   -
217   -/***********************************************************************//**
218 197 * @brief Creates sky maps from data
219 198 *
220 199 * This method is the main code. It
... ... @@ -383,6 +362,11 @@ void ctskymap::get_parameters(void)
383 362 m_nxpix = (*this)["nxpix"].integer();
384 363 m_nypix = (*this)["nypix"].integer();
385 364  
  365 + // Read ahead parameters
  366 + if (read_ahead()) {
  367 + m_outfile = (*this)["outfile"].filename();
  368 + }
  369 +
386 370 // Return
387 371 return;
388 372 }
... ... @@ -555,9 +539,6 @@ void ctskymap::init_members(void)
555 539 m_nxpix = 0;
556 540 m_nypix = 0;
557 541  
558   - // Set logger properties
559   - log.date(true);
560   -
561 542 // Return
562 543 return;
563 544 }
... ...
src/ctskymap/ctskymap.hpp
... ... @@ -59,7 +59,6 @@ public:
59 59  
60 60 // Methods
61 61 void clear(void);
62   - void execute(void);
63 62 void run(void);
64 63 void save(void);
65 64 const GSkymap& map(void) const;
... ...
src/cttsmap/cttsmap.cpp
... ... @@ -140,6 +140,7 @@ cttsmap::~cttsmap(void)
140 140 * @brief Assignment operator
141 141 *
142 142 * @param[in] app Application.
  143 + * @return Application.
143 144 ***************************************************************************/
144 145 cttsmap& cttsmap::operator=(const cttsmap& app)
145 146 {
... ... @@ -192,31 +193,6 @@ void cttsmap::clear(void)
192 193  
193 194  
194 195 /***********************************************************************//**
195   - * @brief Execute application
196   - *
197   - * This is the main execution method of the cttsmap class. It is invoked when
198   - * the executable is called from command line.
199   - *
200   - * The method reads the task parameters, computes the TS values, stores the
201   - * results into map(s), and writes the maps into a FITS file on disk.
202   - ***************************************************************************/
203   -void cttsmap::execute(void)
204   -{
205   - // Signal that some parameters should be read ahead
206   - m_read_ahead = true;
207   -
208   - // Compute the maps
209   - run();
210   -
211   - // Save the maps into FITS file
212   - save();
213   -
214   - // Return
215   - return;
216   -}
217   -
218   -
219   -/***********************************************************************//**
220 196 * @brief Computes the TS maps
221 197 *
222 198 * This method moves a source along a grid of coordinates and refits the
... ... @@ -447,7 +423,6 @@ void cttsmap::init_members(void)
447 423  
448 424 // Initialise protected members
449 425 m_obs.clear();
450   - m_read_ahead = false;
451 426 m_binmin = -1;
452 427 m_binmax = -1;
453 428 m_logL0 = 0.0;
... ... @@ -457,9 +432,6 @@ void cttsmap::init_members(void)
457 432 m_maps.clear();
458 433 m_testsource = NULL;
459 434  
460   - // Set logger properties
461   - log.date(true);
462   -
463 435 // Return
464 436 return;
465 437 }
... ... @@ -488,7 +460,6 @@ void cttsmap::copy_members(const cttsmap&amp; app)
488 460 m_binmax = app.m_binmax;
489 461 m_logL0 = app.m_logL0;
490 462 m_obs = app.m_obs;
491   - m_read_ahead = app.m_read_ahead;
492 463 m_tsmap = app.m_tsmap;
493 464 m_mapnames = app.m_mapnames;
494 465 m_maps = app.m_maps;
... ... @@ -624,7 +595,7 @@ void cttsmap::get_parameters(void)
624 595  
625 596 // Optionally read ahead parameters so that they get correctly
626 597 // dumped into the log file
627   - if (m_read_ahead) {
  598 + if (read_ahead()) {
628 599 m_outfile = (*this)["outfile"].filename();
629 600 }
630 601  
... ...
src/cttsmap/cttsmap.hpp
... ... @@ -70,7 +70,6 @@ public:
70 70  
71 71 // Methods
72 72 void clear(void);
73   - void execute(void);
74 73 void run(void);
75 74 void save(void);
76 75 const GObservations& obs(void) const;
... ... @@ -103,7 +102,6 @@ protected:
103 102  
104 103 // Protected members
105 104 GObservations m_obs; //!< Observation container
106   - bool m_read_ahead; //!< Read ahead parameters
107 105 GSkymap m_tsmap; //!< TS map
108 106 GSkymap m_statusmap; //!< Map of computed bins
109 107 std::vector<std::string> m_mapnames; //!< Names of free parameters
... ...
src/support/ctool.cpp
... ... @@ -176,6 +176,26 @@ ctool&amp; ctool::operator=(const ctool&amp; app)
176 176 = =
177 177 ==========================================================================*/
178 178  
  179 +/***********************************************************************//**
  180 + * @brief Execute application
  181 + *
  182 + * This is the main execution method of a ctool. The method is invoked when
  183 + * the executable is called from command line.
  184 + ***************************************************************************/
  185 +void ctool::execute(void)
  186 +{
  187 + // Signal that some parameters should be read ahead
  188 + m_read_ahead = true;
  189 +
  190 + // Run the tool
  191 + run();
  192 +
  193 + // Save the results
  194 + save();
  195 +
  196 + // Return
  197 + return;
  198 +}
179 199  
180 200  
181 201 /*==========================================================================
... ... @@ -190,6 +210,10 @@ ctool&amp; ctool::operator=(const ctool&amp; app)
190 210 void ctool::init_members(void)
191 211 {
192 212 // Initialise members
  213 + m_read_ahead = false;
  214 +
  215 + // Set logger properties
  216 + log.date(true);
193 217  
194 218 // Return
195 219 return;
... ... @@ -203,7 +227,8 @@ void ctool::init_members(void)
203 227 ***************************************************************************/
204 228 void ctool::copy_members(const ctool& app)
205 229 {
206   - // Copy attributes
  230 + // Copy members
  231 + m_read_ahead = app.m_read_ahead;
207 232  
208 233 // Return
209 234 return;
... ...
src/support/ctool.hpp
... ... @@ -52,16 +52,38 @@ public:
52 52 // Operators
53 53 ctool& operator=(const ctool& app);
54 54  
  55 + // Pure virtual methods
  56 + virtual void clear(void) = 0;
  57 + virtual void run(void) = 0;
  58 + virtual void save(void) = 0;
  59 +
55 60 // Public methods
  61 + virtual void execute(void);
56 62  
57 63 protected:
58 64 // Protected methods
59   - void init_members(void);
60   - void copy_members(const ctool& app);
61   - void free_members(void);
62   - GEbounds get_ebounds(void);
63   - void set_response(GObservations& obs);
64   - void set_obs_response(GCTAObservation* obs);
  65 + void init_members(void);
  66 + void copy_members(const ctool& app);
  67 + void free_members(void);
  68 + const bool& read_ahead(void) const;
  69 + GEbounds get_ebounds(void);
  70 + void set_response(GObservations& obs);
  71 + void set_obs_response(GCTAObservation* obs);
  72 +
  73 + // Protected members
  74 + bool m_read_ahead; //!< Read ahead parameters
65 75 };
66 76  
  77 +
  78 +/***********************************************************************//**
  79 + * @brief Return observation container
  80 + *
  81 + * @return Reference to observation container
  82 + ***************************************************************************/
  83 +inline
  84 +const bool& ctool::read_ahead(void) const
  85 +{
  86 + return (m_read_ahead);
  87 +}
  88 +
67 89 #endif /* CTOOL_HPP */
... ...