Skip to content
Snippets Groups Projects
Commit 19e044cb authored by Sullivan, Brendan T's avatar Sullivan, Brendan T
Browse files

Re #24329 clang-format

parent 71baa032
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ namespace Crystal { ...@@ -23,7 +23,7 @@ namespace Crystal {
/** SetCrystalLocation /** SetCrystalLocation
Description: Description:
This algorithm provides a convenient interface to sets the This algorithm provides a convenient interface to sets the
sample position of an events workspace. sample position of an events workspace.
@author Brendan Sullivan, SNS,ORNL @author Brendan Sullivan, SNS,ORNL
@date Dec 20 2018 @date Dec 20 2018
......
...@@ -9,26 +9,24 @@ ...@@ -9,26 +9,24 @@
#include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/ITableWorkspace.h"
#include "MantidCrystal/LoadIsawUB.h" #include "MantidCrystal/LoadIsawUB.h"
#include "MantidCrystal/ShowPeakHKLOffsets.h"
#include "MantidCrystal/SetCrystalLocation.h" #include "MantidCrystal/SetCrystalLocation.h"
#include "MantidCrystal/ShowPeakHKLOffsets.h"
#include "MantidDataHandling/Load.h" #include "MantidDataHandling/Load.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include <cxxtest/TestSuite.h> #include <cxxtest/TestSuite.h>
using Mantid::DataHandling::Load; using Mantid::DataHandling::Load;
using namespace Mantid::DataObjects; using namespace Mantid::DataObjects;
using Mantid::Crystal::LoadIsawUB; using Mantid::Crystal::LoadIsawUB;
using Mantid::Crystal::ShowPeakHKLOffsets;
using Mantid::Crystal::SetCrystalLocation; using Mantid::Crystal::SetCrystalLocation;
using Mantid::Crystal::ShowPeakHKLOffsets;
using Mantid::DataObjects::TableWorkspace; using Mantid::DataObjects::TableWorkspace;
using Mantid::Kernel::V3D; using Mantid::Kernel::V3D;
using namespace Mantid::API; using namespace Mantid::API;
class SetCrystalLocationTest : public CxxTest::TestSuite { class SetCrystalLocationTest : public CxxTest::TestSuite {
public: public:
void test_algo() { void test_algo() {
std::string WSName = "events"; std::string WSName = "events";
std::string file_name = "BSS_11841_event.nxs"; std::string file_name = "BSS_11841_event.nxs";
...@@ -36,18 +34,19 @@ public: ...@@ -36,18 +34,19 @@ public:
TS_ASSERT_THROWS_NOTHING(loader.initialize()); TS_ASSERT_THROWS_NOTHING(loader.initialize());
TS_ASSERT(loader.isInitialized()); TS_ASSERT(loader.isInitialized());
loader.setPropertyValue("OutputWorkspace", WSName); loader.setPropertyValue("OutputWorkspace", WSName);
loader.setPropertyValue("Filename",file_name); loader.setPropertyValue("Filename", file_name);
TS_ASSERT(loader.execute()); TS_ASSERT(loader.execute());
TS_ASSERT(loader.isExecuted()); TS_ASSERT(loader.isExecuted());
auto workspace = AnalysisDataService::Instance().retrieve(WSName); auto workspace = AnalysisDataService::Instance().retrieve(WSName);
EventWorkspace_sptr events = boost::dynamic_pointer_cast<EventWorkspace>(workspace); EventWorkspace_sptr events =
boost::dynamic_pointer_cast<EventWorkspace>(workspace);
TS_ASSERT(events); TS_ASSERT(events);
auto inst = events->getInstrument(); auto inst = events->getInstrument();
TS_ASSERT(inst); TS_ASSERT(inst);
auto sample = inst->getSample(); auto sample = inst->getSample();
TS_ASSERT(sample); TS_ASSERT(sample);
SetCrystalLocation algo; SetCrystalLocation algo;
TS_ASSERT_THROWS_NOTHING(algo.initialize()); TS_ASSERT_THROWS_NOTHING(algo.initialize());
TS_ASSERT(algo.isInitialized()); TS_ASSERT(algo.isInitialized());
...@@ -57,23 +56,23 @@ public: ...@@ -57,23 +56,23 @@ public:
algo.setProperty("NewY", -0.30); algo.setProperty("NewY", -0.30);
algo.setProperty("NewZ", 10.0); algo.setProperty("NewZ", 10.0);
//Check the sample is at the origin by default // Check the sample is at the origin by default
V3D sampPos0 = sample->getPos(); V3D sampPos0 = sample->getPos();
TS_ASSERT_DELTA(sampPos0.X(), 0.0, 1.e-3); TS_ASSERT_DELTA(sampPos0.X(), 0.0, 1.e-3);
TS_ASSERT_DELTA(sampPos0.Y(), 0.0, 1.e-3); TS_ASSERT_DELTA(sampPos0.Y(), 0.0, 1.e-3);
TS_ASSERT_DELTA(sampPos0.Z(), 0.0, 1.e-3); TS_ASSERT_DELTA(sampPos0.Z(), 0.0, 1.e-3);
//Move the sample to (1.0, -0.3, 10.0) // Move the sample to (1.0, -0.3, 10.0)
TS_ASSERT(algo.execute()); TS_ASSERT(algo.execute());
TS_ASSERT(algo.isExecuted()); TS_ASSERT(algo.isExecuted());
//Check that the sample moved // Check that the sample moved
V3D sampPos1 = sample->getPos(); V3D sampPos1 = sample->getPos();
TS_ASSERT_DELTA(sampPos1.X(), 1.0, 1.e-3); TS_ASSERT_DELTA(sampPos1.X(), 1.0, 1.e-3);
TS_ASSERT_DELTA(sampPos1.Y(), -0.30, 1.e-3); TS_ASSERT_DELTA(sampPos1.Y(), -0.30, 1.e-3);
TS_ASSERT_DELTA(sampPos1.Z(), 10.0, 1.e-3); TS_ASSERT_DELTA(sampPos1.Z(), 10.0, 1.e-3);
//Try it on a separate workspace // Try it on a separate workspace
SetCrystalLocation algo2; SetCrystalLocation algo2;
TS_ASSERT_THROWS_NOTHING(algo2.initialize()); TS_ASSERT_THROWS_NOTHING(algo2.initialize());
TS_ASSERT(algo2.isInitialized()); TS_ASSERT(algo2.isInitialized());
...@@ -85,23 +84,24 @@ public: ...@@ -85,23 +84,24 @@ public:
TS_ASSERT(algo2.execute()); TS_ASSERT(algo2.execute());
TS_ASSERT(algo2.isExecuted()); TS_ASSERT(algo2.isExecuted());
//Check that the original is unchanged. "Events" should be at // Check that the original is unchanged. "Events" should be at
// the same sampPos1 = (1.0, -0.3, 10.0) // the same sampPos1 = (1.0, -0.3, 10.0)
V3D sampPos2 = sample->getPos(); V3D sampPos2 = sample->getPos();
TS_ASSERT_DELTA(sampPos2.X(), 1.0, 1.e-3); TS_ASSERT_DELTA(sampPos2.X(), 1.0, 1.e-3);
TS_ASSERT_DELTA(sampPos2.Y(), -0.30, 1.e-3); TS_ASSERT_DELTA(sampPos2.Y(), -0.30, 1.e-3);
TS_ASSERT_DELTA(sampPos2.Z(), 10.0, 1.e-3); TS_ASSERT_DELTA(sampPos2.Z(), 10.0, 1.e-3);
//Get pointers to the new workspace // Get pointers to the new workspace
auto workspace_new = AnalysisDataService::Instance().retrieve("events_new"); auto workspace_new = AnalysisDataService::Instance().retrieve("events_new");
EventWorkspace_sptr events_new = boost::dynamic_pointer_cast<EventWorkspace>(workspace_new); EventWorkspace_sptr events_new =
boost::dynamic_pointer_cast<EventWorkspace>(workspace_new);
TS_ASSERT(events_new) TS_ASSERT(events_new)
auto inst_new = events_new->getInstrument(); auto inst_new = events_new->getInstrument();
TS_ASSERT(inst_new); TS_ASSERT(inst_new);
auto sample_new = inst_new->getSample(); auto sample_new = inst_new->getSample();
TS_ASSERT(sample_new); TS_ASSERT(sample_new);
//the new workspace should be at (2.,4.,0.,) // the new workspace should be at (2.,4.,0.,)
V3D sampPos3 = sample_new->getPos(); V3D sampPos3 = sample_new->getPos();
TS_ASSERT_DELTA(sampPos3.X(), 2.0, 1.e-3); TS_ASSERT_DELTA(sampPos3.X(), 2.0, 1.e-3);
TS_ASSERT_DELTA(sampPos3.Y(), 4.0, 1.e-3); TS_ASSERT_DELTA(sampPos3.Y(), 4.0, 1.e-3);
......
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