Skip to content
Snippets Groups Projects
Commit 67712616 authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Corrected detector rotation issue

parent c9e495b6
No related branches found
No related tags found
No related merge requests found
...@@ -77,6 +77,7 @@ private: ...@@ -77,6 +77,7 @@ private:
void loadMetaData(const NeXus::NXEntry &, const std::string &); void loadMetaData(const NeXus::NXEntry &, const std::string &);
std::string getInstrumentFilePath(const std::string &) const; std::string getInstrumentFilePath(const std::string &) const;
void rotateInstrument(double, const std::string &); void rotateInstrument(double, const std::string &);
void placeD16(double, double, const std::string &);
void adjustTOF(); void adjustTOF();
void moveSource(); void moveSource();
......
...@@ -123,18 +123,23 @@ void LoadILLSANS::exec() { ...@@ -123,18 +123,23 @@ void LoadILLSANS::exec() {
moveSource(); moveSource();
} }
} else if (m_instrumentName == "D16") {
initWorkSpace(firstEntry, instrumentPath);
progress.report("Loading the instrument " + m_instrumentName);
runLoadInstrument();
double distance = firstEntry.getFloat(instrumentPath + "/Det/value") /
1000; // mm to metre
const double angle = firstEntry.getFloat(instrumentPath + "/Gamma/value");
placeD16(angle, distance, "detector");
} else { } else {
initWorkSpace(firstEntry, instrumentPath); initWorkSpace(firstEntry, instrumentPath);
progress.report("Loading the instrument " + m_instrumentName); progress.report("Loading the instrument " + m_instrumentName);
runLoadInstrument(); runLoadInstrument();
double distance; double distance = m_loader.getDoubleFromNexusPath(
if (m_instrumentName == "D16") { firstEntry, instrumentPath + "/detector/det_calc");
distance = firstEntry.getFloat(instrumentPath + "/Det/value") /
1000; // mm to metre
} else {
distance = m_loader.getDoubleFromNexusPath(
firstEntry, instrumentPath + "/detector/det_calc");
}
progress.report("Moving detectors"); progress.report("Moving detectors");
moveDetectorDistance(distance, "detector"); moveDetectorDistance(distance, "detector");
if (m_instrumentName == "D22") { if (m_instrumentName == "D22") {
...@@ -146,18 +151,13 @@ void LoadILLSANS::exec() { ...@@ -146,18 +151,13 @@ void LoadILLSANS::exec() {
firstEntry, instrumentPath + "/detector/dan_actual"); firstEntry, instrumentPath + "/detector/dan_actual");
rotateD22(angle, "detector");*/ rotateD22(angle, "detector");*/
} }
if (m_instrumentName == "D16") {
const double angle = firstEntry.getFloat(instrumentPath + "/Gamma/value");
rotateInstrument(angle, "detector");
}
} }
progress.report("Setting sample logs"); progress.report("Setting sample logs");
setFinalProperties(filename); setFinalProperties(filename);
setPixelSize(); setPixelSize();
setProperty("OutputWorkspace", m_localWorkspace); setProperty("OutputWorkspace", m_localWorkspace);
} } // namespace DataHandling
/** /**
* Set member variable with the instrument name * Set member variable with the instrument name
...@@ -215,7 +215,7 @@ LoadILLSANS::getDetectorPositionD33(const NeXus::NXEntry &firstEntry, ...@@ -215,7 +215,7 @@ LoadILLSANS::getDetectorPositionD33(const NeXus::NXEntry &firstEntry,
} }
/** /**
* Loads data for D11 and D22 * Loads data for D11, D16 and D22
*/ */
void LoadILLSANS::initWorkSpace(NeXus::NXEntry &firstEntry, void LoadILLSANS::initWorkSpace(NeXus::NXEntry &firstEntry,
const std::string &instrumentPath) { const std::string &instrumentPath) {
...@@ -525,7 +525,7 @@ void LoadILLSANS::moveDetectorDistance(double distance, ...@@ -525,7 +525,7 @@ void LoadILLSANS::moveDetectorDistance(double distance,
} }
/** /**
* Rotates D22 detector around y-axis * Rotates instrument detector around y-axis in place
* @param angle : the angle to rotate [degree] * @param angle : the angle to rotate [degree]
* @param componentName : "detector" * @param componentName : "detector"
*/ */
...@@ -545,6 +545,31 @@ void LoadILLSANS::rotateInstrument(double angle, ...@@ -545,6 +545,31 @@ void LoadILLSANS::rotateInstrument(double angle,
<< "' to angle = " << angle << " degrees.\n"; << "' to angle = " << angle << " degrees.\n";
} }
/**
* @brief LoadILLSANS::placeD16 : place the D16 detector.
* @param angle : the angle between its center and the transmitted beam
* @param distance : the distance between its center and the sample
* @param componentName : "detector"
*/
void LoadILLSANS::placeD16(double angle, double distance,
const std::string &componentName) {
API::IAlgorithm_sptr mover = createChildAlgorithm("MoveInstrumentComponent");
mover->setProperty<MatrixWorkspace_sptr>("Workspace", m_localWorkspace);
mover->setProperty("ComponentName", componentName);
mover->setProperty("X", sin(angle * M_PI / 180) * distance);
mover->setProperty("Y", 0.);
mover->setProperty("Z", cos(angle * M_PI / 180) * distance);
mover->setProperty("RelativePosition", false);
mover->executeAsChildAlg();
// rotate the detector so it faces the sample.
rotateInstrument(angle, componentName);
g_log.debug() << "Moving component '" << componentName
<< "' to angle = " << angle
<< " degrees and distance = " << distance << "metres.\n";
}
/** /**
* Move detectors in X * Move detectors in X
* @param shift : the distance to move [metres] * @param shift : the distance to move [metres]
......
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