Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TGeoLayerBuilderTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TGeoLayerBuilderTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
14 #include "Acts/Geometry/Layer.hpp"
25 
26 #include <array>
27 #include <cstddef>
28 #include <memory>
29 #include <string>
30 #include <utility>
31 #include <vector>
32 
33 #include "TGeoManager.h"
34 
35 using namespace Acts::UnitLiterals;
36 
37 namespace Acts {
38 
39 namespace Test {
40 
42 struct RootGeometry {
44  auto path = Acts::Test::getDataPath("panda.root");
45  TGeoManager::Import(path.c_str());
46  }
47 };
48 
50 
52 
54 BOOST_AUTO_TEST_CASE(TGeoLayerBuilderTests) {
55  using TglConfig = TGeoLayerBuilder::LayerConfig;
56 
57  TglConfig b0Config;
58  b0Config.volumeName = "*";
59  b0Config.sensorNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
60  "PixelActiveo6"};
61  b0Config.localAxes = "XYZ";
62  b0Config.parseRanges = {{binR, {0., 40_mm}}, {binZ, {-60_mm, 15_mm}}};
63  b0Config.envelope = {0_mm, 0_mm};
64 
65  TglConfig eAllConfig;
66  eAllConfig.volumeName = "*";
67  eAllConfig.sensorNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
68  "PixelActiveo6"};
69  eAllConfig.localAxes = "XYZ";
70  eAllConfig.parseRanges = {{binR, {0., 40_mm}}, {binZ, {16_mm, 60_mm}}};
71  eAllConfig.splitConfigs = {{binZ, 5_mm}};
72  eAllConfig.envelope = {0_mm, 0_mm};
73 
74  std::vector<TglConfig> cConfigs = {b0Config};
75  std::vector<TglConfig> pConfigs = {eAllConfig};
76 
77  TGeoLayerBuilder::Config tglbConfig;
78  tglbConfig.configurationName = "Pixels";
79  tglbConfig.layerConfigurations[1] = cConfigs;
80  tglbConfig.layerConfigurations[2] = pConfigs;
81 
82  auto surfaceArrayCreator = std::make_shared<const SurfaceArrayCreator>(
83  getDefaultLogger("SurfaceArrayCreator", Logging::VERBOSE));
84 
85  LayerCreator::Config lcConfig;
86  lcConfig.surfaceArrayCreator = surfaceArrayCreator;
87  auto layerCreator = std::make_shared<const LayerCreator>(
88  lcConfig, getDefaultLogger("LayerCreator", Logging::VERBOSE));
89  tglbConfig.layerCreator = layerCreator;
90 
91  ProtoLayerHelper::Config plhConfig;
92  auto protoLayerHelper = std::make_shared<const ProtoLayerHelper>(
93  plhConfig, getDefaultLogger("ProtoLayerHelper", Logging::VERBOSE));
94  tglbConfig.protoLayerHelper = protoLayerHelper;
95 
96  TGeoLayerBuilder tglb(tglbConfig,
97  getDefaultLogger("TGeoLayerBuilder", Logging::VERBOSE));
98 
99  ObjVisualization3D objVis;
100 
101  auto centralLayers = tglb.centralLayers(tgContext);
102  BOOST_CHECK_EQUAL(centralLayers.size(), 1u);
103  BOOST_CHECK_EQUAL(tglb.detectorElements().size(), 14u);
104 
105  auto positiveLayers = tglb.positiveLayers(tgContext);
106  // Check that it's split into two layers
107  size_t ipl = 0;
108  BOOST_CHECK_EQUAL(positiveLayers.size(), 2u);
109  BOOST_CHECK_EQUAL(tglb.detectorElements().size(), 14u + 16u);
110  for (const auto& pLayer : positiveLayers) {
111  auto sArray = pLayer->surfaceArray();
112  if (sArray != nullptr) {
113  for (auto& surface : sArray->surfaces()) {
115  }
116  }
117  objVis.write("PositiveLayer_" + std::to_string(ipl++));
118  objVis.clear();
119  }
120 }
121 
122 } // namespace Test
123 
124 } // namespace Acts