Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-30 07:55:12

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 #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/Utilities/BinningData.hpp"
0016 #include "Acts/Utilities/BinningType.hpp"
0017 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0018 
0019 #include <iostream>
0020 #include <limits>
0021 #include <memory>
0022 #include <optional>
0023 #include <string>
0024 #include <vector>
0025 
0026 using namespace Acts;
0027 
0028 namespace ActsTests {
0029 
0030 /// @brief This method creates a world volume with
0031 /// some sub structure, this detector is not yet
0032 /// synchronized, it can then be typed into the
0033 /// Detector or the TrackGeometry description
0034 ///
0035 /// @return a proto world volume
0036 ProtoDetector createProtoDetector() {
0037   // Container
0038   ProtoVolume detectorVolume;
0039   detectorVolume.name = "detector-container";
0040   detectorVolume.extent.set(AxisDirection::AxisZ, -2000., 2000);
0041 
0042   // Beam Pipe volume
0043   ProtoVolume beamPipe;
0044   beamPipe.name = "beam-pipe";
0045   beamPipe.extent.set(AxisDirection::AxisR, 0., 30.);
0046 
0047   // Pixel section
0048   ProtoVolume pixelContainer;
0049   pixelContainer.name = "pixel-container";
0050   pixelContainer.extent.set(AxisDirection::AxisR, 40., 200);
0051 
0052   // Pixel volume sub structure
0053   ProtoVolume pixelNec;
0054   pixelNec.name = "pixel-nec";
0055   pixelNec.extent.set(AxisDirection::AxisZ, -1900., -600);
0056 
0057   ProtoVolume pixelBarrel;
0058   pixelBarrel.name = "pixel-barrel";
0059   pixelBarrel.extent.set(AxisDirection::AxisR, 41., 199.);
0060   pixelBarrel.extent.set(AxisDirection::AxisZ, -550., 550.);
0061 
0062   ProtoVolume pixelBarrelL0;
0063   pixelBarrelL0.name = "pixel-barrel-l0";
0064   pixelBarrelL0.extent.set(AxisDirection::AxisR, 45., 50.);
0065   pixelBarrelL0.internal =
0066       ProtoVolume::InternalStructure{Surface::SurfaceType::Cylinder};
0067 
0068   ProtoVolume pixelBarrelL1;
0069   pixelBarrelL1.name = "pixel-barrel-l1";
0070   pixelBarrelL1.extent.set(AxisDirection::AxisR, 70., 80.);
0071   pixelBarrelL1.internal =
0072       ProtoVolume::InternalStructure{Surface::SurfaceType::Cylinder};
0073 
0074   pixelBarrel.container = ProtoVolume::ContainerStructure{
0075       {pixelBarrelL0, pixelBarrelL1},
0076       {BinningData(open, AxisDirection::AxisR, {0., 1.})},
0077       true};
0078 
0079   ProtoVolume pixelPec;
0080   pixelPec.name = "pixel-pec";
0081   pixelPec.extent.set(AxisDirection::AxisZ, 600., 1900.);
0082 
0083   pixelContainer.container = ProtoVolume::ContainerStructure{
0084       {pixelNec, pixelBarrel, pixelPec},
0085       {BinningData(open, AxisDirection::AxisZ, {0., 1})}};
0086 
0087   detectorVolume.container = ProtoVolume::ContainerStructure{
0088       {beamPipe, pixelContainer},
0089       {BinningData(open, AxisDirection::AxisR, {0., 1})}};
0090 
0091   ProtoDetector detector;
0092   detector.name = "detector";
0093   detector.worldVolume = detectorVolume;
0094 
0095   return detector;
0096 }
0097 
0098 BOOST_AUTO_TEST_SUITE(DetectorSuite)
0099 
0100 BOOST_AUTO_TEST_CASE(ProtoTrackingGeometryTests) {
0101   // Get the raw proto detector description
0102   auto detector = createProtoDetector();
0103   detector.harmonize(true);
0104 
0105   // Get the top detector volume
0106   auto& detectorVolume = detector.worldVolume;
0107 
0108   // The detector volume should have received maximum dimensions
0109   CHECK_CLOSE_ABS(detectorVolume.extent.min(AxisDirection::AxisR), 0,
0110                   std::numeric_limits<double>::epsilon());
0111 
0112   CHECK_CLOSE_ABS(detectorVolume.extent.max(AxisDirection::AxisR), 200.,
0113                   std::numeric_limits<double>::epsilon());
0114 
0115   // The detector container should have binning in R
0116   BOOST_CHECK(detectorVolume.container.has_value());
0117   BOOST_CHECK(!detectorVolume.internal.has_value());
0118 
0119   auto& cts = detectorVolume.container.value();
0120 
0121   BOOST_CHECK_EQUAL(cts.constituentBinning.size(), 1u);
0122   BOOST_CHECK_EQUAL(cts.constituentBinning[0].type, arbitrary);
0123   BOOST_CHECK_EQUAL(cts.constituentBinning[0].binvalue, AxisDirection::AxisR);
0124 
0125   const auto& binBoundaries = cts.constituentBinning[0].boundaries();
0126   BOOST_CHECK_EQUAL(binBoundaries.size(), 3u);
0127   CHECK_CLOSE_ABS(binBoundaries[0u], 0.,
0128                   std::numeric_limits<double>::epsilon());
0129   CHECK_CLOSE_ABS(binBoundaries[1u], 35.,
0130                   std::numeric_limits<double>::epsilon());
0131   CHECK_CLOSE_ABS(binBoundaries[2u], 200.,
0132                   std::numeric_limits<double>::epsilon());
0133 
0134   // The first volume is the beam pipe, it should have gotten the
0135   // z dimension
0136   auto& beamPipe = cts.constituentVolumes[0u];
0137 
0138   BOOST_CHECK_EQUAL(beamPipe.name, "beam-pipe");
0139   CHECK_CLOSE_ABS(beamPipe.extent.min(AxisDirection::AxisZ), -2000.,
0140                   std::numeric_limits<double>::epsilon());
0141 
0142   CHECK_CLOSE_ABS(beamPipe.extent.max(AxisDirection::AxisZ), 2000.,
0143                   std::numeric_limits<double>::epsilon());
0144 
0145   // The new beam pipe radius should have been applied
0146   CHECK_CLOSE_ABS(beamPipe.extent.max(AxisDirection::AxisR), 35.,
0147                   std::numeric_limits<double>::epsilon());
0148 
0149   // The second volume is the pixel detector
0150   auto& pixelContainer = cts.constituentVolumes[1u];
0151   BOOST_CHECK_EQUAL(pixelContainer.name, "pixel-container");
0152 
0153   // Pixel container should have fitting boundaries
0154   CHECK_CLOSE_ABS(pixelContainer.extent.min(AxisDirection::AxisR), 35.,
0155                   std::numeric_limits<double>::epsilon());
0156   CHECK_CLOSE_ABS(pixelContainer.extent.max(AxisDirection::AxisR), 200.,
0157                   std::numeric_limits<double>::epsilon());
0158   CHECK_CLOSE_ABS(pixelContainer.extent.min(AxisDirection::AxisZ), -2000.,
0159                   std::numeric_limits<double>::epsilon());
0160   CHECK_CLOSE_ABS(pixelContainer.extent.max(AxisDirection::AxisZ), 2000.,
0161                   std::numeric_limits<double>::epsilon());
0162 
0163   // The Pixel container has constituents
0164   BOOST_CHECK(pixelContainer.container.has_value());
0165   auto& cts1 = pixelContainer.container.value();
0166 
0167   // All of the internal containers should now have synchronized
0168   // inner & outer boundaries
0169   for (auto& pv : cts1.constituentVolumes) {
0170     CHECK_CLOSE_ABS(pv.extent.min(AxisDirection::AxisR), 35.,
0171                     std::numeric_limits<double>::epsilon());
0172 
0173     CHECK_CLOSE_ABS(pv.extent.max(AxisDirection::AxisR), 200.,
0174                     std::numeric_limits<double>::epsilon());
0175   }
0176 
0177   // The binning should have been estimated
0178   BOOST_CHECK_EQUAL(cts1.constituentBinning.size(), 1u);
0179   BOOST_CHECK_EQUAL(cts1.constituentBinning[0].type, arbitrary);
0180   BOOST_CHECK_EQUAL(cts1.constituentBinning[0].binvalue, AxisDirection::AxisZ);
0181 
0182   const auto& binBoundariesZ = cts1.constituentBinning[0].boundaries();
0183   BOOST_CHECK_EQUAL(binBoundariesZ.size(), 4u);
0184   CHECK_CLOSE_ABS(binBoundariesZ[0u], -2000.,
0185                   std::numeric_limits<double>::epsilon());
0186   CHECK_CLOSE_ABS(binBoundariesZ[1u], -575,
0187                   std::numeric_limits<double>::epsilon());
0188   CHECK_CLOSE_ABS(binBoundariesZ[2u], 575.,
0189                   std::numeric_limits<double>::epsilon());
0190   CHECK_CLOSE_ABS(binBoundariesZ[3u], 2000.,
0191                   std::numeric_limits<double>::epsilon());
0192 
0193   // The second volume is the pixel barrel
0194   auto& pixelBarrel = cts1.constituentVolumes[1u];
0195   BOOST_CHECK_EQUAL(pixelBarrel.name, "pixel-barrel");
0196 
0197   // It is a container volume value
0198   BOOST_CHECK(pixelBarrel.container.has_value());
0199   auto& cts2 = pixelBarrel.container.value();
0200   // It is, however, a layer container
0201   BOOST_CHECK(cts2.layerContainer);
0202   for (auto& lVolume : cts2.constituentVolumes) {
0203     BOOST_CHECK(lVolume.internal.has_value());
0204   }
0205 }
0206 
0207 BOOST_AUTO_TEST_CASE(ProtoDetectorTests) {
0208   // Get the raw proto detector description
0209   auto detector = createProtoDetector();
0210   detector.harmonize(false);
0211   std::cout << detector.toString() << std::endl;
0212 }
0213 
0214 BOOST_AUTO_TEST_SUITE_END()
0215 
0216 }  // namespace ActsTests