EIC 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 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 
12  IVisualization3D& helper, const Vector2D& lposition,
13  const ActsSymMatrixD<2>& covariance, const Transform3D& transform,
14  double locErrorScale, const ViewConfig& viewConfig) {
15  auto [lambda0, lambda1, theta] = decomposeCovariance(covariance);
16 
17  std::vector<Vector3D> ellipse = createEllipse(
18  lambda0 * locErrorScale, lambda1 * locErrorScale, theta,
19  viewConfig.nSegments, viewConfig.offset, lposition, transform);
20 
21  ellipse.push_back(transform *
22  Vector3D(lposition.x(), lposition.y(), viewConfig.offset));
23  auto faces = detail::FacesHelper::convexFaceMesh(ellipse, true);
24  Polyhedron ellipseHedron(ellipse, faces.first, faces.second);
25  Acts::GeometryView3D::drawPolyhedron(helper, ellipseHedron, viewConfig);
26 }
27 
29  IVisualization3D& helper, const Vector3D& position,
30  const Vector3D& direction, const ActsSymMatrixD<2>& covariance,
31  double directionScale, double angularErrorScale,
32  const ViewConfig& viewConfig) {
33  auto [lambda0, lambda1, theta] = decomposeCovariance(covariance);
34 
35  // Anker point
36  Vector3D anker = position + directionScale * direction;
37 
38  double dphi = VectorHelpers::phi(direction);
39  double dtheta = VectorHelpers::theta(direction);
40 
41  Transform3D eplane(Translation3D(anker) *
42  AngleAxis3D(dtheta, Vector3D(1., 0., 0.)) *
43  AngleAxis3D(dphi, Vector3D(0., 0., 1.)));
44 
45  // Now generate the ellipse points
46  std::vector<Vector3D> ellipse =
47  createEllipse(angularErrorScale * directionScale * tan(lambda0),
48  angularErrorScale * directionScale * tan(lambda1), theta,
49  viewConfig.nSegments, 0., {0., 0.}, eplane);
50 
51  std::vector<Vector3D> coneTop = ellipse;
52  coneTop.push_back(anker);
53  auto coneTopFaces = detail::FacesHelper::convexFaceMesh(coneTop, true);
54  Polyhedron coneTopHedron(coneTop, coneTopFaces.first, coneTopFaces.second);
55  GeometryView3D::drawPolyhedron(helper, coneTopHedron, viewConfig);
56 
57  std::vector<Vector3D> cone = ellipse;
58  cone.push_back(position);
59  // Force triangular
60  ViewConfig coneViewConfig = viewConfig;
61  coneViewConfig.triangulate = true;
62  auto coneFaces = detail::FacesHelper::convexFaceMesh(cone, true);
63  Polyhedron coneHedron(cone, coneFaces.first, coneFaces.second);
64  GeometryView3D::drawPolyhedron(helper, coneHedron, coneViewConfig);
65 }