/** * @file SEventFinder.cpp * @author Dan Saunders, on behalf of the SoLid collaboration. * @date Halloween 2016 */ #include "SEventFinder.h" #include //============================================================================== //! Constructor setting up default values. SEventFinder::SEventFinder(SDetector * dtr, SClipboard * cb) : ISAlgorithm(dtr, cb, "SEventFinder"), m_htimeWindow(80), m_nEventsFound(0) { m_options.push_back(new SOptionDouble("htimeWindow", &m_htimeWindow)); } //============================================================================== void SEventFinder::initialize() { std::cout<<"[Note]: htimeWindow set to "<nChannels(), 0, dtr()->nChannels()); } //============================================================================== //! Finding events from peak objects. /*! Loops over peaks to find first non-associated peak. As this always results * in a new event instance, create the event. Then add other peaks that are in * time co-incidence (defined by the htimeWindow()). */ void SEventFinder::execute() { for (auto seedPeak : (*cb()->peaks())) { if (!seedPeak->eventAssociated()) { auto event = new SEvent(seedPeak); cb()->events()->push_back(event); m_nEventsFound++; // Find other peaks to form the event. This could be sped up abit, but // simplicity wins for the moment. double seedTime = seedPeak->htime(); for (auto p : (*cb()->peaks())) { if (p->eventAssociated()) continue; double delt = seedTime - p->htime(); if (fabs(delt) < m_htimeWindow) event->addPeak(p); } // Some monitoring. h_htimeInCycle->Fill(event->htime()); for (auto c : (*event->channels())) h_chans->Fill(c->safChanIndex()); h_size->Fill(event->size()); } } // Time sorting. timeSortReconObjects(cb()->events()); } //============================================================================== void SEventFinder::finalize() { std::cout<<"[Note]: Number of events found: "<Write(); h_chans->Write(); h_htimeInCycle->Write(); } //==============================================================================