Skip to content

Commit

Permalink
Refs #9445. Integrate detector efficiency in IDF
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Jun 30, 2014
1 parent c0ac991 commit d051660
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
Expand Up @@ -50,6 +50,8 @@ class MANTID_SINQ_DLL PoldiAbstractDetector

virtual void loadConfiguration(Geometry::Instrument_const_sptr poldiInstrument) = 0;

virtual double efficiency() = 0;

virtual double twoTheta(int elementIndex) = 0;
virtual double distanceFromSample(int elementIndex) = 0;

Expand Down
Expand Up @@ -51,6 +51,8 @@ class MANTID_SINQ_DLL PoldiDetectorDecorator : public PoldiAbstractDetector

virtual void loadConfiguration(Geometry::Instrument_const_sptr poldiInstrument);

virtual double efficiency();

virtual double twoTheta(int elementIndex);
virtual double distanceFromSample(int elementIndex);

Expand Down
Expand Up @@ -47,6 +47,8 @@ class MANTID_SINQ_DLL PoldiHeliumDetector : public PoldiAbstractDetector

void loadConfiguration(Geometry::Instrument_const_sptr poldiInstrument);

double efficiency();

double twoTheta(int elementIndex);
double distanceFromSample(int elementIndex);

Expand All @@ -61,17 +63,18 @@ class MANTID_SINQ_DLL PoldiHeliumDetector : public PoldiAbstractDetector
double phi(int elementIndex);
double phi(double twoTheta);

void initializeFixedParameters(double radius, size_t elementCount, double elementWidth);
void initializeFixedParameters(double radius, size_t elementCount, double elementWidth, double newEfficiency);
void initializeCalibratedParameters(Kernel::V2D position, double centerTwoTheta);

/* These detector parameters are fixed and specific to the geometry or result from it directly */
/* These detector parameters are fixed and specific to the geometry or result from it directly */
double m_radius;
size_t m_elementCount;
size_t m_centralElement;
double m_elementWidth;
double m_angularResolution;
double m_totalOpeningAngle;
std::vector<int> m_availableElements;
double m_efficiency;

/* Parameters that are calibrated or depend on calibrated parameters */
V2D m_calibratedPosition;
Expand Down
Expand Up @@ -49,6 +49,7 @@ class MockDetector : public PoldiAbstractDetector
UNUSED_ARG(poldiInstrument);
}

MOCK_METHOD0(efficiency, double());
MOCK_METHOD1(twoTheta, double(int elementIndex));
MOCK_METHOD1(distanceFromSample, double(int elementIndex));
MOCK_METHOD0(elementCount, size_t());
Expand All @@ -74,7 +75,7 @@ class ConfiguredHeliumDetector : public PoldiHeliumDetector
{
UNUSED_ARG(poldiInstrument);

initializeFixedParameters(3000.0, static_cast<size_t>(400), 2.5);
initializeFixedParameters(3000.0, static_cast<size_t>(400), 2.5, 0.88);
initializeCalibratedParameters(Mantid::Kernel::V2D(-931.47, -860.0), Conversions::degToRad(90.41));
}
};
Expand Down
Expand Up @@ -31,6 +31,15 @@ void PoldiDetectorDecorator::loadConfiguration(Instrument_const_sptr poldiInstru
UNUSED_ARG(poldiInstrument)
}

double PoldiDetectorDecorator::efficiency()
{
if(m_decoratedDetector) {
return m_decoratedDetector->efficiency();
} else {
throw std::runtime_error("No detector decorated!");
}
}

double PoldiDetectorDecorator::twoTheta(int elementIndex)
{
if(m_decoratedDetector) {
Expand Down
Expand Up @@ -19,6 +19,7 @@ PoldiHeliumDetector::PoldiHeliumDetector() :
m_angularResolution(0.0),
m_totalOpeningAngle(0.0),
m_availableElements(),
m_efficiency(0.0),
m_calibratedPosition(0.0, 0.0),
m_vectorAngle(0.0),
m_distanceFromSample(0.0),
Expand All @@ -33,13 +34,20 @@ void PoldiHeliumDetector::loadConfiguration(Instrument_const_sptr poldiInstrumen
IComponent_const_sptr detector = poldiInstrument->getComponentByName("detector");
double radius = detector->getNumberParameter("radius").front() * 1000.0;
double elementWidth = detector->getNumberParameter("element_separation").front() * 1000.0;
initializeFixedParameters(radius, poldiInstrument->getNumberDetectors(), elementWidth);
double newEfficiency = detector->getNumberParameter("efficiency").front();

initializeFixedParameters(radius, poldiInstrument->getNumberDetectors(), elementWidth, newEfficiency);

Kernel::V3D pos = detector->getPos() * 1000.0;
double twoTheta = Conversions::degToRad(detector->getNumberParameter("two_theta").front());
initializeCalibratedParameters(Kernel::V2D(pos.X(), pos.Y()), twoTheta);
}

double PoldiHeliumDetector::efficiency()
{
return m_efficiency;
}

double PoldiHeliumDetector::twoTheta(int elementIndex)
{
double phiForElement = phi(elementIndex);
Expand Down Expand Up @@ -83,8 +91,9 @@ double PoldiHeliumDetector::phi(double twoTheta)
return twoTheta - asin(m_distanceFromSample / m_radius * sin(M_PI + m_vectorAngle - twoTheta));
}

void PoldiHeliumDetector::initializeFixedParameters(double radius, size_t elementCount, double elementWidth)
void PoldiHeliumDetector::initializeFixedParameters(double radius, size_t elementCount, double elementWidth, double newEfficiency)
{
m_efficiency = newEfficiency;
m_radius = radius;
m_elementCount = elementCount;
m_centralElement = (elementCount - 1) / 2;
Expand Down
Expand Up @@ -32,7 +32,7 @@ void PoldiTimeTransformer::initializeFromPoldiInstrument(PoldiInstrumentAdapter_

m_detectorCenter = getDetectorCenterCharacteristics(detector, chopper);
m_detectorElementData = getDetectorElementData(detector, chopper);
m_detectorEfficiency = 0.88;
m_detectorEfficiency = detector->efficiency();

m_chopperSlits = chopper->slitPositions().size();
}
Expand Down
5 changes: 4 additions & 1 deletion Code/Mantid/instrument/POLDI_Definition_2013.xml
Expand Up @@ -271,5 +271,8 @@
<parameter name="element_separation">
<value val="0.0025" />
</parameter>
<parameter name="efficiency">
<value val="0.88" />
</parameter>
</component>
</instrument>
</instrument>

0 comments on commit d051660

Please sign in to comment.