Commit cadd30e9 authored by Purves, Murray's avatar Purves, Murray
Browse files

Improving calibration calculation for SPE read

parent 91344611
Pipeline #16116 passed with stages
in 8 minutes and 41 seconds
......@@ -164,8 +164,7 @@ bool SpectrumSPEStream<data_type>::read_from(const std::string &file)
// Read the energy fit
std::getline(stream, line);
parts.clear();
parts = split_string(" ", trim_string(line), true);
// TODO: Work out what these calibrations refer to
parts = split_string(" ", trim_string(line), true);
float energyFit1 = 0.f, energyFit2 = 0.f, energyFit3 = 0.f;
if (parts.size() > 0)
{
......@@ -179,6 +178,10 @@ bool SpectrumSPEStream<data_type>::read_from(const std::string &file)
{
energyFit3 = stof(parts[2]);
}
// Calculate calibration terms from this
float energyCalGain = energyFit2 / float(totalEntries);
float energyCalOffset =
energyFit1 - ((0.5 / float(totalEntries)) * energyCalGain);
// Next line should be "$MCA_CAL:" followed by MCA calibration
std::getline(stream, line);
......@@ -217,7 +220,7 @@ bool SpectrumSPEStream<data_type>::read_from(const std::string &file)
// Populate SpectrumData object
radix_line(" Adding spectrum...");
mData->addSpectrumData(id, "", "", dateTime, "", liveTime, totalTime, 0.f,
energyFit1, energyFit2, energyFit3, 0.f, 0.f, 0.f,
energyCalOffset, energyCalGain, 0.f, 0.f, 0.f, 0.f,
totalEntries, countsByChannel);
result = true;
......
Supports Markdown
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