Skip to content
Snippets Groups Projects
Commit ca17e372 authored by Michael Wedel's avatar Michael Wedel
Browse files

Refs #11043. Make unit transformation in PoldiPeakSearch more clear

parent 30785199
No related branches found
No related tags found
No related merge requests found
......@@ -94,11 +94,15 @@ protected:
double
minimumPeakHeightFromBackground(UncertainValue backgroundWithSigma) const;
double getTransformedCenter(double value,
const Kernel::Unit_sptr &unit) const;
std::vector<PoldiPeak_sptr>
getPeaks(const MantidVec::const_iterator &baseListStart,
const MantidVec::const_iterator &baseListEnd,
std::list<MantidVec::const_iterator> peakPositions,
const MantidVec &xData, const Kernel::Unit_sptr &unit) const;
double getFWHMEstimate(const MantidVec::const_iterator &baseListStart,
const MantidVec::const_iterator &baseListEnd,
MantidVec::const_iterator peakPosition,
......
......@@ -199,6 +199,26 @@ PoldiPeakSearch::mapPeakPositionsToCorrelationData(
return transformedIndices;
}
/// Converts the value-parameter to d-spacing. Assumes unit to be Q if empty.
double PoldiPeakSearch::getTransformedCenter(double value,
const Unit_sptr &unit) const {
if (boost::dynamic_pointer_cast<Units::dSpacing>(unit)) {
return value;
}
// This is required to preserve default behavior which assumes Q.
Unit_sptr transformUnit = unit;
if (!unit || boost::dynamic_pointer_cast<Units::Empty>(unit)) {
transformUnit = UnitFactory::Instance().create("MomentumTransfer");
}
// Transform value to d-spacing.
Unit_sptr dUnit = UnitFactory::Instance().create("dSpacing");
return UnitConversion::run((*transformUnit), (*dUnit), value, 0, 0, 0,
DeltaEMode::Elastic, 0.0);
}
/** Creates PoldiPeak-objects from peak position iterators
*
* In this method, PoldiPeak objects are created from the raw peak position
......@@ -225,14 +245,7 @@ PoldiPeakSearch::getPeaks(const MantidVec::const_iterator &baseListStart,
peak != peakPositions.end(); ++peak) {
size_t index = std::distance(baseListStart, *peak);
double xDataD = 0.0;
if (boost::dynamic_pointer_cast<Units::dSpacing>(unit)) {
xDataD = xData[index];
} else {
Unit_sptr dUnit = UnitFactory::Instance().create("dSpacing");
xDataD = UnitConversion::run((*unit), (*dUnit), xData[index], 0, 0, 0,
DeltaEMode::Elastic, 0.0);
}
double xDataD = getTransformedCenter(xData[index], unit);
double fwhmEstimate =
getFWHMEstimate(baseListStart, baseListEnd, *peak, xData);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment