Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:11:59

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020-2021 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 http://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.nSegments, viewConfig.offset, lposition, transform);
0031 
0032   ellipse.push_back(transform *
0033                     Vector3(lposition.x(), lposition.y(), viewConfig.offset));
0034   auto faces = detail::FacesHelper::convexFaceMesh(ellipse, true);
0035   Polyhedron ellipseHedron(ellipse, faces.first, faces.second);
0036   Acts::GeometryView3D::drawPolyhedron(helper, ellipseHedron, viewConfig);
0037 }
0038 
0039 void Acts::EventDataView3D::drawCovarianceAngular(
0040     IVisualization3D& helper, const Vector3& position, const Vector3& direction,
0041     const ActsSquareMatrix<2>& covariance, double directionScale,
0042     double angularErrorScale, const ViewConfig& viewConfig) {
0043   auto [lambda0, lambda1, theta] = decomposeCovariance(covariance);
0044 
0045   // Anker point
0046   Vector3 anker = position + directionScale * direction;
0047 
0048   double dphi = VectorHelpers::phi(direction);
0049   double dtheta = VectorHelpers::theta(direction);
0050 
0051   Transform3 eplane(Translation3(anker) *
0052                     AngleAxis3(dphi, Vector3(0., 0., 1.)) *
0053                     AngleAxis3(dtheta, Vector3(0., 1., 0.)));
0054 
0055   // Now generate the ellipse points
0056   std::vector<Vector3> ellipse =
0057       createEllipse(angularErrorScale * directionScale * lambda0 * sin(dtheta),
0058                     angularErrorScale * directionScale * lambda1, theta,
0059                     viewConfig.nSegments, 0., {0., 0.}, eplane);
0060 
0061   std::vector<Vector3> coneTop = ellipse;
0062   coneTop.push_back(anker);
0063   auto coneTopFaces = detail::FacesHelper::convexFaceMesh(coneTop, true);
0064   Polyhedron coneTopHedron(coneTop, coneTopFaces.first, coneTopFaces.second);
0065   GeometryView3D::drawPolyhedron(helper, coneTopHedron, viewConfig);
0066 
0067   std::vector<Vector3> cone = ellipse;
0068   cone.push_back(position);
0069   // Force triangular
0070   ViewConfig coneViewConfig = viewConfig;
0071   coneViewConfig.triangulate = true;
0072   auto coneFaces = detail::FacesHelper::convexFaceMesh(cone, true);
0073   Polyhedron coneHedron(cone, coneFaces.first, coneFaces.second);
0074   GeometryView3D::drawPolyhedron(helper, coneHedron, coneViewConfig);
0075 }