Commit 2513f63b authored by Purves, Murray's avatar Purves, Murray
Browse files

Amending nrps() function to use stl library

parent d27a1c68
Pipeline #16221 passed with stages
in 8 minutes and 57 seconds
#include <algorithm>
#include <cmath>
#include "radixio/spectrum.hh"
......@@ -10,14 +11,12 @@ short Spectrum::nrps() const
// Used by PCF file to allocate space in binary file structure
// Go through each SpectrumData object and find the maximum number of channels
int maxChannels = 0;
for (size_t i = 0; i < mSpectrumData.size(); ++i)
{
if (mSpectrumData[i].numberOfChannels > maxChannels)
{
maxChannels = mSpectrumData[i].numberOfChannels;
}
}
auto comparator = [](const SpectrumData &a, const SpectrumData &b) {
return a.numberOfChannels < b.numberOfChannels;
};
int maxChannels = (*std::max_element(mSpectrumData.begin(),
mSpectrumData.end(), comparator))
.numberOfChannels;
short nrps = short(std::ceil((float(maxChannels) / 64.f) + 1.f));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment