Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:26

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Plugins/TGeo/TGeoDetectorElement.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Plugins/TGeo/TGeoSurfaceConverter.hpp"
0013 #include "Acts/Surfaces/CylinderSurface.hpp"
0014 #include "Acts/Surfaces/DiscSurface.hpp"
0015 #include "Acts/Surfaces/PlaneSurface.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 
0018 #include <tuple>
0019 #include <utility>
0020 
0021 #include <boost/algorithm/string.hpp>
0022 
0023 #include "RtypesCore.h"
0024 #include "TGeoArb8.h"
0025 #include "TGeoBBox.h"
0026 #include "TGeoBoolNode.h"
0027 #include "TGeoCompositeShape.h"
0028 #include "TGeoTrd2.h"
0029 #include "TGeoTube.h"
0030 
0031 using Line2D = Eigen::Hyperplane<double, 2>;
0032 
0033 Acts::TGeoDetectorElement::TGeoDetectorElement(
0034     const Identifier& identifier, const TGeoNode& tGeoNode,
0035     const TGeoMatrix& tGeoMatrix, const std::string& axes, double scalor,
0036     std::shared_ptr<const Acts::ISurfaceMaterial> material)
0037     : Acts::DetectorElementBase(),
0038       m_detElement(&tGeoNode),
0039       m_identifier(identifier) {
0040   // Create temporary local non const surface (to allow setting the
0041   // material)
0042   const Double_t* translation = tGeoMatrix.GetTranslation();
0043   const Double_t* rotation = tGeoMatrix.GetRotationMatrix();
0044 
0045   auto sensor = m_detElement->GetVolume();
0046   auto tgShape = sensor->GetShape();
0047 
0048   auto [cBounds, cTransform, cThickness] =
0049       TGeoSurfaceConverter::cylinderComponents(*tgShape, rotation, translation,
0050                                                axes, scalor);
0051   if (cBounds != nullptr) {
0052     m_transform = cTransform;
0053     m_bounds = cBounds;
0054     m_thickness = cThickness;
0055     m_surface = Surface::makeShared<CylinderSurface>(cBounds, *this);
0056   }
0057 
0058   // Check next if you do not have a surface
0059   if (m_surface == nullptr) {
0060     auto [dBounds, dTransform, dThickness] =
0061         TGeoSurfaceConverter::discComponents(*tgShape, rotation, translation,
0062                                              axes, scalor);
0063     if (dBounds != nullptr) {
0064       m_bounds = dBounds;
0065       m_transform = dTransform;
0066       m_thickness = dThickness;
0067       m_surface = Surface::makeShared<DiscSurface>(dBounds, *this);
0068     }
0069   }
0070 
0071   // Check next if you do not have a surface
0072   if (m_surface == nullptr) {
0073     auto [pBounds, pTransform, pThickness] =
0074         TGeoSurfaceConverter::planeComponents(*tgShape, rotation, translation,
0075                                               axes, scalor);
0076     if (pBounds != nullptr) {
0077       m_bounds = pBounds;
0078       m_transform = pTransform;
0079       m_thickness = pThickness;
0080       m_surface = Surface::makeShared<PlaneSurface>(pBounds, *this);
0081     }
0082   }
0083 
0084   // set the asscoiated material (non const method)
0085   if (m_surface != nullptr) {
0086     m_surface->assignSurfaceMaterial(std::move(material));
0087   }
0088 }
0089 
0090 Acts::TGeoDetectorElement::TGeoDetectorElement(
0091     const Identifier& identifier, const TGeoNode& tGeoNode,
0092     const Transform3& tgTransform,
0093     const std::shared_ptr<const PlanarBounds>& tgBounds, double tgThickness)
0094     : Acts::DetectorElementBase(),
0095       m_detElement(&tGeoNode),
0096       m_transform(tgTransform),
0097       m_identifier(identifier),
0098       m_bounds(tgBounds),
0099       m_thickness(tgThickness) {
0100   m_surface = Surface::makeShared<PlaneSurface>(tgBounds, *this);
0101 }
0102 
0103 Acts::TGeoDetectorElement::TGeoDetectorElement(
0104     const Identifier& identifier, const TGeoNode& tGeoNode,
0105     const Transform3& tgTransform,
0106     const std::shared_ptr<const DiscBounds>& tgBounds, double tgThickness)
0107     : Acts::DetectorElementBase(),
0108       m_detElement(&tGeoNode),
0109       m_transform(tgTransform),
0110       m_identifier(identifier),
0111       m_bounds(tgBounds),
0112       m_thickness(tgThickness) {
0113   m_surface = Surface::makeShared<DiscSurface>(tgBounds, *this);
0114 }
0115 
0116 Acts::TGeoDetectorElement::~TGeoDetectorElement() = default;