Skip to content
Snippets Groups Projects
Commit 0d3b1bdb authored by Antti Soininen's avatar Antti Soininen
Browse files

Release notes & code beautification. Re #24041

parent 65f5dc52
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,8 @@ WorkspaceNearestNeighbours::WorkspaceNearestNeighbours(
std::vector<specnum_t> spectrumNumbers, bool ignoreMaskedDetectors)
: m_spectrumInfo(spectrumInfo),
m_spectrumNumbers(std::move(spectrumNumbers)),
m_noNeighbours(nNeighbours), m_cutoff(std::numeric_limits<double>::lowest()), m_radius(0.),
m_noNeighbours(nNeighbours),
m_cutoff(std::numeric_limits<double>::lowest()), m_radius(0.),
m_bIgnoreMaskedDetectors(ignoreMaskedDetectors) {
this->build(m_noNeighbours);
}
......@@ -166,8 +167,8 @@ void WorkspaceNearestNeighbours::build(const int noNeighbours) {
ANNpoint scaledPos = dataPoints[pointNo];
annTree->annkSearch(scaledPos, // Point to search nearest neighbours of
m_noNeighbours, // Number of neighbours to find (8)
nnIndexList.data(), // Index list of results
nnDistList.data(), // List of distances to each of these
nnIndexList.data(), // Index list of results
nnDistList.data(), // List of distances to each of these
0.0 // Error bound (?) is this the radius to search in?
);
// The distances that are returned are in our scaled coordinate
......@@ -234,7 +235,8 @@ std::vector<size_t> WorkspaceNearestNeighbours::getSpectraDetectors() {
indices.reserve(nSpec);
for (size_t i = 0; i < nSpec; ++i) {
// Always ignore monitors and ignore masked detectors if requested.
const bool heedMasking = m_bIgnoreMaskedDetectors && m_spectrumInfo.isMasked(i);
const bool heedMasking =
m_bIgnoreMaskedDetectors && m_spectrumInfo.isMasked(i);
if (!m_spectrumInfo.isMonitor(i) && !heedMasking) {
indices.emplace_back(i);
}
......
......@@ -20,7 +20,8 @@ struct AreaInfo {
size_t wsIndex;
size_t binIndex;
double weight;
AreaInfo(const size_t xi, const size_t yi, const double w) : wsIndex(yi), binIndex(xi), weight(w) {}
AreaInfo(const size_t xi, const size_t yi, const double w)
: wsIndex(yi), binIndex(xi), weight(w) {}
};
/**
* Private function to calculate polygon area directly to avoid the overhead
......@@ -34,7 +35,7 @@ double polyArea(T &v1, T &v2, Ts &&... vertices) {
return v2.X() * v1.Y() - v2.Y() * v1.X() +
polyArea(v2, std::forward<Ts>(vertices)...);
}
}
} // namespace
namespace Mantid {
......@@ -108,7 +109,8 @@ bool getIntersectionRegion(const std::vector<double> &xAxis,
}
// Q region
start_it = std::upper_bound(verticalAxis.cbegin(), verticalAxis.cend(), yn_lo);
start_it =
std::upper_bound(verticalAxis.cbegin(), verticalAxis.cend(), yn_lo);
end_it = std::upper_bound(start_it, verticalAxis.cend(), yn_hi);
qstart = 0;
if (start_it != verticalAxis.begin()) {
......@@ -134,11 +136,12 @@ bool getIntersectionRegion(const std::vector<double> &xAxis,
* @param x_end The starting x-axis index
* @param areaInfos Output vector of indices and areas of overlapping bins
*/
void calcRectangleIntersections(
const std::vector<double> &xAxis, const std::vector<double> &yAxis,
const Quadrilateral &inputQ, const size_t y_start, const size_t y_end,
const size_t x_start, const size_t x_end,
std::vector<AreaInfo> &areaInfos) {
void calcRectangleIntersections(const std::vector<double> &xAxis,
const std::vector<double> &yAxis,
const Quadrilateral &inputQ,
const size_t y_start, const size_t y_end,
const size_t x_start, const size_t x_end,
std::vector<AreaInfo> &areaInfos) {
std::vector<double> width;
width.reserve(x_end - x_start);
for (size_t xi = x_start; xi < x_end; ++xi) {
......@@ -170,11 +173,12 @@ void calcRectangleIntersections(
* @param x_end The ending x-axis index
* @param areaInfos Output vector of indices and areas of overlapping bins
*/
void calcTrapezoidYIntersections(
const std::vector<double> &xAxis, const std::vector<double> &yAxis,
const Quadrilateral &inputQ, const size_t y_start, const size_t y_end,
const size_t x_start, const size_t x_end,
std::vector<AreaInfo> &areaInfos) {
void calcTrapezoidYIntersections(const std::vector<double> &xAxis,
const std::vector<double> &yAxis,
const Quadrilateral &inputQ,
const size_t y_start, const size_t y_end,
const size_t x_start, const size_t x_end,
std::vector<AreaInfo> &areaInfos) {
// The algorithm proceeds as follows:
// 1. Determine the left/right bin boundaries on the x- (horizontal)-grid.
// 2. Loop along x, for each 1-output-bin wide strip construct a new input Q.
......@@ -208,7 +212,8 @@ void calcTrapezoidYIntersections(
(ul_y >= yAxis[y_start] && ul_y <= yAxis[y_start + 1]) &&
(ur_y >= yAxis[y_start] && ur_y <= yAxis[y_start + 1]) &&
(lr_y >= yAxis[y_start] && lr_y <= yAxis[y_start + 1])) {
areaInfos.emplace_back(x_start, y_start, 0.5 * polyArea(ll, ul, ur, lr, ll));
areaInfos.emplace_back(x_start, y_start,
0.5 * polyArea(ll, ul, ur, lr, ll));
return;
}
......@@ -461,11 +466,12 @@ void calcTrapezoidYIntersections(
* @param x_end The starting x-axis index
* @param areaInfos Output vector of indices and areas of overlapping bins
*/
void calcGeneralIntersections(
const std::vector<double> &xAxis, const std::vector<double> &yAxis,
const Quadrilateral &inputQ, const size_t qstart, const size_t qend,
const size_t x_start, const size_t x_end,
std::vector<AreaInfo> &areaInfos) {
void calcGeneralIntersections(const std::vector<double> &xAxis,
const std::vector<double> &yAxis,
const Quadrilateral &inputQ, const size_t qstart,
const size_t qend, const size_t x_start,
const size_t x_end,
std::vector<AreaInfo> &areaInfos) {
ConvexPolygon intersectOverlap;
areaInfos.reserve((qend - qstart) * (x_end - x_start));
for (size_t yi = qstart; yi < qend; ++yi) {
......
......@@ -35,6 +35,7 @@ Bugfixes
########
- Fixed a bug in :ref:`DirectILLCollectData <algm-DirectILLCollectData>` which prevented the *OutputIncidentEnergyWorkspace* being generated if *IncidentEnergyCalibration* was turned off.
- Fixed the detector :math:`2\theta` width calculation in :ref:`SofQWNormalisedPolygon <algm-SofQWNormalisedPolygon>`. The algorithm was computing the angle between the detector center and top point, not the actual :math:`2\theta` width.
Interfaces
----------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment