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