Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:13:59

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma GCC diagnostic push
0010 #if __GNUC__ == 15
0011 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
0012 #endif
0013 #include <boost/test/data/test_case.hpp>
0014 #pragma GCC diagnostic pop
0015 #include <boost/test/unit_test.hpp>
0016 
0017 #include "Acts/Geometry/CylinderVolumeBuilder.hpp"
0018 
0019 #include <utility>
0020 
0021 namespace bdata = boost::unit_test::data;
0022 
0023 namespace Acts::Test {
0024 //
0025 
0026 /// Unit test for testing the wraps() function of the CylinderVolumeBuilder
0027 BOOST_DATA_TEST_CASE(
0028     CylinderVolumeBuilder_wraps,
0029     bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
0030                    bdata::distribution =
0031                        std::uniform_real_distribution<double>(-15., -11.))) ^
0032         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
0033                        bdata::distribution =
0034                            std::uniform_real_distribution<double>(11., 15.))) ^
0035         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3,
0036                        bdata::distribution =
0037                            std::uniform_real_distribution<double>(-10., 10.))) ^
0038         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 4,
0039                        bdata::distribution =
0040                            std::uniform_real_distribution<double>(0., 4.))) ^
0041         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 5,
0042                        bdata::distribution =
0043                            std::uniform_real_distribution<double>(11., 15.))) ^
0044         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 6,
0045                        bdata::distribution =
0046                            std::uniform_real_distribution<double>(10., 15.))) ^
0047         bdata::xrange(100),
0048     left, right, central, inner, outer, length, index) {
0049   (void)index;
0050   // inner volume
0051   VolumeConfig innerConfig;
0052   innerConfig.rMin = 0.;
0053   innerConfig.rMax = 10.;
0054   innerConfig.zMin = -10.;
0055   innerConfig.zMax = 10.;
0056 
0057   // volume to the left of the inner volume
0058   VolumeConfig outerConfig1;
0059   outerConfig1.rMin = inner;
0060   outerConfig1.rMax = inner + 5.;
0061   outerConfig1.zMin = left - 5.;
0062   outerConfig1.zMax = left;
0063 
0064   // volume to the right of the inner volume
0065   VolumeConfig outerConfig2;
0066   outerConfig2.rMin = inner;
0067   outerConfig2.rMax = inner + 5.;
0068   outerConfig2.zMin = right;
0069   outerConfig2.zMax = right + 5.;
0070 
0071   // volume around the inner volume
0072   VolumeConfig outerConfig3;
0073   outerConfig3.rMin = outer;
0074   outerConfig3.rMax = outer + 5.;
0075   outerConfig3.zMin = central - 5.;
0076   outerConfig3.zMax = central + 5.;
0077 
0078   // volume inside the inner volume
0079   VolumeConfig outerConfig4;
0080   outerConfig4.rMin = inner;
0081   outerConfig4.rMax = inner + 5.;
0082   outerConfig4.zMin = central - 5.;
0083   outerConfig4.zMax = central + 5.;
0084 
0085   // volume around the inner volume config
0086   VolumeConfig outerConfig5;
0087   outerConfig5.rMin = outer;
0088   outerConfig5.rMax = outer + 5.;
0089   outerConfig5.zMin = -length;
0090   outerConfig5.zMax = length;
0091 
0092   // volume around inner volume with same z boundaries
0093   VolumeConfig outerConfig6;
0094   outerConfig6.rMin = outer;
0095   outerConfig6.rMax = outer + 5.;
0096   outerConfig6.zMin = -10.;
0097   outerConfig6.zMax = 10.;
0098 
0099   // check if first volume wraps around the inner volume (wrapping in z)
0100   BOOST_CHECK(outerConfig1.wraps(innerConfig));
0101   // check if second volume wraps around the inner volume (wrapping in z)
0102   BOOST_CHECK(outerConfig2.wraps(innerConfig));
0103   // check if third volume wraps around the inner volume (wrapping in r)
0104   BOOST_CHECK(outerConfig3.wraps(innerConfig));
0105   // check if volume at inside the inner volume can not be wrapped
0106   BOOST_CHECK(!outerConfig4.wraps(innerConfig));
0107   // check if outside volume can not be wrapped around inside volume
0108   BOOST_CHECK(!innerConfig.wraps(outerConfig3));
0109   // check if outside volume contains inside volume
0110   BOOST_CHECK(outerConfig5.wraps(innerConfig));
0111   // check if inside volume is not contained by outside volume
0112   BOOST_CHECK(!innerConfig.wraps(outerConfig5));
0113   // check if outside volume wraps around the inside volume
0114   BOOST_CHECK(outerConfig6.wraps(innerConfig));
0115 }
0116 
0117 /// Unit test for testing the contains(), containsInR() and containsInZ()
0118 /// function of the CylinderVolumeBuilder
0119 BOOST_DATA_TEST_CASE(
0120     CylinderVolumeBuilder_containes,
0121     bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
0122                    bdata::distribution =
0123                        std::uniform_real_distribution<double>(-15., -11.))) ^
0124         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
0125                        bdata::distribution =
0126                            std::uniform_real_distribution<double>(11., 15.))) ^
0127         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3,
0128                        bdata::distribution =
0129                            std::uniform_real_distribution<double>(-10., 10.))) ^
0130         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 4,
0131                        bdata::distribution =
0132                            std::uniform_real_distribution<double>(0., 4.))) ^
0133         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 5,
0134                        bdata::distribution =
0135                            std::uniform_real_distribution<double>(10., 15.))) ^
0136         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 6,
0137                        bdata::distribution =
0138                            std::uniform_real_distribution<double>(10., 15.))) ^
0139         bdata::xrange(100),
0140     left, right, central, inner, outer, length, index) {
0141   (void)index;
0142   // inner volume
0143   VolumeConfig innerConfig;
0144   innerConfig.rMin = 0.;
0145   innerConfig.rMax = 10.;
0146   innerConfig.zMin = -10.;
0147   innerConfig.zMax = 10.;
0148 
0149   // volume to the left of the inner volume
0150   VolumeConfig outerConfig1;
0151   outerConfig1.rMin = inner;
0152   outerConfig1.rMax = inner + 5.;
0153   outerConfig1.zMin = left - 5.;
0154   outerConfig1.zMax = left;
0155 
0156   // volume to the right of the inner volume
0157   VolumeConfig outerConfig2;
0158   outerConfig2.rMin = inner;
0159   outerConfig2.rMax = inner + 5.;
0160   outerConfig2.zMin = right;
0161   outerConfig2.zMax = right + 5.;
0162 
0163   // volume around the inner volume in r
0164   VolumeConfig outerConfig3;
0165   outerConfig3.rMin = outer;
0166   outerConfig3.rMax = outer + 5.;
0167   outerConfig3.zMin = central - 5.;
0168   outerConfig3.zMax = central + 5.;
0169 
0170   // volume inside the inner volume
0171   VolumeConfig outerConfig4;
0172   outerConfig4.rMin = inner;
0173   outerConfig4.rMax = inner + 5.;
0174   outerConfig4.zMin = central - 5.;
0175   outerConfig4.zMax = central + 5.;
0176 
0177   // volume around the inner volume config
0178   VolumeConfig outerConfig5;
0179   outerConfig5.rMin = outer;
0180   outerConfig5.rMax = outer + 5.;
0181   outerConfig5.zMin = -length;
0182   outerConfig5.zMax = length;
0183 
0184   // volume around inner volume with same z boundaries
0185   VolumeConfig outerConfig6;
0186   outerConfig6.rMin = outer;
0187   outerConfig6.rMax = outer + 5.;
0188   outerConfig6.zMin = -10.;
0189   outerConfig6.zMax = 10.;
0190 
0191   // volume inside the inner volume config in z
0192   VolumeConfig innerConfig1;
0193   innerConfig1.rMin = outer;
0194   innerConfig1.rMax = outer + 5.;
0195   innerConfig1.zMin = inner - 5.;
0196   innerConfig1.zMax = inner + 5.;
0197 
0198   // check if first volume wraps around the inner volume (wrapping in z)
0199   BOOST_CHECK(!outerConfig1.contains(innerConfig));
0200   // check if second volume wraps around the inner volume (wrapping in z)
0201   BOOST_CHECK(!outerConfig2.contains(innerConfig));
0202   // check if volume at inside the inner volume can not be wrapped
0203   BOOST_CHECK(!outerConfig4.contains(innerConfig));
0204   // check if outside volume can not be wrapped around inside volume
0205   BOOST_CHECK(!innerConfig.contains(outerConfig3));
0206   // check if outside volume contains inside volume
0207   BOOST_CHECK(outerConfig5.contains(innerConfig));
0208   // check if inside volume is not contained by outside volume
0209   BOOST_CHECK(!innerConfig.contains(outerConfig5));
0210   // check if inside volume is not contained by outside volume
0211   BOOST_CHECK(!outerConfig6.contains(innerConfig));
0212 
0213   // containment checks in r and z for volumes which either contain in r or z
0214   BOOST_CHECK(innerConfig.containsInZ(innerConfig1));
0215   BOOST_CHECK(!innerConfig.containsInR(innerConfig1));
0216   BOOST_CHECK(innerConfig1.containsInR(innerConfig));
0217   BOOST_CHECK(!innerConfig1.containsInZ(innerConfig));
0218 }
0219 
0220 /// Unit test for testing the coverlapsInR()
0221 /// function of the CylinderVolumeBuilder
0222 BOOST_DATA_TEST_CASE(
0223     CylinderVolumeBuilder_overlapsInR,
0224     bdata::random((
0225         bdata::engine = std::mt19937(), bdata::seed = 1,
0226         bdata::distribution = std::uniform_real_distribution<double>(0., 4.))) ^
0227         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
0228                        bdata::distribution =
0229                            std::uniform_real_distribution<double>(11., 15.))) ^
0230         bdata::xrange(100),
0231     inner, outer, index) {
0232   (void)index;
0233   // reference volume
0234   VolumeConfig Config0;
0235   Config0.rMin = 5.;
0236   Config0.rMax = 10.;
0237   Config0.zMin = -10.;
0238   Config0.zMax = 10.;
0239   Config0.present = true;
0240 
0241   // volume inside volume0
0242   VolumeConfig Config1;
0243   Config1.rMin = 0.;
0244   Config1.rMax = inner;
0245   Config1.zMin = -10.;
0246   Config1.zMax = 10.;
0247 
0248   // volume outside volume0
0249   VolumeConfig Config2;
0250   Config2.rMin = outer;
0251   Config2.rMax = outer + 5.;
0252   Config2.zMin = -10.;
0253   Config2.zMax = 10.;
0254 
0255   // volume overlapping with rMin
0256   VolumeConfig Config3;
0257   Config3.rMin = inner + 5;
0258   Config3.rMax = outer + 5.;
0259   Config3.zMin = -10.;
0260   Config3.zMax = 10.;
0261 
0262   // volume overlapping with rMax
0263   VolumeConfig Config4;
0264   Config4.rMin = inner;
0265   Config4.rMax = inner + 5.;
0266   Config4.zMin = -10.;
0267   Config4.zMax = 10.;
0268 
0269   // volume overlapping with rMin and rMax
0270   VolumeConfig Config5;
0271   Config5.rMin = 5.;
0272   Config5.rMax = inner + 5.;
0273   Config5.zMin = -10.;
0274   Config5.zMax = 10.;
0275 
0276   // volume does not overlap with volume completely inside
0277   BOOST_CHECK(!Config0.overlapsInR(Config1));
0278   // volume does not overlap with volume completely outside
0279   BOOST_CHECK(!Config0.overlapsInR(Config2));
0280   // volume overlaps with rMin
0281   BOOST_CHECK(Config0.overlapsInR(Config3));
0282   // volume overlaps with rMax
0283   BOOST_CHECK(Config0.overlapsInR(Config4));
0284   // volume overlaps with rMin and rMax
0285   BOOST_CHECK(Config0.overlapsInR(Config5));
0286 }
0287 
0288 /// Unit test for testing the coverlapsInZ()
0289 /// function of the CylinderVolumeBuilder
0290 BOOST_DATA_TEST_CASE(
0291     CylinderVolumeBuilder_overlapsInZ,
0292     bdata::random((bdata::engine = std::mt19937(), bdata::seed = 1,
0293                    bdata::distribution =
0294                        std::uniform_real_distribution<double>(-15., -11.))) ^
0295         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 2,
0296                        bdata::distribution =
0297                            std::uniform_real_distribution<double>(11., 15.))) ^
0298         bdata::random((bdata::engine = std::mt19937(), bdata::seed = 3,
0299                        bdata::distribution =
0300                            std::uniform_real_distribution<double>(0., 4.))) ^
0301         bdata::xrange(100),
0302     left, right, inner, index) {
0303   (void)index;
0304   // inner volume
0305   VolumeConfig Config0;
0306   Config0.rMin = 0.;
0307   Config0.rMax = 10.;
0308   Config0.zMin = -10.;
0309   Config0.zMax = 10.;
0310   Config0.present = true;
0311 
0312   // volume to the left of volume0
0313   VolumeConfig Config1;
0314   Config1.rMin = 10.;
0315   Config1.rMax = 20.;
0316   Config1.zMin = left - 5.;
0317   Config1.zMax = left;
0318 
0319   // volume to the right of volume0
0320   VolumeConfig Config2;
0321   Config2.rMin = 10.;
0322   Config2.rMax = 20.;
0323   Config2.zMin = right;
0324   Config2.zMax = right + 5.;
0325 
0326   // volume around volume0 with same z boundaries
0327   VolumeConfig Config3;
0328   Config3.rMin = 10.;
0329   Config3.rMax = 20.;
0330   Config3.zMin = -10.;
0331   Config3.zMax = 10.;
0332 
0333   // volume inside volume0 config in z
0334   VolumeConfig Config4;
0335   Config4.rMin = 10.;
0336   Config4.rMax = 20.;
0337   Config4.zMin = inner - 5.;
0338   Config4.zMax = inner + 5.;
0339 
0340   // volume around volume0 config in z
0341   VolumeConfig Config5;
0342   Config5.rMin = 10.;
0343   Config5.rMax = 20.;
0344   Config5.zMin = left;
0345   Config5.zMax = right;
0346 
0347   // volume overlapping on the left
0348   VolumeConfig Config6;
0349   Config6.rMin = 10.;
0350   Config6.rMax = 20.;
0351   Config6.zMin = left;
0352   Config6.zMax = left + 10.;
0353 
0354   // volume overlapping on the right
0355   VolumeConfig Config7;
0356   Config7.rMin = 10.;
0357   Config7.rMax = 20.;
0358   Config7.zMin = right - 10.;
0359   Config7.zMax = right;
0360 
0361   // volume to the right and left do not overlap
0362   BOOST_CHECK(!Config0.overlapsInZ(Config1));
0363   BOOST_CHECK(!Config0.overlapsInZ(Config2));
0364   // volume with same boundaries overlaps
0365   BOOST_CHECK(Config0.overlapsInZ(Config3));
0366   // inside volume overlaps
0367   BOOST_CHECK(Config0.overlapsInZ(Config4));
0368   // volume around overlaps
0369   BOOST_CHECK(Config0.overlapsInZ(Config5));
0370   // volume overlaps on the sides
0371   BOOST_CHECK(Config0.overlapsInZ(Config6));
0372   BOOST_CHECK(Config0.overlapsInZ(Config7));
0373 }
0374 
0375 }  // namespace Acts::Test