Commit 8f3aa801 authored by Purves, Murray's avatar Purves, Murray
Browse files

Fixing energy calibration calculations in spectrumspestream

parent 285607d1
Pipeline #16175 passed with stages
in 8 minutes and 51 seconds
......@@ -112,7 +112,7 @@ bool SpectrumSPEStream<data_type>::read_from(const std::string &file)
// End of this spectrum - populate SpectrumData object
radix_line(" Adding spectrum...");
mData->addSpectrumData(id, "", "", dateTime, "", liveTime, totalTime,
0.f, energyCalOffset, energyCalGain, 0.f, 0.f,
energyCalOffset, energyCalGain, 0.f, 0.f, 0.f,
0.f, 0.f, totalEntries, countsByChannel);
result = true;
break;
......@@ -223,9 +223,14 @@ bool SpectrumSPEStream<data_type>::write_to(const std::string &file) const
fprintf(stream, "$ENER_FIT:\n");
// Calculate energy fit vars
float energyFit1 =
energyCalOffset + (0.5 / float(numberOfChannels) * energyCalGain);
energyCalOffset + ((0.5 / float(numberOfChannels)) * energyCalGain);
float energyFit2 = energyCalGain / float(numberOfChannels);
float energyFit3 = 0.f;
radix_line(" Calculated energy fit:\n 1: "
<< energyFit1 << "\n 2: " << energyFit2
<< "\n 3: " << energyFit3);
radix_line(" From initial values:\n gain: "
<< energyCalGain << "\n offset: " << energyCalOffset);
fprintf(stream, " %10.6e %10.6e %10.6e\n", energyFit1, energyFit2,
energyFit3);
......@@ -382,7 +387,7 @@ void SpectrumSPEStream<data_type>::readEnerFit(std::ifstream &stream,
energyFit3 = stof(parts[2]);
}
// Calculate calibration terms from this
energyCalGain = energyFit2 / float(totalEntries);
energyCalGain = energyFit2 * float(totalEntries);
energyCalOffset = energyFit1 - ((0.5 / float(totalEntries)) * energyCalGain);
radix_line(" energy calibration:");
......
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