Skip to content
Snippets Groups Projects
Commit 6442d617 authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

Replaced int with size_t in RectangularDetector constructor

parent 4c8dd284
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "MathConstants.h" #include "MathConstants.h"
#include "Units.h" #include "Units.h"
RectangularDetector::RectangularDetector(int nxbins, double width, int nybins, double height) RectangularDetector::RectangularDetector(size_t nxbins, double width, size_t nybins, double height)
: m_u0(0.0) : m_u0(0.0)
, m_v0(0.0) , m_v0(0.0)
, m_direction(kvector_t(0.0, -1.0, 0.0)) , m_direction(kvector_t(0.0, -1.0, 0.0))
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
//! @param width Width of the detector in mm along x-direction //! @param width Width of the detector in mm along x-direction
//! @param nybins Number of bins (pixels) in y-direction //! @param nybins Number of bins (pixels) in y-direction
//! @param height Height of the detector in mm along y-direction //! @param height Height of the detector in mm along y-direction
RectangularDetector(int nxbins, double width, int nybins, double height); RectangularDetector(size_t nxbins, double width, size_t nybins, double height);
RectangularDetector(const RectangularDetector& other); RectangularDetector(const RectangularDetector& other);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <memory> #include <memory>
namespace { namespace {
const int rdet_nbinsx(40), rdet_nbinsy(30); const size_t rdet_nbinsx(40), rdet_nbinsy(30);
const double rdet_width(20.0), rdet_height(18.0), rdet_distance(1000.0); const double rdet_width(20.0), rdet_height(18.0), rdet_distance(1000.0);
} }
......
...@@ -146,11 +146,11 @@ std::unique_ptr<IDetector2D> RectangularDetectorItem::createDomainDetector() con ...@@ -146,11 +146,11 @@ std::unique_ptr<IDetector2D> RectangularDetectorItem::createDomainDetector() con
{ {
// basic axes parameters // basic axes parameters
auto& x_axis = item<BasicAxisItem>(RectangularDetectorItem::P_X_AXIS); auto& x_axis = item<BasicAxisItem>(RectangularDetectorItem::P_X_AXIS);
int n_x = x_axis.getItemValue(BasicAxisItem::P_NBINS).toInt(); size_t n_x = x_axis.getItemValue(BasicAxisItem::P_NBINS).toUInt();
double width = x_axis.getItemValue(BasicAxisItem::P_MAX).toDouble(); double width = x_axis.getItemValue(BasicAxisItem::P_MAX).toDouble();
auto& y_axis = item<BasicAxisItem>(RectangularDetectorItem::P_Y_AXIS); auto& y_axis = item<BasicAxisItem>(RectangularDetectorItem::P_Y_AXIS);
int n_y = y_axis.getItemValue(BasicAxisItem::P_NBINS).toInt(); size_t n_y = y_axis.getItemValue(BasicAxisItem::P_NBINS).toUInt();
double height = y_axis.getItemValue(BasicAxisItem::P_MAX).toDouble(); double height = y_axis.getItemValue(BasicAxisItem::P_MAX).toDouble();
std::unique_ptr<RectangularDetector> result(new RectangularDetector(n_x, width, n_y, height)); std::unique_ptr<RectangularDetector> result(new RectangularDetector(n_x, width, n_y, height));
......
...@@ -31,7 +31,7 @@ std::unique_ptr<Simulation> RectDetectorFitTest::createSimulation() ...@@ -31,7 +31,7 @@ std::unique_ptr<Simulation> RectDetectorFitTest::createSimulation()
double detector_distance(500.0); double detector_distance(500.0);
double width(20.0), height(18.0); double width(20.0), height(18.0);
RectangularDetector detector(20, width, 18, height); RectangularDetector detector(20u, width, 18u, height);
// RectangularDetector detector(500, width, 450, height); // RectangularDetector detector(500, width, 450, height);
detector.setPerpendicularToSampleX(detector_distance, width/2., 0.0); detector.setPerpendicularToSampleX(detector_distance, width/2., 0.0);
......
...@@ -36,10 +36,10 @@ RectangularDetectorTest::~RectangularDetectorTest() = default; ...@@ -36,10 +36,10 @@ RectangularDetectorTest::~RectangularDetectorTest() = default;
TEST_F(RectangularDetectorTest, InitialState) TEST_F(RectangularDetectorTest, InitialState)
{ {
RectangularDetector det(50, 10.0, 60, 20.0); RectangularDetector det(50u, 10.0, 60u, 20.0);
EXPECT_EQ(size_t(50), det.getNbinsX()); EXPECT_EQ(50u, det.getNbinsX());
EXPECT_EQ(10.0, det.getWidth()); EXPECT_EQ(10.0, det.getWidth());
EXPECT_EQ(size_t(60), det.getNbinsY()); EXPECT_EQ(60u, det.getNbinsY());
EXPECT_EQ(20.0, det.getHeight()); EXPECT_EQ(20.0, det.getHeight());
EXPECT_EQ(0.0, det.getU0()); EXPECT_EQ(0.0, det.getU0());
...@@ -54,7 +54,7 @@ TEST_F(RectangularDetectorTest, InitialState) ...@@ -54,7 +54,7 @@ TEST_F(RectangularDetectorTest, InitialState)
TEST_F(RectangularDetectorTest, Clone) TEST_F(RectangularDetectorTest, Clone)
{ {
RectangularDetector det(50, 10.0, 60, 20.0); RectangularDetector det(50u, 10.0, 60u, 20.0);
kvector_t normal(10.0, 20.0, 30.0); kvector_t normal(10.0, 20.0, 30.0);
kvector_t direction(1.0, 2.0, 3.0); kvector_t direction(1.0, 2.0, 3.0);
double u0(88.0), v0(99.0); double u0(88.0), v0(99.0);
...@@ -70,7 +70,7 @@ TEST_F(RectangularDetectorTest, Clone) ...@@ -70,7 +70,7 @@ TEST_F(RectangularDetectorTest, Clone)
TEST_F(RectangularDetectorTest, PerpToSample) TEST_F(RectangularDetectorTest, PerpToSample)
{ {
int nbinsx(5), nbinsy(4); size_t nbinsx(5u), nbinsy(4u);
double width(50.0), height(40.0); double width(50.0), height(40.0);
double distance(100.0), u0(20.0), v0(10.0); double distance(100.0), u0(20.0), v0(10.0);
double dx = width / nbinsx; double dx = width / nbinsx;
...@@ -96,7 +96,7 @@ TEST_F(RectangularDetectorTest, PerpToSample) ...@@ -96,7 +96,7 @@ TEST_F(RectangularDetectorTest, PerpToSample)
std::vector<SimulationElement> elements std::vector<SimulationElement> elements
= det.createSimulationElements(simulation.getInstrument().getBeam()); = det.createSimulationElements(simulation.getInstrument().getBeam());
EXPECT_EQ(elements.size(), size_t(nbinsx * nbinsy)); EXPECT_EQ(elements.size(), nbinsx * nbinsy);
// lower left bin // lower left bin
kvector_t k(distance, u0 - dx / 2., (-v0 + dy / 2.)); kvector_t k(distance, u0 - dx / 2., (-v0 + dy / 2.));
...@@ -125,7 +125,7 @@ TEST_F(RectangularDetectorTest, PerpToSample) ...@@ -125,7 +125,7 @@ TEST_F(RectangularDetectorTest, PerpToSample)
TEST_F(RectangularDetectorTest, PerpToDirectBeam) TEST_F(RectangularDetectorTest, PerpToDirectBeam)
{ {
int nbinsx(5), nbinsy(4); size_t nbinsx(5u), nbinsy(4u);
double width(50.0), height(40.0); double width(50.0), height(40.0);
double distance(100.0), u0(20.0), v0(10.0); double distance(100.0), u0(20.0), v0(10.0);
double dx = width / nbinsx; double dx = width / nbinsx;
...@@ -153,7 +153,7 @@ TEST_F(RectangularDetectorTest, PerpToDirectBeam) ...@@ -153,7 +153,7 @@ TEST_F(RectangularDetectorTest, PerpToDirectBeam)
std::vector<SimulationElement> elements std::vector<SimulationElement> elements
= det.createSimulationElements(simulation.getInstrument().getBeam()); = det.createSimulationElements(simulation.getInstrument().getBeam());
EXPECT_EQ(elements.size(), size_t(nbinsx * nbinsy)); EXPECT_EQ(elements.size(), nbinsx * nbinsy);
// lower left bin // lower left bin
double ds = v0 - dy / 2.; double ds = v0 - dy / 2.;
...@@ -168,7 +168,7 @@ TEST_F(RectangularDetectorTest, PerpToDirectBeam) ...@@ -168,7 +168,7 @@ TEST_F(RectangularDetectorTest, PerpToDirectBeam)
TEST_F(RectangularDetectorTest, PerpToReflectedBeam) TEST_F(RectangularDetectorTest, PerpToReflectedBeam)
{ {
int nbinsx(5), nbinsy(4); size_t nbinsx(5u), nbinsy(4u);
double width(50.0), height(40.0); double width(50.0), height(40.0);
double distance(100.0), u0(20.0), v0(10.0); double distance(100.0), u0(20.0), v0(10.0);
double dx = width / nbinsx; double dx = width / nbinsx;
...@@ -197,7 +197,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeam) ...@@ -197,7 +197,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeam)
// checking detector elements // checking detector elements
std::vector<SimulationElement> elements std::vector<SimulationElement> elements
= det.createSimulationElements(simulation.getInstrument().getBeam()); = det.createSimulationElements(simulation.getInstrument().getBeam());
EXPECT_EQ(elements.size(), size_t(nbinsx * nbinsy)); EXPECT_EQ(elements.size(), nbinsx * nbinsy);
double ds = v0 - dy / 2.; double ds = v0 - dy / 2.;
double alpha_x = alpha_i - std::atan(ds / distance); double alpha_x = alpha_i - std::atan(ds / distance);
...@@ -213,7 +213,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeam) ...@@ -213,7 +213,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeam)
// detector perpendicular to reflected beam, when direct beam position is known // detector perpendicular to reflected beam, when direct beam position is known
TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos) TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos)
{ {
int nbinsx(5), nbinsy(4); size_t nbinsx(5u), nbinsy(4u);
double width(50.0), height(40.0); double width(50.0), height(40.0);
double distance(100.0), u0(20.0), v0(10.0); double distance(100.0), u0(20.0), v0(10.0);
double dx = width / nbinsx; double dx = width / nbinsx;
...@@ -255,7 +255,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos) ...@@ -255,7 +255,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos)
// checking detector elements // checking detector elements
std::vector<SimulationElement> elements std::vector<SimulationElement> elements
= det.createSimulationElements(simulation.getInstrument().getBeam()); = det.createSimulationElements(simulation.getInstrument().getBeam());
EXPECT_EQ(elements.size(), size_t(nbinsx * nbinsy)); EXPECT_EQ(elements.size(), nbinsx * nbinsy);
double ds = v0 - dy / 2.; double ds = v0 - dy / 2.;
double alpha_x = alpha_i - std::atan(ds / distance); double alpha_x = alpha_i - std::atan(ds / distance);
...@@ -271,7 +271,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos) ...@@ -271,7 +271,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos)
// Test retrieval of analyzer properties // Test retrieval of analyzer properties
TEST_F(RectangularDetectorTest, AnalyzerProperties) TEST_F(RectangularDetectorTest, AnalyzerProperties)
{ {
RectangularDetector detector(50, 10.0, 60, 20.0); RectangularDetector detector(50u, 10.0, 60u, 20.0);
kvector_t direction; kvector_t direction;
double efficiency = 0.0; double efficiency = 0.0;
......
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