File indexing completed on 2025-01-18 09:12:33
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Detector/ProtoDetector.hpp"
0013 #include "Acts/Geometry/Extent.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0016 #include "Acts/Utilities/BinningData.hpp"
0017 #include "Acts/Utilities/BinningType.hpp"
0018
0019 #include <iostream>
0020 #include <limits>
0021 #include <memory>
0022 #include <optional>
0023 #include <string>
0024 #include <vector>
0025
0026 namespace {
0027
0028
0029
0030
0031
0032
0033
0034 Acts::ProtoDetector createProtoDetector() {
0035
0036 Acts::ProtoVolume detectorVolume;
0037 detectorVolume.name = "detector-container";
0038 detectorVolume.extent.set(Acts::AxisDirection::AxisZ, -2000., 2000);
0039
0040
0041 Acts::ProtoVolume beamPipe;
0042 beamPipe.name = "beam-pipe";
0043 beamPipe.extent.set(Acts::AxisDirection::AxisR, 0., 30.);
0044
0045
0046 Acts::ProtoVolume pixelContainer;
0047 pixelContainer.name = "pixel-container";
0048 pixelContainer.extent.set(Acts::AxisDirection::AxisR, 40., 200);
0049
0050
0051 Acts::ProtoVolume pixelNec;
0052 pixelNec.name = "pixel-nec";
0053 pixelNec.extent.set(Acts::AxisDirection::AxisZ, -1900., -600);
0054
0055 Acts::ProtoVolume pixelBarrel;
0056 pixelBarrel.name = "pixel-barrel";
0057 pixelBarrel.extent.set(Acts::AxisDirection::AxisR, 41., 199.);
0058 pixelBarrel.extent.set(Acts::AxisDirection::AxisZ, -550., 550.);
0059
0060 Acts::ProtoVolume pixelBarrelL0;
0061 pixelBarrelL0.name = "pixel-barrel-l0";
0062 pixelBarrelL0.extent.set(Acts::AxisDirection::AxisR, 45., 50.);
0063 pixelBarrelL0.internal = Acts::ProtoVolume::InternalStructure{
0064 Acts::Surface::SurfaceType::Cylinder};
0065
0066 Acts::ProtoVolume pixelBarrelL1;
0067 pixelBarrelL1.name = "pixel-barrel-l1";
0068 pixelBarrelL1.extent.set(Acts::AxisDirection::AxisR, 70., 80.);
0069 pixelBarrelL1.internal = Acts::ProtoVolume::InternalStructure{
0070 Acts::Surface::SurfaceType::Cylinder};
0071
0072 pixelBarrel.container = Acts::ProtoVolume::ContainerStructure{
0073 {pixelBarrelL0, pixelBarrelL1},
0074 {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisR, {0., 1.})},
0075 true};
0076
0077 Acts::ProtoVolume pixelPec;
0078 pixelPec.name = "pixel-pec";
0079 pixelPec.extent.set(Acts::AxisDirection::AxisZ, 600., 1900.);
0080
0081 pixelContainer.container = Acts::ProtoVolume::ContainerStructure{
0082 {pixelNec, pixelBarrel, pixelPec},
0083 {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisZ, {0., 1})}};
0084
0085 detectorVolume.container = Acts::ProtoVolume::ContainerStructure{
0086 {beamPipe, pixelContainer},
0087 {Acts::BinningData(Acts::open, Acts::AxisDirection::AxisR, {0., 1})}};
0088
0089 Acts::ProtoDetector detector;
0090 detector.name = "detector";
0091 detector.worldVolume = detectorVolume;
0092
0093 return detector;
0094 }
0095
0096 }
0097
0098 namespace Acts::Test {
0099
0100 BOOST_AUTO_TEST_SUITE(Detector)
0101
0102 BOOST_AUTO_TEST_CASE(ProtoTrackingGeometryTests) {
0103
0104 auto detector = createProtoDetector();
0105 detector.harmonize(true);
0106
0107
0108 auto& detectorVolume = detector.worldVolume;
0109
0110
0111 CHECK_CLOSE_ABS(detectorVolume.extent.min(Acts::AxisDirection::AxisR), 0,
0112 std::numeric_limits<double>::epsilon());
0113
0114 CHECK_CLOSE_ABS(detectorVolume.extent.max(Acts::AxisDirection::AxisR), 200.,
0115 std::numeric_limits<double>::epsilon());
0116
0117
0118 BOOST_CHECK(detectorVolume.container.has_value());
0119 BOOST_CHECK(!detectorVolume.internal.has_value());
0120
0121 auto& cts = detectorVolume.container.value();
0122
0123 BOOST_CHECK_EQUAL(cts.constituentBinning.size(), 1u);
0124 BOOST_CHECK_EQUAL(cts.constituentBinning[0].type, Acts::arbitrary);
0125 BOOST_CHECK_EQUAL(cts.constituentBinning[0].binvalue,
0126 Acts::AxisDirection::AxisR);
0127
0128 const auto& binBoundaries = cts.constituentBinning[0].boundaries();
0129 BOOST_CHECK_EQUAL(binBoundaries.size(), 3u);
0130 CHECK_CLOSE_ABS(binBoundaries[0u], 0.,
0131 std::numeric_limits<double>::epsilon());
0132 CHECK_CLOSE_ABS(binBoundaries[1u], 35.,
0133 std::numeric_limits<double>::epsilon());
0134 CHECK_CLOSE_ABS(binBoundaries[2u], 200.,
0135 std::numeric_limits<double>::epsilon());
0136
0137
0138
0139 auto& beamPipe = cts.constituentVolumes[0u];
0140
0141 BOOST_CHECK_EQUAL(beamPipe.name, "beam-pipe");
0142 CHECK_CLOSE_ABS(beamPipe.extent.min(Acts::AxisDirection::AxisZ), -2000.,
0143 std::numeric_limits<double>::epsilon());
0144
0145 CHECK_CLOSE_ABS(beamPipe.extent.max(Acts::AxisDirection::AxisZ), 2000.,
0146 std::numeric_limits<double>::epsilon());
0147
0148
0149 CHECK_CLOSE_ABS(beamPipe.extent.max(Acts::AxisDirection::AxisR), 35.,
0150 std::numeric_limits<double>::epsilon());
0151
0152
0153 auto& pixelContainer = cts.constituentVolumes[1u];
0154 BOOST_CHECK_EQUAL(pixelContainer.name, "pixel-container");
0155
0156
0157 CHECK_CLOSE_ABS(pixelContainer.extent.min(Acts::AxisDirection::AxisR), 35.,
0158 std::numeric_limits<double>::epsilon());
0159 CHECK_CLOSE_ABS(pixelContainer.extent.max(Acts::AxisDirection::AxisR), 200.,
0160 std::numeric_limits<double>::epsilon());
0161 CHECK_CLOSE_ABS(pixelContainer.extent.min(Acts::AxisDirection::AxisZ), -2000.,
0162 std::numeric_limits<double>::epsilon());
0163 CHECK_CLOSE_ABS(pixelContainer.extent.max(Acts::AxisDirection::AxisZ), 2000.,
0164 std::numeric_limits<double>::epsilon());
0165
0166
0167 BOOST_CHECK(pixelContainer.container.has_value());
0168 auto& cts1 = pixelContainer.container.value();
0169
0170
0171
0172 for (auto& pv : cts1.constituentVolumes) {
0173 CHECK_CLOSE_ABS(pv.extent.min(Acts::AxisDirection::AxisR), 35.,
0174 std::numeric_limits<double>::epsilon());
0175
0176 CHECK_CLOSE_ABS(pv.extent.max(Acts::AxisDirection::AxisR), 200.,
0177 std::numeric_limits<double>::epsilon());
0178 }
0179
0180
0181 BOOST_CHECK_EQUAL(cts1.constituentBinning.size(), 1u);
0182 BOOST_CHECK_EQUAL(cts1.constituentBinning[0].type, Acts::arbitrary);
0183 BOOST_CHECK_EQUAL(cts1.constituentBinning[0].binvalue,
0184 Acts::AxisDirection::AxisZ);
0185
0186 const auto& binBoundariesZ = cts1.constituentBinning[0].boundaries();
0187 BOOST_CHECK_EQUAL(binBoundariesZ.size(), 4u);
0188 CHECK_CLOSE_ABS(binBoundariesZ[0u], -2000.,
0189 std::numeric_limits<double>::epsilon());
0190 CHECK_CLOSE_ABS(binBoundariesZ[1u], -575,
0191 std::numeric_limits<double>::epsilon());
0192 CHECK_CLOSE_ABS(binBoundariesZ[2u], 575.,
0193 std::numeric_limits<double>::epsilon());
0194 CHECK_CLOSE_ABS(binBoundariesZ[3u], 2000.,
0195 std::numeric_limits<double>::epsilon());
0196
0197
0198 auto& pixelBarrel = cts1.constituentVolumes[1u];
0199 BOOST_CHECK_EQUAL(pixelBarrel.name, "pixel-barrel");
0200
0201
0202 BOOST_CHECK(pixelBarrel.container.has_value());
0203 auto& cts2 = pixelBarrel.container.value();
0204
0205 BOOST_CHECK(cts2.layerContainer);
0206 for (auto& lVolume : cts2.constituentVolumes) {
0207 BOOST_CHECK(lVolume.internal.has_value());
0208 }
0209 }
0210
0211 BOOST_AUTO_TEST_CASE(ProtoDetectorTests) {
0212
0213 auto detector = createProtoDetector();
0214 detector.harmonize(false);
0215 std::cout << detector.toString() << std::endl;
0216 }
0217
0218 BOOST_AUTO_TEST_SUITE_END()
0219
0220 }