Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:13

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