Skip to content

Commit

Permalink
fix eta lines on both sides of the detector
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger committed Sep 24, 2024
1 parent d2a288f commit 2ac6ef3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions meta/src/display/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ svg::object eta_lines(
std::array<scalar, 2> end;
if (theta < theta_cut) {
end = {zr_, static_cast<scalar>(zr_ * std::tan(theta))};
} else if (theta > M_PI - theta_cut) {
end = {-zr_, static_cast<scalar>(-zr_ * std::tan(theta))};
} else {
end = {static_cast<scalar>(rr_ * 1 / std::tan(theta)), rr_};
}
Expand Down
39 changes: 36 additions & 3 deletions tests/meta/eta_lines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

using namespace actsvg;

TEST(meta, eta_lines) {
TEST(meta, eta_lines_positive_side) {

auto pg = test::playground({-300, -10}, {300, 120});

Expand Down Expand Up @@ -45,7 +45,40 @@ TEST(meta, eta_lines) {

etafile.add_object(eta_lines);
std::ofstream tstream;
tstream.open("test_display_eta_lines.svg");
tstream.open("test_display_eta_lines_ps.svg");
tstream << etafile;
tstream.close();
}
}

TEST(meta, eta_lines_full_detector) {

auto pg = test::playground({-300, -10}, {300, 120});

svg::file etafile;
etafile.add_object(pg);

scalar r = 120;
scalar z = 300;

std::vector<scalar> eta_main = { -3, -2, -1, 0, 1, 2, 3};
style::stroke stroke_main;
bool label_main = true;
style::font font_main;

std::vector<scalar> eta_half = {0.5, 1.5, 2.5};
style::stroke stroke_half;
stroke_half._dasharray = {2, 2};
bool label_half = false;
style::font font_half;

auto eta_lines = display::eta_lines(
"eta_lines_", z, r,
{std::tie(eta_main, stroke_main, label_main, font_main),
std::tie(eta_half, stroke_half, label_half, font_half)});

etafile.add_object(eta_lines);
std::ofstream tstream;
tstream.open("test_display_eta_lines_fd.svg");
tstream << etafile;
tstream.close();
}

0 comments on commit 2ac6ef3

Please sign in to comment.