Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Plugins/GeoModel/src/detail/GeoTubeConverter.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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