Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TGeoDetectorElement.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TGeoDetectorElement.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 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 
10 
17 
18 #include <tuple>
19 #include <utility>
20 
21 #include <boost/algorithm/string.hpp>
22 
23 #include "RtypesCore.h"
24 #include "TGeoArb8.h"
25 #include "TGeoBBox.h"
26 #include "TGeoBoolNode.h"
27 #include "TGeoCompositeShape.h"
28 #include "TGeoTrd2.h"
29 #include "TGeoTube.h"
30 
31 using Line2D = Eigen::Hyperplane<double, 2>;
32 
34  const Identifier& identifier, const TGeoNode& tGeoNode,
35  const TGeoMatrix& tGeoMatrix, const std::string& axes, double scalor,
36  std::shared_ptr<const Acts::ISurfaceMaterial> material)
37  : Acts::IdentifiedDetectorElement(),
38  m_detElement(&tGeoNode),
39  m_identifier(identifier) {
40  // Create temporary local non const surface (to allow setting the
41  // material)
42  const Double_t* translation = tGeoMatrix.GetTranslation();
43  const Double_t* rotation = tGeoMatrix.GetRotationMatrix();
44 
45  auto sensor = m_detElement->GetVolume();
46  auto tgShape = sensor->GetShape();
47 
48  auto [cBounds, cTransform, cThickness] =
49  TGeoSurfaceConverter::cylinderComponents(*tgShape, rotation, translation,
50  axes, scalor);
51  if (cBounds != nullptr) {
52  m_transform = cTransform;
53  m_bounds = cBounds;
54  m_thickness = cThickness;
55  m_surface = Surface::makeShared<CylinderSurface>(cBounds, *this);
56  }
57 
58  // Check next if you do not have a surface
59  if (m_surface == nullptr) {
60  auto [dBounds, dTransform, dThickness] =
61  TGeoSurfaceConverter::discComponents(*tgShape, rotation, translation,
62  axes, scalor);
63  if (dBounds != nullptr) {
64  m_bounds = dBounds;
65  m_transform = dTransform;
66  m_thickness = dThickness;
67  m_surface = Surface::makeShared<DiscSurface>(dBounds, *this);
68  }
69  }
70 
71  // Check next if you do not have a surface
72  if (m_surface == nullptr) {
73  auto [pBounds, pTransform, pThickness] =
74  TGeoSurfaceConverter::planeComponents(*tgShape, rotation, translation,
75  axes, scalor);
76  if (pBounds != nullptr) {
77  m_bounds = pBounds;
78  m_transform = pTransform;
79  m_thickness = pThickness;
80  m_surface = Surface::makeShared<PlaneSurface>(pBounds, *this);
81  }
82  }
83 
84  // set the asscoiated material (non const method)
85  if (m_surface != nullptr) {
86  m_surface->assignSurfaceMaterial(std::move(material));
87  }
88 }
89 
91  const Identifier& identifier, const TGeoNode& tGeoNode,
92  const Transform3& tgTransform,
93  const std::shared_ptr<const PlanarBounds>& tgBounds, double tgThickness)
94  : Acts::IdentifiedDetectorElement(),
95  m_detElement(&tGeoNode),
96  m_transform(tgTransform),
97  m_identifier(identifier),
98  m_bounds(tgBounds),
99  m_thickness(tgThickness) {
100  m_surface = Surface::makeShared<PlaneSurface>(tgBounds, *this);
101 }
102 
104  const Identifier& identifier, const TGeoNode& tGeoNode,
105  const Transform3& tgTransform,
106  const std::shared_ptr<const DiscBounds>& tgBounds, double tgThickness)
107  : Acts::IdentifiedDetectorElement(),
108  m_detElement(&tGeoNode),
109  m_transform(tgTransform),
110  m_identifier(identifier),
111  m_bounds(tgBounds),
112  m_thickness(tgThickness) {
113  m_surface = Surface::makeShared<DiscSurface>(tgBounds, *this);
114 }
115