Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:46:19

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 "ActsPlugins/Root/TGeoDetectorElement.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/CylinderSurface.hpp"
0013 #include "Acts/Surfaces/DiscSurface.hpp"
0014 #include "Acts/Surfaces/PlanarBounds.hpp"
0015 #include "Acts/Surfaces/PlaneSurface.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "ActsPlugins/Root/TGeoSurfaceConverter.hpp"
0018 
0019 #include <utility>
0020 
0021 #include "RtypesCore.h"
0022 #include "TGeoBoolNode.h"
0023 
0024 using namespace Acts;
0025 
0026 using Line2D = Eigen::Hyperplane<double, 2>;
0027 
0028 namespace ActsPlugins {
0029 
0030 TGeoDetectorElement::TGeoDetectorElement(
0031     const Identifier& identifier, const TGeoNode& tGeoNode,
0032     const TGeoMatrix& tGeoMatrix, TGeoAxes axes, double scalor,
0033     std::shared_ptr<const ISurfaceMaterial> material)
0034     : m_detElement(&tGeoNode), m_identifier(identifier) {
0035   // Create temporary local non const surface (to allow setting the
0036   // material)
0037   const Double_t* translation = tGeoMatrix.GetTranslation();
0038   const Double_t* rotation = tGeoMatrix.GetRotationMatrix();
0039 
0040   auto sensor = m_detElement->GetVolume();
0041   auto tgShape = sensor->GetShape();
0042 
0043   auto [cBounds, cTransform, cThickness] =
0044       TGeoSurfaceConverter::cylinderComponents(*tgShape, rotation, translation,
0045                                                axes, scalor);
0046   if (cBounds != nullptr) {
0047     m_transform = cTransform;
0048     m_bounds = cBounds;
0049     m_thickness = cThickness;
0050     m_surface = Surface::makeShared<CylinderSurface>(cBounds, *this);
0051   }
0052 
0053   // Check next if you do not have a surface
0054   if (m_surface == nullptr) {
0055     auto [dBounds, dTransform, dThickness] =
0056         TGeoSurfaceConverter::discComponents(*tgShape, rotation, translation,
0057                                              axes, scalor);
0058     if (dBounds != nullptr) {
0059       m_bounds = dBounds;
0060       m_transform = dTransform;
0061       m_thickness = dThickness;
0062       m_surface = Surface::makeShared<DiscSurface>(dBounds, *this);
0063     }
0064   }
0065 
0066   // Check next if you do not have a surface
0067   if (m_surface == nullptr) {
0068     auto [pBounds, pTransform, pThickness] =
0069         TGeoSurfaceConverter::planeComponents(*tgShape, rotation, translation,
0070                                               axes, scalor);
0071     if (pBounds != nullptr) {
0072       m_bounds = pBounds;
0073       m_transform = pTransform;
0074       m_thickness = pThickness;
0075       m_surface = Surface::makeShared<PlaneSurface>(pBounds, *this);
0076     }
0077   }
0078 
0079   // set the asscoiated material (non const method)
0080   if (m_surface != nullptr) {
0081     m_surface->assignSurfaceMaterial(std::move(material));
0082     m_surface->assignThickness(m_thickness);
0083   }
0084 }
0085 
0086 TGeoDetectorElement::TGeoDetectorElement(
0087     const Identifier& identifier, const TGeoNode& tGeoNode,
0088     const Transform3& tgTransform,
0089     const std::shared_ptr<const PlanarBounds>& tgBounds, double tgThickness)
0090     : m_detElement(&tGeoNode),
0091       m_transform(tgTransform),
0092       m_identifier(identifier),
0093       m_bounds(tgBounds),
0094       m_thickness(tgThickness) {
0095   m_surface = Surface::makeShared<PlaneSurface>(tgBounds, *this);
0096   m_surface->assignThickness(m_thickness);
0097 }
0098 
0099 TGeoDetectorElement::TGeoDetectorElement(
0100     const Identifier& identifier, const TGeoNode& tGeoNode,
0101     const Transform3& tgTransform,
0102     const std::shared_ptr<const DiscBounds>& tgBounds, double tgThickness)
0103     : m_detElement(&tGeoNode),
0104       m_transform(tgTransform),
0105       m_identifier(identifier),
0106       m_bounds(tgBounds),
0107       m_thickness(tgThickness) {
0108   m_surface = Surface::makeShared<DiscSurface>(tgBounds, *this);
0109   m_surface->assignThickness(m_thickness);
0110 }
0111 
0112 TGeoDetectorElement::~TGeoDetectorElement() = default;
0113 
0114 const Transform3& TGeoDetectorElement::nominalTransform() const {
0115   return m_transform;
0116 }
0117 
0118 }  // namespace ActsPlugins