Commit 886dd597025ce2cdec807574fa4b82421521d593

Authored by knodlseder
1 parent 96a8b3c4

Add support for HESS, MAGIC and VERITAS.

This has been done by adding a new member m_instrument that contains the instrument name. Seeds have been added to the observations registry for HESS, MAGIC and VERITAS, and the instrument name is now extracted from the XML file. This allows using the GCTA... classes for other instruments, using the appropriate instrument names.
Showing 1 changed file with 61 additions and 37 deletions
inst/cta/src/GCTAObservation.cpp
... ... @@ -42,8 +42,14 @@
42 42 #include "GIntegrand.hpp"
43 43  
44 44 /* __ Globals ____________________________________________________________ */
45   -const GCTAObservation g_obs_cta_seed;
  45 +const GCTAObservation g_obs_cta_seed("CTA");
  46 +const GCTAObservation g_obs_hess_seed("HESS");
  47 +const GCTAObservation g_obs_magic_seed("MAGIC");
  48 +const GCTAObservation g_obs_veritas_seed("VERITAS");
46 49 const GObservationRegistry g_obs_cta_registry(&g_obs_cta_seed);
  50 +const GObservationRegistry g_obs_hess_registry(&g_obs_hess_seed);
  51 +const GObservationRegistry g_obs_magic_registry(&g_obs_magic_seed);
  52 +const GObservationRegistry g_obs_veritas_registry(&g_obs_veritas_seed);
47 53  
48 54 /* __ Method name definitions ____________________________________________ */
49 55 #define G_RESPONSE "GCTAObservation::response(GResponse&)"
... ... @@ -81,6 +87,29 @@ GCTAObservation::GCTAObservation(void) : GObservation()
81 87  
82 88  
83 89 /***********************************************************************//**
  90 + * @brief Instrument constructor
  91 + *
  92 + * @param[in] instrument Instrument name.
  93 + *
  94 + * Creates empty CTA observation class for a given instrument. This enables
  95 + * using the CTA specific interface for any other THE instrument. Note that
  96 + * each other THE instruments needs a specific registry at the beginning
  97 + * of the GCTAObservation.cpp file.
  98 + ***************************************************************************/
  99 +GCTAObservation::GCTAObservation(const std::string& instrument) : GObservation()
  100 +{
  101 + // Initialise members
  102 + init_members();
  103 +
  104 + // Set instrument
  105 + m_instrument = instrument;
  106 +
  107 + // Return
  108 + return;
  109 +}
  110 +
  111 +
  112 +/***********************************************************************//**
84 113 * @brief Copy constructor
85 114 *
86 115 * @param[in] obs CTA observation.
... ... @@ -279,16 +308,6 @@ void GCTAObservation::pointing(const GCTAPointing& pointing)
279 308  
280 309  
281 310 /***********************************************************************//**
282   - * @brief Returns instrument name
283   - ***************************************************************************/
284   -std::string GCTAObservation::instrument(void) const
285   -{
286   - // Return instument name
287   - return ("CTA");
288   -}
289   -
290   -
291   -/***********************************************************************//**
292 311 * @brief Read observation from XML element
293 312 *
294 313 * @param[in] xml XML element.
... ... @@ -301,7 +320,7 @@ std::string GCTAObservation::instrument(void) const
301 320 * Reads information for a CTA observation from an XML element.
302 321 * The expected format of the XML element is
303 322 *
304   - * <observation name="..." id="..." instrument="CTA">
  323 + * <observation name="..." id="..." instrument="...">
305 324 * <parameter name="EventList" file="..."/>
306 325 * <parameter name="ARF" file="..."/>
307 326 * <parameter name="RMF" file="..."/>
... ... @@ -310,7 +329,7 @@ std::string GCTAObservation::instrument(void) const
310 329 *
311 330 * for an unbinned observation and
312 331 *
313   - * <observation name="..." id="..." instrument="CTA">
  332 + * <observation name="..." id="..." instrument="...">
314 333 * <parameter name="CountsMap" file="..."/>
315 334 * <parameter name="ARF" file="..."/>
316 335 * <parameter name="RMF" file="..."/>
... ... @@ -331,6 +350,9 @@ void GCTAObservation::read(const GXmlElement&amp; xml)
331 350 double thetacut = 0.0;
332 351 double scale = 1.0;
333 352  
  353 + // Extract instrument name
  354 + m_instrument = xml.attribute("instrument");
  355 +
334 356 // Determine number of parameter nodes in XML element
335 357 int npars = xml.elements("parameter");
336 358  
... ... @@ -454,7 +476,7 @@ void GCTAObservation::read(const GXmlElement&amp; xml)
454 476 * Writes information for a CTA observation into an XML element. The expected
455 477 * format of the XML element is
456 478 *
457   - * <observation name="..." id="..." instrument="CTA">
  479 + * <observation name="..." id="..." instrument="...">
458 480 * <parameter name="EventList" file="..."/>
459 481 * <parameter name="ARF" file="..."/>
460 482 * <parameter name="RMF" file="..."/>
... ... @@ -463,7 +485,7 @@ void GCTAObservation::read(const GXmlElement&amp; xml)
463 485 *
464 486 * for an unbinned observation and
465 487 *
466   - * <observation name="..." id="..." instrument="CTA">
  488 + * <observation name="..." id="..." instrument="...">
467 489 * <parameter name="CountsMap" file="..."/>
468 490 * <parameter name="ARF" file="..."/>
469 491 * <parameter name="RMF" file="..."/>
... ... @@ -764,15 +786,16 @@ void GCTAObservation::save(const std::string&amp; filename, bool clobber) const
764 786 void GCTAObservation::init_members(void)
765 787 {
766 788 // Initialise members
  789 + m_instrument = "CTA";
767 790 m_eventfile.clear();
768   - m_response = NULL;
769   - m_pointing = NULL;
770   - m_obs_id = 0;
771   - m_ontime = 0.0;
772   - m_livetime = 0.0;
773   - m_deadc = 0.0;
774   - m_ra_obj = 0.0;
775   - m_dec_obj = 0.0;
  791 + m_response = NULL;
  792 + m_pointing = NULL;
  793 + m_obs_id = 0;
  794 + m_ontime = 0.0;
  795 + m_livetime = 0.0;
  796 + m_deadc = 0.0;
  797 + m_ra_obj = 0.0;
  798 + m_dec_obj = 0.0;
776 799  
777 800 // Return
778 801 return;
... ... @@ -791,13 +814,14 @@ void GCTAObservation::copy_members(const GCTAObservation&amp; obs)
791 814 if (obs.m_pointing != NULL) m_pointing = obs.m_pointing->clone();
792 815  
793 816 // Copy members
794   - m_eventfile = obs.m_eventfile;
795   - m_obs_id = obs.m_obs_id;
796   - m_ontime = obs.m_ontime;
797   - m_livetime = obs.m_livetime;
798   - m_deadc = obs.m_deadc;
799   - m_ra_obj = obs.m_ra_obj;
800   - m_dec_obj = obs.m_dec_obj;
  817 + m_instrument = obs.m_instrument;
  818 + m_eventfile = obs.m_eventfile;
  819 + m_obs_id = obs.m_obs_id;
  820 + m_ontime = obs.m_ontime;
  821 + m_livetime = obs.m_livetime;
  822 + m_deadc = obs.m_deadc;
  823 + m_ra_obj = obs.m_ra_obj;
  824 + m_dec_obj = obs.m_dec_obj;
801 825  
802 826 // Return
803 827 return;
... ... @@ -919,13 +943,13 @@ void GCTAObservation::write_attributes(GFitsHDU* hdu) const
919 943 double deadc = (ontime > 0.0) ? livetime() / ontime : 0.0;
920 944  
921 945 // Set observation information
922   - hdu->card("CREATOR", "GammaLib", "Program which created the file");
923   - hdu->card("TELESCOP", "CTA", "Telescope");
924   - hdu->card("OBS_ID", obs_id(), "Observation identifier");
925   - hdu->card("DATE_OBS", "string", "Observation start date");
926   - hdu->card("TIME_OBS", "string", "Observation start time");
927   - hdu->card("DATE_END", "string", "Observation end date");
928   - hdu->card("TIME_END", "string", "Observation end time");
  946 + hdu->card("CREATOR", "GammaLib", "Program which created the file");
  947 + hdu->card("TELESCOP", instrument(), "Telescope");
  948 + hdu->card("OBS_ID", obs_id(), "Observation identifier");
  949 + hdu->card("DATE_OBS", "string", "Observation start date");
  950 + hdu->card("TIME_OBS", "string", "Observation start time");
  951 + hdu->card("DATE_END", "string", "Observation end date");
  952 + hdu->card("TIME_END", "string", "Observation end time");
929 953  
930 954 // Set observation time information
931 955 hdu->card("TSTART", tstart, "[s] Mission time of start of observation");
... ...