ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimitivesVisualizationBase.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrimitivesVisualizationBase.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
20 
21 #include <fstream>
22 #include <sstream>
23 #include <string>
24 
25 namespace Acts {
26 namespace PrimitivesVisualization {
27 
28 // Test on a plane
29 auto identity = std::make_shared<Transform3D>(Transform3D::Identity());
30 auto rectangle = std::make_shared<RectangleBounds>(10., 10.);
31 auto plane = Surface::makeShared<PlaneSurface>(identity, rectangle);
32 
33 // Test context
35 
41 static inline std::string test(IVisualization& helper) {
42  std::stringstream ss;
43 
44  // Line visualization ------------------------------------------------
45  IVisualization::ColorType lineColor = {0, 0, 250};
46  Vector3D start = {1., 1., 1.};
47  Vector3D end = {4., 4., 4.};
48  Acts::Visualization::drawSegment(helper, start, end, 0.1, 72, lineColor);
49  helper.write("Primitives_Line");
50  helper.write(ss);
51  helper.write(ss);
52  helper.clear();
53 
54  // Arrows visualization ------------------------------------------------
55  start = {1., 0., 0.};
56  end = {4., 0., 0.};
57  Acts::Visualization::drawArrowForward(helper, start, end, 0.1, 0.1, 3., 72,
58  {0, 75, 0});
59 
60  start = {1., 2., 0.};
61  end = {4., 2., 0.};
62  Acts::Visualization::drawArrowBackward(helper, start, end, 0.1, 0.1, 3., 72,
63  {0, 150, 0});
64 
65  start = {1., 4., 0.};
66  end = {4., 4., 0.};
67  Acts::Visualization::drawArrowsBoth(helper, start, end, 0.1, 0.1, 3., 72,
68  {0, 250, 0});
69  helper.write("Primitives_Arrows");
70  helper.write(ss);
71  helper.clear();
72 
73  // Error visualization: local ---------------------------------------------
74  IVisualization::ColorType surfaceColor = {120, 250, 0};
76  helper, *plane, gctx, Transform3D::Identity(), 72, false, surfaceColor);
77 
78  IVisualization::ColorType errorColor = {250, 0, 0};
79 
81  double s0 = 0.45;
82  double s1 = 1.99;
83  double r01 = 0.78;
84  cov << s0 * s0, r01 * s0 * s1, r01 * s0 * s1, s1 * s1;
85 
86  Vector2D lcentered{0., 0.};
88  helper, lcentered, cov, plane->transform(gctx), {3}, 10., 72, errorColor);
89 
90  helper.write("Primitives_CartesianError");
91  helper.write(ss);
92  helper.clear();
93 
94  // Error visualization: angular ---------------------------------------------
96  helper, *plane, gctx, Transform3D::Identity(), 72, false, surfaceColor);
97 
98  // Error visualization
99  errorColor = {250, 0, 0};
100 
102  s0 = 0.08;
103  s1 = 0.01;
104  r01 = 0.3;
105  cov << s0 * s0, r01 * s0 * s1, r01 * s0 * s1, s1 * s1;
106 
107  Vector3D origin{0., 0., 0.};
108  Vector3D direction = Vector3D(1., 3., 15.).normalized();
109 
110  double directionScale = 5.;
111 
113  helper, origin, direction, cov, {3}, directionScale, 10., 72, errorColor);
114 
116  helper, origin + 0.5 * directionScale * direction,
117  origin + 1.2 * directionScale * direction, 0.02, 0.1, 5., 72,
118  {10, 10, 10});
119 
120  helper.write("Primitives_AngularError");
121  helper.write(ss);
122  helper.clear();
123 
124  return ss.str();
125 }
126 
127 } // namespace PrimitivesVisualization
128 } // namespace Acts