Commit a53748b631c51b21f5a0a869d1476e170b28d8cd

Authored by Jürgen Knödlseder
1 parent f59a463b

Add GCTAEventList::remove() method and also handle additional columns in GCTAEve…

…ntList::append() method.
ChangeLog
... ... @@ -3,6 +3,8 @@
3 3 * Version 1.1.0 released
4 4 =========================
5 5  
  6 + Add GCTAEventList::remove method
  7 + Handle also additional columns in GCTAEventList::append method
6 8 Correct GFitsTableCol::insert method for empty columns
7 9 Correct GCTAEdisp2D::compute_ebounds methods (#1662)
8 10 Use GFilename in GFits to store filename (#1649)
... ...
... ... @@ -109,6 +109,16 @@ None
109 109  
110 110 20. CTA interface
111 111 -----------------
  112 +Add GCTAEventList::remove() method to remove events from an event list.
  113 +
  114 +The GCTAEventList::append() method now also appends empty elements to the
  115 +additional columns so that all event list columns have finally the same length.
  116 +
  117 +The GCTAEdisp2D::compute_ebounds_obs() and GCTAEdisp2::compute_ebounds_src()
  118 +methods have been corrected so that they return the energy intervals covered by
  119 +valid matrix elements. With the code before there were problems with not setting
  120 +correctly the maximum energies of the intervals (#1662).
  121 +
112 122 The extension name for the GTI HDU is now determined from the data sub-space
113 123 keyword provided in the events FITS file header. This allows to have multiple
114 124 GTIs (and also event lists) in a single FITS file. We do however require that
... ... @@ -128,11 +138,6 @@ optionally specified extension in the format [EVENTS;GTI] into an events and a
128 138 Good Time Intervals extension name. These changes satisfy the feature request
129 139 #1598.
130 140  
131   -The GCTAEdisp2D::compute_ebounds_obs() and GCTAEdisp2::compute_ebounds_src()
132   -methods have been corrected so that they return the energy intervals covered by
133   -valid matrix elements. With the code before there were problems with not setting
134   -correctly the maximum energies of the intervals (#1662).
135   -
136 141  
137 142 21. COMPTEL interface
138 143 ---------------------
... ...
inst/cta/include/GCTAEventList.hpp
... ... @@ -79,6 +79,7 @@ public:
79 79 // Implement other methods
80 80 void append(const GCTAEventAtom& event);
81 81 void reserve(const int& number);
  82 + void remove(const int& index, const int& number = 1);
82 83 void write(GFits& fits, const std::string& evtname,
83 84 const std::string& gtiname) const;
84 85 double irf_cache(const std::string& name, const int& index) const;
... ...
inst/cta/pyext/GCTAEventList.i
... ... @@ -60,6 +60,7 @@ public:
60 60 // Implement other methods
61 61 void append(const GCTAEventAtom& event);
62 62 void reserve(const int& number);
  63 + void remove(const int& index, const int& number = 1);
63 64 void write(GFits& fits, const std::string& evtname,
64 65 const std::string& gtiname) const;
65 66 double irf_cache(const std::string& name, const int& index) const;
... ...
inst/cta/src/GCTAEventList.cpp
... ... @@ -603,6 +603,11 @@ void GCTAEventList::append(const GCTAEventAtom& event)
603 603 // Append event
604 604 m_events.push_back(event);
605 605  
  606 + // Append an element to all additional columns
  607 + for (int i = 0; i < m_columns.size(); ++i) {
  608 + m_columns[i]->insert(m_columns[i]->length(),1);
  609 + }
  610 +
606 611 // Set event index
607 612 int index = m_events.size()-1;
608 613 m_events[index].m_index = index;
... ... @@ -612,6 +617,41 @@ void GCTAEventList::append(const GCTAEventAtom&amp; event)
612 617 }
613 618  
614 619  
  620 +/***********************************************************************//**
  621 + * @brief Remove event atoms from event list
  622 + *
  623 + * @param[in] index Index from which on events should be removed.
  624 + * @param[in] number Number of event to remove.
  625 + *
  626 + * Removes events from the event list. This method does nothing if @p index
  627 + * points beyond the event list. The method does also gently accepts
  628 + * @p number arguments where @p index + @p number reach beyond the event
  629 + * list.
  630 + ***************************************************************************/
  631 +void GCTAEventList::remove(const int& index, const int& number)
  632 +{
  633 + // Continue only if index is valid
  634 + if (index < size()) {
  635 +
  636 + // Determine number of elements to remove
  637 + int n_remove = (index + number > size()) ? size() - index : number;
  638 +
  639 + // Remove events
  640 + m_events.erase(m_events.begin() + index,
  641 + m_events.begin() + index + n_remove);
  642 +
  643 + // Remove elements from additional columns
  644 + for (int i = 0; i < m_columns.size(); ++i) {
  645 + m_columns[i]->remove(index, n_remove);
  646 + }
  647 +
  648 + } // endif: index was valid
  649 +
  650 + // Return
  651 + return;
  652 +}
  653 +
  654 +
615 655 /*==========================================================================
616 656 = =
617 657 = Private methods =
... ...