EIC 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 
21 
22 #include <fstream>
23 #include <iostream>
24 #include <utility>
25 
26 #include <boost/algorithm/string.hpp>
27 
28 #include "TGeoArb8.h"
29 #include "TGeoBBox.h"
30 #include "TGeoBoolNode.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoTrd2.h"
33 #include "TGeoTube.h"
34 
35 using Line2D = Eigen::Hyperplane<double, 2>;
36 
38  const Identifier& identifier, const TGeoNode& tGeoNode,
39  const TGeoMatrix& tGeoMatrix, const std::string& axes, double scalor,
40  std::shared_ptr<const Acts::ISurfaceMaterial> material)
41  : Acts::IdentifiedDetectorElement(),
42  m_detElement(&tGeoNode),
43  m_identifier(identifier) {
44  // Create temporary local non const surface (to allow setting the
45  // material)
46  const Double_t* translation = tGeoMatrix.GetTranslation();
47  const Double_t* rotation = tGeoMatrix.GetRotationMatrix();
48 
49  auto sensor = m_detElement->GetVolume();
50  auto tgShape = sensor->GetShape();
51 
52  auto cylinderComps = TGeoSurfaceConverter::cylinderComponents(
53  *tgShape, rotation, translation, axes, scalor);
54  auto cylinderBounds = std::get<0>(cylinderComps);
55  if (cylinderBounds != nullptr) {
56  m_transform = std::get<1>(cylinderComps);
57  m_bounds = cylinderBounds;
58  m_thickness = std::get<2>(cylinderComps);
59  m_surface = Surface::makeShared<CylinderSurface>(cylinderBounds, *this);
60  }
61 
62  // Check next if you do not have a surface
63  if (m_surface == nullptr) {
64  auto discComps = TGeoSurfaceConverter::discComponents(
65  *tgShape, rotation, translation, axes, scalor);
66  auto discBounds = std::get<0>(discComps);
67  if (discBounds != nullptr) {
68  m_bounds = discBounds;
69  m_transform = std::get<1>(discComps);
70  m_thickness = std::get<2>(discComps);
71  m_surface = Surface::makeShared<DiscSurface>(discBounds, *this);
72  }
73  }
74 
75  // Check next if you do not have a surface
76  if (m_surface == nullptr) {
77  auto planeComps = TGeoSurfaceConverter::planeComponents(
78  *tgShape, rotation, translation, axes, scalor);
79  auto planeBounds = std::get<0>(planeComps);
80  if (planeBounds != nullptr) {
81  m_bounds = planeBounds;
82  m_transform = std::get<1>(planeComps);
83  m_thickness = std::get<2>(planeComps);
84  m_surface = Surface::makeShared<PlaneSurface>(planeBounds, *this);
85  }
86  }
87 
88  // set the asscoiated material (non const method)
89  if (m_surface != nullptr) {
90  m_surface->assignSurfaceMaterial(std::move(material));
91  }
92 }
93