Commit c1f1cc80 authored by Raquel Alvarez's avatar Raquel Alvarez
Browse files

Re #18569 LoadHelper and related algorithms

parent 9d64b047
......@@ -5,6 +5,7 @@
#include "MantidDataHandling/LoadHelper.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/SpectrumInfo.h"
#include "MantidGeometry/Instrument/ComponentHelper.h"
#include "MantidKernel/PhysicalConstants.h"
......@@ -105,22 +106,14 @@ double LoadHelper::calculateTOF(double distance, double wavelength) {
}
double LoadHelper::getL1(const API::MatrixWorkspace_sptr &workspace) {
Geometry::Instrument_const_sptr instrument = workspace->getInstrument();
Geometry::IComponent_const_sptr sample = instrument->getSample();
double l1 = instrument->getSource()->getDistance(*sample);
return l1;
const auto &spectrumInfo = workspace->spectrumInfo();
return spectrumInfo.l1();
}
double LoadHelper::getL2(const API::MatrixWorkspace_sptr &workspace,
int detId) {
// Get a pointer to the instrument contained in the workspace
Geometry::Instrument_const_sptr instrument = workspace->getInstrument();
// Get the distance between the source and the sample (assume in metres)
Geometry::IComponent_const_sptr sample = instrument->getSample();
// Get the sample-detector distance for this detector (in metres)
double l2 =
workspace->getDetector(detId)->getPos().distance(sample->getPos());
return l2;
const auto &spectrumInfo = workspace->spectrumInfo();
return spectrumInfo.l2(detId);
}
/*
......
......@@ -97,4 +97,46 @@ private:
std::string m_dataFile2015;
};
class LoadILLIndirect2TestPerformance : public CxxTest::TestSuite {
public:
void setUp() override {
for (int i = 0; i < numberOfIterations; ++i) {
loadAlgPtrs.emplace_back(setupAlg());
}
}
void testLoadILLIndirectPerformance() {
for (auto alg : loadAlgPtrs) {
TS_ASSERT_THROWS_NOTHING(alg->execute());
}
}
void tearDown() override {
for (int i = 0; i < numberOfIterations; i++) {
delete loadAlgPtrs[i];
loadAlgPtrs[i] = nullptr;
}
Mantid::API::AnalysisDataService::Instance().remove(outWSName);
}
private:
std::vector<LoadILLIndirect2 *> loadAlgPtrs;
const int numberOfIterations = 5;
const std::string inFileName = "ILLIN16B_127500.nxs";
const std::string outWSName = "LoadILLWsOut";
LoadILLIndirect2 *setupAlg() {
LoadILLIndirect2 *loader = new LoadILLIndirect2;
loader->initialize();
loader->isInitialized();
loader->setPropertyValue("Filename", inFileName);
loader->setPropertyValue("OutputWorkspace", outWSName);
loader->setRethrows(true);
return loader;
}
};
#endif /* MANTID_DATAHANDLING_LOADILLINDIRECT2TEST_H_ */
......@@ -3,9 +3,9 @@
#include <cxxtest/TestSuite.h>
#include "MantidDataHandling/LoadILLReflectometry.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataHandling/LoadILLReflectometry.h"
using namespace Mantid::API;
using Mantid::DataHandling::LoadILLReflectometry;
......@@ -81,4 +81,46 @@ private:
}
};
class LoadILLReflectometryTestPerformance : public CxxTest::TestSuite {
public:
void setUp() override {
for (int i = 0; i < numberOfIterations; ++i) {
loadAlgPtrs.emplace_back(setupAlg());
}
}
void testLoadILLReflectometryPerformance() {
for (auto alg : loadAlgPtrs) {
TS_ASSERT_THROWS_NOTHING(alg->execute());
}
}
void tearDown() override {
for (int i = 0; i < numberOfIterations; i++) {
delete loadAlgPtrs[i];
loadAlgPtrs[i] = nullptr;
}
Mantid::API::AnalysisDataService::Instance().remove(outWSName);
}
private:
std::vector<LoadILLReflectometry *> loadAlgPtrs;
const int numberOfIterations = 5;
const std::string inFileName = "ILLD17-161876-Ni.nxs";
const std::string outWSName = "LoadILLReflectomeryWsOut";
LoadILLReflectometry *setupAlg() {
LoadILLReflectometry *loader = new LoadILLReflectometry;
loader->initialize();
loader->isInitialized();
loader->setPropertyValue("Filename", inFileName);
loader->setPropertyValue("OutputWorkspace", outWSName);
loader->setRethrows(true);
return loader;
}
};
#endif /* MANTID_DATAHANDLING_LOADILLREFLECTOMETRYTEST_H_ */
......@@ -3,9 +3,9 @@
#include <cxxtest/TestSuite.h>
#include "MantidDataHandling/LoadILLSANS.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataHandling/LoadILLSANS.h"
using Mantid::DataHandling::LoadILLSANS;
using namespace Mantid::API;
......@@ -89,4 +89,46 @@ private:
std::string m_testFileNonTof;
};
class LoadILLSANSTestPerformance : public CxxTest::TestSuite {
public:
void setUp() override {
for (int i = 0; i < numberOfIterations; ++i) {
loadAlgPtrs.emplace_back(setupAlg());
}
}
void testLoadILLSANSPerformance() {
for (auto alg : loadAlgPtrs) {
TS_ASSERT_THROWS_NOTHING(alg->execute());
}
}
void tearDown() override {
for (int i = 0; i < numberOfIterations; i++) {
delete loadAlgPtrs[i];
loadAlgPtrs[i] = nullptr;
}
Mantid::API::AnalysisDataService::Instance().remove(outWSName);
}
private:
std::vector<LoadILLSANS *> loadAlgPtrs;
const int numberOfIterations = 2;
const std::string inFileName = "ILLD33_041714_NonTof.nxs";
const std::string outWSName = "LoadILLSANSWsOut";
LoadILLSANS *setupAlg() {
LoadILLSANS *loader = new LoadILLSANS;
loader->initialize();
loader->isInitialized();
loader->setPropertyValue("Filename", inFileName);
loader->setPropertyValue("OutputWorkspace", outWSName);
loader->setRethrows(true);
return loader;
}
};
#endif /* MANTID_DATAHANDLING_LOADILLSANSTEST_H_ */
......@@ -3,9 +3,9 @@
#include <cxxtest/TestSuite.h>
#include "MantidDataHandling/LoadLLB.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataHandling/LoadLLB.h"
using namespace Mantid::API;
using Mantid::DataHandling::LoadLLB;
......@@ -60,4 +60,45 @@ private:
std::string m_testFile;
};
class LoadLLBTestPerformance : public CxxTest::TestSuite {
public:
void setUp() override {
for (int i = 0; i < numberOfIterations; ++i) {
loadAlgPtrs.emplace_back(setupAlg());
}
}
void testLoadLLBPerformance() {
for (auto alg : loadAlgPtrs) {
TS_ASSERT_THROWS_NOTHING(alg->execute());
}
}
void tearDown() override {
for (int i = 0; i < numberOfIterations; i++) {
delete loadAlgPtrs[i];
loadAlgPtrs[i] = nullptr;
}
Mantid::API::AnalysisDataService::Instance().remove(outWSName);
}
private:
std::vector<LoadLLB *> loadAlgPtrs;
const int numberOfIterations = 5;
const std::string inFileName = "LLB_d22418.nxs";
const std::string outWSName = "LoadLLBWsOut";
LoadLLB *setupAlg() {
LoadLLB *loader = new LoadLLB;
loader->initialize();
loader->isInitialized();
loader->setPropertyValue("Filename", inFileName);
loader->setPropertyValue("OutputWorkspace", outWSName);
loader->setRethrows(true);
return loader;
}
};
#endif /* MANTID_DATAHANDLING_LOADLLBTEST_H_ */
......@@ -62,7 +62,6 @@ private:
void setWorkspaceRotationAngle(API::MatrixWorkspace_sptr,
double rotationAngle);
// LoadHelper m_loader;
std::string m_instrumentName; ///< Name of the instrument
double m_wavelength = 0;
std::vector<std::string> m_supportedInstruments{"D2B"};
......
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