Skip to content

Commit

Permalink
Refs #10774. Adding small correction to width in 1D-spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Jan 13, 2015
1 parent c688023 commit 34427bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
Expand Up @@ -76,18 +76,21 @@ class DetectorElementData {
m_timeFactor = current.sinTheta / center.sinTheta * current.totalDistance /
center.totalDistance;
m_widthFactor = current.cosTheta - center.cosTheta;
m_tofFactor = center.tof1A / current.tof1A;
}

double intensityFactor() const { return m_intensityFactor; }
double lambdaFactor() const { return m_lambdaFactor; }
double timeFactor() const { return m_timeFactor; }
double widthFactor() const { return m_widthFactor; }
double tofFactor() const { return m_tofFactor; }

protected:
double m_intensityFactor;
double m_lambdaFactor;
double m_timeFactor;
double m_widthFactor;
double m_tofFactor;
};

typedef boost::shared_ptr<const DetectorElementData>
Expand Down
Expand Up @@ -64,7 +64,7 @@ void PoldiSpectrumDomainFunction::function1DSpectrum(
* terminated by the position in the detector, so the index is stored.
*/
double fwhm = getParameter("Fwhm");
double fwhmT = m_timeTransformer->timeTransformedWidth(fwhm, index);
double fwhmT = m_timeTransformer->dToTOF(fwhm);
double fwhmChannel = fwhmT / m_deltaT;
double sigmaChannel = fwhmChannel / (2.0 * sqrt(2.0 * log(2.0)));

Expand Down Expand Up @@ -121,24 +121,27 @@ void
PoldiSpectrumDomainFunction::poldiFunction1D(const std::vector<int> &indices,
const FunctionDomain1D &domain,
FunctionValues &values) const {
for (auto index = indices.begin(); index != indices.end(); ++index) {
double deltaD = domain[1] - domain[0];

double fwhm = getParameter("Fwhm");
double fwhmChannel = fwhm / deltaD;
double sigmaChannel = fwhmChannel / (2.0 * sqrt(2.0 * log(2.0)));
double deltaD = domain[1] - domain[0];

double centre = getParameter("Centre");
double fwhm = getParameter("Fwhm");

double area = getParameter("Area");
double areaT = m_timeTransformer->timeTransformedIntensity(
area, centre, static_cast<size_t>(*index));
double centre = getParameter("Centre");
double area = getParameter("Area");

double centreTOffsetChannel = centre / deltaD;
int centreChannel = static_cast<int>(centreTOffsetChannel);
double centreTOffsetChannel = centre / deltaD;
int centreChannel = static_cast<int>(centreTOffsetChannel);

int offset = static_cast<int>(domain[0] / deltaD + 0.5);

for (auto index = indices.begin(); index != indices.end(); ++index) {
double fwhmT = m_timeTransformer->timeTransformedWidth(fwhm, *index);
double fwhmChannel = fwhmT / m_deltaT;
double sigmaChannel = fwhmChannel / (2.0 * sqrt(2.0 * log(2.0)));
int widthChannels = std::max(2, static_cast<int>(fwhmChannel * 2.0));

int offset = static_cast<int>(domain[0] / deltaD + 0.5);
double areaT = m_timeTransformer->timeTransformedIntensity(
area, centre, static_cast<size_t>(*index));

for (int i = centreChannel - widthChannels;
i <= centreChannel + widthChannels; ++i) {
Expand Down
Expand Up @@ -39,10 +39,7 @@ double PoldiTimeTransformer::dToTOF(double d) const {

double PoldiTimeTransformer::timeTransformedWidth(double widthD,
size_t detectorIndex) const {
UNUSED_ARG(detectorIndex);

return dToTOF(
widthD); // + m_detectorElementData[detectorIndex]->widthFactor() * 0.0;
return dToTOF(widthD) * m_detectorElementData[detectorIndex]->tofFactor();
}

double PoldiTimeTransformer::timeTransformedCentre(double centreD,
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/SINQ/test/PoldiTimeTransformerTest.h
Expand Up @@ -108,7 +108,7 @@ class PoldiTimeTransformerTest : public CxxTest::TestSuite
TestablePoldiTimeTransformer function;
function.initializeFromPoldiInstrument(m_instrument);

TS_ASSERT_DELTA(function.timeTransformedWidth(fwhm, 342) / deltaT, 4.526804, 1e-5);
TS_ASSERT_DELTA(function.timeTransformedWidth(fwhm, 342) / deltaT, 4.526804 * function.m_detectorElementData[342]->tofFactor(), 1e-5);
}

void testTimeTransformedCentre()
Expand Down

0 comments on commit 34427bb

Please sign in to comment.