34 "An input MDEventWorkspace.");
37 "Fixed radius around each peak position in which to calculate the "
41 "A PeaksWorkspace containing the peaks to centroid.");
44 "The output PeaksWorkspace will be a copy of the input PeaksWorkspace "
45 "with the peaks' positions modified by the new found centroids.");
55 throw std::invalid_argument(
"For now, we expect the input MDEventWorkspace "
56 "to have 3 dimensions only.");
64 if (peakWS != inPeakWS)
65 peakWS = inPeakWS->clone();
72 PRAGMA_OMP(parallel
for schedule(dynamic, 10) )
73 for (
int i = 0; i < int(peakWS->getNumberPeaks()); ++i) {
75 IPeak &p = peakWS->getPeak(i);
76 Peak *peak =
dynamic_cast<Peak *
>(&p);
77 double detectorDistance = 0.;
79 detectorDistance = p.
getL2();
83 if (CoordinatesToUse == 1)
85 else if (CoordinatesToUse == 2)
87 else if (CoordinatesToUse == 3)
91 bool dimensionsUsed[nd];
93 for (
size_t d = 0;
d < nd; ++
d) {
94 dimensionsUsed[
d] =
true;
102 for (
size_t d = 0;
d < nd;
d++)
110 for (
size_t d = 0;
d < nd;
d++)
111 centroid[
d] /=
static_cast<coord_t>(signal);
113 V3D vecCentroid(centroid[0], centroid[1], centroid[2]);
118 if (CoordinatesToUse == 1)
123 }
else if (CoordinatesToUse == 2)
128 }
else if (CoordinatesToUse == 3)
132 }
catch (std::exception &e) {
137 g_log.
information() <<
"Peak " << i <<
" at " << pos <<
": signal " << signal <<
", centroid " << vecCentroid
138 <<
" in " << CoordinatesToUse <<
'\n';
140 g_log.
information() <<
"Peak " << i <<
" at " << pos <<
" had no signal, and could not be centroided.\n";
#define DECLARE_ALGORITHM(classname)
#define CALL_MDEVENT_FUNCTION3(funcname, workspace)
Macro that makes it possible to call a templated method for a MDEventWorkspace using a IMDEventWorksp...
#define PRAGMA_OMP(expression)
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.
A property class for workspaces.
void centroidSphere(Mantid::API::CoordTransform &radiusTransform, const coord_t radiusSquared, coord_t *centroid, signal_t &signal) const override=0
Find the centroid around a sphere.
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
MDBoxBase< MDE, nd > * getBox()
Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override
Get the coordinate system.
Structure describing a single-crystal peak.
bool findDetector()
After creating a peak using the Q in the lab frame, the detPos is set to the direction of the detecto...
Structure describing a single-crystal peak.
virtual void setHKL(double H, double K, double L)=0
virtual void setBinCount(double m_BinCount)=0
virtual void setQLabFrame(const Mantid::Kernel::V3D &QLabFrame, boost::optional< double > detectorDistance)=0
virtual double getL2() const =0
virtual Mantid::Kernel::V3D getQSampleFrame() const =0
virtual Mantid::Kernel::V3D getQLabFrame() const =0
virtual void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame, boost::optional< double > detectorDistance)=0
virtual Mantid::Kernel::V3D getHKL() const =0
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
The concrete, templated class for properties.
void exec() override
Run the algorithm.
void init() override
Initialise the properties.
Mantid::API::IMDEventWorkspace_sptr inWS
Input MDEventWorkspace.
void integrate(typename DataObjects::MDEventWorkspace< MDE, nd >::sptr ws)
Integrate the peaks of the workspace using parameters saved in the algorithm class.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
double signal_t
Typedef for the signal recorded in a MDBox, etc.
@ Input
An input workspace.
@ Output
An output workspace.