Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:15:35

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                                            bool sensitive) const {
0032   /// auto-calculate the unit length conversion
0033   static constexpr double unitLength =
0034       Acts::UnitConstants::mm / GeoModelKernelUnits::millimeter;
0035 
0036   // Create the surface transform
0037   Transform3 transform = Transform3::Identity();
0038   transform.translation() = unitLength * absTransform.translation();
0039   transform.linear() = absTransform.rotation();
0040 
0041   // Create the surface
0042   double innerRadius = unitLength * geoTube.getRMin();
0043   double outerRadius = unitLength * geoTube.getRMax();
0044   double halfZ = unitLength * geoTube.getZHalfLength();
0045 
0046   if (targetShape == Surface::SurfaceType::Straw) {
0047     // Create the element and the surface
0048     auto lineBounds = std::make_shared<LineBounds>(outerRadius, halfZ);
0049     if (!sensitive) {
0050       auto surface = Surface::makeShared<StrawSurface>(transform, lineBounds);
0051       return std::make_tuple(nullptr, surface);
0052     }
0053 
0054     auto detectorElement =
0055         GeoModelDetectorElement::createDetectorElement<StrawSurface>(
0056             geoPV, lineBounds, transform, 2 * outerRadius);
0057     auto surface = detectorElement->surface().getSharedPtr();
0058     return std::make_tuple(detectorElement, surface);
0059     // Next option is translation to disc
0060   } else if (targetShape == Surface::SurfaceType::Disc) {
0061     auto radialBounds =
0062         std::make_shared<RadialBounds>(innerRadius, outerRadius);
0063     if (!sensitive) {
0064       auto surface = Surface::makeShared<DiscSurface>(transform, radialBounds);
0065       return std::make_tuple(nullptr, surface);
0066     }
0067 
0068     // Create the element and the surface
0069     auto detectorElement =
0070         GeoModelDetectorElement::createDetectorElement<DiscSurface>(
0071             geoPV, radialBounds, transform, 2 * halfZ);
0072     auto surface = detectorElement->surface().getSharedPtr();
0073     return std::make_tuple(detectorElement, surface);
0074   }
0075   // Finally cylinder to cylinder
0076   auto cylinderBounds = std::make_shared<CylinderBounds>(outerRadius, halfZ);
0077   if (!sensitive) {
0078     auto surface =
0079         Surface::makeShared<CylinderSurface>(transform, cylinderBounds);
0080     return std::make_tuple(nullptr, surface);
0081   }
0082   // Create the element and the surface
0083 
0084   auto detectorElement =
0085       GeoModelDetectorElement::createDetectorElement<CylinderSurface>(
0086           geoPV, cylinderBounds, transform, outerRadius - innerRadius);
0087   auto surface = detectorElement->surface().getSharedPtr();
0088   return std::make_tuple(detectorElement, surface);
0089 }