File indexing completed on 2026-07-16 08:08:33
0001
0002
0003
0004
0005
0006
0007
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 <boost/algorithm/string.hpp>
0022
0023 #include "RtypesCore.h"
0024 #include "TGeoBoolNode.h"
0025
0026 using namespace Acts;
0027
0028 using Line2D = Eigen::Hyperplane<double, 2>;
0029
0030 namespace ActsPlugins {
0031
0032 TGeoDetectorElement::TGeoDetectorElement(
0033 const Identifier& identifier, const TGeoNode& tGeoNode,
0034 const TGeoMatrix& tGeoMatrix, const std::string& axes, double scalor,
0035 std::shared_ptr<const ISurfaceMaterial> material)
0036 : m_detElement(&tGeoNode), m_identifier(identifier) {
0037
0038
0039 const Double_t* translation = tGeoMatrix.GetTranslation();
0040 const Double_t* rotation = tGeoMatrix.GetRotationMatrix();
0041
0042 auto sensor = m_detElement->GetVolume();
0043 auto tgShape = sensor->GetShape();
0044
0045 auto [cBounds, cTransform, cThickness] =
0046 TGeoSurfaceConverter::cylinderComponents(*tgShape, rotation, translation,
0047 axes, scalor);
0048 if (cBounds != nullptr) {
0049 m_transform = cTransform;
0050 m_bounds = cBounds;
0051 m_thickness = cThickness;
0052 m_surface = Surface::makeShared<CylinderSurface>(cBounds, *this);
0053 }
0054
0055
0056 if (m_surface == nullptr) {
0057 auto [dBounds, dTransform, dThickness] =
0058 TGeoSurfaceConverter::discComponents(*tgShape, rotation, translation,
0059 axes, scalor);
0060 if (dBounds != nullptr) {
0061 m_bounds = dBounds;
0062 m_transform = dTransform;
0063 m_thickness = dThickness;
0064 m_surface = Surface::makeShared<DiscSurface>(dBounds, *this);
0065 }
0066 }
0067
0068
0069 if (m_surface == nullptr) {
0070 auto [pBounds, pTransform, pThickness] =
0071 TGeoSurfaceConverter::planeComponents(*tgShape, rotation, translation,
0072 axes, scalor);
0073 if (pBounds != nullptr) {
0074 m_bounds = pBounds;
0075 m_transform = pTransform;
0076 m_thickness = pThickness;
0077 m_surface = Surface::makeShared<PlaneSurface>(pBounds, *this);
0078 }
0079 }
0080
0081
0082 if (m_surface != nullptr) {
0083 m_surface->assignSurfaceMaterial(std::move(material));
0084 m_surface->assignThickness(m_thickness);
0085 }
0086 }
0087
0088 TGeoDetectorElement::TGeoDetectorElement(
0089 const Identifier& identifier, const TGeoNode& tGeoNode,
0090 const Transform3& tgTransform,
0091 const std::shared_ptr<const PlanarBounds>& tgBounds, double tgThickness)
0092 : m_detElement(&tGeoNode),
0093 m_transform(tgTransform),
0094 m_identifier(identifier),
0095 m_bounds(tgBounds),
0096 m_thickness(tgThickness) {
0097 m_surface = Surface::makeShared<PlaneSurface>(tgBounds, *this);
0098 m_surface->assignThickness(m_thickness);
0099 }
0100
0101 TGeoDetectorElement::TGeoDetectorElement(
0102 const Identifier& identifier, const TGeoNode& tGeoNode,
0103 const Transform3& tgTransform,
0104 const std::shared_ptr<const DiscBounds>& tgBounds, double tgThickness)
0105 : m_detElement(&tGeoNode),
0106 m_transform(tgTransform),
0107 m_identifier(identifier),
0108 m_bounds(tgBounds),
0109 m_thickness(tgThickness) {
0110 m_surface = Surface::makeShared<DiscSurface>(tgBounds, *this);
0111 m_surface->assignThickness(m_thickness);
0112 }
0113
0114 TGeoDetectorElement::~TGeoDetectorElement() = default;
0115
0116 const Transform3& TGeoDetectorElement::nominalTransform() const {
0117 return m_transform;
0118 }
0119
0120 }