36 "An input MDEventWorkspace.");
38 std::vector<std::string> propOptions{
"Q (lab frame)",
"Q (sample frame)",
"HKL"};
39 declareProperty(
"CoordinatesToUse",
"HKL", std::make_shared<StringListValidator>(propOptions),
40 "Ignored: algorithm uses the InputWorkspace's coordinates.");
43 "Fixed radius around each peak position in which to calculate the "
47 "A PeaksWorkspace containing the peaks to centroid.");
50 "The output PeaksWorkspace will be a copy of the input PeaksWorkspace "
51 "with the peaks' positions modified by the new found centroids.");
61 throw std::invalid_argument(
"For now, we expect the input MDEventWorkspace "
62 "to have 3 dimensions only.");
69 if (peakWS != inPeakWS)
70 peakWS = inPeakWS->clone();
74 if (CoordinatesToUse == 1 && CoordinatesToUseStr !=
"Q (lab frame)")
75 g_log.
warning() <<
"Warning: used Q (lab frame) coordinates for MD "
76 "workspace, not CoordinatesToUse from input \n";
77 else if (CoordinatesToUse == 2 && CoordinatesToUseStr !=
"Q (sample frame)")
78 g_log.
warning() <<
"Warning: used Q (sample frame) coordinates for MD "
79 "workspace, not CoordinatesToUse from input \n";
80 else if (CoordinatesToUse == 3 && CoordinatesToUseStr !=
"HKL")
81 g_log.
warning() <<
"Warning: used HKL coordinates for MD workspace, not "
82 "CoordinatesToUse from input \n";
87 PRAGMA_OMP(parallel
for schedule(dynamic, 10) )
88 for (
int i = 0; i < int(peakWS->getNumberPeaks()); ++i) {
89 Peak &p = peakWS->getPeak(i);
90 double detectorDistance = p.
getL2();
94 if (CoordinatesToUse == 1)
96 else if (CoordinatesToUse == 2)
98 else if (CoordinatesToUse == 3)
102 bool dimensionsUsed[nd];
104 for (
size_t d = 0;
d < nd; ++
d) {
105 dimensionsUsed[
d] =
true;
106 center[
d] =
static_cast<coord_t>(pos[
d]);
113 for (
size_t d = 0;
d < nd;
d++)
121 for (
size_t d = 0;
d < nd;
d++)
122 centroid[
d] /=
static_cast<coord_t>(signal);
124 V3D vecCentroid(centroid[0], centroid[1], centroid[2]);
127 if (CoordinatesToUse == 1)
131 }
else if (CoordinatesToUse == 2)
135 }
else if (CoordinatesToUse == 3)
140 g_log.
information() <<
"Peak " << i <<
" at " << pos <<
": signal " << signal <<
", centroid " << vecCentroid
141 <<
" in " << CoordinatesToUse <<
'\n';
143 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.
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 useAlgorithm(const std::string &, const int version=-1)
The algorithm to use instead of this one.
A property class for workspaces.
void setHKL(double H, double K, double L) override
Set all three H,K,L indices of the peak.
Mantid::Kernel::V3D getHKL() const override
Return the HKL vector.
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.
Mantid::Kernel::V3D getQLabFrame() const override
Return the Q change (of the lattice, k_i - k_f) for this peak.
void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame, boost::optional< double > detectorDistance=boost::none) override
Set the peak using the peak's position in reciprocal space, in the sample frame.
void setQLabFrame(const Mantid::Kernel::V3D &qLab, boost::optional< double > detectorDistance=boost::none) override
Set the peak using the peak's position in reciprocal space, in the lab frame.
bool findDetector()
After creating a peak using the Q in the lab frame, the detPos is set to the direction of the detecto...
Mantid::Kernel::V3D getQSampleFrame() const override
Return the Q change (of the lattice, k_i - k_f) for this peak.
double getL2() const override
Return the L2 flight path length (sample to detector), in meters.
The class PeaksWorkspace stores information about a set of SCD peaks.
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.
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.
void exec() override
Run the algorithm.
void init() override
Initialise the properties.
CentroidPeaksMD()
Constructor.
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
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.