Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-15 08:05:33

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