Commit b2608b4d9e795908693df5051fb203a824f1a60a

Authored by Jürgen Knödlseder
1 parent 5b512546

Review code.

src/ctbin/ctbin.cpp
... ... @@ -334,7 +334,7 @@ void ctbin::init_members(void)
334 334 {
335 335 // Initialise members
336 336 m_outcube.clear();
337   - m_usepnt = false;
  337 + m_usepnt = false;
338 338  
339 339 // Initialise protected members
340 340 m_obs.clear();
... ... @@ -357,16 +357,16 @@ void ctbin::init_members(void)
357 357 void ctbin::copy_members(const ctbin& app)
358 358 {
359 359 // Copy attributes
360   - m_outcube = app.m_outcube;
361   - m_usepnt = app.m_usepnt;
  360 + m_outcube = app.m_outcube;
  361 + m_usepnt = app.m_usepnt;
362 362  
363 363 // Copy protected members
364   - m_obs = app.m_obs;
365   - m_cube = app.m_cube;
366   - m_ebounds = app.m_ebounds;
367   - m_gti = app.m_gti;
368   - m_ontime = app.m_ontime;
369   - m_livetime = app.m_livetime;
  364 + m_obs = app.m_obs;
  365 + m_cube = app.m_cube;
  366 + m_ebounds = app.m_ebounds;
  367 + m_gti = app.m_gti;
  368 + m_ontime = app.m_ontime;
  369 + m_livetime = app.m_livetime;
370 370  
371 371 // Return
372 372 return;
... ... @@ -400,8 +400,7 @@ void ctbin::get_parameters(void)
400 400 // If there are no observations in container then load them via user parameters
401 401 if (m_obs.size() == 0) {
402 402  
403   - // Throw exception if no infile is given, since this tool needs an observation
404   - // including events
  403 + // Throw exception if no infile is given
405 404 if ((*this)["inobs"].filename() == "NONE" ||
406 405 (*this)["inobs"].filename() == "") {
407 406 std::string msg = "A valid file needs to be specified for the "
... ...
src/ctbkgcube/ctbkgcube.cpp
1 1 /***************************************************************************
2 2 * ctbkgcube - Background cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2015 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -481,8 +481,8 @@ void ctbkgcube::init_members(void)
481 481 void ctbkgcube::copy_members(const ctbkgcube& app)
482 482 {
483 483 // Copy members
484   - m_outmodel = app.m_outmodel;
485   - m_outcube = app.m_outcube;
  484 + m_outmodel = app.m_outmodel;
  485 + m_outcube = app.m_outcube;
486 486 m_obs = app.m_obs;
487 487 m_bkgcube = app.m_bkgcube;
488 488 m_bkgmdl = app.m_bkgmdl;
... ... @@ -509,9 +509,8 @@ void ctbkgcube::free_members(void)
509 509 /***********************************************************************//**
510 510 * @brief Get application parameters
511 511 *
512   - * @exception GException::invalid_value
513   - * Parameter "inobs" is required for ctbkgcube.
514 512 * @exception GException::invalid_value
  513 + * Parameter "inobs" is required for ctbkgcube.
515 514 * No background model definition XML file specified.
516 515 *
517 516 * Get all task parameters from parameter file or (if required) by querying
... ... @@ -524,10 +523,13 @@ void ctbkgcube::get_parameters(void)
524 523  
525 524 // Throw exception if no infile is given, since this tool needs an observation
526 525 // including events
527   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
528   -
529   - std::string msg = "Parameter \"inobs\" is required to be given in ctbkgcube."
530   - "Specify a vaild observation definition (XML or FITS) file to proceed";
  526 + if ((*this)["inobs"].filename() == "NONE" ||
  527 + (*this)["inobs"].filename() == "") {
  528 + std::string msg = "A valid file needs to be specified for the "
  529 + "\"inobs\" parameter, yet \""+
  530 + (*this)["inobs"].filename()+"\" was given."
  531 + " Specify a vaild observation definition or "
  532 + "event list FITS file to proceed.";
531 533 throw GException::invalid_value(G_GET_PARAMETERS, msg);
532 534 }
533 535  
... ... @@ -592,7 +594,7 @@ void ctbkgcube::get_parameters(void)
592 594  
593 595 // Read output filenames (if needed)
594 596 if (read_ahead()) {
595   - m_outcube = (*this)["outcube"].filename();
  597 + m_outcube = (*this)["outcube"].filename();
596 598 m_outmodel = (*this)["outmodel"].filename();
597 599 }
598 600  
... ...
src/ctbkgcube/ctbkgcube.hpp
1 1 /***************************************************************************
2 2 * ctbkgcube - Background cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2015 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -71,9 +71,8 @@ protected:
71 71 void fill_cube(GCTAObservation* obs);
72 72  
73 73 // Protected members
74   - std::string m_outcube; //!< Filename of output cube
75   - std::string m_outmodel; //!< Filename of output xml model
76   -
  74 + std::string m_outcube; //!< Filename of output cube
  75 + std::string m_outmodel; //!< Filename of output XML model
77 76 GObservations m_obs; //!< Observation container
78 77 GCTAEventCube m_bkgcube; //!< Background cube
79 78 GModels m_bkgmdl; //!< CTA background models
... ...
src/ctbkgcube/ctbkgcube.par
... ... @@ -17,7 +17,7 @@
17 17 #
18 18 # Observational parameters
19 19 #===================
20   -inobs, f, a, "NONE",,, "Input event list, cube or observation definition file"
  20 +inobs, f, a, "NONE",,, "Input event list, cube or observation definition file"
21 21 inmodel, f, a, "NONE",,, "Input (background) model XML file"
22 22 incube, f, a, "NONE",,, "Counts cube for background cube definition"
23 23 outcube, f, a, "bkgcube.fits",,, "Output background cube file"
... ...
src/ctbutterfly/ctbutterfly.cpp
1 1 /***************************************************************************
2 2 * ctbutterfly - butterfly calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Michael Mayer *
  4 + * copyright (C) 2014-2015 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -399,7 +399,6 @@ void ctbutterfly::save(void)
399 399 void ctbutterfly::init_members(void)
400 400 {
401 401 // Initialise members
402   - //m_inobs.clear();
403 402 m_srcname.clear();
404 403 m_outfile.clear();
405 404 m_ebounds.clear();
... ... @@ -424,7 +423,6 @@ void ctbutterfly::init_members(void)
424 423 void ctbutterfly::copy_members(const ctbutterfly& app)
425 424 {
426 425 // Copy attributes
427   - // m_inobs = app.m_inobs;
428 426 m_srcname = app.m_srcname;
429 427 m_outfile = app.m_outfile;
430 428 m_ebounds = app.m_ebounds;
... ... @@ -456,8 +454,6 @@ void ctbutterfly::free_members(void)
456 454 *
457 455 * @exception GException::invalid_value
458 456 * Parameter "inobs" is required for ctbutterfly.
459   -
460   - * @exception GException::invalid_value
461 457 * Test source not found or no RA/DEC parameters found for test
462 458 * source.
463 459 *
... ... @@ -472,12 +468,14 @@ void ctbutterfly::get_parameters(void)
472 468 // If there are no observations in container then load them via user parameters
473 469 if (m_obs.size() == 0) {
474 470  
475   - // Throw exception if no infile is given, since this tool needs an observation
476   - // including events
477   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
478   -
479   - std::string msg = "Parameter \"inobs\" is required to be given in ctbutterfly."
480   - "Specify a vaild observation definition (XML or FITS) file to proceed";
  471 + // Throw exception if no infile is given
  472 + if ((*this)["inobs"].filename() == "NONE" ||
  473 + (*this)["inobs"].filename() == "") {
  474 + std::string msg = "A valid file needs to be specified for the "
  475 + "\"inobs\" parameter, yet \""+
  476 + (*this)["inobs"].filename()+"\" was given."
  477 + " Specify a vaild observation definition or "
  478 + "event list FITS file to proceed.";
481 479 throw GException::invalid_value(G_GET_PARAMETERS, msg);
482 480 }
483 481  
... ... @@ -515,8 +513,8 @@ void ctbutterfly::get_parameters(void)
515 513 std::string matrixfilename = (*this)["matrix"].filename();
516 514 if (matrixfilename != "NONE") {
517 515 std::string msg = "Loading of matrix from file not implemented yet. "
518   - "Use filename = \"NONE\" to induce a recomputation of "
519   - "the matrix internally.";
  516 + "Use filename = \"NONE\" to induce a recomputation of "
  517 + "the matrix internally.";
520 518 throw GException::feature_not_implemented(G_GET_PARAMETERS, msg);
521 519 // m_covariance.load(matrixfilename);
522 520 }
... ...
src/ctbutterfly/ctbutterfly.hpp
1 1 /***************************************************************************
2 2 * ctbutterfly - butterfly calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Michael Mayer *
  4 + * copyright (C) 2014-2015 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -84,7 +84,7 @@ protected:
84 84 std::string m_outfile; //!< Output ascii file
85 85 GEbounds m_ebounds; //!< Energy binning definition
86 86  
87   - // Protected members
  87 + // Protected members
88 88 GObservations m_obs; //!< Observation container
89 89 GMatrixSparse m_covariance; //!< Covariance matrix
90 90 std::vector<double> m_energies; //!< Energy values for storage
... ...
src/ctbutterfly/ctbutterfly.par
... ... @@ -17,8 +17,8 @@
17 17 #
18 18 # General parameters
19 19 #===================
20   -inobs, f, a, "events.fits",,,"Input event list, cube or observation definition file"
21   -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
  20 +inobs, f, a, "events.fits",,,"Input event list, cube or observation definition file"
  21 +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
22 22 srcname, s, a, "Crab",,,"Source of interest"
23 23 caldb, s, a, "dummy",,, "Calibration database"
24 24 irf, s, a, "cta_dummy_irf",,, "Instrument response function"
... ...
src/ctcubemask/ctcubemask.cpp
1 1 /***************************************************************************
2 2 * ctcubemask - Cube filter tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2015 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -36,7 +36,7 @@
36 36 /* __ Method name definitions ____________________________________________ */
37 37 #define G_RUN "ctcubemask::run()"
38 38 #define G_APPLY_MASK "ctcubemask::apply_mask(GCTAObservation*)"
39   -#define G_GET_PARAMETERS "ctcubemask::get_parameters()"
  39 +#define G_GET_PARAMETERS "ctcubemask::get_parameters()"
40 40  
41 41 /* __ Debug definitions __________________________________________________ */
42 42  
... ... @@ -349,27 +349,29 @@ void ctcubemask::save(void)
349 349 ***************************************************************************/
350 350 void ctcubemask::get_parameters(void)
351 351 {
352   - // If there are no observations in container then load them via user parameters
353   - if (m_obs.size() == 0) {
354   -
355   - // Throw exception if no infile is given, since this tool needs an observation
356   - // including events
357   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
358   -
359   - std::string msg = "Parameter \"inobs\" is required to be given in ctcubemask."
360   - "Specify a vaild observation definition (XML or FITS) file to proceed"
361   - "It is not possible to build a binned observation from scratch";
362   - throw GException::invalid_value(G_GET_PARAMETERS, msg);
363   - }
  352 + // If there are no observations in container then load them via user
  353 + // parameters
  354 + if (m_obs.size() == 0) {
  355 +
  356 + // Throw exception if no infile is given
  357 + if ((*this)["inobs"].filename() == "NONE" ||
  358 + (*this)["inobs"].filename() == "") {
  359 + std::string msg = "A valid file needs to be specified for the "
  360 + "\"inobs\" parameter, yet \""+
  361 + (*this)["inobs"].filename()+"\" was given."
  362 + " Specify a vaild observation definition or "
  363 + "event list FITS file to proceed.";
  364 + throw GException::invalid_value(G_GET_PARAMETERS, msg);
  365 + }
364 366  
365   - // Build observation container without response (not needed)
366   - m_obs = get_observations(false);
  367 + // Build observation container without response (not needed)
  368 + m_obs = get_observations(false);
367 369  
368   - } // endif: there was no observation in the container
  370 + } // endif: there was no observation in the container
369 371  
370 372 // Get parameters
371 373 m_regfile = (*this)["regfile"].filename();
372   - m_usepnt = (*this)["usepnt"].boolean();
  374 + m_usepnt = (*this)["usepnt"].boolean();
373 375 if (!m_usepnt) {
374 376 m_ra = (*this)["ra"].real();
375 377 m_dec = (*this)["dec"].real();
... ... @@ -523,7 +525,6 @@ void ctcubemask::apply_mask(GCTAObservation* obs)
523 525 void ctcubemask::init_members(void)
524 526 {
525 527 // Initialise parameters
526   - //m_infile.clear();
527 528 m_regfile.clear();
528 529 m_outcube.clear();
529 530 m_prefix.clear();
... ... @@ -537,7 +538,6 @@ void ctcubemask::init_members(void)
537 538 // Initialise protected members
538 539 m_obs.clear();
539 540 m_infiles.clear();
540   -// m_use_xml = false;
541 541  
542 542 // Return
543 543 return;
... ... @@ -552,7 +552,6 @@ void ctcubemask::init_members(void)
552 552 void ctcubemask::copy_members(const ctcubemask& app)
553 553 {
554 554 // Copy parameters
555   - //m_infile = app.m_infile;
556 555 m_regfile = app.m_regfile;
557 556 m_outcube = app.m_outcube;
558 557 m_prefix = app.m_prefix;
... ... @@ -566,7 +565,6 @@ void ctcubemask::copy_members(const ctcubemask&amp; app)
566 565 // Copy protected members
567 566 m_obs = app.m_obs;
568 567 m_infiles = app.m_infiles;
569   -// m_use_xml = app.m_use_xml;
570 568  
571 569 // Return
572 570 return;
... ...
src/ctcubemask/ctcubemask.hpp
1 1 /***************************************************************************
2 2 * ctcubemask - Cube filter tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2015 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -92,7 +92,6 @@ protected:
92 92 // Protected members
93 93 GObservations m_obs; //!< Observations container
94 94 std::vector<std::string> m_infiles; //!< Input event filenames
95   - //bool m_use_xml; //!< Use XML file instead of FITS file
96 95 };
97 96  
98 97  
... ...
src/ctcubemask/ctcubemask.par
... ... @@ -17,7 +17,7 @@
17 17 #
18 18 # File information
19 19 #=================
20   -inobs, f, a, "cntmap.fits",,,"Input counts cube or observation definition file"
  20 +inobs, f, a, "cntmap.fits",,,"Input counts cube or observation definition file"
21 21 regfile, f, a, "NONE",,,"Exclusion region file in ds9 format"
22 22 outcube, f, a, "filtered_cube.fits",,,"Output event cube or observation definition file"
23 23 prefix, s, h, "filtered_",,,"Prefix for counts cube in observation definition file"
... ...
src/ctexpcube/ctexpcube.cpp
1 1 /***************************************************************************
2 2 * ctexpcube - Exposure cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -312,7 +312,6 @@ void ctexpcube::init_members(void)
312 312 // Initialise protected members
313 313 m_obs.clear();
314 314 m_expcube.clear();
315   - //m_ebounds.clear();
316 315  
317 316 // Return
318 317 return;
... ... @@ -331,8 +330,8 @@ void ctexpcube::copy_members(const ctexpcube&amp; app)
331 330 m_apply_edisp = app.m_apply_edisp;
332 331  
333 332 // Copy protected members
334   - m_obs = app.m_obs;
335   - m_expcube = app.m_expcube;
  333 + m_obs = app.m_obs;
  334 + m_expcube = app.m_expcube;
336 335  
337 336 // Return
338 337 return;
... ... @@ -361,15 +360,18 @@ void ctexpcube::free_members(void)
361 360 ***************************************************************************/
362 361 void ctexpcube::get_parameters(void)
363 362 {
364   - // If there are no observations in container then load them via user parameters
  363 + // If there are no observations in container then load them via user
  364 + // parameters
365 365 if (m_obs.size() == 0) {
366 366  
367   - // Throw exception if no infile is given, since this tool needs an observation
368   - // including events
369   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
370   -
371   - std::string msg = "Parameter \"inobs\" is required to be given in ctexpcube."
372   - "Specify a vaild observation definition (XML or FITS) file to proceed";
  367 + // Throw exception if no infile is given
  368 + if ((*this)["inobs"].filename() == "NONE" ||
  369 + (*this)["inobs"].filename() == "") {
  370 + std::string msg = "A valid file needs to be specified for the "
  371 + "\"inobs\" parameter, yet \""+
  372 + (*this)["inobs"].filename()+"\" was given."
  373 + " Specify a vaild observation definition or "
  374 + "event list FITS file to proceed.";
373 375 throw GException::invalid_value(G_GET_PARAMETERS, msg);
374 376 }
375 377  
... ... @@ -411,7 +413,7 @@ void ctexpcube::get_parameters(void)
411 413 // Define exposure cube
412 414 m_expcube = GCTAExposure(cube);
413 415  
414   - } // endif: filename was not valid
  416 + } // endif: filename was not valid
415 417  
416 418 // ... otherwise setup the exposure cube from the counts map
417 419 else {
... ...
src/ctexpcube/ctexpcube.par
... ... @@ -17,7 +17,7 @@
17 17 #
18 18 # Observational parameters
19 19 #===================
20   -inobs, f, a, "NONE",,, "Event list or observation definition file"
  20 +inobs, f, a, "NONE",,, "Event list or observation definition file"
21 21 incube, f, a, "NONE",,, "Counts map for exposure cube definition"
22 22 outcube, f, a, "expcube.fits",,, "Output exposure cube file"
23 23 caldb, s, a, "dummy",,, "Calibration database"
... ...
src/ctlike/ctlike.cpp
1 1 /***************************************************************************
2 2 * ctlike - Maximum likelihood fitting tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -363,11 +363,14 @@ void ctlike::get_parameters(void)
363 363 // If there are no observations in container then load them via user parameters
364 364 if (m_obs.size() == 0) {
365 365  
366   - // Throw exception if no infile is given, since this tool needs an observation
367   - // including events
368   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
369   - std::string msg = "Parameter \"inobs\" is required to be given in ctlike."
370   - "Specify a vaild observation definition (XML or FITS) file to proceed";
  366 + // Throw exception if no infile is given
  367 + if ((*this)["inobs"].filename() == "NONE" ||
  368 + (*this)["inobs"].filename() == "") {
  369 + std::string msg = "A valid file needs to be specified for the "
  370 + "\"inobs\" parameter, yet \""+
  371 + (*this)["inobs"].filename()+"\" was given."
  372 + " Specify a vaild observation definition or "
  373 + "event list FITS file to proceed.";
371 374 throw GException::invalid_value(G_GET_PARAMETERS, msg);
372 375 }
373 376  
... ...
src/ctlike/ctlike.hpp
1 1 /***************************************************************************
2 2 * ctlike - Maximum likelihood fitting tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -74,7 +74,7 @@ protected:
74 74  
75 75 // User parameters
76 76 bool m_refit; //!< Refitting
77   - std::string m_outmodel; //!< Source model output XML file
  77 + std::string m_outmodel; //!< Source model output XML file
78 78 bool m_apply_edisp; //!< Apply energy dispersion?
79 79  
80 80 // Members
... ...
src/ctlike/ctlike.par
... ... @@ -17,13 +17,13 @@
17 17 #
18 18 # General parameters
19 19 #===================
20   -inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file"
21   -stat, s, h, "POISSON",,, "Optimization statistics"
22   -edisp, b, h, no,,, "Apply energy dispersion?"
23   -refit, b, h, no,,, "Do refitting?"
24   -caldb, s, a, "dummy",,, "Calibration database"
25   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
26   -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
  20 +inobs, f, a, "events.fits",,, "Event list, counts cube or observation definition file"
  21 +stat, s, h, "POISSON",,, "Optimization statistics"
  22 +edisp, b, h, no,,, "Apply energy dispersion?"
  23 +refit, b, h, no,,, "Do refitting?"
  24 +caldb, s, a, "dummy",,, "Calibration database"
  25 +irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  26 +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
27 27 outmodel, f, a, "crab_results.xml",,, "Source model output file"
28 28 #
29 29 # Standard parameters
... ...
src/ctmodel/ctmodel.par
... ... @@ -19,12 +19,12 @@
19 19 #===================
20 20 incube, f, a, "NONE",,, "Input counts map or observation definition file"
21 21 outcube, f, a, "modmap.fits",,, "Output counts map or observation definition file"
22   -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
  22 +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
23 23 edisp, b, h, no,,, "Apply energy dispersion?"
24 24 #
25 25 # Observation parameters
26 26 #=======================
27   -inobs, f, a, "NONE",,, "Input event list, cube or observation definition file"
  27 +inobs, f, a, "NONE",,, "Input event list, cube or observation definition file"
28 28 caldb, s, a, "$CTOOLS/share/caldb/data/cta/dummy",,, "Calibration database"
29 29 irf, s, a, "cta_dummy_irf",,, "Instrument response function"
30 30 ra, r, a, 83.63,0,360, "RA of pointing (degrees)"
... ...
src/ctobssim/ctobssim.cpp
1 1 /***************************************************************************
2 2 * ctobssim - Observation simulator tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -427,6 +427,7 @@ void ctobssim::run(void)
427 427 return;
428 428 }
429 429  
  430 +
430 431 /***********************************************************************//**
431 432 * @brief Save the selected event list(s)
432 433 *
... ... @@ -491,7 +492,7 @@ void ctobssim::init_members(void)
491 492 // Initialise user parameters
492 493 m_outevents.clear();
493 494 m_prefix.clear();
494   - m_seed = 1;
  495 + m_seed = 1;
495 496 m_apply_edisp = false;
496 497  
497 498 // Initialise protected members
... ... @@ -519,7 +520,7 @@ void ctobssim::init_members(void)
519 520 void ctobssim::copy_members(const ctobssim& app)
520 521 {
521 522 // Copy user parameters
522   - m_outevents = app.m_outevents;
  523 + m_outevents = app.m_outevents;
523 524 m_prefix = app.m_prefix;
524 525 m_seed = app.m_seed;
525 526 m_apply_edisp = app.m_apply_edisp;
... ... @@ -559,21 +560,18 @@ void ctobssim::free_members(void)
559 560 void ctobssim::get_parameters(void)
560 561 {
561 562 // If there are no observations in container then load them via user parameters
562   - if (m_obs.size() == 0) {
  563 + if (m_obs.size() == 0) {
563 564  
564 565 // Build observation container
565 566 m_obs = get_observations();
566 567  
567   - } // endif: there was no observation in the container
  568 + } // endif: there was no observation in the container
568 569  
569   - // Read model definition file if required
570   - if (m_obs.models().size() == 0) {
  570 + // Read model definition file if required
  571 + if (m_obs.models().size() == 0) {
571 572 std::string inmodel = (*this)["inmodel"].filename();
572   -
573   - // Load models from file
574 573 m_obs.models(inmodel);
575   -
576   - } // endif: there were no models
  574 + }
577 575  
578 576 // Get other parameters
579 577 m_seed = (*this)["seed"].integer();
... ...
src/ctobssim/ctobssim.hpp
1 1 /***************************************************************************
2 2 * ctobssim - Observation simulator tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -85,7 +85,7 @@ protected:
85 85 void save_xml(void);
86 86  
87 87 // User parameters
88   - std::string m_outevents; //!< Output events file
  88 + std::string m_outevents; //!< Output events file
89 89 std::string m_prefix; //!< Prefix for multiple event lists
90 90 int m_seed; //!< Random number generator seed
91 91 bool m_apply_edisp; //!< Apply energy dispersion?
... ...
src/ctobssim/ctobssim.par
... ... @@ -17,10 +17,10 @@
17 17 #
18 18 # File information
19 19 #=================
20   -inobs, f, h, "NONE",,,"Input event list or observation definition file"
21   -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Model"
22   -outevents,f, a, "events.fits",,, "Output event data file or observation definition file"
23   -prefix, s, h, "sim_events_",,, "Prefix for event lists in observation definition file"
  20 +inobs, f, h, "NONE",,,"Input event list or observation definition file"
  21 +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Model"
  22 +outevents, f, a, "events.fits",,,"Output event data file or observation definition file"
  23 +prefix, s, h, "sim_events_",,,"Prefix for event lists in observation definition file"
24 24 #
25 25 # Observation parameters
26 26 #=======================
... ...
src/ctpsfcube/ctpsfcube.cpp
1 1 /***************************************************************************
2 2 * ctpsfcube - PSF cube generation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2015 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -35,7 +35,6 @@
35 35  
36 36 /* __ Method name definitions ____________________________________________ */
37 37 #define G_GET_PARAMETERS "ctpsfcube::get_parameters()"
38   -#define G_SET_FROM_CNTMAP "ctpsfcube::set_from_cntmap(std::string&)"
39 38  
40 39 /* __ Debug definitions __________________________________________________ */
41 40  
... ... @@ -355,12 +354,14 @@ void ctpsfcube::get_parameters(void)
355 354 // If there are no observations in container then load them via user parameters
356 355 if (m_obs.size() == 0) {
357 356  
358   - // Throw exception if no infile is given, since this tool needs an observation
359   - // including events
360   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
361   -
362   - std::string msg = "Parameter \"inobs\" is required to be given in ctpsfcube."
363   - "Specify a vaild observation definition (XML or FITS) file to proceed";
  357 + // Throw exception if no infile is given
  358 + if ((*this)["inobs"].filename() == "NONE" ||
  359 + (*this)["inobs"].filename() == "") {
  360 + std::string msg = "A valid file needs to be specified for the "
  361 + "\"inobs\" parameter, yet \""+
  362 + (*this)["inobs"].filename()+"\" was given."
  363 + " Specify a vaild observation definition or "
  364 + "event list FITS file to proceed.";
364 365 throw GException::invalid_value(G_GET_PARAMETERS, msg);
365 366 }
366 367  
... ... @@ -373,8 +374,8 @@ void ctpsfcube::get_parameters(void)
373 374 std::string incube = (*this)["incube"].filename();
374 375  
375 376 // Get additional binning parameters
376   - double dmax = (*this)["amax"].real();
377   - int ndbins = (*this)["anumbins"].integer();
  377 + double dmax = (*this)["amax"].real();
  378 + int ndbins = (*this)["anumbins"].integer();
378 379  
379 380 // Check for filename validity
380 381 if ((incube == "NONE") || (gammalib::strip_whitespace(incube) == "")) {
... ... @@ -388,7 +389,7 @@ void ctpsfcube::get_parameters(void)
388 389 // Check if pointing should be used
389 390 if (usepnt) {
390 391  
391   - // buld cube from user parameters and pointing information
  392 + // Build cube from user parameters and pointing information
392 393 cube = get_cube(m_obs);
393 394  
394 395 } // endif: pointing used as map center
... ... @@ -402,6 +403,7 @@ void ctpsfcube::get_parameters(void)
402 403  
403 404 // Define psf cube
404 405 m_psfcube = GCTAMeanPsf(cube, dmax, ndbins);
  406 +
405 407 }
406 408  
407 409 // ... otherwise setup the exposure cube from the counts map
... ...
src/ctpsfcube/ctpsfcube.par
... ... @@ -17,7 +17,7 @@
17 17 #
18 18 # Observational parameters
19 19 #===================
20   -inobs, f, a, "NONE",,, "Event list or observation definition file"
  20 +inobs, f, a, "NONE",,, "Event list or observation definition file"
21 21 incube, f, a, "NONE",,, "Counts map for exposure cube definition"
22 22 outcube, f, a, "psfcube.fits",,, "Output exposure cube file"
23 23 caldb, s, a, "dummy",,, "Calibration database"
... ...
src/ctselect/ctselect.cpp
1 1 /***************************************************************************
2 2 * ctselect - Data selection tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -471,12 +471,14 @@ void ctselect::get_parameters(void)
471 471 // If there are no observations in container then load them via user parameters
472 472 if (m_obs.size() == 0) {
473 473  
474   - // Throw exception if no infile is given, since this tool needs an observation
475   - // including events
476   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
477   -
478   - std::string msg = "Parameter \"inobs\" is required to be given in ctselect."
479   - "Specify a vaild observation definition (XML or FITS) file to proceed";
  474 + // Throw exception if no infile is given
  475 + if ((*this)["inobs"].filename() == "NONE" ||
  476 + (*this)["inobs"].filename() == "") {
  477 + std::string msg = "A valid file needs to be specified for the "
  478 + "\"inobs\" parameter, yet \""+
  479 + (*this)["inobs"].filename()+"\" was given."
  480 + " Specify a vaild observation definition or "
  481 + "event list FITS file to proceed.";
480 482 throw GException::invalid_value(G_GET_PARAMETERS, msg);
481 483 }
482 484  
... ... @@ -511,7 +513,7 @@ void ctselect::get_parameters(void)
511 513 // dumped into the log file
512 514 if (read_ahead()) {
513 515 m_outobs = (*this)["outobs"].filename();
514   - m_prefix = (*this)["prefix"].string();
  516 + m_prefix = (*this)["prefix"].string();
515 517 }
516 518  
517 519 // Set time interval with input times given in CTA reference
... ...
src/ctselect/ctselect.hpp
1 1 /***************************************************************************
2 2 * ctselect - Data selection tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -82,7 +82,7 @@ protected:
82 82 const std::string& outfile) const;
83 83  
84 84 // User parameters
85   - std::string m_outobs; //!< Output event list or XML file
  85 + std::string m_outobs; //!< Output event list or XML file
86 86 std::string m_prefix; //!< Prefix for multiple event lists
87 87 bool m_usepnt; //!< Use pointing instead of RA/DEC parameters
88 88 double m_ra; //!< RA of ROI centre
... ...
src/ctselect/ctselect.par
... ... @@ -17,11 +17,11 @@
17 17 #
18 18 # File information
19 19 #=================
20   -inobs, f, a, "events.fits",,,"Input event list or observation definition file"
21   -outobs,f, a, "selected_events.fits",,,"Output event list or observation definition file"
  20 +inobs, f, a, "events.fits",,,"Input event list or observation definition file"
  21 +outobs, f, a, "selected_events.fits",,,"Output event list or observation definition file"
22 22 prefix, s, h, "selected_",,,"Prefix for event lists in observation definition file"
23   -caldb, s, h, "dummy",,, "Calibration database"
24   -irf, s, h, "cta_dummy_irf",,, "Instrument response function"
  23 +caldb, s, h, "dummy",,, "Calibration database"
  24 +irf, s, h, "cta_dummy_irf",,, "Instrument response function"
25 25 #
26 26 # Selection parameters
27 27 #=====================
... ...
src/ctskymap/ctskymap.cpp
1 1 /***************************************************************************
2 2 * ctskymap - Sky mapping tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -35,7 +35,8 @@
35 35 /* __ Method name definitions ____________________________________________ */
36 36 #define G_INIT_MAP "ctskymap::init_map(GCTAObservation* obs)"
37 37 #define G_BIN_EVENTS "ctskymap::bin_events(GCTAObservation*)"
38   -#define G_GET_PARAMETERS "ctskymap::get_parameters()"
  38 +#define G_GET_PARAMETERS "ctskymap::get_parameters()"
  39 +
39 40 /* __ Debug definitions __________________________________________________ */
40 41  
41 42 /* __ Coding definitions _________________________________________________ */
... ... @@ -329,22 +330,25 @@ void ctskymap::save(void)
329 330 ***************************************************************************/
330 331 void ctskymap::get_parameters(void)
331 332 {
332   - // If there are no observations in container then load them via user parameters
333   - if (m_obs.size() == 0) {
334   -
335   - // Throw exception if no infile is given, since this tool needs an observation
336   - // including events
337   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
338   -
339   - std::string msg = "Parameter \"inobs\" is required to be given in ctskymap."
340   - "Specify a vaild observation definition (XML or FITS) file to proceed";
341   - throw GException::invalid_value(G_GET_PARAMETERS, msg);
342   - }
  333 + // If there are no observations in container then load them via user
  334 + // parameters
  335 + if (m_obs.size() == 0) {
  336 +
  337 + // Throw exception if no infile is given
  338 + if ((*this)["inobs"].filename() == "NONE" ||
  339 + (*this)["inobs"].filename() == "") {
  340 + std::string msg = "A valid file needs to be specified for the "
  341 + "\"inobs\" parameter, yet \""+
  342 + (*this)["inobs"].filename()+"\" was given."
  343 + " Specify a vaild observation definition or "
  344 + "event list FITS file to proceed.";
  345 + throw GException::invalid_value(G_GET_PARAMETERS, msg);
  346 + }
343 347  
344   - // Build observation container without response (not needed)
345   - m_obs = get_observations(false);
  348 + // Build observation container without response (not needed)
  349 + m_obs = get_observations(false);
346 350  
347   - } // endif: there was no observation in the container
  351 + } // endif: there was no observation in the container
348 352  
349 353 // Get parameters
350 354 bool usepnt = (*this)["usepnt"].boolean();
... ... @@ -365,8 +369,8 @@ void ctskymap::get_parameters(void)
365 369 } // endelse: m_usepnt was false
366 370  
367 371 // Get remaining parameters
368   - m_emin = (*this)["emin"].real();
369   - m_emax = (*this)["emax"].real();
  372 + m_emin = (*this)["emin"].real();
  373 + m_emax = (*this)["emax"].real();
370 374  
371 375 // Read ahead parameters
372 376 if (read_ahead()) {
... ... @@ -485,8 +489,8 @@ void ctskymap::init_members(void)
485 489 // Initialise members
486 490 m_obs.clear();
487 491 m_skymap.clear();
488   - m_emin = 0.0;
489   - m_emax = 0.0;
  492 + m_emin = 0.0;
  493 + m_emax = 0.0;
490 494  
491 495 // Return
492 496 return;
... ... @@ -501,10 +505,10 @@ void ctskymap::init_members(void)
501 505 void ctskymap::copy_members(const ctskymap& app)
502 506 {
503 507 // Copy attributes
504   - m_obs = app.m_obs;
505   - m_skymap = app.m_skymap;
506   - m_emin = app.m_emin;
507   - m_emax = app.m_emax;
  508 + m_obs = app.m_obs;
  509 + m_skymap = app.m_skymap;
  510 + m_emin = app.m_emin;
  511 + m_emax = app.m_emax;
508 512  
509 513 // Return
510 514 return;
... ...
src/ctskymap/ctskymap.hpp
1 1 /***************************************************************************
2 2 * ctskymap - Sky mapping tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -72,7 +72,7 @@ protected:
72 72 void map_events(GCTAObservation* obs);
73 73  
74 74 // User parameters
75   - std::string m_outmap; //!< Output counts map
  75 + std::string m_outmap; //!< Output counts map
76 76 double m_emin; //!< Minimum energy (TeV)
77 77 double m_emax; //!< Maximum energy (TeV)
78 78  
... ...
src/cttsmap/cttsmap.cpp
1 1 /***************************************************************************
2 2 * cttsmap - TS map calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Michael Mayer *
  4 + * copyright (C) 2014-2015 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -436,18 +436,18 @@ void cttsmap::init_members(void)
436 436 void cttsmap::copy_members(const cttsmap& app)
437 437 {
438 438 // Copy attributes
439   - m_srcname = app.m_srcname;
  439 + m_srcname = app.m_srcname;
440 440 m_outmap = app.m_outmap;
441 441  
442 442 // Copy protected members
443   - m_binmin = app.m_binmin;
444   - m_binmax = app.m_binmax;
445   - m_logL0 = app.m_logL0;
446   - m_obs = app.m_obs;
447   - m_tsmap = app.m_tsmap;
448   - m_mapnames = app.m_mapnames;
449   - m_maps = app.m_maps;
450   - m_statusmap = app.m_statusmap;
  443 + m_binmin = app.m_binmin;
  444 + m_binmax = app.m_binmax;
  445 + m_logL0 = app.m_logL0;
  446 + m_obs = app.m_obs;
  447 + m_tsmap = app.m_tsmap;
  448 + m_mapnames = app.m_mapnames;
  449 + m_maps = app.m_maps;
  450 + m_statusmap = app.m_statusmap;
451 451  
452 452 // Clone protected members
453 453 m_testsource = (app.m_testsource != NULL) ? app.m_testsource->clone() : NULL;
... ... @@ -485,15 +485,18 @@ void cttsmap::free_members(void)
485 485 ***************************************************************************/
486 486 void cttsmap::get_parameters(void)
487 487 {
488   - // If there are no observations in container then load them via user parameters
  488 + // If there are no observations in container then load them via user
  489 + // parameters
489 490 if (m_obs.size() == 0) {
490 491  
491   - // Throw exception if no infile is given, since this tool needs an observation
492   - // including events
493   - if ((*this)["inobs"].filename()=="NONE" || (*this)["inobs"].filename() == "") {
494   -
495   - std::string msg = "Parameter \"inobs\" is required to be given in cttsmap."
496   - "Specify a vaild observation definition (XML or FITS) file to proceed";
  492 + // Throw exception if no infile is given
  493 + if ((*this)["inobs"].filename() == "NONE" ||
  494 + (*this)["inobs"].filename() == "") {
  495 + std::string msg = "A valid file needs to be specified for the "
  496 + "\"inobs\" parameter, yet \""+
  497 + (*this)["inobs"].filename()+"\" was given."
  498 + " Specify a vaild observation definition or "
  499 + "event list FITS file to proceed.";
497 500 throw GException::invalid_value(G_GET_PARAMETERS, msg);
498 501 }
499 502  
... ... @@ -544,14 +547,13 @@ void cttsmap::get_parameters(void)
544 547 (*m_testsource)["DEC"].fix();
545 548 }
546 549  
547   -
548   - // Get sky map binning from user parameters
549   - // and check if pointing should be used
  550 + // Get sky map binning from user parameters and check if pointing
  551 + // should be used
550 552 GSkymap map;
551 553 bool usepnt = (*this)["usepnt"].boolean();
552 554 if (usepnt) {
553 555  
554   - // build cube from user parameters and pointing information
  556 + // Build cube from user parameters and pointing information
555 557 map = get_map(m_obs);
556 558  
557 559 } // endif: pointing used as map center
... ...
src/cttsmap/cttsmap.hpp
1 1 /***************************************************************************
2 2 * cttsmap - TS map calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Michael Mayer *
  4 + * copyright (C) 2014-2015 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -85,12 +85,12 @@ protected:
85 85  
86 86 // User parameters
87 87 std::string m_srcname; //!< Name of source which is moved around
88   - std::string m_outmap; //!< Output counts map or XML file
  88 + std::string m_outmap; //!< Output counts map or XML file
89 89  
90 90 // Parameters to control speed and job splitting
91   - int m_binmin; //!< Map bin number from which computation should start
92   - int m_binmax; //!< Map bin number where map computation should end
93   - double m_logL0; //!< Likelihood value of null hypothesis
  91 + int m_binmin; //!< Map bin number from which computation should start
  92 + int m_binmax; //!< Map bin number where map computation should end
  93 + double m_logL0; //!< Likelihood value of null hypothesis
94 94  
95 95 // Protected members
96 96 GObservations m_obs; //!< Observation container
... ...
src/cttsmap/cttsmap.par
... ... @@ -17,11 +17,11 @@
17 17 #
18 18 # General parameters
19 19 #===================
20   -inobs, f, a, "events.fits",,,"Input event list, cube or observation definition file"
21   -inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
22   -srcname, s, a, "TestSource",,,"Test source"
23   -caldb, s, a, "dummy",,, "Calibration database"
24   -irf, s, a, "cta_dummy_irf",,, "Instrument response function"
  20 +inobs, f, a, "events.fits",,, "Input event list, cube or observation definition file"
  21 +inmodel, f, a, "$CTOOLS/share/models/crab.xml",,, "Source model"
  22 +srcname, s, a, "TestSource",,, "Test source"
  23 +caldb, s, a, "dummy",,, "Calibration database"
  24 +irf, s, a, "cta_dummy_irf",,, "Instrument response function"
25 25 outmap, f, a, "tsmap.fits",,, "Output counts cube"
26 26  
27 27 #
... ...
src/support/ctool.cpp
1 1 /***************************************************************************
2 2 * ctool - ctool base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -48,8 +48,9 @@
48 48  
49 49 /* __ Method name definitions ____________________________________________ */
50 50 #define G_GET_EBOUNDS "ctool::get_ebounds()"
51   -#define G_SET_FROM_CNTMAP "ctool::set_from_cntmap(std::string&)"
52   -#define G_GET_CUBE "ctool::get_cube(GObservations&)"
  51 +#define G_SET_FROM_CNTMAP "ctool::set_from_cntmap(std::string&)"
  52 +#define G_GET_MEAN_POINTING "ctool::get_mean_pointing(GObservations&)"
  53 +#define G_GET_CUBE "ctool::get_cube(GObservations&)"
53 54  
54 55 /* __ Debug definitions __________________________________________________ */
55 56  
... ... @@ -228,7 +229,7 @@ void ctool::init_members(void)
228 229 {
229 230 // Initialise members
230 231 m_read_ahead = false;
231   - m_use_xml = false;
  232 + m_use_xml = false;
232 233  
233 234 // Set CTA time reference. G_CTA_MJDREF is the CTA reference MJD,
234 235 // which is defined in GCTALib.hpp. This is somehow a kluge. We need
... ... @@ -252,8 +253,8 @@ void ctool::copy_members(const ctool&amp; app)
252 253 {
253 254 // Copy members
254 255 m_read_ahead = app.m_read_ahead;
255   - m_use_xml = app.m_use_xml;
256   - m_cta_ref = app.m_cta_ref;
  256 + m_use_xml = app.m_use_xml;
  257 + m_cta_ref = app.m_cta_ref;
257 258  
258 259 // Return
259 260 return;
... ... @@ -276,6 +277,172 @@ void ctool::free_members(void)
276 277  
277 278  
278 279 /***********************************************************************//**
  280 + * @brief Build a CTA observation with an empty event list
  281 + *
  282 + * Creates an empty CTA observation from user parameters. An empty event list
  283 + * including RoI, GTI and energy boundary information is attached to the
  284 + * observation. The method also sets the pointing direction using the ra and
  285 + * dec parameter, the ROI based on ra, dec and rad, a single GTI based on
  286 + * tmin and tmax, and a single energy boundary based on emin and emax. The
  287 + * method furthermore sets the ontime, livetime and deadtime correction
  288 + * factor.
  289 + *
  290 + * The following parameters are read:
  291 + * ra - Right Ascension of pointing and RoI centre (deg)
  292 + * dec - Declination of pointing and RoI centre (deg)
  293 + * rad - Radius of RoI (deg)
  294 + * deadc - Deadtime correction factor
  295 + * tmin - Start time
  296 + * tmax - Stop time
  297 + * emin - Minimum energy (TeV)
  298 + * emax - Maximum energy (TeV)
  299 + ***************************************************************************/
  300 +GCTAObservation ctool::setup_obs(void)
  301 +{
  302 + // Get CTA observation parameters
  303 + double ra = (*this)["ra"].real();
  304 + double dec = (*this)["dec"].real();
  305 + double rad = (*this)["rad"].real();
  306 + double deadc = (*this)["deadc"].real();
  307 + double t_min = (*this)["tmin"].real();
  308 + double t_max = (*this)["tmax"].real();
  309 + double e_min = (*this)["emin"].real();
  310 + double e_max = (*this)["emax"].real();
  311 +
  312 + // Allocate CTA observation and empty event list
  313 + GCTAObservation obs;
  314 + GCTAEventList list;
  315 +
  316 + // Set pointing direction
  317 + GCTAPointing pnt;
  318 + GSkyDir skydir;
  319 + skydir.radec_deg(ra, dec);
  320 + pnt.dir(skydir);
  321 +
  322 + // Set ROI
  323 + GCTAInstDir instdir(skydir);
  324 + GCTARoi roi(instdir, rad);
  325 +
  326 + // Set GTI
  327 + GGti gti(m_cta_ref);
  328 + GTime tstart;
  329 + GTime tstop;
  330 + tstart.set(t_min, m_cta_ref);
  331 + tstop.set(t_max, m_cta_ref);
  332 + gti.append(tstart, tstop);
  333 +
  334 + // Set energy boundaries
  335 + GEbounds ebounds;
  336 + GEnergy emin;
  337 + GEnergy emax;
  338 + emin.TeV(e_min);
  339 + emax.TeV(e_max);
  340 + ebounds.append(emin, emax);
  341 +
  342 + // Set CTA event list attributes
  343 + list.roi(roi);
  344 + list.gti(gti);
  345 + list.ebounds(ebounds);
  346 +
  347 + // Attach event list to CTA observation
  348 + obs.events(list);
  349 +
  350 + // Set observation ontime, livetime and deadtime correction factor
  351 + obs.pointing(pnt);
  352 + obs.ontime(gti.ontime());
  353 + obs.livetime(gti.ontime()*deadc);
  354 + obs.deadc(deadc);
  355 +
  356 + // Return CTA observation
  357 + return obs;
  358 +
  359 +}
  360 +
  361 +
  362 +/***********************************************************************//**
  363 + * @brief Build a skymap based on user parameters
  364 + *
  365 + * Creates an empty skymap from input user parameters.
  366 + *
  367 + * The following parameters are read:
  368 + * proj - Coordinate projection
  369 + * coordsys - Coordinate system
  370 + * binsz - Bin size (deg)
  371 + * nxpix - Number of pixels in Right Ascension or longitude
  372 + * nypix - Number of pixels in Declination or latitude
  373 + ***************************************************************************/
  374 +GSkymap ctool::get_map()
  375 +{
  376 + // Read task parameters
  377 + double xref = (*this)["xref"].real();
  378 + double yref = (*this)["yref"].real();
  379 + std::string proj = (*this)["proj"].string();
  380 + std::string coordsys = (*this)["coordsys"].string();
  381 + double binsz = (*this)["binsz"].real();
  382 + int nxpix = (*this)["nxpix"].integer();
  383 + int nypix = (*this)["nypix"].integer();
  384 +
  385 + // Initialise sky map
  386 + GSkymap map = GSkymap(proj, coordsys, xref, yref, -binsz, binsz,
  387 + nxpix, nypix, 1);
  388 +
  389 + // Return sky map
  390 + return map;
  391 +}
  392 +
  393 +
  394 +/***********************************************************************//**
  395 + * @brief Build a skymap based on user parameters
  396 + *
  397 + * @param[in] obs Observation container.
  398 + *
  399 + * Creates an empty skymap from input user parameters. The reference
  400 + * coordinate is extracted from the mean pointing of the CTA observations
  401 + * in the observation container (see get_mean_pointing()).
  402 + *
  403 + * The following parameters are read:
  404 + * proj - Coordinate projection
  405 + * coordsys - Coordinate system
  406 + * binsz - Bin size (deg)
  407 + * nxpix - Number of pixels in Right Ascension or longitude
  408 + * nypix - Number of pixels in Declination or latitude
  409 + ***************************************************************************/
  410 +GSkymap ctool::get_map(const GObservations& obs)
  411 +{
  412 + // Read task parameters
  413 + std::string proj = (*this)["proj"].string();
  414 + std::string coordsys = (*this)["coordsys"].string();
  415 + double binsz = (*this)["binsz"].real();
  416 + int nxpix = (*this)["nxpix"].integer();
  417 + int nypix = (*this)["nypix"].integer();
  418 +
  419 + // Initialise reference coordinates
  420 + double xref = 0.0;
  421 + double yref = 0.0;
  422 +
  423 + // Get pointing from observations
  424 + GSkyDir pnt = get_mean_pointing(obs);
  425 +
  426 + // Use correct coordinate system
  427 + if (gammalib::toupper(coordsys) == "GAL") {
  428 + xref = pnt.l_deg();
  429 + yref = pnt.b_deg();
  430 + }
  431 + else {
  432 + xref = pnt.ra_deg();
  433 + yref = pnt.dec_deg();
  434 + }
  435 +
  436 + // Initialise sky map
  437 + GSkymap map = GSkymap(proj, coordsys, xref, yref, -binsz, binsz,
  438 + nxpix, nypix, 1);
  439 +
  440 + // Return sky map
  441 + return map;
  442 +}
  443 +
  444 +
  445 +/***********************************************************************//**
279 446 * @brief Get the energy boundaries
280 447 *
281 448 * @exception GException::invalid_value
... ... @@ -285,6 +452,12 @@ void ctool::free_members(void)
285 452 * supports loading of energy boundary information from the EBOUNDS or
286 453 * ENERGYBINS extension, or setting energy boundaries using a linear
287 454 * or logarithmical spacing.
  455 + *
  456 + * The following parameters are read:
  457 + * ebinalg - Energy binning algorithm
  458 + * emin - Minimum energy (if ebinalg != FILE)
  459 + * emax - Maximum energy (if ebinalg != FILE)
  460 + * enumbins - Number of energy bins (if ebinalg != FILE)
288 461 ***************************************************************************/
289 462 GEbounds ctool::get_ebounds(void)
290 463 {
... ... @@ -352,52 +525,16 @@ GEbounds ctool::get_ebounds(void)
352 525 }
353 526  
354 527  
355   -
356   -
357   -/***********************************************************************//**
358   - * @brief Get a GCTAEventCube from file
359   - *
360   - * @param[in] filename FITS file of count cube.
361   - * @exception GException::invalid_value
362   - * Counts map not of WCS type
363   - *
364   - * Gets an cta event cube from file. This function is used in many ctools
365   - * to obtain a skymap definition from file
366   - *
367   - ***************************************************************************/
368   -GCTAEventCube ctool::set_from_cntmap(const std::string filename)
369   -{
370   - // Allocate CTA observation
371   - GCTAEventCube cube;
372   -
373   - // Load counts map in CTA observation
374   - cube.load(filename);
375   -
376   - // Check for valid WCS coordinate system
377   - const GWcs* wcs = dynamic_cast<const GWcs*>(cube.map().projection());
378   - if (wcs == NULL) {
379   -
380   - std::string msg = "Counts map project is not of WCS type.";
381   - throw GException::invalid_value(G_SET_FROM_CNTMAP, msg);
382   -
383   - } // endif: WCS projection was not valid
384   -
385   - // Return cube
386   - return cube;
387   -}
388   -
389   -
390   -
391 528 /***********************************************************************//**
392 529 * @brief Get observation container
393 530 *
394   - * @param[in] get_response flag whether response information should be loaded
  531 + * @param[in] get_response Indicates whether response information should
  532 + * be loaded (default: true)
395 533 *
396 534 * Get an observation container according to the user parameters. The method
397   - * supports loading of a individual FITS file, an observation definition file in XML
398   - * format. If the input filename is empty, parameters are read to build a CTA observation
399   - * from scratch.
400   - *
  535 + * supports loading of a individual FITS file or an observation definition
  536 + * file in XML format. If the input filename is empty, parameters are read
  537 + * to build a CTA observation from scratch.
401 538 ***************************************************************************/
402 539 GObservations ctool::get_observations(const bool& get_response)
403 540 {
... ... @@ -428,6 +565,7 @@ GObservations ctool::get_observations(const bool&amp; get_response)
428 565  
429 566 } // endif: filename was "NONE" or ""
430 567  
  568 + // ... otherwise we have a file name
431 569 else {
432 570  
433 571 // Try first to open as FITS file
... ... @@ -454,6 +592,7 @@ GObservations ctool::get_observations(const bool&amp; get_response)
454 592 m_use_xml = false;
455 593  
456 594 }
  595 +
457 596 // ... otherwise try to open as XML file
458 597 catch (GException::fits_open_error &e) {
459 598  
... ... @@ -472,7 +611,8 @@ GObservations ctool::get_observations(const bool&amp; get_response)
472 611 // Signal that XML file should be used for storage
473 612 m_use_xml = true;
474 613  
475   - } // endcatch: file was an XML file
  614 + } // endcatch: file was an XML file
  615 +
476 616 }
477 617  
478 618 // Return observation container
... ... @@ -480,118 +620,58 @@ GObservations ctool::get_observations(const bool&amp; get_response)
480 620  
481 621 }
482 622  
  623 +
483 624 /***********************************************************************//**
484   - * @brief Build a CTA observation with an empty event list
  625 + * @brief Derives mean pointing from CTA observations
485 626 *
486   - * Creates an empty CTA observation from user parameters. An empty event list
487   - * including RoI, GTi and energy boundary information is attached to the observation.
488   - * The method also sets the pointing direction using the ra and dec parameter, the ROI based on
489   - * ra, dec and rad, a single GTI based on tmin and tmax, and a
490   - * single energy boundary based on emin and emax. The method furthermore
491   - * sets the ontime, livetime and deadtime correction factor.
  627 + * @param[in] obs Observation container.
  628 + * @return Pointing direction.
  629 + *
  630 + * Computes the mean pointing direction from all CTA observations in the
  631 + * observation container.
492 632 *
  633 + * @todo This method does not work properly for wrap arounds in Right
  634 + * Ascension. It certainly will also lead to bad results near the
  635 + * celestial pole.
493 636 ***************************************************************************/
494   -GCTAObservation ctool::setup_obs(void)
495   -{
496   - //Get CTA observation parameters
497   - double ra = (*this)["ra"].real();
498   - double dec = (*this)["dec"].real();
499   - double rad = (*this)["rad"].real();
500   - double deadc = (*this)["deadc"].real();
501   - double t_min = (*this)["tmin"].real();
502   - double t_max = (*this)["tmax"].real();
503   - double e_min = (*this)["emin"].real();
504   - double e_max = (*this)["emax"].real();
505   -
506   - // Allocate CTA observation and empty event list
507   - GCTAObservation obs;
508   - GCTAEventList list;
509   -
510   - // Set pointing direction
511   - GCTAPointing pnt;
512   - GSkyDir skydir;
513   - skydir.radec_deg(ra, dec);
514   - pnt.dir(skydir);
515   -
516   - // Set ROI
517   - GCTAInstDir instdir(skydir);
518   - GCTARoi roi(instdir, rad);
519   -
520   - // Set GTI
521   - GGti gti(m_cta_ref);
522   - GTime tstart;
523   - GTime tstop;
524   - tstart.set(t_min, m_cta_ref);
525   - tstop.set(t_max, m_cta_ref);
526   - gti.append(tstart, tstop);
527   -
528   - // Set energy boundaries
529   - GEbounds ebounds;
530   - GEnergy emin;
531   - GEnergy emax;
532   - emin.TeV(e_min);
533   - emax.TeV(e_max);
534   - ebounds.append(emin, emax);
535   -
536   - // Set CTA event list attributes
537   - list.roi(roi);
538   - list.gti(gti);
539   - list.ebounds(ebounds);
540   -
541   - // Attach event list to CTA observation
542   - obs.events(list);
543   -
544   - // Set observation ontime, livetime and deadtime correction factor
545   - obs.pointing(pnt);
546   - obs.ontime(gti.ontime());
547   - obs.livetime(gti.ontime()*deadc);
548   - obs.deadc(deadc);
549   -
550   - // Return CTA observation
551   - return obs;
552   -
553   -}
554   -
555   -GSkyDir ctool::get_pointing(const GObservations& obs)
  637 +GSkyDir ctool::get_mean_pointing(const GObservations& obs)
556 638 {
557 639 // Initialise values
558   - double xref = 0.0;
559   - double yref = 0.0;
560   - int n_pnt = 0;
561   - bool found = false;
  640 + double xref = 0.0;
  641 + double yref = 0.0;
  642 + int n_pnt = 0;
562 643  
563 644 // Loop over all observations to compute mean pointings
564 645 for (int i = 0; i < obs.size(); ++i) {
565   - const GCTAObservation* cta_obs = dynamic_cast<const GCTAObservation*>(obs[i]);
566   - if (cta_obs != NULL) {
567 646  
568   - // get pointing
  647 + // If we have a CTA observation then extract the pointing direction
  648 + const GCTAObservation* cta_obs = dynamic_cast<const GCTAObservation*>(obs[i]);
  649 + if (cta_obs != NULL) {
  650 +
  651 + // Get pointing
569 652 const GCTAPointing& pnt = cta_obs->pointing();
570 653  
571 654 // Add to coordinates
572   - xref += pnt.dir().ra_deg();
573   - yref += pnt.dir().dec_deg();
  655 + xref += pnt.dir().ra_deg();
  656 + yref += pnt.dir().dec_deg();
574 657 n_pnt += 1;
575 658  
576   - // Signal that pointing has been found
577   - found = true;
578   -
579 659 } // endif: cta observation was valid
580 660  
581   - } // endfor: loop over alle observations
  661 + } // endfor: loop over all observations
582 662  
583 663 // Signal if no pointing is found
584   - if (!found) {
  664 + if (n_pnt < 1) {
585 665 std::string msg = "No valid CTA observation has been found in "
586 666 "observation list, hence no pointing information "
587 667 "could be extracted. Use the \"usepnt=no\" "
588   - "option and specify pointing explicitly";
589   - throw GException::invalid_value(G_GET_CUBE, msg);
  668 + "option and specify the pointing explicitly.";
  669 + throw GException::invalid_value(G_GET_MEAN_POINTING, msg);
590 670 }
591 671  
592 672 // Calculate mean coordinates
593   - double ra = xref / double (n_pnt);
594   - double dec = yref / double (n_pnt);
  673 + double ra = xref / double(n_pnt);
  674 + double dec = yref / double(n_pnt);
595 675  
596 676 // Initialise sky dir
597 677 GSkyDir dir = GSkyDir();
... ... @@ -601,23 +681,30 @@ GSkyDir ctool::get_pointing(const GObservations&amp; obs)
601 681 return dir;
602 682 }
603 683  
  684 +
604 685 /***********************************************************************//**
605   - * @brief Build a GCTAEventCube based on user parameters
  686 + * @brief Build CTA event cube based on user parameters
606 687 *
607   - * Creates an empty CTA event cube from input user parameters. It appends a dummy
608   - * GTi to the event cube.
  688 + * Creates an empty CTA event cube from input user parameters. It appends a
  689 + * dummy GTI to the event cube.
609 690 *
  691 + * The following parameters are read:
  692 + * xref - Reference in Right Ascension or longitude (deg)
  693 + * yref - Reference in Declination or latitude (deg)
  694 + * proj - Coordinate projection
  695 + * coordsys - Coordinate system
  696 + * binsz - Bin size (deg)
  697 + * nxpix - Number of pixels in Right Ascension or longitude
  698 + * nypix - Number of pixels in Declination or latitude
  699 + * ebinalg - Energy binning algorithm
  700 + * emin - Minimum energy (if ebinalg != FILE)
  701 + * emax - Maximum energy (if ebinalg != FILE)
  702 + * enumbins - Number of energy bins (if ebinalg != FILE)
610 703 ***************************************************************************/
611 704 GCTAEventCube ctool::get_cube(void)
612 705 {
613   - // Get cube parameters
614   - double xref = (*this)["xref"].real();
615   - double yref = (*this)["yref"].real();
616   - std::string proj = (*this)["proj"].string();
617   - std::string coordsys = (*this)["coordsys"].string();
618   - double binsz = (*this)["binsz"].real();
619   - int nxpix = (*this)["nxpix"].integer();
620   - int nypix = (*this)["nypix"].integer();
  706 + // Get skymap
  707 + GSkymap map = get_map();
621 708  
622 709 // Set energy boundaries
623 710 GEbounds ebounds = get_ebounds();
... ... @@ -626,145 +713,153 @@ GCTAEventCube ctool::get_cube(void)
626 713 GGti gti;
627 714 gti.append(GTime(0.0), GTime(0.1234));
628 715  
629   - // Initialise sky map
630   - GSkymap map = GSkymap(proj, coordsys, xref, yref, -binsz, binsz, nxpix, nypix, ebounds.size());
  716 + // Extend skymap to the requested number of maps
  717 + map.nmaps(ebounds.size());
631 718  
632 719 // Build event cube from given information
633   - GCTAEventCube cube = GCTAEventCube(map,ebounds,gti);
  720 + GCTAEventCube cube = GCTAEventCube(map, ebounds, gti);
634 721  
635 722 // Return cube
636 723 return cube;
637   -
638 724 }
639 725  
  726 +
640 727 /***********************************************************************//**
641   - * @brief Build a GCTAEventCube based on user parameters
  728 + * @brief Build CTA event cube based on user parameters
642 729 *
643   - * @param[in] obs observation container
  730 + * @param[in] obs Observation container.
644 731 *
645   - * Creates an empty CTA event cube from input user parameters. It appends a dummy
646   - * GTi to the event cube. The input parameter is used to extract the pointing information
647   - * from the given observations. This function is used if a ctool has the input parameter
648   - * usepnt=true.
  732 + * Creates an empty CTA event cube from input user parameters. The reference
  733 + * coordinate is extracted from the mean pointing of the CTA observations
  734 + * in the observation container (see get_mean_pointing()). This method will
  735 + * be used if a ctool has the input parameter usepnt=true. The method
  736 + * appends a dummy GTI to the event cube.
649 737 *
  738 + * The following parameters are read:
  739 + * proj - Coordinate projection
  740 + * coordsys - Coordinate system
  741 + * binsz - Bin size (deg)
  742 + * nxpix - Number of pixels in Right Ascension or longitude
  743 + * nypix - Number of pixels in Declination or latitude
  744 + * ebinalg - Energy binning algorithm
  745 + * emin - Minimum energy (if ebinalg != FILE)
  746 + * emax - Maximum energy (if ebinalg != FILE)
  747 + * enumbins - Number of energy bins (if ebinalg != FILE)
650 748 ***************************************************************************/
651 749 GCTAEventCube ctool::get_cube(const GObservations& obs)
652 750 {
653   - // Read ahead map information
654   - std::string proj = (*this)["proj"].string();
655   - std::string coordsys = (*this)["coordsys"].string();
656   -
657   - // Initialise reference coordinates
658   - double xref = 0.0;
659   - double yref = 0.0;
660   -
661   - // Get pointing from observations
662   - GSkyDir pnt = get_pointing(obs);
663   -
664   - // Use correct coordinate system
665   - if (gammalib::toupper(coordsys) == "GAL") {
666   - xref = pnt.l_deg();
667   - yref = pnt.b_deg();
668   - }
669   - else {
670   - xref = pnt.ra_deg();
671   - yref = pnt.dec_deg();
672   - }
673   -
674   - // Read further binning parameters
675   - double binsz = (*this)["binsz"].real();
676   - int nxpix = (*this)["nxpix"].integer();
677   - int nypix = (*this)["nypix"].integer();
  751 + // Get skymap
  752 + GSkymap map = get_map(obs);
678 753  
679 754 // Set energy boundaries
680   - GEbounds ebounds = get_ebounds();
  755 + GEbounds ebounds = get_ebounds();
681 756  
682 757 // Set dummy GTI that is needed for event cube creation
683 758 GGti gti;
684 759 gti.append(GTime(0.0), GTime(0.1234));
685 760  
686   - // Build skymap from user parameters
687   - GSkymap map = GSkymap(proj, coordsys, xref, yref, -binsz, binsz, nxpix, nypix, ebounds.size());
  761 + // Extend skymap to the requested number of maps
  762 + map.nmaps(ebounds.size());
688 763  
689 764 // Initialise event cube from all parameters
690   - GCTAEventCube cube = GCTAEventCube(map,ebounds,gti);
  765 + GCTAEventCube cube = GCTAEventCube(map, ebounds, gti);
691 766  
692 767 // Return event cube
693 768 return cube;
694   -
695 769 }
696 770  
  771 +
697 772 /***********************************************************************//**
698   - * @brief Build a skymap based on user parameters
699   - *
700   - * Creates an empty skymap from input user parameters.
  773 + * @brief Get current resident set size (physical memory use) in Bytes
701 774 *
  775 + * @return Physical memory use in Bytes.
702 776 ***************************************************************************/
703   -GSkymap ctool::get_map()
  777 +size_t ctool::get_current_rss(void)
704 778 {
705   - // Read map information
706   - double xref = (*this)["xref"].real();
707   - double yref = (*this)["yref"].real();
708   - std::string proj = (*this)["proj"].string();
709   - std::string coordsys = (*this)["coordsys"].string();
710   - double binsz = (*this)["binsz"].real();
711   - int nxpix = (*this)["nxpix"].integer();
712   - int nypix = (*this)["nypix"].integer();
  779 + // Initialize resident set size
  780 + size_t rss = 0;
713 781  
714   - // Initialise sky map
715   - GSkymap map = GSkymap(proj, coordsys, xref, yref, -binsz, binsz, nxpix, nypix, 1);
  782 + // Determine resident set size (architecture dependent)
  783 + // OSX
  784 + #if defined(__APPLE__) && defined(__MACH__)
  785 + #ifdef MACH_TASK_BASIC_INFO
  786 + struct mach_task_basic_info info;
  787 + mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
  788 + if (task_info(mach_task_self( ), MACH_TASK_BASIC_INFO,
  789 + (task_info_t)&info, &infoCount) == KERN_SUCCESS) {
  790 + rss = (size_t)info.resident_size;
  791 + }
  792 + #else
  793 + struct task_basic_info info;
  794 + mach_msg_type_number_t info_count = TASK_BASIC_INFO_COUNT;
  795 + if (task_info(mach_task_self(), TASK_BASIC_INFO,
  796 + (task_info_t)&info, &info_count) == KERN_SUCCESS) {
  797 + rss = (size_t)info.resident_size;
  798 + }
  799 + #endif
  800 + // Linux
  801 + #elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
  802 + FILE* fp = NULL;
  803 + if ((fp = fopen( "/proc/self/statm", "r" )) != NULL) {
  804 + if (fscanf( fp, "%*s%ld", &rss ) == 1) {
  805 + rss *= (size_t)sysconf(_SC_PAGESIZE);
  806 + }
  807 + fclose(fp);
  808 + }
  809 + // AIX, BSD, Solaris, and Unknown OS
  810 + #else
  811 + rss = 0;
  812 + #endif
716 813  
717   - // Return sky map
718   - return map;
  814 + // Return resident set size
  815 + return rss;
719 816 }
720 817  
  818 +
721 819 /***********************************************************************//**
722   - * @brief Build a skymap based on user parameters
  820 + * @brief Get a CTA ebent cube from from file
723 821 *
724   - * Creates an empty skymap from input user parameters.
  822 + * @param[in] filename FITS file of count cube.
  823 + *
  824 + * @exception GException::invalid_value
  825 + * Counts map not of WCS type
725 826 *
  827 + * Gets an event cube from a FITS file. This function is used in many ctools
  828 + * to obtain a skymap definition from an event cube.
  829 + *
  830 + * @todo Is it necessary to restrict this method to WCS coordinates?
726 831 ***************************************************************************/
727   -GSkymap ctool::get_map(const GObservations& obs)
  832 +GCTAEventCube ctool::set_from_cntmap(const std::string filename)
728 833 {
729   - // Read ahead map information
730   - std::string proj = (*this)["proj"].string();
731   - std::string coordsys = (*this)["coordsys"].string();
732   -
733   - // Initialise reference coordinates
734   - double xref = 0.0;
735   - double yref = 0.0;
736   -
737   - // Get pointing from observations
738   - GSkyDir pnt = get_pointing(obs);
739   -
740   - // Use correct coordinate system
741   - if (gammalib::toupper(coordsys) == "GAL") {
742   - xref = pnt.l_deg();
743   - yref = pnt.b_deg();
744   - }
745   - else {
746   - xref = pnt.ra_deg();
747   - yref = pnt.dec_deg();
748   - }
749   -
750   - double binsz = (*this)["binsz"].real();
751   - int nxpix = (*this)["nxpix"].integer();
752   - int nypix = (*this)["nypix"].integer();
  834 + // Allocate CTA observation
  835 + GCTAEventCube cube;
753 836  
754   - // Initialise sky map
755   - GSkymap map = GSkymap(proj, coordsys, xref, yref, -binsz, binsz, nxpix, nypix, 1);
  837 + // Load counts map in CTA observation
  838 + cube.load(filename);
756 839  
757   - // Return sky map
758   - return map;
  840 + // Check for valid WCS coordinate system
  841 + const GWcs* wcs = dynamic_cast<const GWcs*>(cube.map().projection());
  842 + if (wcs == NULL) {
  843 + std::string msg = "Counts map project is not of WCS type.";
  844 + throw GException::invalid_value(G_SET_FROM_CNTMAP, msg);
  845 + }
  846 +
  847 + // Return cube
  848 + return cube;
759 849 }
760 850  
  851 +
761 852 /***********************************************************************//**
762 853 * @brief Set response for all CTA observations in container
763 854 *
764 855 * @param[in,out] obs Observation container
765 856 *
766 857 * Set the response for a CTA observations in the container that so far have
767   - * no response using the "database" and "irf" task parameters.
  858 + * no response using the "caldb" and "irf" task parameters.
  859 + *
  860 + * The following parameters are read:
  861 + * caldb - Calibration database
  862 + * irf - Instrument response function
768 863 ***************************************************************************/
769 864 void ctool::set_response(GObservations& obs)
770 865 {
... ... @@ -796,8 +891,12 @@ void ctool::set_response(GObservations&amp; obs)
796 891 *
797 892 * @param[in,out] obs CTA observation
798 893 *
799   - * Set the response for a CTA observation using the "database" and "irf"
  894 + * Set the response for a CTA observation using the "caldb" and "irf"
800 895 * task parameters.
  896 + *
  897 + * The following parameters are read:
  898 + * caldb - Calibration database
  899 + * irf - Instrument response function
801 900 ***************************************************************************/
802 901 void ctool::set_obs_response(GCTAObservation* obs)
803 902 {
... ... @@ -822,50 +921,3 @@ void ctool::set_obs_response(GCTAObservation* obs)
822 921 // Return
823 922 return;
824 923 }
825   -
826   -
827   -/***********************************************************************//**
828   - * @brief Get current resident set size (physical memory use) in Bytes
829   - *
830   - * @return Physical memory use in Bytes.
831   - ***************************************************************************/
832   -size_t ctool::get_current_rss(void)
833   -{
834   - // Initialize resident set size
835   - size_t rss = 0;
836   -
837   - // Determine resident set size (architecture dependent)
838   - // OSX
839   - #if defined(__APPLE__) && defined(__MACH__)
840   - #ifdef MACH_TASK_BASIC_INFO
841   - struct mach_task_basic_info info;
842   - mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
843   - if (task_info(mach_task_self( ), MACH_TASK_BASIC_INFO,
844   - (task_info_t)&info, &infoCount) == KERN_SUCCESS) {
845   - rss = (size_t)info.resident_size;
846   - }
847   - #else
848   - struct task_basic_info info;
849   - mach_msg_type_number_t info_count = TASK_BASIC_INFO_COUNT;
850   - if (task_info(mach_task_self(), TASK_BASIC_INFO,
851   - (task_info_t)&info, &info_count) == KERN_SUCCESS) {
852   - rss = (size_t)info.resident_size;
853   - }
854   - #endif
855   - // Linux
856   - #elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
857   - FILE* fp = NULL;
858   - if ((fp = fopen( "/proc/self/statm", "r" )) != NULL) {
859   - if (fscanf( fp, "%*s%ld", &rss ) == 1) {
860   - rss *= (size_t)sysconf(_SC_PAGESIZE);
861   - }
862   - fclose(fp);
863   - }
864   - // AIX, BSD, Solaris, and Unknown OS
865   - #else
866   - rss = 0;
867   - #endif
868   -
869   - // Return resident set size
870   - return rss;
871   -}
... ...
src/support/ctool.hpp
1 1 /***************************************************************************
2 2 * ctool - ctool base class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2015 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -62,28 +62,27 @@ public:
62 62  
63 63 protected:
64 64 // Protected methods
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   - GObservations get_observations(const bool& get_response=true);
  65 + void init_members(void);
  66 + void copy_members(const ctool& app);
  67 + void free_members(void);
  68 + const bool& read_ahead(void) const;
71 69 GCTAObservation setup_obs(void);
72   - GSkymap get_map(void);
73   - GCTAEventCube get_cube(void);
74   - GSkymap get_map(const GObservations& obs);
75   - GCTAEventCube get_cube(const GObservations& obs);
76   - GCTAEventCube set_from_cntmap(const std::string filename);
77   - GSkyDir get_pointing(const GObservations& obs);
78   -
79   - void set_response(GObservations& obs);
80   - void set_obs_response(GCTAObservation* obs);
81   - size_t get_current_rss(void);
  70 + GSkymap get_map(void);
  71 + GSkymap get_map(const GObservations& obs);
  72 + GEbounds get_ebounds(void);
  73 + GObservations get_observations(const bool& get_response = true);
  74 + GCTAEventCube get_cube(void);
  75 + GCTAEventCube get_cube(const GObservations& obs);
  76 + GSkyDir get_mean_pointing(const GObservations& obs);
  77 + size_t get_current_rss(void);
  78 + GCTAEventCube set_from_cntmap(const std::string filename);
  79 + void set_response(GObservations& obs);
  80 + void set_obs_response(GCTAObservation* obs);
82 81  
83 82 // Protected members
84   - bool m_read_ahead; //!< Read ahead parameters
85   - bool m_use_xml; //!< Use XML file instead of FITS file for observations
86   - GTimeReference m_cta_ref; //!< CTA time reference
  83 + bool m_read_ahead; //!< Read ahead parameters
  84 + bool m_use_xml; //!< Use XML file instead of FITS file for observations
  85 + GTimeReference m_cta_ref; //!< CTA time reference
87 86 };
88 87  
89 88  
... ...