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 <cmath>
#include "radixio/spectrum.hh" #include "radixio/spectrum.hh"
...@@ -10,14 +11,12 @@ short Spectrum::nrps() const ...@@ -10,14 +11,12 @@ short Spectrum::nrps() const
// Used by PCF file to allocate space in binary file structure // Used by PCF file to allocate space in binary file structure
// Go through each SpectrumData object and find the maximum number of channels // Go through each SpectrumData object and find the maximum number of channels
int maxChannels = 0; auto comparator = [](const SpectrumData &a, const SpectrumData &b) {
for (size_t i = 0; i < mSpectrumData.size(); ++i) return a.numberOfChannels < b.numberOfChannels;
{ };
if (mSpectrumData[i].numberOfChannels > maxChannels) int maxChannels = (*std::max_element(mSpectrumData.begin(),
{ mSpectrumData.end(), comparator))
maxChannels = mSpectrumData[i].numberOfChannels; .numberOfChannels;
}
}
short nrps = short(std::ceil((float(maxChannels) / 64.f) + 1.f)); 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