Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:06

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 
0078   IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0079       irSurfaces{rSurfaces, {}, {AxisDirection::AxisPhi}};
0080 
0081   GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi},
0082                                           44u};
0083   PolyhedronReferenceGenerator<1u, true> rGenerator;
0084 
0085   auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
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>(20., 20.);
0100   auto dSurface = Surface::makeShared<DiscSurface>(Transform3::Identity(),
0101                                                    std::move(rBounds));
0102   rSurfaces.push_back(dSurface.get());
0103 
0104   IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0105       irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {AxisDirection::AxisPhi}};
0106 
0107   GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi},
0108                                           44u};
0109   PolyhedronReferenceGenerator<1u, true> rGenerator;
0110 
0111   auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0112   // The displaying
0113   auto pIndexedRing = IndexedSurfacesConverter::convert(
0114       tContext, rSurfaces, indexedRing, drawOptions);
0115   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc1DWithSupport");
0116   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0117 }
0118 
0119 BOOST_AUTO_TEST_CASE(RingDisc2D) {
0120   // Two rings to make a disc
0121   CylindricalTrackingGeometry::DetectorStore dStore;
0122   auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0123                                             42., 0., 2., 22u);
0124 
0125   auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0126                                             80., 0., 2., 22u);
0127 
0128   decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0129   rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0130 
0131   IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0132       irSurfaces{rSurfaces, {}, {AxisDirection::AxisR, AxisDirection::AxisPhi}};
0133 
0134   GridAxisGenerators::VarBoundEqClosed aGenerator{
0135       {24., 74., 110.}, {-std::numbers::pi, std::numbers::pi}, 44u};
0136   PolyhedronReferenceGenerator<1u, true> rGenerator;
0137 
0138   auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0139   // The displaying
0140   auto pIndexedRing = IndexedSurfacesConverter::convert(
0141       tContext, rSurfaces, indexedRing, drawOptions);
0142   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2D");
0143 
0144   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0145 }
0146 
0147 BOOST_AUTO_TEST_CASE(RingDisc2DFine) {
0148   // Three rings to make a disc
0149   CylindricalTrackingGeometry::DetectorStore dStore;
0150   auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0151                                             42., 0., 2., 22u);
0152 
0153   auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0154                                             80., 0., 2., 22u);
0155 
0156   auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
0157                                             122., 0., 2., 36u);
0158 
0159   decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0160   rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0161   rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
0162 
0163   IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0164       irSurfaces{rSurfaces, {}, {AxisDirection::AxisR, AxisDirection::AxisPhi}};
0165 
0166   GridAxisGenerators::EqBoundEqClosed aGenerator{
0167       {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u};
0168 
0169   PolyhedronReferenceGenerator<1u, true> rGenerator;
0170   auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0171   // The displaying
0172   auto pIndexedRing = IndexedSurfacesConverter::convert(
0173       tContext, rSurfaces, indexedRing, drawOptions);
0174   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2DFine");
0175 
0176   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0177 }
0178 
0179 BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) {
0180   // Three rings to make a disc
0181   CylindricalTrackingGeometry::DetectorStore dStore;
0182   auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0183                                             42., 0., 2., 22u);
0184 
0185   auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0186                                             80., 0., 2., 22u);
0187 
0188   auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
0189                                             122., 0., 2., 36u);
0190 
0191   decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0192   rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0193   rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
0194 
0195   IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0196       irSurfaces{rSurfaces,
0197                  {},
0198                  {AxisDirection::AxisR, AxisDirection::AxisPhi},
0199                  {2u, 4u}};
0200 
0201   GridAxisGenerators::EqBoundEqClosed aGenerator{
0202       {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u};
0203   PolyhedronReferenceGenerator<1u, true> rGenerator;
0204 
0205   auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0206   // The displaying
0207   auto pIndexedRing = IndexedSurfacesConverter::convert(
0208       tContext, rSurfaces, indexedRing, drawOptions);
0209   auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2DFineExpanded");
0210 
0211   toFile({pIndexRingView}, pIndexRingView._id + ".svg");
0212 }
0213 
0214 BOOST_AUTO_TEST_CASE(Cylinder2D) {
0215   CylindricalTrackingGeometry::DetectorStore dStore;
0216   auto surfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145,
0217                                              116., 3., 2., {52, 14});
0218 
0219   IndexedSurfacesGenerator<decltype(surfaces), IndexedSurfacesNavigation>
0220       icSurfaces{surfaces,
0221                  {},
0222                  {AxisDirection::AxisZ, AxisDirection::AxisPhi},
0223                  {1u, 1u}};
0224 
0225   GridAxisGenerators::EqBoundEqClosed aGenerator{
0226       {-500., 500}, 28, {-std::numbers::pi, std::numbers::pi}, 52u};
0227   PolyhedronReferenceGenerator<1u, true> rGenerator;
0228 
0229   auto indexedCylinder = icSurfaces(tContext, aGenerator, rGenerator);
0230   // The displaying
0231   auto pIndexeCylinder = IndexedSurfacesConverter::convert(
0232       tContext, surfaces, indexedCylinder, drawOptions);
0233   auto pIndexCylinderView = View::zphi(pIndexeCylinder, "Cylinder");
0234 
0235   toFile({pIndexCylinderView}, pIndexCylinderView._id + ".svg");
0236 }
0237 
0238 BOOST_AUTO_TEST_SUITE_END()