Commit 2a5fdd40 authored by Walsh, Michael's avatar Walsh, Michael
Browse files

added newline, moved docstrings to cpp

parent 37aa382e
......@@ -66,32 +66,10 @@ private:
/// Execution code
void exec() override;
/// Helper functions
/** Iterates through spectrum in the input workspace finding the center of mass until
* we converge to within the tolerance specified in meters
*
* @param inputWS :: workspace to find the center of mass of
* @param centerX :: save the real center of mass x coord here
* @param centerY :: save the real center of mass y coord here
* @param numSpec :: number of spectrum in the workspace to iterate through
* @param progress :: object for reporting progress of the operation
*/
void findCenterOfMass(API::MatrixWorkspace_sptr inputWS, double &centerX, double &centerY, const int numSpec,
API::Progress &progress);
/** Integrate events in the inputEventWS to determine thier sum and error values
*
* @param inputEventWS :: event workspace to ingegrate
* @param numSpec :: number of events in the workspace to iterate through
* @param progress :: object for reporting progress of the operation
* @return workspace containing the calculated x, y, and e data over numSpec
*/
API::MatrixWorkspace_sptr sumUsingSpectra(DataObjects::EventWorkspace_const_sptr inputEventWS, const int numSpec,
API::Progress &progress);
/** Package the algorithm outputs one of two ways depending on whether or
* not it was given an input EventWorkspace to start with
*
* @param centerX :: center of mass x coord to package
* @param centerY :: center of mass y coord to package
*/
void storeOutputWorkspace(double centerX, double centerY);
// Iteration cutoff
const int m_maxIteration = 200;
......
......@@ -42,52 +42,13 @@ public:
double calculateDistance();
double calculateRadiusX();
double calculateRadiusY();
/** Sets member variables x/y to new x/y based on
* spectrum info and historgram data at the given index
*
* @param index :: index of spectrum data
* @return number of points of histogram data at index
*/
double updatePositionAndReturnCount(int index);
/** Searches for the first valid spectrum info in member variable `workspace`
*
* @param numSpec :: the number of spectrum in the workspace to search through
* @return index of first valid spectrum
*/
int findFirstValidWs(const int numSpec);
/** Performs checks on the spectrum located at index to determine if
* it is acceptable to be operated on
*
* @param index :: index of spectrum data
* @return true/false if its valid
*/
bool isValidWs(int index);
/** Checks to see if spectrum at index is within the diameter of the given beamRadius
*
* @param beamRadius :: radius of beam in meters
* @param index :: index of spectrum data
* @param directBeam :: whether or not the spectrum is subject to the beam
* @return number of points of histogram data at index
*/
bool isOutOfBoundsOfNonDirectBeam(const double beamRadius, int index, const bool directBeam);
/** Checks if a given x/y coord is within the bounding box
*
* @param x :: x coordinate
* @param y :: y coordinate
* @return true/false if it is within the mins/maxs of the box
*/
bool containsPoint(double x, double y);
/** Perform normalization on x/y coords over given values
*
* @param x :: value to normalize member x over
* @param y :: value to normalize member y over
*/
void normalizePosition(double x, double y);
/** Compare current mins and maxs to the coordinates of the spectrum at index
* expnd mins and maxs to include this spectrum
*
* @param index :: index of spectrum data
*/
void updateMinMax(int index);
private:
......@@ -104,4 +65,4 @@ private:
};
} // namespace Algorithms
} // namespace Mantid
\ No newline at end of file
} // namespace Mantid
......@@ -60,6 +60,13 @@ void FindCenterOfMassPosition2::init() {
"the center of mass of the scattering pattern.");
}
/** Integrate events in the inputEventWS to determine thier sum and error values
*
* @param inputEventWS :: event workspace to ingegrate
* @param numSpec :: number of events in the workspace to iterate through
* @param progress :: object for reporting progress of the operation
* @return workspace containing the calculated x, y, and e data over numSpec
*/
API::MatrixWorkspace_sptr
FindCenterOfMassPosition2::sumUsingSpectra(DataObjects::EventWorkspace_const_sptr inputEventWS, const int numSpec,
Progress &progress) {
......@@ -128,6 +135,15 @@ double updateBoundingBox(WorkspaceBoundingBox &boundingBox, WorkspaceBoundingBox
bool equals(double a, double b) { return fabs(a - b) < std::numeric_limits<double>::min(); }
/** Iterates through spectrum in the input workspace finding the center of mass until
* we converge to within the tolerance specified in meters
*
* @param inputWS :: workspace to find the center of mass of
* @param centerX :: save the real center of mass x coord here
* @param centerY :: save the real center of mass y coord here
* @param numSpec :: number of spectrum in the workspace to iterate through
* @param progress :: object for reporting progress of the operation
*/
void FindCenterOfMassPosition2::findCenterOfMass(API::MatrixWorkspace_sptr inputWS, double &centerX, double &centerY,
const int numSpec, Progress &progress) {
const double tolerance = getProperty("Tolerance");
......@@ -207,6 +223,12 @@ void FindCenterOfMassPosition2::findCenterOfMass(API::MatrixWorkspace_sptr input
centerY = boundingBox.getCenterY();
}
/** Package the algorithm outputs one of two ways depending on whether or
* not it was given an input EventWorkspace to start with
*
* @param centerX :: center of mass x coord to package
* @param centerY :: center of mass y coord to package
*/
void FindCenterOfMassPosition2::storeOutputWorkspace(double centerX, double centerY) {
std::string output = getProperty("Output");
......
......@@ -28,6 +28,12 @@ void WorkspaceBoundingBox::setBounds(double xMin, double xMax, double yMin, doub
this->yMax = yMax;
}
/** Performs checks on the spectrum located at index to determine if
* it is acceptable to be operated on
*
* @param index :: index of spectrum data
* @return true/false if its valid
*/
bool WorkspaceBoundingBox::isValidWs(int index) {
const auto spectrumInfo = this->workspace->spectrumInfo();
if (!spectrumInfo.hasDetectors(index)) {
......@@ -46,6 +52,11 @@ bool WorkspaceBoundingBox::isValidWs(int index) {
return true;
}
/** Searches for the first valid spectrum info in member variable `workspace`
*
* @param numSpec :: the number of spectrum in the workspace to search through
* @return index of first valid spectrum
*/
int WorkspaceBoundingBox::findFirstValidWs(const int numSpec) {
const auto spectrumInfo = this->workspace->spectrumInfo();
int i;
......@@ -56,6 +67,12 @@ int WorkspaceBoundingBox::findFirstValidWs(const int numSpec) {
return i;
}
/** Sets member variables x/y to new x/y based on
* spectrum info and historgram data at the given index
*
* @param index :: index of spectrum data
* @return number of points of histogram data at index
*/
double WorkspaceBoundingBox::updatePositionAndReturnCount(int index) {
const auto spectrumInfo = this->workspace->spectrumInfo();
auto &YIn = this->workspace->y(index);
......@@ -66,6 +83,11 @@ double WorkspaceBoundingBox::updatePositionAndReturnCount(int index) {
return YIn[m_specID];
}
/** Compare current mins and maxs to the coordinates of the spectrum at index
* expnd mins and maxs to include this spectrum
*
* @param index :: index of spectrum data
*/
void WorkspaceBoundingBox::updateMinMax(int index) {
const auto spectrumInfo = this->workspace->spectrumInfo();
double x = spectrumInfo.position(index).X();
......@@ -76,6 +98,13 @@ void WorkspaceBoundingBox::updateMinMax(int index) {
this->yMax = std::max(y, this->yMax);
}
/** Checks to see if spectrum at index is within the diameter of the given beamRadius
*
* @param beamRadius :: radius of beam in meters
* @param index :: index of spectrum data
* @param directBeam :: whether or not the spectrum is subject to the beam
* @return number of points of histogram data at index
*/
bool WorkspaceBoundingBox::isOutOfBoundsOfNonDirectBeam(const double beamRadius, int index, const bool directBeam) {
const auto spectrumInfo = this->workspace->spectrumInfo();
double x = spectrumInfo.position(index).X();
......@@ -95,11 +124,22 @@ double WorkspaceBoundingBox::calculateDistance() {
double WorkspaceBoundingBox::calculateRadiusX() { return std::min((x - xMin), (xMax - x)); }
double WorkspaceBoundingBox::calculateRadiusY() { return std::min((y - yMin), (yMax - y)); }
/** Perform normalization on x/y coords over given values
*
* @param x :: value to normalize member x over
* @param y :: value to normalize member y over
*/
void WorkspaceBoundingBox::normalizePosition(double x, double y) {
this->x /= x;
this->y /= y;
}
/** Checks if a given x/y coord is within the bounding box
*
* @param x :: x coordinate
* @param y :: y coordinate
* @return true/false if it is within the mins/maxs of the box
*/
bool WorkspaceBoundingBox::containsPoint(double x, double y) {
if (x > this->xMax || x < this->xMin || y > yMax || y < yMin)
return false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment