mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-06 12:50:40 +02:00
enum is now enum class
This commit is contained in:
parent
fca9d5d2fa
commit
d4050ec557
@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
namespace aare {
|
namespace aare {
|
||||||
|
|
||||||
typedef enum {
|
enum class corner : int {
|
||||||
cBottomLeft = 0,
|
cBottomLeft = 0,
|
||||||
cBottomRight = 1,
|
cBottomRight = 1,
|
||||||
cTopLeft = 2,
|
cTopLeft = 2,
|
||||||
cTopRight = 3
|
cTopRight = 3
|
||||||
} corner;
|
};
|
||||||
|
|
||||||
typedef enum {
|
enum class pixel : int {
|
||||||
pBottomLeft = 0,
|
pBottomLeft = 0,
|
||||||
pBottom = 1,
|
pBottom = 1,
|
||||||
pBottomRight = 2,
|
pBottomRight = 2,
|
||||||
@ -23,7 +23,7 @@ typedef enum {
|
|||||||
pTopLeft = 6,
|
pTopLeft = 6,
|
||||||
pTop = 7,
|
pTop = 7,
|
||||||
pTopRight = 8
|
pTopRight = 8
|
||||||
} pixel;
|
};
|
||||||
|
|
||||||
template <typename T> struct Eta2 {
|
template <typename T> struct Eta2 {
|
||||||
double x;
|
double x;
|
||||||
@ -132,7 +132,8 @@ Eta2<T> calculate_eta2(const Cluster<T, 2, 2, int16_t> &cl) {
|
|||||||
if ((cl.data[0] + cl.data[2]) != 0)
|
if ((cl.data[0] + cl.data[2]) != 0)
|
||||||
eta.y = static_cast<double>(cl.data[2]) / (cl.data[0] + cl.data[2]);
|
eta.y = static_cast<double>(cl.data[2]) / (cl.data[0] + cl.data[2]);
|
||||||
eta.sum = cl.sum();
|
eta.sum = cl.sum();
|
||||||
eta.c = cBottomLeft; // TODO! This is not correct, but need to put something
|
eta.c = static_cast<int>(corner::cBottomLeft); // TODO! This is not correct,
|
||||||
|
// but need to put something
|
||||||
return eta;
|
return eta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,20 +70,20 @@ Interpolator::interpolate(const ClusterVector<ClusterType> &clusters) {
|
|||||||
// cBottomRight = 1,
|
// cBottomRight = 1,
|
||||||
// cTopLeft = 2,
|
// cTopLeft = 2,
|
||||||
// cTopRight = 3
|
// cTopRight = 3
|
||||||
switch (eta.c) {
|
switch (static_cast<corner>(eta.c)) {
|
||||||
case cTopLeft:
|
case corner::cTopLeft:
|
||||||
dX = -1.;
|
dX = -1.;
|
||||||
dY = 0;
|
dY = 0;
|
||||||
break;
|
break;
|
||||||
case cTopRight:;
|
case corner::cTopRight:;
|
||||||
dX = 0;
|
dX = 0;
|
||||||
dY = 0;
|
dY = 0;
|
||||||
break;
|
break;
|
||||||
case cBottomLeft:
|
case corner::cBottomLeft:
|
||||||
dX = -1.;
|
dX = -1.;
|
||||||
dY = -1.;
|
dY = -1.;
|
||||||
break;
|
break;
|
||||||
case cBottomRight:
|
case corner::cBottomRight:
|
||||||
dX = 0.;
|
dX = 0.;
|
||||||
dY = -1.;
|
dY = -1.;
|
||||||
break;
|
break;
|
||||||
|
@ -21,10 +21,12 @@ using ClusterTypes =
|
|||||||
auto get_test_parameters() {
|
auto get_test_parameters() {
|
||||||
return GENERATE(
|
return GENERATE(
|
||||||
std::make_tuple(ClusterTypes{Cluster<int, 2, 2>{0, 0, {1, 2, 3, 1}}},
|
std::make_tuple(ClusterTypes{Cluster<int, 2, 2>{0, 0, {1, 2, 3, 1}}},
|
||||||
Eta2<int>{2. / 3, 3. / 4, corner::cBottomLeft, 7}),
|
Eta2<int>{2. / 3, 3. / 4,
|
||||||
|
static_cast<int>(corner::cBottomLeft), 7}),
|
||||||
std::make_tuple(
|
std::make_tuple(
|
||||||
ClusterTypes{Cluster<int, 3, 3>{0, 0, {1, 2, 3, 4, 5, 6, 1, 2, 7}}},
|
ClusterTypes{Cluster<int, 3, 3>{0, 0, {1, 2, 3, 4, 5, 6, 1, 2, 7}}},
|
||||||
Eta2<int>{6. / 11, 2. / 7, corner::cTopRight, 20}),
|
Eta2<int>{6. / 11, 2. / 7, static_cast<int>(corner::cTopRight),
|
||||||
|
20}),
|
||||||
std::make_tuple(ClusterTypes{Cluster<int, 5, 5>{
|
std::make_tuple(ClusterTypes{Cluster<int, 5, 5>{
|
||||||
0, 0, {1, 6, 7, 6, 5, 4, 3, 2, 1, 2, 8, 9, 8,
|
0, 0, {1, 6, 7, 6, 5, 4, 3, 2, 1, 2, 8, 9, 8,
|
||||||
1, 4, 5, 6, 7, 8, 4, 1, 1, 1, 1, 1}}},
|
1, 4, 5, 6, 7, 8, 4, 1, 1, 1, 1, 1}}},
|
||||||
@ -61,14 +63,13 @@ TEST_CASE("calculate_eta2", "[eta_calculation]") {
|
|||||||
CHECK(eta.sum == expected_eta.sum);
|
CHECK(eta.sum == expected_eta.sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3x3 cluster layout (rotated to match the cBottomLeft enum):
|
||||||
|
// 6, 7, 8
|
||||||
|
// 3, 4, 5
|
||||||
|
// 0, 1, 2
|
||||||
|
|
||||||
//3x3 cluster layout (rotated to match the cBottomLeft enum):
|
TEST_CASE("Calculate eta2 for a 3x3 int32 cluster with the largest 2x2 sum in "
|
||||||
// 6, 7, 8
|
"the bottom left",
|
||||||
// 3, 4, 5
|
|
||||||
// 0, 1, 2
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Calculate eta2 for a 3x3 int32 cluster with the largest 2x2 sum in the bottom left",
|
|
||||||
"[eta_calculation]") {
|
"[eta_calculation]") {
|
||||||
|
|
||||||
// Create a 3x3 cluster
|
// Create a 3x3 cluster
|
||||||
@ -84,45 +85,43 @@ TEST_CASE("Calculate eta2 for a 3x3 int32 cluster with the largest 2x2 sum in th
|
|||||||
cl.data[6] = 8;
|
cl.data[6] = 8;
|
||||||
cl.data[7] = 2;
|
cl.data[7] = 2;
|
||||||
cl.data[8] = 3;
|
cl.data[8] = 3;
|
||||||
|
|
||||||
// 8, 2, 3
|
// 8, 2, 3
|
||||||
// 20, 50, 3
|
// 20, 50, 3
|
||||||
// 30, 23, 5
|
// 30, 23, 5
|
||||||
|
|
||||||
auto eta = calculate_eta2(cl);
|
auto eta = calculate_eta2(cl);
|
||||||
CHECK(eta.c == corner::cBottomLeft);
|
CHECK(eta.c == static_cast<int>(corner::cBottomLeft));
|
||||||
CHECK(eta.x == 50.0 / (20 + 50)); // 4/(3+4)
|
CHECK(eta.x == 50.0 / (20 + 50)); // 4/(3+4)
|
||||||
CHECK(eta.y == 50.0 / (23 + 50)); // 4/(1+4)
|
CHECK(eta.y == 50.0 / (23 + 50)); // 4/(1+4)
|
||||||
CHECK(eta.sum == 30+23+20+50);
|
CHECK(eta.sum == 30 + 23 + 20 + 50);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Calculate eta2 for a 3x3 int32 cluster with the largest 2x2 sum in the top left",
|
TEST_CASE("Calculate eta2 for a 3x3 int32 cluster with the largest 2x2 sum in "
|
||||||
"[eta_calculation]") {
|
"the top left",
|
||||||
|
"[eta_calculation]") {
|
||||||
|
|
||||||
// Create a 3x3 cluster
|
// Create a 3x3 cluster
|
||||||
Cluster<int32_t, 3, 3> cl;
|
Cluster<int32_t, 3, 3> cl;
|
||||||
cl.x = 0;
|
cl.x = 0;
|
||||||
cl.y = 0;
|
cl.y = 0;
|
||||||
cl.data[0] = 8;
|
cl.data[0] = 8;
|
||||||
cl.data[1] = 12;
|
cl.data[1] = 12;
|
||||||
cl.data[2] = 5;
|
cl.data[2] = 5;
|
||||||
cl.data[3] = 77;
|
cl.data[3] = 77;
|
||||||
cl.data[4] = 80;
|
cl.data[4] = 80;
|
||||||
cl.data[5] = 3;
|
cl.data[5] = 3;
|
||||||
cl.data[6] = 82;
|
cl.data[6] = 82;
|
||||||
cl.data[7] = 91;
|
cl.data[7] = 91;
|
||||||
cl.data[8] = 3;
|
cl.data[8] = 3;
|
||||||
|
|
||||||
// 82, 91, 3
|
// 82, 91, 3
|
||||||
// 77, 80, 3
|
// 77, 80, 3
|
||||||
// 8, 12, 5
|
// 8, 12, 5
|
||||||
|
|
||||||
auto eta = calculate_eta2(cl);
|
|
||||||
CHECK(eta.c == corner::cTopLeft);
|
|
||||||
CHECK(eta.x == 80. / (77 + 80)); // 4/(3+4)
|
|
||||||
CHECK(eta.y == 91.0 / (91 + 80)); // 7/(7+4)
|
|
||||||
CHECK(eta.sum == 77+80+82+91);
|
|
||||||
|
|
||||||
|
auto eta = calculate_eta2(cl);
|
||||||
|
CHECK(eta.c == static_cast<int>(corner::cTopLeft));
|
||||||
|
CHECK(eta.x == 80. / (77 + 80)); // 4/(3+4)
|
||||||
|
CHECK(eta.y == 91.0 / (91 + 80)); // 7/(7+4)
|
||||||
|
CHECK(eta.sum == 77 + 80 + 82 + 91);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user