Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:33

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Visualization/EventDataView3D.hpp"
0010 
0011 #include "Acts/Geometry/Polyhedron.hpp"
0012 #include "Acts/Surfaces/detail/FacesHelper.hpp"
0013 #include "Acts/Utilities/Helpers.hpp"
0014 
0015 #include <cmath>
0016 #include <utility>
0017 
0018 namespace Acts {
0019 class IVisualization3D;
0020 }  // namespace Acts
0021 
0022 void Acts::EventDataView3D::drawCovarianceCartesian(
0023     IVisualization3D& helper, const Vector2& lposition,
0024     const SquareMatrix2& covariance, const Transform3& transform,
0025     double locErrorScale, const ViewConfig& viewConfig) {
0026   auto [lambda0, lambda1, theta] = decomposeCovariance(covariance);
0027 
0028   std::vector<Vector3> ellipse = createEllipse(
0029       lambda0 * locErrorScale, lambda1 * locErrorScale, theta,
0030       viewConfig.quarterSegments, viewConfig.offset, lposition, transform);
0031 
0032   ellipse.push_back(transform *
0033                     Vector3(lposition.x(), lposition.y(), viewConfig.offset));
0034   auto [faces, triangularMesh] =
0035       detail::FacesHelper::convexFaceMesh(ellipse, true);
0036   Polyhedron ellipseHedron(ellipse, faces, triangularMesh);
0037   Acts::GeometryView3D::drawPolyhedron(helper, ellipseHedron, viewConfig);
0038 }
0039 
0040 void Acts::EventDataView3D::drawCovarianceAngular(
0041     IVisualization3D& helper, const Vector3& position, const Vector3& direction,
0042     const ActsSquareMatrix<2>& covariance, double directionScale,
0043     double angularErrorScale, const ViewConfig& viewConfig) {
0044   auto [lambda0, lambda1, theta] = decomposeCovariance(covariance);
0045 
0046   // Anker point
0047   Vector3 anker = position + directionScale * direction;
0048 
0049   double dphi = VectorHelpers::phi(direction);
0050   double dtheta = VectorHelpers::theta(direction);
0051 
0052   Transform3 eplane(Translation3(anker) *
0053                     AngleAxis3(dphi, Vector3(0., 0., 1.)) *
0054                     AngleAxis3(dtheta, Vector3(0., 1., 0.)));
0055 
0056   // Now generate the ellipse points
0057   std::vector<Vector3> ellipse =
0058       createEllipse(angularErrorScale * directionScale * lambda0 * sin(dtheta),
0059                     angularErrorScale * directionScale * lambda1, theta,
0060                     viewConfig.quarterSegments, 0., {0., 0.}, eplane);
0061 
0062   std::vector<Vector3> coneTop = ellipse;
0063   coneTop.push_back(anker);
0064   auto [faces, triangularMesh] =
0065       detail::FacesHelper::convexFaceMesh(coneTop, true);
0066   Polyhedron coneTopHedron(coneTop, faces, triangularMesh);
0067   GeometryView3D::drawPolyhedron(helper, coneTopHedron, viewConfig);
0068 
0069   std::vector<Vector3> cone = ellipse;
0070   cone.push_back(position);
0071   // Force triangular
0072   ViewConfig coneViewConfig = viewConfig;
0073   coneViewConfig.triangulate = true;
0074   auto [facesCone, triangularMeshCone] =
0075       detail::FacesHelper::convexFaceMesh(cone, true);
0076   Polyhedron coneHedron(cone, facesCone, triangularMeshCone);
0077   GeometryView3D::drawPolyhedron(helper, coneHedron, coneViewConfig);
0078 }