Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IndexedSurfacesSvgConverterTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IndexedSurfacesSvgConverterTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 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 
9 #include <boost/test/unit_test.hpp>
10 
22 
23 #include <tuple>
24 
25 using namespace Acts;
26 using namespace Acts::Svg;
27 using namespace Acts::Test;
28 using namespace Acts::Experimental;
29 using namespace Acts::Experimental::detail;
30 
33 
35  // The converter options
37  // Sensitive surface style
38  Style sensitiveStyle;
39  sensitiveStyle.fillColor = {51, 153, 255};
40  sensitiveStyle.fillOpacity = 0.9;
41  sensitiveStyle.highlightColor = {255, 153, 51};
42  sensitiveStyle.highlights = {"onmouseover", "onmouseout"};
43  sensitiveStyle.strokeWidth = 0.5;
44  sensitiveStyle.strokeColor = {0, 0, 0};
45  sensitiveStyle.nSegments = 72u;
46  std::pair<GeometryIdentifier, Style> allSensitives = {GeometryIdentifier(0u),
47  sensitiveStyle};
48 
49  // Hierarchy map of styles
50  GeometryHierarchyMap<Style> surfaceStyles({allSensitives});
51  isOptions.surfaceStyles = surfaceStyles;
52 
53  // The grid style
54  GridConverter::Options gridOptions;
55  Style gridStyle;
56  gridStyle.fillOpacity = 0.;
57  gridStyle.strokeColor = {0, 0, 255};
58  gridStyle.strokeWidth = 1.;
59  gridStyle.highlightStrokeWidth = 3;
60  gridStyle.highlightStrokeColor = {255, 0, 0};
61  gridOptions.style = gridStyle;
62 
63  isOptions.gridOptions = gridOptions;
64  return isOptions;
65 }
66 
68 
69 BOOST_AUTO_TEST_SUITE(ActSvg)
70 
71 BOOST_AUTO_TEST_CASE(RingDisc1D) {
72  // A single ring
74  auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
75  55., 0., 2., 22u);
76 
78  rSurfaces, {}, {binPhi}};
79 
80  GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u};
82 
83  auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
84  // The displaying
85  auto pIndexedRing = IndexedSurfacesConverter::convert(
86  tContext, rSurfaces, indexedRing, drawOptions);
87  auto pIndexRingView = View::xy(pIndexedRing, "RingDisc1D");
88  toFile({pIndexRingView}, pIndexRingView._id + ".svg");
89 }
90 
91 BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) {
92  // A single ring
94  auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
95  55., 0., 2., 22u);
96 
97  auto rBounds = std::make_shared<RadialBounds>(20., 20.);
98  auto dSurface = Surface::makeShared<DiscSurface>(Transform3::Identity(),
100  rSurfaces.push_back(dSurface.get());
101 
103  rSurfaces, {rSurfaces.size() - 1u}, {binPhi}};
104 
105  GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u};
107 
108  auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
109  // The displaying
110  auto pIndexedRing = IndexedSurfacesConverter::convert(
111  tContext, rSurfaces, indexedRing, drawOptions);
112  auto pIndexRingView = View::xy(pIndexedRing, "RingDisc1DWithSupport");
113  toFile({pIndexRingView}, pIndexRingView._id + ".svg");
114 }
115 
116 BOOST_AUTO_TEST_CASE(RingDisc2D) {
117  // Two rings to make a disc
119  auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
120  42., 0., 2., 22u);
121 
122  auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
123  80., 0., 2., 22u);
124 
125  decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
126  rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
127 
129  rSurfaces, {}, {binR, binPhi}};
130 
132  {24., 74., 110.}, {-M_PI, M_PI}, 44u};
134 
135  auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
136  // The displaying
137  auto pIndexedRing = IndexedSurfacesConverter::convert(
138  tContext, rSurfaces, indexedRing, drawOptions);
139  auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2D");
140 
141  toFile({pIndexRingView}, pIndexRingView._id + ".svg");
142 }
143 
144 BOOST_AUTO_TEST_CASE(RingDisc2DFine) {
145  // Three rings to make a disc
147  auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
148  42., 0., 2., 22u);
149 
150  auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
151  80., 0., 2., 22u);
152 
153  auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
154  122., 0., 2., 36u);
155 
156  decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
157  rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
158  rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
159 
161  rSurfaces, {}, {binR, binPhi}};
162 
164  {24., 152}, 8u, {-M_PI, M_PI}, 88u};
165 
167  auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
168  // The displaying
169  auto pIndexedRing = IndexedSurfacesConverter::convert(
170  tContext, rSurfaces, indexedRing, drawOptions);
171  auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2DFine");
172 
173  toFile({pIndexRingView}, pIndexRingView._id + ".svg");
174 }
175 
176 BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) {
177  // Three rings to make a disc
179  auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
180  42., 0., 2., 22u);
181 
182  auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
183  80., 0., 2., 22u);
184 
185  auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
186  122., 0., 2., 36u);
187 
188  decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
189  rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
190  rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
191 
193  rSurfaces, {}, {binR, binPhi}, {2u, 4u}};
194 
196  {24., 152}, 8u, {-M_PI, M_PI}, 88u};
198 
199  auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
200  // The displaying
201  auto pIndexedRing = IndexedSurfacesConverter::convert(
202  tContext, rSurfaces, indexedRing, drawOptions);
203  auto pIndexRingView = View::xy(pIndexedRing, "RingDisc2DFineExpanded");
204 
205  toFile({pIndexRingView}, pIndexRingView._id + ".svg");
206 }
207 
208 BOOST_AUTO_TEST_CASE(Cylinder2D) {
210  auto surfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145,
211  116., 3., 2., {52, 14});
212 
214  surfaces, {}, {binZ, binPhi}, {1u, 1u}};
215 
217  {-500., 500}, 28, {-M_PI, M_PI}, 52u};
219 
220  auto indexedCylinder = icSurfaces(tContext, aGenerator, rGenerator);
221  // The displaying
222  auto pIndexeCylinder = IndexedSurfacesConverter::convert(
223  tContext, surfaces, indexedCylinder, drawOptions);
224  auto pIndexCylinderView = View::zphi(pIndexeCylinder, "Cylinder");
225 
226  toFile({pIndexCylinderView}, pIndexCylinderView._id + ".svg");
227 }
228 
229 BOOST_AUTO_TEST_SUITE_END()