/** Reduce the peak list by removing duplicates then convert SXPeaks objects to PeakObjects and add them to the output workspace @param pcv : current peak list containing potential duplicates */ void FindSXPeaks::reducePeakList(const peakvector &pcv) { double resol = getProperty("Resolution"); peakvector finalv; for (const auto ¤tPeak : pcv) { auto pos = std::find_if(finalv.begin(), finalv.end(), [¤tPeak, resol](SXPeak &peak) { bool result = currentPeak.compare(peak, resol); if (result) peak += currentPeak; return result; }); if (pos == finalv.end()) finalv.push_back(currentPeak); } for (auto &finalPeak : finalv) { finalPeak.reduce(); try { Geometry::IPeak *peak = m_peaks->createPeak(finalPeak.getQ()); if (peak) { peak->setIntensity(finalPeak.getIntensity()); peak->setDetectorID(finalPeak.getDetectorId()); m_peaks->addPeak(*peak); delete peak; } } catch (std::exception &e) { g_log.error() << e.what() << '\n'; } } }
/** Reduce the peak list by removing duplicates then convert SXPeaks objects to PeakObjects and add them to the output workspace @param pcv : current peak list containing potential duplicates */ void FindSXPeaks::reducePeakList(const peakvector &pcv) { double resol = getProperty("Resolution"); peakvector finalv; bool found = false; for (std::size_t i = 0; i < pcv.size(); i++) { for (std::size_t j = 0; j < finalv.size(); j++) { if (pcv[i].compare(finalv[j], resol)) { finalv[j] += pcv[i]; found = true; break; } } if (!found) finalv.push_back(pcv[i]); found = false; } for (std::size_t i = 0; i < finalv.size(); i++) { finalv[i].reduce(); try { Geometry::IPeak *peak = m_peaks->createPeak(finalv[i].getQ()); if (peak) { peak->setIntensity(finalv[i].getIntensity()); peak->setDetectorID(finalv[i].getDetectorId()); m_peaks->addPeak(*peak); delete peak; } } catch (std::exception &e) { g_log.error() << e.what() << std::endl; } } }
/** Reduce the peak list by removing duplicates then convert SXPeaks objects to PeakObjects and add them to the output workspace @param pcv : current peak list containing potential duplicates @param progress: a progress object */ void FindSXPeaks::reducePeakList(const peakvector &pcv, Progress &progress) { MatrixWorkspace_const_sptr localworkspace = getProperty("InputWorkspace"); auto &goniometerMatrix = localworkspace->run().getGoniometer().getR(); auto compareStrategy = getCompareStrategy(); auto reductionStrategy = getReducePeakListStrategy(compareStrategy.get()); auto finalv = reductionStrategy->reduce(pcv, progress); for (auto &finalPeak : finalv) { finalPeak.reduce(); try { Geometry::IPeak *peak = m_peaks->createPeak(finalPeak.getQ()); if (peak) { peak->setIntensity(finalPeak.getIntensity()); peak->setDetectorID(finalPeak.getDetectorId()); peak->setGoniometerMatrix(goniometerMatrix); m_peaks->addPeak(*peak); delete peak; } } catch (std::exception &e) { g_log.error() << e.what() << '\n'; } } }