Commit 5b2923e3 authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #3521: MDEWFindPeaks fills in the detector, row, col of the peaks found...

Refs #3521: MDEWFindPeaks fills in the detector, row, col of the peaks found where possible. SaveIsawPeaks works with the output.
parent 9d8f2820
......@@ -43,7 +43,7 @@ namespace DataObjects
Mantid::Geometry::IDetector_const_sptr getDetector() const;
Mantid::Geometry::IInstrument_const_sptr getInstrument() const;
bool findDetectorUsingQ();
bool findDetector();
int getRunNumber() const;
void setRunNumber(int m_RunNumber);
#include "MantidDataObjects/Peak.h"
#include "MantidGeometry/Instrument/RectangularDetector.h"
#include "MantidKernel/System.h"
#include "MantidGeometry/Objects/InstrumentRayTracer.h"
using namespace Mantid;
using namespace Mantid::Kernel;
......@@ -433,15 +434,31 @@ namespace DataObjects
detPos = samplePos + beam * detectorDistance;
/** Using the Q in the lab frame and the instrument set in the peak,
* try to find the detector that measured this peak.
/** After creating a peak using the Q in the lab frame,
* the detPos is set to the direction of the detector (but the detector is unknown)
* Uses ray tracing to find the peak.
* Using the instrument set in the peak, perform ray tracing
* to find the exact detector. *
* @return true if the detector ID was found.
bool Peak::findDetectorUsingQ()
bool Peak::findDetector()
// Scattered beam direction
V3D beam = detPos - samplePos;
// Create a ray tracer
InstrumentRayTracer tracker( boost::const_pointer_cast<IInstrument>(m_inst) );
IDetector_sptr det = tracker.getDetectorResult();
if (det)
// Set the detector ID, the row, col, etc.
return true;
return false;
......@@ -259,6 +259,24 @@ public:
/** Create peaks using Q in the lab frame,
* then find the corresponding detector ID */
void test_findDetector()
Peak p1(inst, 19999, 2.0);
V3D Qlab1 = p1.getQLabFrame();
V3D detPos1 = p1.getDetPos();
// Construct using just Q
Peak p2(inst, Qlab1, detPos1.norm());
TS_ASSERT( p2.findDetector() );
comparePeaks(p1, p2);
TS_ASSERT_EQUALS( p2.getBankName(), "bank1");
TS_ASSERT_EQUALS( p2.getRow(), 99);
TS_ASSERT_EQUALS( p2.getCol(), 99);
TS_ASSERT_EQUALS( p2.getDetectorID(), 19999);
......@@ -58,7 +58,7 @@ namespace Mantid
/// Constructor taking an instrument
InstrumentRayTracer(IInstrument_sptr instrument);
InstrumentRayTracer(IInstrument_sptr instrument);
/// Trace a given track from the instrument source in the given direction
/// and compile a list of results that this track intersects.
void trace(const Kernel::V3D & direction) const;
......@@ -222,7 +222,7 @@ namespace MDEvents
// TODO: Goniometer matrix and other stuff?
// Look for a detector
// The "bin count" used will be the box density.
p.setBinCount( box->getSignalNormalized() );
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