51 "Input md workspace.");
53 "A PeaksWorkspace containing the peaks to integrate.");
55 auto positiveValidator = std::make_shared<BoundedValidator<double>>();
56 positiveValidator->setExclusive(
true);
57 positiveValidator->setLower(0);
59 auto compositeValidator = std::make_shared<CompositeValidator>();
60 compositeValidator->add(positiveValidator);
64 "Threshold signal above which to consider peaks");
66 std::array<std::string, 3> normalizations = {{
"NoNormalization",
"VolumeNormalization",
"NumEventsNormalization"}};
70 "Normalization to use with Threshold. Defaults to "
71 "VolumeNormalization to account for different binning.");
74 "An output integrated peaks workspace.");
76 "MDHistoWorkspace containing the labeled clusters used by "
87 if (normProp ==
"NoNormalization") {
89 }
else if (normProp ==
"VolumeNormalization") {
104 if (peakWS != inPeakWS) {
105 peakWS = inPeakWS->clone();
110 if (mdCoordinates ==
None) {
111 throw std::invalid_argument(
"The coordinate system of the input "
112 "MDWorkspace cannot be established. Create "
113 "your workspace with an MDFrame which is "
114 "not a General Frame or Unknown Frame.");
132 std::map<size_t, size_t> labelsTakenByPeaks;
139 progress.doReport(
"Performing Peak Integration");
141 progress.resetNumSteps(peakWS->getNumberPeaks(), 0.9, 1);
143 for (
int i = 0; i < peakWS->getNumberPeaks(); ++i) {
148 if (std::isnan(signalValue)) {
149 g_log.
warning() <<
"Warning: image for integration is off edge of detector for peak " << i <<
'\n';
152 <<
" Has no corresponding cluster/blob detected on "
153 "the image. This could be down to your Threshold "
156 const auto labelIdAtPeak =
static_cast<size_t>(signalValue);
157 ICluster *
const cluster = clusterMap[labelIdAtPeak].get();
159 peak.setIntensity(integratedValues.get<0>());
160 peak.setSigmaIntensity(std::sqrt(integratedValues.get<1>()));
163 auto it = labelsTakenByPeaks.find(labelIdAtPeak);
164 if (it != labelsTakenByPeaks.end()) {
165 g_log.
warning() <<
"Overlapping Peaks. Peak: " << i <<
" overlaps with another Peak: " << it->second
166 <<
" and shares label id: " << it->first <<
'\n';
168 labelsTakenByPeaks.emplace(labelIdAtPeak, i);
#define DECLARE_ALGORITHM(classname)
#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_CRITICAL(name)
#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 PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
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.
ConnectedComponentLabelling : Implements connected component labeling on MDHistoWorkspaces.
size_t getStartLabelId() const
Getter for the start label id.
ConnectedComponentMappingTypes::ClusterTuple executeAndFetchClusters(Mantid::API::IMDHistoWorkspace_sptr ws, BackgroundStrategy *const strategy, Mantid::API::Progress &progress) const
Execute and return clusters, as well as maps to integratable clusters.
HardThresholdBackground : Implementation of BackgroundStrategy using a fixed background signal value ...
ICluster : Abstract cluster.
boost::tuple< double, double > ClusterIntegratedValues
virtual ClusterIntegratedValues integrate(std::shared_ptr< const Mantid::API::IMDHistoWorkspace > ws) const =0
integrate the cluster
IntegratePeaksUsingClusters : Uses clustering to integrate peaks.
void init() override
Initialize the algorithm's properties.
void exec() override
Execute the algorithm.
const std::string category() const override
Algorithm's category for identification.
Mantid::API::MDNormalization getNormalization()
Get the normalization.
int version() const override
Algorithm's version for identification.
PeakClusterProjection : Maps peaks onto IMDHistoWorkspaces and returns the signal value at the peak c...
Mantid::signal_t signalAtPeakCenter(const Mantid::Geometry::IPeak &peak, Mantid::API::MDNormalization normalization=Mantid::API::NoNormalization) const
Get the signal value at the peak center.
Structure describing a single-crystal peak.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
ListValidator is a validator that requires the value of a property to be one of a defined list of pos...
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
Validator to check that a property is not left empty.
The concrete, templated class for properties.
std::shared_ptr< IMDHistoWorkspace > IMDHistoWorkspace_sptr
shared pointer to Mantid::API::IMDHistoWorkspace
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.
Namespace containing useful typedefs.
std::map< size_t, std::shared_ptr< Mantid::Crystal::ICluster > > ClusterMap
boost::tuple< Mantid::API::IMDHistoWorkspace_sptr, ClusterMap > ClusterTuple
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
double signal_t
Typedef for the signal recorded in a MDBox, etc.
@ Input
An input workspace.
@ Output
An output workspace.