Mantid
Loading...
Searching...
No Matches
WorkspaceBoundingBox.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
11#include "MantidHistogramData/Histogram.h"
12#include "MantidKernel/Logger.h"
13#include "MantidKernel/V3D.h"
14
15namespace Mantid {
16namespace Algorithms {
17namespace {
18// static logger
19Kernel::Logger g_log("WorkspaceBoundingBox");
20} // namespace
21
22/* This is a simple class originally intended for use solely with FindCenterOfMassPosition2.cpp
23 *
24 */
26public:
30
32 double getX() const { return x; }
33 double getY() const { return y; }
34 double getCenterX() const { return centerX; }
35 double getCenterY() const { return centerY; }
36 double getXMin() const { return xMin; }
37 double getXMax() const { return xMax; }
38 double getYMin() const { return yMin; }
39 double getYMax() const { return yMax; }
40
41 void setPosition(double x, double y);
42 void setCenter(double x, double y);
43 void setBounds(double xMin, double xMax, double yMin, double yMax);
44
45 double calculateDistance() const;
46 double calculateRadiusX() const;
47 double calculateRadiusY() const;
48
50 int findFirstValidWs(const int numSpec) const;
51 bool isValidWs(int index) const;
52 bool isOutOfBoundsOfNonDirectBeam(const double beamRadius, int index, const bool directBeam);
53 bool containsPoint(double x, double y);
54 void normalizePosition(double x, double y);
55 void updateMinMax(int index);
56
57private:
58 Kernel::V3D &position(int index) const;
59 double yValue(const int index) const;
62 double x{0};
63 double y{0};
64 double centerX{0};
65 double centerY{0};
66 double xMin{0};
67 double xMax{0};
68 double yMin{0};
69 double yMax{0};
70 // cache information
71 mutable int m_cachedPositionIndex{-1};
73 mutable int m_cachedHistogramYIndex{-1};
74 mutable double m_cachedYValue;
75};
76
77} // namespace Algorithms
78} // namespace Mantid
double position
Definition: GetAllEi.cpp:154
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
void(ComponentInfo::* setPosition)(const size_t, const Mantid::Kernel::V3D &)
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Definition: SpectrumInfo.h:53
bool isValidWs(int index) const
Performs checks on the spectrum located at index to determine if it is acceptable to be operated on.
API::MatrixWorkspace_const_sptr m_workspace
void updateMinMax(int index)
Compare current mins and maxs to the coordinates of the spectrum at index expnd mins and maxs to incl...
bool isOutOfBoundsOfNonDirectBeam(const double beamRadius, int index, const bool directBeam)
Checks to see if spectrum at index is within the diameter of the given beamRadius.
void setBounds(double xMin, double xMax, double yMin, double yMax)
void normalizePosition(double x, double y)
Perform normalization on x/y coords over given values.
double updatePositionAndReturnCount(int index)
Sets member variables x/y to new x/y based on spectrum info and historgram data at the given index.
bool containsPoint(double x, double y)
Checks if a given x/y coord is within the bounding box.
int findFirstValidWs(const int numSpec) const
Searches for the first valid spectrum info in member variable workspace
API::MatrixWorkspace_const_sptr getWorkspace()
Class for 3D vectors.
Definition: V3D.h:34
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
Helper class which provides the Collimation Length for SANS instruments.