EIC 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 
18 
19 #include "TGeoManager.h"
20 
21 namespace Acts {
22 
23 namespace Test {
24 
26 struct RootGeometry {
28  auto path = Acts::Test::getDataPath("panda.root");
29  TGeoManager::Import(path.c_str());
30  }
31 };
32 
34 
35 RootGeometry rGeometry = RootGeometry();
36 
38 BOOST_AUTO_TEST_CASE(TGeoParser_Pixel) {
39  if (gGeoManager != nullptr) {
40  std::string volumeName = "*";
41  TGeoParser::Options tgpOptions;
42  tgpOptions.volumeNames = {volumeName};
43  tgpOptions.targetNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
44  "PixelActiveo6"};
45  std::string axes = "XYZ";
46  double scale = 10.;
47 
48  TGeoParser::State tgpState;
49  tgpState.volume = gGeoManager->GetTopVolume();
50 
51  // Parse the full ones
52  TGeoParser::select(tgpState, tgpOptions);
53 
54  // This should select 176 PixelActive modules
55  BOOST_CHECK_EQUAL(tgpState.selectedNodes.size(), 176u);
56 
58  ObjVisualization3D objVis;
59  for (auto& snode : tgpState.selectedNodes) {
60  const auto& shape = *(snode.node->GetVolume()->GetShape());
61  const auto& transform = *(snode.transform.get());
62  auto surface =
63  TGeoSurfaceConverter::toSurface(shape, transform, axes, scale);
65  }
66  objVis.write("PixelActive");
67  }
68 }
69 
71 BOOST_AUTO_TEST_CASE(TGeoParser_Pixel_SelectInnermost) {
72  if (gGeoManager != nullptr) {
73  std::string volumeName = "*";
74  TGeoParser::Options tgpOptions;
75  tgpOptions.volumeNames = {volumeName};
76  tgpOptions.targetNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5",
77  "PixelActiveo6"};
78  tgpOptions.parseRanges.push_back({binR, {0., 40.}});
79  tgpOptions.parseRanges.push_back({binZ, {-60., 15.}});
80  tgpOptions.unit = 10.;
81 
82  std::string axes = "XYZ";
83 
84  TGeoParser::State tgpState;
85  tgpState.volume = gGeoManager->GetTopVolume();
86 
87  // Parse the full ones
88  TGeoParser::select(tgpState, tgpOptions);
89 
90  // This should select 14 PixelActive modules
91  BOOST_CHECK_EQUAL(tgpState.selectedNodes.size(), 14u);
92 
94  ObjVisualization3D objVis;
95  for (auto& snode : tgpState.selectedNodes) {
96  const auto& shape = *(snode.node->GetVolume()->GetShape());
97  const auto& transform = *(snode.transform.get());
99  tgpOptions.unit);
101  }
102  objVis.write("PixelActive_Innermost");
103  }
104 }
105 
106 } // namespace Test
107 } // namespace Acts