62 return requestedNormalisation;
68 "An input MDWorkspace.");
71 "The output Tableworkspace "
72 "with columns containing key summary information about the MDWorkspace.");
74 declareProperty(
"LimitRows",
true,
"Limit the report output to a maximum number of rows");
78 "The number of neighbours to utilise. Defaults to 100000.");
81 std::vector<std::string> propOptions;
86 declareProperty(
"Normalisation",
"none", std::make_shared<StringListValidator>(propOptions),
87 "What normalisation do you wish to apply"
88 " none: No normalisation.\n"
89 " volume: Normalise by the volume.\n"
90 " number of events: Normalise by the number of events.");
93 "Output box coordinates in terms of original workspace coordinates");
97 "Optional output data table with MDEventWorkspace-specific box data.");
104template <
typename MDE,
size_t nd>
110 output->addColumn(
"int",
"RecursionDepth");
111 output->addColumn(
"int",
"NumBoxes");
112 output->addColumn(
"int",
"NumWithEvents");
113 output->addColumn(
"double",
"PctWithEvents");
114 output->addColumn(
"int",
"TotalEvents");
115 output->addColumn(
"double",
"AvgEventsPer");
116 output->addColumn(
"double",
"TotalWeight");
117 output->addColumn(
"double",
"TotalSignal");
118 output->addColumn(
"double",
"TotalErrorSquared");
119 for (
size_t d = 0;
d < nd;
d++)
123 std::vector<int> NumBoxes(depth, 0);
124 std::vector<int> NumWithEvents(depth, 0);
125 std::vector<int> TotalEvents(depth, 0);
126 std::vector<double> TotalWeight(depth, 0);
127 std::vector<double> TotalSignal(depth, 0);
128 std::vector<double> TotalErrorSquared(depth, 0);
129 std::vector<std::vector<double>> Dims(depth, std::vector<double>(nd, 0.0));
131 std::vector<API::IMDNode *> boxes;
132 ws->
getBox()->getBoxes(boxes, depth,
true);
133 for (
auto &boxe : boxes) {
136 throw(std::runtime_error(
"Can not cast IMDNode to any type of boxes"));
137 size_t d = box->getDepth();
139 if (box->getNPoints() > 0)
140 NumWithEvents[
d] += 1;
141 TotalEvents[
d] +=
static_cast<int>(box->getNPoints());
142 TotalWeight[
d] += box->getTotalWeight();
143 TotalSignal[
d] += box->getSignal();
144 TotalErrorSquared[
d] += box->getErrorSquared();
145 for (
size_t dim = 0; dim < nd; dim++)
146 Dims[
d][dim] =
double(box->getExtents(dim).getSize());
150 for (
size_t d = 0;
d < depth;
d++) {
153 output->cell<
int>(rowCounter, col++) =
int(
d);
154 output->cell<
int>(rowCounter, col++) = NumBoxes[
d];
155 output->cell<
int>(rowCounter, col++) = NumWithEvents[
d];
156 output->cell<
double>(rowCounter, col++) = 100.0 *
double(NumWithEvents[
d]) / double(NumBoxes[
d]);
157 output->cell<
int>(rowCounter, col++) = TotalEvents[
d];
158 output->cell<
double>(rowCounter, col++) =
double(TotalEvents[
d]) / double(NumBoxes[
d]);
159 output->cell<
double>(rowCounter, col++) = TotalWeight[
d];
160 output->cell<
double>(rowCounter, col++) = TotalSignal[
d];
161 output->cell<
double>(rowCounter, col++) = TotalErrorSquared[
d];
162 for (
size_t dim = 0; dim < nd; dim++)
163 output->cell<
double>(rowCounter, col++) = Dims[
d][dim];
179 const bool transformCoordsToOriginal =
getProperty(
"TransformCoordsToOriginal");
183 const std::string signalColumnName =
"Signal/" + strNormalisation;
184 const std::string errorColumnName =
"Error/" + strNormalisation;
185 output->addColumn(
"double", signalColumnName);
186 output->addColumn(
"double", errorColumnName);
187 output->addColumn(
"int",
"Number of Events");
189 const size_t ndims = input->getNumDims();
192 std::string dimInUnit = dim->getName() +
"/" + dim->getUnits().ascii();
193 output->addColumn(
"double", dimInUnit);
195 output->getColumn(dimInUnit)->setPlotType(1);
199 output->getColumn(signalColumnName)->setPlotType(2);
200 output->getColumn(errorColumnName)->setPlotType(5);
202 auto it = input->createIterator();
203 it->setNormalization(requestedNormalisation);
217 size_t cellIndex = 0;
219 output->cell<
double>(rowCounter, cellIndex++) = it->getNormalizedSignal();
220 output->cell<
double>(rowCounter, cellIndex++) = it->getNormalizedError();
221 output->cell<
int>(rowCounter, cellIndex++) =
int(it->getNumEvents());
222 VMD center = it->getCenter();
223 const size_t numberOriginal = input->getNumberTransformsToOriginal();
224 if (transformCoordsToOriginal && numberOriginal > 0) {
225 const size_t index = numberOriginal - 1;
232 output->cell<
double>(rowCounter, cellIndex++) = center[
index];
236 if (!it->next() || (bLimitRows && ((rowCounter + 1) >= maxRows))) {
#define DECLARE_ALGORITHM(classname)
std::map< DeltaEMode::Type, std::string > index
#define CALL_MDEVENT_FUNCTION(funcname, workspace)
Macro that makes it possible to call a templated method for a MDEventWorkspace using a IMDEventWorksp...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
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.
Helper class for reporting progress from algorithms.
A property class for workspaces.
Templated super-class of a multi-dimensional event "box".
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
MDBoxBase< MDE, nd > * getBox()
Mantid::API::BoxController_sptr getBoxController() override
Returns the BoxController used in this workspace.
BoundedValidator is a validator that requires the values to be between upper or lower bounds,...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
The concrete, templated class for properties.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
void exec() override
Run the algorithm.
void init() override
Initialise the properties.
void getBoxData(typename DataObjects::MDEventWorkspace< MDE, nd >::sptr ws)
Make a table of box data.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
@ VolumeNormalization
Divide the signal by the volume of the box/bin.
@ NumEventsNormalization
Divide the signal by the number of events that contributed to it.
@ NoNormalization
Don't normalize = return raw counts.
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.
std::string numberOfEventsNormalisationOption()
Non-member defining the number of events normalisation option.
Mantid::API::MDNormalization whichNormalisation(const std::string &strNormalisation)
Non-member method to interpret an normalisation option.
std::string noNormalisationOption()
Non-member defining the no normalisation option.
std::string volumeNormalisationOption()
Non-member defining the volume normalisation option.
@ Input
An input workspace.
@ Output
An output workspace.