Mantid
Loading...
Searching...
No Matches
FakeMDEventData.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// Includes
9//----------------------------------------------------------------------------------------------
11
14
15namespace Mantid::MDAlgorithms {
16
17using namespace API;
18using namespace DataObjects;
19using namespace Kernel;
20
21// Register the algorithm into the AlgorithmFactory
22DECLARE_ALGORITHM(FakeMDEventData)
23
24
26void FakeMDEventData::init() {
27 declareProperty(std::make_unique<WorkspaceProperty<IMDEventWorkspace>>("InputWorkspace", "", Direction::InOut),
28 "An input workspace, that will get DataObjects added to it");
29
30 declareProperty(std::make_unique<ArrayProperty<double>>("UniformParams", ""),
31 "Add a uniform, randomized distribution of events.\n"
32 "1 parameter: number_of_events; they will be distributed "
33 "across the size of the workspace.\n"
34 "Depending on the sign of this parameter, the events are "
35 "either distributed randomly around the box \n"
36 "(Case 1, positive) or placed on the regular grid through "
37 "the box (Case 2, negative)\n"
38 "Treatment of Multiple parameters: depends on the Case\n"
39 "Case 1: number_of_events, min,max (for each dimension); "
40 "distribute the events inside the range given.\n"
41 "Case 2: Additional parameters describe initial location and "
42 "steps of the regular grid in each dimension\n");
43
44 declareProperty(std::make_unique<ArrayProperty<double>>("PeakParams", ""),
45 "Add a peak with a normal distribution around a central point.\n"
46 "Parameters: number_of_events, x, y, z, ..., radius.\n");
47
48 declareProperty(std::make_unique<ArrayProperty<double>>("EllipsoidParams", ""),
49 "Add an nd ellipsoidal peak with a multivariate normal distribution\n"
50 "around a central point (x1,...x_N). The ellipsoid is defined by an\n"
51 "N eigenvectors with N elements and N eigenvalues which correpsond \n"
52 "to the variance along the principal axes. The final argument is \n"
53 "doCounts which can be either negative or positive. If doCounts<0\n"
54 "then all events have a count of 1, else if doCounts>0 then the\n"
55 "counts of each event is determined by the Mahalanobis distance\n"
56 "https://en.wikipedia.org/wiki/Mahalanobis_distance \n"
57 "Parameters: number_of_events, x_1,..,x_N, \n"
58 "eigvect_1(1),...,eigvect_1(N), ..., eigvect_N(1),..eigvect_N(N), \n"
59 "eigval_1,...,eigval_N, doCounts.\n");
60
61 declareProperty(std::make_unique<PropertyWithValue<int>>("RandomSeed", 0),
62 "Seed int for the random number generator.");
63
64 declareProperty(std::make_unique<PropertyWithValue<bool>>("RandomizeSignal", false),
65 "If true, the events' signal and error values will be "
66 "randomized around 1.0+-0.5.");
67}
68
73
74 FakeMD faker(getProperty("UniformParams"), getProperty("PeakParams"), getProperty("EllipsoidParams"),
75 getProperty("RandomSeed"), getProperty("RandomizeSignal"));
76 faker.fill(getProperty("InputWorkspace"));
77}
78
79} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
A property class for workspaces.
Provides a helper class to add fake data to an MD workspace.
Definition: FakeMD.h:22
void fill(const API::IMDEventWorkspace_sptr &workspace)
Add the fake data to the given workspace.
Definition: FakeMD.cpp:53
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
The concrete, templated class for properties.
FakeMDEventData : Algorithm to create fake multi-dimensional event data that gets added to MDEventWor...
void exec() override
Run the algorithm.
@ InOut
Both an input & output workspace.
Definition: Property.h:55