45 "An input MDEventWorkspace containing the SCD data.");
47 "The list of peaks to integrate, matching the InputWorkspace.");
49 declareProperty(
"RadiusStart", 0.0,
"Radius at which to start integrating.");
50 declareProperty(
"RadiusEnd", 1.0,
"Radius at which to stop integrating.");
51 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
52 mustBePositive->setLower(0);
53 declareProperty(
"NumSteps", 10, mustBePositive,
"Number of steps, between start and end, to calculate radius.");
56 "For background subtraction: the peak radius will be multiplied\n"
57 "by this factor and passed to the BackgroundInnerRadius parameter.\n"
58 "Default 0.0 (no background).");
60 "For background subtraction: the peak radius will be multiplied\n"
61 "by this factor and passed to the BackgroundOuterRadius parameter.\n"
62 "Default 0.0 (no background).");
68 "For background subtraction:\n"
69 "Specify a fixed BackgroundInnerRadius, which does not "
70 "change with PeakRadius.\n"
71 "Default 0.0 (no background).");
74 "For background subtraction:\n"
75 "Specify a fixed BackgroundOuterRadius, which does not "
76 "change with PeakRadius.\n"
77 "Default 0.0 (no background).");
83 "An output workspace2D containing intensity vs radius.");
85 "An output workspace2D containing number of peaks at levels "
86 "of I/sigI vs radius.");
91 std::map<std::string, std::string> out;
92 double BackgroundInnerFactor =
getProperty(
"BackgroundInnerFactor");
93 double BackgroundOuterFactor =
getProperty(
"BackgroundOuterFactor");
94 double BackgroundInnerRadius =
getProperty(
"BackgroundInnerRadius");
95 double BackgroundOuterRadius =
getProperty(
"BackgroundOuterRadius");
96 if ((BackgroundInnerRadius > 0) && (BackgroundInnerFactor > 0)) {
97 out[
"BackgroundInnerRadius"] =
"Do not specify both BackgroundInnerRadius and BackgroundInnerFactor.";
98 out[
"BackgroundInnerFactor"] =
"Do not specify both BackgroundInnerRadius and BackgroundInnerFactor.";
100 if ((BackgroundOuterRadius > 0) && (BackgroundOuterFactor > 0)) {
101 out[
"BackgroundOuterRadius"] =
"Do not specify both BackgroundOuterRadius and BackgroundOuterFactor.";
102 out[
"BackgroundOuterFactor"] =
"Do not specify both BackgroundOuterRadius and BackgroundOuterFactor.";
115 double BackgroundInnerFactor =
getProperty(
"BackgroundInnerFactor");
116 double BackgroundOuterFactor =
getProperty(
"BackgroundOuterFactor");
117 double BackgroundInnerRadius =
getProperty(
"BackgroundInnerRadius");
118 double BackgroundOuterRadius =
getProperty(
"BackgroundOuterRadius");
127 auto ax = std::make_unique<TextAxis>(outWS->getNumberHistograms());
128 for (
int i = 0; i < peaksWS->getNumberPeaks(); i++) {
129 V3D hkl = peaksWS->getPeak(i).getHKL();
131 ax->setLabel(
size_t(i), hkl.
toString());
133 outWS->replaceAxis(1, std::move(ax));
137 auto ax2 = std::make_unique<TextAxis>(outWS2->getNumberHistograms());
138 ax2->setLabel(0,
"I/SigI=2");
139 ax2->setLabel(1,
"I/SigI=3");
140 ax2->setLabel(2,
"I/SigI=5");
141 ax2->setLabel(3,
"I/SigI=10");
142 outWS2->replaceAxis(1, std::move(ax2));
144 Progress prog(
this, 0.0, 1.0, NumSteps);
145 double progStep = 1.0 / double(NumSteps);
146 for (
int step = 0; step < NumSteps; step++) {
148 double radius = RadiusStart + double(step) * (RadiusEnd - RadiusStart) / (
double(NumSteps - 1));
152 double OuterRadius = 0;
153 if (BackgroundOuterRadius > 0)
154 OuterRadius = BackgroundOuterRadius;
155 if (BackgroundOuterFactor > 0)
156 OuterRadius = BackgroundOuterFactor *
radius;
157 double InnerRadius = 0;
158 if (BackgroundInnerRadius > 0)
159 InnerRadius = BackgroundInnerRadius;
160 if (BackgroundInnerFactor > 0)
161 InnerRadius = BackgroundInnerFactor *
radius;
164 auto alg =
createChildAlgorithm(
"IntegratePeaksMD", progStep *
double(step), progStep *
double(step + 1),
false);
165 alg->setProperty(
"InputWorkspace", inWS);
166 alg->setProperty(
"PeaksWorkspace", peaksWS);
167 alg->setProperty<std::vector<double>>(
"PeakRadius", {
radius});
168 alg->setProperty<std::vector<double>>(
"BackgroundOuterRadius", {OuterRadius});
169 alg->setProperty<std::vector<double>>(
"BackgroundInnerRadius", {InnerRadius});
170 alg->setPropertyValue(
"OutputWorkspace",
"__tmp__PeakIntensityVsRadius");
172 if (alg->isExecuted()) {
177 for (
int i = 0; i < 4; i++) {
178 outWS2->mutableX(i)[step] =
radius;
182 for (
int i = 0; i < outPeaks->getNumberPeaks(); i++) {
185 outWS->mutableX(wi)[step] =
radius;
194 }
else if (ISigI > 5.0) {
198 }
else if (ISigI > 3.0) {
201 }
else if (ISigI > 2.0) {
205 outWS2->mutableY(0)[step] =
static_cast<double>(ISigI2);
206 outWS2->mutableY(1)[step] =
static_cast<double>(ISigI3);
207 outWS2->mutableY(2)[step] =
static_cast<double>(ISigI5);
208 outWS2->mutableY(3)[step] =
static_cast<double>(ISigI10);
215 outWS->setYUnit(
"Integrated Intensity");
216 outWS->getAxis(0)->title() =
"Radius";
217 outWS2->setYUnit(
"Number Peaks");
218 outWS2->getAxis(0)->title() =
"Radius";
#define DECLARE_ALGORITHM(classname)
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.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Helper class for reporting progress from algorithms.
A property class for workspaces.
Calculate the integrated intensity of peaks vs integration radius.
int version() const override
Algorithm's version for identification.
std::map< std::string, std::string > validateInputs() override
Check for reasonable values.
void exec() override
Execute the algorithm.
const std::string category() const override
Algorithm's category for identification.
void init() override
Initialize the algorithm's properties.
Structure describing a single-crystal peak.
virtual double getSigmaIntensity() const =0
virtual double getIntensity() const =0
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
void debug(const std::string &msg)
Logs at debug level.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::string toString() const
void round() noexcept
Round each component to the nearest integer.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::string toString(const T &value)
Convert a number to a string.
@ Input
An input workspace.
@ Output
An output workspace.