diff --git a/ChangeLog b/ChangeLog index f9cbd74..998cc00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,10 +3,11 @@ * Version 1.1.0 released ========================= - Implement event fetching and disposal in GCTAEventList (#1648) + Remove event fetching from GCTAObservation class (#1648) + Implement event fetching and disposal in GCTAEventList class (#1648) Add GFilename::fullname() method Add GCTAEventList::remove() method - Handle also additional columns in GCTAEventList::append method + Handle also additional columns in GCTAEventList::append() method Correct GFitsTableCol::insert() method for empty columns Correct GCTAEdisp2D::compute_ebounds_xxx() methods (#1662) Use GFilename in GFits to store filename (#1649) diff --git a/NEWS b/NEWS index d156b2d..939a679 100644 --- a/NEWS +++ b/NEWS @@ -13,9 +13,12 @@ made since the last release of GammaLib. 2. Public interface modifications --------------------------------- -The following methods return now GFilename instead of std::string: -- GFits::filename() +The following methods have been removed from the public interface: +- GCTAObservation::dispose_events() +The return value has been changed for the following methods: +- GFits::filename() returns now GFilename instead of std::string +- GCTAObservation::eventtype() returns now std::string instead of const std::string& 3. Configuration ----------------- @@ -112,7 +115,8 @@ None ----------------- Event fetching and disposal has been implemented in the GCTAEventList class by additing the fetch() and dispose() methods. Now, events are only loaded upon -request and can be dispatched after user to save memory (#1648). +request and can be dispatched after user to save memory. The event fetching and +disposal logic has been removed from GCTAObservation (#1648). Add GCTAEventList::remove() method to remove events from an event list. diff --git a/inst/cta/include/GCTAObservation.hpp b/inst/cta/include/GCTAObservation.hpp index b776a2b..fe27830 100644 --- a/inst/cta/include/GCTAObservation.hpp +++ b/inst/cta/include/GCTAObservation.hpp @@ -87,10 +87,6 @@ public: virtual void write(GXmlElement& xml) const; virtual std::string print(const GChatter& chatter = NORMAL) const; - // Overwrite virtual base class methods - virtual const GEvents* events(void) const; - virtual void events(const GEvents& events); - // Other methods bool has_response(void) const; bool has_events(void) const; @@ -128,8 +124,7 @@ public: void deadc(const double& deadc); void eventfile(const std::string& filename); const std::string& eventfile(void) const; - const std::string& eventtype(void) const; - void dispose_events(void); + std::string eventtype(void) const; const double& lo_user_thres(void) const; const double& hi_user_thres(void) const; void n_tels(const int& tels); @@ -142,12 +137,10 @@ protected: void free_members(void); void read_attributes(const GFitsHDU& hdu); void write_attributes(GFitsHDU& hdu) const; - void set_event_type(void); // Protected members std::string m_instrument; //!< Instrument name std::string m_eventfile; //!< Event filename - std::string m_eventtype; //!< Event type (for XML file) GCTAResponse* m_response; //!< Pointer to instrument response functions GCTAPointing m_pointing; //!< Pointing direction int m_obs_id; //!< Observation ID @@ -449,18 +442,6 @@ const std::string& GCTAObservation::eventfile(void) const /***********************************************************************//** - * @brief Return type of events - * - * @return Type of events. - ***************************************************************************/ -inline -const std::string& GCTAObservation::eventtype(void) const -{ - return m_eventtype; -} - - -/***********************************************************************//** * @brief Return user low energy threshold * * @return User low energy threshold. diff --git a/inst/cta/pyext/GCTAObservation.i b/inst/cta/pyext/GCTAObservation.i index 5840f7a..c3487a1 100644 --- a/inst/cta/pyext/GCTAObservation.i +++ b/inst/cta/pyext/GCTAObservation.i @@ -59,10 +59,6 @@ public: virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; - // Overwrite virtual base class methods - virtual const GEvents* events(void) const; - virtual void events(const GEvents& events); - // Other methods bool has_response(void) const; bool has_events(void) const; @@ -100,8 +96,7 @@ public: void deadc(const double& deadc); void eventfile(const std::string& filename); const std::string& eventfile(void) const; - const std::string& eventtype(void) const; - void dispose_events(void); + std::string eventtype(void) const; const double& lo_user_thres(void) const; const double& hi_user_thres(void) const; void n_tels(const int& tels); diff --git a/inst/cta/src/GCTAObservation.cpp b/inst/cta/src/GCTAObservation.cpp index d435d15..89d63fd 100644 --- a/inst/cta/src/GCTAObservation.cpp +++ b/inst/cta/src/GCTAObservation.cpp @@ -35,7 +35,6 @@ #include "GGti.hpp" #include "GTools.hpp" #include "GIntegral.hpp" -#include "GCTAException.hpp" #include "GCTASupport.hpp" #include "GCTAObservation.hpp" #include "GCTAResponseIrf.hpp" @@ -64,7 +63,6 @@ const GObservationRegistry g_obs_veritas_registry(&g_obs_veritas_seed); #define G_WRITE "GCTAObservation::write(GXmlElement&)" #define G_LOAD "GCTAObservation::load(std::string&, std::string&, "\ "std::string&, std::string&)" -#define G_EVENTS "GCTAObservation::events()" /* __ Macros _____________________________________________________________ */ @@ -82,7 +80,7 @@ const GObservationRegistry g_obs_veritas_registry(&g_obs_veritas_seed); /***********************************************************************//** * @brief Void constructor * - * Creates an empty CTA observation. + * Constructs an empty CTA observation. ***************************************************************************/ GCTAObservation::GCTAObservation(void) : GObservation() { @@ -99,7 +97,7 @@ GCTAObservation::GCTAObservation(void) : GObservation() * * @param[in] instrument Instrument name. * - * Creates an empty CTA observation for a given instrument. This enables + * Constructs an empty CTA observation for a given instrument. This enables * using the CTA specific interface for any other VHE instrument. Note that * each other VHE instruments needs a specific registry at the beginning * of the GCTAObservation.cpp file. So far the following instruments are @@ -126,8 +124,8 @@ GCTAObservation::GCTAObservation(const std::string& instrument) : GObservation() * @param[in] psfcube Psf cube file name. * @param[in] bkgcube Backgorund cube file name. * - * Creates a CTA observation from a counts cube, an exposure cube and a Psf - * cube. + * Constructs a CTA observation from a counts cube, an exposure cube, a Psf + * cube and a background cube. ***************************************************************************/ GCTAObservation::GCTAObservation(const std::string& cntcube, const std::string& expcube, @@ -150,7 +148,7 @@ GCTAObservation::GCTAObservation(const std::string& cntcube, * * @param[in] obs CTA observation. * - * Creates a CTA observation by copying an existing CTA observation. + * Constructs a CTA observation by copying an existing CTA observation. ***************************************************************************/ GCTAObservation::GCTAObservation(const GCTAObservation& obs) : GObservation(obs) { @@ -167,6 +165,8 @@ GCTAObservation::GCTAObservation(const GCTAObservation& obs) : GObservation(obs) /***********************************************************************//** * @brief Destructor + * + * Destructs CTA observation. ***************************************************************************/ GCTAObservation::~GCTAObservation(void) { @@ -223,6 +223,8 @@ GCTAObservation& GCTAObservation::operator=(const GCTAObservation& obs) /***********************************************************************//** * @brief Clear CTA observation + * + * Clear CTA observation. ***************************************************************************/ void GCTAObservation::clear(void) { @@ -243,6 +245,8 @@ void GCTAObservation::clear(void) * @brief Clone CTA observation * * @return Pointer to deep copy of CTA observation. + * + * Returns a pointer to a deep copy of a CTA observation. ***************************************************************************/ GCTAObservation* GCTAObservation::clone(void) const { @@ -255,28 +259,30 @@ GCTAObservation* GCTAObservation::clone(void) const * * @param[in] rsp Response function. * - * @exception GException::invalid_value - * Specified response in not of type GCTAResponse. + * @exception GException::invalid_argument + * Invalid response class specified. * - * Sets the response function for the observation. The argument has to be of - * type GCTAResponse, otherwise an exception is thrown. + * Sets the response function for the observation. ***************************************************************************/ void GCTAObservation::response(const GResponse& rsp) { + // Cast response dynamically + const GCTAResponse* ptr = dynamic_cast(&rsp); + + // Throw exception if response is not of correct type + if (ptr == NULL) { + std::string cls = std::string(typeid(&rsp).name()); + std::string msg = "Invalid response type \""+cls+"\" provided on " + "input. Please specify a \"GCTAResponse\" " + "object as argument."; + throw GException::invalid_argument(G_RESPONSE_SET, msg); + } + // Free response if (m_response != NULL) delete m_response; - m_response = NULL; - - // Get pointer on CTA response - const GCTAResponse* cta = dynamic_cast(&rsp); - if (cta == NULL) { - std::string msg = "Specified response function is not a CTA " - "response function.\n" + rsp.print(); - throw GException::invalid_value(G_RESPONSE_SET, msg); - } // Clone response function - m_response = cta->clone(); + m_response = ptr->clone(); // Return return; @@ -291,15 +297,16 @@ void GCTAObservation::response(const GResponse& rsp) * @exception GException::invalid_value * No valid response found in CTA observation. * - * Returns a pointer to the CTA response function. The pointer returned is - * never NULL. + * Returns a pointer to the CTA response function. An exception is thrown if + * the pointer is not valid, hence the user does not need to verify the + * validity of the pointer. ***************************************************************************/ const GCTAResponse* GCTAObservation::response(void) const { // Throw an exception if the response pointer is not valid if (m_response == NULL) { - std::string msg = "No valid response function found in CTA" - " observation.\n"; + std::string msg = "No valid response function found in CTA " + "observation.\n"; throw GException::invalid_value(G_RESPONSE_GET, msg); } @@ -380,287 +387,84 @@ void GCTAObservation::response(const GCTACubeExposure& expcube, /***********************************************************************//** * @brief Get Region of Interest * + * @return Region of Interest. + * * @exception GException::invalid_value - * Events is not an event list or unable to open an event file. + * Observation does not contain events. + * Observation does not contain an event list. * - * Extract the Region of Interest from the event list. If events are loaded - * into the observation, the RoI is simply copied over. If no events are - * present, the method attemps to read the RoI from the header keywords of - * the event file. This obviously only works if a valid event file name is - * available. + * Extracts the Region of Interest from the event list. An exception is + * thrown if the observation does not contain an event list. ***************************************************************************/ GCTARoi GCTAObservation::roi(void) const { - // Initialise ROI - GCTARoi roi; - - // If CTA has events then simply retrieve the ROI from the event list - if (m_events != NULL) { - - // Extract region of interest from CTA observation - const GCTAEventList* list = dynamic_cast(m_events); - if (list == NULL) { - std::string msg = "The observation does not contain an event " - "list. An event list is needed to retrieve " - "the Region of Interest."; - throw GException::invalid_value(G_ROI, msg); - } - roi = list->roi(); - + // Throw an exception if no events exist + if (m_events == NULL) { + std::string msg = "Region of Interest is not defined since the " + "observation does not contain events."; + throw GException::invalid_value(G_ROI, msg); } - // ... otherwise try reading the ROI from the event file header - else { - - // Try opening event file - GFits fits; - try { - fits.open(m_eventfile); - } - catch (std::exception &e) { - std::string msg; - if (m_eventfile.length() == 0) { - msg = "The observation does not contain any information about " - "the event file, hence the Region of Interest cannot be " - "determined."; - } - else { - msg = "Could no open the event file \""+m_eventfile+"\". " - "Please check that the file name is valid."; - } - throw GException::invalid_value(G_ROI, msg); - } - - GFilename fname(m_eventfile); - - // Get event list HDU - const GFitsTable& hdu = *fits.table(fname.extname("EVENTS")); - - // Read ROI from data selection keywords - roi = gammalib::read_ds_roi(hdu); - - // Close FITS file - fits.close(); - + // Get pointer to event list. Throw an exception if no event list is found + const GCTAEventList* list = dynamic_cast(m_events); + if (list == NULL) { + std::string msg = "Region of Interest is not defined since the " + "observation does not contain an event list."; + throw GException::invalid_value(G_ROI, msg); } // Return ROI - return roi; + return (list->roi()); } /***********************************************************************//** * @brief Get Good Time Intervals * - * @return Good Time Interval + * @return Good Time Intervals. * * @exception GException::invalid_value - * Unable to open the event file or to extract GTI information - * from file. - * - * Extract the Good Time Intervals from the events. If events are loaded into - * the observation, the GTIs are simply copied over. If no events are present - * the method attemps to read the GTIs first from a GTI file, and if no GTI - * file is given, by building a GTI from the event TSTART and TSTOP values. - * The latter obviously only works if a valid event file name is available. + * Observation does not contain events. + * + * Extracts the Good Time Intervals from the events. An exception is thrown + * if the observation does not contain events. ***************************************************************************/ GGti GCTAObservation::gti(void) const { - // Initialise GTIs - GGti gti; - - // If CTA has events then simply retrieve the GTIs from the events - if (m_events != NULL) { - - // Copy over GTIs - gti = m_events->gti(); - - } - - // ... otherwise try reading the GTIs from file - else { - - // Extract the GTIs on basis on the DSS keywords, and if these - // keywords are not present, we build the GTIs from the start and - // stop time that is provided in the event header - if (!m_eventfile.empty()) { - - // Initialise filename - GFilename fname(m_eventfile); - - // Open FITS file - GFits fits(fname.filename()); - - // Get extension name - std::string extname = fname.extname("EVENTS"); - - // If the FITS file contains the specified extension then - // first search for DSS keywords, and if they were not found, - // use TSTART and TSTOP to build the GTI - if (fits.contains(extname)) { - - // Get event list HDU - const GFitsTable& events = *fits.table(extname); - - // Read GTI extension name from data sub-space keyword - std::string gti_extname = gammalib::read_ds_gti_extname(events); - - // If no GTI extension name was found then - if (gti_extname.empty()) { - gti_extname = "GTI"; - } - - // If GTI extension is present in FITS file then read Good - // Time Intervals from that extension - if (fits.contains(gti_extname)) { - const GFitsTable& hdu = *fits.table(gti_extname); - gti.read(hdu); - } - - // ... otherwise build GTI from TSTART and TSTOP - else { - - // Read start and stop time - double tstart = events.real("TSTART"); - double tstop = events.real("TSTOP"); - - // Create time reference from header information - GTimeReference timeref(events); - - // Set GTI time reference - gti.reference(timeref); - - // Set start and stop time - GTime start(tstart, gti.reference()); - GTime stop(tstop, gti.reference()); - - // Append start and stop time as single time interval to GTI - gti.append(start, stop); - - } // endelse: GTI built from TSTART and TSTOP - - // Close FITS file - fits.close(); - - } // endif: FITS files contained event extension - - // ... otherwise throw an exception - else { - std::string msg = "No event extension \""+extname+"\" found " - "in file \""+fname.filename()+"\". Please " - "specify a file name with a valid event " - "extension name."; - throw GException::invalid_value(G_GTI, msg); - } - - } // endif: event file name was not empty - - // ... else throw an exception - else { - std::string msg = "The observation does not contain any " - "information about the event file or the GTI " - "file, hence the Good Time Intervals cannot " - "be determined."; - throw GException::invalid_value(G_GTI, msg); - } // endelse: filenames were empty - - } // endelse: GTI had to be loaded - - // Check for GTI validity - if (gti.size() == 0) { - std::string msg = "Could not find Good Time Interval information " - "in the event file \""+m_eventfile+"\". Please " - "check that Good Time Interval information is " - "properly set in the event file."; + // Throw an exception if no events exist + if (m_events == NULL) { + std::string msg = "Good Time Intervals are not defined since the " + "observation does not contain events."; throw GException::invalid_value(G_GTI, msg); } - // Return GTIs - return gti; + // Return GTI + return (m_events->gti()); } /***********************************************************************//** * @brief Get energy boundaries * + * @return Energy boundaries. + * * @exception GException::invalid_value - * Unable to open the event file or to extract energy boundaries - * from file. - * - * Extract the energy boundaries from the events. If events are loaded into - * the observation, the energy boundaries are simply copied over. If no - * events are present the method attemps to read the energy boundaries from - * the event file. This obviously only works if a valid event file name is - * available. + * Observation does not contain events. + * + * Extract the energy boundaries from the events. An exception is thrown if + * the observation does not contain events. ***************************************************************************/ GEbounds GCTAObservation::ebounds(void) const { - // Initialise energy boundaries - GEbounds ebounds; - - // If CTA has events then simply retrieve the energy boundaries from the - // events - if (m_events != NULL) { - - // Copy over energy boundaries - ebounds = m_events->ebounds(); - - } - - // ... otherwise try reading the energy boundaries from the event file - else { - - // Try opening event file - GFits fits; - try { - fits.open(m_eventfile); - } - catch (std::exception &e) { - std::string msg; - if (m_eventfile.length() == 0) { - msg = "The observation does not contain any information about " - "the event file, hence the energy boundaries cannot be " - "determined."; - } - else { - msg = "Could not open the event file \""+m_eventfile+"\". " - "Please check that the file name is valid."; - } - throw GException::invalid_value(G_EBOUNDS, msg); - } - - GFilename fname(m_eventfile); - - // If file contains an EBOUNDS extension then load the energy - // boundaries from that extension - if (fits.contains("EBOUNDS")) { - const GFitsTable& hdu = *fits.table("EBOUNDS"); - ebounds.read(hdu); - } - - // ... otherwise, if file contains an EVENTS extension then load the - // energy boundaries from the data selection keywords - else if (fits.contains(fname.extname("EVENTS"))) { - const GFitsTable& hdu = *fits.table(fname.extname("EVENTS")); - ebounds = gammalib::read_ds_ebounds(hdu); - } - - // ... else throw an exception - else { - std::string msg = "Could no find energy boundary information in " - "the event file \""+m_eventfile+"\". Please " - "check that energy boundary information is " - "properly set in the event file."; - throw GException::invalid_value(G_EBOUNDS, msg); - } - - // Close FITS file - fits.close(); - + // Throw an exception if no events exist + if (m_events == NULL) { + std::string msg = "Energy boundaries are not defined since the " + "observation does not contain events."; + throw GException::invalid_value(G_EBOUNDS, msg); } // Return energy boundaries - return ebounds; + return (m_events->ebounds()); } @@ -726,6 +530,7 @@ GEbounds GCTAObservation::ebounds(void) const * ... * * + * * * * Optional user energy thresholds can be specified by adding the @a emin @@ -775,19 +580,22 @@ void GCTAObservation::read(const GXmlElement& xml) (par->attribute("name") == "CountsCube")) { // Store event type - m_eventtype = par->attribute("name"); + //m_eventtype = par->attribute("name"); // Read eventlist file name std::string filename = par->attribute("file"); + // Load events + load(filename); + // Initialise filename - GFilename fname(filename); + //GFilename fname(filename); // Open FITS file - GFits fits(fname.filename()); + //GFits fits(fname.filename()); // Get extension name - std::string extname = fname.extname("EVENTS"); + //std::string extname = fname.extname("EVENTS"); // Read observation attributes. Note that we do not load the // events and GTI here as this will be done on-the-fly when @@ -796,6 +604,7 @@ void GCTAObservation::read(const GXmlElement& xml) // GCTAObservation to access th GTIs without accessing the // events. It would be better if the GCTAEventList class handles // the loading of the events on request. + /* if (fits.contains(extname)) { const GFitsHDU& hdu = *fits.at(extname); read_attributes(hdu); @@ -804,12 +613,13 @@ void GCTAObservation::read(const GXmlElement& xml) const GFitsHDU& hdu = *fits.at(0); read_attributes(hdu); } + */ // Close FITS file - fits.close(); + //fits.close(); // Store event filename - m_eventfile = filename; + //m_eventfile = filename; // Increment parameter counter n_evfile++; @@ -1024,6 +834,7 @@ void GCTAObservation::read(const GXmlElement& xml) * ... * * + * * * * If user energy thresholds are defined (i.e. threshold values are >0) the @@ -1035,18 +846,17 @@ void GCTAObservation::read(const GXmlElement& xml) ***************************************************************************/ void GCTAObservation::write(GXmlElement& xml) const { - // Throw an exception if m_eventtype is neither "EventList" nor - // "CountsCube" - if ((m_eventtype != "EventList") && - (m_eventtype != "CountsCube")) { + // Throw an exception if eventtype() is neither "EventList" nor + std::string evttype = eventtype(); + if ((evttype != "EventList") && (evttype != "CountsCube")) { std::string msg; - if (m_eventtype.length() == 0) { + if (evttype.empty()) { msg = "The observation does not contain any events, hence " "it cannot be written into an XML file."; } else { msg = "The observation contains an unknown event type \""+ - m_eventtype+"\". The event type needs to be either " + evttype+"\". The event type needs to be either " "\"EventList\" or \"CountsCube\"."; } throw GException::invalid_value(G_WRITE, msg); @@ -1065,7 +875,7 @@ void GCTAObservation::write(GXmlElement& xml) const if (!m_eventfile.empty()) { // Write event file name - GXmlElement* par = gammalib::xml_need_par(G_WRITE, xml, m_eventtype); + GXmlElement* par = gammalib::xml_need_par(G_WRITE, xml, evttype); par->attribute("file", m_eventfile); } @@ -1104,6 +914,15 @@ void GCTAObservation::write(GXmlElement& xml) const * @brief Read data from FITS file * * @param[in] fits FITS file. + * + * Reads event data from a FITS file and sets the observation attributes. + * + * The method automatically switches between an event list and a counts cube, + * depending of the information provided in the FITS file. If an extension + * name is specified, the method checks whether the extension exists and + * loads the extension as event list. Otherwise, it checks whether the file + * contains an "EVENTS" extension and loads the extension as event list. + * If none of the above are satistified, the method loads a counts cube. ***************************************************************************/ void GCTAObservation::read(const GFits& fits) { @@ -1155,9 +974,6 @@ void GCTAObservation::read(const GFits& fits) } - // Set the event type - set_event_type(); - // Return return; } @@ -1352,97 +1168,46 @@ void GCTAObservation::save(const std::string& filename, const bool& clobber) con /***********************************************************************//** - * @brief Set event container + * @brief Return event type string * - * @param[in] events Event container. + * @return Event type string. * - * Set the event container for this observation by cloning the @p events. + * Returns "EventList" if the observation contains an event list, + * "CountsCube" if it contains a counts cube, "Events" if it container an + * unknown type of events (which should never occur), and an empty string if + * no events have been allocated. ***************************************************************************/ -void GCTAObservation::events(const GEvents& events) +std::string GCTAObservation::eventtype(void) const { - // Remove an existing event container - if (m_events != NULL) delete m_events; - - // Clone events - m_events = events.clone(); - - // Set event type - set_event_type(); - - // Return - return; -} - + // Initialise empty event type string + std::string eventtype = ""; -/***********************************************************************//** - * @brief Return pointer to event container - * - * @return Pointer to event container (always valid). - * - * @exception GException::invalid_value - * Events could not be fetched from disk. - * - * Returns a pointer to the event container. If no events exist the method - * tries to fetch events from the file specified by the m_eventfile member. - * If this fails, an exception will be thrown. - ***************************************************************************/ -const GEvents* GCTAObservation::events(void) const -{ - // If event container is offline then bring it online now - if (m_events == NULL) { + // Continue only if events are allocated + if (m_events != NULL) { - // Try loading the events from FITS file. Catch any exception. Put - // the code into a critical zone as it might be called from within - // a parallelized thread. - #pragma omp critical - { - try { - const_cast(this)->load(m_eventfile); - } - catch (...) { - ; - } + // Case A: we have a list + GCTAEventList* list = dynamic_cast(m_events); + if (list != NULL) { + eventtype = "EventList"; } - // Throw an exception if the event container is still not valid - if (m_events == NULL) { - std::string msg; - if (m_eventfile.length() == 0) { - msg = "The observation does not contain any information about " - "the event file, hence the events cannot be fetched " - "from disk for access."; + // Case B: we have a cube + else { + GCTAEventCube* cube = dynamic_cast(m_events); + if (cube != NULL) { + eventtype = "CountsCube"; } + + // Case C: we don't know what we have else { - msg = "Could no load the event file \""+m_eventfile+"\" into " - "the observation. Please check that the file name is " - "valid and that the file contains events."; + eventtype = "Events"; } - throw GException::invalid_value(G_EVENTS, msg); } - } - - // Return pointer to event container - return m_events; -} - + } // endif: events were allocated -/***********************************************************************//** - * @brief Dispose events - * - * Drops the events from the observation. Be careful with using this method - * as the events are not saved before being disposed. - ***************************************************************************/ -void GCTAObservation::dispose_events(void) -{ - // Delete any existing event container - if (m_events != NULL) delete m_events; - - // Signal that we disposed the events - m_events = NULL; - - // Return - return; + // Return event type + return eventtype; } @@ -1468,7 +1233,7 @@ std::string GCTAObservation::print(const GChatter& chatter) const result.append("\n"+gammalib::parformat("Identifier")+id()); result.append("\n"+gammalib::parformat("Instrument")+instrument()); result.append("\n"+gammalib::parformat("Event file")+eventfile()); - result.append("\n"+gammalib::parformat("Event type")+m_eventtype); + result.append("\n"+gammalib::parformat("Event type")+eventtype()); result.append("\n"+gammalib::parformat("Statistics")+statistics()); result.append("\n"+gammalib::parformat("Ontime")); result.append(gammalib::str(ontime())+" s"); @@ -1544,7 +1309,6 @@ void GCTAObservation::init_members(void) m_instrument = "CTA"; m_object.clear(); m_eventfile.clear(); - m_eventtype.clear(); m_bgdfile.clear(); m_response = NULL; m_pointing.clear(); @@ -1574,7 +1338,6 @@ void GCTAObservation::copy_members(const GCTAObservation& obs) m_instrument = obs.m_instrument; m_object = obs.m_object; m_eventfile = obs.m_eventfile; - m_eventtype = obs.m_eventtype; m_bgdfile = obs.m_bgdfile; m_pointing = obs.m_pointing; m_obs_id = obs.m_obs_id; @@ -1759,46 +1522,3 @@ void GCTAObservation::write_attributes(GFitsHDU& hdu) const // Return return; } - - -/***********************************************************************//** - * @brief Set event type - * - * Depending on the type of events that are stored in the m_events member, - * set the event type to - * - * "EventList" if m_events is of type GCTAEventList - * "CountsCube" if m_events is of type GCTAEventCube - * "Events" if m_events is not NULL but neither GCTAEventList nor GCTAEventCube - * "" if m_events is NULL - * - ***************************************************************************/ -void GCTAObservation::set_event_type(void) -{ - // Continue only if events are loaded - if (m_events != NULL) { - - // Case A: we have a list - GCTAEventList* list = dynamic_cast(m_events); - if (list != NULL) { - m_eventtype = "EventList"; - } - - // Case B: we have a cube - else { - GCTAEventCube* cube = dynamic_cast(m_events); - if (cube != NULL) { - m_eventtype = "CountsCube"; - } - - // Case C: we don't know what we have - else { - m_eventtype = "Events"; - } - } - - } - - // Return - return; -}