Mantid
Loading...
Searching...
No Matches
MDAlgorithmsTestHelper.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7/*********************************************************************************
8 * PLEASE READ THIS!!!!!!!
9 *
10 * This collection of functions MAY ONLY be used in packages above MDAlgorithms
11 *********************************************************************************/
13
17
18namespace Mantid {
19using namespace API;
20using namespace DataObjects;
21
22namespace MDAlgorithms::MDAlgorithmsTestHelper {
23
36DataObjects::MDEventWorkspace3Lean::sptr makeFileBackedMDEW(const std::string &wsName, bool fileBacked, long numEvents,
38 // ---------- Make a file-backed MDEventWorkspace -----------------------
39 std::string snEvents = std::to_string(numEvents);
40 MDEventWorkspace3Lean::sptr ws1 = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 0);
41 ws1->getBoxController()->setSplitThreshold(100);
42 ws1->setCoordinateSystem(coord);
44 wsName, std::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(ws1));
45 FrameworkManager::Instance().exec("FakeMDEventData", 6, "InputWorkspace", wsName.c_str(), "UniformParams",
46 snEvents.c_str(), "RandomizeSignal", "1");
47 if (fileBacked) {
48 std::string filename = wsName + ".nxs";
49 auto saver =
50 FrameworkManager::Instance().exec("SaveMD", 4, "InputWorkspace", wsName.c_str(), "Filename", filename.c_str());
51 FrameworkManager::Instance().exec("LoadMD", 8, "OutputWorkspace", wsName.c_str(), "Filename",
52 saver->getPropertyValue("Filename").c_str(), "FileBackEnd", "1", "Memory", "0");
53 }
54 return std::dynamic_pointer_cast<MDEventWorkspace3Lean>(
56}
57
72 const Mantid::Geometry::MDFrame &frame,
73 long numEvents,
75 // ---------- Make a file-backed MDEventWorkspace -----------------------
76 std::string snEvents = std::to_string(numEvents);
78 MDEventsTestHelper::makeAnyMDEWWithFrames<MDLeanEvent<3>, 3>(10, 0.0, 10.0, frame, 0);
79 ws1->getBoxController()->setSplitThreshold(100);
80 ws1->setCoordinateSystem(coord);
82 wsName, std::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>(ws1));
83 FrameworkManager::Instance().exec("FakeMDEventData", 6, "InputWorkspace", wsName.c_str(), "UniformParams",
84 snEvents.c_str(), "RandomizeSignal", "1");
85 if (fileBacked) {
86 std::string filename = wsName + ".nxs";
87 auto saver =
88 FrameworkManager::Instance().exec("SaveMD", 4, "InputWorkspace", wsName.c_str(), "Filename", filename.c_str());
89 FrameworkManager::Instance().exec("LoadMD", 8, "OutputWorkspace", wsName.c_str(), "Filename",
90 saver->getPropertyValue("Filename").c_str(), "FileBackEnd", "1", "Memory", "0");
91 }
92 return std::dynamic_pointer_cast<MDEventWorkspace3Lean>(
94}
95
96} // namespace MDAlgorithms::MDAlgorithmsTestHelper
97} // namespace Mantid
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
MDFrame : The coordinate frame for a dimension, or set of dimensions in a multidimensional workspace.
Definition: MDFrame.h:22
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::size_t numEvents(::NeXus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix, const NexusHDF5Descriptor &descriptor)
Get the number of events in the currently opened group.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
DataObjects::MDEventWorkspace3Lean::sptr makeFileBackedMDEW(const std::string &wsName, bool fileBacked, long numEvents=10000, Kernel::SpecialCoordinateSystem coord=Kernel::None)
Make a (optionally) file backed MDEventWorkspace with nEvents fake data points the points are randoml...
DataObjects::MDEventWorkspace3Lean::sptr makeFileBackedMDEWwithMDFrame(const std::string &wsName, bool fileBacked, const Mantid::Geometry::MDFrame &frame, long numEvents=10000, Kernel::SpecialCoordinateSystem coord=Kernel::None)
Make a (optionally) file backed MDEventWorkspace with nEvents fake data points the points are randoml...
Helper class which provides the Collimation Length for SANS instruments.
std::string to_string(const wide_integer< Bits, Signed > &n)