Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-06 07:53:39

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 <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Detector/detail/IndexedGridFiller.hpp"
0013 #include "Acts/Detector/detail/IndexedSurfacesGenerator.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/GeometryIdentifier.hpp"
0016 #include "Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp"
0017 #include "Acts/Surfaces/DiscSurface.hpp"
0018 #include "Acts/Surfaces/RadialBounds.hpp"
0019 #include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0020 #include "Acts/Utilities/Grid.hpp"
0021 #include "Acts/Utilities/GridAxisGenerators.hpp"
0022 
0023 #include <numbers>
0024 #include <tuple>
0025 
0026 using namespace Acts;
0027 using namespace Acts::Svg;
0028 using namespace Acts::Test;
0029 using namespace Acts::Experimental;
0030 using namespace Acts::Experimental::detail;
0031 
0032 GeometryContext tContext;
0033 CylindricalTrackingGeometry cGeometry = CylindricalTrackingGeometry(tContext);
0034 
0035 IndexedSurfacesConverter::Options generateDrawOptions() {
0036   // The converter options
0037   IndexedSurfacesConverter::Options isOptions;
0038   // Sensitive surface style
0039   Style sensitiveStyle;
0040   sensitiveStyle.fillColor = {51, 153, 255};
0041   sensitiveStyle.fillOpacity = 0.9;
0042   sensitiveStyle.highlightColor = {255, 153, 51};
0043   sensitiveStyle.highlights = {"onmouseover", "onmouseout"};
0044   sensitiveStyle.strokeWidth = 0.5;
0045   sensitiveStyle.strokeColor = {0, 0, 0};
0046   sensitiveStyle.quarterSegments = 72u;
0047   std::pair<GeometryIdentifier, Style> allSensitives = {GeometryIdentifier(0u),
0048                                                         sensitiveStyle};
0049 
0050   // Hierarchy map of styles
0051   GeometryHierarchyMap<Style> surfaceStyles({allSensitives});
0052   isOptions.surfaceStyles = surfaceStyles;
0053 
0054   // The grid style
0055   GridConverter::Options gridOptions;
0056   Style gridStyle;
0057   gridStyle.fillOpacity = 0.;
0058   gridStyle.strokeColor = {0, 0, 255};
0059   gridStyle.strokeWidth = 1.;
0060   gridStyle.highlightStrokeWidth = 3;
0061   gridStyle.highlightStrokeColor = {255, 0, 0};
0062   gridOptions.style = gridStyle;
0063 
0064   isOptions.gridOptions = gridOptions;
0065   return isOptions;
0066 }
0067 
0068 auto drawOptions = generateDrawOptions();
0069 
0070 BOOST_AUTO_TEST_SUITE(ActSvg)
0071 
0072 BOOST_AUTO_TEST_CASE(RingDisc1D) {
0073   // A single ring
0074   CylindricalTrackingGeometry::DetectorStore dStore;
0075   auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
0076                                           55., 0., 2., 22u);
0077   // Polyhedron reference generator
0078   PolyhedronReferenceGenerator<1u, true> rGenerator;
0079   // A single proto axis clused in phi with 44 bins
0080   DirectedProtoAxis pAxis(AxisDirection::AxisPhi, AxisBoundaryType::Closed,
0081                           -std::numbers::pi, std::numbers::pi, 44u);
0082   auto indexedRing =
0083       Acts::detail::IndexedSurfacesGenerator::createInternalNavigation<
0084           Experimental::IndexedSurfacesNavigation>(tContext, rSurfaces,
0085                                                    rGenerator, pAxis, 0u);
0086   // The displaying
0087   auto pIndexedRing = IndexedSurfacesConverter::convert(
0088       tContext, rSurfaces, indexedRing, drawOptions);
0089   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc1D");
0090   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0091 }
0092 
0093 BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) {
0094   // A single ring
0095   CylindricalTrackingGeometry::DetectorStore dStore;
0096   auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
0097                                           55., 0., 2., 22u);
0098 
0099   auto rBounds = std::make_shared<RadialBounds>(10., 20.);
0100   auto dSurface = Surface::makeShared<DiscSurface>(Transform3::Identity(),
0101                                                    std::move(rBounds));
0102   rSurfaces.push_back(dSurface.get());
0103 
0104   // Polyhedron reference generator
0105   PolyhedronReferenceGenerator<1u, true> rGenerator;
0106   // A single proto axis clused in phi with 44 bins
0107   DirectedProtoAxis pAxis(AxisDirection::AxisPhi, AxisBoundaryType::Closed,
0108                           -std::numbers::pi, std::numbers::pi, 44u);
0109   auto indexedRing =
0110       Acts::detail::IndexedSurfacesGenerator::createInternalNavigation<
0111           Experimental::IndexedSurfacesNavigation>(
0112           tContext, rSurfaces, rGenerator, pAxis, 0u, {rSurfaces.size() - 1u});
0113   // The displaying
0114   auto pIndexedRing = IndexedSurfacesConverter::convert(
0115       tContext, rSurfaces, indexedRing, drawOptions);
0116   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc1DWithSupport");
0117   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0118 }
0119 
0120 BOOST_AUTO_TEST_CASE(RingDisc2D) {
0121   // Two rings to make a disc
0122   CylindricalTrackingGeometry::DetectorStore dStore;
0123   auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0124                                             42., 0., 2., 22u);
0125 
0126   auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0127                                             80., 0., 2., 22u);
0128 
0129   decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0130   rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0131 
0132   DirectedProtoAxis pAxisR(AxisDirection::AxisR, AxisBoundaryType::Bound,
0133                            {24., 74., 110});
0134   DirectedProtoAxis pAxisPhi(AxisDirection::AxisPhi, AxisBoundaryType::Closed,
0135                              -std::numbers::pi, std::numbers::pi, 44u);
0136 
0137   PolyhedronReferenceGenerator<1u, true> rGenerator;
0138 
0139   auto indexedRing =
0140       Acts::detail::IndexedSurfacesGenerator::createInternalNavigation<
0141           Experimental::IndexedSurfacesNavigation>(
0142           tContext, rSurfaces, rGenerator, pAxisR, 0u, pAxisPhi, 0u);
0143 
0144   // The displaying
0145   auto pIndexedRing = IndexedSurfacesConverter::convert(
0146       tContext, rSurfaces, indexedRing, drawOptions);
0147   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2D");
0148 
0149   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0150 }
0151 
0152 BOOST_AUTO_TEST_CASE(RingDisc2DFine) {
0153   // Three rings to make a disc
0154   CylindricalTrackingGeometry::DetectorStore dStore;
0155   auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0156                                             42., 0., 2., 22u);
0157 
0158   auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0159                                             80., 0., 2., 22u);
0160 
0161   auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
0162                                             122., 0., 2., 36u);
0163 
0164   decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0165   rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0166   rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
0167 
0168   DirectedProtoAxis pAxisR(AxisDirection::AxisR, AxisBoundaryType::Bound, 24.,
0169                            152, 8u);
0170   DirectedProtoAxis pAxisPhi(AxisDirection::AxisPhi, AxisBoundaryType::Closed,
0171                              -std::numbers::pi, std::numbers::pi, 88u);
0172 
0173   PolyhedronReferenceGenerator<1u, true> rGenerator;
0174 
0175   auto indexedRing =
0176       Acts::detail::IndexedSurfacesGenerator::createInternalNavigation<
0177           Experimental::IndexedSurfacesNavigation>(
0178           tContext, rSurfaces, rGenerator, pAxisR, 0u, pAxisPhi, 0u);
0179 
0180   // The displaying
0181   auto pIndexedRing = IndexedSurfacesConverter::convert(
0182       tContext, rSurfaces, indexedRing, drawOptions);
0183   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2DFine");
0184 
0185   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0186 }
0187 
0188 BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) {
0189   // Three rings to make a disc
0190   CylindricalTrackingGeometry::DetectorStore dStore;
0191   auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0192                                             42., 0., 2., 22u);
0193 
0194   auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0195                                             80., 0., 2., 22u);
0196 
0197   auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
0198                                             122., 0., 2., 36u);
0199 
0200   decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0201   rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0202   rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
0203 
0204   PolyhedronReferenceGenerator<1u, true> rGenerator;
0205 
0206   DirectedProtoAxis pAxisR(AxisDirection::AxisR, AxisBoundaryType::Bound, 24.,
0207                            152, 8u);
0208   DirectedProtoAxis pAxisPhi(AxisDirection::AxisPhi, AxisBoundaryType::Closed,
0209                              -std::numbers::pi, std::numbers::pi, 88u);
0210 
0211   auto indexedRing =
0212       Acts::detail::IndexedSurfacesGenerator::createInternalNavigation<
0213           Experimental::IndexedSurfacesNavigation>(
0214           tContext, rSurfaces, rGenerator, pAxisR, 2u, pAxisPhi, 4u);
0215 
0216   // The displaying
0217   auto pIndexedRing = IndexedSurfacesConverter::convert(
0218       tContext, rSurfaces, indexedRing, drawOptions);
0219   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2DFineExpanded");
0220 
0221   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0222 }
0223 
0224 BOOST_AUTO_TEST_CASE(Cylinder2D) {
0225   CylindricalTrackingGeometry::DetectorStore dStore;
0226   auto surfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145,
0227                                              116., 3., 2., {52, 14});
0228 
0229   DirectedProtoAxis pAxisZ(AxisDirection::AxisZ, AxisBoundaryType::Bound, -500.,
0230                            500., 28u);
0231   DirectedProtoAxis pAxisPhi(AxisDirection::AxisPhi, AxisBoundaryType::Closed,
0232                              -std::numbers::pi, std::numbers::pi, 52u);
0233   PolyhedronReferenceGenerator<1u, true> rGenerator;
0234 
0235   auto indexedCylinder =
0236       Acts::detail::IndexedSurfacesGenerator::createInternalNavigation<
0237           Experimental::IndexedSurfacesNavigation>(
0238           tContext, surfaces, rGenerator, pAxisZ, 1u, pAxisPhi, 1u);
0239 
0240   // The displaying
0241   auto pIndexeCylinder = IndexedSurfacesConverter::convert(
0242       tContext, surfaces, indexedCylinder, drawOptions);
0243   auto pIndexCylinderView = View::zphi(pIndexeCylinder, "Cylinder");
0244 
0245   toFile({pIndexCylinderView}, pIndexCylinderView._id + ".svg");
0246 }
0247 
0248 BOOST_AUTO_TEST_SUITE_END()