Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:15:18

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