Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:42

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 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/CylinderLayer.hpp"
0013 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/TrackingGeometry.hpp"
0016 #include "Acts/Geometry/TrackingVolume.hpp"
0017 #include "Acts/Surfaces/CylinderBounds.hpp"
0018 #include "Acts/Surfaces/CylinderSurface.hpp"
0019 #include "Acts/Utilities/BinUtility.hpp"
0020 #include "Acts/Utilities/BinnedArrayXD.hpp"
0021 
0022 namespace Acts {
0023 
0024 ///  helper function to create a cylinder
0025 TrackingVolumePtr constructCylinderVolume(
0026     const GeometryContext& gctx, double surfaceHalfLengthZ, double surfaceR,
0027     double surfaceRstagger, double surfaceZoverlap, double layerEnvelope,
0028     double volumeEnvelope, double innerVolumeR, double outerVolumeR,
0029     const std::string& name) {
0030   ///  the surface transforms
0031   auto sfnPosition = Vector3(0., 0., -3 * surfaceHalfLengthZ - surfaceZoverlap);
0032   auto sfnTransform = Transform3(Translation3(sfnPosition));
0033   auto sfcTransform = Transform3::Identity();
0034   auto sfpPosition = Vector3(0., 0., 3 * surfaceHalfLengthZ - surfaceZoverlap);
0035   auto sfpTransform = Transform3(Translation3(sfpPosition));
0036   ///  the surfaces
0037   auto sfnBounds = std::make_shared<CylinderBounds>(
0038       surfaceR - 0.5 * surfaceRstagger, surfaceHalfLengthZ);
0039   auto sfn = Surface::makeShared<CylinderSurface>(sfnTransform, sfnBounds);
0040   auto sfcBounds = std::make_shared<CylinderBounds>(
0041       surfaceR + 0.5 * surfaceRstagger, surfaceHalfLengthZ);
0042   auto sfc = Surface::makeShared<CylinderSurface>(sfcTransform, sfcBounds);
0043   auto sfpBounds = std::make_shared<CylinderBounds>(
0044       surfaceR - 0.5 * surfaceRstagger, surfaceHalfLengthZ);
0045   auto sfp = Surface::makeShared<CylinderSurface>(sfpTransform, sfpBounds);
0046 
0047   ///  prepare the surfaces
0048 
0049   ///  make the binned array
0050   double bUmin = sfnPosition.z() - surfaceHalfLengthZ;
0051   double bUmax = sfpPosition.z() + surfaceHalfLengthZ;
0052 
0053   std::vector<std::shared_ptr<const Surface>> surfaces_only = {{sfn, sfc, sfp}};
0054   std::vector<const Surface*> surfaces_only_raw = {
0055       {sfn.get(), sfc.get(), sfp.get()}};
0056 
0057   Axis<AxisType::Equidistant, AxisBoundaryType::Bound> axis(
0058       bUmin, bUmax, surfaces_only.size());
0059   auto g2l = [](const Vector3& glob) {
0060     return std::array<double, 1>({{glob.z()}});
0061   };
0062   auto l2g = [](const std::array<double, 1>& loc) {
0063     return Vector3(0, 0, loc[0]);
0064   };
0065   auto sl = std::make_unique<SurfaceArray::SurfaceGridLookup<decltype(axis)>>(
0066       g2l, l2g, std::make_tuple(axis));
0067   sl->fill(gctx, surfaces_only_raw);
0068   auto bArray = std::make_unique<SurfaceArray>(std::move(sl), surfaces_only);
0069 
0070   ///  now create the Layer
0071   auto layer0bounds = std::make_shared<const CylinderBounds>(surfaceR, bUmax);
0072   auto layer0 = CylinderLayer::create(Transform3::Identity(), layer0bounds,
0073                                       std::move(bArray),
0074                                       surfaceRstagger + 2 * layerEnvelope);
0075   std::unique_ptr<const LayerArray> layerArray =
0076       std::make_unique<const BinnedArrayXD<LayerPtr>>(layer0);
0077 
0078   ///  create the volume
0079   auto volumeBounds = std::make_shared<CylinderVolumeBounds>(
0080       innerVolumeR, outerVolumeR, bUmax + volumeEnvelope);
0081 
0082   TrackingVolumePtr volume = std::make_shared<TrackingVolume>(
0083       Transform3::Identity(), volumeBounds, nullptr, std::move(layerArray),
0084       nullptr, MutableTrackingVolumeVector{}, name);
0085   ///  return the volume
0086   return volume;
0087 }
0088 
0089 ///  helper function to create a container
0090 MutableTrackingVolumePtr constructContainerVolume(const GeometryContext& gctx,
0091                                                   TrackingVolumePtr iVolume,
0092                                                   TrackingVolumePtr oVolume,
0093                                                   double hVolumeR,
0094                                                   double hVolumeHalflength,
0095                                                   const std::string& name) {
0096   ///  create the volume array
0097   using VAP = std::pair<TrackingVolumePtr, Vector3>;
0098   std::vector<VAP> volumes = {
0099       {iVolume, iVolume->referencePosition(gctx, AxisDirection::AxisR)},
0100       {oVolume, oVolume->referencePosition(gctx, AxisDirection::AxisR)}};
0101   ///  the bounds for the container
0102   auto hVolumeBounds =
0103       std::make_shared<CylinderVolumeBounds>(0., hVolumeR, hVolumeHalflength);
0104   ///  create the BinUtility & the BinnedArray
0105   auto vUtility = std::make_unique<const BinUtility>(
0106       volumes.size(), 0., hVolumeR, open, AxisDirection::AxisR);
0107   std::shared_ptr<const TrackingVolumeArray> vArray =
0108       std::make_shared<const BinnedArrayXD<TrackingVolumePtr>>(
0109           volumes, std::move(vUtility));
0110   ///  create the container volume
0111   auto hVolume = std::make_shared<TrackingVolume>(
0112       Transform3::Identity(), hVolumeBounds, nullptr, nullptr, vArray,
0113       MutableTrackingVolumeVector{}, name);
0114   // return the container
0115   return hVolume;
0116 }
0117 }  // namespace Acts