Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TGeoParserTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TGeoParserTests.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 
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 #include "TGeoManager.h"
26 
27 namespace Acts {
28 
29 namespace Test {
30 
32 struct RootGeometry {
34  auto path = Acts::Test::getDataPath("panda.root");
35  TGeoManager::Import(path.c_str());
36  }
37 };
38 
40 
41 RootGeometry rGeometry = RootGeometry();
42 
44 BOOST_AUTO_TEST_CASE(TGeoParser_Pixel) {
45  if (gGeoManager != nullptr) {
46  std::string volumeName = "*";
47  TGeoParser::Options tgpOptions;
48  tgpOptions.volumeNames = {volumeName};
49  tgpOptions.targetNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
50  "PixelActiveo6"};
51  std::string axes = "XYZ";
52  double scale = 10.;
53 
54  TGeoParser::State tgpState;
55  tgpState.volume = gGeoManager->GetTopVolume();
56 
57  // Parse the full ones
58  TGeoParser::select(tgpState, tgpOptions);
59 
60  // This should select 176 PixelActive modules
61  BOOST_CHECK_EQUAL(tgpState.selectedNodes.size(), 176u);
62 
64  ObjVisualization3D objVis;
65  for (auto& snode : tgpState.selectedNodes) {
66  const auto& shape = *(snode.node->GetVolume()->GetShape());
67  const auto& transform = *(snode.transform.get());
68  auto [surface, thickness] =
71  }
72  objVis.write("PixelActive");
73  }
74 }
75 
77 BOOST_AUTO_TEST_CASE(TGeoParser_Pixel_SelectInnermost) {
78  if (gGeoManager != nullptr) {
79  std::string volumeName = "*";
80  TGeoParser::Options tgpOptions;
81  tgpOptions.volumeNames = {volumeName};
82  tgpOptions.targetNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
83  "PixelActiveo6"};
84  tgpOptions.parseRanges.push_back({binR, {0., 40.}});
85  tgpOptions.parseRanges.push_back({binZ, {-60., 15.}});
86  tgpOptions.unit = 10.;
87 
88  std::string axes = "XYZ";
89 
90  TGeoParser::State tgpState;
91  tgpState.volume = gGeoManager->GetTopVolume();
92 
93  // Parse the full ones
94  TGeoParser::select(tgpState, tgpOptions);
95 
96  // This should select 14 PixelActive modules
97  BOOST_CHECK_EQUAL(tgpState.selectedNodes.size(), 14u);
98 
100  ObjVisualization3D objVis;
101  for (auto& snode : tgpState.selectedNodes) {
102  const auto& shape = *(snode.node->GetVolume()->GetShape());
103  const auto& transform = *(snode.transform.get());
105  shape, transform, axes, tgpOptions.unit);
107  }
108  objVis.write("PixelActive_Innermost");
109  }
110 }
111 
112 } // namespace Test
113 } // namespace Acts