Skip to content

Commit

Permalink
Refs #8385 Refactor code to sum spectra.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Nov 7, 2013
1 parent d37882b commit 258dfb8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Code/Mantid/Framework/DataHandling/src/LoadLLB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,24 @@ int LoadLLB::getDetectorElasticPeakPosition(const NeXus::NXFloat &data) {

std::vector<int> listOfFoundEPP;


std::vector<int> cumulatedSumOfSpectras(m_numberOfChannels, 0);
for (size_t i = 0; i < m_numberOfTubes; i++) {
for (size_t i = 0; i < m_numberOfTubes; i++)
{
float* data_p = &data(static_cast<int>(i), 0);
std::vector<int> thisSpectrum(data_p, data_p + static_cast<int>(m_numberOfChannels));
// sum spectras
std::transform(thisSpectrum.begin(), thisSpectrum.end(),
cumulatedSumOfSpectras.begin(), cumulatedSumOfSpectras.begin(),
std::plus<int>());
float currentSpec = 0;

for (size_t j = 0; j < m_numberOfChannels; ++j)
currentSpec += data_p[j];

if(i > 0)
{
cumulatedSumOfSpectras[i] = cumulatedSumOfSpectras[i-1] + static_cast<int>(currentSpec);
}
else
{
cumulatedSumOfSpectras[i] = static_cast<int>(currentSpec);
}
}
auto it = std::max_element(cumulatedSumOfSpectras.begin(),
cumulatedSumOfSpectras.end());
Expand Down

0 comments on commit 258dfb8

Please sign in to comment.