/** * @file SClipboard.cpp * @author Dan Saunders & Mathieu Labare, on behalf of the SoLid collaboration. * @date 16 Feb 2016 */ #include "SClipboard.h" //============================================================================== //! Constructor just setting default values. SClipboard::SClipboard(SDetector * dtr) : m_cycle(0), m_detector(dtr) { m_rawBuffer = new SRawBuffer(); } //============================================================================== //! Function to empty containers per block process. void SClipboard::clear() { // For triggered data timeblock destructor cascades down to // delete all waveforms and all trigger records. // 8 channel systems using non-trigger don't yet support this. // We can tell which is which by checking the size of // m_timeblocks. If m_timeblocks.size() > 0 then it's the // triggered data. This will be updated for other data streams // in the future. See issue #41. if (m_timeblocks.size() > 0) { for (auto blk: m_timeblocks) delete blk; m_timeblocks.clear(); } else { // If there are no timeblocks waveforms must be deleted from // the m_waveforms vector. for (auto w : m_waveforms) delete w; } m_waveforms.clear(); for (auto p : m_peaks) delete p; m_peaks.clear(); for (auto e : m_events) delete e; m_events.clear(); } //============================================================================== //! Add timeblock and fill m_waveforms and SChannel::addWaveform void SClipboard::addTimeBlock(STimeBlock * tb) { m_timeblocks.push_back(tb); auto wfbs = tb->waveformblocks(); for (auto wfb : *wfbs) { for (auto wf : wfb->waveforms) { m_waveforms.push_back(wf); SChannel * chan = wf->channel(); if (chan != NULL) { chan->addWaveform(wf); } else { std::cout << "[WARNING] SClipboard ignoring NULL channel. " << std::endl; } } } } //============================================================================== //! Getter for a specific algorithm with error checking. ISAlgorithm * SClipboard::algo(std::string algoName) { if (m_algos.count(algoName) == 0) { SRunStatus(SStatusType::InstantFinishError, "SClipboard::algo", "Algo named " + algoName + " not found in clipboard map of algos. Killing."); return NULL; } else { return m_algos[algoName]; } } //============================================================================== //! Sort waveforms by time in different collections void SClipboard::sortWaveforms() { // Sort in m_waveforms timeSortReconObjects(&m_waveforms); // Sort in each time block for (auto tb : m_timeblocks) { auto wfbs = tb->waveformblocks(); for (auto wfb : *wfbs) { auto wfs = wfb->waveforms; timeSortReconObjects(&wfs); } } // Sort in channels auto chans = m_detector->channels(); for (auto chan : *chans) { timeSortReconObjects(chan->waveforms()); } } //============================================================================== //! Print out current set of conditions. void SClipboard::printConditions() { std::cout<<"---------- Conditions Summary ----------"<print(); } std::cout<<"----------"<