Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:25:36

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/Units.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/Layer.hpp"
0014 #include "Acts/Geometry/LayerCreator.hpp"
0015 #include "Acts/Geometry/ProtoLayerHelper.hpp"
0016 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0017 #include "Acts/Surfaces/SurfaceArray.hpp"
0018 #include "Acts/Utilities/BinningType.hpp"
0019 #include "Acts/Utilities/Logger.hpp"
0020 #include "Acts/Visualization/GeometryView3D.hpp"
0021 #include "Acts/Visualization/ObjVisualization3D.hpp"
0022 #include "ActsPlugins/Root/TGeoLayerBuilder.hpp"
0023 #include "ActsTests/CommonHelpers/DataDirectory.hpp"
0024 
0025 #include <array>
0026 #include <cstddef>
0027 #include <memory>
0028 #include <string>
0029 #include <utility>
0030 #include <vector>
0031 
0032 #include "TGeoManager.h"
0033 
0034 using namespace Acts;
0035 using namespace ActsPlugins;
0036 using namespace Acts::UnitLiterals;
0037 
0038 namespace ActsTests {
0039 
0040 /// @brief struct to load the global geometry
0041 struct RootGeometry {
0042   RootGeometry() {
0043     auto path = ActsTests::getDataPath("panda.root");
0044     TGeoManager::Import(path.c_str());
0045   }
0046 };
0047 
0048 RootGeometry rGeometry = RootGeometry();
0049 
0050 GeometryContext tgContext = GeometryContext();
0051 
0052 BOOST_AUTO_TEST_SUITE(RootSuite)
0053 
0054 /// @brief Unit test checking the match probability
0055 BOOST_AUTO_TEST_CASE(TGeoLayerBuilderTests) {
0056   using TglConfig = TGeoLayerBuilder::LayerConfig;
0057 
0058   TglConfig b0Config;
0059   b0Config.volumeName = "*";
0060   b0Config.sensorNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
0061                           "PixelActiveo6"};
0062   b0Config.localAxes = "XYZ";
0063   b0Config.parseRanges = {{AxisDirection::AxisR, {0., 40_mm}},
0064                           {AxisDirection::AxisZ, {-60_mm, 15_mm}}};
0065   b0Config.envelope = {0_mm, 0_mm};
0066 
0067   TglConfig eAllConfig;
0068   eAllConfig.volumeName = "*";
0069   eAllConfig.sensorNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
0070                             "PixelActiveo6"};
0071   eAllConfig.localAxes = "XYZ";
0072   eAllConfig.parseRanges = {{AxisDirection::AxisR, {0., 40_mm}},
0073                             {AxisDirection::AxisZ, {16_mm, 60_mm}}};
0074   eAllConfig.splitConfigs = {{AxisDirection::AxisZ, 5_mm}};
0075   eAllConfig.envelope = {0_mm, 0_mm};
0076 
0077   std::vector<TglConfig> cConfigs = {b0Config};
0078   std::vector<TglConfig> pConfigs = {eAllConfig};
0079 
0080   TGeoLayerBuilder::Config tglbConfig;
0081   tglbConfig.configurationName = "Pixels";
0082   tglbConfig.layerConfigurations[1] = cConfigs;
0083   tglbConfig.layerConfigurations[2] = pConfigs;
0084 
0085   auto surfaceArrayCreator = std::make_shared<const SurfaceArrayCreator>(
0086       getDefaultLogger("SurfaceArrayCreator", Logging::VERBOSE));
0087 
0088   LayerCreator::Config lcConfig;
0089   lcConfig.surfaceArrayCreator = surfaceArrayCreator;
0090   auto layerCreator = std::make_shared<const LayerCreator>(
0091       lcConfig, getDefaultLogger("LayerCreator", Logging::VERBOSE));
0092   tglbConfig.layerCreator = layerCreator;
0093 
0094   ProtoLayerHelper::Config plhConfig;
0095   auto protoLayerHelper = std::make_shared<const ProtoLayerHelper>(
0096       plhConfig, getDefaultLogger("ProtoLayerHelper", Logging::VERBOSE));
0097   tglbConfig.protoLayerHelper = protoLayerHelper;
0098 
0099   TGeoLayerBuilder tglb(tglbConfig,
0100                         getDefaultLogger("TGeoLayerBuilder", Logging::VERBOSE));
0101 
0102   ObjVisualization3D objVis;
0103 
0104   auto centralLayers = tglb.centralLayers(tgContext);
0105   BOOST_CHECK_EQUAL(centralLayers.size(), 1u);
0106   BOOST_CHECK_EQUAL(tglb.detectorElements().size(), 14u);
0107 
0108   auto positiveLayers = tglb.positiveLayers(tgContext);
0109   // Check that it's split into two layers
0110   std::size_t ipl = 0;
0111   BOOST_CHECK_EQUAL(positiveLayers.size(), 2u);
0112   BOOST_CHECK_EQUAL(tglb.detectorElements().size(), 14u + 16u);
0113   for (const auto& pLayer : positiveLayers) {
0114     auto sArray = pLayer->surfaceArray();
0115     if (sArray != nullptr) {
0116       for (auto& surface : sArray->surfaces()) {
0117         GeometryView3D::drawSurface(objVis, *surface, tgContext);
0118       }
0119     }
0120     objVis.write("PositiveLayer_" + std::to_string(ipl++));
0121     objVis.clear();
0122   }
0123 }
0124 
0125 BOOST_AUTO_TEST_SUITE_END()
0126 
0127 }  // namespace ActsTests