Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimitivesView3DBase.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrimitivesView3DBase.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 
27 namespace PrimitivesView3DTest {
28 
29 // Test on a plane
30 auto identity = Transform3::Identity();
31 auto rectangle = std::make_shared<RectangleBounds>(10., 10.);
32 auto plane = Surface::makeShared<PlaneSurface>(identity, rectangle);
33 
34 // Test context
36 
42 static inline std::string run(IVisualization3D& helper) {
43  std::stringstream ss;
44 
45  ViewConfig lineView({0, 0, 255});
46  lineView.lineThickness = 0.1;
47 
48  // Line visualization ------------------------------------------------
49  Vector3 start = {1., 1., 1.};
50  Vector3 end = {4., 4., 4.};
51  Acts::GeometryView3D::drawSegment(helper, start, end);
52  helper.write("Primitives_Line");
53  helper.write(ss);
54  helper.clear();
55 
56  // Arrows visualization ------------------------------------------------
57  start = {1., 0., 0.};
58  end = {4., 0., 0.};
59  Acts::GeometryView3D::drawArrowForward(helper, start, end, 3., 2., lineView);
60 
61  start = {1., 2., 0.};
62  end = {4., 2., 0.};
63  Acts::GeometryView3D::drawArrowBackward(helper, start, end, 3., 2., lineView);
64 
65  start = {1., 4., 0.};
66  end = {4., 4., 0.};
67  Acts::GeometryView3D::drawArrowsBoth(helper, start, end, 3., 2., lineView);
68 
69  helper.write("Primitives_Arrows");
70  helper.write(ss);
71  helper.clear();
72 
73  // Error visualization: local ---------------------------------------------
75 
76  ViewConfig errorVis({250, 0, 0});
77  errorVis.lineThickness = 0.025;
78 
79  SquareMatrix2 cov = SquareMatrix2::Identity();
80  double s0 = 0.75;
81  double s1 = 1.99;
82  double r01 = 0.78;
83  cov << s0 * s0, r01 * s0 * s1, r01 * s0 * s1, s1 * s1;
84 
85  Vector2 lcentered{0., 0.};
87  helper, lcentered, cov, plane->transform(gctx), 1.0, errorVis);
88 
89  helper.write("Primitives_CartesianError");
90  helper.write(ss);
91  helper.clear();
92 
93  // Error visualization: angular ---------------------------------------------
95  cov = SquareMatrix2::Identity();
96  s0 = 0.08;
97  s1 = 0.035;
98  r01 = 0.3;
99  cov << s0 * s0, r01 * s0 * s1, r01 * s0 * s1, s1 * s1;
100 
101  Vector3 origin{0., 0., 0.};
102  Vector3 direction = Vector3(1., 3., 15.).normalized();
103 
104  double directionScale = 5.;
105 
107  directionScale, 10., errorVis);
108 
110  helper, origin + 0.5 * directionScale * direction,
111  origin + 1.2 * directionScale * direction, 3., 2., errorVis);
112 
113  helper.write("Primitives_AngularError");
114  helper.write(ss);
115  helper.clear();
116 
117  return ss.str();
118 }
119 
120 } // namespace PrimitivesView3DTest
121 } // namespace Acts