Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 07:50:59

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/GeoModel/detail/GeoTubeConverter.hpp"
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Plugins/GeoModel/GeoModelConversionError.hpp"
0013 #include "Acts/Surfaces/CylinderBounds.hpp"
0014 #include "Acts/Surfaces/CylinderSurface.hpp"
0015 #include "Acts/Surfaces/DiscSurface.hpp"
0016 #include "Acts/Surfaces/LineBounds.hpp"
0017 #include "Acts/Surfaces/RadialBounds.hpp"
0018 #include "Acts/Surfaces/StrawSurface.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 
0021 #include <GeoModelKernel/GeoFullPhysVol.h>
0022 #include <GeoModelKernel/GeoLogVol.h>
0023 #include <GeoModelKernel/GeoShape.h>
0024 #include <GeoModelKernel/GeoTube.h>
0025 #include <GeoModelKernel/Units.h>
0026 
0027 Acts::Result<Acts::GeoModelSensitiveSurface>
0028 Acts::detail::GeoTubeConverter::operator()(const PVConstLink& geoPV,
0029                                            const GeoTube& geoTube,
0030                                            const Transform3& absTransform,
0031                                            SurfaceBoundFactory& boundFactory,
0032                                            bool sensitive) const {
0033   /// auto-calculate the unit length conversion
0034   static constexpr double unitLength =
0035       Acts::UnitConstants::mm / GeoModelKernelUnits::millimeter;
0036 
0037   // Create the surface transform
0038   Transform3 transform = Transform3::Identity();
0039   transform.translation() = unitLength * absTransform.translation();
0040   transform.linear() = absTransform.rotation();
0041 
0042   // Create the surface
0043   double innerRadius = unitLength * geoTube.getRMin();
0044   double outerRadius = unitLength * geoTube.getRMax();
0045   double halfZ = unitLength * geoTube.getZHalfLength();
0046 
0047   if (targetShape == Surface::SurfaceType::Straw) {
0048     // Create the element and the surface
0049     auto lineBounds = boundFactory.makeBounds<LineBounds>(outerRadius, halfZ);
0050     if (!sensitive) {
0051       auto surface = Surface::makeShared<StrawSurface>(transform, lineBounds);
0052       return std::make_tuple(nullptr, surface);
0053     }
0054 
0055     auto detectorElement =
0056         GeoModelDetectorElement::createDetectorElement<StrawSurface>(
0057             geoPV, lineBounds, transform, 2 * outerRadius);
0058     auto surface = detectorElement->surface().getSharedPtr();
0059     return std::make_tuple(detectorElement, surface);
0060     // Next option is translation to disc
0061   } else if (targetShape == Surface::SurfaceType::Disc) {
0062     auto radialBounds =
0063         std::make_shared<RadialBounds>(innerRadius, outerRadius);
0064     if (!sensitive) {
0065       auto surface = Surface::makeShared<DiscSurface>(transform, radialBounds);
0066       return std::make_tuple(nullptr, surface);
0067     }
0068 
0069     // Create the element and the surface
0070     auto detectorElement =
0071         GeoModelDetectorElement::createDetectorElement<DiscSurface>(
0072             geoPV, radialBounds, transform, 2 * halfZ);
0073     auto surface = detectorElement->surface().getSharedPtr();
0074     return std::make_tuple(detectorElement, surface);
0075   }
0076   // Finally cylinder to cylinder
0077   auto cylinderBounds = std::make_shared<CylinderBounds>(outerRadius, halfZ);
0078   if (!sensitive) {
0079     auto surface =
0080         Surface::makeShared<CylinderSurface>(transform, cylinderBounds);
0081     return std::make_tuple(nullptr, surface);
0082   }
0083   // Create the element and the surface
0084 
0085   auto detectorElement =
0086       GeoModelDetectorElement::createDetectorElement<CylinderSurface>(
0087           geoPV, cylinderBounds, transform, outerRadius - innerRadius);
0088   auto surface = detectorElement->surface().getSharedPtr();
0089   return std::make_tuple(detectorElement, surface);
0090 }