27const
std::
string MergeMD::name()
const {
return "MergeMD"; }
42 "The names of the input MDWorkspaces as a comma-separated list");
45 "Name of the output MDWorkspace.");
56 auto it = inputs.begin();
57 for (; it != inputs.end(); it++) {
61 throw std::invalid_argument(
"Workspace " + *it +
" is not a MDEventWorkspace. Cannot merge this workspace.");
66 throw std::invalid_argument(
"No valid m_workspaces specified.");
71 size_t numDims = ws0->getNumDims();
72 auto displNorm = ws0->displayNormalization();
73 auto displNormH = ws0->displayNormalizationHisto();
76 std::vector<coord_t> dimMin(numDims, +1e30f);
77 std::vector<coord_t> dimMax(numDims, -1e30f);
81 if (ws->getNumDims() != numDims)
82 throw std::invalid_argument(
83 "Workspace " + ws->getName() +
" does not match the number of dimensions of the others (" +
86 if (ws->getEventTypeName() != ws0->getEventTypeName())
87 throw std::invalid_argument(
"Workspace " + ws->getName() +
" does not match the MDEvent type of the others (" +
88 ws->getEventTypeName() +
", expected " + ws0->getEventTypeName() +
")");
90 for (
size_t d = 0;
d < numDims;
d++) {
93 if (dim->getName() != dim0->getName())
94 throw std::invalid_argument(
"Workspace " + ws->getName() +
" does not have the same dimension " +
96 dim0->getName() +
")");
99 if (dim->getMaximum() > dimMax[
d])
100 dimMax[
d] = dim->getMaximum();
101 if (dim->getMinimum() < dimMin[
d])
102 dimMin[
d] = dim->getMinimum();
110 out->setDisplayNormalization(displNorm);
111 out->setDisplayNormalizationHisto(displNormH);
114 for (
size_t d = 0;
d < numDims;
d++) {
117 dimMax[
d], dim0->getNBins());
131 uint16_t nExperiments(0);
132 if (
m_workspaces.size() > std::numeric_limits<uint16_t>::max())
133 throw std::invalid_argument(
"currently we can not combine more then 65535 experiments");
135 nExperiments =
static_cast<uint16_t
>(
m_workspaces.size());
137 for (uint16_t i = 0; i < nExperiments; i++) {
138 uint16_t nWSexperiments =
m_workspaces[i]->getNumExperimentInfo();
140 for (uint16_t j = 0; j < nWSexperiments; j++) {
143 out->addExperimentInfo(ei);
160template <
size_t nd,
size_t ond>
176template <
size_t nd,
size_t ond>
192 throw std::runtime_error(
"Incompatible workspace types passed to MergeMD.");
205 std::vector<API::IMDNode *> boxes;
207 auto numBoxes = int(boxes.size());
209 bool fileBasedSource(
false);
211 fileBasedSource =
true;
217 for (
int i = 0; i < numBoxes; i++) {
220 if (box && !box->getIsMasked()) {
225 for (
auto it = events.cbegin(); it != events.cend(); ++it) {
227 MDE newEvent(it->getSignal(), it->getErrorSquared(), it->getCenter());
229 copyEvent(*it, newEvent, expInfoIndexOffset);
236 box->releaseEvents();
264 const std::vector<std::string> inputs_orig =
getProperty(
"InputWorkspaces");
267 std::vector<std::string> inputs;
268 for (
const auto &input : inputs_orig) {
271 std::vector<std::string> group = wsgroup->
getNames();
272 inputs.insert(inputs.end(), group.begin(), group.end());
275 inputs.emplace_back(input);
279 if (inputs.size() == 1) {
280 g_log.
error(
"Only one input workspace specified");
281 throw std::invalid_argument(
"Only one input workspace specified");
295 this->
progress(0.95,
"Refreshing cache");
300 g_log.
debug() << tim <<
" to merge all workspaces.\n";
#define DECLARE_ALGORITHM(classname)
static std::unique_ptr< QThreadPool > tp
#define CALL_MDEVENT_FUNCTION(funcname, workspace)
Macro that makes it possible to call a templated method for a MDEventWorkspace using a IMDEventWorksp...
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PRAGMA_OMP(expression)
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
std::string getName(const IMDDimension &self)
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
void setBoxController(const Mantid::API::BoxController_sptr &bc, const Mantid::Geometry::Instrument_const_sptr &instrument)
Set the settings in the given box controller.
void initBoxControllerProps(const std::string &SplitInto="5", int SplitThreshold=1000, int MaxRecursionDepth=5)
Initialise the properties.
void setFileNeedsUpdating(bool value)
Sets the marker set to true when a file-backed workspace needs its back-end file updated (by calling ...
virtual void getBoxes(std::vector< IMDNode * > &boxes, size_t maxDepth, bool leafOnly)=0
Fill a vector with all the boxes who are the childred of this one up to a certain depth.
Helper class for reporting progress from algorithms.
Class to hold a set of workspaces.
std::vector< std::string > getNames() const
Returns the names of workspaces that make up this group.
A property class for workspaces.
Templated super-class of a multi-dimensional event "box".
virtual size_t addEvent(const MDE &point)=0
Add a single event.
Templated class for a multi-dimensional event "box".
const std::vector< MDE > & getConstEvents() const
Get vector of constant events to use.
static API::IMDEventWorkspace_sptr CreateMDWorkspace(size_t nd, const std::string &eventType="MDLeanEvent", const Mantid::API::MDNormalization &preferredNormalization=Mantid::API::MDNormalization::VolumeNormalization, const Mantid::API::MDNormalization &preferredNormalizationHisto=Mantid::API::MDNormalization::VolumeNormalization)
Create a MDEventWorkspace of the given type.
uint64_t getNPoints() const override
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
MDBoxBase< MDE, nd > * getBox()
void splitAllIfNeeded(Kernel::ThreadScheduler *ts) override
Split all boxes that exceed the split threshold.
bool isFileBacked() const override
Templated class holding data about a neutron detection event in N-dimensions (for example,...
uint16_t getExpInfoIndex() const
void setDetectorId(int32_t id)
Sets the detectorId of this event.
void setExpInfoIndex(uint16_t index)
Sets the expInfoIndex of this event.
int32_t getDetectorID() const
Templated class holding data about a neutron detection event in N-dimensions (for example,...
Support for a property that holds an array of values.
CPUTimer : Timer that uses the CPU time, rather than wall-clock time to measure execution time.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void information(const std::string &msg)
Logs at information level.
Validator to check that a property is not left empty.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
A Thread Pool implementation that keeps a certain number of threads running (normally,...
A First-In-First-Out Thread Scheduler.
The ThreadScheduler object defines how tasks are allocated to threads and in what order.
Merge several MDWorkspaces into one.
void doPlus(typename Mantid::DataObjects::MDEventWorkspace< MDE, nd >::sptr ws)
Perform the adding.
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
void createOutputWorkspace(std::vector< std::string > &inputs)
Create the output MDWorkspace from a list of input.
std::vector< Mantid::API::IMDEventWorkspace_sptr > m_workspaces
Vector of input MDWorkspaces.
void exec() override
Execute the algorithm.
Mantid::API::IMDEventWorkspace_sptr out
Output MDEventWorkspace.
std::vector< uint16_t > experimentInfoNo
Vector of number of experimentalInfos for each input workspace.
const std::string category() const override
Algorithm's category for identification.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< const IMDEventWorkspace > IMDEventWorkspace_const_sptr
Shared pointer to Mantid::API::IMDEventWorkspace (const version)
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< MDHistoDimension > MDHistoDimension_sptr
Shared pointer to a MDHistoDimension.
std::shared_ptr< const IMDDimension > IMDDimension_const_sptr
Shared Pointer to const IMDDimension.
std::string toString(const T &value)
Convert a number to a string.
void copyEvent(const MDLeanEvent< nd > &srcEvent, MDLeanEvent< ond > &newEvent, const uint16_t expInfoIndexOffset)
Copy the extra data (not signal, error or coordinates) from one event to another with different numbe...
@ Output
An output workspace.