diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h index 77406b3a1141bec7407325aff6db061fc15c0134..236d501170c8a382a2b3861a888e788d77a71631 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h @@ -56,11 +56,15 @@ private: const size_t m_stride; double m_tofMin; double m_tofMax; + // correction + const double m_period; + const double m_phase; public: // construction EventCounter(std::vector<size_t> &eventCounts, const std::vector<bool> &mask, - const std::vector<int> &offsets, size_t stride); + const std::vector<int> &offsets, size_t stride, + double periode, double phase); // properties double tofMin() const; @@ -77,12 +81,15 @@ private: const std::vector<bool> &m_mask; const std::vector<int> &m_offsets; const size_t m_stride; + // correction + const double m_period; + const double m_phase; public: // construction - EventAssigner(std::vector<EventVector_pt> &eventVectors, - const std::vector<bool> &mask, const std::vector<int> &offsets, - size_t stride); + EventAssigner(std::vector<EventVector_pt> &eventVectors, const std::vector<bool> &mask, + const std::vector<int> &offsets, size_t stride, + double periode, double phase); // methods void addEvent(size_t x, size_t y, double tof); diff --git a/Code/Mantid/Framework/DataHandling/src/LoadANSTOHelper.cpp b/Code/Mantid/Framework/DataHandling/src/LoadANSTOHelper.cpp index fbfb9d3848f380abb1432eaa3615b98831184ccd..2744d7c5612d30fc4678f9a544556c2959558da4 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadANSTOHelper.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadANSTOHelper.cpp @@ -52,11 +52,13 @@ void ProgressTracker::complete() { // EventCounter EventCounter::EventCounter(std::vector<size_t> &eventCounts, const std::vector<bool> &mask, - const std::vector<int> &offsets, size_t stride) + const std::vector<int> &offsets, size_t stride, + double periode, double phase) : m_eventCounts(eventCounts), m_mask(mask), m_offsets(offsets), m_stride(stride), m_tofMin(std::numeric_limits<double>::max()), - m_tofMax(std::numeric_limits<double>::min()) {} + m_tofMax(std::numeric_limits<double>::min()), + m_period(periode), m_phase(phase) {} double EventCounter::tofMin() const { return m_tofMin <= m_tofMax ? m_tofMin : 0.0; } @@ -64,6 +66,15 @@ double EventCounter::tofMax() const { return m_tofMin <= m_tofMax ? m_tofMax : 0.0; } void EventCounter::addEvent(size_t x, size_t y, double tof) { + // correction + if (m_period > 0.0) { + tof += m_phase; + while (tof > m_period) + tof -= m_period; + while (tof < 0) + tof += m_period; + } + size_t yNew = y + (size_t)m_offsets[x]; if (yNew < m_stride) { size_t s = m_stride * x + yNew; @@ -82,10 +93,21 @@ void EventCounter::addEvent(size_t x, size_t y, double tof) { // EventAssigner EventAssigner::EventAssigner(std::vector<EventVector_pt> &eventVectors, const std::vector<bool> &mask, - const std::vector<int> &offsets, size_t stride) + const std::vector<int> &offsets, size_t stride, + double periode, double phase) : m_eventVectors(eventVectors), m_mask(mask), - m_offsets(offsets), m_stride(stride) {} + m_offsets(offsets), m_stride(stride), + m_period(periode), m_phase(phase) {} void EventAssigner::addEvent(size_t x, size_t y, double tof) { + // correction + if (m_period > 0.0) { + tof += m_phase; + while (tof > m_period) + tof -= m_period; + while (tof < 0) + tof += m_period; + } + size_t yNew = y + (size_t)m_offsets[x]; if (yNew < m_stride) { size_t s = m_stride * x + yNew;