EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingGeometryClosureTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackingGeometryClosureTests.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/unit_test.hpp>
10 
13 #include "Acts/Utilities/Units.hpp"
14 
16 
17 using namespace Acts::UnitLiterals;
18 
19 namespace Acts {
20 namespace Test {
21 
22 // Create a test context
24 
33 
34 // sensitive surface definitions
35 double surfaceHalfLengthZ = 50_mm;
36 double surfaceRstagger = 5_mm;
37 double surfaceZoverlap = 10_mm;
38 double layerEnvelope = 0.5_mm;
39 double volumeEnvelope = 10_mm;
40 
41 // inner inner volume definitions
42 double iiv_surfaceR = 25_mm;
43 double iiv_volumeR =
45 
47 double iov_surfaceR = 100_mm;
48 double iov_volumeR =
50 
55  "InnerInnerVolume");
60  "InnerOuterVolume");
61 
62 // now create the Inner Container volume
63 double volumeHalfZ =
68 
69 // outer volume definitions
70 double ov_surfaceR = 150_mm;
71 double ov_volumeR =
73 
78  "OuterVolume");
81  volumeHalfZ, "WorldVolume");
82 
83 // creating a TrackingGeometry
84 // -> closs the geometry, this should set the GeometryIdentifier
86 // get the world back
87 auto world = tGeometry.highestTrackingVolume();
88 
89 BOOST_AUTO_TEST_CASE(GeometryIdentifier_closeGeometry_test) {
90  // the lambda for checking
91  auto check_vol = [](const TrackingVolume& vol,
93  // check the geometry id of the volume
94  BOOST_CHECK_EQUAL(geoid, vol.geometryId().volume());
95  // check the geometry id of all boundary surfaces of the volume
96  // - this is strictly only possible when glueing if OFF
97  GeometryIdentifier::Value bsurface_id = 0;
98  for (auto bSf : vol.boundarySurfaces()) {
99  // check the bsurface volume id
100  auto bs_vol_id = bSf->surfaceRepresentation().geometryId().volume();
101  BOOST_CHECK_EQUAL(geoid, bs_vol_id);
102  // check the bsurface boundary id
103  auto bs_bsf_id = bSf->surfaceRepresentation().geometryId().boundary();
104  BOOST_CHECK_EQUAL(++bsurface_id, bs_bsf_id);
105  }
106  // testing the layer and it's approach surfaces
107  if (vol.confinedLayers() != nullptr) {
108  // layers start are counted from 1 - n
109  GeometryIdentifier::Value layer_id = 0;
110  for (auto lay : vol.confinedLayers()->arrayObjects()) {
111  // check the layer volume id and layer layer id
112  auto lay_vol_id = lay->geometryId().volume();
113  auto lay_lay_id = lay->geometryId().layer();
114  BOOST_CHECK_EQUAL(++layer_id, lay_lay_id);
115  BOOST_CHECK_EQUAL(geoid, lay_vol_id);
116  // test the layer approach surfaces
117  if (lay->approachDescriptor() != nullptr) {
118  // approach surfacesare counted from 1 - n
119  GeometryIdentifier::Value asurface_id = 0;
120  for (auto asf : lay->approachDescriptor()->containedSurfaces()) {
121  // check the approach volume id, approach layer id, approach
122  // approach
123  // id
124  auto asf_vol_id = asf->geometryId().volume();
125  auto asf_lay_id = asf->geometryId().layer();
126  auto asf_asf_id = asf->geometryId().approach();
127  BOOST_CHECK_EQUAL(layer_id, asf_lay_id);
128  BOOST_CHECK_EQUAL(geoid, asf_vol_id);
129  BOOST_CHECK_EQUAL(++asurface_id, asf_asf_id);
130  }
131  }
132  // test the sensitive surfaces
133  if (lay->surfaceArray() != nullptr) {
134  // sensitive surfaces are counted from 1 - n
135  GeometryIdentifier::Value ssurface_id = 0;
136  for (auto ssf : lay->surfaceArray()->surfaces()) {
137  // check the approach volume id, approach layer id, approach
138  // approach
139  // id
140  auto ssf_vol_id = ssf->geometryId().volume();
141  auto ssf_lay_id = ssf->geometryId().layer();
142  auto ssf_ssf_id = ssf->geometryId().sensitive();
143  BOOST_CHECK_EQUAL(layer_id, ssf_lay_id);
144  BOOST_CHECK_EQUAL(geoid, ssf_vol_id);
145  BOOST_CHECK_EQUAL(++ssurface_id, ssf_ssf_id);
146  }
147  }
148  }
149  }
150  };
151 
152  // get the two volumes the world is built of
153  auto ioVolumes = world->confinedVolumes()->arrayObjects();
154  // check the size - has to be two volumes
155  BOOST_CHECK_EQUAL(2ul, ioVolumes.size());
156  // get the innermost volumes
157  auto iioVolumes = ioVolumes[0]->confinedVolumes()->arrayObjects();
158  // check the size - has to be two volumes
159  BOOST_CHECK_EQUAL(2ul, iioVolumes.size());
160 
161  // check the world
162  check_vol(*world, 1);
163  // - check InnerVolume
164  check_vol(*ioVolumes[0], 2);
165  // -- check the InnerInnerVolume
166  check_vol(*iioVolumes[0], 3);
167  // -- check the InenerOuterVolume
168  check_vol(*iioVolumes[1], 4);
169  // - check the OuterVolume
170  check_vol(*ioVolumes[1], 5);
171 }
172 
173 BOOST_AUTO_TEST_CASE(TrackingGeometry_testVisitSurfaces) {
174  // this will also cover TrackingVolume::visitSurfaces
175  // its a pretty bare bones test, and only asserts that the
176  // method is called on the expected number of surfaces
177  size_t nSurfaces = 0;
178  tGeometry.visitSurfaces([&nSurfaces](const auto*) { nSurfaces++; });
179 
180  BOOST_CHECK_EQUAL(nSurfaces, 9u);
181 }
182 
183 } // end of namespace Test
184 } // end of namespace Acts