Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventDataView3D.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EventDataView3D.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020-2021 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 
10 
14 
15 #include <cmath>
16 #include <utility>
17 
18 namespace Acts {
19 class IVisualization3D;
20 } // namespace Acts
21 
23  IVisualization3D& helper, const Vector2& lposition,
25  double locErrorScale, const ViewConfig& viewConfig) {
26  auto [lambda0, lambda1, theta] = decomposeCovariance(covariance);
27 
28  std::vector<Vector3> ellipse = createEllipse(
29  lambda0 * locErrorScale, lambda1 * locErrorScale, theta,
30  viewConfig.nSegments, viewConfig.offset, lposition, transform);
31 
32  ellipse.push_back(transform *
33  Vector3(lposition.x(), lposition.y(), viewConfig.offset));
34  auto faces = detail::FacesHelper::convexFaceMesh(ellipse, true);
35  Polyhedron ellipseHedron(ellipse, faces.first, faces.second);
36  Acts::GeometryView3D::drawPolyhedron(helper, ellipseHedron, viewConfig);
37 }
38 
40  IVisualization3D& helper, const Vector3& position, const Vector3& direction,
41  const ActsSquareMatrix<2>& covariance, double directionScale,
42  double angularErrorScale, const ViewConfig& viewConfig) {
43  auto [lambda0, lambda1, theta] = decomposeCovariance(covariance);
44 
45  // Anker point
46  Vector3 anker = position + directionScale * direction;
47 
48  double dphi = VectorHelpers::phi(direction);
49  double dtheta = VectorHelpers::theta(direction);
50 
51  Transform3 eplane(Translation3(anker) *
52  AngleAxis3(dphi, Vector3(0., 0., 1.)) *
53  AngleAxis3(dtheta, Vector3(0., 1., 0.)));
54 
55  // Now generate the ellipse points
56  std::vector<Vector3> ellipse =
57  createEllipse(angularErrorScale * directionScale * lambda0 * sin(dtheta),
58  angularErrorScale * directionScale * lambda1, theta,
59  viewConfig.nSegments, 0., {0., 0.}, eplane);
60 
61  std::vector<Vector3> coneTop = ellipse;
62  coneTop.push_back(anker);
63  auto coneTopFaces = detail::FacesHelper::convexFaceMesh(coneTop, true);
64  Polyhedron coneTopHedron(coneTop, coneTopFaces.first, coneTopFaces.second);
65  GeometryView3D::drawPolyhedron(helper, coneTopHedron, viewConfig);
66 
67  std::vector<Vector3> cone = ellipse;
68  cone.push_back(position);
69  // Force triangular
70  ViewConfig coneViewConfig = viewConfig;
71  coneViewConfig.triangulate = true;
72  auto coneFaces = detail::FacesHelper::convexFaceMesh(cone, true);
73  Polyhedron coneHedron(cone, coneFaces.first, coneFaces.second);
74  GeometryView3D::drawPolyhedron(helper, coneHedron, coneViewConfig);
75 }