ECCE @ 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
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 GeometryID
86 // get the world back
87 auto world = tGeometry.highestTrackingVolume();
88 
89 BOOST_AUTO_TEST_CASE(GeometryID_closeGeometry_test) {
90  // the lambda for checking
91  auto check_vol = [](const TrackingVolume& vol, GeometryID::Value geoid) {
92  // check the geometry id of the volume
93  BOOST_CHECK_EQUAL(geoid, vol.geoID().volume());
94  // check the geometry id of all boundary surfaces of the volume
95  // - this is strictly only possible when glueing if OFF
96  GeometryID::Value bsurface_id = 0;
97  for (auto bSf : vol.boundarySurfaces()) {
98  // check the bsurface volume id
99  auto bs_vol_id = bSf->surfaceRepresentation().geoID().volume();
100  BOOST_CHECK_EQUAL(geoid, bs_vol_id);
101  // check the bsurface boundary id
102  auto bs_bsf_id = bSf->surfaceRepresentation().geoID().boundary();
103  BOOST_CHECK_EQUAL(++bsurface_id, bs_bsf_id);
104  }
105  // testing the layer and it's approach surfaces
106  if (vol.confinedLayers() != nullptr) {
107  // layers start are counted from 1 - n
108  GeometryID::Value layer_id = 0;
109  for (auto lay : vol.confinedLayers()->arrayObjects()) {
110  // check the layer volume id and layer layer id
111  auto lay_vol_id = lay->geoID().volume();
112  auto lay_lay_id = lay->geoID().layer();
113  BOOST_CHECK_EQUAL(++layer_id, lay_lay_id);
114  BOOST_CHECK_EQUAL(geoid, lay_vol_id);
115  // test the layer approach surfaces
116  if (lay->approachDescriptor() != nullptr) {
117  // approach surfacesare counted from 1 - n
118  GeometryID::Value asurface_id = 0;
119  for (auto asf : lay->approachDescriptor()->containedSurfaces()) {
120  // check the approach volume id, approach layer id, approach
121  // approach
122  // id
123  auto asf_vol_id = asf->geoID().volume();
124  auto asf_lay_id = asf->geoID().layer();
125  auto asf_asf_id = asf->geoID().approach();
126  BOOST_CHECK_EQUAL(layer_id, asf_lay_id);
127  BOOST_CHECK_EQUAL(geoid, asf_vol_id);
128  BOOST_CHECK_EQUAL(++asurface_id, asf_asf_id);
129  }
130  }
131  // test the sensitive surfaces
132  if (lay->surfaceArray() != nullptr) {
133  // sensitive surfaces are counted from 1 - n
134  GeometryID::Value ssurface_id = 0;
135  for (auto ssf : lay->surfaceArray()->surfaces()) {
136  // check the approach volume id, approach layer id, approach
137  // approach
138  // id
139  auto ssf_vol_id = ssf->geoID().volume();
140  auto ssf_lay_id = ssf->geoID().layer();
141  auto ssf_ssf_id = ssf->geoID().sensitive();
142  BOOST_CHECK_EQUAL(layer_id, ssf_lay_id);
143  BOOST_CHECK_EQUAL(geoid, ssf_vol_id);
144  BOOST_CHECK_EQUAL(++ssurface_id, ssf_ssf_id);
145  }
146  }
147  }
148  }
149  };
150 
151  // get the two volumes the world is built of
152  auto ioVolumes = world->confinedVolumes()->arrayObjects();
153  // check the size - has to be two volumes
154  BOOST_CHECK_EQUAL(2ul, ioVolumes.size());
155  // get the innermost volumes
156  auto iioVolumes = ioVolumes[0]->confinedVolumes()->arrayObjects();
157  // check the size - has to be two volumes
158  BOOST_CHECK_EQUAL(2ul, iioVolumes.size());
159 
160  // check the world
161  check_vol(*world, 1);
162  // - check InnerVolume
163  check_vol(*ioVolumes[0], 2);
164  // -- check the InnerInnerVolume
165  check_vol(*iioVolumes[0], 3);
166  // -- check the InenerOuterVolume
167  check_vol(*iioVolumes[1], 4);
168  // - check the OuterVolume
169  check_vol(*ioVolumes[1], 5);
170 }
171 
172 BOOST_AUTO_TEST_CASE(TrackingGeometry_testVisitSurfaces) {
173  // this will also cover TrackingVolume::visitSurfaces
174  // its a pretty bare bones test, and only asserts that the
175  // method is called on the expected number of surfaces
176  size_t nSurfaces = 0;
177  tGeometry.visitSurfaces([&nSurfaces](const auto*) { nSurfaces++; });
178 
179  BOOST_CHECK_EQUAL(nSurfaces, 9u);
180 }
181 
182 } // end of namespace Test
183 } // end of namespace Acts