Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PolyhedronSurfacesTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PolyhedronSurfacesTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 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/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
13 // Helper
15 
16 // The class to test
17 #include "Acts/Geometry/Extent.hpp"
19 
20 // Cone surface
23 
24 // Cylinder surface
27 
28 // Disc Surface
33 
34 // Plane Surface
41 
42 // Straw Surface
47 
48 #include <fstream>
49 #include <tuple>
50 #include <utility>
51 #include <vector>
52 
53 namespace Acts {
54 
55 using namespace UnitLiterals;
56 
57 using IdentifiedPolyhedron = std::tuple<std::string, bool, Polyhedron>;
58 
59 namespace Test {
60 
61 // Create a test context
63 
64 std::vector<std::tuple<std::string, bool, unsigned int>> testModes = {
65  {"", false, 72}, {"Triangulate", true, 72}, {"Extremas", false, 1}};
66 
67 auto transform = std::make_shared<Transform3>(Transform3::Identity());
68 
69 BOOST_AUTO_TEST_SUITE(Surfaces)
70 
71 
72 BOOST_AUTO_TEST_CASE(ConeSurfacePolyhedrons) {
73  double hzpmin = 10_mm;
74  double hzpos = 35_mm;
75  double hzneg = -20_mm;
76  double alpha = 0.234;
77  double phiSector = 0.358;
78 
79  for (const auto& mode : testModes) {
80  unsigned int segments = std::get<unsigned int>(mode);
81  std::string modename = std::get<std::string>(mode);
82  bool modetrg = std::get<bool>(mode);
83 
85  auto cone = std::make_shared<ConeBounds>(alpha, 0_mm, hzpos);
86  auto oneCone = Surface::makeShared<ConeSurface>(transform, cone);
87  auto oneConePh = oneCone->polyhedronRepresentation(tgContext, segments);
88  size_t expectedFaces = segments < 4 ? 4 : segments;
89  BOOST_CHECK_EQUAL(oneConePh.faces.size(), expectedFaces);
90  BOOST_CHECK_EQUAL(oneConePh.vertices.size(), expectedFaces + 1);
91  // Check the extent in space
92  double r = hzpos * std::tan(alpha);
93  auto extent = oneConePh.extent();
94  CHECK_CLOSE_ABS((extent.range(binX).min() -r, 1e-6);
95  CHECK_CLOSE_ABS((extent.range(binX).max() r, 1e-6);
96  CHECK_CLOSE_ABS((extent.range(binY).min() -r, 1e-6);
97  CHECK_CLOSE_ABS((extent.range(binY).max() r, 1e-6);
98  CHECK_CLOSE_ABS((extent.range(binR).min() 0_mm, 1e-6);
99  CHECK_CLOSE_ABS((extent.range(binR).max() r, 1e-6);
100  CHECK_CLOSE_ABS((extent.range(binZ).min() 0_mm, 1e-6);
101  CHECK_CLOSE_ABS((extent.range(binZ).max() hzpos, 1e-6);
102 
104  auto conePiece = std::make_shared<ConeBounds>(alpha, hzpmin, hzpos);
105  auto oneConePiece = Surface::makeShared<ConeSurface>(transform, conePiece);
106  auto oneConePiecePh =
107  oneConePiece->polyhedronRepresentation(tgContext, segments);
108  expectedFaces = segments < 4 ? 4 : segments;
109  // Check the extent in space
110  double rmin = hzpmin * std::tan(alpha);
111  extent = oneConePiecePh.extent();
112  CHECK_CLOSE_ABS((extent.range(binX).min() -r, 1e-6);
113  CHECK_CLOSE_ABS((extent.range(binX).max() r, 1e-6);
114  CHECK_CLOSE_ABS((extent.range(binY).min() -r, 1e-6);
115  CHECK_CLOSE_ABS((extent.range(binY).max() r, 1e-6);
116  CHECK_CLOSE_ABS((extent.range(binR).min() rmin, 1e-6);
117  CHECK_CLOSE_ABS((extent.range(binR).max() r, 1e-6);
118  CHECK_CLOSE_ABS((extent.range(binZ).min() hzpmin, 1e-6);
119  CHECK_CLOSE_ABS((extent.range(binZ).max() hzpos, 1e-6);
120 
121  // The full cone on both sides
122  auto coneBoth = std::make_shared<ConeBounds>(alpha, hzneg, hzpos);
123  auto twoCones = Surface::makeShared<ConeSurface>(transform, coneBoth);
124  auto twoConesPh = twoCones->polyhedronRepresentation(tgContext, segments);
125  expectedFaces = segments < 4 ? 8 : 2 * segments;
126  BOOST_CHECK_EQUAL(twoConesPh.faces.size(), expectedFaces);
127  BOOST_CHECK_EQUAL(twoConesPh.vertices.size(), expectedFaces + 1);
128  extent = twoConesPh.extent();
129  CHECK_CLOSE_ABS((extent.range(binX).min() -r, 1e-6);
130  CHECK_CLOSE_ABS((extent.range(binX).max() r, 1e-6);
131  CHECK_CLOSE_ABS((extent.range(binY).min() -r, 1e-6);
132  CHECK_CLOSE_ABS((extent.range(binY).max() r, 1e-6);
133  CHECK_CLOSE_ABS((extent.range(binR).min() 0_mm, 1e-6);
134  CHECK_CLOSE_ABS((extent.range(binR).max() r, 1e-6);
135  CHECK_CLOSE_ABS((extent.range(binZ).min() hzneg, 1e-6);
136  CHECK_CLOSE_ABS((extent.range(binZ).max() hzpos, 1e-6);
137 
138  // A centered sectoral cone on both sides
139  auto sectoralBoth =
140  std::make_shared<ConeBounds>(alpha, hzneg, hzpos, phiSector, 0.);
141  auto sectoralCones =
142  Surface::makeShared<ConeSurface>(transform, sectoralBoth);
143  auto sectoralConesPh =
144  sectoralCones->polyhedronRepresentation(tgContext, segments);
145  extent = sectoralConesPh.extent();
146  CHECK_CLOSE_ABS((extent.range(binX).max() r, 1e-6);
147  CHECK_CLOSE_ABS((extent.range(binR).min() 0_mm, 1e-6);
148  CHECK_CLOSE_ABS((extent.range(binR).max() r, 1e-6);
149  CHECK_CLOSE_ABS((extent.range(binZ).min() hzneg, 1e-6);
150  CHECK_CLOSE_ABS((extent.range(binZ).max() hzpos, 1e-6);
151  }
152 }
153 
155 BOOST_AUTO_TEST_CASE(CylinderSurfacePolyhedrons) {
156  double r = 25_mm;
157  double hZ = 35_mm;
158 
159  double phiSector = 0.458;
160  double averagePhi = -1.345;
161 
162  for (const auto& mode : testModes) {
163  unsigned int segments = std::get<unsigned int>(mode);
164  std::string modename = std::get<std::string>(mode);
165  bool modetrg = std::get<bool>(mode);
166 
167  size_t expectedFaces = segments < 4 ? 4 : segments;
168  size_t expectedVertices = segments < 4 ? 8 : 2 * segments;
169 
171  auto cylinder = std::make_shared<CylinderBounds>(r, hZ);
172  auto fullCylinder =
173  Surface::makeShared<CylinderSurface>(transform, cylinder);
174  auto fullCylinderPh =
175  fullCylinder->polyhedronRepresentation(tgContext, segments);
176 
177  BOOST_CHECK_EQUAL(fullCylinderPh.faces.size(), expectedFaces);
178  BOOST_CHECK_EQUAL(fullCylinderPh.vertices.size(), expectedVertices);
179  // Check the extent in space
180  auto extent = fullCylinderPh.extent();
181  CHECK_CLOSE_ABS((extent.range(binX).min() -r, 1e-6);
182  CHECK_CLOSE_ABS((extent.range(binX).max() r, 1e-6);
183  CHECK_CLOSE_ABS((extent.range(binY).min() -r, 1e-6);
184  CHECK_CLOSE_ABS((extent.range(binY).max() r, 1e-6);
185  CHECK_CLOSE_ABS((extent.range(binR).min() r, 1e-6);
186  CHECK_CLOSE_ABS((extent.range(binR).max() r, 1e-6);
187  CHECK_CLOSE_ABS((extent.range(binZ).min() -hZ, 1e-6);
188  CHECK_CLOSE_ABS((extent.range(binZ).max() hZ, 1e-6);
189 
191  auto sectorCentered = std::make_shared<CylinderBounds>(r, phiSector, hZ);
192  auto centerSectoredCylinder =
193  Surface::makeShared<CylinderSurface>(transform, sectorCentered);
194  auto centerSectoredCylinderPh =
195  centerSectoredCylinder->polyhedronRepresentation(tgContext, segments);
196 
197  // Check the extent in space
198  extent = centerSectoredCylinderPh.extent();
199  CHECK_CLOSE_ABS((extent.range(binX).min() r * std::cos(phiSector), 1e-6);
200  CHECK_CLOSE_ABS((extent.range(binX).max() r, 1e-6);
201  CHECK_CLOSE_ABS((extent.range(binY).min() -r * std::sin(phiSector), 1e-6);
202  CHECK_CLOSE_ABS((extent.range(binY).max() r * std::sin(phiSector), 1e-6);
203  CHECK_CLOSE_ABS((extent.range(binR).min() r, 1e-6);
204  CHECK_CLOSE_ABS((extent.range(binR).max() r, 1e-6);
205  CHECK_CLOSE_ABS((extent.range(binZ).min() -hZ, 1e-6);
206  CHECK_CLOSE_ABS((extent.range(binZ).max() hZ, 1e-6);
207 
209  auto sectorShifted =
210  std::make_shared<CylinderBounds>(r, averagePhi, phiSector, hZ);
211  auto shiftedSectoredCylinder =
212  Surface::makeShared<CylinderSurface>(transform, sectorShifted);
213  auto shiftedSectoredCylinderPh =
214  shiftedSectoredCylinder->polyhedronRepresentation(tgContext, segments);
215 
216  // Check the extent in space
217  extent = shiftedSectoredCylinderPh.extent();
218  CHECK_CLOSE_ABS((extent.range(binR).min() r, 1e-6);
219  CHECK_CLOSE_ABS((extent.range(binR).max() r, 1e-6);
220  CHECK_CLOSE_ABS((extent.range(binZ).min() -hZ, 1e-6);
221  CHECK_CLOSE_ABS((extent.range(binZ).max() hZ, 1e-6);
222  }
223 }
224 
226 BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) {
227  double innerR = 10_mm;
228  double outerR = 25_mm;
229 
230  double phiSector = 0.345;
231  double averagePhi = -1.0;
232 
233  double cphi = std::cos(phiSector);
234  double sphi = std::sin(phiSector);
235 
236  std::pair<Vector3, Vector3> lineA = {
237  Vector3(0., 0., 0.), Vector3(outerR * cphi, outerR * sphi, 0.)};
238  std::pair<Vector3, Vector3> lineB = {
239  Vector3(0., 0., 0.), Vector3(outerR * cphi, -outerR * sphi, 0.)};
240 
241  double minPhi = averagePhi - phiSector;
242  double maxPhi = averagePhi + phiSector;
243  lineA = {Vector3(0., 0., 0.),
244  Vector3(outerR * std::cos(minPhi), outerR * std::sin(minPhi), 0.)};
245  lineB = {Vector3(0., 0., 0.),
246  Vector3(outerR * std::cos(maxPhi), outerR * std::sin(maxPhi), 0.)};
247 
248  for (const auto& mode : testModes) {
249  unsigned int segments = std::get<unsigned int>(mode);
250  std::string modename = std::get<std::string>(mode);
251  bool modetrg = std::get<bool>(mode);
252 
253  // Full disc
254  auto disc = std::make_shared<RadialBounds>(0_mm, outerR);
255  auto fullDisc = Surface::makeShared<DiscSurface>(transform, disc);
256  auto fullDiscPh = fullDisc->polyhedronRepresentation(tgContext, segments);
257 
258  unsigned int expectedVertices = segments > 4 ? segments : 4;
259  unsigned int expectedFaces = 1;
260 
261  BOOST_CHECK_EQUAL(fullDiscPh.faces.size(), expectedFaces);
262  BOOST_CHECK_EQUAL(fullDiscPh.vertices.size(), expectedVertices);
263 
264  auto extent = fullDiscPh.extent();
265  CHECK_CLOSE_ABS((extent.range(binX).min() -outerR, 1e-6);
266  CHECK_CLOSE_ABS((extent.range(binX).max() outerR, 1e-6);
267  CHECK_CLOSE_ABS((extent.range(binY).min() -outerR, 1e-6);
268  CHECK_CLOSE_ABS((extent.range(binY).max() outerR, 1e-6);
269  CHECK_CLOSE_ABS((extent.range(binR).min() 0., 1e-6);
270  CHECK_CLOSE_ABS((extent.range(binR).max() outerR, 1e-6);
271  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
272  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
273 
274  // Ring disc
275  auto radial = std::make_shared<RadialBounds>(innerR, outerR);
276  auto radialDisc = Surface::makeShared<DiscSurface>(transform, radial);
277  auto radialPh = radialDisc->polyhedronRepresentation(tgContext, segments);
278  extent = radialPh.extent();
279  CHECK_CLOSE_ABS((extent.range(binX).min() -outerR, 1e-6);
280  CHECK_CLOSE_ABS((extent.range(binX).max() outerR, 1e-6);
281  CHECK_CLOSE_ABS((extent.range(binY).min() -outerR, 1e-6);
282  CHECK_CLOSE_ABS((extent.range(binY).max() outerR, 1e-6);
283  CHECK_CLOSE_ABS((extent.range(binR).min() innerR, 1e-6);
284  CHECK_CLOSE_ABS((extent.range(binR).max() outerR, 1e-6);
285  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
286  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
287 
288  // Sectoral disc - around 0.
289  auto sector = std::make_shared<RadialBounds>(0., outerR, phiSector);
290  auto sectorDisc = Surface::makeShared<DiscSurface>(transform, sector);
291  auto sectorPh = sectorDisc->polyhedronRepresentation(tgContext, segments);
292  extent = sectorPh.extent();
293  CHECK_CLOSE_ABS((extent.range(binX).min() 0., 1e-6);
294  CHECK_CLOSE_ABS((extent.range(binX).max() outerR, 1e-6);
295  CHECK_CLOSE_ABS((extent.range(binY).min() -outerR * std::sin(phiSector),
296  1e-6);
297  CHECK_CLOSE_ABS((extent.range(binY).max() outerR * std::sin(phiSector),
298  1e-6);
299  CHECK_CLOSE_ABS((extent.range(binR).min() 0., 1e-6);
300  CHECK_CLOSE_ABS((extent.range(binR).max() outerR, 1e-6);
301  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
302  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
303 
304  // Sectoral ring - around 0.
305  auto sectorRing = std::make_shared<RadialBounds>(innerR, outerR, phiSector);
306  auto sectorRingDisc =
307  Surface::makeShared<DiscSurface>(transform, sectorRing);
308  auto sectorRingDiscPh =
309  sectorRingDisc->polyhedronRepresentation(tgContext, segments);
310  extent = sectorRingDiscPh.extent();
311  CHECK_CLOSE_ABS((extent.range(binX).min() innerR * std::cos(phiSector),
312  1e-6);
313  CHECK_CLOSE_ABS((extent.range(binX).max() outerR, 1e-6);
314  CHECK_CLOSE_ABS((extent.range(binY).min() -outerR * std::sin(phiSector),
315  1e-6);
316  CHECK_CLOSE_ABS((extent.range(binY).max() outerR * std::sin(phiSector),
317  1e-6);
318  CHECK_CLOSE_ABS((extent.range(binR).min() innerR, 1e-6);
319  CHECK_CLOSE_ABS((extent.range(binR).max() outerR, 1e-6);
320  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
321  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
322 
323  // Sectoral disc - shifted
324  auto sectorRingShifted =
325  std::make_shared<RadialBounds>(innerR, outerR, averagePhi, phiSector);
326  auto sectorRingDiscShifted =
327  Surface::makeShared<DiscSurface>(transform, sectorRingShifted);
328  auto sectorRingDiscShiftedPh =
329  sectorRingDiscShifted->polyhedronRepresentation(tgContext, segments);
330  extent = sectorRingDiscShiftedPh.extent();
331  CHECK_CLOSE_ABS((extent.range(binR).min() innerR, 1e-6);
332  CHECK_CLOSE_ABS((extent.range(binR).max() outerR, 1e-6);
333  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
334  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
335 
336  // Trapezoid for a disc
337  double halfXmin = 10_mm;
338  double halfXmax = 20_mm;
339  auto trapezoidDisc = std::make_shared<DiscTrapezoidBounds>(
340  halfXmin, halfXmax, innerR, outerR, 0.);
341  auto trapezoidDiscSf =
342  Surface::makeShared<DiscSurface>(transform, trapezoidDisc);
343  auto trapezoidDiscSfPh =
344  trapezoidDiscSf->polyhedronRepresentation(tgContext, segments);
345  extent = trapezoidDiscSfPh.extent();
346  CHECK_CLOSE_ABS((extent.range(binR).min() innerR, 1e-6);
347  CHECK_CLOSE_ABS((extent.range(binR).max() outerR, 1e-6);
348  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
349  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
350 
351  auto trapezoidDiscShifted = std::make_shared<DiscTrapezoidBounds>(
352  halfXmin, halfXmax, innerR, outerR, averagePhi);
353  auto trapezoidDiscShiftedSf =
354  Surface::makeShared<DiscSurface>(transform, trapezoidDiscShifted);
355  auto trapezoidDiscShiftedSfPh =
356  trapezoidDiscShiftedSf->polyhedronRepresentation(tgContext, segments);
357  extent = trapezoidDiscShiftedSfPh.extent();
358  CHECK_CLOSE_ABS((extent.range(binR).min() innerR, 1e-6);
359  CHECK_CLOSE_ABS((extent.range(binR).max() outerR, 1e-6);
360  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
361  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
362 
363  double minRadius = 7.;
364  double maxRadius = 12.;
365  double minPhiA = 0.75;
366  double maxPhiA = 1.4;
367 
368  Vector2 offset(-2., 2.);
369 
370  auto annulus = std::make_shared<AnnulusBounds>(minRadius, maxRadius,
371  minPhiA, maxPhiA, offset);
372  auto annulusDisc = Surface::makeShared<DiscSurface>(transform, annulus);
373  auto annulusDiscPh =
374  annulusDisc->polyhedronRepresentation(tgContext, segments);
375  }
376 }
377 
379 BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) {
380  double rhX = 10_mm;
381  double rhY = 25_mm;
382  double shiftY = 50_mm;
383  auto rectangular = std::make_shared<RectangleBounds>(rhX, rhY);
384 
385  // Special test for shifted plane to check rMin/rMax
386  Vector3 shift(0., shiftY, 0.);
387  auto shiftedTransform = std::make_shared<Transform3>(Transform3::Identity());
388  shiftedTransform->pretranslate(shift);
389  auto shiftedPlane =
390  Surface::makeShared<PlaneSurface>(shiftedTransform, rectangular);
391  auto shiftedPh = shiftedPlane->polyhedronRepresentation(tgContext, 1);
392  auto shiftedExtent = shiftedPh.extent();
393  // Let's check the extent
394  CHECK_CLOSE_ABS(shifted(extent.range(binX).min() -rhX, 1e-6);
395  CHECK_CLOSE_ABS(shifted(extent.range(binX).max() rhX, 1e-6);
396  CHECK_CLOSE_ABS(shifted(extent.range(binY).min() -rhY + shiftY, 1e-6);
397  CHECK_CLOSE_ABS(shifted(extent.range(binY).max() rhY + shiftY, 1e-6);
398 
399  for (const auto& mode : testModes) {
400  unsigned int segments = std::get<unsigned int>(mode);
401  std::string modename = std::get<std::string>(mode);
402  bool modetrg = std::get<bool>(mode);
403 
405  auto rectangularPlane =
406  Surface::makeShared<PlaneSurface>(transform, rectangular);
407  auto rectangularPh =
408  rectangularPlane->polyhedronRepresentation(tgContext, segments);
409  auto extent = rectangularPh.extent();
410  CHECK_CLOSE_ABS((extent.range(binX).min() -rhX, 1e-6);
411  CHECK_CLOSE_ABS((extent.range(binX).max() rhX, 1e-6);
412  CHECK_CLOSE_ABS((extent.range(binY).min() -rhY, 1e-6);
413  CHECK_CLOSE_ABS((extent.range(binY).max() rhY, 1e-6);
414  CHECK_CLOSE_ABS((extent.range(binR).min() 0., 1e-6);
415  CHECK_CLOSE_ABS((extent.range(binR).max()
416  std::hypot(rhX, rhY), 1e-6);
417  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
418  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
419  BOOST_CHECK(rectangularPh.vertices.size() == 4);
420  BOOST_CHECK(rectangularPh.faces.size() == 1);
421  std::vector<size_t> expectedRect = {0, 1, 2, 3};
422  BOOST_CHECK(rectangularPh.faces[0] == expectedRect);
423 
425  double thX1 = 10_mm;
426  double thX2 = 25_mm;
427  double thY = 35_mm;
428 
429  auto trapezoid = std::make_shared<TrapezoidBounds>(thX1, thX2, thY);
430  auto trapezoidalPlane =
431  Surface::makeShared<PlaneSurface>(transform, trapezoid);
432  auto trapezoidalPh =
433  trapezoidalPlane->polyhedronRepresentation(tgContext, segments);
434  extent = trapezoidalPh.extent();
435 
436  double thX = std::max(thX1, thX2);
437  CHECK_CLOSE_ABS((extent.range(binX).min() -thX, 1e-6);
438  CHECK_CLOSE_ABS((extent.range(binX).max() thX, 1e-6);
439  CHECK_CLOSE_ABS((extent.range(binY).min() -thY, 1e-6);
440  CHECK_CLOSE_ABS((extent.range(binY).max() thY, 1e-6);
441  CHECK_CLOSE_ABS((extent.range(binR).min() 0., 1e-6);
442  CHECK_CLOSE_ABS((extent.range(binR).max()
443  std::hypot(thX, thY), 1e-6);
444  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
445  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
446  BOOST_CHECK(trapezoidalPh.vertices.size() == 4);
447  BOOST_CHECK(trapezoidalPh.faces.size() == 1);
448  std::vector<size_t> expectedTra = {0, 1, 2, 3};
449  BOOST_CHECK(trapezoidalPh.faces[0] == expectedTra);
450 
452  double rMaxX = 30_mm;
453  double rMaxY = 40_mm;
454  auto ellipse = std::make_shared<EllipseBounds>(0., 0., rMaxX, rMaxY);
455  auto ellipsoidPlane = Surface::makeShared<PlaneSurface>(transform, ellipse);
456  auto ellispoidPh =
457  ellipsoidPlane->polyhedronRepresentation(tgContext, segments);
458  extent = ellispoidPh.extent();
459  CHECK_CLOSE_ABS((extent.range(binX).min() -rMaxX, 1e-6);
460  CHECK_CLOSE_ABS((extent.range(binX).max() rMaxX, 1e-6);
461  CHECK_CLOSE_ABS((extent.range(binY).min() -rMaxY, 1e-6);
462  CHECK_CLOSE_ABS((extent.range(binY).max() rMaxY, 1e-6);
463  CHECK_CLOSE_ABS((extent.range(binR).min() 0., 1e-6);
464  CHECK_CLOSE_ABS((extent.range(binR).max() rMaxY, 1e-6);
465  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
466  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
467 
468  double rMinX = 10_mm;
469  double rMinY = 20_mm;
470  auto ellipseRing =
471  std::make_shared<EllipseBounds>(rMinX, rMaxX, rMinY, rMaxY);
472  auto ellipsoidRingPlane =
473  Surface::makeShared<PlaneSurface>(transform, ellipseRing);
474  auto ellispoidRingPh =
475  ellipsoidRingPlane->polyhedronRepresentation(tgContext, segments);
476 
477  extent = ellispoidPh.extent();
478  CHECK_CLOSE_ABS((extent.range(binX).min() -rMaxX, 1e-6);
479  CHECK_CLOSE_ABS((extent.range(binX).max() rMaxX, 1e-6);
480  CHECK_CLOSE_ABS((extent.range(binY).min() -rMaxY, 1e-6);
481  CHECK_CLOSE_ABS((extent.range(binY).max() rMaxY, 1e-6);
482  CHECK_CLOSE_ABS((extent.range(binR).min() rMinX, 1e-6);
483  CHECK_CLOSE_ABS((extent.range(binR).max() rMaxY, 1e-6);
484  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
485  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
486 
488  std::vector<Vector2> vtxs = {
489  Vector2(-40_mm, -10_mm), Vector2(-10_mm, -30_mm),
490  Vector2(30_mm, -20_mm), Vector2(10_mm, 20_mm),
491  Vector2(-20_mm, 50_mm), Vector2(-30_mm, 30_mm)};
492 
493  auto sextagon = std::make_shared<ConvexPolygonBounds<6>>(vtxs);
494  auto sextagonPlane = Surface::makeShared<PlaneSurface>(transform, sextagon);
495  auto sextagonPlanePh =
496  sextagonPlane->polyhedronRepresentation(tgContext, segments);
497 
499  double hMinX = 10_mm;
500  double hMedX = 20_mm;
501  double hMaxX = 15_mm;
502  double hMinY = 40_mm;
503  double hMaxY = 50_mm;
504  auto diamond =
505  std::make_shared<DiamondBounds>(hMinX, hMedX, hMaxX, hMinY, hMaxY);
506  auto diamondPlane = Surface::makeShared<PlaneSurface>(transform, diamond);
507  auto diamondPh =
508  diamondPlane->polyhedronRepresentation(tgContext, segments);
509  BOOST_CHECK(diamondPh.vertices.size() == 6);
510  BOOST_CHECK(diamondPh.faces.size() == 1);
511  extent = diamondPh.extent();
512  CHECK_CLOSE_ABS((extent.range(binX).min() -hMedX, 1e-6);
513  CHECK_CLOSE_ABS((extent.range(binX).max() hMedX, 1e-6);
514  CHECK_CLOSE_ABS((extent.range(binY).min() -hMinY, 1e-6);
515  CHECK_CLOSE_ABS((extent.range(binY).max() hMaxY, 1e-6);
516  CHECK_CLOSE_ABS((extent.range(binR).min() 0., 1e-6);
517  CHECK_CLOSE_ABS((extent.range(binR).max()
518  std::hypot(hMaxX, hMaxY), 1e-6);
519  CHECK_CLOSE_ABS((extent.range(binZ).min() 0., 1e-6);
520  CHECK_CLOSE_ABS((extent.range(binZ).max() 0., 1e-6);
521  }
522 }
523 
524 BOOST_AUTO_TEST_SUITE_END()
525 
526 } // namespace Test
527 
528 } // namespace Acts