ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
tracking.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s)
12#include "detray/plugins/svgtools/meta/proto/intersection.hpp"
13#include "detray/plugins/svgtools/meta/proto/landmark.hpp"
14#include "detray/plugins/svgtools/meta/proto/trajectory.hpp"
15
16// Actsvg include(s)
17#include "actsvg/core.hpp"
18
19// System include(s)
20#include <algorithm>
21#include <string>
22#include <vector>
23
24namespace detray::svgtools::meta::display {
25
27template <concepts::point3D point3_t, typename view_t>
28inline auto landmark(const std::string& id,
29 const svgtools::meta::proto::landmark<point3_t>& lm,
30 const view_t& view) {
31 const auto point_view = view(std::vector{lm._position}).at(0);
32 return actsvg::draw::marker(id, point_view, lm._marker);
33}
34
36template <concepts::point3D point3_t, typename view_t>
37inline auto intersection(
38 const std::string& id,
39 const svgtools::meta::proto::intersection<point3_t>& intr,
40 const view_t& view) {
41 actsvg::svg::object ret;
42 ret._tag = "g";
43 ret._id = id;
44 for (std::size_t index = 0; index < intr._landmarks.size(); index++) {
45 const auto lm = intr._landmarks.at(index);
46 const auto svg = svgtools::meta::display::landmark(
47 id + "_intersection_" + std::to_string(index), lm, view);
48 ret.add_object(svg);
49 }
50 return ret;
51}
52
54template <concepts::point3D point3_t, typename view_t>
55inline auto trajectory(
56 const std::string& id,
57 const svgtools::meta::proto::trajectory<point3_t>& p_trajectory,
58 const view_t& view) {
59 std::vector<actsvg::point2> points;
60 auto change_view = [view](const point3_t& p) {
61 return view(std::vector{p}).at(0);
62 };
63 std::ranges::transform(p_trajectory._points, std::back_inserter(points),
64 change_view);
65 actsvg::svg::object ret;
66 ret._tag = "g";
67 ret._id = id;
68 for (std::size_t i = 0; i < points.size() - 1; i++) {
69 // TODO: use smooth curves instead of lines.
70 const auto l = actsvg::draw::line(id, points.at(i), points.at(i + 1),
71 p_trajectory._stroke);
72 ret.add_object(l);
73 }
74 return ret;
75}
76
77} // namespace detray::svgtools::meta::display