Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CylinderVolumeBuilderTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CylinderVolumeBuilderTests.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/unit_test.hpp>
11 
13 
14 #include <utility>
15 
16 namespace bdata = boost::unit_test::data;
17 namespace tt = boost::test_tools;
18 
19 namespace Acts {
20 
21 namespace Test {
22 
24 BOOST_DATA_TEST_CASE(CylinderVolumeBuilder_wraps,
25  bdata::random(-11., -15.) ^ bdata::random(11., 15.) ^
26  bdata::random(-10., 10.) ^ bdata::random(0., 4.) ^
27  bdata::random(11., 15.) ^ bdata::random(10., 15.) ^
28  bdata::xrange(100),
29  left, right, central, inner, outer, length, index) {
30  (void)index;
31  // inner volume
32  VolumeConfig innerConfig;
33  innerConfig.rMin = 0.;
34  innerConfig.rMax = 10.;
35  innerConfig.zMin = -10.;
36  innerConfig.zMax = 10.;
37 
38  // volume to the left of the inner volume
39  VolumeConfig outerConfig1;
40  outerConfig1.rMin = inner;
41  outerConfig1.rMax = inner + 5.;
42  outerConfig1.zMin = left - 5.;
43  outerConfig1.zMax = left;
44 
45  // volume to the right of the inner volume
46  VolumeConfig outerConfig2;
47  outerConfig2.rMin = inner;
48  outerConfig2.rMax = inner + 5.;
49  outerConfig2.zMin = right;
50  outerConfig2.zMax = right + 5.;
51 
52  // volume around the inner volume
53  VolumeConfig outerConfig3;
54  outerConfig3.rMin = outer;
55  outerConfig3.rMax = outer + 5.;
56  outerConfig3.zMin = central - 5.;
57  outerConfig3.zMax = central + 5.;
58 
59  // volume inside the inner volume
60  VolumeConfig outerConfig4;
61  outerConfig4.rMin = inner;
62  outerConfig4.rMax = inner + 5.;
63  outerConfig4.zMin = central - 5.;
64  outerConfig4.zMax = central + 5.;
65 
66  // volume around the inner volume config
67  VolumeConfig outerConfig5;
68  outerConfig5.rMin = outer;
69  outerConfig5.rMax = outer + 5.;
70  outerConfig5.zMin = -length;
71  outerConfig5.zMax = length;
72 
73  // volume around inner volume with same z boundaries
74  VolumeConfig outerConfig6;
75  outerConfig6.rMin = outer;
76  outerConfig6.rMax = outer + 5.;
77  outerConfig6.zMin = -10.;
78  outerConfig6.zMax = 10.;
79 
80  // check if first volume wraps around the inner volume (wrapping in z)
81  BOOST_CHECK(outerConfig1.wraps(innerConfig));
82  // check if second volume wraps around the inner volume (wrapping in z)
83  BOOST_CHECK(outerConfig2.wraps(innerConfig));
84  // check if third volume wraps around the inner volume (wrapping in r)
85  BOOST_CHECK(outerConfig3.wraps(innerConfig));
86  // check if volume at inside the inner volume can not be wrapped
87  BOOST_CHECK(!outerConfig4.wraps(innerConfig));
88  // check if outside volume can not be wrapped around inside volume
89  BOOST_CHECK(!innerConfig.wraps(outerConfig3));
90  // check if outside volume contains inside volume
91  BOOST_CHECK(outerConfig5.wraps(innerConfig));
92  // check if inside volume is not contained by outside volume
93  BOOST_CHECK(!innerConfig.wraps(outerConfig5));
94  // check if outside volume wraps around the inside volume
95  BOOST_CHECK(outerConfig6.wraps(innerConfig));
96 }
97 
100 BOOST_DATA_TEST_CASE(CylinderVolumeBuilder_containes,
101  bdata::random(-11., -15.) ^ bdata::random(11., 15.) ^
102  bdata::random(-10., 10.) ^ bdata::random(0., 4.) ^
103  bdata::random(10., 15.) ^ bdata::random(10., 15.) ^
104  bdata::xrange(100),
105  left, right, central, inner, outer, length, index) {
106  (void)index;
107  // inner volume
108  VolumeConfig innerConfig;
109  innerConfig.rMin = 0.;
110  innerConfig.rMax = 10.;
111  innerConfig.zMin = -10.;
112  innerConfig.zMax = 10.;
113 
114  // volume to the left of the inner volume
115  VolumeConfig outerConfig1;
116  outerConfig1.rMin = inner;
117  outerConfig1.rMax = inner + 5.;
118  outerConfig1.zMin = left - 5.;
119  outerConfig1.zMax = left;
120 
121  // volume to the right of the inner volume
122  VolumeConfig outerConfig2;
123  outerConfig2.rMin = inner;
124  outerConfig2.rMax = inner + 5.;
125  outerConfig2.zMin = right;
126  outerConfig2.zMax = right + 5.;
127 
128  // volume around the inner volume in r
129  VolumeConfig outerConfig3;
130  outerConfig3.rMin = outer;
131  outerConfig3.rMax = outer + 5.;
132  outerConfig3.zMin = central - 5.;
133  outerConfig3.zMax = central + 5.;
134 
135  // volume inside the inner volume
136  VolumeConfig outerConfig4;
137  outerConfig4.rMin = inner;
138  outerConfig4.rMax = inner + 5.;
139  outerConfig4.zMin = central - 5.;
140  outerConfig4.zMax = central + 5.;
141 
142  // volume around the inner volume config
143  VolumeConfig outerConfig5;
144  outerConfig5.rMin = outer;
145  outerConfig5.rMax = outer + 5.;
146  outerConfig5.zMin = -length;
147  outerConfig5.zMax = length;
148 
149  // volume around inner volume with same z boundaries
150  VolumeConfig outerConfig6;
151  outerConfig6.rMin = outer;
152  outerConfig6.rMax = outer + 5.;
153  outerConfig6.zMin = -10.;
154  outerConfig6.zMax = 10.;
155 
156  // volume inside the inner volume config in z
157  VolumeConfig innerConfig1;
158  innerConfig1.rMin = outer;
159  innerConfig1.rMax = outer + 5.;
160  innerConfig1.zMin = inner - 5.;
161  innerConfig1.zMax = inner + 5.;
162 
163  // check if first volume wraps around the inner volume (wrapping in z)
164  BOOST_CHECK(!outerConfig1.contains(innerConfig));
165  // check if second volume wraps around the inner volume (wrapping in z)
166  BOOST_CHECK(!outerConfig2.contains(innerConfig));
167  // check if volume at inside the inner volume can not be wrapped
168  BOOST_CHECK(!outerConfig4.contains(innerConfig));
169  // check if outside volume can not be wrapped around inside volume
170  BOOST_CHECK(!innerConfig.contains(outerConfig3));
171  // check if outside volume contains inside volume
172  BOOST_CHECK(outerConfig5.contains(innerConfig));
173  // check if inside volume is not contained by outside volume
174  BOOST_CHECK(!innerConfig.contains(outerConfig5));
175  // check if inside volume is not contained by outside volume
176  BOOST_CHECK(!outerConfig6.contains(innerConfig));
177 
178  // containment checks in r and z for volumes which either contain in r or z
179  BOOST_CHECK(innerConfig.containsInZ(innerConfig1));
180  BOOST_CHECK(!innerConfig.containsInR(innerConfig1));
181  BOOST_CHECK(innerConfig1.containsInR(innerConfig));
182  BOOST_CHECK(!innerConfig1.containsInZ(innerConfig));
183 }
184 
187 BOOST_DATA_TEST_CASE(CylinderVolumeBuilder_overlapsInR,
188  bdata::random(0., 4.) ^ bdata::random(11., 15.) ^
189  bdata::xrange(100),
190  inner, outer, index) {
191  (void)index;
192  // reference volume
193  VolumeConfig Config0;
194  Config0.rMin = 5.;
195  Config0.rMax = 10.;
196  Config0.zMin = -10.;
197  Config0.zMax = 10.;
198  Config0.present = true;
199 
200  // volume inside volume0
201  VolumeConfig Config1;
202  Config1.rMin = 0.;
203  Config1.rMax = inner;
204  Config1.zMin = -10.;
205  Config1.zMax = 10.;
206 
207  // volume outside volume0
208  VolumeConfig Config2;
209  Config2.rMin = outer;
210  Config2.rMax = outer + 5.;
211  Config2.zMin = -10.;
212  Config2.zMax = 10.;
213 
214  // volume overlapping with rMin
215  VolumeConfig Config3;
216  Config3.rMin = inner + 5;
217  Config3.rMax = outer + 5.;
218  Config3.zMin = -10.;
219  Config3.zMax = 10.;
220 
221  // volume overlapping with rMax
222  VolumeConfig Config4;
223  Config4.rMin = inner;
224  Config4.rMax = inner + 5.;
225  Config4.zMin = -10.;
226  Config4.zMax = 10.;
227 
228  // volume overlapping with rMin and rMax
229  VolumeConfig Config5;
230  Config5.rMin = 5.;
231  Config5.rMax = inner + 5.;
232  Config5.zMin = -10.;
233  Config5.zMax = 10.;
234 
235  // volume does not overlap with volume completely inside
236  BOOST_CHECK(!Config0.overlapsInR(Config1));
237  // volume does not overlap with volume completely outside
238  BOOST_CHECK(!Config0.overlapsInR(Config2));
239  // volume overlaps with rMin
240  BOOST_CHECK(Config0.overlapsInR(Config3));
241  // volume overlaps with rMax
242  BOOST_CHECK(Config0.overlapsInR(Config4));
243  // volume overlaps with rMin and rMax
244  BOOST_CHECK(Config0.overlapsInR(Config5));
245 }
246 
249 BOOST_DATA_TEST_CASE(CylinderVolumeBuilder_overlapsInZ,
250  bdata::random(-11., -15.) ^ bdata::random(11., 15.) ^
251  bdata::random(0., 4.) ^ bdata::xrange(100),
252  left, right, inner, index) {
253  (void)index;
254  // inner volume
255  VolumeConfig Config0;
256  Config0.rMin = 0.;
257  Config0.rMax = 10.;
258  Config0.zMin = -10.;
259  Config0.zMax = 10.;
260  Config0.present = true;
261 
262  // volume to the left of volume0
263  VolumeConfig Config1;
264  Config1.rMin = 10.;
265  Config1.rMax = 20.;
266  Config1.zMin = left - 5.;
267  Config1.zMax = left;
268 
269  // volume to the right of volume0
270  VolumeConfig Config2;
271  Config2.rMin = 10.;
272  Config2.rMax = 20.;
273  Config2.zMin = right;
274  Config2.zMax = right + 5.;
275 
276  // volume around volume0 with same z boundaries
277  VolumeConfig Config3;
278  Config3.rMin = 10.;
279  Config3.rMax = 20.;
280  Config3.zMin = -10.;
281  Config3.zMax = 10.;
282 
283  // volume inside volume0 config in z
284  VolumeConfig Config4;
285  Config4.rMin = 10.;
286  Config4.rMax = 20.;
287  Config4.zMin = inner - 5.;
288  Config4.zMax = inner + 5.;
289 
290  // volume around volume0 config in z
291  VolumeConfig Config5;
292  Config5.rMin = 10.;
293  Config5.rMax = 20.;
294  Config5.zMin = left;
295  Config5.zMax = right;
296 
297  // volume overlapping on the left
298  VolumeConfig Config6;
299  Config6.rMin = 10.;
300  Config6.rMax = 20.;
301  Config6.zMin = left;
302  Config6.zMax = left + 10.;
303 
304  // volume overlapping on the right
305  VolumeConfig Config7;
306  Config7.rMin = 10.;
307  Config7.rMax = 20.;
308  Config7.zMin = right - 10.;
309  Config7.zMax = right;
310 
311  // volume to the right and left do not overlap
312  BOOST_CHECK(!Config0.overlapsInZ(Config1));
313  BOOST_CHECK(!Config0.overlapsInZ(Config2));
314  // volume with same boundaries overlaps
315  BOOST_CHECK(Config0.overlapsInZ(Config3));
316  // inside volume overlaps
317  BOOST_CHECK(Config0.overlapsInZ(Config4));
318  // volume around overlaps
319  BOOST_CHECK(Config0.overlapsInZ(Config5));
320  // volume overlaps on the sides
321  BOOST_CHECK(Config0.overlapsInZ(Config6));
322  BOOST_CHECK(Config0.overlapsInZ(Config7));
323 }
324 
325 } // namespace Test
326 
327 } // namespace Acts