Commit 84656aea authored by Mathieu Tillet's avatar Mathieu Tillet
Browse files

Move all of D11B at once when loading

Instead of moving each part separately, move all of the components by
moving the parent, thus making sure the distance between the panels will
stay constant.
This requires to use the relativePosition flag, because the high level
parent cannot be moved to absolute position.
parent e95f1c32
......@@ -70,7 +70,8 @@ private:
size_t loadDataFromTubes(NeXus::NXInt &, const std::vector<double> &, size_t);
void runLoadInstrument();
void moveDetectorsD33(const DetectorPosition &);
void moveDetectorDistance(double, const std::string &);
void moveDetectorDistance(double distance, const std::string &componentName,
const bool relative = false);
void moveDetectorHorizontal(double, const std::string &);
void moveDetectorVertical(double, const std::string &);
Kernel::V3D getComponentPosition(const std::string &componentName);
......
......@@ -151,17 +151,12 @@ void LoadILLSANS::exec() {
initWorkSpaceD11B(firstEntry, instrumentPath);
progress.report("Loading the instrument " + m_instrumentName);
runLoadInstrument();
double distance =
double finalDistance =
firstEntry.getFloat(instrumentPath + "/detector/det_calc") / 1000.;
moveDetectorDistance(distance, "detector_center");
distance =
firstEntry.getFloat(instrumentPath + "/detectorLeft/det_calc") / 1000.;
moveDetectorDistance(distance, "detector_left");
V3D pos = getComponentPosition("detector_center");
double currentDistance = pos.Z();
distance =
firstEntry.getFloat(instrumentPath + "/detectorRight/det_calc") / 1000.;
moveDetectorDistance(distance, "detector_right");
moveDetectorDistance(finalDistance - currentDistance, "detector", true);
} else if (m_instrumentName == "D22B") {
initWorkSpaceD22B(firstEntry, instrumentPath);
......@@ -652,21 +647,33 @@ void LoadILLSANS::moveDetectorsD33(const DetectorPosition &detPos) {
* @param componentName : name of the component to move
*/
void LoadILLSANS::moveDetectorDistance(double distance,
const std::string &componentName) {
const std::string &componentName,
const bool relative) {
API::IAlgorithm_sptr mover = createChildAlgorithm("MoveInstrumentComponent");
V3D pos = getComponentPosition(componentName);
mover->setProperty<MatrixWorkspace_sptr>("Workspace", m_localWorkspace);
mover->setProperty("ComponentName", componentName);
mover->setProperty("X", pos.X());
mover->setProperty("Y", pos.Y());
if (relative) {
mover->setProperty("X", 0.);
mover->setProperty("Y", 0.);
} else {
mover->setProperty("X", pos.X());
mover->setProperty("Y", pos.Y());
}
mover->setProperty("Z", distance);
mover->setProperty("RelativePosition", false);
mover->setProperty("RelativePosition", relative);
mover->executeAsChildAlg();
g_log.debug() << "Moving component '" << componentName
<< "' to Z = " << distance << '\n';
API::Run &runDetails = m_localWorkspace->mutableRun();
runDetails.addProperty<double>("L2", distance, true);
if (!relative) {
g_log.debug() << "Moving component '" << componentName
<< "' to Z = " << distance << '\n';
API::Run &runDetails = m_localWorkspace->mutableRun();
runDetails.addProperty<double>("L2", distance, true);
} else {
g_log.debug() << "Moving component '" << componentName
<< "' by Z = " << distance << '\n';
}
}
/**
......
Supports Markdown
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