diff --git a/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiTimeTransformer.h b/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiTimeTransformer.h index 7cda56781a9d..bbfa04e66b1e 100644 --- a/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiTimeTransformer.h +++ b/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiTimeTransformer.h @@ -101,12 +101,13 @@ class MANTID_SINQ_DLL PoldiTimeTransformer size_t detectorElementCount() const; double dToTOF(double d) const; - double timeTransformedWidth(double widthD, size_t detectorIndex) const; - double timeTransformedCentre(double centreD, size_t detectorIndex) const; - double timeTransformedIntensity(double areaD, double centreD, size_t detectorIndex) const; - double detectorElementIntensity(double centreD, size_t detectorIndex) const; + double adjustedWidth(double widthT, size_t detectorIndex) const; + double adjustedCentre(double centreT, size_t detectorIndex) const; - double calculatedTotalIntensity(double centreD) const; + double adjustedIntensity(double area, double centreT, size_t detectorIndex) const; + double detectorElementIntensity(double centreT, size_t detectorIndex) const; + + double calculatedTotalIntensity(double centreT) const; protected: std::vector getDetectorElementData(const PoldiAbstractDetector_sptr &detector, const PoldiAbstractChopper_sptr &chopper); diff --git a/Code/Mantid/Framework/SINQ/src/PoldiCalculateSpectrum2D.cpp b/Code/Mantid/Framework/SINQ/src/PoldiCalculateSpectrum2D.cpp index 529c9dc08757..03de6feb10e9 100644 --- a/Code/Mantid/Framework/SINQ/src/PoldiCalculateSpectrum2D.cpp +++ b/Code/Mantid/Framework/SINQ/src/PoldiCalculateSpectrum2D.cpp @@ -88,8 +88,8 @@ namespace Poldi IFunction_sptr peakFunction = FunctionFactory::Instance().createFunction("PoldiSpectrumDomainFunction"); peakFunction->setParameter("Area", peak->intensity()); - peakFunction->setParameter("Fwhm", peak->fwhm(PoldiPeak::AbsoluteD)); - peakFunction->setParameter("Centre", peak->d()); + peakFunction->setParameter("Fwhm", m_timeTransformer->dToTOF(peak->fwhm(PoldiPeak::AbsoluteD))); + peakFunction->setParameter("Centre", m_timeTransformer->dToTOF(peak->d())); mdFunction->addFunction(peakFunction); } @@ -347,7 +347,7 @@ namespace Poldi for(size_t i = 0; i < peakCollection->peakCount(); ++i) { PoldiPeak_sptr peak = peakCollection->peak(i); - double calculatedIntensity = m_timeTransformer->calculatedTotalIntensity(peak->d()); + double calculatedIntensity = m_timeTransformer->calculatedTotalIntensity(m_timeTransformer->dToTOF(peak->d())); PoldiPeak_sptr normalizedPeak = peak->clone(); normalizedPeak->setIntensity(peak->intensity() / calculatedIntensity); diff --git a/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp b/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp index 8ac61cf73375..82eb1666755c 100644 --- a/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp +++ b/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiSpectrumDomainFunction.cpp @@ -61,15 +61,15 @@ void PoldiSpectrumDomainFunction::function1DSpectrum(const API::FunctionDomain1D * 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->adjustedWidth(fwhm, index); double fwhmChannel = fwhmT / m_deltaT; double sigmaChannel = fwhmChannel / (2.0 * sqrt(2.0 * log(2.0))); double centre = getParameter("Centre"); - double centreT = m_timeTransformer->timeTransformedCentre(centre, index); + double centreT = m_timeTransformer->adjustedCentre(centre, index); double area = getParameter("Area"); - double areaT = m_timeTransformer->timeTransformedIntensity(area, centre, index); + double areaT = m_timeTransformer->adjustedIntensity(area, centre, index); /* Once all the factors are all there, the calculation needs to be * performed with one offset per chopper slit. diff --git a/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiTimeTransformer.cpp b/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiTimeTransformer.cpp index 37336fd2ceda..0749659082ad 100644 --- a/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiTimeTransformer.cpp +++ b/Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiTimeTransformer.cpp @@ -43,38 +43,38 @@ double PoldiTimeTransformer::dToTOF(double d) const return m_detectorCenter.tof1A * d; } -double PoldiTimeTransformer::timeTransformedWidth(double widthD, size_t detectorIndex) const +double PoldiTimeTransformer::adjustedWidth(double widthT, size_t detectorIndex) const { UNUSED_ARG(detectorIndex); - return dToTOF(widthD);// + m_detectorElementData[detectorIndex]->widthFactor() * 0.0; + return widthT;// + m_detectorElementData[detectorIndex]->widthFactor() * 0.0; } -double PoldiTimeTransformer::timeTransformedCentre(double centreD, size_t detectorIndex) const +double PoldiTimeTransformer::adjustedCentre(double centreT, size_t detectorIndex) const { - return dToTOF(centreD) * m_detectorElementData[detectorIndex]->timeFactor(); + return centreT * m_detectorElementData[detectorIndex]->timeFactor(); } -double PoldiTimeTransformer::timeTransformedIntensity(double areaD, double centreD, size_t detectorIndex) const +double PoldiTimeTransformer::adjustedIntensity(double area, double centreT, size_t detectorIndex) const { - return areaD * detectorElementIntensity(centreD, detectorIndex); + return area * detectorElementIntensity(centreT, detectorIndex); } -double PoldiTimeTransformer::detectorElementIntensity(double centreD, size_t detectorIndex) const +double PoldiTimeTransformer::detectorElementIntensity(double centreT, size_t detectorIndex) const { - double lambda = dToTOF(centreD) * m_detectorElementData[detectorIndex]->lambdaFactor(); + double lambda = centreT * m_detectorElementData[detectorIndex]->lambdaFactor(); double intensity = m_spectrum->intensity(lambda) * m_detectorElementData[detectorIndex]->intensityFactor(); return intensity * (1.0 - exp(-m_detectorEfficiency * lambda)); } -double PoldiTimeTransformer::calculatedTotalIntensity(double centreD) const +double PoldiTimeTransformer::calculatedTotalIntensity(double centreT) const { double sum = 0.0; double chopperSlitFactor = static_cast(m_chopperSlits); for(size_t i = 0; i < m_detectorElementData.size(); ++i) { - sum += chopperSlitFactor * detectorElementIntensity(centreD, i); + sum += chopperSlitFactor * detectorElementIntensity(centreT, i); } return sum; diff --git a/Code/Mantid/Framework/SINQ/test/PoldiCalculateSpectrum2DTest.h b/Code/Mantid/Framework/SINQ/test/PoldiCalculateSpectrum2DTest.h index a7fc9bbaa223..d9050c81645f 100644 --- a/Code/Mantid/Framework/SINQ/test/PoldiCalculateSpectrum2DTest.h +++ b/Code/Mantid/Framework/SINQ/test/PoldiCalculateSpectrum2DTest.h @@ -163,6 +163,7 @@ class PoldiCalculateSpectrum2DTest : public CxxTest::TestSuite void testGetFunctionFromPeakCollection() { TestablePoldiCalculateSpectrum2D spectrumCalculator; + spectrumCalculator.setTimeTransformer(m_timeTransformer); PoldiPeakCollection_sptr peaks = PoldiPeakCollectionHelpers::createPoldiPeakCollectionNormalized(); boost::shared_ptr poldi2DFunction = spectrumCalculator.getFunctionFromPeakCollection(peaks); diff --git a/Code/Mantid/Framework/SINQ/test/PoldiSpectrumDomainFunctionTest.h b/Code/Mantid/Framework/SINQ/test/PoldiSpectrumDomainFunctionTest.h index 3b6dbc2b42ce..46846e4e0916 100644 --- a/Code/Mantid/Framework/SINQ/test/PoldiSpectrumDomainFunctionTest.h +++ b/Code/Mantid/Framework/SINQ/test/PoldiSpectrumDomainFunctionTest.h @@ -107,8 +107,13 @@ class PoldiSpectrumDomainFunctionTest : public CxxTest::TestSuite TestablePoldiSpectrumDomainFunction function; function.initialize(); function.setParameter("Area", 1.9854805); - function.setParameter("Fwhm", 0.0027446316797104233); - function.setParameter("Centre", 1.1086444); + + int detectorCentre = static_cast(m_detector->centralElement()); + double flightPath = m_detector->distanceFromSample(detectorCentre) + m_chopper->distanceFromSample(); + double sinTheta = sin(m_detector->twoTheta(detectorCentre) / 2.0); + + function.setParameter("Fwhm", Conversions::dtoTOF(0.0027446316797104233, flightPath, sinTheta)); + function.setParameter("Centre", Conversions::dtoTOF(1.1086444, flightPath, sinTheta)); function.initializeInstrumentParameters(m_instrument); function.m_deltaT = 3.0; diff --git a/Code/Mantid/Framework/SINQ/test/PoldiTimeTransformerTest.h b/Code/Mantid/Framework/SINQ/test/PoldiTimeTransformerTest.h index 1c238e4304fb..e3085eb8b9fa 100644 --- a/Code/Mantid/Framework/SINQ/test/PoldiTimeTransformerTest.h +++ b/Code/Mantid/Framework/SINQ/test/PoldiTimeTransformerTest.h @@ -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.adjustedWidth(function.dToTOF(fwhm), 342) / deltaT, 4.526804, 1e-5); } void testTimeTransformedCentre() @@ -118,7 +118,7 @@ class PoldiTimeTransformerTest : public CxxTest::TestSuite TestablePoldiTimeTransformer function; function.initializeFromPoldiInstrument(m_instrument); - TS_ASSERT_DELTA(function.timeTransformedCentre(centre, 342), 5964.820800781, 1e-3); + TS_ASSERT_DELTA(function.adjustedCentre(function.dToTOF(centre), 342), 5964.820800781, 1e-3); } void testTimeTransformedIntensity() @@ -129,7 +129,7 @@ class PoldiTimeTransformerTest : public CxxTest::TestSuite TestablePoldiTimeTransformer function; function.initializeFromPoldiInstrument(m_instrument); - TS_ASSERT_DELTA(function.timeTransformedIntensity(areaD, centre, 342), 4.611182, 1e-5); + TS_ASSERT_DELTA(function.adjustedIntensity(areaD, function.dToTOF(centre), 342), 4.611182, 1e-5); } void TestCalculatedTotalIntensity() @@ -140,7 +140,7 @@ class PoldiTimeTransformerTest : public CxxTest::TestSuite function.initializeFromPoldiInstrument(m_instrument); function.m_chopperSlits = 8; - TS_ASSERT_DELTA(fabs(1.0 - function.calculatedTotalIntensity(centre)/8220.165039062), 0.0, 1e-7); + TS_ASSERT_DELTA(fabs(1.0 - function.calculatedTotalIntensity(function.dToTOF(centre))/8220.165039062), 0.0, 1e-7); }